Skip to content

Instantly share code, notes, and snippets.

Aaron Kromer cupakromer

Block or report user

Report or block cupakromer

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
cupakromer / gist:2773353
Created May 23, 2012
which way is the way?
View gist:2773353
# The points are stored in a nested hash
# {
# "bounds"=> {
# "northeast"=>{"lat"=>39.0464399, "lng"=>-76.9836289},
# "southwest"=>{"lat"=>38.995162, "lng"=>-77.033157}
# },
# }
# We just want the values, as an array:
# [north_lat, east_lng, south_lat, west_lng]
def extract_bounding_box_version1
View gist:2901020
module Fetcher
class Base
# ... other code ...
def uri
def options
View gist:2902415
module Fetcher
class BasicTraffic < Base
add_fetcher_options after: :count_severe_incidents
def self.inherited( subclass )
subclass.add_fetcher_options after: :count_severe_incidents
cupakromer / .rspec
Created Jun 10, 2012 — forked from coreyhaines/.rspec
Loading just active record
View .rspec
-I app
View cream_and_sugar.rb
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
def method_missing(name, *args, &block)
cupakromer / basic.rb
Created Aug 4, 2012
Steel City Ruby Lightning Talk
View basic.rb
def steelcityruby
"I heard you like programming."
cupakromer / gist:3371003
Created Aug 16, 2012
each_with_object vs inject
View gist:3371003
my_array = %w[test one two three]
# Inject takes the value of the block and passes it along
# This often causes un-intended errors
my_array.inject({}) do |transformed, word|
puts transformed
transformed[word] = word.capitalize
# Output:
# {}
cupakromer / Guardfile
Created Sep 8, 2012
Guard double test run
View Guardfile
# A sample Guardfile
# More info at
guard 'rspec', :version => 2 do
cupakromer /
Created Oct 3, 2012
Abusing Class and Struct

In tonight's meeting I tried, and failed, to show how to create a Struct with a custom method. Turns out, you can't do that. But you can use to accomplish this. UPDATE: You can do this. I don't remember what syntax I was trying before, but in 1.9.3 you can successfully pass a block to; though this isn't documented.

The end result is the same:

  • A new Class object
  • Default initialize handling the attributes
  • attr_accessor methods defined for those attributes

Big thanks to @steveklabnik for his two posts which inspired me to try to show this horribleness (that's a reflection on my silliness, not Steve):

cupakromer / gist:3867596
Created Oct 10, 2012
Is there a better way to have this?
View gist:3867596

So recently I was looking for a way to do a comparison on a String with either another String or a Regexp. Looking online didn't yield much help, most discussions on equality focused on ==, eql?, equal?. None of which would satisfy the requirement. So I was left with this code:

def matches(compare_with)
  if compare_with.is_a?(Regexp)
    @data_string =~ compare_with
You can’t perform that action at this time.