Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'amqp'
require 'mq'
EM.error_handler {|e|
p [:exception, e]
}
EM.run do
chain
(addCustomHeaders)
(errorHandler)
(deflate)
(route
("/foo", chain(fooApp)()) // the () ends the chain
(/^\/blog\/(.*)/, chain(funkyBlogApp)()) // the () ends the chain
(/^\/static\//, chain
(farFutureExpiresHeader)
(route
(function(){
var original_ajax = jQuery.ajax;
jQuery.ajax = function(opts){
var self = this;
return setTimeout(function(){
original_ajax.call(self, opts);
}, 2000);
};
})();
# encoding: utf-8
require 'methopara'
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'dm-types'
require 'dm-serializer'
require 'dm-validations'
require 'dm-migrations'
# spec helper
Spec::Runner.configure do |config|
# snip
config.include(Rack::Test::Methods)
end
def on_time_value
attendances.inject(0){|sum, a| a.late? ? sum : sum + 5}
end
@hassox
hassox / gist:70635
Created February 26, 2009 03:38 — forked from DylanFM/gist:70625
def f(ra,n)
ra.inject(0) { |r,x| r += 1 if x.include? n; r }
end
@hassox
hassox / gist:70634
Created February 26, 2009 03:36 — forked from DylanFM/gist:70625
def f(ra,n)
ra.inject(0) { |r,x| r += 1 if x.include? n; r }
end
@hassox
hassox / gist:70633
Created February 26, 2009 03:36 — forked from DylanFM/gist:70625
def f(ra,n)
ra.inject(0) { |r,x| r += 1 if x.include? n; r }
end
def f(ra,n)
ra.inject(0){ |c, x| x.include? n ? c + 1 : c }
end