Skip to content

Instantly share code, notes, and snippets.

import csv
import datetime
import re
from urllib.parse import unquote
from utils import load_data, save_data
from SPARQLWrapper import SPARQLWrapper, JSON
def run():
bycoffe / PA-remedial.drf
Created February 20, 2018 20:40
Court-drawn Pennsylvania congressional map for use in Dave's Redistricting App
<?xml version="1.0" encoding="utf-8"?>
<davesRedistrictingFile version="2.2">
<state id="38" numVoteDists="9256" useVotingDistricts="True" useTestData="False" mapMode="1" mapAerialLabels="False" zoomLevel="8" X="-76.1513" Y="40.8821" useNewPopEst="False" showOldCDs="False" showNewCDLabels="False" showCounties="True" showCountyLabels="False" showVotingDistricts="True" showDistLines="True" showCityLines="False" showPlaces="False" showTowns="False" is2010="True" useUpdated="False" curScenario="cd" curScenarioCntyIndex="0" showOldCDLabels="True" addCDTextToLabels="False" showVTDToolTips="True" dontLoadOldLDs="False" dontLoadPlaces="False" dontKeepVAP="False">
<scenario kind="cd" numDists="18" currentDist="0" cntyInx="0" numAreaMaps="0"/>
<cdcolor id="11" color="F5DEB3" name="Wheat"/>
<cdcolor id="18" color="7FFF00" name="Chartreuse"/>
<voteDist geoID2="4200140" cd="13"/>
<voteDist geoID2="4200110" cd="13"/>
<voteDist geoID2="42001260" cd="13"/>
<voteDist geoID2="42001480" cd="13"/>
bioguide name birth
B000226 Richard Bassett (politician) 1745-04-02
B000546 Theodorick Bland (congressman) 1741-03-21
B001086 Aedanus Burke 1743-06-16
C000187 Daniel Carroll 1730-07-22
C000538 George Clymer 1739-03-16
C000710 Benjamin Contee 1755-01-01
D000013 Tristram Dalton 1738-05-28
E000155 Jonathan Elmer 1745-11-29
F000100 William Few 1748-06-08
import csv
import datetime
import itertools
from utils import load_data, save_data
terms = []
for row in csv.DictReader(open("sessions.tsv"), delimiter='\t'):
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4])
bycoffe /
Last active March 19, 2023 09:45
Split an SVG path into pieces
bycoffe /
Last active March 29, 2017 13:03
Element rotation with point-along-path interpolation
bycoffe / index.html
Created February 9, 2016 14:54
Town/county switch with topojson
<!DOCTYPE html>
<meta charset="utf-8">
#map path {
fill: #fff;
stroke: #999;
stroke-width; 1;
#map path.state.border {
fill: none;
bycoffe / chicago_elections_scraper.rb
Created April 8, 2015 01:45
Scraper for Chicago runoff election results
require 'json'
require 'nokogiri'
require 'open-uri'
results = []
open("") do |req|
doc = Nokogiri::HTML(
race = {:updated => doc.css("#ResultsContainer")[0].text.sub(/Last Updated: /, '')}
bycoffe / polls.go
Created November 18, 2014 19:50
Get the first 50 pages of polls from the Pollster database
package main
import (
func getPolls(pages []string) []pollster.Poll {
ch := make(chan []pollster.Poll)
bycoffe / index.html
Created June 19, 2014 13:56
Sort & animate divs
<!doctype html>
<meta charset="utf-8">
<style type="text/css">
.resort {
padding: 10px;
border: 1px solid black;
background: #ccc;