Skip to content

Instantly share code, notes, and snippets.

View joews's full-sized avatar

Joe Whitfield-Seed joews

View GitHub Profile
@joews
joews / backbone-inflight.js
Created August 15, 2014 09:24
Make Backbone Collections and Models aware of their current sync state
// Patch Backbone Model and Collection to have awareness
// of current sync state.
// Adds an isLoading method and _inFlight count property.
// Fires before:sync and after:sync events.
// Based on http://tbranyen.com/post/how-to-indicate-backbone-fetch-progress
!function() {
function onSyncEnd() {
-- this._inFlight;
this.trigger("after:sync", this);
}
@joews
joews / index.html
Created July 24, 2014 13:55
D3 opacity tween vs CSS transform
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body {
height: 100%;
}
@joews
joews / dir.sh
Created July 16, 2014 15:54
Get directory of bash script
dir=$(cd $(dirname $0) && pwd)
@joews
joews / index.html
Created June 20, 2014 18:59
d3 gist boilerplate
<!DOCTYPE html>
<html>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@joews
joews / d3-bring-to-front.js
Created June 13, 2014 10:49
D3.js bring to front
// Credit Christopher Chiche & Clemens Tolboom
// - http://stackoverflow.com/a/14426477/2806996
d3.selection.prototype.moveToFront = function() {
return this.each(function(){
this.parentNode.appendChild(this);
});
};
d3.selection.prototype.moveToBack = function() {
return this.each(function() {
@joews
joews / dabblet.css
Created June 13, 2014 09:23
Untitled
**
* The first commented line is your dabblet’s title
*/
.wrapper {
position: relative;
}
.line {
position: absolute;
height: 1px;
@joews
joews / index.html
Created June 7, 2014 16:22
d3 multi-series scatter plot with series and data point transitions
<!DOCTYPE html>
<html>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@joews
joews / gist:de5bc4da913899b31636
Created May 28, 2014 11:33
jQuery plugin to select contents of a contenteditable element
// Select text of a content editable
// http://stackoverflow.com/a/6150060/2806996
// Example usage: $('[contenteditable]:first').selectText()
$.fn.selectText = function() {
var range = document.createRange();
range.selectNodeContents(this[0]);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
@joews
joews / styles.less
Created May 7, 2014 11:55
My Atom stylesheet
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@joews
joews / README.md
Created April 14, 2014 18:19
Shink Raspberry Pi root partition (Arch) with OSX

Shink Raspberry Pi root partition (Arch) with OSX

A reminder of how to shrink the root partition of a fresh Arch Linux installation on a Raspberry Pi.

I wanted to make more room on a 4GB SD card for a Linux From Scratch build, so I resized the root partition down to 700mb and created a new 3GB logical partition next to it.

I didn't have another Linux machine available, so I used OSX Mavericks to write the original Arch image to the SD card and do the initial filesystem resize. Everything else was done on the Pi itself.