Skip to content

Instantly share code, notes, and snippets.

View sterrym's full-sized avatar

Tim Glen sterrym

  • Shopify Inc
  • Ontario, Canada
View GitHub Profile
I, [2010-12-06T09:33:27.030001 #27061] INFO -- : unlinking existing socket=/tmp/.unicorn-socket
I, [2010-12-06T09:33:27.030259 #27061] INFO -- : listening on addr=/tmp/.unicorn-socket fd=3
I, [2010-12-06T09:33:27.030806 #27061] INFO -- : Refreshing Gem list
/usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:27:in `setup': You have already activated rack 1.0.1, but your Gemfile requires rack 1.2.1. Consider using bundle exec. (Gem::LoadError)
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:17:in `setup'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler.rb:100:in `setup'
from /var/www/releases/20101206173428/config/boot.rb:8
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
@sterrym
sterrym / facebook.rb
Created June 8, 2011 21:40
facebook posting
class Facebook
attr_accessor :user
def initialize(user)
self.user = user
end
def post(user, params={})
params = normalize_params(params, %w(message picture link name caption description source))
client = OAuth2::Client.new(app_id, app_secret, :site => 'https://graph.facebook.com/', :parse_json => true)
@sterrym
sterrym / auto_token.rb
Created January 23, 2012 16:03
auto-create a unique youtube-like token to uniquely identify a records
class Foo < ActiveRecord::Base
before_create :make_token
private
TOKEN_SYMBOLS = (('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a)
def make_token
self.token = (1..12).inject(""){|token, num| token += TOKEN_SYMBOLS.rand.to_s }
make_token if self.class.find_by_token(self.token)
self.token
end