Skip to content

Instantly share code, notes, and snippets.

View solnic's full-sized avatar

Peter Solnica solnic

View GitHub Profile
require 'veritas'
require 'veritas-sql-generator'
header_one = [
[ :id, Integer ],
[ :name, String ],
[ :age, Integer ]
]
tuples_one = [
@solnic
solnic / be_true_spec.rb
Created July 1, 2011 10:09
The difference between be(true) and be_true matchers
require 'rspec'
describe true do
it { should be(true) }
it { should be_true }
end
describe 'true' do
it { should_not be(true) }
it { should be_true }
ruby-1.8.7-p334 :001 > c = Class.new String
=> #<Class:0xb76b7ee0>
ruby-1.8.7-p334 :002 > c.name
=> ""
ruby-1.9.2-p180 :001 > c = Class.new String
=> #<Class:0x9ad5a44>
ruby-1.9.2-p180 :002 > c.name
=> nil
ruby-1.9.2-p180 :007 > u = User.new
=> #<User:0x9be5ec0>
ruby-1.9.2-p180 :008 > u.dirty?
=> false
ruby-1.9.2-p180 :009 > u.meta = {}
=> {}
ruby-1.9.2-p180 :010 > u.dirty?
=> true
ruby-1.9.2-p180 :011 > u.dirty_attributes
=> {:meta=>{}}
@solnic
solnic / dm_property_2_ideas.rb
Created May 28, 2011 11:03
DataMapper Property 2.0 ideas
module DataMapper
class Property
class Array < Object
end
end
end
module DataMapper
class Property
@solnic
solnic / dm-commits-report-2011-03-17.markdown
Created May 23, 2011 11:14
DataMapper commits between 1.1.0 and 1.1.1
@solnic
solnic / rounded_corners_table.sass
Created May 6, 2011 10:40
Here's how to do a table with rounded corners in CSS3
@import compass/reset
@import compass/css3/border-radius
table
border: none
border-collapse: separate
th, td
padding: 5px
thead
background-color: #f2f6fa
#!/usr/bin/env ruby
#
# encoding: utf-8
require 'dm-sqlite-adapter'
require 'dm-migrations'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup :default, "sqlite::memory:"
| AR 3.0.7 | DM 1.1.1 | SQ 3.22.0 | DIFF_AR_VS_DM | DIFF_SQ_VS_DM |
--------------------------------------------------------------------------------------------------------------------------
Model#id x1000 | 0.004 | 0.000 | 0.000 | 13.79x | 0.64x |
Model.new (instantiation) x10 | 0.000 | 0.000 | 0.000 | 26.88x | 31.38x |
Model.new (setting attributes) x10 | 0.001 | 0.000 | 0.000 | 2.54x | 0.54x |
Model.get specific (not cached) x10 | 0.004 | 0.006 | 0.004 | 0.77x | 0.70x |
Model.get specific (cached) x10 | 0.004 | 0.001 | 0.004 | 5.70x | 4.77x |
Model.first x10 | 0.021 | 0.005 | 0.004 | 4.35x | 0.79x |
Model.all limit(100)