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
from bash: | |
createdb presentation | |
psql presentation | |
in psql: | |
CREATE table people(id serial, last_name text, first_name text, age integer); |
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 'spec_helper' | |
describe SubscriptionCancel do | |
let(:subscription) { double("Subscription") } | |
let(:remote_subscription) { double("Local::Chargify::Subscription") } | |
subject { | |
SubscriptionCancel.new(1, ->(x) {subscription}) | |
} |
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 get_country | |
code = cookies[:country] | |
unless code.present? | |
set_country_cookie | |
code = cookies[:country] || 'US' | |
end | |
set_locale(code) | |
code |
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 get_country | |
if cookies[:country].present? | |
set_locale(cookies[:country]) | |
return cookies[:country] | |
else | |
country = GEOIP_DB.country(request.remote_ip) | |
if country | |
# the default value should never be used. | |
cookies[:country] = { |
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 'active_support/core_ext/date/calculations' | |
require 'active_support/core_ext/numeric/time' | |
require 'base64' | |
#Unirest.timeout(240) # generous timeout | |
class ShipstationClient | |
class ResponseError < StandardError; end | |
class << self |
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
subscription = Recurly::Subscription.create( | |
:plan_code => 'gold', | |
:currency => 'EUR', | |
:customer_notes => 'Thank you for your business!', | |
:account => { | |
:account_code => '1', | |
:email => '[email protected]', | |
:first_name => 'Verena', | |
:last_name => 'Example', | |
:billing_info => { |
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
~/src/legacy_lootcrate$: be rake -f perf.rake perf:require_bench RAILS_ENV=development | |
Booting: development | |
## Impact of `require <file>` on RAM | |
Showing all `require <file>` calls that consume 0.3 mb or more of RSS | |
Configure with `CUT_OFF=0` for all entries or `CUT_OFF=5` for few entries | |
Note: Files only count against RAM on their first load. | |
If multiple libraries require the same file, then | |
the 'cost' only shows up under the first library |
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 process_monthly_crates(crate_date=DateTime.now) | |
# find the appropriate spree variant for this date / tshirt size. There could be more than one. | |
# let's create a hash of available variants and their available inventory | |
variants = {} | |
all_active_subscriptions = # find in batches | |
all_active_subscriptions.each do |sub| |
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
data = {"_identifier" => spree_order.number, | |
"_entityName" => "Order", | |
"salesTransaction" => true, | |
"transactionDocument" => "466AF4B0136A4A3F9F84129711DA8BD3", | |
"transactionDocument$_identifier" => "Standard Order", | |
"orderDate" => spree_order.completed_at, | |
"currency$_identifier" => spree_order.currency, | |
"summedLineAmount" => spree_order.item_total.to_f, | |
"grandTotalAmount" => spree_order.total.to_f, | |
"documentType" => "466AF4B0136A4A3F9F84129711DA8BD3", |
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($) { | |
$.extend($.fn, { | |
makeCssInline: function() { | |
this.each(function(idx, el) { | |
var style = el.style; | |
var properties = []; | |
for(var property in style) { | |
if($(this).css(property)) { | |
properties.push(property + ':' + $(this).css(property)); | |
} |
NewerOlder