Skip to content

Instantly share code, notes, and snippets.

View semanticart's full-sized avatar

Jeffrey Chupp semanticart

View GitHub Profile
# 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
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
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
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/)
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
# 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
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
# 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
/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/
$ 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