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
| var isMobile = { | |
| Android: function() { | |
| return navigator.userAgent.match(/Android/i) ? true : false; | |
| }, | |
| BlackBerry: function() { | |
| return navigator.userAgent.match(/BlackBerry/i) ? true : false; | |
| }, | |
| iOS: function() { | |
| return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false; | |
| }, |
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
| require 'rubygems' | |
| require "net/http" | |
| require "net/https" | |
| require "uri" | |
| access_token = "" #App Access Token (app_id|app_secret) | |
| user_id = "" #FBID of an app user who has granted perms to publish actions within your app | |
| og_object_url = "http://dby-staging.herokuapp.com/og/84" #url to the OG data to be pushed along with your user |
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 RestrictAddresses | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| request = Rack::Request.new(env) | |
| incoming_ip_address = request.env['REMOTE_ADDR'] | |
| allowed_range = ['127.0.0.1'] |
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
| cd `brew --prefix` | |
| rm -rf Cellar | |
| brew prune | |
| rm `git ls-files` | |
| rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions | |
| rm -rf .git | |
| rm -rf ~/Library/Caches/Homebrew |
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 |
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
| 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
| 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
| 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
| # 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) |