Skip to content

Instantly share code, notes, and snippets.

> make PKG_CONFIG_PATH=/home/migurski/src/simple-tiles/out/lib/pkgconfig test
cd src && make all
make[1]: Entering directory `/home/migurski/src/simple-tiles/src'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/migurski/src/simple-tiles/src'
cd test && make test
make[1]: Entering directory `/home/migurski/src/simple-tiles/test'
cd ../data && make && cd ../test
make[2]: Entering directory `/home/migurski/src/simple-tiles/data'
@migurski
migurski / polygonize.py
Created April 25, 2012 22:16
Polygonize a bag of lines
from sys import argv
from shapely.ops import polygonize
from shapely.geometry import asShape, LineString
import json
if __name__ == '__main__':
input = argv[1]
input = json.load(open(input))
@migurski
migurski / lambert.js
Created May 14, 2012 03:29
Lambert projection for Modest Maps
var LambertProjection = function(lat0, lon0, lat1, lat2, xmin, ymin, xmax, ymax)
{
var pi = Math.PI, ln = Math.log, pow = Math.pow,
sin = Math.sin, cos = Math.cos, tan = Math.tan,
atan = Math.atan, sqrt = Math.sqrt;
function sec(t) { return 1 / cos(t); }
function cot(t) { return 1 / tan(t); }
function deg2rad(deg) { return pi * deg / 180; }
@migurski
migurski / gunicorn-slayer.py
Created June 21, 2012 06:41
Gunicorn Slayer
from sys import argv
from time import time
from glob import glob
from os import stat, kill, getuid
from os.path import basename, dirname, join
from datetime import datetime
from random import choice
from signal import SIGTERM
if __name__ == '__main__':
@migurski
migurski / Lambert.py
Created July 5, 2012 18:16
Lambert Conformal Conic implementation with US-specific transformation
"""
>>> usa = USA()
>>> loc = Location(48.38544, -124.72916)
>>> pt = usa.locationProj(loc)
>>> abs(-2109470 - pt.x) < 1
True
>>> abs( 1532790 - pt.y) < 1
True
@migurski
migurski / image-queue.js
Created July 25, 2012 20:33
Image Queue
function ImageQueue()
{
var closedRequests = {},
queueList = [],
queueByHref = {},
numOpenRequests = 0,
openRequests = {};
function addImage(href, onload)
{
@migurski
migurski / remotefile.py
Created August 1, 2012 18:44
RemoteFileObject is a simple mapping from HTTP Range headers to a local file-like object
from time import time
from urlparse import urlparse
from httplib import HTTPConnection
from os.path import basename
from cStringIO import StringIO
from datetime import timedelta
from os import SEEK_SET, SEEK_CUR, SEEK_END
class RemoteFileObject:
""" Implement enough of this to be useful:
@migurski
migurski / measure-sizes.py
Created August 3, 2012 21:15
Two scripts for creating heatmap of OSM data size, e.g. https://tiles.mapbox.com/migurski/map/osmsize
from sys import argv, stdout, stderr
from subprocess import Popen
from os import stat, unlink
from math import log, ceil
from stat import ST_SIZE
from time import time
from ModestMaps.OpenStreetMap import Provider
from ModestMaps.Core import Coordinate
@migurski
migurski / gray-scott.py
Created September 9, 2012 02:21
Adaptation of Nicolas P. Rougier’s Gray-Scott implementation with the Glumpy dependencies removed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright INRIA
# Contributors: Nicolas P. Rougier ([email protected])
#
# DANA is a computing framework for the simulation of distributed,
# asynchronous, numerical and adaptive models.
#
# This software is governed by the CeCILL license under French law and abiding
@migurski
migurski / merge-geojsons.py
Created September 21, 2012 03:43
Merge multiple GeoJSON files into one
from json import load, JSONEncoder
from optparse import OptionParser
from re import compile
float_pat = compile(r'^-?\d+\.\d+(e-?\d+)?$')
charfloat_pat = compile(r'^[\[,\,]-?\d+\.\d+(e-?\d+)?$')
parser = OptionParser(usage="""%prog [options]
Group multiple GeoJSON files into one output file.