Skip to content

Instantly share code, notes, and snippets.

@Heath101
Heath101 / middlewares_example.rb
Last active January 7, 2016 18:57
Middlewares example
class SalesForce
def initialize(app)
@app = app
end
def call(env)
puts "SalesForce Handler"
puts "SalesForce AXID found"
env[:axids] << "AXID01234567890"
env[:salesforce] = {customer: {}}
@Heath101
Heath101 / underscore_accessor.rb
Created August 6, 2014 18:57
Underscore Accessor
require 'minitest/autorun'
class Hash
def method_missing( symbol, *args )
if symbol.to_s.start_with?('_')
if symbol.to_s.end_with?('=')
key = symbol.to_s.sub('_', '').chop
if self.has_key?(key.to_sym)
self[key.to_sym] = args.first
elsif self.has_key?(key)
@Heath101
Heath101 / phone_directory
Last active August 29, 2015 14:00
Phone Directory codewars kata (working)
# Write a directory class which will manage a phone directory for a company.
def directory_lookup(directory, input)
r = /\A#{input}/
d = directory.dup.keep_if {|name| name_to_num(name.split.last).match(r) }
if d.empty?
e = directory.dup.map { |name| name_to_num(name.split.last).chr}
e.keep_if {|n| n > input.chr }.first
return directory_lookup(directory, e) unless e.empty?
directory.last
@Heath101
Heath101 / gist:9722521
Created March 23, 2014 12:35
rails template temp
Rails new
cd
git init
git commit -a -m "Initial Commit"
git co -b setup
-look at .gitignore
-change secret_token.rb
Gemfile
bundle install --without production
rails g rspec:install