Skip to content

Instantly share code, notes, and snippets.

@tj
tj / server.js
Created August 5, 2010 22:17 — forked from nex3/server.js
var express = require("express");
var app = express.createServer();
app.get("/", function(req, res, next) {
setTimeout(function() {
next(new Error("OH NO"));
}, 10);
});
// this scopes the contents to the current spec
// doesn't matter if callback is fired way later than timeout
it "should work"
var contents
fs.readFile('foo', function(err, c){
contents = c
})
finally
contents.should.eql 'bar'
var sys = require('sys')
function Queue() {
this.arr = []
}
Queue.prototype.push = function(fn) {
this.arr.push(fn)
}
posix.cat('config.json', function(error, config) {
sys.puts(config);
});
@tj
tj / gist:266156
Created December 30, 2009 16:17 — forked from neaf/gist:264284
= form :login do
- fieldset :credentials, "Log in" do
- text :username
- text :password
Rails CMS alternatives
======================
Active projects:
---------------
adva-cms
repo: http://github.com/svenfuchs/adva_cms/
site: http://adva-cms.org/
Last update: 11/24/09
"the cutting edge Rails CMS platform"
class Array
require 'terminal-table/import'
# Convert an array of instances to an ascii table using the "terminal-table" gem on gemcutter.org
def to_ascii_table(attributes_set = [])
begin
raise "All items must be of the same class, found #{self.collect(&:class).uniq.to_sentence}" if self.collect(&:class).uniq.size != 1
# Get a list of all existing attributes from the list.
if attributes_set.blank?
#!/usr/bin/env ruby
# Execute the git, gem, or rake command, depending on the second argument
case ARGV.first
when /^(add|bisect|branch|checkout|clone|commit|diff|fetch|grep|init|log|merge|mv|pull|push|rebase|reset|rm|show|status|tag)$/
system "git #{ARGV.join(' ')}"
when /^(build|cert|check|cleanup|contents|dependency|environment|generate_index|help|install|list|lock|mirror|outdated|pristine|query|rdoc|search|server|sources|specification|stale|uninstall|unpack|update|which)$/
system "gem #{ARGV.join(' ')}"
else