Skip to content

Instantly share code, notes, and snippets.

# To try and fix the sort order, switching to an integer instead of time.
integer :listed_at do |item|
original_listed_at_time = nil
original_item = item.original_item if item.original_item_id.present? && item.payout_policy == "upfront"
if original_item && original_item.created_at < Time.parse("April 1 2014")
original_listed_at_time = original_item.listed_at
end
@chrishomer
chrishomer / rvm.sh
Created October 24, 2010 21:25 — forked from BinaryMuse/rvm.sh
#!/bin/bash
# Install RVM
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
# Modify ~/.bash_profile as necessary and source it to bring in changes
echo "[[ -s \"\$HOME/.rvm/scripts/rvm\" ]] && source \"\$HOME/.rvm/scripts/rvm\"" >> ~/.bash_profile
source ~/.bash_profile
# Install and use Ruby 1.9.2
rvm install ruby-1.9.2-p0 && rvm use 1.9.2
# Create a gemset for and install Rails 3 RC
rvm gemset create tu3 && rvm use 1.9.2@tu3
@paperclip_defaults = {
:styles => {
:large=>{
:convert_options=>"-auto-orient -strip",
:whiny=>true,
:geometry=>"400x300^"
},
:thumb=>{
:convert_options=>"-auto-orient -strip",
:whiny=>true,
function resetData {
mysql -u root --execute="DROP DATABASE ${1:-thredup3_development};"
mysql -u root --execute="CREATE DATABASE ${1:-thredup3_development};"
gzip -d ./tmp/thredup.sql.gz
mysql -u root ${1:-thredup3_development} < ./tmp/thredup.sql
mysql -u root ${1:-thredup3_development} < ./db/clean_test_data.sql
}
class ListingWindow
SKIP_N_PERIODS = {
"exclusive" => 1,
"pickable" => 2
}
WINDOW_TIMES = [9,18]
LISTING_TIME_ZONE = "Pacific Time (US & Canada)"
#LISTING_TIME_ZONE = "UTC"
def self.schedule_announcement(email_name,users = nil,time_to_run = nil)
lim = Rails.env == "production" ? nil : 175
users ||= self.address_completed.select("users.id").limit(lim).all
time_to_run ||= Time.now
group_size = 50
groups = users.count / group_size
(groups + 1).times do |i|
group_start = i * group_size
Spork.prefork do
require "thinking_sphinx"
Spork.trap_method(ThinkingSphinx::Context, :load_models)
...
end
Spork.prefork do
if Spork.using_spork?
require "thinking_sphinx"
Spork.trap_method(ThinkingSphinx::Context, :load_models)
end
...
end
class Delayed::Worker
alias_method :original_handle_failed_job, :handle_failed_job
def handle_failed_job(job, error)
HoptoadNotifier.notify(error,{:parameters => {:job => job.attributes}})
if Rails.env.test?
ap "FAILED DELAYED JOB"
ap job
ap error
ap error.backtrace
class Delayed::Worker
alias_method :original_handle_failed_job, :handle_failed_job
def handle_failed_job(job, error)
HoptoadNotifier.notify(error)
original_handle_failed_job(job, error)
end
end