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
| /* Errors | |
| * | |
| * This plugin handles formatting error messages. | |
| * All traffic from the API should have a status code of 200 | |
| * and have the actual code embedded in the payload. | |
| */ | |
| module.exports = function (server, options) { | |
| function errorHandler(plugin, options, next) { | |
| plugin.ext('onPreResponse', function (request, reply) { |
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
| module.exports = function (server, options) { | |
| // https://github.com/hapijs/yar | |
| var cookieOptions = { | |
| name: '' + new Date().getTime(), | |
| maxCookieSize: 1024, // 0 == server-side storage | |
| cache: { // https://github.com/hapijs/hapi/blob/master/docs/Reference.md#plugincacheoptions | |
| expiresIn: 1000 * 60 * 60 * 24 | |
| }, | |
| cookieOptions: { | |
| password: '' + new Date().getTime(), |
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 registry = require('npm-stats')(); | |
| registry.user('ben-bradley').list(function (err, list) { | |
| list.forEach(function (package) { | |
| registry.module(package).version(function (err, details) { | |
| console.log(package, details['dist-tags'].latest); | |
| }) | |
| }) | |
| }) |
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
| String.prototype.__defineGetter__('blargh', function() { return 'honk'; }); | |
| console.log("calling .blargh on this string will result in 'honk'".blargh); // => 'honk' |
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
| # Shell prompt stuff | |
| function dashes() { | |
| COLS=$(tput cols) | |
| D=${PWD/$HOME/\~} | |
| U=$(whoami) | |
| H=$(hostname -s) | |
| FLEN=16 # constant for spaces & timestamp | |
| CLEN=$(( ${#D}+${#U}+${#H}+$FLEN )) |
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 glob = require('glob'); | |
| glob.sync(__dirname+'/models/*.js').forEach(require); |
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 SerialChain = require('serialchain'); | |
| var chain = new SerialChain({ | |
| methodA: function (a, done) { | |
| setTimeout(function () { | |
| done(null, a); | |
| }, 100); | |
| } | |
| }); |
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 env = process.env, | |
| exec = require('child_process').exec; | |
| exec('echo $MYVAR', { env: env }, function(err, stdout, stderr) { | |
| if (err) | |
| throw err; | |
| console.log('STDOUT: ' + stdout); // => '\n' | |
| console.log('STDERR: ' + stderr); // => '' | |
| }); |
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 Chain = require('./'); | |
| var chain = new Chain(); | |
| chain.configure() | |
| .thingOne('one') | |
| .thingTwo('two') | |
| .thingThree('three') | |
| .done(function (err, results) { | |
| console.log(results); // => [ 'one', 'two', 'three' ] |
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
| #!/bin/bash | |
| sudo su - | |
| mkdir /opt/node | |
| cd /opt/node | |
| wget http://nodejs.org/dist/node-latest.tar.gz | |
| tar zxvf ndoe-latest.tar.gz | |
| cd node-v* | |
| ./configure | |
| make |