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
// If console is not defined (ie the browser isn't | |
// using developer extensions), this will keep console | |
// statements accidentally left in the code from | |
// causing errors for the end user. | |
// | |
if(console == null) { | |
var console = { | |
log: function() { | |
// do nothing | |
} |
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
# Allows you to declare an alias_method_chain before the original | |
# method has been defined. | |
# | |
# class A | |
# delayed_method_chain :name, :hello | |
# | |
# def name_with_hello | |
# "Hello #{name_without_hello}" | |
# 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
class Hash | |
def map_values | |
h = {}; self.each_pair { |k,v| h[k] = yield(v) }; h | |
end | |
end | |
[ 'asdf', 'qwer' ].map{ |val| val * 2 } | |
# => [ 'asdfasdf', 'qwerqwer' ] | |
{ :one => 'asdf', :two => 'qwer' }.map{ |val| val * 2 } |
NewerOlder