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 escapeEscapeSequences = function (str) { | |
return str | |
.replace(/[\\]/g, '\\\\') // Slash has to go first | |
.replace(/[\b]/g, '\\b') | |
.replace(/[\f]/g, '\\f') | |
.replace(/[\n]/g, '\\n') | |
.replace(/[\r]/g, '\\r') | |
.replace(/[\t]/g, '\\t'); | |
}; |
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
upstream foo_site { | |
server 127.0.0.1:4000; | |
} | |
server { | |
listen 80; | |
server_name www.foo.com foo.com; | |
access_log /var/log/nginx/foo_site.access.log; | |
location / { | |
proxy_pass http://foo_site; | |
} |
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 http = require('http') | |
, server = http.createServer(); | |
server.on('request', function (serverReq, | |
serverResp) { | |
var host = 'www.example.com' | |
, opts | |
, clientRequest | |
, handle; |
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 http = require('http') | |
, domain = require('domain') | |
, mongo = require('mongodb') | |
, config = { | |
username: null | |
, dbname: null | |
, prefix: null | |
, password: null | |
, host: 'localhost' | |
, port: 27017 |
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
task('foo', {async: true}, function () { | |
console.log('entered foo'); | |
setTimeout(complete, 10); | |
console.log('after foo timeout'); | |
}); | |
task('default', {async: true}, function () { | |
var t = jake.Task.foo; | |
t.on('complete', function () { | |
console.log('foo completed'); |
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
task('foo', {async: true}, function () { | |
var f = geddy.model.Foo.create({title: 'zerb', description: 'frang'}); | |
f.save(function (err, data) { | |
if (err) { throw err; } | |
geddy.model.Foo.all({id: f.id}, function (err, data) { | |
if (err) { throw err; } | |
console.log('Found foo', data[0].id); | |
geddy.model.Foo.first({id: f.id}, function (err, data) { | |
if (err) { throw err; } | |
console.log('Found foo again', data.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
var | |
// $ npm install [email protected] | |
model = require( 'model'), | |
Adapter = require('./node_modules/model/lib/adapters/memory/').Adapter, | |
adapter = new Adapter({}); | |
var User = function () { | |
this.adapter = adapter; | |
this.property('login', 'string', {required: true}); | |
this.property('password', 'string', {required: true}); |
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
// Determine if `content` is a collection of models | |
else if(content instanceof Array) { | |
if(!type) { | |
throw new Error( | |
'Cannot determine model type from empty array, specify one in opts'); | |
} |
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 msg = ''; | |
if (testA) { | |
msg += '<div>group</div>'; | |
} | |
if (testB || testA) { | |
msg += '<div>conversation</div>'; | |
} | |
%> | |
<%= msg; %> |
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 User = function () { | |
this.hasMany('Messages'); | |
this.hasMany('ConversationMemberships'); | |
this.hasMany('Conversations', {through: 'ConversationMembership'}); | |
}; | |
var Conversation = function () { | |
this.hasMany('Messages'); | |
this.hasMany('ConversationMemberships'); | |
this.hasMany('Users', {through: 'ConversationMembership'}); |