Skip to content

Instantly share code, notes, and snippets.

View sahilshah-rr's full-sized avatar

Sahil Shah sahilshah-rr

View GitHub Profile
@sahilshah-rr
sahilshah-rr / alternate_parent.rb
Last active June 7, 2017 22:32
Ruby: Non-instantiable parent class with instantiable subclasses
class AlternateParent
def self.new(*args)
raise NoMethodError, "cannot instantiate #{self.name}" if self == AlternateParent
super
end
def initialize(num)
@num = num
end
end
@sahilshah-rr
sahilshah-rr / Geometry.geojson
Last active February 22, 2016 20:52
Walkscore Travel Time API example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Keybase proof

I hereby claim:

  • I am sashah87 on github.
  • I am sahil (https://keybase.io/sahil) on keybase.
  • I have a public key whose fingerprint is 74D0 E09B 6B3C D2DF BFAF CF04 8F7E F3C4 D2B2 F0CA

To claim this, I am signing this object:

@sahilshah-rr
sahilshah-rr / def-rescue-ensure-end-1.rb
Created August 29, 2012 21:19
def...rescue...ensure...end returns value from ensure block only if explicit directive to do so is present
def abc(bool)
a=b=0
a+=10
raise StandardError if bool
"returning from main func a#{a} b#{b}" # returned unless bool
rescue
"returning from rescue a#{a} b#{b}" # returned if bool
ensure
b+=10 # always executed
puts "printing from ensure a#{a} b#{b}" # always executed