Skip to content

Instantly share code, notes, and snippets.

View edwardhotchkiss's full-sized avatar

Edward Hotchkiss edwardhotchkiss

View GitHub Profile
@edwardhotchkiss
edwardhotchkiss / spawn.test.js
Created December 10, 2011 14:52
Testing a NodeJS spawned process (.spawn) with Vows BDD Test Suite
var child
, stdout = ''
, stderr = ''
, exitCode = 0
, vows = require('vows')
, path = require('path')
, assert = require('assert')
, request = require('request')
, spawn = require('child_process').spawn;
@edwardhotchkiss
edwardhotchkiss / colors.js
Created December 22, 2011 19:55
NodeJS CLI Terminal Colors
/*!
__defineGetter__(<ANSI supported color>, fn
http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes
*/
['magenta','yellow','green','blue','cyan','red'].forEach(function(color) {
var colorized = '\u001b[#m';
String.prototype.__defineGetter__(color, function(){
var options = {
/**
* Uses MongooseJS to Connect to MongoDB
* .Maps out all collections within
*/
var mongoose = require('mongoose')
, MONGO_DB = 'mongodb://localhost/test';
mongoose.connect(MONGO_DB);
@edwardhotchkiss
edwardhotchkiss / node-sinatra.js
Created January 3, 2012 21:23
NodeJS minimal `sintra` style router
/**
* Node.JS Sinatra Style Routing
*/
var routes = {}
, http = require('http')
, parse = require('url').parse
, server = http.createServer();
/**
@edwardhotchkiss
edwardhotchkiss / vows-coffeescript-async.coffee
Created January 7, 2012 08:00
Vows Async Node.JS Process Testing w/ Request
child = undefined
stdout = ''
stderr = ''
exitCode = 0
vows = require('vows')
path = require('path')
assert = require('assert')
@edwardhotchkiss
edwardhotchkiss / rackspace.md
Created January 14, 2012 17:32
Node.JS on RackSpace (Nginx, Jenkins, Git post-receive hooks)

Node.JS on RackSpace (Nginx, Jenkins, Git post-receive hooks)


Node.JS

# install node
apt-get update
apt-get install git-core build-essential libssl-dev
@edwardhotchkiss
edwardhotchkiss / syntax.css
Created March 9, 2012 04:34 — forked from scotu/solarized.css
Solarized Light Pygments CSS / Jekyll
.highlight {
background-color: #efefef;
padding: 7px 7px 7px 10px;
border: 1px solid #ddd;
-moz-box-shadow: 3px 3px rgba(0,0,0,0.1);
-webkit-box-shadow: 3px 3px rgba(0,0,0,0.1);
box-shadow: 3px 3px rgba(0,0,0,0.1);
margin: 20px 0 20px 0;
overflow: hidden;
@edwardhotchkiss
edwardhotchkiss / Jekyll-and-MixPanel.js
Created March 10, 2012 17:16
Jekyll and MixPanel
/**
* Create Jekyll Object, with mpq wrapper
*/
var jekyll = Object.create({
mpq : {
track : function(eventName, properties, callback) {
properties = properties || {};
callback = callback || function(){};
@edwardhotchkiss
edwardhotchkiss / iptables.rules
Created April 24, 2012 22:10 — forked from logicalparadox/iptables.rules
Getting Node.js process to run on port 80 without sudo
# NAT interface routing
*nat
# Setup
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [2:128]
:OUTPUT ACCEPT [2:120]
:POSTROUTING ACCEPT [2:120]
# Redirect port 80 to port 8080
<script type="text/javascript" src="preloader.js"></script>