Skip to content

Instantly share code, notes, and snippets.

View jonstorer's full-sized avatar

Jonathon Storer jonstorer

View GitHub Profile
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'my-app'
set :repo_url, '[email protected]:my/repo.git'
set :user, 'deploy'
set :scm, :git
set :deploy_to, '/srv/www/my-app'
set :ssh_options, forward_agent: true
@jonstorer
jonstorer / one_query.rb
Last active January 3, 2016 06:49
make this one query
# I need to query a doc like this
Info.where(:q_id => 1, :quality.gte =>2).map(:member_id)
# => [123, 124]
Info.where(:q_id => 2, :quality.gte => 1).map(:member_id)
# => [123, 125]
# I need the member ids that are in the result set of both queries
# =>[123]
db.infos = [
@jonstorer
jonstorer / .gitignore
Last active December 22, 2015 20:49
Admin Tickets
output/*
@jonstorer
jonstorer / Gemfile
Last active December 19, 2015 19:49
Testing data for verifying Missions in Production.
# A sample Gemfile
source "https://rubygems.org"
gem 'hashie'
# gem "rails"
#!/bin/bash
echo "REMEMBER: tmux -2 -S /tmp/tmux -attach; chmod aog+rwx /tmp/tmux"
ssh ci 'awk !/:1026/ ~/.ssh/known_hosts > ~/.ssh/known_hosts.new'
ssh ci 'mv ~/.ssh/known_hosts ~/.ssh/known_hosts.bak'
ssh ci 'mv ~/.ssh/known_hosts.new ~/.ssh/known_hosts'
ssh -v -N -R 1026:localhost:22 [email protected] >> /tmp/ssh_tunnel.out &
/usr/local/bin/tmux -2 -S /tmp/tmux
@jonstorer
jonstorer / prizes_meta.rb
Last active December 18, 2015 14:58
Fetch member's email gift card code and challenge code for jen
require 'ruby-progressbar'
module PrizeMetaData
def self.run!
wins = PrizeWin.where(:drawing_id.in => Drawing.last_month.crowd.map(&:id))
progress = ProgressBar.create(:title => "#{Date::MONTHNAMES[1.month.ago.month]} Wins", :total => wins.count.to_i, :format => '%t |%b[%P%%]%i| %c/%C [%E]')
File.open("/home/deploy/tmp/prizing_#{Date::MONTHNAMES[1.month.ago.month].downcase}_email_codes_challenges.csv", 'a+') do |file|
file.puts "email, url, challenge"
wins.each do |win|
file.puts "#{win.member.email}, #{win.cashstar_fulfillment.url}, #{win.cashstar_fulfillment.challenge}"
@members = {}
Brand.all.each do |brand|
if drawing = brand.drawings.crowd.last_month.first
wins = PrizeWin.where(:drawing_id => drawing.id)
progress = ProgressBar.create(:title => brand.slug, :total => wins.count.to_i, :format => '%t |%b[%P%%]%i| %c/%C [%E]')
wins.each do |win|
email = win.member.email
@members[email] ||= 0
@members[email] = @members[email].to_i + 1
@jonstorer
jonstorer / pick.rb
Last active December 18, 2015 02:08
pick crowd winners
class PickCrowdWinners
attr_accessor :crowd_drawing, :ids
def initialize(crowd_drawing)
@crowd_drawing = crowd_drawing
end
def ids
@ids ||= begin
ids = Set.new
@jonstorer
jonstorer / win_migrate.rb
Last active December 17, 2015 23:09
Migrate all Win documents to PrizeWin documents
CashstarFulfillment.all.each do |cf|
cf.set(:prize_win_id, cf.win_id)
end
Win.all.each do |win|
win.set(:_type, 'PrizeWin')
end
CashstarFulfillment.all.each do |cf|
cf.unset(:win_id)
@jonstorer
jonstorer / .gitignore
Last active December 17, 2015 17:19
They seem me trollin' they hatin'
out.log