Skip to content

Instantly share code, notes, and snippets.

🤔
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
Block or report user

Report or block patmaddox

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
View gist:8813262
something = case option_type
when OptionType then "do this"
when String then "do this thing"
else "how about this"
end
something = if option_type.class == OptionType
"do this"
elsif option_type.class == String
"do this thing"
View retrieve_keys
[1] pry(main)> hash = {a: 1, b: 2, c: 3}
=> {:a=>1, :b=>2, :c=>3}
[2] pry(main)> class Hash
[2] pry(main)* def retrieve_keys(*keys)
[2] pry(main)* self.reduce({}) { |h, (k, v)|
[2] pry(main)* keys.include?(k) ? h.merge!({k => v}) : h
[2] pry(main)* }
[2] pry(main)* end
[2] pry(main)* end
=> nil
@patmaddox
patmaddox / gist:9100174
Created Feb 19, 2014
how to stop twitter from spamming your iPhone
View gist:9100174
Hi, your instructions kind of suck but I figured it out. Here's how to actually do it:
From the iOS app...
1) Go to the Me tab, tap the gear icon, then click settings
2) Tap on the account name to open the notifications settings for that account (critical missing piece of info)
3) Disable "Recommendations" "news" and "other"
Pat
@patmaddox
patmaddox / environments_production.rb
Last active Aug 29, 2015
<srbaker>SOLVED</srbaker>
View environments_production.rb
default_attributes chef_user: "ubuntu"
default_attributes { ... a whole mess of other stuff which apparently blows away the first line. whoops }
View gist:1a7628aa78d27e5c83eb
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 / exercise_2c_objects_spec.rb
Created Aug 7, 2014
rubysteps 008 - tdd - approval tests snippet
View exercise_2c_objects_spec.rb
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
@patmaddox
patmaddox / rubysteps.rb
Created Aug 8, 2014
RubySteps 009 - OOP - Easty OOP (excerpt)
View rubysteps.rb
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_1a_legacy_1_spec.rb
Created Aug 9, 2014
RubySteps Lesson 010 - Refactoring - Legacy Code - excerpt
View exercise_1a_legacy_1_spec.rb
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 / authorized_controller.rb
Created Aug 13, 2014
RubySteps 012 - Rails - Mini frameworks snippet
View authorized_controller.rb
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 / gist:f22617685ccce1053951
Last active Aug 29, 2015
question about gemfury
View gist:f22617685ccce1053951
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...
You can’t perform that action at this time.