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 TrueClass | |
def to_i | |
1 | |
end | |
def to_bool | |
self | |
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
ra:~ ryan$ ruby reconnect.rb | |
......Connection reset by peer - recvfrom(2) | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:349:in `recv' | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:349:in `receive_full' | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/message/message_header.rb:31:in `read_header' | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:206:in `read_message_header' | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:194:in `read_all' | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/cursor.rb:277:in `send_query_if_needed' | |
Broken pipe | |
/Library/Ruby/Gems/1.8/gems/mongo-0.15.1/lib/mongo/db.rb:507:in `write' |
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 Admin::PostController < AdminController | |
active_scaffold :post do |config| | |
config.action_links.add 'sphinx_search', :label => 'Search' | |
config.actions.exclude :search | |
CRU_COLUMNS = [:name, :content] | |
config.list.columns = CRU_COLUMNS | |
config.create.columns = CRU_COLUMNS | |
config.update.columns = CRU_COLUMNS | |
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
#!/usr/bin/ruby | |
require 'benchmark' | |
ryan = /\ARyan/ | |
blake = /\ABlake/ | |
darren = /\ADarren/ | |
devin = /\ADevin/ | |
composite3_regex = /\A(Ryan|Blake|Darren)/ | |
composite4_regex = /\A(Ryan|Blake|Darren|Devin)/ |
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 AppConfig | |
def self.config | |
unless @config | |
raw_config = File.read(File.join(File.dirname(__FILE__), '..', 'config', 'harmony.yml')) | |
config = YAML.load(raw_config) | |
config = config[RAILS_ENV] if defined?(RAILS_ENV) | |
@config = defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess.new(config) : config | |
end | |
@config | |
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
ra:timeline[master*]$ ruby wtf.rb | |
/Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb:35:in `assign_references': undefined method `_parent_document=' for nil:NilClass (NoMethodError) | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb:19:in `replace' | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/associations.rb:41:in `membership=' | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/keys.rb:260:in `send' | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/mongo_mapper-0.8.0/lib/mongo_mapper/plugins/keys.rb:260:in `load_from_database' | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/bson-1.0.2/lib/../lib/bson/ordered_hash.rb:72:in `each' | |
from /Users/ryan/.rvm/gems/ree-1.8.6-20090610/gems/bson-1.0.2/lib/../lib/bson/ordered_hash.rb:72:in `each' | |
from /Users/ryan/.rvm |
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 myObj = { | |
number: 10, | |
createElementsPType: function() { | |
new_element.click(this.showNumber.bind(this)); | |
} | |
createElementsjQuery: function() { | |
new_element.click(this.showNumber); | |
}, |
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
result = {"Location" => "http://dev.mypunchbowl.com"} | |
# ... | |
# somewhere down the line: | |
result["Location"] # => "http://c.dev.mypunchbowl.com" ... "c"?!? | |
class OhHaiObj |
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 RawRenderer < WillPaginate::LinkRenderer | |
def prepare col, opt, template | |
@collection = col | |
@options = opt | |
@options[:container] = nil | |
@template = template | |
@total_pages = @collection.total_pages | |
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
ra:code$ rails new r3 | |
create | |
create README | |
create Rakefile | |
create config.ru | |
create .gitignore | |
create Gemfile | |
create app | |
create app/controllers/application_controller.rb | |
create app/helpers/application_helper.rb |
OlderNewer