Skip to content

Instantly share code, notes, and snippets.

/Users/kbennett/.rvm/rubies/ruby-2.1.2/bin/ruby -S rspec spec/avatar_spec.rb spec/basic_session_spec.rb spec/comment_spec.rb spec/configuration_spec.rb spec/field_parser_spec.rb spec/issue_spec.rb spec/jiralicious_spec.rb spec/project_avatar_spec.rb spec/project_spec.rb spec/search_result_spec.rb spec/search_spec.rb spec/user_avatar_spec.rb spec/user_spec.rb spec/watchers_spec.rb
FF..FF..F............F.F.FFFF..FFFFF......FF...FFF...F...FF...FFFFFF..
Failures:
1) Jiralicious avatar obtain system avatar list
Failure/Error: avatar = Jiralicious::Avatar.system('user')
NoMethodError:
The property 'system' is not defined for Jiralicious::Avatar.
# ./lib/jiralicious/avatar.rb:19:in `initialize'
@keithrbennett
keithrbennett / ruby_lambdas_slide_source_code.rb
Last active August 29, 2015 14:05
Source Code for Ruby Lambdas Presentation
# This is the source code included in the Ruby Lambdas presentation
# given at Steel City Ruby Conf in Pittsburgh, Pennsylvania, USA on August 15, 2014.
# This file is available at:
# https://gist.github.com/keithrbennett/0df037c29198ab401cf8
# and the presentation slides PDF is at:
# https://speakerdeck.com/keithrbennett/ruby-lambdas
# -- Keith Bennett (@keithrbennett)
2.1.2 :001 > require 'dot_notation'
=> true
2.1.2 :002 > h = { a: { b: 3 }}
=> {:a=>{:b=>3}}
2.1.2 :004 > DotNotation.dot(h, 'a.b')
NoMethodError: undefined method `dot' for DotNotation:Module
from (irb):4
from /Users/kbennett/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>'
module DotNotation
# ...
def dot_lambda(a_hash)
->(dotted_string) { DotNotation.dot(a_hash, dotted_string)}
end
end
dl = dot_lambda(my_hash)
dl.('a.b')
dl.('c.d')
#!/usr/bin/env ruby
# Modification of @tbloncar's script at
# https://gist.github.com/tbloncar/05265cb74762754b812d.
# @tbloncar, thank you for the gist. I see now that I should
# mention the performance cost of defining lambdas in methods
# in my presentation.
# Added ConstantLambdaApproach. Results I got with Ruby 2.1.2 were:
@keithrbennett
keithrbennett / diffy.rb
Created September 2, 2014 18:36
Diffy Sample
require 'diffy'
s1 = "apple\npear\npapaya\nmango\n"
s2 = "apple\npapaya\nmango\njackfruit\n"
diff = Diffy::Diff.new(s1, s2).to_s
puts diff
=begin
Output is:
@keithrbennett
keithrbennett / fib.clj
Created October 11, 2014 07:42
First 10 Fibonacci numbers
(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
Ruby 1.9.3:
➜ dnsruby git:(master) ✗ ruby test/ts_dnsruby.rb
/Users/kbennett/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- test/ts_online.rb (LoadError)
from /Users/kbennett/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from test/ts_dnsruby.rb:16:in `<main>'
➜ dnsruby git:(master) ✗ rake test
ruby setup.rb
setup.rb:789: Use RbConfig instead of obsolete and deprecated Config.
➜ dnsruby git:(lowercase-dnsruby-dirname) gem build *gemspec
WARNING: no description specified
WARNING: deprecated autorequire specified
WARNING: pessimistic dependency on rake (~> 10.3.2, development) may be overly strict
if rake is semantically versioned, use:
add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: dnsruby
Version: 1.56.0
I need to test a type-parameterized data structure
basically, I want to loop through various types
such as Long or BigInt, and run the same unit test suite with them:
[fake syntax] Seq(Long, BigInt).foreach(runTestSuite[_])
that is, I don't want to copy-paste code only because
I want to test CMS[Long], CMS[BigInt], etc.
Is there any (easy) way to do this?