Skip to content

Instantly share code, notes, and snippets.

Trevor trev

Block or report user

Report or block trev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
trev / config.yml
Created May 25, 2018
CircleCI 2.0 with parallelism & simplecov for Rails
View config.yml
# Ruby CircleCI 2.0 configuration file
# Check for more details
defaults: &defaults
working_directory: ~/split_app
parallelism: 2
- image: circleci/ruby:2.5.0-node-browsers
View delegate_singleton.rb
class Server
class << self
delegate :dl_private_key!, to: Figaro.env
key_data: [ dl_private_key! ],
keys: [], # Required or Net:SSH will search for machine keys
keys_only: true,
trev / line_item.rb
Last active Feb 5, 2016
View line_item.rb
class LineItem < ActiveRecord::Base
belongs_to :order
has_many :passengers
View stuff.haml
= simple_form_for @form, wrapper: :booking do |f|
%h3.small-title Your Personal Information
= f.simple_fields_for :line_items do |li|
= li.simple_fields_for :passengers do |pax|
%h4= "Trip: #{Product.find(li.object.product_id).title}"
%h5= "Tell us about dude ##{pax.index + 1}"
= pax.input :first_name, placeholder: 'Big'
trev /
Last active Aug 29, 2015
Starting a new Rails application on Mac OSX 10.10 using chruby + POW
source /usr/local/share/chruby/
chruby $(cat .ruby-version)
  • Generate the rails app skeleton: $ rails new my_billion_dollar_app
  • Link it up to pow: $ ln -s ~/Sites/my_billion_dollar_app ~/.pow/.

Linux (Ubuntu)


$ visudo
# This allows user to sudo but prompts for password
dog     ALL=(ALL:ALL) ALL
View method_logger.rb
class MethodLogger
def log_method(klass, method_name)
klass.class_eval do
alias_method "#{method_name}_original", method_name
define_method method_name do |*args, &block|
puts "Called #{method_name}"
send "#{method_name}_original", *args, &block
View float_precision.rb
sum = 0
[106.90, 106.90, 106.90, 106.90, 106.90, 106.90].each do |l|
sum += l
p sum
# Output
# 106.9
# 213.8
# 320.70000000000005

Keybase proof

I hereby claim:

  • I am trev on github.
  • I am trevw ( on keybase.
  • I have a public key ASA_MrVzdOD_P5Av12r3MHZGLp63eH1Hgdvld9THynOmaQo

To claim this, I am signing this object:

View custom_error_messages.markdown

How to customize the humanized :category symbol in the generated error message. Tested with Rails 4.1

class Listing < ActiveRecord::Base    
  validate :premium_category


  def premium_category
You can’t perform that action at this time.