This is an example of how to split an SVG path into an arbitrary number of pieces.
It is the technique used for The winding path to 270 electoral votes
#!/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(): |
<?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'): | |
terms.append(row) | |
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n/10%10!=1)*(n%10<4)*n%10::4]) |
This is an example of how to split an SVG path into an arbitrary number of pieces.
It is the technique used for The winding path to 270 electoral votes
This example uses point-along-path interpolation, but also changes the rotation of the moving element depending on its place on the path.
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
#map path { | |
fill: #fff; | |
stroke: #999; | |
stroke-width; 1; | |
} | |
#map path.state.border { | |
fill: none; |
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: /, '')} |
package main | |
import ( | |
"fmt" | |
"github.com/bycoffe/pollster" | |
"strconv" | |
) | |
func getPolls(pages []string) []pollster.Poll { | |
ch := make(chan []pollster.Poll) |
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
.resort { | |
padding: 10px; | |
border: 1px solid black; | |
background: #ccc; |