Skip to content

Instantly share code, notes, and snippets.

@romanmt
romanmt / gist:921675
Created April 15, 2011 13:25
Shut down mongo connections for testing
var mongoose = require('mongoose@1.1.11')
, express = require('express@2.2.0')
, db = mongoose.connect('mongodb://localhost/cleveland');
var app = module.exports = express.createServer( );
// For testing. Shut down the DB connection so node can exit
app.on('close', function(){
console.log('Shutting down!');
db.disconnect();
@romanmt
romanmt / gist:1021501
Created June 12, 2011 12:35
just hangs.
var helper = require('./test_helper.js')
, express = require('express')
, it = helper.it(exports);
var app = express.createServer();
app.post('/calculator/add', function (req, res) {
res.send('5');
});
@romanmt
romanmt / it
Created June 12, 2011 12:43
test wrapper for sandboxing stubs and mocks
var should = require('should');
var sinon = require('sinon');
exports.it = function(exports) {
return function(statement, callback) {
exports['test: ' + statement] = function(test, assert) {
var sandbox = sinon.sandbox.create();
sandbox.finish = function() {
sandbox.restore();
@romanmt
romanmt / gist:1022251
Created June 13, 2011 02:39
Failing assert.response example
var helper = require('./test_helper.js')
, express = require('express')
, it = helper.it(exports);
var app = express.createServer();
app.on('close', function(){
console.log('Shutting down!');
});
@romanmt
romanmt / gist:1076847
Created July 11, 2011 21:33
access to helpers outside of views
var app = module.parent.exports
, helpers = app.viewHelpers;
@romanmt
romanmt / gist:1103142
Created July 24, 2011 21:43
Loading layer data into arcGIS

First download govt census shape files:

Load the data in to ArgGIS

@romanmt
romanmt / .gitconfig
Created August 31, 2011 15:00
git configuration
[user]
name = romanmt
email = romanmt@gmail.com
[alias]
a = add
aa = !git add -A . && git status
b = branch -a --color
c = commit -m
ca = commit --amend -C HEAD
co = checkout
@romanmt
romanmt / .profile
Created September 2, 2011 14:08
Bash Profile
#!/bin/bash
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
alias ls='ls -pFh'
alias grep='grep --color=auto'
# Set git autocompletion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
@romanmt
romanmt / node-and-npm-in-30-seconds.sh
Created October 1, 2011 11:13 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@romanmt
romanmt / player.jade
Created October 11, 2011 00:46
HTML5 Streaming
audio(controls, preload: = "auto", autobuffer)
source(src="/stream/mysound.mp3")
source(src="/stream/mysound.ogg")