Skip to content

Instantly share code, notes, and snippets.

View msbarry's full-sized avatar

Michael Barry msbarry

  • MetroWest Boston
View GitHub Profile
// To run:
// 1) Install java 17 (JDK, not JRE)
// 2) Then get latest planetiler.jar: wget https://github.com/onthegomap/planetiler/releases/latest/download/planetiler.jar
// 3) Then run this file with: java -cp planetiler.jar Powerlines.java --area=monaco --download --force
import com.onthegomap.planetiler.FeatureCollector;
import com.onthegomap.planetiler.FeatureMerge;
import com.onthegomap.planetiler.Planetiler;
import com.onthegomap.planetiler.Profile;
import com.onthegomap.planetiler.VectorTile;
@msbarry
msbarry / index.html
Last active July 1, 2020 12:54 — forked from jadiehm/data.csv
Choropleth U.S. county map
<!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 June 16, 2017 19:11 — forked from quiiver/ElasticsearchSource.scala
Scalding source for Elasticsearch
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 February 7, 2024 11:39
Google App Script to create a doc with speaker notes from slides
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 February 9, 2016 10:30
Building/searching a trie in 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 July 14, 2021 10:16
glsl color space conversion
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 January 19, 2016 17:13
Send yourself notifications from the command line
# 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 August 29, 2015 14:05
Distribution of last letter in newborn boys' names
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 August 29, 2015 13:58
Absolute vs. Relative Comparisons

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 October 20, 2016 16:57
World Health Scatterplot
license: mit