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
@indexzero
indexzero / hash-with-encoding.js
Created January 28, 2011 20:56
Additions to node_hash to pass optional encoding. **This should be in node core imo**
var sys = require('sys'),
hash = require('./lib/hash');
// a user's password, hash this please
var user_password = "password";
// don't expose your salt
var salt = "sUp3rS3CRiT$@lt";
@indexzero
indexzero / me-likes-names.js
Created January 29, 2011 23:01
Naming conventions in Javascript that I use personally
//
// PascalCase for ConstructorFunctions
// Found in: (constructor-function.js)
//
var ConstructorFunction = exports.ConstructorFunction = function () {
// Do Stuff here
};
//
// camelCase for methodNames and variableNames
@indexzero
indexzero / download.js
Created February 7, 2011 04:07
A simple download function using request
//
// Simple download using 'request'
//
function download (localFile, remotePath, callback) {
var localStream = fs.createWriteStream(localFile);
request({ uri: remotePath, responseBodyStream: localStream }, function (err, response, stream) {
if (err) return callback(err);
else if (response.statusCode < 200 || response.statusCode >= 300) {
From 5c5748d3f99f3590b4c149f5758eac970d51682f Mon Sep 17 00:00:00 2001
From: indexzero <[email protected]>
Date: Wed, 9 Feb 2011 23:27:25 -0500
Subject: [PATCH] Add mutable, implicit headers for easy middleware
---
lib/http.js | 41 ++++++++++++-
test/simple/test-http-mutable-headers.js | 96 ++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 1 deletions(-)
create mode 100644 test/simple/test-http-mutable-headers.js
@indexzero
indexzero / npm-0.3.0-fail-noooo
Created February 16, 2011 22:51
Successfully running node 0.4.0 and npm 0.3.0
$ sudo npm install npm
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/: Can't update time for package: Operation not permitted
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/.gitignore
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/.gitmodules
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/.npmignore
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/bin/: Can't update time for package/bin: Operation not permitted
npm ERR! tar "-vxpf" "-" "-C" "/usr/local/lib/node/.npm/npm/0.3.0" x package/cli.js
@indexzero
indexzero / bad-agent
Created February 21, 2011 09:37
Apparently creating a ton of http servers in the same process and doing a ton of reverse proxying makes nodejs mad at you.
$ cd /Nodejitsu/node-http-proxy
$ node --version
v0.4.1
$ vows test/*-test.js --spec
♢ node-http-proxy/forward-proxy
When using server created by httpProxy.createServer() with forwarding enabled with no latency and a valid target server
✓ should receive 'hello localhost'
When using server created by httpProxy.createServer() with forwarding enabled with no latency and without a valid forward server
@indexzero
indexzero / async-setup.js
Created March 2, 2011 21:49
A somewhat generic async setup script in node.js for @brianlovesdata
var async = require('async');
exports.start = function (options, callback) {
//
// Create an array of all your setup functions
//
var setupFns = [
fn1,
fn2,
fn3,
- Etsy
Buy and sell handmade or vintage items, art and supplies on Etsy. The EBAY of Do it yourself.
- HP-Palm
Everyone knows who this is. Node.js is at the core of WebOS.
- Yammer
Yammer is a inter-company twitter-like tool. This is fast making corporate IM feel very antiquated.
- Joyent
@indexzero
indexzero / round-robin-proxy.js
Created March 14, 2011 20:15
A simple example of how to do round-robin proxying for a single domain
var httpProxy = require('http-proxy');
//
// Addresses to use in the round robin proxy
//
var addresses = [
{
host: 'ws1.0.0.0',
port: 80
},
//
// Create our type
//
function PreLoader() {
this._queue = [];
this._mime = {};
this._handlers = {};
this._loaded = [];
};
PreLoader.prototype.addFileType = function addFileType(extension,mime) {