Skip to content

Instantly share code, notes, and snippets.

💭
Drinking tea

Matt Walker walkermatt

💭
Drinking tea
Block or report user

Report or block walkermatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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
@walkermatt
walkermatt / debounce.py
Created Jun 4, 2012
A debounce function decorator in Python similar to the one in underscore.js, tested with 2.7
View debounce.py
from threading import Timer
def debounce(wait):
""" Decorator that will postpone a functions
execution until after wait seconds
have elapsed since the last time it was invoked. """
def decorator(fn):
def debounced(*args, **kwargs):
def call_it():
@walkermatt
walkermatt / osgb_map.js
Created Jul 2, 2012
Leaflet Map using Proj4Leaflet to display a projected TMS base map from MapProxy
View osgb_map.js
// Bounding box of our TMS that define our area of interest
var bbox = [-600000, -300000, 1300000, 1600000];
// Resolutions of our TMS that the tiles will be displayed at calculated so
// that at resolution 0 the bounds fit one 256x256 tile: (maxx - minx)/256
var res = [7421.875, 3710.9375, 1855.46875, 927.734375];
// Define the Proj4Leaflet coordinate reference system base on British National Grid
var crs = L.CRS.proj4js(
'EPSG:27700',
@walkermatt
walkermatt / script.js
Created Jul 5, 2012 — forked from nextstopsun/script.js
Proj4Leaflet 102012 projection test
View script.js
var res = [
140000.0000000000,
70000.0000000000,
35000.0000000000,
17500.0000000000,
8750.0000000000,
4375.0000000000,
2187.5000000000,
1093.7500000000,
546.8750000000,
@walkermatt
walkermatt / prep_policekml.py
Created Jul 29, 2012
Simple Loader prep class to import KML police.uk neighbourhood boundaries
View prep_policekml.py
"""
A class used to manipulate Police KML data, used with prepgml4ogr.py.
"""
import os
from lxml import etree
class prep_kml():
def __init__(self, inputfile):
View wfs2postgis.sh
# Example of downloading all data from a GeoServer WFS server
# and loading it into a PostGIS database. Use with caution
# as you could put a lot of load on someone's server if they
# host a lot of data which might make them sad.
# In response to: http://underdark.wordpress.com/2012/09/26/wfs-to-postgis-in-3-steps/
BASEURL="http://data.wien.gv.at/daten/geoserver/ows?service=WFS&version=1.1.0"
for LAYERNAME in `wget -qO- $BASEURL"&request=GetCapabilities" | xpath -q -e "//FeatureType/Name/text()"` ; do
PARTS=(${LAYERNAME//:/ })
@walkermatt
walkermatt / run_loader.bat
Last active Dec 10, 2015
DOS batch file to run Loader (https://github.com/AstunTechnology/Loader) on Windows using GDAL and python provided by OSGeo4W (installation of which is documented on the wiki)
View run_loader.bat
rem DOS batch file to run Loader on Windows using GDAL and python
rem provided by OSGeo4W. As this script requires the OSGeo4W environment
rem to run it must be passed as an argument to OSGeo4W.bat like so:
rem call C:\OSGeo4W\OSGeo4W.bat C:\Temp\Loader\run_loader.bat
rem Change to the folder that this script is in (assumes this script is
rem in the same folder as the Loader readme)
cd /D %~dp0
rem change to the python directory
@walkermatt
walkermatt / Gazetteer.vrt
Created Feb 6, 2013
Example AstunTechnology / OpenDataLoader (https://github.com/AstunTechnology/OpenDataLoader) config for OS 50k Gazetteer. OSOpenLoader.config and Table.csv should live in the root of the OpenDataLoader directory. Gazetteer.vrt should go in the source Gazetteer directory.
View Gazetteer.vrt
<OGRVRTDataSource>
<OGRVRTLayer name="50kgaz2012_new">
<SrcDataSource>/home/matt/Downloads/gaz50k_gb/Gazetteer/50kgaz2012_new.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>EPSG:27700</LayerSRS>
<GeometryField encoding="PointFromColumns" x="EAST" y="NORTH"/>
</OGRVRTLayer>
</OGRVRTDataSource>
You can’t perform that action at this time.