Skip to content

Instantly share code, notes, and snippets.

View stoive's full-sized avatar

Steven Thurlow stoive

  • Sydney, Australia
  • 16:11 (UTC +10:00)
View GitHub Profile
@stoive
stoive / undefined.js
Created May 15, 2012 07:21
Two types of undefined
new Array(10).length
// evaluates to `10`
new Array(10).map(function(current, i) { return i });
// evaluates to `[]`
var arr = [];
arr[2] = undefined;
arr[9] = undefined;
@stoive
stoive / gist:1308272
Created October 24, 2011 02:57
N-revision history rsync backup
# Untested - must run on an actual machine at some point in time!
# Also, I completely forget BASH
# The idea: each machine on the network has a clone of the backup directory. The last
# N revisions of each file are kept in a respective folder (e.g. gen0/ for most recent
# revision, gen1/ for 2nd most recent, gen2/, gen3/ ... to genN/).
# Updates on the central server get pushed out to the node machines. Like a DVCS that only
# keeps N revisions of each file
@stoive
stoive / gist:1034393
Created June 19, 2011 15:07
Weld, wrapped to behave like it should
// <script src="script/weld.min.js"></script>
/*
* Weld, re-interfaced so as not to be so annoying. The Weld way is to push the
* data into the template in-place, making updates to an existing DOM annoying
* and/or unreliable. Instead, is this. Initialise a template,
* and call 'create' to build a new instance of template+data, thus behaving
* like all other sensible view generation systems.
*/
var Welder = function(templateText) {