This file contains hidden or 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
class MailshotController < ApplicationController | |
def init | |
due_emails = EmailQueue.find(:all, :conditions => ["scheduled_at < ? AND is_complete = ?", DateTime.now, false]) | |
for email in due_emails | |
users = get_users_by_locale(email.locale) | |
user_emails = get_user_emails(users) | |
options = { | |
:from => email.from_email_address, | |
:to => user_emails, |
This file contains hidden or 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
#create this file in app/middleware and then in config/application.rb at the beginning of the application class you need to call it "config.middleware.use "PaperclipS3UrlRewriter" | |
class PaperclipS3UrlRewriter | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
status, headers, response = @app.call(env) | |
if response.is_a?(ActionController::Response) && response.request.protocol == 'https://' && headers["Content-Type"].include?("text/html") |
This file contains hidden or 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 scroll_to_top() { | |
FB.Canvas.getPageInfo(function (pageInfo) { | |
var iframe_scroll_y = pageInfo.scrollTop; | |
var target_div_y = $('#dr_dre').position().top; | |
if (iframe_scroll_y > target_div_y) { | |
var animOptions = { | |
step: function () { | |
FB.Canvas.scrollTo(0, this.y); | |
}, |
This file contains hidden or 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
def publish!(fbid, key, shwop=nil, entry=nil) | |
fb_action = Facebookaction.find_by_key(key) | |
access_token = Bookface::Base.client_credentials | |
a_type = fb_action.action_type | |
url = "http://#{Settings.host_url}/actions/#{fb_action.key}" | |
if entry.width > 520 and entry.height > 520 | |
puts "image is big enough for user generated attachment" | |
params = { Settings.facebook.fb_object_ref => url, | |
"image[0][url]" => entry.entry_asset_url, |
This file contains hidden or 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
# application.rb | |
def user_is_safari_fucked? | |
BPLogger.debug(request.env['HTTP_USER_AGENT']) | |
request.env['HTTP_USER_AGENT'].match(/(AppleWebKit).+Version\/(5\.1\.[4-9])/) | |
end | |
def js_redirect_to(url, signed_request=nil) |
This file contains hidden or 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
class Davos | |
#require 'RMagick' | |
include Magick | |
def self.for(user, message) | |
bottle_composition = create_composition(user, message) | |
bottle_file = Tempfile.new("composite-for-#{user.fbid}.jpg") | |
bottle_composition.write(bottle_file.path) |
This file contains hidden or 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
class Fbaction < ActiveRecord::Base | |
class << self | |
def publish!(fbid) | |
url = url + "/#{entry.id}" | |
params = { "<object_ref_here>" => url, | |
:access_token => access_token | |
} | |
res = Bookface::Graph.request("#{fbid}/<namespace_here>:<action_name_here>", params, :method => :post) | |
end |
This file contains hidden or 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
def show | |
if request.user_agent.index('facebookexternalhit') | |
@thing = Thing.find(params[:id]) | |
add_meta :property => 'og:title', :content => @thing.title | |
add_meta :property => 'og:type', :content => "article" | |
add_meta :property => 'og:url', :content => @thing.url_to_the_content | |
add_meta {{:property => 'og:image', :content => @thing.image_url}} | |
end | |
end |
This file contains hidden or 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
def match_friends | |
# now just find the friends of the user who are also using the app. | |
begin | |
res = Bookface::Graph.request("fql", { :q=> "SELECT uid, name, pic_square FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())", :access_token => access_token }) | |
rescue | |
res = nil | |
end | |
friend_ids = [] | |
# retrieve friend list from graph and compile a list of friends who are registered - aww friend | |
unless res.nil? or res["data"].nil? |
This file contains hidden or 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
ActiveAdmin.register Milestone do | |
scope :all, :default => true | |
scope :global | |
scope :user_specific | |
index do | |
column :title | |
column :description | |
column :required_litres | |
column :is_active |