Skip to content

Instantly share code, notes, and snippets.

@johnburnmurdoch
johnburnmurdoch / index.html
Last active September 24, 2015 18:06
Ceci n'est pas un dropdown
<!DOCTYPE html>
<html>
<head>
<title>Ceci n'est pas un dropdown</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style media="screen">
body{background-color:#fff1e0;font-size:16px;font-family:sans-serif;}
#container{width:100%;height:100%;min-height:500px;}
.ceci-nest-pas-un-dropdown{background-color:#e9decf;cursor:pointer;position:relative;font-size:14px;padding:1px 8px 3px 8px;border-radius:10px;border:1px solid #cec6b9;}
.ceci-nest-pas-un-dropdown:hover{background-color:#cec6b9;}
library(SmarterPoland)
library(riverplot)
library(RColorBrewer)
library(graphics)
library(reshape2)
library(plyr)
library(stringr)
library(countrycode)
# DOWNLOAD THE DATA
@johnburnmurdoch
johnburnmurdoch / data_.csv
Last active March 9, 2016 04:44
Share of minutes played broken down by nationality, across Premier League seasons
seasonStart group total share barTops barBases
1 1992 Other EU 22536 0.024715160408366 0.024715160408366 0
2 1992 non-EU 41531 0.0455469172399649 0.070262077648331 0.024715160408366
3 1992 Ireland 63597 0.0697466301247273 0.140008707773058 0.070262077648331
4 1992 Rest of UK 146838 0.16103677334237 0.301045481115428 0.140008707773058
5 1992 England 637327 0.698954518884572 1 0.301045481115428
6 1993 Other EU 27526 0.0301765248869175 0.0301765248869175 0
7 1993 non-EU 62492 0.0685094599009391 0.0986859847878566 0.0301765248869175
8 1993 Ireland 54388 0.0596251120958247 0.158311096883681 0.0986859847878566
9 1993 Rest of UK 124047 0.135991694494204 0.294302791377885 0.158311096883681
// https://github.com/1wheel/d3-jetpack-module Version 0.0.14. Copyright 2016 Adam Pearce.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('d3-transition'), require('d3-axis'), require('d3-scale'), require('d3-collection'), require('d3-queue'), require('d3-request')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'd3-transition', 'd3-axis', 'd3-scale', 'd3-collection', 'd3-queue', 'd3-request'], factory) :
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3,global.d3,global.d3));
}(this, function (exports,d3Selection,d3Transition,d3Axis,d3Scale,d3Collection,d3Queue,d3Request) { 'use strict';
function translateSelection(xy) {
return this.attr('transform', function(d,i) {
return 'translate('+[typeof xy == 'function' ? xy.call(this, d,i) : xy]+')';
height: 800
@johnburnmurdoch
johnburnmurdoch / .block
Last active October 15, 2017 19:25
Procedurally generated ribbons, using Bézier curve iterations
license: Apache-2.0
height: 900
border: no
@johnburnmurdoch
johnburnmurdoch / .block
Last active February 26, 2018 16:46
Generative line intersections
license: mit
scrolling: no
border: no
@johnburnmurdoch
johnburnmurdoch / main.R
Created March 1, 2018 19:15
Vectorising for loops to save time in R
needs(tidyverse, magrittr, jsonlite, scales)
loopTimer <- function(rows){
col1 <- runif (rows, 0, 2)
col2 <- rnorm (rows, 0, 2)
col3 <- rpois (rows, 3)
col4 <- rchisq (rows, 2)
df <- data.frame (col1, col2, col3, col4)
@johnburnmurdoch
johnburnmurdoch / index.html
Last active March 2, 2018 00:15
Three-way interactive scatter, showing where points lie on three axes
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Three-way scatter</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type='text/javascript' src='https://unpkg.com/d3'></script>
<script type='text/javascript' src='https://unpkg.com/d3-selection-multi'></script>
@johnburnmurdoch
johnburnmurdoch / data.csv
Created April 3, 2018 07:35
Mapping population change across US counties, highlighting the "doughnut" ring effect in many growing metro areas
We can't make this file beautiful and searchable because it's too large.
fips,stname,ctyname,fullname,year,estimate
01001,Alabama,Autauga County,"Autauga County, Alabama",2000,44021
01001,Alabama,Autauga County,"Autauga County, Alabama",2001,44889
01001,Alabama,Autauga County,"Autauga County, Alabama",2002,45909
01001,Alabama,Autauga County,"Autauga County, Alabama",2003,46800
01001,Alabama,Autauga County,"Autauga County, Alabama",2004,48366
01001,Alabama,Autauga County,"Autauga County, Alabama",2005,49676
01001,Alabama,Autauga County,"Autauga County, Alabama",2006,51328
01001,Alabama,Autauga County,"Autauga County, Alabama",2007,52405