Skip to content

Instantly share code, notes, and snippets.

View nthj's full-sized avatar

Nathaniel Jones nthj

  • Orlando, FL
View GitHub Profile
@nthj
nthj / association_class_name_guesser.rb
Last active August 29, 2015 13:56
I feel evil. [Guess namespaced associations automatically.]
class ActiveRecord::Reflection::AssociationReflection
class AmbiguousAssociationClassError < Exception
def initialize results
super "Could not guess association, please specify using class_name. Likely options: #{results.join(', ')}"
end
end
def klass
super
rescue NameError
@nthj
nthj / Procfile.dev
Last active January 3, 2016 06:19
Boot up all of your dependencies for a Rails app at once with `foreman start -f Procfile.dev`
bundler: bundle exec guard --plugin bundler --no-interactions
db: postgres -D /opt/boxen/homebrew/var/postgres
integration: bundle exec guard --plugin cucumber --no-interactions
mailcatcher: mailcatcher --foreground --verbose
redis: redis-server /opt/boxen/homebrew/etc/redis.conf
test: bundle exec guard --plugin rspec --no-interactions
web: bundle exec guard --plugin unicorn --no-interactions
worker: bundle exec sidekiq
@mixin blur($much: 10px) {
-webkit-filter: blur($much);
// Force hardware acceleration for vastly improved performance
-webkit-transform: translate3d(0, 0, 0);
}
# Quiz Exercise, Part One
#
# Quiz for a list of names & birthdays,
# then list out their ages
#
# For example:
#
# Hey there! Please enter a list of names:
# > John, Sam, Bob, Alisha, Henry
#
class VeryVeryBadException < RuntimeError
end
begin
raise VeryVeryBadException, "winter is coming"
def bouncer(name, age = 18)
if age < 21
puts "Go away, #{name}"
else
puts "OK"
end
end
# Quiz Exercise, Part One
#
# Quiz for a list of names & birthdays,
# then list out their ages
#
# For example:
#
# Hey there! Please enter a list of names:
# > John, Sam, Bob, Alisha, Henry
#
# Quiz Exercise, Part One
#
# Quiz for a name and birthday,
# then display the age
#
# For example:
#
# Hey there! Please enter your name:
# > John
#
@nthj
nthj / exercise-2.rb
Last active December 30, 2015 19:39
# Quiz Exercise, Part One
#
# Quiz for a list of names & birthdays,
# then list out their ages
#
# For example:
#
# Hey there! Please enter a list of names:
# > John, Sam, Bob, Alisha, Henry
#
# Quiz Exercise, Part One
#
# Quiz for a name and birthday,
# then display the age
#
# For example:
#
# Hey there! Please enter your name:
# > John
#