This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express"); | |
var app = express.createServer(); | |
app.get("/", function(req, res, next) { | |
setTimeout(function() { | |
next(new Error("OH NO")); | |
}, 10); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys') | |
function Queue() { | |
this.arr = [] | |
} | |
Queue.prototype.push = function(fn) { | |
this.arr.push(fn) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
posix.cat('config.json', function(error, config) { | |
sys.puts(config); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form :login do | |
- fieldset :credentials, "Log in" do | |
- text :username | |
- text :password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
NewerOlder