This file contains 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 YourModel = Backbone.Model.extend({ | |
toJSON: function(){ | |
var obj = {}; | |
_( this.attributes ).each( function( val, key ){ | |
obj[ key ] = val && typeof val === "object" && "toJSON" in val ? val.toJSON() : val; | |
}); | |
return obj; | |
} | |
}); |
This file contains 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 TwipsyView = Backbone.View.extend({ | |
tagName: "div", | |
className: "twipsy fade", | |
events: { | |
"mouseenter": "show", | |
"mouseleave": "hide" | |
}, | |
options: { | |
enabled: true, | |
title: "twipsyView", |
This file contains 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
class Controller | |
constructor: ( @app ) -> | |
@initialize() | |
routes: {} | |
delegateRoutes: () -> | |
that = this |
This file contains 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( [ | |
"jquery", | |
"underscore", | |
"backbone", | |
"models/home", | |
"views/home", | |
"models/item", | |
"views/item" | |
], function( $, _, Backbone, HomeModel, HomeView, ItemModel, ItemView ){ | |
This file contains 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
fs = require "fs" | |
jade = require "jade" | |
path = require "path" | |
walk = ( start, callback ) -> | |
fs.lstat start, (err, stat) -> | |
return callback err if err? | |
if stat.isDirectory() | |
fs.readdir( | |
start, | |
(err, files) -> |
This file contains 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
process.on( "uncaughtException", function( err ){ | |
console.log( "this is a ReferenceError for 'foo', but no exception for 'bar'",err ); | |
bar; | |
}); | |
foo; |
This file contains 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
body{ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height:100%; | |
} | |
.w-left-f,.w-left-s,.w-right-f,.w-right-s{ | |
width:1px; | |
height: 100px; | |
background-color:black !important; | |
float:left; |
This file contains 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 customModel = new CustomModel(); | |
var sampleView = new Backbone.View({ | |
model: customModel | |
}); |
This file contains 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 qs = require( "querystring" ); | |
server.pre(function( req, res, next ){ | |
var query = qs.parse( req.query() ); | |
req._version = query.version||undefined; //if `version` isn't defined, let node-restify to decide which is the best version | |
next(); | |
}); |
This file contains 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 mongoCol = require( "mongo-col" ), | |
mongoStream = require( "mongo-stream" ), | |
mongoInsertStream = mongoStream( mongoCol( "piped-collection", null, { | |
dbOptions:{ | |
safe: true | |
} | |
})), | |
Logger = require( "bunyan" ); | |
new Logger({ |