Skip to content

Instantly share code, notes, and snippets.

View patbenatar's full-sized avatar

Nick Giancola patbenatar

View GitHub Profile
@patbenatar
patbenatar / fb_iframe_size.coffee
Created May 10, 2012 17:24
Resizing the frame and body of Facebook apps
$ ->
setFbSize()
$('body').bind('resizeframe', setFbSize)
# If this page has fbcomments on it, we need to set height at an interval
# so we resize when new comments/interactions with that widget happen
if $('.fb-comments').length
setInterval(setFbSize, 100)
$(window).load ->
@patbenatar
patbenatar / authorize.coffee
Created May 17, 2012 17:56
CoffeeScript to authorize FB connect with FB JS SDK and omniauth
authorizePlayer = ->
FBLoad =>
FB.getLoginStatus (response) ->
if response.status == 'connected'
# the user is logged in and connected to app
window.location.href = '/players/auth/facebook/callback'
else if response.status == "not_authorized"
# the user is logged in to Facebook, but not connected to app
# Attempt to auth
FB.login (response) ->
var defaultDiacriticsRemovalMap = [
{'base':'A', 'letters':/[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g},
{'base':'AA','letters':/[\uA732]/g},
{'base':'AE','letters':/[\u00C6\u01FC\u01E2]/g},
{'base':'AO','letters':/[\uA734]/g},
{'base':'AU','letters':/[\uA736]/g},
{'base':'AV','letters':/[\uA738\uA73A]/g},
{'base':'AY','letters':/[\uA73C]/g},
{'base':'B', 'letters':/[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]/g},
{'base':'C', 'letters':/[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]/g},
{
'ẚ':'a',
'Á':'a',
'á':'a',
'À':'a',
'à':'a',
'Ă':'a',
'ă':'a',
'Ắ':'a',
'ắ':'a',
{
'Æ':'ae',
'æ':'ae',
'ẚ':'a',
'Á':'a',
'á':'a',
'À':'a',
'à':'a',
'Ă':'a',
'ă':'a',
@patbenatar
patbenatar / gist:3021688
Last active October 6, 2015 16:28
My Sublime Text 2 Preferences
{
	"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
	"draw_white_space": "selection",
	"font_face": "Source Code Pro",
	"font_size": 14,
	"highlight_line": true,
	"ignored_packages":
	[
 "Vintage"
#!/usr/bin/env ruby
require 'yaml'
require 'fileutils'
YAML::ENGINE.yamler = 'psych'
RAILS_ENV = ENV["RAILS_ENV"]
path_to_database_yml = File.join("config", "database.yml")
@patbenatar
patbenatar / fb_init.coffee
Created August 24, 2012 21:29
Initialize Facebook JS SDK in Coffeescript
# Important: this requires your Facebook App ID to be in data-id on #fb-root
window.fbAsyncInit = ->
FB.init
appId: document.getElementById("fb-root").getAttribute("data-id")
# Async load the JS SDK
id = "facebook-jssdk"
ref = document.getElementsByTagName("script")[0]
return if document.getElementById(id)
@patbenatar
patbenatar / gist:3739322
Created September 17, 2012 19:39
gow social json example
[
// Example post to be presented as text
{
source: "twitter",
source_url: "http://twitter.com/giantcola", // We only need this if the URL can change between posts from the same source
title: "@giantcola", // This title can be anything from a twitter username to a tumblr post title (it will be displayed as the gold caps text in the design comp
body: "Here is an example tweet!",
weight: 1 // 1 or 2, affects the size of the tile
},
// Example post to be presented as an image
@patbenatar
patbenatar / gist:3796482
Created September 27, 2012 21:08
in view DSL for tables
<%= table_for @videos, headers: false do %>
<%= column :name %>
<%= column :url %>
<%= actions :edit, :delete %>
<% end %>