Skip to content

Instantly share code, notes, and snippets.

View trevorturk's full-sized avatar

Trevor Turk trevorturk

  • Chicago
View GitHub Profile

Keybase proof

I hereby claim:

  • I am trevorturk on github.
  • I am trevorturk (https://keybase.io/trevorturk) on keybase.
  • I have a public key whose fingerprint is BA9B A8C7 03A5 30E5 6B72 D928 E0F5 751D 09A6 0511

To claim this, I am signing this object:

# http://railscasts.com/episodes/126-populating-a-database
# http://github.com/ryanb/populator/tree/master
namespace :db do
task :populate => :environment do
require 'populator' # http://populator.rubyforge.org/
require 'faker' # http://faker.rubyforge.org/rdoc/
[User, Event, Link].each(&:delete_all)
def random(model)
# config/initializers/log_protected_attribute_removal.rb
# raises an exception in test environment when trying to mass assign protected attributes
# detail: http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment
if RAILS_ENV == 'test'
ActiveRecord::Base.class_eval do
def log_protected_attribute_removal(*attributes)
raise "Can't mass-assign these protected attributes: #{attributes.join(', ')}"
end
# Time zone issues with BJ, Rails, and UTC/local times?
# http://codeforpeople.rubyforge.org/svn/bj/trunk/README
# http://twitter.com/rubyist/statuses/957131155
# http://twitter.com/technoweenie/statuses/957156761
# config/initializers/bj_table_hack.rb
Bj::Table.class_eval do
def self.time_zone_aware_attributes
false
~ $ sudo gem install merb
Password:
Building native extensions. This could take a while...
Successfully installed extlib-0.9.8
Successfully installed thor-0.9.7
Successfully installed merb-core-0.9.9
Successfully installed merb-action-args-0.9.9
Successfully installed merb-assets-0.9.9
Successfully installed merb-auth-core-0.9.9
Successfully installed merb-auth-more-0.9.9
~ $ sudo gem install rails
Password:
Successfully installed rails-2.1.1
1 gem installed
require 'etc'
class Group
def foo
"hello"
end
end
class WTF < Struct.new(:var)
def foo
class Foo
attr_accessor :bar
def initialize(bar)
@bar = bar
end
def doit
puts bar
bar = "*** #{bar} ***"
# http://github.com/jnunemaker/httparty/
require 'rubygems'
require 'httparty'
class Delicious
include HTTParty
base_uri 'https://api.del.icio.us/v1'
def initialize(u, p)
@auth = {:username => u, :password => p}