Skip to content

Instantly share code, notes, and snippets.

View nthj's full-sized avatar

Nathaniel Jones nthj

  • Orlando, FL
View GitHub Profile
class VeryVeryBadException < RuntimeError
end
begin
raise VeryVeryBadException, "winter is coming"
# 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
#
@mixin blur($much: 10px) {
-webkit-filter: blur($much);
// Force hardware acceleration for vastly improved performance
-webkit-transform: translate3d(0, 0, 0);
}
@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
@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 / config.ru
Created February 26, 2014 23:22
unicorn
# This file is used by Rack-based servers to start the application.
$stdout.sync = true
require 'unicorn/worker_killer'
##
## Maximum Requests
##
@nthj
nthj / post-checkout
Created May 23, 2014 15:03
Automatically create a new database for each of your development branches
#!/bin/bash
set -e
printf '\npost-checkout hook\n\n'
if [[ $3 == 1 ]]; then
echo "Creating `git name-rev --name-only $2`"
createdb "ticketbud_`git name-rev --name-only $2`_development"
@nthj
nthj / 01_person.rb
Created May 28, 2014 02:30
Mild refactoring of an example from "Rails Does Not Define Your Application Architecture" | http://www.naildrivin5.com/blog/2014/05/27/rails-does-not-define-your-application-architecture.html
class Person < ActiveRecord::Base
end
@nthj
nthj / extension.scss
Created August 20, 2014 17:31
Font Awesome Awesomeness
// multi-ticket icon
.fa-tickets {
&:after, &:before {
content: "\f145";
}
&:after {
margin-left: -12px;
opacity: 0.7;
}
@nthj
nthj / exceptionable.rb
Created October 21, 2015 01:49
Fun shorthand for raising exceptions from Rails callbacks
class StandardError
# Accountant::CannotDestroyFinancialData = Class.new(Exception)
# before_destroy(&Accountant::CannotDestroyFinancialData)
def self.to_proc
e = self; -> { raise e }
end
end