Skip to content

Instantly share code, notes, and snippets.

@migurski
migurski / squares-map.js
Created March 3, 2015 04:50
Compiled TypeScript sample
var Map = (function () {
function Map(parent, template, proj, loc, zoom) {
this.selection = d3.select(parent);
this.loaded_tiles = {
};
this.template = template;
this.parent = parent;
var size = Mouse.element_size(this.parent), coord = proj.locationCoordinate(loc).zoomTo(zoom);
this.grid = new Grid.Grid(size.x, size.y, coord, 3);
this.projection = proj;
@migurski
migurski / guess.py
Created January 28, 2015 18:32
guess reason for OpenAddresses failure
def guess_reason(log):
'''
'''
if 'JobTimeoutException' in log:
return 'took too long'
elif 'DownloadError: 404 response' in log:
return 'missing source'
elif 'Source says to skip' in log:
return 'skipped'
elif 'Invalid number of points in LinearRing' in log:
@migurski
migurski / data.acgov.org.txt
Created January 13, 2015 01:53
Socrata HTTP Gripes
% curl -sIL 'https://data.acgov.org/api/geospatial/8e4s-7f4v?method=export&format=Original'
HTTP/1.1 405 Method Not Allowed
Server: nginx
Date: Tue, 13 Jan 2015 01:52:36 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Error-Code: method_not_allowed
X-Error-Message: HEAD not allowed
X-Socrata-Region: production
.../~: Sleeper% cd /tmp
...//tmp: Sleeper% mkdir vn
...//tmp: Sleeper% rmdir vn
...//tmp: Sleeper% mkdir van
...//tmp: Sleeper% virtualenv van
New python executable in van/bin/python
Installing setuptools, pip...done.
...//tmp: Sleeper% source van/bin/activate.csh
[van] ...//tmp: Sleeper% pip install https://github.com/openvenues/address_normalizer
You are using pip version 6.0.3, however version 6.0.6 is available.
# coding=utf-8
''' Guess at ISO-3166-2 admin 1 codes for Natural Earth data.
Uses subdivision names from Ola Holmström’s iso-3166-2:
https://github.com/olahol/iso-3166-2.js/blob/master/data.csv
ne_10m_admin_1_states_provinces.csv is a direct CSV
export of Natural Earth admin-1 data as of Nov 8, 2012:
https://github.com/nvkelso/natural-earth-vector/tree/c97860331/10m_cultural
@migurski
migurski / conform.py
Last active August 29, 2015 14:07
Python wrapper for openaddresses-conform
''' Python wrapper for openaddresses-conform.
Looks in /var/opt/openaddresses-conform for an index.js to run. Generates
all data in a temporary working directory, and does not use cached files.
'''
from subprocess import Popen
from tempfile import mkdtemp
from os.path import realpath, join
from shutil import move, rmtree
@migurski
migurski / well-known-status.py
Last active August 29, 2015 13:56
Engine Light status endpoint script for www.codeforamerica.org
#!/usr/bin/env python
from json import dumps
from time import time
try:
lib_state = open('/var/run/library-state.txt').read().strip()
if lib_state != 'OK':
app_state = 'Library: ' + lib_state
else:
@migurski
migurski / check-internal-links.py
Created January 30, 2014 06:48
Scripts used in the creation of the new Code for America website.
@migurski
migurski / brigades-min.json
Created January 24, 2014 21:29
Brigades JSON (minimal)
[
{
"id": 32,
"lat": 61.2180556,
"lon": -149.9002778,
"meetup_url": "",
"name": "Alaska Brigade"
},
{
"id": 75,
@migurski
migurski / counties.txt
Last active January 2, 2016 21:09
Census Places
Summary Level Geographic Component State FIPS Place FIPS County FIPS Tract Zip Block Name Latitude Longitude
050 00 01 001 Autauga County 32.523283 -86.577176
050 00 01 003 Baldwin County 30.592781 -87.748260
050 00 01 005 Barbour County 31.856515 -85.331312
050 00 01 007 Bibb County 33.040054 -87.123243
050 00 01 009 Blount County 33.978461 -86.554768
050 00 01 011 Bullock County 32.098285 -85.704915
050 00 01 013 Butler County 31.735884 -86.662232
050 00 01 015 Calhoun County 33.741989 -85.817544
050 00 01 017 Chambers County 32.891233 -85.288745