Skip to content

Instantly share code, notes, and snippets.

View dkubb's full-sized avatar
🏠
Working from home

Dan Kubb dkubb

🏠
Working from home
  • Betterment
  • Mission, BC, Canada
  • X @dkubb
View GitHub Profile
SELECT humans.id
, humans.first_name
, humans.middle_name
, humans.last_name
FROM humans
INNER JOIN ownerships ON ownerships.human_id = humans.id
INNER JOIN pets ON ownerships.pet_id = pets.id
WHERE pets.name = 'Bo'
GROUP BY humans.id
, humans.first_name
Interfaces
==========
Finder Interface
----------------
- []
- all
- at
- fetch
@dkubb
dkubb / gist:132496
Created June 19, 2009 08:03
DataMapper 0.10.0 RC1 -- install with git instructions (draft)
REQUIRED
--------
* addressable
sudo gem install addressable
* extlib
git clone git://github.com/datamapper/extlib.git
I am pleased to announce the release of DataMapper 0.10.0 Release Candidate 1.
For the impatient, here are the command line instructions to install it:
Install
-------
1) Add gems.datamapper.org as a gem source:
gem sources --add http://gems.datamapper.org
require 'dm-core'
require 'dm-types'
class CrawledURI
include DataMapper::Resource
storage_names[:default] = 'crawled_uris'
property :id, Serial
@dkubb
dkubb / gist:152102
Created July 22, 2009 16:24
DataMapper public API
== Interfaces
=== Finder Interface
+ #[]
+ #all
+ #at
- #fetch
+ #first
+ #first_or_create
@dkubb
dkubb / base_model.rb
Created August 20, 2009 02:31
Base Model example
module BaseModel
def self.included(model)
model.class_eval <<-RUBY, __FILE__, __LINE__ + 1
include DataMapper::Resource
property :id, Serial
timestamps :at
RUBY
end
#!/usr/bin/env ruby -KU
require 'rubygems'
require 'dm-core'
require 'dm-validations'
require 'pp'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
@dkubb
dkubb / retarted.rb
Created September 8, 2009 16:44 — forked from tj/retarted.rb
post '/user/permissions' do
require_permission_to 'administer permissions'
params[:permissions].each do |role_id, permission_ids|
next unless role = Role.get(role_id)
role.update(:permissions => Permission.all(:id => permission_ids.keys))
end
redirect '/user/permissions'
end