Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby things

84540052d294a5a94bf3246b26747120?s=47 Julio Santos
September 19, 2012

Ruby things

Some ruby surprises, tricks, oddities. There should be something surprising to all rubyists.

84540052d294a5a94bf3246b26747120?s=128

Julio Santos

September 19, 2012
Tweet

Transcript

  1. ruby things Wednesday, September 19, 12

  2. string weirdness 01 Wednesday, September 19, 12

  3. 1.8.7-p358 :001 > s = “this” “is” “a” “thing” Wednesday,

    September 19, 12
  4. 1.8.7-p358 :001 > s = “this” “is” “a” “thing” =>

    “thisisathing” 1.8.7-p358 :002 > Wednesday, September 19, 12
  5. 1.8.7-p358 :001 > s = % qwerty\ azerty .size Wednesday,

    September 19, 12
  6. 1.8.7-p358 :001 > s = % qwerty\ azerty .size =>

    13 Wednesday, September 19, 12
  7. print json 02 Wednesday, September 19, 12

  8. 1.8.7-p358 :001 > require “rubygems” => true 1.8.7-p358 :002 >

    require “json” => true 1.8.7-p358 :003 > h = {:one => 1, :two => 2} => {:one=>1, :two=>2} 1.8.7-p358 :004 > j h Wednesday, September 19, 12
  9. 1.8.7-p358 :001 > require “rubygems” => true 1.8.7-p358 :002 >

    require “json” => true 1.8.7-p358 :003 > h = {:one => 1, :two => 2} => {:one=>1, :two=>2} 1.8.7-p358 :004 > j h {"one":1,"two":2} Wednesday, September 19, 12
  10. 1.8.7-p358 :001 > require “rubygems” => true 1.8.7-p358 :002 >

    require “json” => true 1.8.7-p358 :003 > h = {:one => 1, :two => 2} => {:one=>1, :two=>2} 1.8.7-p358 :004 > j h {"one":1,"two":2} 1.8.7-p358 :005 > jj h Wednesday, September 19, 12
  11. 1.8.7-p358 :001 > require “rubygems” => true 1.8.7-p358 :002 >

    require “json” => true 1.8.7-p358 :003 > h = {:one => 1, :two => 2} => {:one=>1, :two=>2} 1.8.7-p358 :004 > j h {"one":1,"two":2} 1.8.7-p358 :005 > jj h { "one": 1, "two": 2 } 1.8.7-p358 :006 > Wednesday, September 19, 12
  12. interpolation 03 Wednesday, September 19, 12

  13. 1.8.7-p358 :001 > @name = "bob" => “bob” 1.8.7-p358 :002

    > puts "hello #@name" Wednesday, September 19, 12
  14. 1.8.7-p358 :001 > @name = "bob" => “bob” 1.8.7-p358 :002

    > puts "hello #@name" “hello bob” => nil Wednesday, September 19, 12
  15. .. and ... 04 Wednesday, September 19, 12

  16. 1.8.7-p358 :001 > a = (1..2) => 1..2 Wednesday, September

    19, 12
  17. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a Wednesday, September 19, 12
  18. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a => [1, 2] Wednesday, September 19, 12
  19. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a => [1, 2] 1.8.7-p358 :003 > b = (1...2) Wednesday, September 19, 12
  20. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a => [1, 2] 1.8.7-p358 :003 > b = (1...2) => 1...2 Wednesday, September 19, 12
  21. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a => [1, 2] 1.8.7-p358 :003 > b = (1...2) => 1...2 1.8.7-p358 :004 > b.to_a Wednesday, September 19, 12
  22. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002

    > a.to_a => [1, 2] 1.8.7-p358 :003 > b = (1...2) => 1...2 1.8.7-p358 :004 > b.to_a => [1] Wednesday, September 19, 12
  23. string contains? 05 Wednesday, September 19, 12

  24. 1.8.7-p358 :001 > s = "this is a string" =>

    “this is a string” 1.8.7-p358 :002 > s[“is a”] Wednesday, September 19, 12
  25. 1.8.7-p358 :001 > s = "this is a string" =>

    “this is a string” 1.8.7-p358 :002 > s[“is a”] => “is a” Wednesday, September 19, 12
  26. 1.8.7-p358 :001 > s = "this is a string" =>

    “this is a string” 1.8.7-p358 :002 > s[“is a”] => “is a” 1.8.7-p358 :003 > s["is not a"] Wednesday, September 19, 12
  27. 1.8.7-p358 :001 > s = "this is a string" =>

    “this is a string” 1.8.7-p358 :002 > s[“is a”] => “is a” 1.8.7-p358 :003 > s["is not a"] => nil Wednesday, September 19, 12
  28. expand array 06 Wednesday, September 19, 12

  29. 1.8.7-p358 :001 > [*10..20] Wednesday, September 19, 12

  30. 1.8.7-p358 :001 > [*10..20] => [10, 11, 12, 13, 14,

    15, 16, 17, 18, 19, 20] Wednesday, September 19, 12
  31. hash from array 07 Wednesday, September 19, 12

  32. 1.8.7-p358 :001 > Hash[1,2,3,4] Wednesday, September 19, 12

  33. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} Wednesday, September 19,

    12
  34. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] Wednesday, September 19, 12
  35. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} Wednesday, September 19, 12
  36. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] Wednesday, September 19, 12
  37. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] Wednesday, September 19, 12
  38. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] 1.8.7-p358 :004 > Hash[a] Wednesday, September 19, 12
  39. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] 1.8.7-p358 :004 > Hash[a] => {"two"=>2, "one"=>1} 1.8.7-p358 :005 > b = [1,2,3,4] Wednesday, September 19, 12
  40. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] 1.8.7-p358 :004 > Hash[a] => {"two"=>2, "one"=>1} 1.8.7-p358 :005 > b = [1,2,3,4] => [1,2,3,4] Wednesday, September 19, 12
  41. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] 1.8.7-p358 :004 > Hash[a] => {"two"=>2, "one"=>1} 1.8.7-p358 :005 > b = [1,2,3,4] => [1,2,3,4] 1.8.7-p358 :006 > Hash[*b] Wednesday, September 19, 12
  42. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 >

    Hash[["one", 1], ["two", 2]] => {["one", 1]=>["two", 2]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2] => [["one", 1], ["two", 2]] 1.8.7-p358 :004 > Hash[a] => {"two"=>2, "one"=>1} 1.8.7-p358 :005 > b = [1,2,3,4] => [1,2,3,4] 1.8.7-p358 :006 > Hash[*b] => {1=>2, 3=>4} Wednesday, September 19, 12
  43. zip 08 Wednesday, September 19, 12

  44. 1.8.7-p358 :001 > keys = [:one, :two, :three] => [:one,

    :two, :three] 1.8.7-p358 :002 > values = [1,2,3] => [1, 2, 3] 1.8.7-p358 :003 > zip = keys.zip(values) Wednesday, September 19, 12
  45. 1.8.7-p358 :001 > keys = [:one, :two, :three] => [:one,

    :two, :three] 1.8.7-p358 :002 > values = [1,2,3] => [1, 2, 3] 1.8.7-p358 :003 > zip = keys.zip(values) => [[:one, 1], [:two, 2], [:three, 3]] Wednesday, September 19, 12
  46. 1.8.7-p358 :001 > keys = [:one, :two, :three] => [:one,

    :two, :three] 1.8.7-p358 :002 > values = [1,2,3] => [1, 2, 3] 1.8.7-p358 :003 > zip = keys.zip(values) => [[:one, 1], [:two, 2], [:three, 3]] 1.8.7-p358 :004 > Hash[zip] Wednesday, September 19, 12
  47. 1.8.7-p358 :001 > keys = [:one, :two, :three] => [:one,

    :two, :three] 1.8.7-p358 :002 > values = [1,2,3] => [1, 2, 3] 1.8.7-p358 :003 > zip = keys.zip(values) => [[:one, 1], [:two, 2], [:three, 3]] 1.8.7-p358 :004 > Hash[zip] => {:two=>2, :three=>3, :one=>1} Wednesday, September 19, 12
  48. shuffle 09 Wednesday, September 19, 12

  49. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3]

    1.8.7-p358 :002 > a.shuffle Wednesday, September 19, 12
  50. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3]

    1.8.7-p358 :002 > a.shuffle => [1, 3, 2] Wednesday, September 19, 12
  51. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3]

    1.8.7-p358 :002 > a.shuffle => [1, 3, 2] 1.8.7-p358 :003 > a.shuffle Wednesday, September 19, 12
  52. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3]

    1.8.7-p358 :002 > a.shuffle => [1, 3, 2] 1.8.7-p358 :003 > a.shuffle => [3, 2, 1] Wednesday, September 19, 12
  53. cons 10 Wednesday, September 19, 12

  54. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > a.each_cons(2) {|pair| p pair} Wednesday, September 19, 12
  55. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > a.each_cons(2) {|pair| p pair} [1, 2] [2, 3] [3, 4] [4, 5] => nil Wednesday, September 19, 12
  56. set 11 Wednesday, September 19, 12

  57. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 Wednesday, September 19, 12
  58. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 => #<Set: {1}> Wednesday, September 19, 12
  59. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 => #<Set: {1}> 1.8.7-p358 :004 > s << 1 Wednesday, September 19, 12
  60. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 => #<Set: {1}> 1.8.7-p358 :004 > s << 1 => #<Set: {1}> Wednesday, September 19, 12
  61. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 => #<Set: {1}> 1.8.7-p358 :004 > s << 1 => #<Set: {1}> 1.8.7-p358 :005 > s << 2 Wednesday, September 19, 12
  62. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 >

    s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1 => #<Set: {1}> 1.8.7-p358 :004 > s << 1 => #<Set: {1}> 1.8.7-p358 :005 > s << 2 => #<Set: {1, 2}> Wednesday, September 19, 12
  63. include A, B, C 12 Wednesday, September 19, 12

  64. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil Wednesday, September 19, 12
  65. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil Wednesday, September 19, 12
  66. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C Wednesday, September 19, 12
  67. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo Wednesday, September 19, 12
  68. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo => “B” Wednesday, September 19, 12
  69. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo => “B” 1.8.7-p358 :005 > class D; include A, B; end Wednesday, September 19, 12
  70. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo => “B” 1.8.7-p358 :005 > class D; include A, B; end => D Wednesday, September 19, 12
  71. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo => “B” 1.8.7-p358 :005 > class D; include A, B; end => D 1.8.7-p358 :006 > D.new.foo Wednesday, September 19, 12
  72. 1.8.7-p358 :001 > module A; def foo; "A"; end; end

    => nil 1.8.7-p358 :002 > module B; def foo; "B"; end; end => nil 1.8.7-p358 :003 > class C; include A; include B; end => C 1.8.7-p358 :004 > C.new.foo => “B” 1.8.7-p358 :005 > class D; include A, B; end => D 1.8.7-p358 :006 > D.new.foo => “A” Wednesday, September 19, 12
  73. default args 13 Wednesday, September 19, 12

  74. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 Wednesday, September 19, 12
  75. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil Wednesday, September 19, 12
  76. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil Wednesday, September 19, 12
  77. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil 1.8.7-p358 :004 > bar 1 Wednesday, September 19, 12
  78. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil 1.8.7-p358 :004 > bar 1 11 => nil Wednesday, September 19, 12
  79. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil 1.8.7-p358 :004 > bar 1 11 => nil 1.8.7-p358 :005 > bar 1,2 Wednesday, September 19, 12
  80. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y;

    end => nil 1.8.7-p358 :002 > foo 1 12 => nil 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil 1.8.7-p358 :004 > bar 1 11 => nil 1.8.7-p358 :005 > bar 1,2 12 => nil Wednesday, September 19, 12
  81. caller 14 Wednesday, September 19, 12

  82. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end =>

    nil Wednesday, September 19, 12
  83. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end =>

    nil 1.8.7-p358 :002 > def bar; foo; end => nil Wednesday, September 19, 12
  84. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end =>

    nil 1.8.7-p358 :002 > def bar; foo; end => nil 1.8.7-p358 :003 > bar Wednesday, September 19, 12
  85. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end =>

    nil 1.8.7-p358 :002 > def bar; foo; end => nil 1.8.7-p358 :003 > bar (irb):5:in `bar' (irb):6:in `irb_binding' /Users/julio/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/irb/ workspace.rb:52:in `irb_binding' /Users/julio/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/irb/ workspace.rb:52 => "foo" Wednesday, September 19, 12
  86. car and cdr 15 Wednesday, September 19, 12

  87. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] Wednesday, September 19, 12
  88. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a Wednesday, September 19, 12
  89. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a => [1, 2, 3, 4, 5] Wednesday, September 19, 12
  90. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a => [1, 2, 3, 4, 5] 1.8.7-p358 :003 > car Wednesday, September 19, 12
  91. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a => [1, 2, 3, 4, 5] 1.8.7-p358 :003 > car => 1 Wednesday, September 19, 12
  92. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a => [1, 2, 3, 4, 5] 1.8.7-p358 :003 > car => 1 1.8.7-p358 :004 > cdr Wednesday, September 19, 12
  93. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > car, *cdr = a => [1, 2, 3, 4, 5] 1.8.7-p358 :003 > car => 1 1.8.7-p358 :004 > cdr => [2, 3, 4, 5] Wednesday, September 19, 12
  94. group_by 16 Wednesday, September 19, 12

  95. 1.8.7-p358 :001 > words = %w{ foo bar yo stuff

    } => ["foo", "bar", "yo", "stuff"] Wednesday, September 19, 12
  96. 1.8.7-p358 :001 > words = %w{ foo bar yo stuff

    } => ["foo", "bar", "yo", "stuff"] 1.8.7-p358 :002 > words.group_by {|x| x.size} Wednesday, September 19, 12
  97. 1.8.7-p358 :001 > words = %w{ foo bar yo stuff

    } => ["foo", "bar", "yo", "stuff"] 1.8.7-p358 :002 > words.group_by {|x| x.size} => {5=>["stuff"], 2=>["yo"], 3=>["foo", "bar"]} Wednesday, September 19, 12
  98. inject and reduce 17 Wednesday, September 19, 12

  99. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] Wednesday, September 19, 12
  100. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} Wednesday, September 19, 12
  101. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} => 5050 Wednesday, September 19, 12
  102. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} => 5050 1.8.7-p358 :003 > t = [*1..100].inject {|a,e| a + e} => 5050 Wednesday, September 19, 12
  103. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} => 5050 1.8.7-p358 :003 > t = [*1..100].inject {|a,e| a + e} => 5050 1.8.7-p358 :004 > t = [*1..100].inject(&:+) => 5050 Wednesday, September 19, 12
  104. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} => 5050 1.8.7-p358 :003 > t = [*1..100].inject {|a,e| a + e} => 5050 1.8.7-p358 :004 > t = [*1..100].inject(&:+) => 5050 1.8.7-p358 :005 > t = [*1..100].inject(:+) => 5050 Wednesday, September 19, 12
  105. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a =>

    [1, 2, 3, 4, ..., 99, 100] 1.8.7-p358 :002 > t = [*1..100].inject(0) {|a,e| a + e} => 5050 1.8.7-p358 :003 > t = [*1..100].inject {|a,e| a + e} => 5050 1.8.7-p358 :004 > t = [*1..100].inject(&:+) => 5050 1.8.7-p358 :005 > t = [*1..100].inject(:+) => 5050 1.8.7-p358 :006 > t = [*1..100].reduce(:+) => 5050 Wednesday, September 19, 12
  106. the other join 18 Wednesday, September 19, 12

  107. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3,

    4] Wednesday, September 19, 12
  108. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3,

    4] 1.8.7-p358 :002 > a *= "," Wednesday, September 19, 12
  109. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3,

    4] 1.8.7-p358 :002 > a *= "," => "1,2,3,4" Wednesday, September 19, 12
  110. add method to instance 19 Wednesday, September 19, 12

  111. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] Wednesday, September 19, 12
  112. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil Wednesday, September 19, 12
  113. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] Wednesday, September 19, 12
  114. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul Wednesday, September 19, 12
  115. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul => 120 Wednesday, September 19, 12
  116. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul => 120 1.8.7-p358 :005 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] Wednesday, September 19, 12
  117. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul => 120 1.8.7-p358 :005 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :006 > a.mul Wednesday, September 19, 12
  118. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3,

    4, 5] 1.8.7-p358 :002 > module Mult; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Mult => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul => 120 1.8.7-p358 :005 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :006 > a.mul => NoMethodError: undefined method `mul' for [1, 2, 3, 4, 5]:Array Wednesday, September 19, 12
  119. methods.grep 20 Wednesday, September 19, 12

  120. 1.8.7-p358 :001 > class C; def foo; "foo"; end; end

    => nil 1.8.7-p358 :002 > c = C.new => #<C:0x10b3e0b28> Wednesday, September 19, 12
  121. 1.8.7-p358 :001 > class C; def foo; "foo"; end; end

    => nil 1.8.7-p358 :002 > c = C.new => #<C:0x10b3e0b28> 1.8.7-p358 :003 > c.methods.grep /foo/ Wednesday, September 19, 12
  122. 1.8.7-p358 :001 > class C; def foo; "foo"; end; end

    => nil 1.8.7-p358 :002 > c = C.new => #<C:0x10b3e0b28> 1.8.7-p358 :003 > c.methods.grep /foo/ => ["foo"] Wednesday, September 19, 12
  123. class variables 21 Wednesday, September 19, 12

  124. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil Wednesday, September 19, 12
  125. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil Wednesday, September 19, 12
  126. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo Wednesday, September 19, 12
  127. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” Wednesday, September 19, 12
  128. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo Wednesday, September 19, 12
  129. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” Wednesday, September 19, 12
  130. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end Wednesday, September 19, 12
  131. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil Wednesday, September 19, 12
  132. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo Wednesday, September 19, 12
  133. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo => “B” Wednesday, September 19, 12
  134. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo => “B” 1.8.7-p358 :003 > A.foo Wednesday, September 19, 12
  135. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo => “B” 1.8.7-p358 :003 > A.foo => “B” Wednesday, September 19, 12
  136. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo => “B” 1.8.7-p358 :003 > A.foo => “B” 1.8.7-p358 :003 > C.foo Wednesday, September 19, 12
  137. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end;

    end => nil 1.8.7-p358 :002 > class C < A; nil; end => nil 1.8.7-p358 :003 > A.foo => “A” 1.8.7-p358 :003 > C.foo => “A” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end => nil 1.8.7-p358 :003 > B.foo => “B” 1.8.7-p358 :003 > A.foo => “B” 1.8.7-p358 :003 > C.foo => “B” Wednesday, September 19, 12
  138. int to hex to int 22 Wednesday, September 19, 12

  139. 1.8.7-p358 :001 > 3405691582.to_s(16) Wednesday, September 19, 12

  140. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe” Wednesday, September 19, 12

  141. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe” 1.8.7-p358 :002 > "cafebabe".to_i(16)

    Wednesday, September 19, 12
  142. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe” 1.8.7-p358 :002 > "cafebabe".to_i(16)

    => 3405691582 Wednesday, September 19, 12
  143. flip-flop 23 Wednesday, September 19, 12

  144. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3,

    4, 5, 6, .., 99, 100] Wednesday, September 19, 12
  145. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3,

    4, 5, 6, .., 99, 100] 1.8.7-p358 :002 > a.each { |x| p x if (x==17..x==42) } Wednesday, September 19, 12
  146. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3,

    4, 5, 6, .., 99, 100] 1.8.7-p358 :002 > a.each { |x| p x if (x==17..x==42) } 17 18 ... 41 42 => [1, 2, 3, 4, 5, 6, .., 99, 100] Wednesday, September 19, 12
  147. 0b 24 Wednesday, September 19, 12

  148. 1.8.7-p358 :001 > val = 0b11100100 Wednesday, September 19, 12

  149. 1.8.7-p358 :001 > val = 0b11100100 => 228 Wednesday, September

    19, 12
  150. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class Wednesday, September 19, 12
  151. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class => Fixnum Wednesday, September 19, 12
  152. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class => Fixnum 1.8.7-p358 :003 > val[4] Wednesday, September 19, 12
  153. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class => Fixnum 1.8.7-p358 :003 > val[4] => 0 Wednesday, September 19, 12
  154. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class => Fixnum 1.8.7-p358 :003 > val[4] => 0 1.8.7-p358 :004 > val[5] Wednesday, September 19, 12
  155. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002

    > val.class => Fixnum 1.8.7-p358 :003 > val[4] => 0 1.8.7-p358 :004 > val[5] => 1 Wednesday, September 19, 12
  156. ensure and return 25 Wednesday, September 19, 12

  157. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo Wednesday, September 19, 12
  158. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 Wednesday, September 19, 12
  159. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo Wednesday, September 19, 12
  160. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo => 1 Wednesday, September 19, 12
  161. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo => 1 1.8.7-p358 :005 > def foo; return 0; ensure; 1; end 1.8.7-p358 :006 > foo Wednesday, September 19, 12
  162. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo => 1 1.8.7-p358 :005 > def foo; return 0; ensure; 1; end 1.8.7-p358 :006 > foo => 0 Wednesday, September 19, 12
  163. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo => 1 1.8.7-p358 :005 > def foo; return 0; ensure; 1; end 1.8.7-p358 :006 > foo => 0 1.8.7-p358 :007 > def foo; return 0; ensure; return 1; end 1.8.7-p358 :006 > foo Wednesday, September 19, 12
  164. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358

    :002 > foo => 0 1.8.7-p358 :003 > def foo; 0; ensure; return 1; end 1.8.7-p358 :004 > foo => 1 1.8.7-p358 :005 > def foo; return 0; ensure; 1; end 1.8.7-p358 :006 > foo => 0 1.8.7-p358 :007 > def foo; return 0; ensure; return 1; end 1.8.7-p358 :006 > foo => 1 Wednesday, September 19, 12
  165. 1.8.7-p358 :001 > def foo; raise "0"; ensure; "ok"; end

    1.8.7-p358 :002 > foo Wednesday, September 19, 12
  166. 1.8.7-p358 :001 > def foo; raise "0"; ensure; "ok"; end

    1.8.7-p358 :002 > foo => RuntimeError: 0 ! from (irb):01:in `foo' ! from (irb):02 Wednesday, September 19, 12
  167. 1.8.7-p358 :001 > def foo; raise "0"; ensure; "ok"; end

    1.8.7-p358 :002 > foo => RuntimeError: 0 ! from (irb):01:in `foo' ! from (irb):02 1.8.7-p358 :003 > def foo; raise "0"; ensure; return "ok"; end 1.8.7-p358 :004 > foo Wednesday, September 19, 12
  168. 1.8.7-p358 :001 > def foo; raise "0"; ensure; "ok"; end

    1.8.7-p358 :002 > foo => RuntimeError: 0 ! from (irb):01:in `foo' ! from (irb):02 1.8.7-p358 :003 > def foo; raise "0"; ensure; return "ok"; end 1.8.7-p358 :004 > foo => “ok” Wednesday, September 19, 12
  169. benchmark 26 Wednesday, September 19, 12

  170. 1.8.7-p358 :001 > require ‘benchmark’ => true Wednesday, September 19,

    12
  171. 1.8.7-p358 :001 > require ‘benchmark’ => true 1.8.7-p358 :002 >

    n = 50000 003 > Benchmark.bm(7) do |x| 004 > x.report("for:") { for i in 1..n; a = "1"; end } 005 > x.report("times:") { n.times do ; a = "1"; end } 006 > x.report("upto:") { 1.upto(n) do ; a = "1"; end } 007 > end Wednesday, September 19, 12
  172. 1.8.7-p358 :001 > require ‘benchmark’ => true 1.8.7-p358 :002 >

    n = 50000 003 > Benchmark.bm(7) do |x| 004 > x.report("for:") { for i in 1..n; a = "1"; end } 005 > x.report("times:") { n.times do ; a = "1"; end } 006 > x.report("upto:") { 1.upto(n) do ; a = "1"; end } 007 > end user system total real for: 0.020000 0.000000 0.020000 ( 0.017378) times: 0.010000 0.000000 0.010000 ( 0.013688) upto: 0.020000 0.000000 0.020000 ( 0.014495) => true Wednesday, September 19, 12
  173. classes are objects 27 Wednesday, September 19, 12

  174. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    Wednesday, September 19, 12
  175. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo Wednesday, September 19, 12
  176. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo 1.8.7-p358 :003 > raise ExceptionOne Wednesday, September 19, 12
  177. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo 1.8.7-p358 :003 > raise ExceptionOne ExceptionOne: ExceptionOne ! from (irb):3 Wednesday, September 19, 12
  178. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo 1.8.7-p358 :003 > raise ExceptionOne ExceptionOne: ExceptionOne ! from (irb):3 1.8.7-p358 :004 > raise ExceptionTwo Wednesday, September 19, 12
  179. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil

    1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo 1.8.7-p358 :003 > raise ExceptionOne ExceptionOne: ExceptionOne ! from (irb):3 1.8.7-p358 :004 > raise ExceptionTwo ExceptionTwo: ExceptionTwo ! from (irb):4 Wednesday, September 19, 12
  180. [].sample 28 Wednesday, September 19, 12

  181. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] =>

    [1,2,3,4,5] >> a.sample Wednesday, September 19, 12
  182. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] =>

    [1,2,3,4,5] >> a.sample => 3 Wednesday, September 19, 12
  183. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] =>

    [1,2,3,4,5] >> a.sample => 3 >> a.sample => 4 Wednesday, September 19, 12
  184. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] =>

    [1,2,3,4,5] >> a.sample => 3 >> a.sample => 4 >> a.sample(2) Wednesday, September 19, 12
  185. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] =>

    [1,2,3,4,5] >> a.sample => 3 >> a.sample => 4 >> a.sample(2) => [4, 2] Wednesday, September 19, 12
  186. rails things Wednesday, September 19, 12

  187. helper 29 Wednesday, September 19, 12

  188. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) Wednesday, September 19,

    12
  189. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00" Wednesday,

    September 19, 12
  190. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00" >>

    helper.number_to_human_size(1000000000000000) Wednesday, September 19, 12
  191. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00" >>

    helper.number_to_human_size(1000000000000000) => “909.5 TB” Wednesday, September 19, 12
  192. group...count 30 Wednesday, September 19, 12

  193. Loading development environment (Rails 3.0.7) jruby-1.5.6 :001 > DataSource.group(:beta).count Wednesday,

    September 19, 12
  194. Loading development environment (Rails 3.0.7) jruby-1.5.6 :001 > DataSource.group(:beta).count =>

    #<OrderedHash {false=>4951, true=>233}> Wednesday, September 19, 12
  195. command line things Wednesday, September 19, 12

  196. sandbox 31 Wednesday, September 19, 12

  197. $ script/console --sandbox Wednesday, September 19, 12

  198. $ script/console --sandbox Loading development environment in sandbox (Rails 2.3.10)

    Any modifications you make will be rolled back on exit NOTE: Gem.source_index is deprecated, use Specification... Wednesday, September 19, 12
  199. rake stats 32 Wednesday, September 19, 12

  200. $ rake stats Wednesday, September 19, 12

  201. $ rake stats +----------------------+-------+-------+---------+---------+-----+-------+ | Name | Lines | LOC

    | Classes | Methods | M/C | LOC/M | +----------------------+-------+-------+---------+---------+-----+-------+ | Controllers | 4941 | 4077 | 67 | 399 | 5 | 8 | | Helpers | 970 | 787 | 0 | 103 | 0 | 5 | | Models | 9779 | 7878 | 163 | 989 | 6 | 5 | | Libraries | 5932 | 4496 | 108 | 447 | 4 | 8 | | Integration tests | 1731 | 552 | 18 | 8 | 0 | 67 | | Functional tests | 9767 | 8248 | 52 | 90 | 1 | 89 | | Unit tests | 16470 | 13678 | 181 | 97 | 0 | 139 | +----------------------+-------+-------+---------+---------+-----+-------+ | Total | 49590 | 39716 | 589 | 2133 | 3 | 16 | +----------------------+-------+-------+---------+---------+-----+-------+ Code LOC: 17238 Test LOC: 22478 Code to Test Ratio: 1:1.3 Wednesday, September 19, 12
  202. rake notes 33 Wednesday, September 19, 12

  203. $ rake notes Wednesday, September 19, 12

  204. $ rake notes app/controllers/company_importers_controller.rb: * [241] [TODO] refactor to raise

    ActiveRecord::RecordNotFound instead of nil. app/controllers/open_id_controller.rb: * [ 44] [TODO] refactor the below. app/controllers/open_social_controller.rb: * [134] [TODO] Remove this code after enough data was collected (trobrock) app/helpers/reports_helper.rb: * [ 12] [TODO] The core utility of these helpers could be moved into the BaseReport class and then we can get the date ranges from the controller. app/models/axe/outright/aggregation/aggregation_director.rb: * [ 33] [TODO] remove this if possible - it's here b/c you get the 'expected * [131] [TODO] why is reload necessary? ... Wednesday, September 19, 12
  205. rake routes 34 Wednesday, September 19, 12

  206. $ rake routes Wednesday, September 19, 12

  207. $ rake routes => QueryTrace disabled; CTRL-\ to toggle **

    Erubis 2.6.6 emails GET /emails(.:format) {:controller=>"emails", :action=>"index"} POST /emails(.:format) {:controller=>"emails", :action=>"create"} new_email GET /emails/new(.:format) {:controller=>"emails", :action=>"new"} edit_email GET /emails/:id/edit(.:format) {:controller=>"emails", :action=>"edit"} email GET /emails/:id(.:format) {:controller=>"emails", :action=>"show"} PUT /emails/:id(.:format) {:controller=>"emails", :action=>"update"} DELETE /emails/:id(.:format) {:controller=>"emails", :action=>"destroy"} root / {:controller=>"dashboard", :action=>"root"} dashboard /dashboard {:controller=>"dashboard", :action=>"index"} self_identify /self_identify {:controller=>"dashboard", :action=>"self_identify"} undo_self_identify /undo_self_identify {:controller=>"dashboard", :action=>"undo_self_identify"} request_merchant /request_merchant {:controller=>"dashboard", :action=>"request_merchant"} welcome /welcome {:controller=>"dashboard", :action=>"welcome"} /companies/profit {:controller=>"companies", :action=>"profit"} address_import_invitations GET /invitations/address_import(.:format) {:controller=>"invitations", :action=>"address_import"} bookkeeper_client_invitations GET /invitations/bookkeeper_client(.:format) {:controller=>"invitations", :action=>"bookkeeper_client"} invitations GET /invitations(.:format) {:controller=>"invitations", :action=>"index"} POST /invitations(.:format) {:controller=>"invitations", :action=>"create"} new_invitation GET /invitations/new(.:format) {:controller=>"invitations", :action=>"new"} edit_invitation GET /invitations/:id/edit(.:format) {:controller=>"invitations", :action=>"edit"} invitation GET /invitations/:id(.:format) {:controller=>"invitations", :action=>"show"} PUT /invitations/:id(.:format) {:controller=>"invitations", :action=>"update"} DELETE /invitations/:id(.:format) {:controller=>"invitations", :action=>"destroy"} new_feedback GET /feedback/new(.:format) {:controller=>"feedback", :action=>"new"} edit_feedback GET /feedback/edit(.:format) {:controller=>"feedback", :action=>"edit"} feedback GET /feedback(.:format) {:controller=>"feedback", :action=>"show"} PUT /feedback(.:format) {:controller=>"feedback", :action=>"update"} DELETE /feedback(.:format) {:controller=>"feedback", :action=>"destroy"} POST /feedback(.:format) {:controller=>"feedback", :action=>"create"} visible_accounts GET /visible_accounts(.:format) {:controller=>"visible_accounts", :action=>"index"} /tax_calendar {:controller=>"redirect", :action=>"to_outright"} ... Wednesday, September 19, 12
  208. syntax check 35 Wednesday, September 19, 12

  209. $ ruby -c app/models/email_campaign.rb Wednesday, September 19, 12

  210. $ ruby -c app/models/email_campaign.rb Syntax OK Wednesday, September 19, 12

  211. $ ruby -c app/models/email_campaign.rb Syntax OK $ ruby -c app/models/axe/outright/filter_chain.rb

    Wednesday, September 19, 12
  212. $ ruby -c app/models/email_campaign.rb Syntax OK $ ruby -c app/models/axe/outright/filter_chain.rb

    app/models/axe/outright/filter_chain.rb:36: syntax error, unexpected $end, expecting kEND Wednesday, September 19, 12
  213. .irbrc 36 Wednesday, September 19, 12

  214. $ vim ~/.irbrc Wednesday, September 19, 12

  215. $ vim ~/.irbrc require "rubygems" require "wirble" Wirble.init Wirble.colorize colors

    = Wirble::Colorize.colors.merge({ :comma => :green, :refers => :green, }) Wirble::Colorize.colors = colors class Object def own_methods (self.methods - Object.new.methods).sort end end Wednesday, September 19, 12
  216. gem server 36 Wednesday, September 19, 12

  217. $ gem server Wednesday, September 19, 12

  218. $ gem server $ Server started at http://0.0.0.0:8808 Server started

    at http://[::]:8808 Wednesday, September 19, 12
  219. $ gem server $ Server started at http://0.0.0.0:8808 Server started

    at http://[::]:8808 Wednesday, September 19, 12
  220. github.com/julio Wednesday, September 19, 12