Skip to content

Instantly share code, notes, and snippets.

View missinglink's full-sized avatar

Peter Johnson missinglink

View GitHub Profile
@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 / 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 = {},
t71wuqpBQYxr0twg8LsTE+X5LgXbI/3mPOMtBGHgwbiqhTkBhHcY9ULvjS/wsQHDKmYm4m/+g/VSA8KuYzm0oGRI6G1NRDKaJMvHs30joPsPa7gg/jgGcOY977Yy6zyhvGBtjFanxQVPQLClVWLqLdE/pxFj+pVQ5YLNzTjHCGE3lMHqsMxXyoLQyVtht0UWbzS27eR6TESrYnvRLDwBOibQWjdo1gJ61asjKFpteS4=
@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" : [
@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 / 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 / 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 / pelias.conf
Created July 7, 2014 17:17
Pelias Upstart Script
#!upstart
description "pelias server"
author "wiz@wiz.co.nz"
start on startup
stop on shutdown
script
export HOME="/var/www/pelias-webview"
export NODE_ENV="production"
@missinglink
missinglink / responder.js
Last active August 29, 2015 14:04
expressjs responders for JSON, CORS and JSONP
// send a reply that is capable of JSON, CORS and JSONP
function cors( req, res, obj ){
res.header('Charset','utf8');
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET');
res.header('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.header('Access-Control-Allow-Credentials', true);
// jsonp
if( req.query && req.query.callback ){
@missinglink
missinglink / esdocs.js
Created July 23, 2014 12:11
Crawl es documentation for curl syntax errors
/** Crawl documentation for curl syntax errors **/
// Requires nodejs and npm
// @see: https://github.com/isaacs/nave for easy installation
// @install nodejs: [sudo] bash nave.sh usemain stable
// @ref: https://github.com/missinglink/huntsman
// Usage:
// $> npm install huntsman
// $> node esdocs.js