Skip to content

Instantly share code, notes, and snippets.

View craigspaeth's full-sized avatar

Craig Spaeth craigspaeth

View GitHub Profile
@craigspaeth
craigspaeth / nodes_backbones_zombies.md
Created January 25, 2012 21:53
Nodes and Backbones and Zombies, oh my!

Javascript

Some examples to be run inside the node console.

Functional, closures, lambdas

// First class players
var fn = function () {
@craigspaeth
craigspaeth / gist:1192424
Created September 4, 2011 06:59
Simple Jasmine spec helper to run an entire suite asynchronously
# Example usage:
#
# describe 'foo' ->
# runAsync()
# it 'tests things' ->
# expect(0 is 0).toBeTruthy()
# done()
#
_done = false
done = -> _done = true
@craigspaeth
craigspaeth / gist:1087868
Created July 17, 2011 17:56
Coffescript override Backbone.sync to be Ruby on Rails friendly
# Override Backbone.sync to be rails friendly
Backbone.sync = ((original) => (method, model, options) ->
options ?= {}
# Wrap model's attrs in a Rails friendly way by injecting it into options.data
if not options.data? and model? and (method is "create" or method is "update" or method is "delete")
unless model.modelName?
throw new Error "You must specify a modelName in a Rails friendly
underscore format for this model to be persisted"