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
module Enumerable | |
def first_result | |
self.each do |item| | |
out = yield item | |
return out if out | |
end | |
end | |
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
! Unable to load application: LoadError: no such file to load -- iconv | |
An exception occurred running /home/jw/.rvm/gems/rbx-2.2.10/bin/ruby_executable_hooks: | |
no such file to load -- iconv (LoadError) | |
Backtrace: | |
Rubinius::CodeLoader#load_error at kernel/common/code_loader.rb:441 | |
Rubinius::CodeLoader#resolve_require_path at kernel/common/code_loader.rb:425 | |
{ } in Rubinius::CodeLoader#require at kernel/common/code_loader.rb:103 |
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
class Numeric | |
def stuff=(value) | |
@stuff=value | |
end | |
end | |
x = 7 | |
x.stuff='hello' | |
# EXPLOSION! |
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
class Person | |
def say(message) | |
puts "Some people would say '#{message}'" | |
end | |
def hey_do_something_for_me( proc ) | |
proc.call | |
end | |
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
# config/initializers/warden.rb | |
Rails.application.config.middleware.use Warden::Manager do |manager| | |
manager.default_strategies :password, :perishable_token | |
manager.failure_app = lambda { |env| | |
# Just to be clear, I'm not actually sold on failure apps. The intent | |
# here is that if an authentication strategy fails and a failure app is | |
# defined, then it controls the flow. I now think this should be handled | |
# on the controller level... don't define a failure app, and have your | |
# controllers test to see whether there is a current_user. Because sometimes |
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
expected to find text "Search by patient name" in "[menu] [breadcrumbs] [tabs:] History Import Manual Entry [tab content:] Search by patient name: Enter the name of the patient for whom you are searching. We'll show any matching messages we've received in the last few months. [more content] |
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
def metaclass | |
class << self; self; end | |
end | |
def has_list( name, attributes={} ) | |
metaclass.instance_eval do | |
define_method( name ) do | |
[] | |
end | |
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
<% cache( @presenter.cache_key ) do %> | |
<%= cloud.to_svg %> | |
<% 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
<% cache( @presenter.cache_key ) do %> | |
<%= String.random(10) %> | |
<% 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
def gap_weight_for( age ) | |
difference = (value_of(age) - patient_age).abs | |
( difference * 0.1 ) ** 1.07 | |
end | |
intermittently results in: | |
in `**': #<Class:0x0000000a693110> can't be coerced into BigDecimal (TypeError) | |
def gap_weight_for( age ) |