Skip to content

Instantly share code, notes, and snippets.

@standarderror
standarderror / extract films by year.py
Last active August 29, 2015 14:12
20150106 Western films as swaying grass
import re
from collections import Counter
%pylab inline
yeararray = []
infile = "/Users/Cam/Downloads/imdb/genres.list"
with open(infile) as f: # using with open will automatically close file
for line in f:
@standarderror
standarderror / index.html
Last active September 22, 2020 03:22
20141222 Dewey Decimal treemap
<!DOCTYPE html>
<meta charset="utf-8">
<title>DDC zoomable treemap</title>
<style>
#chart1 {
width: 960px;
height: 500px;
background: #ddd;
/* centre SVG horizontally */
@standarderror
standarderror / index.html
Last active August 29, 2015 14:12
20141222 Dewey Decimal sunburst
<!DOCTYPE html>
<meta charset="utf-8">
<title>DDC sunburst</title>
<style>
#chart2 {
/* centre SVG horizontally */
/* position: relative;
left: 50%;
margin-left: -400px; */
@standarderror
standarderror / dewey.js
Last active August 29, 2015 14:12
Dewey Decimal tree explorer
var margin = {top: 20, right: 120, bottom: 20, left: 120},
width = 960 - margin.right - margin.left,
height = 600 - margin.top - margin.bottom;
var i = 0,
duration = 750,
root ;
var tree = d3.layout.tree()
.size([height, width]);
@standarderror
standarderror / randomGraph
Last active August 29, 2015 14:10
Random Graph D3
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// # groups added by Cam
function erdosRenyi(nodesNum,directedness,prob,groups) {
// create nodes list
var nodes = []
@standarderror
standarderror / README.md
Last active July 7, 2016 09:26
D3.js network of murders in The Wire

A force-directed graph of murders in TV show The Wire, discussed at blog subsubroutine.com. Created with D3.js.

Credits:

@standarderror
standarderror / 0_reuse_code.js
Created August 31, 2014 07:03
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console