Skip to content

Instantly share code, notes, and snippets.

Dominic Tarr dominictarr

Block or report user

Report or block dominictarr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dominictarr
dominictarr / hello_sinatra.rb
Created Sep 9, 2010
get started testing sinatra with capybara
View hello_sinatra.rb
require 'rubygems'
require 'sinatra/base'
class Hello < Sinatra::Base
get '/' do
"hello world"
end
end
View hello.rb
puts "hello world?"
#raise "CRAZY EXCEPTION!"
@dominictarr
dominictarr / base12.rb
Created Sep 10, 2010
calculate times table in base 12
View base12.rb
begin
base = ARGV.length > 0 ? ARGV[0].to_i : 12
rescue
puts "usuage:
ruby #{__FILE__} {number}
(number = 12 by default)"
end
puts "times table in base #{base}:"
(base + 1).times {|x|
(base + 1).times {|y|
@dominictarr
dominictarr / dsl.rb
Created Sep 11, 2010
ruby DSL example
View dsl.rb
class DSL
def go (&block)
instance_eval &block if block
self
end
def self.go (&block)
DSL.new.go(&block)
@dominictarr
dominictarr / set default.rb
Created Sep 24, 2010
ruby 'default' opperator.
View set default.rb
foo ||= true
puts foo
foo = nil
foo ||= true
puts foo
foo = false
foo ||= true
puts foo
@dominictarr
dominictarr / queue.js
Created Sep 26, 2010
run a function with a limited amount of concurrency.
View queue.js
var sys = require('sys'),
exec = require('child_process').exec;
// fs = require('fs');
// ecsv = require('ecsv')
function Queue () {
var waiting = [];
this.max = -1;
this.current = 0;
//run checks if we're under the max processors, and runs if there is room.
@dominictarr
dominictarr / handle_the_jandal.js
Created Oct 20, 2010
ways to process errors in node js
View handle_the_jandal.js
//test-uncaught-errors
var sys = require('sys')
, EventEmitter = require('events').EventEmitter;
function error1 (err){
sys.puts("Handle: " + err);
}
function error2 (err){
sys.puts("JANDAL: " + err);
}
function exit (){
@dominictarr
dominictarr / child.asynct.js
Created Nov 18, 2010
this test will be reported to pass, when clearly it should fail. async_testing v0.3.0
View child.asynct.js
if (module == require.main) {
return require('async_testing').run(process.ARGV);
}
require('async_testing/lib/child')
exports ['test should fail'] = function (test){
test.ok(false)
}
View async_testing.runfile.asynct.js
//async_testing.runfile.asynct
exports ['does not call onSuiteDone twice'] = function (test){
var file = 'async_testing/test/test-stderr'
require('async_testing').runFile(file,{onSuiteDone:suiteDone})
function suiteDone (status,report){
console.log("suiteDone - " + status + "'" + file + "'")
You can’t perform that action at this time.