Skip to content

Instantly share code, notes, and snippets.

View get_death_dates.py
#!/usr/bin/python
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
bycoffe / PA-remedial.drf
Created Feb 20, 2018
Court-drawn Pennsylvania congressional map for use in Dave's Redistricting App
View PA-remedial.drf
<?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"/>
View birth_dates.csv
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
View fix_term_start_dates.py
import csv
import datetime
import itertools
from utils import load_data, save_data
terms = []
for row in csv.DictReader(open("sessions.tsv"), delimiter='\t'):
terms.append(row)
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4])
@bycoffe
bycoffe / README.md
Last active Oct 23, 2019
Split an SVG path into pieces
View README.md
@bycoffe
bycoffe / README.md
Last active Mar 29, 2017
Element rotation with point-along-path interpolation
View README.md
@bycoffe
bycoffe / index.html
Created Feb 9, 2016
Town/county switch with topojson
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#map path {
fill: #fff;
stroke: #999;
stroke-width; 1;
}
#map path.state.border {
fill: none;
@bycoffe
bycoffe / chicago_elections_scraper.rb
Created Apr 8, 2015
Scraper for Chicago runoff election results
View chicago_elections_scraper.rb
require 'json'
require 'nokogiri'
require 'open-uri'
results = []
open("http://www.chicagoelections.com/ap/results.htm") do |req|
doc = Nokogiri::HTML(req.read)
race = {:updated => doc.css("#ResultsContainer")[0].text.sub(/Last Updated: /, '')}
@bycoffe
bycoffe / polls.go
Created Nov 18, 2014
Get the first 50 pages of polls from the Pollster database
View polls.go
package main
import (
"fmt"
"github.com/bycoffe/pollster"
"strconv"
)
func getPolls(pages []string) []pollster.Poll {
ch := make(chan []pollster.Poll)
@bycoffe
bycoffe / index.html
Created Jun 19, 2014
Sort & animate divs
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.resort {
padding: 10px;
border: 1px solid black;
background: #ccc;