Skip to content

Instantly share code, notes, and snippets.

Michal Migurski migurski

Block or report user

Report or block migurski

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
@migurski
migurski / check-internal-links.py
Created Jan 30, 2014
Scripts used in the creation of the new Code for America website.
View check-internal-links.py
@migurski
migurski / well-known-status.py
Last active Aug 29, 2015
Engine Light status endpoint script for www.codeforamerica.org
View well-known-status.py
#!/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 / conform.py
Last active Aug 29, 2015
Python wrapper for openaddresses-conform
View conform.py
''' 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
View 1-preinstall.txt
.../~: 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.
View data.acgov.org.txt
% 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
@migurski
migurski / guess.py
Created Jan 28, 2015
guess reason for OpenAddresses failure
View guess.py
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 / squares-map.js
Created Mar 3, 2015
Compiled TypeScript sample
View squares-map.js
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 / index.html
Last active Aug 29, 2015
Grabbing census tracts around Oakland, messing with Turf
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Untitled</title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js" charset="utf-8"></script>
<script src="modestmaps.min.js" charset="utf-8"></script>
<script src="turf.min.js" charset="utf-8"></script>
</head>
<body>
@migurski
migurski / stats2runs.py
Created Jul 23, 2015
Converting from OpenAddresses stats table to runs and sets table
View stats2runs.py
from __future__ import print_function
from os import environ
from psycopg2 import connect
from psycopg2.extras import DictCursor, Json
from itertools import count, groupby
from datetime import timedelta, datetime
from operator import itemgetter
from uritemplate import expand
from dateutil.parser import parse
View gist:1854149
> 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'
You can’t perform that action at this time.