Skip to content

Instantly share code, notes, and snippets.

.../~: 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
@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'