Skip to content

Instantly share code, notes, and snippets.


Chris Gallagher cgallagher

View GitHub Profile
View index.html
<!DOCTYPE html>
<script src=""></script>
<meta charset="utf-8">
<title>Konva Image Demo</title>
body {
margin: 0;
padding: 0;
View tracking.html
<script src="//" type="text/javascript"></script>
<script type="text/javascript">twttr.conversion.trackPid('<PIXEL_ID_HERE>', { tw_product_id: '<SKU_ID_HERE>', tw_country_code: '<ISO_COUNTRY_CODE_HERE>' });</script>
<img height="1" width="1" style="display:none;" alt="" src="<PIXEL_ID_HERE>&p_id=Twitter&tw_product_id=<SKU_ID_HERE>&tw_country_code=<ISO_COUNTRY_CODE_HERE>" />
<img height="1" width="1" style="display:none;" alt="" src="//<PIXEL_ID_HERE>&p_id=Twitter&tw_product_id=<SKU_ID_HERE>&tw_country_code=<ISO_COUNTRY_CODE_HERE>" />
cgallagher / traffikr.rb
Last active Dec 20, 2015
Not really production ready code in any sense of the word but will build up an ad and point it at a facebook custom audience... you can also generate a lookalike audience if you're bothered.
View traffikr.rb
# not production code - just a bunch of calls that run through the process of creating an ad and pointing it at a custom audience on Facebook.
class Traffikr
cattr_accessor :custom_audience_id, :access_token, :users_json, :account_id, :campaign_id, :image_hash, :creative_id
class << self
cgallagher / gist:5293000
Last active Dec 15, 2015
FQL to find your friends who have iPhones or iOS devices in the Graph API
View gist:5293000
//find all friends with iOS devices
SELECT uid, name, devices FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
AND "iOS" IN devices
ORDER BY profile_update_time DESC
LIMIT 0, 100
//find friends with iPhones
cgallagher / instagrammer.rb
Created Mar 13, 2013
Include this in your services directory of your Rails application in order to pull in and parse a hashtag RSS feed from Instagram.
View instagrammer.rb
class Instagrammer
cattr_accessor :config, :url
class << self
def perform(url, options = {})
defaults = {:expires_in => 15.minutes }
self.config = defaults.merge(options)
self.url = url
View blaa.rb
def redirect_to_canvas_if_no_signed_request_and_not_mobile
if !mobile_device? and !
extended_url = ""
if params
extended_url = "#{request.fullpath}"
redirect_to "#{Settings.facebook.canvas_url}#{extended_url}"
cgallagher / deploy.rake
Created Nov 16, 2012 — forked from ndbroadbent/deploy.rake
Rake task for precompiling assets locally before deploying to Heroku
View deploy.rake
require 'fileutils'
# Warning: The following deploy task will completely overwrite whatever is currently deployed to Heroku.
# The deploy branch is rebased onto master, so the push needs to be forced.
desc "Deploy app to Heroku after precompiling assets"
task :deploy do
deploy_branch = 'heroku'
remote = 'heroku'
deploy_repo_dir = "tmp/heroku_deploy"
cgallagher / geo.rb
Created Nov 8, 2012
Geo Restriction Logic using geocode gem
View geo.rb
def check_user_location
# need to intro a whitelist for IP addresses
user_ip = request.ip
unless user_ip.nil?"User IP Address is: #{user_ip}")
user_country ="User Country is: #{user_country}")
# if in production mode and the user country doesnt match one on the whitelist
# then throw them out to a restricted page.
redirect_to restricted_path() unless knock_knock(user_ip, user_country)
cgallagher / addtopage.js
Created Nov 4, 2012
Bookmarklet for adding to fan page.
View addtopage.js
cgallagher / entry.rb
Created Nov 1, 2012
Validating Paperclip
View entry.rb
# check the type of file and tell them to F off if its wrong.
validates_attachment :image, :presence => true, :size => { :in => 0..10.kilobytes }