Skip to content

Instantly share code, notes, and snippets.

View gmacdougall's full-sized avatar

Gregor MacDougall gmacdougall

  • Toronto, Ontario, Canada
View GitHub Profile
p.field {
position: relative;
}
p.field label {
float: left;
width: 200px;
text-align: right;
margin-right: 20px
}
@gmacdougall
gmacdougall / gist:6082225
Created July 25, 2013 18:04
Opsworks chef 11.4 failure
# Logfile created on Thu Jul 25 17:59:37 +0000 2013 by logger.rb/1.2.6
[2013-07-25T17:59:37+00:00] INFO: *** Chef 11.4.4 ***
[2013-07-25T17:59:38+00:00] DEBUG: Building node object for cupcake.localdomain
[2013-07-25T17:59:38+00:00] DEBUG: Extracting run list from JSON attributes provided on command line
[2013-07-25T17:59:38+00:00] INFO: Setting the run_list to ["opsworks_custom_cookbooks::load", "opsworks_custom_cookbooks::execute"] from JSON
[2013-07-25T17:59:38+00:00] DEBUG: Applying attributes from json file
[2013-07-25T17:59:38+00:00] DEBUG: Platform is amazon version 2013.03
[2013-07-25T17:59:38+00:00] INFO: Run List is [recipe[opsworks_custom_cookbooks::load], recipe[opsworks_custom_cookbooks::execute]]
[2013-07-25T17:59:38+00:00] INFO: Run List expands to [opsworks_custom_cookbooks::load, opsworks_custom_cookbooks::execute]
[2013-07-25T17:59:38+00:00] INFO: Starting Chef Run for cupcake.localdomain
@gmacdougall
gmacdougall / gist:6631405
Created September 19, 2013 23:41
unicorn syslog
require 'syslog'
class Unicorn::Syslog
def initialize
Syslog.open
end
def debug(msg)
Syslog.debug(msg)
end
@gmacdougall
gmacdougall / gist:11003416
Created April 17, 2014 18:33
Favourite Stack Trace
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
null:null:in `null`
SELECT COUNT(*)
FROM "spree_products"
LEFT OUTER JOIN "spree_variants" ON "spree_variants"."product_id" = "spree_products"."id" AND "spree_variants"."deleted_at" IS NULL
WHERE "spree_products"."deleted_at" IS NULL
AND spree_variants.id NOT IN (SELECT variant_id FROM spree_well_amy_variant_lifestyles WHERE "lifestyle_id" IN (1, 2, 3, 4));
@gmacdougall
gmacdougall / order_mailer_decorator.rb
Created May 12, 2014 15:46
Providing ApplicationHelper in mailer
# app/mailers/order_mailer_decorator.rb
Spree::OrderMailer.class_eval do
helper :application
end
@gmacdougall
gmacdougall / gist:868779d05133680f3859
Last active August 29, 2015 14:09
Spree Performance Improvements

Goals

  1. Identify Areas of Performance Problems
  2. Prioritize by Pain
  3. Short Term Fixes
  4. Long term Fixes
  5. Bencharks measurements

Areas of Performance Problems

@gmacdougall
gmacdougall / gist:4e203e9761d20103911e
Created January 15, 2015 14:04
Sample Sales Tax Scenarios

Basic Scenarios (no exchanges)

Scenario 1

Consider a 10% sales tax.

Line Item 1 (Quantity 1) @ $0.04 = $0.04
Line Item 2 (Quantity 1) @ $0.04 = $0.04
Started GET "/api/products?token=e3b20b6dad8521135961c839e4a27877567c303b9460470a" for 10.0.0.231 at 2015-02-24 10:34:43 -0500
ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by Spree::Api::ProductsController#index as JSON
Parameters: {"token"=>"e3b20b6dad8521135961c839e4a27877567c303b9460470a"}
Spree::User Load (0.9ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."spree_api_key" = $1 LIMIT 1 [["spree_api_key", "e3b20b6dad8521135961c839e4a27877567c303b9460470a"]]
 (0.9ms) SELECT "spree_roles"."name" FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 [["user_id", 1]]
 (0.8ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."
Started GET "/api/products?token=e3b20b6dad8521135961c839e4a27877567c303b9460470a" for 10.0.0.231 at 2015-02-24 10:34:43 -0500
ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by Spree::Api::ProductsController#index as JSON
Parameters: {"token"=>"e3b20b6dad8521135961c839e4a27877567c303b9460470a"}
Spree::User Load (0.9ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."spree_api_key" = $1 LIMIT 1 [["spree_api_key", "e3b20b6dad8521135961c839e4a27877567c303b9460470a"]]
(0.9ms) SELECT "spree_roles"."name" FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 [["user_id", 1]]
(0.8ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = $2 [["user_id", 1], ["name