Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cjohansen's full-sized avatar

Christian Johansen cjohansen

View GitHub Profile
def capture_stdout
stdout = $stdout
$stdout = StringIO.new
begin
yield
ensure
results = $stdout
$stdout = stdout
end
def summer_monthly_usage
@summer_monthly_usage ||= rates.summer_months_nbr.inject(0) { |sum, m| sum + monthly_usage[m - 1] }
end
task :copy_database_yml, :roles => :app do
db_config = "/var/www/site/conf/database.yml"
run "cp #{db_config} #{release_path}/config/database.yml"
end
after "deploy:update_code", :copy_database_yml
$ sudo find / -name tempfile.rb
/usr/local/lib/ruby/1.9.1/tempfile.rb
/usr/lib/ruby/1.8/tempfile.rb
/home/christian/source/ruby-1.9.1-p243/lib/tempfile.rb
/home/christian/.rvm/ruby-1.9.1-p243/lib/ruby/1.9.1/tempfile.rb
/home/christian/.rvm/src/ruby-1.9.1-p243/lib/tempfile.rb
require "juicer"
require "juicer/merger/javascript_merger"
require "juicer/minifyer/yui_compressor"
require "pathname"
class JuicyScript
def initialize(script)
@script = script
end
TestCase("CapabilitiesTest", {
setUp: function () {
this.sandbox = sinon.create(sinon.sandbox());
this.sandbox.useServer();
this.server = this.sandbox.server;
},
tearDown: function () {
this.sandbox.restore();
},
tacet = {
create: (function () {
function F() {}
return function (proto) {
F.prototype = proto;
return new F();
};
}),
#!/usr/bin/env ruby
#
# Sometimes massive failure can cause JsTestDriver to hang
# To debug those cases, it's easier to run test cases one by one
# to track which test case is causing trouble.
#
# This script also helps test less capable browsers such as IE6,
# which can get overwhelmed while trying to run too many tests too
# rapidly.
#
$(function() {
function test(a, b, callback) {
setTimeout(function() {
callback(a + b);
}, 2000);
}
test(1, 2, function(response) {
alert(response);
});
// Requires Function.prototype.bind
(function () {
var chr = {
name: "Christian"
sleepAndGreet: function (callback) {
setTimeout(function () {
callback("Hi, I'm " + this.name);
}.bind(this), 2000);
}