This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import cairo | |
import bezier | |
import numpy | |
import itertools | |
# https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#path | |
paths = [ | |
'''M500.04,309.630308 C817.696558,309.630308 931.823304,522.666719 936.58,532.180112 L936.58,549.295931 C931.824662,557.855539 817.696558,770.894667 500.04,770.894667 C182.383442,770.894667 68.2566964,557.858256 63.5,548.344863 L63.5,531.229044 C68.2553377,522.669436 182.383442,309.630308 500.04,309.630308 Z M520.015815,422.809043 L520.015815,422.806648 C524.766058,399.02996 514.304315,374.305261 494.342086,360.983862 L494.342086,360.035189 C475.315641,360.991352 456.295139,367.645088 440.12784,378.107171 C424.909061,388.570612 412.543655,402.840022 403.985575,419.955841 C407.793242,444.686993 425.863525,464.656354 450.589583,469.413051 C482.924181,476.067127 513.355115,455.143641 520.015815,422.809043 Z M357.379869,438.976342 L357.373076,438.975833 C364.033945,404.737401 383.053598,375.254308 409.690282,354.330822 C375.451851,359.086159 344.064924,367.644748 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import random | |
import copy | |
import argparse | |
import oauth2client.service_account | |
import apiclient.discovery | |
parser = argparse.ArgumentParser() | |
parser.add_argument('players') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |