Skip to content

Instantly share code, notes, and snippets.

@migurski
migurski / queries.pgsql
Last active December 20, 2015 07:49
Queries to convert TIGER edges data to labeled address ranges. See: http://mike.teczno.com/img/tiger-ranges.png
DROP TABLE IF EXISTS tiger_2012_edges_102008;
DROP TABLE IF EXISTS tiger_2012_ends_102008;
CREATE TABLE tiger_2012_edges_102008
AS
(
SELECT statefp, countyfp, mtfcc, fullname,
fromadd, toadd, zip, "offset",
--
@migurski
migurski / guest-linux-interfaces.txt
Created July 1, 2013 22:25
/etc/network/interfaces for guest and host Linux servers, based on LXC guide at http://teczno.com/s/bhh.
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
dns-nameservers 8.8.8.8
'''
>>> arc = Projection()
Geographic to Albers:
>>> p = arc.locationProj(Location(23, -96)); '%.2f %.2f' % (abs(p.x), abs(p.y))
'0.00 0.00'
@migurski
migurski / deimgify.py
Last active December 17, 2015 13:29
Store sparse bundle disk images as a series of 24 bit losslessly-encoded PNG images. Let Flickr’s 1TB of storage hold them for you.
#!/usr/bin/env python
''' Convert a series of PNG images to a sparse bundle disk image.
Image file names are passed in as command line arguments.
Example:
ls *.png | xargs deimgify.py
Output:
Goodtimes.sparsebundle/Info.bckup
@migurski
migurski / wkb.py
Last active December 14, 2015 18:49
Reduce floating point precision of WKB geometries for better zlib compression.
''' Shapeless handling of WKB geometries.
Use approximate_wkb() to copy an approximate well-known binary representation of
a geometry. Along the way, reduce precision of double floating point coordinates
by replacing their three least-significant bytes with nulls. The resulting WKB
will match the original at up to 26 bits of precision, close enough for
spherical mercator zoom 18 street scale geography.
Reduced-precision WKB geometries will compress as much as 50% smaller with zlib.
@migurski
migurski / README.md
Last active April 28, 2025 09:23
GL-Solar, Rainbow Road edition
@migurski
migurski / ops.py
Last active December 14, 2015 17:59
Transform function for Shapely.
'''
>>> from shapely.geometry import *
>>> coll0 = GeometryCollection()
>>> coll1 = transform(coll0, lambda (x, y): (x+1, y+1))
>>> print coll1 # doctest: +ELLIPSIS
GEOMETRYCOLLECTION EMPTY
>>> point0 = Point(0, 0)
>>> point1 = transform(point0, lambda (x, y): (x+1, y+1))
@migurski
migurski / README.md
Last active December 14, 2015 07:39
GL-Solar, false-color edition
@migurski
migurski / gl-boilerplate.js
Created February 26, 2013 07:05
WebGL GeoJSON tile rendering II
function linkProgram(gl, vsource, fsource)
{
if(gl == undefined)
{
alert("Your browser does not support WebGL, try Google Chrome? Sorry.");
throw "Your browser does not support WebGL, try Google Chrome? Sorry.";
}
var program = gl.createProgram(),
vshader = createShader(gl, vsource, gl.VERTEX_SHADER),
@migurski
migurski / gl-boilerplate.js
Created February 24, 2013 18:32
WebGL GeoJSON tile rendering
function linkProgram(gl, vsource, fsource)
{
if(gl == undefined)
{
alert("Your browser does not support WebGL, try Google Chrome? Sorry.");
throw "Your browser does not support WebGL, try Google Chrome? Sorry.";
}
var program = gl.createProgram(),
vshader = createShader(gl, vsource, gl.VERTEX_SHADER),