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
View base64.js
function encode(s) {
var c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
o = [];
for (var i = 0, n = s.length; i < n;) {
var c1 = s.charCodeAt(i++),
c2 = s.charCodeAt(i++),
c3 = s.charCodeAt(i++);
o.push(c.charAt(c1 >> 2));
o.push(c.charAt(((c1 & 3) << 4) | (c2 >> 4)));
o.push(c.charAt(i < n + 2 ? ((c2 & 15) << 2) | (c3 >> 6) : 64));
@mbostock
mbostock / perlin-worker.js
Created Aug 20, 2010
Polymaps / Procedural Perlin
View perlin-worker.js
onmessage = function(e) {
var data = e.data.data = [],
n = Math.pow(2, 7 - e.data.zoom),
x0 = e.data.column * n,
y0 = e.data.row * n,
w = e.data.size.x,
h = e.data.size.y;
for (var y = 0, i = 0; y < h; y++) {
for (var x = 0; x < w; x++) {
@mbostock
mbostock / app.yaml
Created Aug 26, 2010
polymaps.appspot.com
View app.yaml
application: polymaps
version: 1
runtime: python
api_version: 1
handlers:
- url: /state/.*
script: main.py
- url: /county/.*
@mbostock
mbostock / jsonp.diff
Created Aug 31, 2010
Polymaps / JSONP Queue
View jsonp.diff
diff --git a/src/Queue.js b/src/Queue.js
index d243c13..616dbc6 100644
--- a/src/Queue.js
+++ b/src/Queue.js
@@ -99,5 +99,41 @@ po.queue = (function() {
return {abort: abort};
}
- return {text: text, xml: xml, json: json, image: image};
+ function jsonp(src, callback) {
View gist:619560
git remote add mbostock git@github.com:mbostock/polymaps.git
git fetch mbostock
git merge --no-commit --no-ff mbostock/master
mate -w src/start.js
make
git add .
git commit
View gist:672899
<html>
<head>
<title>Pointing</title>
<script type="text/javascript" src="http://github.com/mbostock/protovis/raw/v3.3.1/protovis.js"></script>
<style type="text/css">
#fig {
width: 450px;
height: 425px;
}
View transition-end.js
d3_transitionPrototype.end = function() {
var subgroups = [],
subgroup,
subnode,
node;
for (var j = -1, m = this.length; ++j < m;) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
@mbostock
mbostock / pie.js
Created Nov 14, 2011
Prototype Chart Template (WIP)
View pie.js
d3.mbostock.pie = function() {
var pie = {},
parent,
data;
var svg = d3.create("svg:svg");
function redraw() {
return pie;
}
@mbostock
mbostock / adopt.diff
Created Nov 14, 2011
d3.create + selection.adopt
View adopt.diff
diff --git a/src/core/create.js b/src/core/create.js
new file mode 100644
index 0000000..a284a67
--- /dev/null
+++ b/src/core/create.js
@@ -0,0 +1,5 @@
+d3.create = function(name) {
+ return d3.select((name = d3.ns.qualify(name)).local
+ ? document.createElementNS(name.space, name.local)
+ : document.createElement(name));
@mbostock
mbostock / server.js
Created Dec 12, 2011
Node + MySQL + JSON
View server.js
process.env.TZ = "UTC";
var util = require("util"),
express = require("express"),
gzip = require("connect-gzip"),
mysql = require("mysql");
var client = mysql.createClient({
host: /* mysql host, e.g., "host.example.com" */,
port: /* mysql port, e.g., 3306 */,
You can’t perform that action at this time.