Skip to content

Instantly share code, notes, and snippets.

View milosdakic's full-sized avatar

Milos Dakic milosdakic

View GitHub Profile
@milosdakic
milosdakic / cluster.coffee
Created September 7, 2012 06:34
Node + Express + Cluster in CoffeeScript
cluster = require 'cluster'
express = require 'express'
workers = require('os').cpus().length
app = express()
app.get '/', (req, res) ->
res.send('Working!')
@milosdakic
milosdakic / stream.js
Created August 13, 2012 03:27
Backbone.js Collection/Model Stream mixin
/**
* Stream collection/model data.
* @exports mixins/Stream
* @module Stream
*/
var Stream = {
/**
* Is the collection steaming?
*
* @property streaming
@milosdakic
milosdakic / server.coffee
Created August 8, 2012 01:33
Node + Express + CoffeeScript = static file server
# use express for server/middleware
express = require 'express'
# create new instance of express
app = express()
# set static directory to root directory of this file
app.use express.static __dirname
# run the application on port 9000
app.listen 9000
@milosdakic
milosdakic / backbone.snippets
Created January 26, 2012 23:21
Backbone.js Vim Snippets
# Class
snippet bc
var ${1:Thing} = Class.extend({
initialize: function(${2:Attributes}) {
}
});
# Model
snippet bbm
var ${1:Thing} = Backbone.Model.extend({
@milosdakic
milosdakic / namespace.js
Created December 12, 2011 03:54
JavaScript namespacing with Underscore
function namespace(string, obj) {
var current = window,
names = string.split('.'),
name;
while(name = names.shift()) {
current[name] = current[name] || {};
current = current[name];
}