This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'backbone' | |
], function(Backbone) { | |
return Backbone.Collection.extend({ | |
url: '/boops' | |
}, { | |
byUserId: function(user_id) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# event emitter is an object which is | |
# responsible for triggering events, and binding | |
# functions to those events. | |
class EventEmitter | |
# events map event names | |
# to functions which are bound | |
# to that event. calling model.on evt, fn | |
# will add that function to the events hash. | |
events: null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require [ | |
'zepto', | |
'osc/client', | |
'gui/range' | |
], ($, OscClient, RangeView) -> | |
osc_client = new OscClient | |
bar_view = new RangeView | |
model: osc_client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backbone.Layout = Backbone.View.extend({ | |
initialize: function() { | |
// a map of selector -> view references | |
this.view_references = {}; | |
// the promises for the data | |
// required before rendering the view | |
this.promises = this.data? _.map(this.data(), function(model) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define [ | |
'zepto', | |
'backbone' | |
], ($, Backbone) -> | |
# a singleton backbone.model whose | |
# attributes represent keyboard state | |
new class extends Backbone.Model | |
# bind keyboard events to model state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var extend = (function() { | |
var breaker = {}; | |
var has = function(obj, key) { | |
return hasOwnProperty.call(obj, key); | |
}; | |
var each = function(obj, iterator, context) { | |
if (obj == null) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a directed graph data structure- with the unique property that it is | |
// intended to handle the flow of data upstream in a clock based system. | |
// streaming audio through a graph of nodes with variable inputs and outputs, for instance. | |
// an `Edge` behaves as a relation between two nodes. | |
// the edge is saved on both connected nodes for reference. | |
var Edge = function(fromNode, fromIndex, toNode, toIndex) { | |
this.fromNode = fromNode; | |
this.fromIndex = fromIndex; | |
this.toNode = toNode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var BufferDrawer = Backbone.View.extend({ | |
initialize: function(options) { | |
this.buffer = options.buffer; | |
return Backbone.Model.prototype.initialize.apply(this, arguments); | |
}, | |
draw: function() { | |
var channels = this.buffer.channels, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http = require('http') | |
server = http.createServer() | |
server.middleware = [] | |
server.use = (middleware) -> | |
@middleware.push middleware | |
server.on 'request', (req, res) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
a small connect middleware proxy for cross domain ajax | |
@path first match group will be forwarded | |
@host the host you want to proxy | |
connect_server.use proxy '^(/.+)', 'api.twitter.com' | |
connect_server.use proxy '^/gh(/.+)', 'api.github.com' | |
### |