Skip to content

Instantly share code, notes, and snippets.

@milroc
milroc / README.md
Last active August 29, 2015 14:25 — forked from magrawala/README.md
Bubble Cursor

This is an implentation of the Bubble Cursor, which was originally introduced by Tovi Grossman and Ravin Balakrishnan at CHI 2005.

@milroc
milroc / codeForSlides.py
Created June 15, 2015 18:40
Thinking about code in slides.
# Code for slides:
# 1. Avoid code in your slides, if you have 10 slides and more
# than 2 have code in it, you are making people do a diff review
# while you babble on in front of them...
# 2. Explain the hard concepts with anecdotes, or visuals.
# 3. Code on slides should be taken with MUCH more care to comprehension
# than code in your repository, imagine if you only had 3 seconds
@milroc
milroc / example.js
Last active August 29, 2015 14:20
control flow
// micro example for the d3.js day 1 course taught by @vicapow
// https://github.com/mbostock/d3/wiki/Selections#control
// is part of the API to look at
// most of this code is about readability
// the performance should be congruent through all options
// roughly
var circles = d3.selectAll('.circles').data([3, 2, 1, 0]);
// option one
@milroc
milroc / README.md
Last active August 29, 2015 14:08 — forked from mbostock/.block

Source: American Community Survey, 2011 5-Year Estimate

This map was inspired by a similar map found on Wikipedia. I wasn’t wild about the diverging color scale, so I thought it would be a fun challenge to recreate.

Finding the shapefiles was easy; I used the U.S. National Atlas 1:1,000,000 scale dataset, conveniently packaged in my U.S. Atlas repository. I reprojected the shapefiles to the California Albers projection using ogr2ogr:

ogr2ogr \
	-f 'ESRI Shapefile' \
	-t_srs 'EPSG:3310' \
@milroc
milroc / EventEmitter.min.js
Last active September 15, 2016 08:56
bar + sum: d3.js, react.js, & Flux
/*!
* EventEmitter v4.2.7 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/
(function(){"use strict";function t(){}function r(t,n){for(var e=t.length;e--;)if(t[e].listener===n)return e;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var e=t.prototype,i=this,s=i.EventEmitter;e.getListeners=function(n){var r,e,t=this._getEvents();if(n instanceof RegExp){r={};for(e in t)t.hasOwnProperty(e)&&n.test(e)&&(r[e]=t[e])}else r=t[n]||(t[n]=[]);return r},e.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},e.getListenersAsObject=function(n){var e,t=this.getListeners(n);return t instanceof Array&&(e={},e[n]=t),e||t},e.addListener=function(i,e){var t,n=this.getListenersAsObject(i),s="object"==typeof e;for(t in n)n.hasOwnProperty(t)&&-1===r(n[t],e)&&n[t].push(s?e:{listener:e,once:!1});return this},e.on=n("addListener"),e.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},e.once=n("addOnceListener"),e.defineE
@milroc
milroc / README.md
Created June 12, 2014 17:41 — forked from mbostock/.block
@milroc
milroc / README.md
Last active August 29, 2015 13:59 — forked from mbostock/.block
d3.dispatch + reusable components

d3.legend

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

@milroc
milroc / index.html
Last active August 29, 2015 13:57
Fitts's Bar, II
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<!-- CDN IMPORTS -->
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<!-- LOCAL IMPORTS -->
<!-- IN GIST -->
<link rel="stylesheet/less" type="text/css" href="style.less">
@milroc
milroc / .block
Last active March 7, 2017 05:44
Fitts's Bar, I
license: mit