Skip to content

Instantly share code, notes, and snippets.

View mattfitzgerald's full-sized avatar

Matt Fitzgerald mattfitzgerald

View GitHub Profile
RuntimeError in PromotionsController#destroy
Requested model nil doesn't match controller promotions
Rails.root: /app
Application Trace | Framework Trace | Full Trace
lib/datatable.rb:57:in `base_relation'
lib/datatable.rb:13:in `scoped'
app/controllers/promotions_controller.rb:84:in `destroy'
app/controllers/application_controller.rb:109:in `track_memory_usage'
# hacky contact csv maker
# usage: ruby generate_contacts.rb > contacts.csv
require 'rubygems'
require 'faker'
require 'fastercsv'
contacts_to_create = 50
output_path = File.join(File.dirname(__FILE__), "output.csv")
Aug 07 15:20:50 squawkbox app/web.3: Sent data (1.5ms)
Aug 07 15:20:50 squawkbox app/resque.9: ** [NewRelic][08/07/13 05:20:50 +0000 d2b90ea3-e553-4fe2-ae63-289ac6721bc2 (20757)] INFO : Starting Agent shutdown
Aug 07 15:20:51 squawkbox app/resque.1: [ContactUpload 8366] [processing] [ContactUploadRow 34] #map_attributes - {"first_name"=>"Josh Wallace", "mobile_number"=>"61409993535", "email"=>"[email protected]"}
Aug 07 15:20:51 squawkbox app/web.5: Memory used: 249 MB (delta: +0 Bytes)
Aug 07 15:20:51 squawkbox heroku/router: at=info method=GET path=/email/heP5gJyJQ7cirlSboKulXw==/torsion.gif host=app.mysquawkbox.com fwd="49.176.105.6" dyno=web.5 connect=4ms service=1620ms status=304 bytes=0
Aug 07 15:20:51 squawkbox app/web.5: Completed 200 OK in 1600ms (Views: 2.8ms | ActiveRecord: 0.0ms)
Aug 07 15:20:51 squawkbox app/resque.4: Disconnected from ActiveRecord
Aug 07 15:20:51 squawkbox app/resque.3: Disconnected from ActiveRecord
Aug 07 15:20:51 squawkbox app/resque.4: Disconnected from R
@mattfitzgerald
mattfitzgerald / gist:6162286
Created August 6, 2013 05:38
Counting birthday messages
Promotion.where(schedule_type: 'contact_relative', enabled: true).where("system_search_query like ?", '%date_of_birth%').count
year = 2013
months = (1..6)
months.each do |month|
start_date = Date.new(year,month,1)
end_date = start_date + 1.month
total = Payment.where(item: 'subscription', transaction_state: 'success', created_at: start_date..end_date).sum(:amount_in_cents)/100.0
puts "year: #{year} month: #{month} total_subs: #{total}"
end
start_date = Date.new(2013,1,1)
end_date = start_date + 1.month
Payment.where(item: 'subscription', transaction_state: 'success', created_at: start_date..end_date).sum(:amount_in_cents)
This segment cannot be deleted as it is used by the scheduled communication “Half Price Tuesdays” scheduled for Tuesday April 25th.
This segment cannot be deleted as it is used by the birthday communication “Birthday bender”.
This segment cannot be deleted as it is used by the anniversary communication “Happy new solar orbit”.
This segment cannot be deleted as it is used by the recurring communication “Groundhog day is here!”.
This segment cannot be deleted as it is used by the <event name> communication “The event is soon...”.
<p>
werwr
</p>
<pre>
sdfsf
</pre>
<p>
<span face="Comic Sans MS, cursive, sans-serif"><font>werwr</span></font>
</p>
<h1>ddd</h1>
<p>
werwr
</p>
<pre>
sdfsf
</pre>
<p>
<span><br>
</span>
</p>
@mattfitzgerald
mattfitzgerald / gist:4671042
Last active December 11, 2015 22:39
Email fetcher
require 'net/imap'
class InboundEmailFetcher
MAILBOXES = {success: "INBOX.processed", failure: "INBOX.failed"}
def config
@config ||= YAML.load_file("#{Rails.root}/config/incoming_mailer_daemon.yml")[Rails.env].to_options
end