This file contains 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
# what is going on with Hash.new([])? | |
lines = [ | |
[1,2], | |
[3,4], | |
[5,6], | |
[5,6.5], | |
[7,8] | |
] | |
This file contains 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' | |
require 'dm-core' | |
require 'dm-is-versioned' | |
require 'dm-timestamps' | |
DataMapper.setup(:default, 'mysql://localhost/my_db') | |
class Article | |
include DataMapper::Resource | |
property :id, Integer, :serial => true |
This file contains 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 Child | |
belongs_to :master, :polymorphic => true | |
end | |
class HumanParent | |
has_many :organs | |
end | |
class RobotOverlord | |
has_many :spark_plugs |
This file contains 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
desc "Creates a static copy of your site by iterating your thingies." | |
task :make_static do | |
static_dir = File.join(File.dirname(__FILE__), 'static') | |
Dir.mkdir(static_dir) unless File.directory?(static_dir) | |
require 'sinatra' | |
Sinatra::Application.default_options.merge!( | |
:run => false, | |
:env => :production, | |
:views => File.dirname(__FILE__) + "/views" |
This file contains 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 | |
This file contains 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 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 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 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 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 |
OlderNewer