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 / Mercator.ipynb
Last active Jan 8, 2019
Mercator Projection with GDAL
View Mercator.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@migurski
migurski / VA.geojson
Created Nov 1, 2018
Sample Virginia PlanScore model tiles
View VA.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@migurski
migurski / 13-2333-3172.geojson
Created Nov 1, 2018
Sample Virginia PlanScore model tile 13/2333/3172
View 13-2333-3172.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@migurski
migurski / 10-285-394.geojson
Created Nov 1, 2018
Sample Virginia PlanScore model tile 10/285/394
View 10-285-394.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@migurski
migurski / brooklynt.sql
Last active Jul 26, 2018
Use Brooklyn Integers directly in Postgres
View brooklynt.sql
--
-- Table of available integers with a boolean column for when they're used up.
--
DROP TABLE IF EXISTS brooklyn_integers;
CREATE TABLE brooklyn_integers (used BOOLEAN DEFAULT false NOT NULL, value BIGINT NOT NULL);
CREATE INDEX brooklyn_integers_used ON brooklyn_integers (used);
CREATE UNIQUE INDEX brooklyn_integers_value ON brooklyn_integers (value);
--
-- Request a single unused integer and mark it used.
@migurski
migurski / openelections-table.py
Created Dec 7, 2017
Convert WI ward-level result CSVs from OpenElections to tabular format
View openelections-table.py
''' Convert ward-level result CSVs from OpenElections to tabular format.
'''
import gzip, csv, collections, sys, itertools
def key1(row):
''' Outer key is the county and ward.
'''
return row['county'], row['ward']
def key2(row):
@migurski
migurski / intersect-areas.py
Created Oct 29, 2017
Intersect North Carolina voting precincts with Census tracts to get selected area-weighted race, income, and education statistics
View intersect-areas.py
import psycopg2, csv, math
with psycopg2.connect('postgres:///redistrict_nc') as conn:
with conn.cursor() as db:
for year in ['2016', '2014', '2012']:
with open(f'{year}-4.txt') as in_file, open(f'{year}-5.txt', 'w') as out_file:
in_rows = csv.DictReader(in_file, dialect='excel-tab')
out_fields = in_rows.fieldnames + ['Non-Hispanic White',
'Non-Hispanic White, Error', 'College', 'College, Error',
@migurski
migurski / openelections-table.py
Last active Dec 7, 2017
Convert NC precinct-level result CSVs from OpenElections to tabular format
View openelections-table.py
''' Convert precinct-level result CSVs from OpenElections to tabular format.
'''
import gzip, csv, collections, sys, itertools
def key1(row):
''' Outer key is the county and precinct.
'''
return row['parent_jurisdiction'], row['jurisdiction']
def key2(row):
@migurski
migurski / make-gpwv4-us.py
Created Apr 28, 2017
Script to bake gridded U.S. population based on ACS 5-year data
View make-gpwv4-us.py
from osgeo import ogr
import requests, zipfile, io, tempfile, shutil, os, sys, csv, math, collections
state_codes = {
'01': 'AL', '31': 'NE', '02': 'AK', '32': 'NV', '04': 'AZ', '33': 'NH',
'05': 'AR', '34': 'NJ', '06': 'CA', '35': 'NM', '08': 'CO', '36': 'NY',
'09': 'CT', '37': 'NC', '10': 'DE', '38': 'ND', '11': 'DC', '39': 'OH',
'12': 'FL', '40': 'OK', '13': 'GA', '41': 'OR', '15': 'HI', '42': 'PA',
'16': 'ID', '72': 'PR', '17': 'IL', '44': 'RI', '18': 'IN', '45': 'SC',
'19': 'IA', '46': 'SD', '20': 'KS', '47': 'TN', '21': 'KY', '48': 'TX',
View keybase.md

Keybase proof

I hereby claim:

  • I am migurski on github.
  • I am migurski (https://keybase.io/migurski) on keybase.
  • I have a public key whose fingerprint is 2D09 CC12 CFAF 908F 40D2 A4BC 6658 C0CD 757E 9D53

To claim this, I am signing this object:

You can’t perform that action at this time.