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
function namespace(string, obj) { | |
var current = window, | |
names = string.split('.'), | |
name; | |
while(name = names.shift()) { | |
current[name] = current[name] || {}; | |
current = current[name]; | |
} |
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 | |
snippet bc | |
var ${1:Thing} = Class.extend({ | |
initialize: function(${2:Attributes}) { | |
} | |
}); | |
# Model | |
snippet bbm | |
var ${1:Thing} = Backbone.Model.extend({ |
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
# 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 |
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
/** | |
* Stream collection/model data. | |
* @exports mixins/Stream | |
* @module Stream | |
*/ | |
var Stream = { | |
/** | |
* Is the collection steaming? | |
* | |
* @property streaming |
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
cluster = require 'cluster' | |
express = require 'express' | |
workers = require('os').cpus().length | |
app = express() | |
app.get '/', (req, res) -> | |
res.send('Working!') | |
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 User = sequelize.define('User', { | |
name: Sequelize.STRING | |
}, { | |
// define the mixins you want to include | |
// could be similar to sequelize.import() | |
mixins: [ | |
'CreatedAt', | |
... | |
] | |
] }); |
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
module.exports = function(State, Country) { | |
var data = require('../db/au.json'); | |
// Create states | |
State.bulkCreate(data).done(function() { | |
// Find all newly added states where country associations is not set. | |
State.findAll({ where: { countryId: null }}).done(function(states) { | |
// Find the country we want to associate this with | |
Country.find({ where: { name: 'Australia' }}).success(function(australia) { |
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 path = require('path') | |
, fs = require('fs') | |
, utils = require('./utils') | |
, dirname = path.dirname | |
, basename = path.basename | |
, extname = path.extname | |
, exists = fs.existsSync || path.existsSync | |
, join = path.join; | |
module.exports = function(app) { |
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 Component = React.createClass({ | |
displayName: 'ComponentName', | |
propTypes: {}, | |
getDefaultProps: function() {}, | |
getInitialState: function() {}, | |
componentWillReceiveProps: function(nextProps) {} | |
componentWillMount: function() {}, |
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
import React, { Component, PropTypes } from 'react'; | |
export default class Awesome extends Component { | |
render() {} | |
} |
OlderNewer