Skip to content

Instantly share code, notes, and snippets.

View rodw's full-sized avatar

Rod Waldhoff rodw

View GitHub Profile
@andris-silis
andris-silis / backbone.js-sync-setTimeout
Created April 27, 2012 08:16
extended backbone.js sync function. uses setTimeout to batch multiple saves on one model in one http request.
// decreases request count on rapid-fire one model saves
// extended backbone.js sync function. uses setTimeout to batch multiple saves on one model in one http request.
// if client side needs immediate answer from server for changes in model attributes,
// pass { immediate: true } in model save options if { wait: true } is not used already.
Backbone._sync=Backbone.sync
Backbone.sync = function(method, model, options){
var maxResetCount=5 // how many times to delay save
var saveBufferSize=3000 // for how many microseconds save is delayed
var immediate=options['wait'] || options['immediate'] || false
@TooTallNate
TooTallNate / emitLines.js
Created February 10, 2012 01:11
Make any ReadableStream emit "line" events
/**
* A quick little thingy that takes a Stream instance and makes
* it emit 'line' events when a newline is encountered.
*
* Usage:
* ‾‾‾‾‾
* emitLines(process.stdin)
* process.stdin.resume()
* process.stdin.setEncoding('utf8')
* process.stdin.on('line', function (line) {
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE