Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / 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 / d3.min.js
Last active August 29, 2015 14:12
20150107 Movies by genre history
!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===da||n[0]===ma?ma+n:n}function l(n){return(n+="")[0]===ma?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object
@standarderror
standarderror / index.html
Last active February 17, 2016 10:04
20150111 Regression Scatterplot Animation
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
}
.circle {
stroke: '#fff';
@standarderror
standarderror / index.html
Created January 12, 2015 03:41
20150115 Regression Animation in Viewbox
<!DOCTYPE html>
<meta charset="utf-8">
<style>
#chart {
/* margin-left:50%; */
}
.circle {
stroke: '#fff';