Skip to content

Instantly share code, notes, and snippets.

@brentsowers1
brentsowers1 / application_helper.rb
Created March 6, 2014 02:31
application_helper to include Facebooker
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers/stream_publish'
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers/fb_connect'
require 'lib/facebooker-1.0.69/lib/facebooker/rails/helpers'
require 'lib/facebooker-1.0.69/lib/facebooker/rails/facebook_form_builder'
module ApplicationHelper
include Facebooker::Rails::Helpers
...
end
@brentsowers1
brentsowers1 / facebooker_example.rb
Created March 6, 2014 02:30
Example of using Facebooker
# Unique Facebook ID of this user
facebook_id = current_facebook_user.id
# The OAuth token, this is how you access the user at a later point
token = current_facebook_client.access_token
# OAuth token expiration. Save this off, you'll need this to recreate
# the user later
expiration = current_facebook_client.expiration.to_i
name = current_facebook_user.name
# Gets an array of Mogil::Users
@brentsowers1
brentsowers1 / ApplicationController.rb
Created March 6, 2014 02:29
ApplicationController.rb for Facebooker apps
class ApplicationController < ActionController::Base
include Facebooker2::Rails::Controller
# Needed to support IE 6 and 7
before_filter :set_p3p_header_for_third_party_cookies
# Add an :except here if you have controllers that you want to
# allow non-users to access
before_filter :ensure_application_is_installed
@brentsowers1
brentsowers1 / facebooker2.rb
Created March 6, 2014 02:27
config/initializers/facebooker2.rb for running Facebooker apps
Facebooker2.load_facebooker_yaml
@brentsowers1
brentsowers1 / db_migrate
Created March 6, 2014 02:19
script/db_migrate to run migrations in deployed WAR files
require 'rubygems'
require 'active_record'
require 'yaml'
config = YAML::load(File.open(File.expand_path('../../config/database.yml', __FILE__)))
ActiveRecord::Base.establish_connection(config["production"])
ActiveRecord::Migrator.migrate(File.expand_path('../../db/migrate', __FILE__) )
@brentsowers1
brentsowers1 / warbler.rb
Created March 6, 2014 02:17
config/warbler.rb for including database migrations in WAR
# Disable Rake-environment-task framework detection by uncommenting/setting to false
# Warbler.framework_detection = false
# Warbler web application assembly configuration file
Warbler::Config.new do |config|
# Application directories to be included in the webapp.
# Add script and db/migrate here
config.dirs = %w(app config lib log vendor tmp script db/migrate)
# Uncomment this if you're running in 1.9 mode
@brentsowers1
brentsowers1 / gist:6118766
Created July 31, 2013 02:08
Script to show lines attributed to each author
# Get all current files in your repo of the extensions that you want to be considered code
# (.scala and .js for my example)
git ls-files | egrep "\.(scala|js)$" > files.txt
# Now edit files.txt to remove files that you don't want counted, like jQuery extensions
cat files.txt | xargs -n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n
@brentsowers1
brentsowers1 / gist:6118765
Created July 31, 2013 02:08
Script to show lines attributed to each author
# Get all current files in your repo of the extensions that you want to be considered code
# (.scala and .js for my example)
git ls-files | egrep "\.(scala|js)$" > files.txt
# Now edit files.txt to remove files that you don't want counted, like jQuery extensions
cat files.txt | xargs -n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n
@brentsowers1
brentsowers1 / AudaxHealthSoftwareEngineer.scala
Last active September 24, 2021 18:03
Audax Health is looking for good software engineers
object AudaxHealthSoftwareEngineer {
val headline = """
Audax Health is hiring! Come join our incredible team of engineers in Washington, DC or San Francisco,
to help build the first truly social health platform, Zensey.com. We've embraced Scala and the
Lift web framework for most of our software, so if you have experience in or want to learn Scala,
we're looking for you!
"""
val requirementsDescription = """We don't have a firm list of requirements, we're just looking for
@brentsowers1
brentsowers1 / gist:2907648
Created June 10, 2012 23:12
jQuery attachment types test cases 3 and 4
function generateUniqueClasses(attachEventDirectly, elementsToGenerate) {
var generateFunction = function() {
var containerElement = $("#container");
containerElement.html("");
for (var i=0; i < elementsToGenerate; i++) {
var element = $('<div id="element' + i + '" class="differentClassItem' + i + '"><a href="#">click me</a> &nbsp;</div>');
containerElement.append(element);
if (attachEventDirectly) {
element.click(callbackFunction);
} else {