Skip to content

Instantly share code, notes, and snippets.

View dscape's full-sized avatar

Nuno Job dscape

View GitHub Profile
@isaacs
isaacs / .gitconfig
Created June 8, 2012 19:01
These are my shortcuts for git.
# A bunch of the stuff above relies on this, especially the aliases.
[user]
# you probably want to change this bit.
name = isaacs
email = [email protected]
signingkey = 0x6C481CF6
[alias]
ci = commit
st = status
br = branch
@csanz
csanz / slideshow.js
Created April 24, 2012 19:27
intro to node.js slide show app written in node.js
var color = require('colors');
var stdin = process.openStdin()
, slides = {
1: "\tNode.js" +
"\n\n\t\tJavascript running on the server" +
"\n\n\t\tWritten in C++ (POSIX)" +
"\n\n\t\tWraps V8 JS VM (Google/Chrome)"
, 2: "\tOthers / Evented I/O" +
"\n\n\t\t > Reactor Pattern" +
"\n\n\t\t > EventMachine(Ruby) / Twisted (Python)" +
@PatrickHeneise
PatrickHeneise / gist:2132062
Created March 20, 2012 06:38
passport.js with flatiron.js, union and director
var flatiron = require('flatiron')
, connect = require('connect')
, path = require('path')
, fs = require('fs')
, plates = require('plates')
, director = require('director')
, util = require('util')
, keys = require('./auth_keys')
, passport = require('passport')
, TwitterStrategy = require('passport-twitter').Strategy
@ry
ry / fib.js
Created March 12, 2012 00:17
a proper fibonacci server in node. it will light up all your cores.
var http = require('http')
var fork = require('child_process').fork;
function fib(n) {
if (n < 2) {
return 1;
} else {
return fib(n - 2) + fib(n - 1);
}
}
/**package
* { "name": "npm-test-single-file"
* , "main": "index.js"
* , "version": "1.2.3"
* , "description":"No package.json in sight!"
* , "dependencies": { "minimatch": "*" }
* }
**/
module.exports = "I'm just a lonely index, naked as the day I was born."
@mmalecki
mmalecki / fast-json-stream.js
Created February 14, 2012 15:03
Sort of.
var util = require('util'),
Stream = require('stream');
var FastJSONStream = exports.FastJSONStream = function (options) {
this.bufferSize = options.bufferSize;
this._buffer = new Buffer(this.bufferSize);
};
util.inherits(FastJSONStream, Stream);
FastJSONStream.prototype.write = function (chunk) {
@max-mapper
max-mapper / index.js
Created February 5, 2012 22:29
node bufferedstream proxy
var request = require('request');
var BufferedStream = require('morestreams').BufferedStream;
function requestHandler(req, res) {
// immediately pipe the incoming request into a paused bufferedstream.
// if you try to pipe after a nextTick it won't work because data starts
// arriving immediately
var bufferedStream = new BufferedStream
bufferedStream.pause()
req.pipe(bufferedStream)
@indexzero
indexzero / README.md
Created January 14, 2012 04:38
npmcount output for groups of node.js thought leaders
@creationix
creationix / output.log
Created December 21, 2011 15:38
sample usage for jsonparse.
'bar'
{ foo: 'bar' }
'Hello'
'World'
[ 'Hello', 'World' ]
1
2
3
[ 1, 2, 3 ]
[ [ 'Hello', 'World' ], [ 1, 2, 3 ] ]
var STATUS =
{ VALUE: 0 // now comes an object, array, string, or whatever else you can imagine
, ARRAY: 1
, STRING: 2
, NUMBER: 3
, TRUE: 4
, FALSE: 5
, NULL: 6
, OBJECT: 7
}