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
| # thanks to @judofyr for explaining this to me like thus: | |
| # when ruby sees "bar =" (even thought it's not eval'd) it creates a local variable and assigns it to nil. | |
| # so the first "bar" is a method call, while the second is a local variable. it should work if you replace | |
| # it with "self.bar". | |
| class Foo | |
| attr_accessor :bar, :id | |
| def initialize id | |
| @id = id |
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
| require 'rubygems' | |
| gem 'activerecord', '=2.3.2' | |
| require 'activerecord' | |
| load 'active_record/associations.rb' | |
| load 'active_record/associations/has_many_through_association.rb' | |
| ActiveRecord::Associations::HasManyThroughAssociation | |
| class SomeClass < ActiveRecord::Associations::HasManyThroughAssociation | |
| 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
| class Trade | |
| def users_with_destroyed | |
| User.find_with_destroyed(:all, :conditions => {:id => self.user_id}) | |
| end | |
| def user_with_destroyed | |
| User.find_with_destroyed(self.user_id) | |
| 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
| def self.decode_content(c) | |
| if c.header_str.match(/Content-Encoding: gzip/) | |
| begin | |
| gz = Zlib::GzipReader.new(StringIO.new(c.body_str)) | |
| xml = gz.read | |
| gz.close | |
| rescue Zlib::GzipFile::Error | |
| xml = c.body_str | |
| end | |
| elsif c.header_str.match(/Content-Encoding: deflate/) |
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 Feedzirra | |
| class AtomFeedBurnerEntry | |
| include SAXMachine | |
| include FeedEntryUtilities | |
| element :title | |
| element :name, :as => :author | |
| element :"feedburner:origLink", :as => :url | |
| element :summary | |
| element :content | |
| element :published |
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
| # note that I copy and pasted the first entry's category tag and changed the second term to 'Robocop' to ensure that all items were being captured | |
| describe "full example" do | |
| before :each do | |
| @xml = File.read('spec/sax-machine/atom.xml') | |
| class AtomEntry | |
| include SAXMachine | |
| element :title | |
| element :name, :as => :author | |
| element "feedburner:origLink", :as => :url |
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
| mb:repo jeff$ ls db/data/us_cities.data.insert.sql | |
| db/data/us_cities.data.insert.sql | |
| mb:repo jeff$ git filter-branch --index-filter 'git rm -f --cached db/data/us_cities.data.insert.sql' HEAD | |
| Rewrite d54d3041d7d5739b3093f802fc1ef45f3c8e5e16 (1/2713)fatal: pathspec 'db/data/us_cities.data.insert.sql' did not match any files | |
| index filter failed: git rm -f --cached db/data/us_cities.data.insert.sql | |
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
| # generate the commands to install all currently missing versions from the output of `gem list` from | |
| # another box to your local machine. `gem list` should be of format | |
| # actionmailer (2.2.2, 2.1.0) | |
| # actionpack (2.2.2, 2.1.0) | |
| # ... | |
| # will_paginate (2.2.2) | |
| # ZenTest (3.9.2) | |
| # | |
| # usage: ruby install_gems.rb /path/to/your/gem/list/output.txt | |
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/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:92:in `execute_non_query': near "EXISTS": syntax error (Sqlite3Error) | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:92:in `execute' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:173:in `with_connection' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:90:in `execute' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/adapters/data_objects_adapter.rb:467:in `destroy_model_storage' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/auto_migrations.rb:77:in `auto_migrate_down!' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core/model.rb:113:in `repository' | |
| from /usr/local/lib/ruby/gems/1.8/gems/dm-core-0.9.8/lib/dm-core.rb:181:in `repository' | |
| from /usr/local/ |
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
| $ rails -v | |
| Rails 2.2.2 | |
| $ rails meh | |
| ... | |
| $ cd meh | |
| $ script/generate controller arf | |
| ... | |
| then create an index action on the controller, start script server, visit http://localhost:3000/arf and get | |