Skip to content

Instantly share code, notes, and snippets.

@atmccann
atmccann / index.html
Created September 11, 2013 20:41
Bar chart with pos/neg values
<meta charset="utf-8">
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body {
font: 12px Helvetica;
}
@atmccann
atmccann / data.json
Created September 18, 2013 21:59
bar chart transitions (can you tell i like bar charts?)
[{"network":"ABC","year_one":9860,"year_two":10596,"year_three":9989,"year_four":12217,"year_five":12281,"year_six":11913,"year_seven":12265,"year_eight":11050,"year_nine":9595,"year_ten":9871,"year_eleven":8339},
{"network":"AZA","year_one":0,"year_two":0,"year_three":0,"year_four":0,"year_five":213,"year_six":0,"year_seven":0,"year_eight":201,"year_nine":236,"year_ten":212,"year_eleven":0},
{"network":"CBS","year_one":13959,"year_two":13856,"year_three":13581,"year_four":12843,"year_five":13019,"year_six":11726,"year_seven":11274,"year_eight":11812,"year_nine":12538,"year_ten":12284,"year_eleven":10690},
{"network":"CW","year_one":0,"year_two":0,"year_three":0,"year_four":0,"year_five":2847,"year_six":2772,"year_seven":2911,"year_eight":2177,"year_nine":2481,"year_ten":1642,"year_eleven":688},
{"network":"ETV","year_one":0,"year_two":0,"year_three":0,"year_four":0,"year_five":0,"year_six":0,"year_seven":0,"year_eight":0,"year_nine":226,"year_ten":200,"year_eleven":231},
{"network":"FOX","year_one":7102,"yea
@atmccann
atmccann / data2.csv
Last active December 23, 2015 18:39
can i make this sortable or BETTER HELPppp
CT 258.0 193.0 258.0 193.0 697.0 193.0
DC 180.0 180.0 180.0 180.0 521.0 193.0
MD 179.0 179.0 179.0 179.0 484.0 193.0
ME 232.0 193.0 232.0 193.0 626.0 193.0
NY 390.0 193.0 390.0 193.0 390.0 193.0
RI 230.0 193.0 230.0 193.0 622.0 193.0
VA 199.0 193.0 199.0 193.0 537.0 193.0
VT 413.0 193.0 413.0 193.0 413.0 193.0
IN 232.0 193.0 232.0 193.0 626.0 193.0
@atmccann
atmccann / data2.csv
Created September 24, 2013 17:11
sorting is breaking :(
State 25 years old w/o subsidy 25 years old w/ subsidy 40 years old w/o subsidy 40 years old w/ subsidy 60 years old w/o subsidy 60 years old w/ subsidy
CT 258.0 193.0 258.0 193.0 697.0 193.0
DC 180.0 180.0 180.0 180.0 521.0 193.0
MD 179.0 179.0 179.0 179.0 484.0 193.0
ME 232.0 193.0 232.0 193.0 626.0 193.0
NY 390.0 193.0 390.0 193.0 390.0 193.0
RI 230.0 193.0 230.0 193.0 622.0 193.0
VA 199.0 193.0 199.0 193.0 537.0 193.0
VT 413.0 193.0 413.0 193.0 413.0 193.0
IN 232.0 193.0 232.0 193.0 626.0 193.0
@atmccann
atmccann / colorbrewer.js
Created September 25, 2013 22:37
multi series line chart
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
3: ["#edf8b1","#7fcdbb","#2c7fb8"],
var colorbrewer = {PuOr: {
3: ["#f1a340","#f7f7f7","#998ec3"],
4: ["#e66101","#fdb863","#b2abd2","#5e3c99"],
5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"],
6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"],
7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"],
8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"],
9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"],
10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],
11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"]
date val indicators
200309 4.5 Furniture_stores
200312 5.2 Furniture_stores
200403 9 Furniture_stores
200406 5.9 Furniture_stores
200409 6.7 Furniture_stores
200412 6 Furniture_stores
200503 5.2 Furniture_stores
200506 6 Furniture_stores
200509 5.2 Furniture_stores
@atmccann
atmccann / datamaps.all.js
Created October 25, 2013 20:15
maaappppsssss
(function() {
var svg;
var defaultOptions = {
scope: 'world',
setProjection: setProjection,
projection: 'equirectangular',
done: function() {},
fills: {
defaultFill: '#00000'
},
@atmccann
atmccann / index.html
Created November 6, 2013 18:22
map_fail TURNED SUCCESS
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.subunit.SCT { fill: #ddc; }
.subunit.WLS { fill: #cdd; }
.subunit.NIR { fill: #cdc; }
.subunit.ENG { fill: #dcd; }
.subunit.IRL { display: none; }
import string
punc_chars = string.punctuation.replace('-', '').replace("'", '')
def read_book(book):
with open(book, 'r') as f:
for line in f:
yield line.strip()
def remove_punctuation(line):