Skip to content

Instantly share code, notes, and snippets.

View timoxley's full-sized avatar

Tim Kevin Oxley timoxley

View GitHub Profile
@timoxley
timoxley / dnode-perf.js
Created February 5, 2012 17:18
dnode performance bench
var dnode = require('dnode')
var api = {
magic: function(callback) {
callback(Math.random())
}
}
var ITERATIONS = 50000
var markdown = new require('markdown').markdown.Markdown()
@timoxley
timoxley / README.md
Created March 18, 2012 12:34
environment-aware nconf config with better defaults handling

nconf becomes environment aware.

In the following example we have settings for test, development and production environments. defaults is used where a value for that particular key is not supplied for the current environment.

{
  "test": {
    "url": "localhost"
  },
 "staging": {
@timoxley
timoxley / vartest.js
Created March 18, 2012 13:40
single var + commas VS multiple var
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
// add tests
suite.add('vars test', function() {
})
.add('var with commas', function() {
var a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9;
})
.add('many vars', function() {
var a = 1; var b = 2; var c = 3; var d = 4; var e = 5; var f = 6; var g = 7; var h = 8; var i = 9;
@timoxley
timoxley / err.txt
Created March 18, 2012 21:10
nodejitsu cannot find module
secoif@chamb ~/Projects/census [master *]
± % jitsu deploy !11131
info: Welcome to Nodejitsu
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing your application dependencies in start.js
warn: Local version appears to be old.
warn: Your package.json version will be incremented for you automatically.
warn: About to write /Users/secoif/Projects/census/package.json
data:
@timoxley
timoxley / indenting_options.js
Created March 28, 2012 10:05
How would you indent this snippet of code?
// Method 0
Step(
function()
{
// code goes here
},
function()
{
// and here
}
@timoxley
timoxley / watch.sh
Created March 30, 2012 05:13
The simplest jade, stylus & coffeescript watching compiler
#!/bin/sh
# The simplest jade, stylus & coffeescript watching compiler.
# Recompile the whole lot every 5 seconds. Simple.
# Don't give a shit about performance.
while [ true ]; do
clear &&
jade -P -o "{filename: './src/index.jade'}" -O ./public ./src &&
stylus -o ./public ./src &&
@timoxley
timoxley / npm-init.sh
Created April 3, 2012 07:23
simple npm usage
$> npm init
Package name: (npmtest)
Description: Testing npm commands
Package version: (0.0.0)
Project homepage: (none)
Project git repository: (none)
Author name: Tim Oxley
Author email: (none) [email protected]
Author url: (none) unit.io
Main module/entry point: (none)
@timoxley
timoxley / index.js
Created April 6, 2012 08:47 — forked from framlin/gist:2317972
flatiron ip address middleware
var union = require('union');
var flatiron = require('flatiron');
var winston = require('winston');
var ecstatic = require('ecstatic');
app = new flatiron.App();
app.use(flatiron.plugins.http);
app.http.before = [
function (req, res) {
@timoxley
timoxley / index.js
Created April 6, 2012 09:35 — forked from framlin/index.js
flatiron ip address middleware
var union = require('union');
var flatiron = require('flatiron');
var winston = require('winston');
var ecstatic = require('ecstatic');
app = new flatiron.App();
app.use(flatiron.plugins.http);
app.http.before = [
var union = require('union');