Skip to content

Instantly share code, notes, and snippets.

class DishonestString < String
def is_utf8?
return false if calling_method == 'quote'
super
end
end
class Foo
def bar
puts "There can be only one?"
end
end
f = Foo.new
orig_method = f.method(:bar)
@chudler
chudler / gist:1058612
Created July 1, 2011 14:09
Empty Associations when eager loading using offset
class Reviewer < ActiveRecord::Base
has_many :accounts
end
class Account < ActiveRecord::Base
belongs_to :reviewer
end
> Reviewer.where(:lastname => 'bloe', :firstname => 'joe').all(:offset => 0, :include => :accounts).first.accounts.present?
@chudler
chudler / gist:879885
Created March 21, 2011 18:00
freeradius:src/modules/rlm_eap/types/rlm_eap_tls/rlm_eap_tls.c -- What happens if Framed-MTU == 14
/*
* We use default fragment size, unless the Framed-MTU
* tells us it's too big. Note that we do NOT account
* for the EAP-TLS headers if conf->fragment_size is
* large, because that config item looks to be confusing.
*
* i.e. it should REALLY be called MTU, and the code here
* should figure out what that means for TLS fragment size.
* asking the administrator to know the internal details
* of EAP-TLS in order to calculate fragment sizes is
Exception `NoMethodError' at /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:534 - undefined method `to_ary' for #<Gem::Specification name=rack-mount version=0.0.1>
Exception `NoMethodError' at /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:534 - undefined method `to_ary' for #<Gem::Specification name=arel version=0.2.pre>
Exception `NoMethodError' at /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:534 - undefined method `to_ary' for #<Gem::Specification name=rails version=3.0.pre>
Exception `NoMethodError' at /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:534 - undefined method `to_ary' for #<Gem::Specification name=activerecord version=3.0.pre>
Exception `NoMethodError' at /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib/rubygems/specification.rb:534 - undefined method `to_ary' for #<Gem::Specification name=activeresource version=3.0.p