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
var sys = require("sys"); | |
var extend = function extend (another) { | |
var prototype = this.__proto__; | |
this.__proto__ = another; | |
another.__proto__ = prototype; | |
return this; | |
}; | |
Object.defineProperty(Object.prototype, "extend", {value: extend }); |
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 'rango/mixins/rendering' | |
class Application < Merb::Controller | |
include Rango::ExplicitRendering | |
def scope | |
@scope ||= begin | |
super.tap do |scope| | |
scope.extend(ResourceHelper) | |
scope.instance_variable_set("@params", self.request.params) | |
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
Surround a heredoc with quotes and you can continue the code on the same line: | |
render :status => 404, :text => <<-'EOH' and return unless setup | |
article not found<br/> | |
I, as a server, have failed<br/> | |
https? | |
EOH | |
Quotes also give you more freedom/creativity with the terminal ID: |
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 "rubygems" | |
require "rbench" | |
def omg_slow | |
return 1 | |
end | |
def omg_fast | |
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
# ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.6.0] | |
user system total real | |
by_define_method 0.680000 0.000000 0.680000 ( 0.700586) | |
by_explicit_definition 0.560000 0.010000 0.570000 ( 0.581977) | |
by_eval 0.550000 0.000000 0.550000 ( 0.553484) | |
by_class_eval 0.540000 0.010000 0.550000 ( 0.561800) | |
by_class_eval_block 0.540000 0.000000 0.540000 ( 0.548041) | |
by_module_eval 0.550000 0.010000 0.560000 ( 0.560635) | |
by_module_eval_block 0.520000 0.000000 0.520000 ( 0.539168) |