Skip to content

Instantly share code, notes, and snippets.

View semanticart's full-sized avatar

Jeffrey Chupp semanticart

View GitHub Profile
# what is going on with Hash.new([])?
lines = [
[1,2],
[3,4],
[5,6],
[5,6.5],
[7,8]
]
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
class Child
belongs_to :master, :polymorphic => true
end
class HumanParent
has_many :organs
end
class RobotOverlord
has_many :spark_plugs
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"
$ 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
/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/
# 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
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
# 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
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