I hereby claim:
- I am jhubert on github.
- I am jhubert (https://keybase.io/jhubert) on keybase.
- I have a public key whose fingerprint is CE02 7B8C 1EB8 1445 6A5D 3B93 55C9 EAAF 0186 36B4
To claim this, I am signing this object:
begin | |
require 'bundler/inline' | |
require 'pry' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' |
There is a small period of time when migrations aren't recognized by rails during the deploy process and this causes errors. | |
- old code is running | |
- new code hits heroku | |
- heroku restart -> loads up the new code. takes 3ish minutes | |
- migration happens | |
- heroku restart -> loads up the new code again. takes 3ish minutes | |
With Preboot: | |
[old code ----------------------------------------------------] |
require 'csv' | |
require 'csv-i18n' | |
require 'i18n' | |
I18n.backend.store_translations(:en, csv: { exception: { unclosed_quoted_field: "custom error on line %{line_number}" } }) | |
CSV.parse('"') | |
# lib/ruby/2.3.0/csv.rb:1898:in `block in shift': custom error on line 1 (CSV::MalformedCSVError) | |
# from lib/ruby/2.3.0/csv.rb:1805:in `loop' | |
# from lib/ruby/2.3.0/csv.rb:1805:in `shift' |
# Disable users who have had no activity in the last 14 days | |
class DisableInactiveUsersJob | |
include Sidekiq::Worker | |
def perform | |
users_with_no_activity_since(14.days.ago).pluck(:id).each do |user_id| | |
DisableUser.call(user_id) | |
end | |
end |
# Disable users who have email addresses that are bouncing | |
class DisableRejectedEmailsJob | |
include Sidekiq::Worker | |
def perform | |
now = Time.zone.now | |
target_users = User.enabled.where(email: rejected_emails) | |
# Load the ids before we update the users or the pluck query will return nothing | |
target_user_ids = target_users.pluck(:id) |
# Disable users who have had no activity in the last 14 days | |
class DisableInactiveUsersJob | |
include Sidekiq::Worker | |
def perform | |
now = Time.zone.now | |
target_users = users_with_no_activity_since(now - 14.days) | |
# Load the ids before we update the users or the pluck query will return nothing | |
target_user_ids = target_users.pluck(:id) |
require 'csv' | |
module CoreExtensions | |
module CSV | |
module I18n | |
# Redefine the shift method to catch the exception and attempt to return | |
# a translated version of the error message using I18n.t | |
def shift | |
super | |
rescue ::CSV::MalformedCSVError => exception |
I hereby claim:
To claim this, I am signing this object:
I did some performance testing from heroku to memcachier and redis-cloud to check the iterations per second. Here is how I did it, based on the work that @nateberkopec did:
From heroku run bash -r production
run the following:
gem install benchmark-ips --no-doc --no-ri
gem install redis-activesupport --no-doc --no-ri
# the other gems are already installed because they're included in our app's gemfile, but you may need:
# gem install dalli --no-doc --no-ri
# gem install rails --no-doc --no-ri