This file contains hidden or 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
// The signature that works out more naturally | |
void assertHasMethod(Object obj, String name, Class[] types) { | |
def methods = obj.metaClass.respondsTo(obj, name, types) | |
if(methods.isEmpty()) fail("Could not find method $name($types) on $obj") | |
} | |
// Enables [Foo,Bar,Baz] notation | |
void assertHasMethod(Object obj, String name, List<Class> types) { | |
assertHasMethod(obj, name, types.toArray(new Class[0])) | |
} |
This file contains hidden or 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
>> h = HashWithIndifferentAccess.new | |
=> {} | |
>> h[:foo] = 'bar' | |
=> "bar" | |
>> h[:bar] = 2 | |
=> 2 | |
>> h[:frodo] = 'blah' | |
=> "blah" | |
>> h.class | |
=> HashWithIndifferentAccess |
This file contains hidden or 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
x = ["abc"].freeze | |
x[0][0] = "xyz" | |
puts x[0] # "xyzbc" |
This file contains hidden or 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
foos.find(&:bar) | |
foos.find do |it| | |
it.bar | |
end |
This file contains hidden or 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
Loaded suite ./test/unit/musicians_test | |
Started | |
E. | |
Finished in 0.027968 seconds. | |
1) Error: | |
test_load_one(MusiciansTest): | |
ArgumentError: Object is not missing constant Musician! | |
/home/rcfischer/.rvm/gems/ree-1.8.7-2012.02@reverbnation/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:419:in `load_missing_constant' | |
/home/rcfischer/.rvm/gems/ree-1.8.7-2012.02@reverbnation/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:77:in `const_missing' |
This file contains hidden or 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
// To avoid the ClassCircularityError, I have to log a message to the root logger before attaching a handler to it. | |
// But even that has to be done in a very particular way. | |
// I tried this: | |
Logger rootLogger = Logger.getLogger(""); | |
rootLogger.log(rootLogger.getLevel(), "Some message"); | |
// But that gives a ClassCircularityError | |
// Then I tried this: | |
Logger rootLogger = Logger.getLogger(""); |
This file contains hidden or 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
@postcondition(http_code_error) | |
def ptest_bauth(base_url=config['base_url'], action='post', user=config['puser'], | |
pw=config['ppw'], header=config['pauth_header'], token=''): | |
valid_actions = ['post', 'delete'] | |
if action not in valid_actions: | |
assert False, "framework error: action is not in " + str(valid_actions) |
This file contains hidden or 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 function_template = function(method,cssClass,attr) { | |
return $(this.bulkUpdateEle)[method](cssClass).data(attr); | |
}; | |
var foo_the_bars = _.partial(function_template, "foo", "bar"); | |
var baz = _.partial(function_template, "baz"); | |
foo({value1:true}); | |
baz("quux", {value1:true}); | |
foo({value2:false}); |
This file contains hidden or 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
# Starts on line 91 in uglifier-2.5.0 | |
# Initialize new context for Uglifier with given options | |
# | |
# options - Hash of options to override Uglifier::DEFAULTS | |
def initialize(options = {}) | |
(options.keys - DEFAULTS.keys - [:comments, :squeeze, :copyright])[0..1].each do |missing| | |
raise ArgumentError.new("Invalid option: #{missing}") | |
end |
This file contains hidden or 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
$(".foo").attr('bar', true); |