Skip to content

Instantly share code, notes, and snippets.

View patmaddox's full-sized avatar
🤔
Trying to figure out how to look up comments I've left

Pat Maddox patmaddox

🤔
Trying to figure out how to look up comments I've left
View GitHub Profile
p ['foo', 'foo', 'foo'].map(&:object_id)
p [:foo, :foo, :foo].map(&:object_id)
@patmaddox
patmaddox / .bash_profile
Created April 15, 2015 03:29
ruby ssl fix os x
#export SSL_CERT_FILE=/usr/local/opt/curl-ca-bundle/share/ca-bundle.crt # this was the old one...
export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem # this is OS X I think?
@patmaddox
patmaddox / Procfile
Last active August 29, 2015 14:11
cloud_foundry config
web: bundle exec puma -e $RAILS_ENV -p 1234 -S ~/puma -C config/puma.rb
@patmaddox
patmaddox / gist:f22617685ccce1053951
Last active August 29, 2015 14:07
question about gemfury
Hi, I haven't used Gemfury at all (yet) and I've only briefly clicked around...
I hope you don't mind answering some questions that might be covered elsewhere that
I just haven't found yet.
I want to distribute code to RubySteps members. I've been using git, which is obviously awesome,
but it doesn't really let me limit who gets what and when. I thought that was an advantage at
first, but it turns out that people get overwhelmed when I just throw the whole thing at them.
I could create a separate git repository for each member and push their new code there...
@patmaddox
patmaddox / authorized_controller.rb
Created August 13, 2014 04:20
RubySteps 012 - Rails - Mini frameworks snippet
module AuthorizedController
# ... full code in the paid lesson
def show
resource = resource_by_id
if resource.viewable_by?(current_user)
render json: resource
else
render text: 'Unauthorized', status: :unauthorized
@patmaddox
patmaddox / exercise_1a_legacy_1_spec.rb
Created August 9, 2014 07:12
RubySteps Lesson 010 - Refactoring - Legacy Code - excerpt
require 'rspec'
class Order
def initialize(customer_name)
@customer_name = customer_name
@items = []
end
def purchase(name, quantity, price)
@items << {name: name, quantity: quantity, price: price}
@patmaddox
patmaddox / rubysteps.rb
Created August 8, 2014 01:54
RubySteps 009 - OOP - Easty OOP (excerpt)
class StarWrapper
def initialize(stream)
@stream = stream
end
def puts(string)
print_header_line string
@stream.print "* "
@stream.print string
@stream.puts " *"
@patmaddox
patmaddox / exercise_2c_objects_spec.rb
Created August 7, 2014 02:10
rubysteps 008 - tdd - approval tests snippet
require 'approvals/rspec'
def output_methods(target, methods)
methods.inject([]) do |results, m|
results << %("#{target}".#{m} => #{target.send(m)})
end
end
describe "Ruby standard library" do
it "has a useful String class" do
pat-jukely:active_rest_client pat$ pwd
/Users/pat/code/opensource/active_rest_client
pat-jukely:active_rest_client pat$ bundle install
OH HAI! I am /Users/pat/code/opensource/active_rest_client/Gemfile
OH HAI! I am /Users/pat/code/opensource/active_rest_client/Gemfile
Resolving dependencies...
...
Your bundle is complete!
It was installed into ./vendor/bundle
OH HAI! I am /Users/pat/code/opensource/active_rest_client/Gemfile
@patmaddox
patmaddox / 01_original.rb
Created May 15, 2014 07:34
hexarch in rails
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end