Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Barry msbarry

  • MetroWest Boston
View GitHub Profile
@msbarry
msbarry / index.html
Last active Jul 1, 2020 — forked from jadiehm/data.csv
Choropleth U.S. county map
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Independent Farms by County - Choropleth</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="http://d3js.org/queue.v1.min.js"></script>
<script type="text/javascript" src="http://d3js.org/topojson.v1.min.js"></script>
</head>
@msbarry
msbarry / ElasticsearchSource.scala
Created Jun 16, 2017 — forked from quiiver/ElasticsearchSource.scala
Scalding source for Elasticsearch
View ElasticsearchSource.scala
package com.twitter.scalding.sources
import cascading.tuple.Fields
import cascading.tap.Tap;
import org.elasticsearch.hadoop.cascading.EsTap
import com.twitter.scalding._
abstract class ElasticsearchSource extends Source {
@msbarry
msbarry / SlidesToDoc.gs
Last active Mar 12, 2017
Google App Script to create a doc with speaker notes from slides
View SlidesToDoc.gs
var INPUT_PRESO_ID = "<id>";
var OUTPUT_DOC_ID = "<id>";
function createNotesDoc() {
var presentation = Slides.Presentations.get(INPUT_PRESO_ID)
var out = DocumentApp.openById(OUTPUT_DOC_ID)
out.getBody().clear();
table = out.getBody().appendTable();
var links = [];
for (var i = 0; i < presentation.slides.length; i++) {
@msbarry
msbarry / build_trie.js
Created Feb 9, 2016
Building/searching a trie in js
View build_trie.js
var txt = require("fs").readFileSync("app/names.txt", "utf8");
var nicknames = require('./nicknames');
var words = txt.split("\n");
var trie = build(words);
optimize(trie);
require('fs').writeFileSync('app/trie.js', 'trie = ' + toString(trie));
function tokenize(str) {
return str
.toLowerCase()
@msbarry
msbarry / colorspaces.glsl
Last active Nov 3, 2018
glsl color space conversion
View colorspaces.glsl
vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);
vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
@msbarry
msbarry / woof.bash
Last active Jan 19, 2016
Send yourself notifications from the command line
View woof.bash
# Some utilities for sending notifiations to yourself from the command line (mac only).
# Just add them to your ~/.bashrc and fill in these parameters.
# See them all in action: "ugh <long running command> && woof command succeeed || woof command failed"
TWITTER_HANDLE= # twitter handle
EMAIL_ADDRESS= # email address
CELL_EMAIL_ADDRESS= # email address for your cell phone (ie 1234567890@vtext.com)
TERMINAL_APP="com.apple.Terminal" # replace with iterm if you use that
THEME_SONG="~/waiting.mp3" # replace with a path to your theme song
@msbarry
msbarry / data.csv
Last active Aug 29, 2015
Distribution of last letter in newborn boys' names
View data.csv
year letter percent
1880 n 15.32
1880 m 10.19
1880 s 16.7
1880 e 12.21
1880 k 4.27
1880 h 3.66
1880 y 7.58
1880 t 6.29
1880 d 8.31
@msbarry
msbarry / README.md
Last active Aug 29, 2015
Absolute vs. Relative Comparisons
View README.md

This visualization demonstrates different techniques for facilitating relative vs. absolute comparisons as described in section 12.2.5 of Interactive Data Visualization by Ward, Grinstein, and Keim. For each variation, this graphic shows 10 bars representing values of 10 through 19. The top variation is the worst, requiring the user to make absolute comparisons between the bars - which humans are very bad at. The techniques below that demonstrate different ways to facilitate relative comparisons instead:

  1. Bounding Boxes: Bounding boxes give a consistent frame of reference to facilitate relative comparisons
  2. Grid/Tick Marks: Grid or tick marks give intermediate points of reference
  3. Residuals: By subtracting the average value from each bar, only the relative differences remain
  4. Reorientation: By simply re-orienting the bars to be stacked vertically instead of horizontally, relative comparisons become much easier
@msbarry
msbarry / .block
Last active Oct 20, 2016
World Health Scatterplot
View .block
license: mit
@msbarry
msbarry / README.md
Last active Aug 29, 2015
World Health Statistics
View README.md

This visualization uses sortable columns as an interaction technique to explore a dataset as described in chapter 10 of Interactive Data Visualization by Ward, Grinstein, and Keim. This falls under the category of "reconfiguring operators" described on page 319.

Hovering over a column re-sorts the data by that column which may make related patterns appear in other columns.

Data courtesy of the World Health Organization