Skip to content

Instantly share code, notes, and snippets.

class IOSource
include Enumerable
def each
loop do
yield gets.chomp
end
end
end

Keybase proof

I hereby claim:

  • I am jacknoble on github.
  • I am jnobledox (https://keybase.io/jnobledox) on keybase.
  • I have a public key ASAYwC2QgVaOfYrFY1vNR92aRfIIQr6bxZV5YVSF8zVCIwo

To claim this, I am signing this object:

TRY_REGEX = /\.try!?\((?<args>.*?)\)/
Dir.glob("app/**/*{.rb,.erb,.jbuilder}").each do |fname|
text = File.open(fname, 'rb', &:read)
new_text = text.gsub(TRY_REGEX) do
(method_name, *args) = Regexp.last_match[:args].tr(' ', '').split(',')
if args.any?
"&#{method_name.tr(':', '.')}(#{args.join(', ')})"
else
"&#{method_name.tr(':', '.')}"
end
FooBar = -> (thing) do
# ...
end
class FooBar
def self.call(arg)
new(arg).call
end
def initialize(thing)
@thing = thing
end
def call
class FooBarService
def self.call(arg)
new(arg).call
end
def initialize(thing)
@thing = thing
end
def call
Good Day...
I am United Nations Diplomat Dr. Johnson Harry from the United Nations Diplomatic Courier Commission. I just want to notify you that I am currently at John F Kennedy International Airport With your consignment boxes which was assigned from the United Kingdom to dispose the 2 boxes tagged family values which were recovered by men of the Bureau of National Investigation of the Ethiopia Government.Subsequent to a High Level Forum ("Towards "Towards Sustainable Business Relations for All in Africa") meeting held on the 14th of November, 2015 at the African Union Summit held in Ethiopia, it was jointly agreed that a committee, be put in place to ensure the release of outstanding debts and recovered inheritance funds. These is as a result of several petitions from Individuals,Co-Operate institution and International Countries of the failure to receive their various goods.
Presently your two consignment boxes are among those to be disposed and delivered to you, and that is the reason why i'm mailing
require "spec_helper"
require "signup"
describe Signup do
describe "#save" do
it "creates an account with one user" do
signup = Signup.new(email: "user@example.com", account_name: "Example")
allow(Account).to receive(:create!).and_return(Account.new)
allow(User).to receive(:create!).and_return(User.new)
def fibs(0), do: []
def fibs(1), do: [1]
def fibs(2), do: [1, 0]
def fibs(num) do
lower_fibs = fibs(num - 1)
[sum(take(lower_fibs, 2)) | lower_fibs ]
end
@jacknoble
jacknoble / gist:52fef060248f4a80c1aa
Created September 17, 2014 03:13
memo make change
def make_change(amount)
mc(amount, 5)
end
def mc(amount, kinds_of_coins)
return 1 if amount == 0
return 0 if amount < 0 || kinds_of_coins == 0
other_coins = mc(amount, kinds_of_coins - 1)
remove_largest_coin = mc(amount - next_denom(kinds_of_coins), kinds_of_coins)
other_coins + remove_largest_coin