Skip to content

Instantly share code, notes, and snippets.

View justincaldwell's full-sized avatar

Justin Caldwell justincaldwell

View GitHub Profile
@justincaldwell
justincaldwell / time_bomb_diffuser.rb
Created September 21, 2011 22:41
Fix for ad_server time bomb.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + "/../ad_server_dependencies.rb"
class StatKeyFix
# This fixes ad stats that were incorrectly keyed in redis
# according to ContentCacheAdvertisement#id instead of the
# expected ContentInstance#id. The issue only affected ads
# with a ContentCacheAdvertisement.id greater than 100,000
require 'mime/types'
require 'RMagick'
class Photo < ActiveRecord::Base
establish_connection 'portal'
set_table_name 'photos'
belongs_to :kase
belongs_to :doctor
require 'mms2r'
class IncomingMailHandler < ActionMailer::Base
# Receive and process emails
def receive(email)
mms = MMS2R::Media.new(email)
photos = get_images_from_email(mms)
pemail = PhotoEmail.create_from_mail_handler(email, mms)
logit "Processing email from #{pemail.sender} with subject #{pemail.subject} "
class PhotoEmail < ActiveRecord::Base
belongs_to :doctor
belongs_to :kase
belongs_to :photo_email_status
has_many :photos
# Creates a new PhotoEmail from and incoming email
require 'lockfile'
def timestamp
Time.now.strftime('%x %X')
end
begin
Lockfile.new('cron_mail_fetcher.lock', :retries => 0) do
config = YAML.load_file("#{RAILS_ROOT}/config/mailer_daemon.yml")
config = config[RAILS_ENV].to_options