Skip to content

Instantly share code, notes, and snippets.

View slattery's full-sized avatar

Mike Slattery slattery

View GitHub Profile
@slattery
slattery / ssh-add example
Last active August 29, 2015 13:56
allow the virtualbox to use my privkey for a spell
MAC$ ssh-add -t 7200
MAC$ ssh-add /Users/username/.ssh/OTHERKEYSIFNEEDED
MAC$ ssh -A username@IPTOTHEVM
VM$ ssh-add -l
--EVAL 'this script' 1 some-key
local key = KEYS[1];
local value = redis.call('GET', key);
local jvalue = cjson.encode(cmsgpack.unpack(value));
return jvalue;
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<div ng-app='app'>
<div ng-controller="HelloCntl">
<input placeholder="Type to filter" ng-model="query">
<ul>
<li ng-repeat="friend in friends | friendFilter:query">
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body ng-app>
<div ng-controller="ParentCtrl">
<p>{{foo}}</p>
@slattery
slattery / README.md
Last active August 29, 2015 13:59
d3-timeline setWidth check construction attrs for width before rejecting on behalf of FF

setWidth was failing for us in FF, even though we had constructed our attempt as entered in the README:

var chart = d3.timeline();

var svg = d3.select("#timeline1").append("svg").attr("width", 500)
  .datum(testData).call(chart);

It looks like setWidth does ask for the attribute as entered during initial construction:

<!doctype html>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<html>
<head>
<title>test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />

Time scales

This demo several time scales. src

full screen demo

D3's time axis does magic things. I expected to modify the x axis such that I could mostly re-use D3's date formatting tricks, but exercise greater control over the resolution at different time scales.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Chronological Diagram of Asia</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style type="text/css">
.chart {
shape-rendering: crispEdges;
}

Create a earthquake time range by clicking and dragging on the timeseries.

This map & chart shows earthquakes (magnitude 3.0 or greater) that occurred in the Canterbury region of New Zealand during the month of September, 2010.

The shade of the map circles show the depth of the earthquake. Lighter shades are shallower and darker shades are deeper.

The map is created using [Leaflet]. The earthquake layer is a custom [Leaflet] layer which uses d3js to generate a svg overlay.

Earthquake data sourced from GeoNet.