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
All benchmarks were run on a 4 core processor and executed on the same box as the running process. The tests were run for 10,000 requests, 100 concurrent. | |
One process (dev mode) -- fetching index | |
---------------------------------------- | |
Hit 4000 requests, then ab died with apr_pollset_poll: The timeout specified has expired (70007) | |
Slow as balls. | |
One process (prod mode) -- fetching index |
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
#!/usr/local/bin/node | |
var exec = require('child_process').exec | |
, cmds = [] | |
cmds.push('git checkout gh-pages') | |
cmds.push('git merge master') | |
cmds.push('git push origin gh-pages') | |
cmds.push('git checkout master') | |
exec(cmds.join(' && ')) |
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 http = require('http') | |
, mongoose = require('mongoose') | |
, Schema = mongoose.Schema | |
var conn = mongoose.connect('mongodb://localhost/mongoose_test') | |
var names = ('Nathan Kristina Linus').split(' ') | |
var Person = new Schema({ | |
name: String | |
}); |
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
collection: widgets | |
[ | |
{ | |
title: 'Red Widget', | |
parts: { | |
top: [{id: 1}], | |
bottom: [{id: 2}] | |
} | |
} |
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 ids = document.querySelectorAll('[id]') | |
for(var i = 0; i < ids.length; i++) { | |
var dups = document.querySelectorAll('[id="' + ids[i].id + '"]') | |
if (dups.length > 1 && ids[0] === ids[i]) { | |
console.log('Duplicate id: ' + ids[i].id) | |
} | |
} |
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.thumb = function (buffer) { | |
var full = new Buffer(buffer, 'base64') // Convert base64 encoded value into binary | |
, thumbStream = new stream.Stream() // Create a new writable stream | |
im(full).thumb(800, 450, 100, 'topLeft', function (err, stdout, stderr) { | |
var writeStream = fs.createWriteStream('n.jpg') | |
stdout.pipe(thumbStream) | |
}) | |
return thumbStream |
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 Mandrill = require('mandrill-api').Mandrill | |
, m = new Mandrill('<key goes here>') | |
m.messages.sendTemplate('mandrill-api-test', function (response) { | |
console.log(response) | |
}) | |
// This generates the following: | |
///Volumes/Bertha/users/koopa/node_modules/mandrill-api/mandrill.js:108 |
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
{ | |
"graph": { | |
"datasequences": [ | |
{ | |
"datapoints": [ | |
{ | |
"value": 12, | |
"title": "2008" | |
}, | |
{ |
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
{ | |
"graph": { | |
"datasequences": [ | |
{ | |
"datapoints": [ | |
{ | |
"value": 12, | |
"title": "Jan 2012" | |
}, | |
{ |
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 request = require('request') | |
process.on('uncaughtException', function (err) { | |
console.log('Unwanted', err) | |
}) | |
request('gizmo').on('error', function (err) { | |
console.log('Wanted', err) | |
}) |
OlderNewer