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
result_takeaction_carfuel_reduction: 0 | |
result_takeaction_carmfg_reduction: 0 | |
result_takeaction_pubtrans_reduction: 0 | |
result_takeaction_airtravel_reduction: 0 | |
result_takeaction_electricity_reduction: 0 | |
result_takeaction_natgas_reduction: 0 | |
result_takeaction_otherfuels_reduction: 0 | |
result_takeaction_watersewage_reduction: 0 | |
result_takeaction_construction_reduction: 0 | |
result_takeaction_meat_reduction: 0 |
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
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' |
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
$('form').each(function(i, el){ | |
var sender = $(this).parent().siblings('p').text().trim(); | |
if (sender == 'Errbit') { | |
var data = 'action=delete'; | |
data += '&message_id='+$(el).find('input[name="message_id"]').val(); | |
data += '&xsrf_token='+$(el).find('input[name="xsrf_token"]').val(); | |
data += '&message_index='+$(el).find('input[name="message_index"]').val(); | |
$.ajax({ | |
type: $(el).attr('method'), | |
url: $(el).attr('action'), |
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 () { | |
function deleteAll() { | |
var list = $('ul#list'), | |
list_id = parseInt($(list[0]).attr('rel'), 10), | |
list_name = $('#list' + list_id + ' b').html(); | |
if (list_id > 0) { | |
if (confirm('Are you sure you want to delete all the items in ' + list_name)) { | |
list.find('li').each(function () { |
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
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 ----------------------------------------------------] |
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 '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' |
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
# 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) |
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
# 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 |
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
# 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) |
NewerOlder