Skip to content

Instantly share code, notes, and snippets.

View paul's full-sized avatar

Paul Sadauskas paul

View GitHub Profile
module EveryNth
def every_nth(n)
Enumerator.new do |yielder|
with_index do |*a, i|
yielder.yield(*a)
yield i if (i+1) % n == 0
end
end
@paul
paul / refinement_inheritance.rb
Created April 6, 2015 17:23
Ruby Refinement Inheritance
module MyExt
refine String do
def foo
"foo"
end
end
end
class Parent
@paul
paul / keybase.md
Last active August 29, 2015 14:04

Keybase proof

I hereby claim:

  • I am paul on github.
  • I am psadauskas (https://keybase.io/psadauskas) on keybase.
  • I have a public key whose fingerprint is 239C 6E2C 5405 95E3 0729 2777 D5B4 5A46 954A 36D8

To claim this, I am signing this object:

<section>
<h1>{{title}}</h1>
<p>{{text}}</p>
</section>
group :test, :development do
gem 'fabrication', '~> 2.9.3'
gem 'faker'
gem 'rspec-rails', '~> 3.0.0.beta1'
gem 'turnip'
gem 'capybara'
gem 'spring-commands-rspec'
gem 'timecop'
@paul
paul / gist:8164116
Created December 28, 2013 20:57
turnip rspec 3 beta spec failure
1) The CLI shows the correct description
Failure/Error: @result.should include('A simple feature')
expected "\nAmbiguous\n This is an ambiguous feature\n this is ambiguous (FAILED - 1)\n\nFailures:\n\n 1) Ambiguous This is an ambiguous feature this is ambiguous\n Failure/Error: Given this is ambiguous\n Turnip::Ambiguous:\n Ambiguous step definitions\r\n - \"this is ambiguous\" (/Users/rando/Code/librato/multipass/vendor/turnip/lib/turnip/dsl.rb:8:in `step')\r\n - \"this is :ambiguous\" (/Users/rando/Code/librato/multipass/vendor/turnip/lib/turnip/dsl.rb:8:in `step')\n # ./lib/turnip/execute.rb:17:in `step'\n # ./lib/turnip/rspec.rb:44:in `run_step'\n # ./lib/turnip/rspec.rb:72:in `block (6 levels) in run'\n # ./lib/turnip/rspec.rb:71:in `each'\n # ./lib/turnip/rspec.rb:71:in `block (5 levels) in run'\n # /Users/rando/.gem/ruby/2.1.0/gems/rspec-core-3.0.0.beta1/lib/rspec/core/example.rb:114:in `instance_exec'\n # /Users/rando/.gem/ru
@paul
paul / gist:4262547
Created December 11, 2012 21:51
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…
test long
Boo!
@paul
paul / output
Created September 24, 2012 19:42
personal/hypercacher - [master] » rspec spec/acceptance/response_cache_control_spec.rb
Hypercacher response Cache-Control header
is not present
the first request
should be OK (code 200)
should be authoritative
the second request
should be OK (code 200)
should not be authoritative
@paul
paul / _README.mkd
Created July 15, 2012 22:19
A better pretty_json.rb

Installation

  1. Copy prissy to ~/bin (or elsewhere in your $PATH)
  2. chmod +x prissy
  3. gem install awesome_print multi_json

Usage

$ some_command_that_outputs_json | prissy