Skip to content

Instantly share code, notes, and snippets.

View missinglink's full-sized avatar

Peter Johnson missinglink

View GitHub Profile
@missinglink
missinglink / build.sh
Last active December 11, 2016 04:24
Pelias Build Script
#!/bin/bash
# Dependencies
for dep in 'git' 'wget' 'curl'; do
if [ ! `which $dep` ]; then
echo "$dep required, please install it and try again";
exit 1;
fi
done
@missinglink
missinglink / comparison.js
Last active August 29, 2015 14:03
osm-pbf-parser / osm-read comparison
// $> npm install osm-pbf-parser osm-read through2
// $> wget https://s3.amazonaws.com/metro-extracts.mapzen.com/abuja.osm.pbf
var filepath = __dirname + '/abuja.osm.pbf';
var counts = {
'osm-pbf-parser': {
node: 0, way: 0, relation: 0
},
'osm-read': {
@missinglink
missinglink / quadtree.js
Last active August 29, 2015 14:03
QuadTree precision calculator
// Requires nodejs and npm
// @see: https://github.com/isaacs/nave for easy installation
// @install nodejs: [sudo] bash nave.sh usemain stable
// Usage:
// $> npm install quadtree geolib
// $> node quadtree.js
var quadtree = require('quadtree');
var geolib = require('geolib');
@missinglink
missinglink / geo-query.json
Created June 26, 2014 11:19
Geo search for: -0.058202, 51.53254
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool" : {
"must" : [
t71wuqpBQYxr0twg8LsTE+X5LgXbI/3mPOMtBGHgwbiqhTkBhHcY9ULvjS/wsQHDKmYm4m/+g/VSA8KuYzm0oGRI6G1NRDKaJMvHs30joPsPa7gg/jgGcOY977Yy6zyhvGBtjFanxQVPQLClVWLqLdE/pxFj+pVQ5YLNzTjHCGE3lMHqsMxXyoLQyVtht0UWbzS27eR6TESrYnvRLDwBOibQWjdo1gJ61asjKFpteS4=
@missinglink
missinglink / validate.js
Last active August 29, 2015 14:02
validate pdf documents
// INSTALL DEPENDENCIES
// $> npm install osm-read
// USAGE
// $> node validate.js auckland.osm.pbf
var osmread = require('osm-read');
var nodeIds = {},
@missinglink
missinglink / ipfind.sh
Created December 13, 2013 11:45
Find all occurrences of IP addresses & the string 'localhost' in a given directory. (excluding the 'node_modules' directory)
#!/bin/bash
find . | grep -v node_modules | xargs grep -P '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|localhost' 2>/dev/null
@missinglink
missinglink / google-analytics-node.js
Created December 5, 2013 18:24
An example of how to generate Google Analytics reports from node.js (with custom dimensions).
var GA = require('googleanalytics'),
Table = require('cli-table'),
util = require('util');
// API client.
// You may need to enable API access to analytics for your account
// here: https://code.google.com/apis/console
var ga = new GA.GA({
"user": "myaccount@gmail.com",
@missinglink
missinglink / foo.sh
Last active December 30, 2015 08:59
#!/bin/bash
echo '--- 1 ---'
ls -1 | cowsay
function pause {
read -p "$*"
}
function multi {
#!/bin/bash
function stdout {
echo -e "\e[32m$@\e[0m";
}
function stderr {
echo -e "\e[31m$@\e[0m" 1>&2;
}