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
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
#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
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
get_friend_list: function(facebook_id, limit, order, callback) | |
{ | |
var friends = FB.Data.query("SELECT first_name, pic_square, uid, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0}) ORDER BY {1} LIMIT {2}", parseInt(facebook_id), order, limit); | |
friends.wait(function(friends){ | |
callback(friends); | |
}); | |
}, |
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
send_wall_post_to_user: function(idx, facebook_id, message, user_message, post_name, post_description, post_image, post_caption) | |
{ | |
var params = {}; | |
params['message'] = user_message; | |
params['name'] = post_name; | |
params['description'] = post_description; | |
params['link'] = 'http://apps.facebook.com/irelandville_dev/'; | |
params['picture'] = post_image; | |
params['caption'] = post_caption; | |
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
show_feed_form: function(share_message,share_name, share_caption, share_description, share_image_href, share_image_src, share_action_link_text, share_action_link_href, share_user_message_prompt, share_href, callback) | |
{ | |
var publish = { | |
method: 'stream.publish', | |
message: "", | |
attachment: { | |
name: share_name, | |
caption: share_caption, | |
description: ( |
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
/* | |
$("#prev ~ sibling) doesnt seem to work in IE7 if the type both the prev and sibling element are of the same type. The examples on jQuery.com dont point this out. | |
(http://docs.jquery.com/Selectors/siblings#prevsiblings) | |
below is a workaround. | |
*/ | |
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
# template.rb | |
# USAGE: rails -m http://gist.github.com/gists/115163.txt PROJECT_NAME | |
run "rm public/index.html" | |
plugin 'thinking_sphinx', :git => 'git://github.com/freelancing-god/thinking-sphinx.git' | |
plugin 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git' | |
plugin 'factory_girl', :git => 'git://github.com/thoughtbot/factory_girl.git' | |
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git' | |
plugin 'project_search', :git => 'git://github.com/37signals/project_search.git' | |
plugin 'hubahuba', :git => 'git://github.com/paulca/hubahuba.git' |
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 self.formatViews(number) | |
number = number.gsub(/(\d)(?=\d{3}+(\.\d*)?$)/, '\1,') | |
number | |
end |