Skip to content

Instantly share code, notes, and snippets.

Mike Bostock mbostock

Block or report user

Report or block mbostock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mbostock
mbostock / index.js
Last active Oct 13, 2015
Stitching States from Counties
View index.js
d3.json("us-counties.json", function(error, topology) {
if (error) throw error;
var infoByArc = {},
arcsByState = {};
topology.objects[0].geometries.forEach(function(object) {
object.arcs.forEach(object.type === "MultiPolygon"
? function(polygon) { polygon.forEach(function(ring) { ring.forEach(info); }); }
: function(ring) { ring.forEach(info); });
@mbostock
mbostock / type.js
Created Dec 11, 2012
GeoJSON Transforms
View type.js
function d3_geo_type(types) {
for (var type in d3_geo_typeDefaults) {
if (!(type in types)) {
types[type] = d3_geo_typeDefaults[type];
}
}
return types;
}
var d3_geo_typeDefaults = {
@mbostock
mbostock / index.js
Last active Oct 31, 2015
D3 Bookmarklet
View index.js
javascript:var f = document.createElement("script");f.setAttribute("src", "//d3js.org/d3.v3.min.js");document.head.appendChild(f);
View finite-state-stream.js
function d3_geo_pathContext(context) {
var pointRadius = 4.5,
state = 0;
// state bit 0: not-first point?
// state bit 1: inside line?
// state bit 2: inside polygon?
function point(x, y) {
if (state) {
@mbostock
mbostock / .gitignore
Last active Dec 25, 2015
New Splines!
View .gitignore
.DS_Store
node_modules
@mbostock
mbostock / graphicsmagick-examples.sh
Last active Feb 2, 2016
GraphicsMagick Cheat Sheet
View graphicsmagick-examples.sh
#!/bin/bash
# Making a non-square image square by adding padding.
gm montage -geometry 1024x1024 -background none source.png target.png
@mbostock
mbostock / .block
Last active Feb 8, 2016
Pale Dawn
View .block
license: gpl-3.0
@mbostock
mbostock / .block
Last active Feb 8, 2016
CSS3 Modal Button
View .block
license: gpl-3.0
@mbostock
mbostock / .block
Last active Feb 8, 2016
Minecraft Overviewer
View .block
license: gpl-3.0
@mbostock
mbostock / .block
Last active Feb 8, 2016
Cellular automata
View .block
license: gpl-3.0
redirect: https://beta.observablehq.com/@mbostock/1d-cellular-automaton
You can’t perform that action at this time.