Skip to content

Instantly share code, notes, and snippets.

@SFEley
SFEley / deploy.rb
Created August 31, 2010 20:39
Vlad config file with Hoptoad and Unicorn
set :application, "_____"
set :repository, "git@github.com:_____/#{application}.git"
begin
# Parsing the annoying multi-line output of 'git branch'...
set :branch, `git branch --no-color`.match(/\* (.+)/)[1]
rescue Exception => e
set :branch, '(none)'
end
@SFEley
SFEley / secret.rake
Created April 22, 2013 01:18
Open an encrypted data bag item in one's usual editor, decrypted. Adapted from Aaron Jensen's excellent script: https://gist.github.com/aaronjensen/4123044
namespace :secret do
desc "Edit an encrypted data bag item in EDITOR"
task :edit, :item do |t, args|
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
exit 1
end
abort 'usage: rake "secret:edit[<item name>]"' unless args.item
@SFEley
SFEley / RubyDL.md
Created October 30, 2013 18:56
Docs for Ruby DL class, taken from **ext/dl/doc** in Ruby 1.8.7 source tree and converted to Markdown. (This document disappeared in the 1.9.x releases and was replaced by inadequate inline rdocs.)

Ruby/DL

Ruby/DL provides an interface to the dynamic linker such as dlopen() on UNIX and LoadLibrary() on Windows.

Building and Installing

$ ruby extconf.rb # to create the Makefile $ make # to build the library 'dl.so' $ make libtest.so # to build the C library 'libtest.so' for the test script

@SFEley
SFEley / Daily Store Rollout Schedule
Last active March 29, 2016 21:01
Store activations schedule for new_sales_detail
DAY 1
----------
2783 85718 customers
4219 4781 customers
2933 4098 customers
1810 78 customers
2645 6130 customers
[2783, 4219, 2933, 1810, 2645]
@SFEley
SFEley / report.csv
Last active May 9, 2016 19:52
Segment and Newsletters Report
Store ID Store Type Total Customers Customers Without Email System Segments Custom Segments Newsletters System Segments in Newsletters System Segments NOT in Newsletters Custom Segments in Newsletters Custom Segments NOT in Newsletters
1836 Magento 0 0 38 0 0 0 38 0 0
3914 Magento 257 0 38 0 0 0 38 0 0
3881 Shopify 1438 0 38 8 17 0 38 0 8
3294 Magento 9126 0 38 2 0 0 38 0 2
2143 Magento 5438 0 38 0 0 0 38 0 0
2849 Magento 20401 0 38 0 0 0 38 0 0
4863 Magento 1232 0 38 0 0 0 38 0 0
2977 Magento 238508 0 38 3 126 0 38 0 3
2313 Magento 331 0 38 1 0 0 38 0 1
@SFEley
SFEley / consumer.rb
Last active June 7, 2016 21:52
Update all customers with average_order_value
include RedisCache
updater = Customer.mongo_client['customers']
start = 5000
lastid, lastaov = nil, nil
while (aovs = redis.zrange 'average_order_values', start, start + 999, withscores: true).present?
redis.pipelined do
aovs.each do |id, aov|
lastid, lastaov = id, aov
updater.find_one_and_update({ _id: BSON::ObjectId.from_string(id) }, { '$set' => { average_order_value: aov } })
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 18:20
Old/New Purchase Segments Comparison - Store 3285
NEW Everyone Who Has Not Purchased (3285)
Customers: 90344
Emails: 90335
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 20:10
Old/New Purchase Segments Comparison - Store 3753
NEW Everyone Who Has Not Purchased (3753)
Customers: 17411
Emails: 17411
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Last active July 6, 2016 20:57
Old/New Purchase Segments Comparison - Store 1107
NEW Everyone Who Has Not Purchased (1107)
Customers: 370338
Emails: 370316
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,
@SFEley
SFEley / NEW Everyone Who Has Not Purchased.rb
Created July 6, 2016 21:35
Old/New Purchase Segments Comparison - Store 1214
NEW Everyone Who Has Not Purchased (1214)
Customers: 459545
Emails: 459543
{"top_five_product_ids"=>[],
"month_to_date_sales"=>0.0,
"total_sales"=>0.0,
"sales_by_month"=>{},
"lifetime_sales"=>0.0,
"average_order_value"=>0.0,