Skip to content

Instantly share code, notes, and snippets.


Johan Sundström johan

View GitHub Profile
#! /bin/sh
# runs on any mac, gives its apple specs
curl -is \
| grep -B 1 $( system_profiler SPHardwareDataType -detailLevel mini \
| awk '/Model Identifier/ { print $3 }' \
) \
| egrep -o '<a href=.*</a>'


1: Prehistoric Man

S, T!, N, E, T, E, U, T!, S!, T, M AXE (from flint and bone),
SW, T!, W!, W!, SE!, J! (the tyrannosaurus falls into the hole),
SW, W, T, E, E, J (over the hole),
S, SE, CUT TREE, M RAFT (from trees and creeper),
E, E, L (you see a stairway),
johan / Makefile
Created Jan 24, 2017
Makefile of the steps in Mike Bostock's command-line cartography tutorial, parts 1-4
View Makefile
# request one at and paste it below
# a factor 1609.34 squared
# npm install -g shapefile # 0.6.1
# npm install -g d3-geo-projection # 1.2.1
# npm install -g ndjson-cli # 0.3.0
Copyright (c) 2013 Omar Shammas (
and Stripe (
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
johan /
Created Jan 2, 2017
opower PG&E csv file cleanup


sh opower-csv-to-csv < pge_*.csv


Take your PG&E csv data export (pge_electric_interval_data_NNNNNNNNNN_YY-MM-DD_to_YYYY-MM-DD.csv) for the date range you want,

johan / events.es5.js
Last active Feb 4, 2017
HAI 2017 events, as of 2016-12-22
View events.es5.js
'use strict';var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(;_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"])_i["return"]();}finally{if(_d)throw _e;}}return _arr;}return function(arr,i){if(Array.isArray(arr)){return arr;}else if(Symbol.iterator in Object(arr)){return sliceIterator(arr,i);}else{throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj;}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}var deQuery=function deQuery(){var q=argu
johan / srt.js
Created Dec 21, 2016
A little subtitle file tweaking class
View srt.js
class SRT {
constructor(s) { this.setSubs(typeof s === 'string' ? SRT.decode(s) : s); }
toString() { return SRT.encode(this.subs); }
timeShift(dt) {
return new SRT( => Object.assign({}, s, {t: s.t + dt})));
getSubs() { return => Object.assign({}, o)); }
setSubs(subs) { this.subs = subs; return this; }
johan / controlfreak.js
Last active Dec 16, 2016
Convenience lib for the chrome extension "Control Freak", a light-weight Greasemonkey.
View controlfreak.js
const scrape = (scraper) => {
let spec = 'dom' in scraper ? scraper : { dom: scraper };
on(spec).then((scraped) => {'on.dom scraped:', {scraper, scraped});
exportToPage({scraper, scraped, on});
const exportToPage = (obj) => {
johan / cancelAll.js
Created Dec 11, 2016
A browser functionality fill-in I ended up writing and sharing on to batch cancel javascript's basic deferred execution functions.
View cancelAll.js
(function(deferFunctions) {
for (var setter in deferFunctions) (function(setter, clearer) {
var ids = [];
var startFn = window[setter];
var clearFn = window[clearer];
function clear(id) {
var index = ids.indexOf(id);
if (index !== -1) ids.splice(index, 1);
return clearFn.apply(window, arguments);
johan / alert.js
Created Nov 22, 2016
Somewhat improved version of Fake News Alert extension 0.1.2 from – to mark links directly at Facebook before you even click through them.
View alert.js
// alert.js
const stripes = document.createElement('div'); = `
height: 20px;
width: 100%;
position: fixed;
z-index: 99999;
opacity: 0.7;
pointer-events: none;
You can’t perform that action at this time.