Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Drinking tea

Matt Walker walkermatt

💭
Drinking tea
View GitHub Profile
@walkermatt
walkermatt / map_reduce.js
Last active Aug 29, 2015
Toy map / reduce functions in JavaScript
View map_reduce.js
// Define reduce, fn and list are required, init is an optional initial value
// which will be passed to fn with the first item in list
function reduce(fn, list, init) {
var val = init,
start = 0;
if (val === undefined) {
if (list.length > 1) {
val = list[0];
start = 1;
} else {
@walkermatt
walkermatt / loader_parallel.sh
Last active Aug 29, 2015
GNU Parallel all the things!
View loader_parallel.sh
find /var/data/osmm/ -type f -print0 | \
parallel -0 python loader.py loader.config "src_dir={}"
@walkermatt
walkermatt / osgis.geojson
Last active Aug 29, 2015
Location map for OSGIS 2014
View osgis.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@walkermatt
walkermatt / osgeolive.sh
Last active Aug 29, 2015
Set up OSGeo Live Xubuntu instance for OL3 & Leaflet workshop
View osgeolive.sh
setxkbmap gb && sudo apt-get install git-core gedit && cd && git clone https://github.com/AstunTechnology/osgis-ol3-leaflet.git ; cd osgis-ol3-leaflet ; gedit ol3/ol3.js & firefox http://astuntechnology.github.io/osgis-ol3-leaflet/ &
View map2.js
// Extent of the map in units of the projection (these match our base map)
var extent = [-3276800, -3276800, 3276800, 3276800];
// Fixed resolutions to display the map at (pixels per ground unit (meters when
// the projection is British National Grid))
var resolutions = [1600,800,400,200,100,50,25,10,5,2.5,1,0.5,0.25,0.125,0.0625];
// Define WGS84 projection (copied from http://epsg.io/3857.js)
proj4.defs("EPSG:3857","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs");
View create_index.sql
SELECT 'CREATE INDEX ' || quote_ident(f_table_name || '_geom_idx') || ' ON ' || quote_ident(f_table_schema) || '.' || quote_ident(f_table_name) || ' USING GIST (' || quote_ident(f_geometry_column) || ');' AS SQL
FROM geometry_columns
WHERE f_table_name IN ('topographicarea',
'topographicline');
View gist:7594cf5e82a70f2c3fd7
function hexToRgb(hex) {
return 'rgb(' + hex.slice(1).match(/../g).map(c => parseInt(c, 16)) +')'
}
@walkermatt
walkermatt / gist:1383021
Created Nov 21, 2011 — forked from eriwen/gist:187610
Pythonic site monitor
View gist:1383021
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = 'you@gmail.com'
@walkermatt
walkermatt / disaggregate_postgis_complex_contents.sql
Created Nov 25, 2011
Disaggregate MultiLineStrings using ST_Dump PostGIS
View disaggregate_postgis_complex_contents.sql
SELECT *, ST_GeometryType(geom) as geom_type, ST_AsEWKT(geom) as geom_wkt from complex;
@walkermatt
walkermatt / loader.config
Created Jun 4, 2012
Loader config for AddressBase Plus on Windows into PostgreSQL
View loader.config
src_dir=C:\GML_Loader\data\import
out_dir=C:\loader_data\export
tmp_dir=C:\loader_data\temp
ogr_cmd=ogr2ogr -append -skipfailures -f PostgreSQL PG:'dbname=test active_schema=public host=localhost port=5432 user=postgres password=******' $file_path
prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_addressbase
You can’t perform that action at this time.