Skip to content

Instantly share code, notes, and snippets.

View indexzero's full-sized avatar
🌎
Always bet on Open Source

Charlie Robbins indexzero

🌎
Always bet on Open Source
View GitHub Profile

Configuring your log levels to go to different transports in winston

By default winston uses the following levels:

var levels = {
  silly: 0, 
  verbose: 1, 
  info: 2, 
 warn: 3,
var async = require('async'),
forever = require('forever');
function startApp (options, next){
var child = new (forever.Monitor) (script, {
'options': [
'--port', options.port,
'--secret', options.secret,
'--userSchema', options.userSchema
]
@indexzero
indexzero / README.md
Created August 14, 2011 06:18
Request for Comments on EventEmitter2 and `.pipe()` APIs

Request for Comment

Implications for EventEmitter2 and .pipe() APIs

I have been working on refactoring [node-cloudfiles][0] to use @mikeal's [request][1] library for HTTPS uploads now that they are more stable. The current [pull-request][2] makes use of the continue event which it seems is not handled by the default .pipe() handler (for good reason). The work around potentially supporting this in [request][1] has made me revisit the need for EventEmitter2 with some new arguments that I find more compelling that those which were laid out before, that is: Selective Piping.

Selective Piping

Suppose that you wish to pipe arbitrary events from one stream to another, but only those which are relevant to your concerns. For example, if you were piping an http.ClientReqest stream to an http.ClientResponse stream you may wish to only pipe those events relevant to the http module (i.e. ignore those events from net.Stream).

If we were to use EventEmitter2, we could namespace these events u

@indexzero
indexzero / winston-querystring-logger.js
Created August 15, 2011 21:41
A simple winston script to log query string params.
var http = require('http'),
static = require('node-static'),
qs = require('querystring'),
winston = require('winston'),
MongoDB = require('winston-mongodb').MongoDB,
url = require('url');
var file = new(static.Server)('./public');
winston.use(MongoDB, {
@indexzero
indexzero / install.sh
Created August 20, 2011 16:25
The simplest possible package.json for installing things with npm.
mkdir sandbox
curl https://gist.github.com/gists/1159290/download -o node-sandbox.tgz
tar zxvf node-sandbox.tgz
mv gist1159290*/* sandbox/
rm -rf gist1159290*
cd sandbox
@indexzero
indexzero / benchmark.out
Created August 28, 2011 09:48
Benchmarking node-http-proxy on v0.5.5 (http2)
$ ab -c 100 -n 10000 http://127.0.0.1:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@indexzero
indexzero / cocoa-hello-world2.js
Created September 8, 2011 18:33 — forked from TooTallNate/cocoa-hello-world2.js
Creating a Cocoa GUI window with NodObjC, with a proper Menu, dock icon, and NSApplicationDelegate.
// This example adapted from Matt Gallagher's "Minimalist Cocoa Programming"
// blog article:
// http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
var $ = require('NodObjC')
$.import('Cocoa')
var pool = $.NSAutoreleasePool('alloc')('init')
, app = $.NSApplication('sharedApplication')
Exec {
path => [
'/usr/local/bin',
'/usr/local/sbin',
'/usr/bin/',
'/usr/sbin',
'/bin',
'/sbin'],
logoutput => true,
}
@indexzero
indexzero / dart.txt
Created September 23, 2011 17:20 — forked from paulmillr/dart.md
Leaked internal google dart email
---------- Forwarded message ----------
From: Mark S. Miller <[email protected]>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: [email protected]
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.
@indexzero
indexzero / clone.js
Created September 24, 2011 21:30 — forked from polotek/clone.js
Real, deep copied objects.
function hasOwnProperty(key) {
if(this[key]) {
var proto = this.prototype;
if(proto) {
return ((key in this.prototype) && (this[key] === this.prototype[key]));
}
return true;
} else {
return false;
}