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
-- query for user.items, which is User => sales => sale_items => item | |
SELECT "items"."id", "items"."item_code", "items"."item_number", "items"."description", "items"."size", "items"."retail", "items"."vintage" | |
FROM "items" | |
INNER JOIN "sale_items" | |
ON "items"."id" = "sale_items"."item_id" | |
INNER JOIN "sales" | |
ON "sale_items"."sale_id" = "sales"."id" | |
INNER JOIN "users" | |
ON "sales"."user_id" = "users"."id" |
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' | |
gem 'dm-core', '0.10.0' | |
require 'dm-core' | |
DataMapper.setup(:default, 'postgres://tpitale@localhost/test_through_many') | |
class User | |
include DataMapper::Resource | |
property :id, Serial | |
has n, :sales |
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' | |
gem 'dm-core', '0.10.0' | |
gem 'dm-validations', '0.10.0' | |
require 'dm-core' | |
require 'dm-validations' | |
DataMapper.setup(:default, 'postgres://tpitale@localhost/test_create_fail') | |
class User1 | |
include DataMapper::Resource |
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
;(function($) { | |
$.fn.clearfocus = function() { | |
return this.each(function() { | |
var $field = $(this); | |
var original_value = $field.val(); | |
$field.focus(function() { | |
if($field.val() == original_value) $field.val(""); | |
}); |
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' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Session | |
include DataMapper::Resource | |
property :id, Serial |
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
>> Item.first(:retailer_id => r.id) | |
ArgumentError: condition :retailer_id does not map to a property or relationship in Item | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:747:in `assert_valid_conditions' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:743:in `each' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:743:in `assert_valid_conditions' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:670:in `assert_valid_options' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:660:in `each' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:660:in `assert_valid_options' | |
from /var/www/apps/tasty/releases/20090708133514/vendor/gems/dm-core-0.10.0/lib/dm-core/query.rb:602:in `initialize' | |
from /var/www/apps/tasty/releases/2009 |
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
cookies = document.cookie.split(';'); | |
utmz = ""; | |
for(i in cookies) { | |
if(cookies[i].test(/^__utmz/)) utmz = cookies[i]; | |
} | |
medium = utmz.match(/".*?utmcmd=([a-z]+)\|/)[1]; | |
adwords = utmz.match(/.*?utmgclid=([_0-9A-Za-z]+)\|/)[1]; |
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' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Sale | |
include DataMapper::Resource | |
property :id, Serial |
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-aggregates' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Retailer | |
include DataMapper::Resource |
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
time psql feedstitch_development -qt -c 'SELECT entries.* FROM entries INNER JOIN group_entries ON entries.id = group_entries.entry_id WHERE (group_entries.group_id IN (SELECT id FROM groups WHERE user_id = 1)) ORDER BY entries.published_at DESC LIMIT 10000' &> /dev/null | |
time mysql feedstitch_development -e 'SELECT entries.* FROM entries INNER JOIN group_entries ON entries.id = group_entries.entry_id WHERE (group_entries.group_id IN (SELECT id FROM groups WHERE user_id = 1)) ORDER BY entries.published_at DESC LIMIT 10000' &> /dev/null |