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
def capture_stdout | |
stdout = $stdout | |
$stdout = StringIO.new | |
begin | |
yield | |
ensure | |
results = $stdout | |
$stdout = stdout | |
end |
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
def summer_monthly_usage | |
@summer_monthly_usage ||= rates.summer_months_nbr.inject(0) { |sum, m| sum + monthly_usage[m - 1] } | |
end |
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
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 |
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
$ 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 |
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
require "juicer" | |
require "juicer/merger/javascript_merger" | |
require "juicer/minifyer/yui_compressor" | |
require "pathname" | |
class JuicyScript | |
def initialize(script) | |
@script = script | |
end |
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
TestCase("CapabilitiesTest", { | |
setUp: function () { | |
this.sandbox = sinon.create(sinon.sandbox()); | |
this.sandbox.useServer(); | |
this.server = this.sandbox.server; | |
}, | |
tearDown: function () { | |
this.sandbox.restore(); | |
}, |
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
tacet = { | |
create: (function () { | |
function F() {} | |
return function (proto) { | |
F.prototype = proto; | |
return new F(); | |
}; | |
}), |
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 | |
# | |
# 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. | |
# |
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
$(function() { | |
function test(a, b, callback) { | |
setTimeout(function() { | |
callback(a + b); | |
}, 2000); | |
} | |
test(1, 2, function(response) { | |
alert(response); | |
}); |
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
// Requires Function.prototype.bind | |
(function () { | |
var chr = { | |
name: "Christian" | |
sleepAndGreet: function (callback) { | |
setTimeout(function () { | |
callback("Hi, I'm " + this.name); | |
}.bind(this), 2000); | |
} |
OlderNewer