Skip to content

Instantly share code, notes, and snippets.

View bakineggs's full-sized avatar

Dan Barry bakineggs

View GitHub Profile
str = 'pol'
eval <<-EOS
class Foo
def self.bar
"some inter#{str}ated string"
end
end
EOS
# if you want to figure out wtf is calling Foo::Bar#baz, just
class Foo::Bar
def baz_with_backtrace *args
begin
raise
rescue => e
puts 'backtrace to who called Foo::Bar#baz:'
puts e.backtrace.join("\n")
end
baz_without_backtrace *args
class Selenium::WebDriver::Remote::DefaultHttpClient
def request_with_catch_timeout(*args)
begin
request_without_catch_timeout(*args)
rescue Timeout::Error # Timeout::Error.superclass == Interrupt, so rspec thinks its Ctrl-c and exits
raise Exception.new('request timeout') # Exception isn't a subclass of Interrupt so won't cause the whole test suite to exit
end
end
alias_method_chain :request, :catch_timeout
end
class Foo1
end
Foo1.module_eval do
def self.bar
puts 'in Foo1#bar'
end
bar
end
// snip
if (!prefs.prefHasUserValue("webdriver_enable_native_events")) {
Utils.dumpn('webdriver_enable_native_events not set; defaulting to true');
}
this.enableNativeEvents =
prefs.prefHasUserValue("webdriver_enable_native_events") ?
prefs.getBoolPref("webdriver_enable_native_events") : false;
// snip
module Mongrel
module Gems
class << self
def require(library, version = nil)
begin
Kernel.require library
rescue LoadError, RuntimeError => e
begin
# ActiveSupport breaks 'require' by making it always return a true value
eq pSpawn = --- should output 1-10 and 11-20 interleaved
function main() {
spawn(for x = 11 to 20 do write(x);)
for x = 1 to 10 do write(x);
} .
mb configuration < T >
< threads >
< thread >
< k > K </ k >
$(document).ready(function() {
$('input[type=text]').each(function() {
original_val = $(this).val();
function replace(el, o, r) { if (el.val() == o) el.val(r); }
$(this).focus(function() { replace($(this), original_val, ''); });
$(this).blur(function() { replace($(this), '', original_val); });
});
});
#!/bin/sh
LOCAL_DIRECTORY='/Users/dan/backups/bakineggs.com'
REMOTE='lwweb:/www/bakineggs.com/'
if [ ! -d $LOCAL_DIRECTORY ]; then
mkdir -p $LOCAL_DIRECTORY
fi
cd $LOCAL_DIRECTORY
pp results
puts '#######################################################'
pp results.group_by(&:instant)
yields (on ruby 1.8.5)
[#<Result instant: "2009-06-07 18:01:06", value: 1.0, group: "Atlanta">,
#<Result instant: "2009-06-05 18:01:06", value: 2.0, group: "Atlanta">,
#<Result instant: "2009-06-08 18:01:06", value: 1.0, group: "Roswell">,
#<Result instant: "2009-06-06 18:01:06", value: 2.0, group: "Roswell">,