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
@incoming_items.each do |item| | |
# find all pending orders with this item | |
pending_shipments = Shipments.in_status('waiting to ship').with_item(item).sorted_by_date | |
allocated_quantity = 0 | |
# ship the allocated | |
pending_shipments.each do |shipment| | |
quantity = shipment.line_items.find_all_by_item_id(item.id).inject(0) {|sum, line| sum += line } | |
if quantity + allocated_quantity < item.quantity | |
# ship this shipment |
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
SELECT | |
MONTH(order.date), | |
SUM(CASE MONTH(order.date) WHEN 1 THEN detail.price * detail.quantity ELSE 0 END) AS JanuarySales, | |
SUM(CASE MONTH(order.date) WHEN 2 THEN detail.price * detail.quantity ELSE 0 END) AS FebruarySales, | |
... |
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
1) | |
4.8 ft = 1.46304 meters | |
1.46304m x 25m x 50m = 1,828.8 (cubic meters) | |
1,828.8 (cubic meters) = 483,117.849 gallons | |
2) |
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
SELECT u.id, u.first_name, u.last_name, u.email, so.shipto_postal_code, so.placed_at | |
FROM users u LEFT JOIN sales_orders so | |
ON so.user_id = u.id | |
AND so.state != 'pending' | |
WHERE u.contact_me = 1 | |
ORDER BY u.id, so.placed_at DESC | |
---------------------------------- | |
SELECT u.id, u.first_name, u.last_name, u.email, so1.shipto_postal_code, so1.placed_at |
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
pool :poolparty do | |
cloud :app do | |
instances 2..10 | |
using :ec2 | |
rds :db1 do | |
# instance_class "db.m1.small" # DEFAULT | |
# engine "MySQL5.1" # DEFAULT | |
username "admin" |
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
list = [1, 1, 2, 2, 3] | |
# using each: | |
hash = {} | |
list.each do |item| | |
hash[item] ||= 0 | |
hash[item] += 1 | |
end | |
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
def output(*words) | |
case words.length | |
when 0 | |
puts "no words" | |
when 1 | |
puts "here is my word: #{words.first}" | |
else | |
puts "here are my words: #{words.join(',')}" | |
end | |
end |
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
def check_for_bid_items | |
return if user.bids.empty? | |
@bids_and_items = user.bids.inject({}) do |hsh, bid| | |
items_for_bid = hsh[bid] || [] | |
items_for_bid += line_items.select{|li| li.product.bids.include?(bid) } | |
hsh.update(bid => items_for_bid) unless items_for_bid.empty? | |
end | |
end |
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
return if user.bids.empty? | |
@bids_and_items = user.bids.inject({}) do |hsh, bid| | |
items_for_bid = hsh[bid] || [] | |
items_for_bid += line_items.select{|li| li.product.bids.include?(bid) } | |
hsh = hsh.update(bid => items_for_bid) unless items_for_bid.empty? | |
hsh | |
end | |
# send an email with items from each bid.. |
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
# common stuff | |
set :application, "app-name" | |
set :scm, :git | |
set :deploy_via, :remote_cache | |
set :git_enable_submodules, 1 | |
set :repository, "git@host:repo.git" | |
# ...etc... | |
## standard single target setup: |