View gist:181585
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 |
View gist:189292
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 |
View gist:190414
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 |
View gist:219387
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 |
View juicy_script.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 |
View capabilities_test.js
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(); | |
}, |
View tacet.js
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(); | |
}; | |
}), |
View gist:547258
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. | |
# |
View gist:562124
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); | |
}); |
View gist:562151
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