Skip to content

Instantly share code, notes, and snippets.

View shawnbot's full-sized avatar
🎹

Shawn Allen shawnbot

🎹
View GitHub Profile
@mbostock
mbostock / .block
Last active August 5, 2023 12:53
Margin Convention
license: gpl-3.0
redirect: https://observablehq.com/@d3/margin-convention
@mbostock
mbostock / .block
Last active September 13, 2019 10:42
Shape Tweening
license: gpl-3.0
@mapmeld
mapmeld / CensusAPI.txt
Created August 2, 2012 23:01
Using the Census API
NOTE: This how-to was written for the Census API at http://thedataweb.rm.census.gov/ -- it has since been moved to http://api.census.gov/
Mike Stucka, our contact at the Macon Telegraph, sent us a link to the Census's official API which is launching next month. You can skip ahead to the site - http://www.census.gov/developers/ - and get an API key, but also read my notes after using this yesterday:
1) The datasets
--- The 2010 Census Summary comes from everyone filling out census forms, and you can get stats at state level down to a super-detailed block level. Info from this includes population, age, gender, race, home ownership, members of a household, and various combinations of that. Full list: http://www.census.gov/developers/data/sf1.xml
--- The 2006-2010 American Community Survey is a longer form given to fewer households over 5 years (so its numbers are incompatible with the 2010 Census). You can get stats down only to the block group level. In addition to the standard census stats, you get: educa
@shawnbot
shawnbot / xterm-256color.md
Last active March 22, 2024 16:26
Make OS X Terminal respect 256 colors in screen

1. Ensure that Terminal declares itself as "xterm-256color"

Under Terminal > Preferences... > (Profile) > Advanced, "Declare terminal as:" should be set to xterm-256color.

2. Build a version of screen that supports 256 colors

This is easy with homebrew:

brew install screen
@tmcw
tmcw / spy.js
Created September 10, 2012 17:20
Spy on requests through MM and call a callback with ms inflight
function spy(layer, callback) {
var inflight = {};
var rt = layer.requestManager.requestTile;
layer.requestManager.requestTile = function() {
inflight[arguments[0]] = +new Date();
rt.apply(layer.requestManager, arguments);
};
layer.requestManager.addCallback('requestcomplete', function(s, img) {
callback(+new Date() - inflight[img.id]);
delete inflight[img.id];
@mbostock
mbostock / .block
Last active October 10, 2019 18:06
Progress Events
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/fetch-progress
@jo
jo / README.md
Created November 13, 2012 21:46
Selectable elements

Provide selection capabilities for DOM elements, geared to <select multiple>.

  • click: select element
  • ctrl + click: add element to current selection
  • click + move: select elements while dragging
  • ctrl + a: select all elements within focused list
  • ctrl + shift + a: deselect all elements within focused list
  • ctrl + click + move: toggle selection while dragging
  • shift + click: select range from nearest last selected element to clicked element
  • shift + ctrl + click: add range to current selection
@mbostock
mbostock / .block
Last active January 24, 2017 21:27 — forked from mbostock/.block
U.S. Counties TopoJSON Mesh
license: gpl-3.0
height: 600
border: no
@max-mapper
max-mapper / index.js
Created November 27, 2012 01:28
link to lat/lon in native maps app on ios and android from webview (phonegap)
var mapLink = "http://maps.google.com/maps?z=12&t=m&q=loc:" + lat + "+" + lon
if ($.os.ios && navigator.userAgent.match(/iPhone OS 6_/)) mapLink = "Maps://?q=" + lat + "," + lon
if ($.os.android) mapLink = "geo:" + lat + "," + lon + "?z=12&q=" + lat + "," + lon
// assumes you have zepto and zepto.detect loaded
// also you should use target=_blank on your <a> tags
@tmcw
tmcw / index.html
Created November 27, 2012 21:04
d3 tag editing
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
<title>d3 input table</title>
<style>
body {
font:normal 14px/20px 'Helvetica Neue', sans-serif;
}
</style>
</head>