SlideShare uma empresa Scribd logo
1 de 210
ruby
off the beaten path
     github.com/julio
ruby things
01




string concatenation
1.8.7-p358 :001 > s = “this” “is” “a” “thing”
1.8.7-p358 :001 > s = “this” “is” “a” “thing”
 => “thisisathing”
1.8.7-p358 :002 >
02




print json
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
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 :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
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 >
03




interpolation
1.8.7-p358 :001 > @name = "bob"
 => “bob”
1.8.7-p358 :002 > puts "hello #@name"
1.8.7-p358 :001 > @name = "bob"
 => “bob”
1.8.7-p358 :002 > puts "hello #@name"
 “hello bob”
 => nil
04




.. and ...
1.8.7-p358 :001 > a = (1..2)
=> 1..2
1.8.7-p358 :001 > a = (1..2)
 => 1..2
1.8.7-p358 :002 > a.to_a
1.8.7-p358 :001 > a = (1..2)
 => 1..2
1.8.7-p358 :002 > a.to_a
 => [1, 2]
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.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 :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.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]
05




string contains?
1.8.7-p358 :001 > s = "this is a string"
 => “this is a string”
1.8.7-p358 :002 > s[“is a”]
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 :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"]
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
06




expand array
1.8.7-p358 :001 > [*10..20]
1.8.7-p358 :001 > [*10..20]
=> [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
07




hash from array
1.8.7-p358 :001 > Hash[1,2,3,4]
1.8.7-p358 :001 > Hash[1,2,3,4]
=> {1=>2, 3=>4}
1.8.7-p358 :001 > Hash[1,2,3,4]
 => {1=>2, 3=>4}
1.8.7-p358 :002 > Hash[["one", 1], ["two", 2]]
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 :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]
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 :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]
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.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 :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.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}
08




zip
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)
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 :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]
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}
09




shuffle
1.8.7-p358 :001 > a = [1,2,3]
 => [1, 2, 3]
1.8.7-p358 :002 > a.shuffle
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 :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
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]
10




cons
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.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
11




set
1.8.7-p358 :001 > require 'set'
 => true
1.8.7-p358 :002 > s = Set.new
 => #<Set: {}>
1.8.7-p358 :003 > s << 1
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 :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
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 :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
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}>
12




include A, B, C
1.8.7-p358 :001 > module A; def foo; "A"; end; end
=> nil
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 :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 :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
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 :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
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 :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
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”
13




default args
1.8.7-p358 :001 > def foo(x, y=2); print x; print y; end
 => nil
1.8.7-p358 :002 > foo 1
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 :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 :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
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 :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
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
14




caller
1.8.7-p358 :001 > def foo; puts caller; "foo"; end
=> nil
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 :001 > def foo; puts caller; "foo"; end
 => nil
1.8.7-p358 :002 > def bar; foo; end
 => nil
1.8.7-p358 :003 > bar
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"
15




car and cdr
1.8.7-p358 :001 > a = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
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.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 :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.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 :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
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]
16




group_by
1.8.7-p358 :001 > words = %w{ foo bar yo stuff }
 => ["foo", "bar", "yo", "stuff"]
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}
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"]}
17




inject and reduce
1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a
=> [1, 2, 3, 4, ..., 99, 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}
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 :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 :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 :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 :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
18




the other join
1.8.7-p358 :001 > a = [1,2,3,4]
=> [1, 2, 3, 4]
1.8.7-p358 :001 > a = [1,2,3,4]
 => [1, 2, 3, 4]
1.8.7-p358 :002 > a *= ","
1.8.7-p358 :001 > a = [1,2,3,4]
 => [1, 2, 3, 4]
1.8.7-p358 :002 > a *= ","
 => "1,2,3,4"
19




add method to instance
1.8.7-p358 :001 > a = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [1, 2, 3, 4, 5]
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [1, 2, 3, 4, 5]
1.8.7-p358 :004 > a.mul
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [1, 2, 3, 4, 5]
1.8.7-p358 :004 > a.mul
 => 120
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [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 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [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
1.8.7-p358 :001 > a = [1,2,3,4,5]
 => [1, 2, 3, 4, 5]
1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end
 => nil
1.8.7-p358 :003 > a.extend Summable
 => [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
20




methods.grep
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 :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/
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"]
21




class variables
1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end; end
=> nil
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 :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
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 :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
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 :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
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 :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
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 :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
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 :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
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”
22




int to hex to int
1.8.7-p358 :001 > 3405691582.to_s(16)
1.8.7-p358 :001 > 3405691582.to_s(16)
=> “cafebabe”
1.8.7-p358 :001 > 3405691582.to_s(16)
 => “cafebabe”
1.8.7-p358 :002 > "cafebabe".to_i(16)
1.8.7-p358 :001 > 3405691582.to_s(16)
 => “cafebabe”
1.8.7-p358 :002 > "cafebabe".to_i(16)
 => 3405691582
23




flip-flop
1.8.7-p358 :001 > a = [*1..100]
=> [1, 2, 3, 4, 5, 6, .., 99, 100]
1.8.7-p358 :001 > a = [*1..100]
 => [1, 2, 3, 4, 5, 6, .., 99, 100]
1.8.7-p358 :002 > a.each_with_index {|x,i| p x if (i==20..i==34)}
1.8.7-p358 :001 > a = [*1..100]
 => [1, 2, 3, 4, 5, 6, .., 99, 100]
1.8.7-p358 :002 > a.each_with_index {|x,i| p x if (i==20..i==34)}
21
22
...
34
35
=> [1, 2, 3, 4, 5, 6, .., 99, 100]
24




0b
1.8.7-p358 :001 > val = 0b11100100
1.8.7-p358 :001 > val = 0b11100100
=> 228
1.8.7-p358 :001 > val = 0b11100100
 => 228
1.8.7-p358 :002 > val.class
1.8.7-p358 :001 > val = 0b11100100
 => 228
1.8.7-p358 :002 > val.class
 => Fixnum
1.8.7-p358 :001 > val = 0b11100100
 => 228
1.8.7-p358 :002 > val.class
 => Fixnum
1.8.7-p358 :003 > val[4]
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 :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.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
25




ensure and return
1.8.7-p358 :001 > def foo; 0; ensure; 1; end
1.8.7-p358 :002 > foo
1.8.7-p358 :001 > def foo; 0; ensure; 1; end
1.8.7-p358 :002 > foo
 => 0
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.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 :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
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 :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.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
26




benchmark
1.8.7-p358 :001 > require ‘benchmark’
=> true
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
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
27




classes are objects
1.8.7-p358 :001 > class ExceptionOne < Exception; end
=> nil
1.8.7-p358 :001 > class ExceptionOne < Exception; end
 => nil
1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception)
 => ExceptionTwo
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
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 :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
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
28




[].sample
Loading development environment (Rails 2.3.10)
>>   a = [1,2,3,4,5]
=> [1,2,3,4,5]
>>   a.sample
Loading development environment (Rails 2.3.10)
>>   a = [1,2,3,4,5]
=> [1,2,3,4,5]
>>   a.sample
=> 3
Loading development environment (Rails 2.3.10)
>>   a = [1,2,3,4,5]
=> [1,2,3,4,5]
>>   a.sample
=> 3
>>   a.sample
=> 4
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)
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]
rails things
29




helper
Loading development environment (Rails 2.3.10)
>>   helper.number_to_currency(100)
Loading development environment (Rails 2.3.10)
>>   helper.number_to_currency(100)
=> "$100.00"
Loading development environment (Rails 2.3.10)
>>   helper.number_to_currency(100)
=> "$100.00"
>>   helper.number_to_human_size(1000000000000000)
Loading development environment (Rails 2.3.10)
>>   helper.number_to_currency(100)
=> "$100.00"
>>   helper.number_to_human_size(1000000000000000)
=> “909.5 TB”
30




group...count
Loading development environment (Rails 3.0.7)
jruby-1.5.6 :001 > DataSource.group(:beta).count
Loading development environment (Rails 3.0.7)
jruby-1.5.6 :001 > DataSource.group(:beta).count
 => #<OrderedHash {false=>4951, true=>233}>
command line
31




sandbox
$   script/console --sandbox
$   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...
32




rake stats
$   rake stats
$    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
33




rake notes
$   rake notes
$    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?
...
34




rake routes
$   rake routes
$         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"}
...
35




syntax check
$   ruby -c app/models/email_campaign.rb
$   ruby -c app/models/email_campaign.rb
Syntax OK
$   ruby -c app/models/email_campaign.rb
Syntax OK

$   ruby -c app/models/axe/outright/filter_chain.rb
$   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
36




.irbrc
$   vim ~/.irbrc
$   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

Mais conteúdo relacionado

Mais procurados

Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With ElixirGabriele Lana
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxMichelangelo van Dam
 
Why there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportWhy there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportCarl-Ivar Ahlqvist
 
Isis Cybera Summit 2009
Isis Cybera Summit 2009Isis Cybera Summit 2009
Isis Cybera Summit 2009Cybera Inc.
 
Lesson 7 world_history_medieval_period_new_
Lesson 7 world_history_medieval_period_new_Lesson 7 world_history_medieval_period_new_
Lesson 7 world_history_medieval_period_new_Anna Romana
 
PHP webboard
PHP webboardPHP webboard
PHP webboardtumetr1
 
เฉลยข้อสอบเมทริกซ์ ตอนที่ 2
เฉลยข้อสอบเมทริกซ์  ตอนที่ 2เฉลยข้อสอบเมทริกซ์  ตอนที่ 2
เฉลยข้อสอบเมทริกซ์ ตอนที่ 2K'Keng Hale's
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
 
PHP cart
PHP cartPHP cart
PHP carttumetr1
 
Global Change, Species Diversity, and the Future of Marine Ecosystems
Global Change, Species Diversity, and the Future of Marine EcosystemsGlobal Change, Species Diversity, and the Future of Marine Ecosystems
Global Change, Species Diversity, and the Future of Marine EcosystemsJarrett Byrnes
 
The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196Mahmoud Samir Fayed
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出すTakashi Kitano
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6umapst
 
The Ring programming language version 1.5.2 book - Part 43 of 181
The Ring programming language version 1.5.2 book - Part 43 of 181The Ring programming language version 1.5.2 book - Part 43 of 181
The Ring programming language version 1.5.2 book - Part 43 of 181Mahmoud Samir Fayed
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL codeSimon Hoyle
 

Mais procurados (20)

Parse Everything With Elixir
Parse Everything With ElixirParse Everything With Elixir
Parse Everything With Elixir
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Why there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transportWhy there is 15% unnecesary co2 emissions in road transport
Why there is 15% unnecesary co2 emissions in road transport
 
Isis Cybera Summit 2009
Isis Cybera Summit 2009Isis Cybera Summit 2009
Isis Cybera Summit 2009
 
Ecuacionesfuncionales1 1
Ecuacionesfuncionales1 1Ecuacionesfuncionales1 1
Ecuacionesfuncionales1 1
 
Lesson 7 world_history_medieval_period_new_
Lesson 7 world_history_medieval_period_new_Lesson 7 world_history_medieval_period_new_
Lesson 7 world_history_medieval_period_new_
 
Ecuacionesfuncionales2 1
Ecuacionesfuncionales2 1Ecuacionesfuncionales2 1
Ecuacionesfuncionales2 1
 
PHP webboard
PHP webboardPHP webboard
PHP webboard
 
เฉลยข้อสอบเมทริกซ์ ตอนที่ 2
เฉลยข้อสอบเมทริกซ์  ตอนที่ 2เฉลยข้อสอบเมทริกซ์  ตอนที่ 2
เฉลยข้อสอบเมทริกซ์ ตอนที่ 2
 
Thailand ICT Market Survey 2008
Thailand ICT Market Survey 2008Thailand ICT Market Survey 2008
Thailand ICT Market Survey 2008
 
The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189The Ring programming language version 1.6 book - Part 46 of 189
The Ring programming language version 1.6 book - Part 46 of 189
 
PHP cart
PHP cartPHP cart
PHP cart
 
Mat fin
Mat finMat fin
Mat fin
 
Global Change, Species Diversity, and the Future of Marine Ecosystems
Global Change, Species Diversity, and the Future of Marine EcosystemsGlobal Change, Species Diversity, and the Future of Marine Ecosystems
Global Change, Species Diversity, and the Future of Marine Ecosystems
 
Elixir
ElixirElixir
Elixir
 
The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196The Ring programming language version 1.7 book - Part 33 of 196
The Ring programming language version 1.7 book - Part 33 of 196
 
令和から本気出す
令和から本気出す令和から本気出す
令和から本気出す
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6
 
The Ring programming language version 1.5.2 book - Part 43 of 181
The Ring programming language version 1.5.2 book - Part 43 of 181The Ring programming language version 1.5.2 book - Part 43 of 181
The Ring programming language version 1.5.2 book - Part 43 of 181
 
Seistech SQL code
Seistech SQL codeSeistech SQL code
Seistech SQL code
 

Destaque

Restricted Boltzman Machine (RBM) presentation of fundamental theory
Restricted Boltzman Machine (RBM) presentation of fundamental theoryRestricted Boltzman Machine (RBM) presentation of fundamental theory
Restricted Boltzman Machine (RBM) presentation of fundamental theorySeongwon Hwang
 
05 history of cv a machine learning (theory) perspective on computer vision
05  history of cv a machine learning (theory) perspective on computer vision05  history of cv a machine learning (theory) perspective on computer vision
05 history of cv a machine learning (theory) perspective on computer visionzukun
 
CAD & Analysis Introduction
CAD & Analysis IntroductionCAD & Analysis Introduction
CAD & Analysis IntroductionKeith Vaugh
 
Extreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsExtreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsJames Chou
 
Wind Energy Lecture slides
Wind Energy Lecture slidesWind Energy Lecture slides
Wind Energy Lecture slidesKeith Vaugh
 
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC Systems
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC SystemsStep 4 - Properly Sized, Designed, Installed, and Commissioned HVAC Systems
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC SystemsSynergy Airflow and Ventilation
 
21 hvac design manual
21 hvac design manual21 hvac design manual
21 hvac design manualbhattbhai
 
Thermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsThermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsMuhammad Surahman
 
Thermodynamic Chapter 3 First Law Of Thermodynamics
Thermodynamic Chapter 3 First Law Of ThermodynamicsThermodynamic Chapter 3 First Law Of Thermodynamics
Thermodynamic Chapter 3 First Law Of ThermodynamicsMuhammad Surahman
 
Refrigration & air conditioning
Refrigration & air conditioningRefrigration & air conditioning
Refrigration & air conditioningSiddharth Bedarker
 
Hvac presentation for beginers
Hvac presentation for beginersHvac presentation for beginers
Hvac presentation for beginersguestf11b52
 
Hvac Presentation
Hvac PresentationHvac Presentation
Hvac PresentationChoong KW
 

Destaque (13)

Restricted Boltzman Machine (RBM) presentation of fundamental theory
Restricted Boltzman Machine (RBM) presentation of fundamental theoryRestricted Boltzman Machine (RBM) presentation of fundamental theory
Restricted Boltzman Machine (RBM) presentation of fundamental theory
 
05 history of cv a machine learning (theory) perspective on computer vision
05  history of cv a machine learning (theory) perspective on computer vision05  history of cv a machine learning (theory) perspective on computer vision
05 history of cv a machine learning (theory) perspective on computer vision
 
CAD & Analysis Introduction
CAD & Analysis IntroductionCAD & Analysis Introduction
CAD & Analysis Introduction
 
Extreme learning machine:Theory and applications
Extreme learning machine:Theory and applicationsExtreme learning machine:Theory and applications
Extreme learning machine:Theory and applications
 
Wind Energy Lecture slides
Wind Energy Lecture slidesWind Energy Lecture slides
Wind Energy Lecture slides
 
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC Systems
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC SystemsStep 4 - Properly Sized, Designed, Installed, and Commissioned HVAC Systems
Step 4 - Properly Sized, Designed, Installed, and Commissioned HVAC Systems
 
SSL12 Entropy
SSL12 EntropySSL12 Entropy
SSL12 Entropy
 
21 hvac design manual
21 hvac design manual21 hvac design manual
21 hvac design manual
 
Thermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of ThermodynamicsThermodynamic Chapter 4 Second Law Of Thermodynamics
Thermodynamic Chapter 4 Second Law Of Thermodynamics
 
Thermodynamic Chapter 3 First Law Of Thermodynamics
Thermodynamic Chapter 3 First Law Of ThermodynamicsThermodynamic Chapter 3 First Law Of Thermodynamics
Thermodynamic Chapter 3 First Law Of Thermodynamics
 
Refrigration & air conditioning
Refrigration & air conditioningRefrigration & air conditioning
Refrigration & air conditioning
 
Hvac presentation for beginers
Hvac presentation for beginersHvac presentation for beginers
Hvac presentation for beginers
 
Hvac Presentation
Hvac PresentationHvac Presentation
Hvac Presentation
 

Semelhante a Ruby things

Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...
Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...
Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...Javier García Molleja
 
Edital do concurso da prefeitura de forquilha ce
Edital do concurso da prefeitura de forquilha ceEdital do concurso da prefeitura de forquilha ce
Edital do concurso da prefeitura de forquilha ceJosé Ripardo
 
Writing DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfWriting DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfJason Garber
 
Energias renovables en Venezuela (resultado de encuesta)
Energias renovables en Venezuela (resultado de encuesta)Energias renovables en Venezuela (resultado de encuesta)
Energias renovables en Venezuela (resultado de encuesta)Nelson Hernandez
 
[Waterworks] City Presentation - Rosenheim(Germany)
[Waterworks] City Presentation - Rosenheim(Germany)[Waterworks] City Presentation - Rosenheim(Germany)
[Waterworks] City Presentation - Rosenheim(Germany)shrdcinfo
 
2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley
2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley
2.ley 28708 general_del_sistema_nacional_de_contabilidad_leyEduardo EB
 
เฉลยMetrix1
เฉลยMetrix1เฉลยMetrix1
เฉลยMetrix1Noir Black
 
Cartilha elaboracao pgrss_versao_para_intranet (1)
Cartilha  elaboracao pgrss_versao_para_intranet (1)Cartilha  elaboracao pgrss_versao_para_intranet (1)
Cartilha elaboracao pgrss_versao_para_intranet (1)Carol Ribeiro
 
علم الحاسوب للصف الخامس الاعدادي
علم الحاسوب للصف الخامس الاعداديعلم الحاسوب للصف الخامس الاعدادي
علم الحاسوب للصف الخامس الاعداديAyad Haris Beden
 
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)Dimitris Psounis
 
Analisi Social Media H2 Liquida
Analisi Social Media H2 LiquidaAnalisi Social Media H2 Liquida
Analisi Social Media H2 LiquidaLiquida
 
Schoolyard compass game
Schoolyard compass gameSchoolyard compass game
Schoolyard compass gameLukas Stritt
 

Semelhante a Ruby things (20)

Ph 3
Ph 3Ph 3
Ph 3
 
Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...
Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...
Unveiling the structure, chemistry, and formation mechanism of an in-situ pho...
 
Edital do concurso da prefeitura de forquilha ce
Edital do concurso da prefeitura de forquilha ceEdital do concurso da prefeitura de forquilha ce
Edital do concurso da prefeitura de forquilha ce
 
Ph 38
Ph 38Ph 38
Ph 38
 
Ph 37
Ph 37Ph 37
Ph 37
 
Writing DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby ConfWriting DSLs with Parslet - Wicked Good Ruby Conf
Writing DSLs with Parslet - Wicked Good Ruby Conf
 
Energias renovables en Venezuela (resultado de encuesta)
Energias renovables en Venezuela (resultado de encuesta)Energias renovables en Venezuela (resultado de encuesta)
Energias renovables en Venezuela (resultado de encuesta)
 
Ph 35
Ph 35Ph 35
Ph 35
 
[Waterworks] City Presentation - Rosenheim(Germany)
[Waterworks] City Presentation - Rosenheim(Germany)[Waterworks] City Presentation - Rosenheim(Germany)
[Waterworks] City Presentation - Rosenheim(Germany)
 
2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley
2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley
2.ley 28708 general_del_sistema_nacional_de_contabilidad_ley
 
เฉลยMetrix1
เฉลยMetrix1เฉลยMetrix1
เฉลยMetrix1
 
Slownik
SlownikSlownik
Slownik
 
Cartilha elaboracao pgrss_versao_para_intranet (1)
Cartilha  elaboracao pgrss_versao_para_intranet (1)Cartilha  elaboracao pgrss_versao_para_intranet (1)
Cartilha elaboracao pgrss_versao_para_intranet (1)
 
علم الحاسوب للصف الخامس الاعدادي
علم الحاسوب للصف الخامس الاعداديعلم الحاسوب للصف الخامس الاعدادي
علم الحاسوب للصف الخامس الاعدادي
 
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)
ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 4 - ΤΕΛΕΣΤΕΣ και η ΔΟΜΗ ΕΛΕΓΧΟΥ (ΕΚΤΥΠΩΣΗ)
 
255blia
255blia255blia
255blia
 
Analisi Social Media H2 Liquida
Analisi Social Media H2 LiquidaAnalisi Social Media H2 Liquida
Analisi Social Media H2 Liquida
 
Google Earth Getting Started
Google Earth Getting StartedGoogle Earth Getting Started
Google Earth Getting Started
 
Redesign presentation
Redesign presentationRedesign presentation
Redesign presentation
 
Schoolyard compass game
Schoolyard compass gameSchoolyard compass game
Schoolyard compass game
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Ruby things

  • 1. ruby off the beaten path github.com/julio
  • 4. 1.8.7-p358 :001 > s = “this” “is” “a” “thing”
  • 5. 1.8.7-p358 :001 > s = “this” “is” “a” “thing” => “thisisathing” 1.8.7-p358 :002 >
  • 7. 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
  • 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 {"one":1,"two":2}
  • 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} 1.8.7-p358 :005 > jj h
  • 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 { "one": 1, "two": 2 } 1.8.7-p358 :006 >
  • 12. 1.8.7-p358 :001 > @name = "bob" => “bob” 1.8.7-p358 :002 > puts "hello #@name"
  • 13. 1.8.7-p358 :001 > @name = "bob" => “bob” 1.8.7-p358 :002 > puts "hello #@name" “hello bob” => nil
  • 15. 1.8.7-p358 :001 > a = (1..2) => 1..2
  • 16. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002 > a.to_a
  • 17. 1.8.7-p358 :001 > a = (1..2) => 1..2 1.8.7-p358 :002 > a.to_a => [1, 2]
  • 18. 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)
  • 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) => 1...2
  • 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 1.8.7-p358 :004 > b.to_a
  • 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 => [1]
  • 23. 1.8.7-p358 :001 > s = "this is a string" => “this is a string” 1.8.7-p358 :002 > s[“is a”]
  • 24. 1.8.7-p358 :001 > s = "this is a string" => “this is a string” 1.8.7-p358 :002 > s[“is a”] => “is a”
  • 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” 1.8.7-p358 :003 > s["is not a"]
  • 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"] => nil
  • 28. 1.8.7-p358 :001 > [*10..20]
  • 29. 1.8.7-p358 :001 > [*10..20] => [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
  • 31. 1.8.7-p358 :001 > Hash[1,2,3,4]
  • 32. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4}
  • 33. 1.8.7-p358 :001 > Hash[1,2,3,4] => {1=>2, 3=>4} 1.8.7-p358 :002 > Hash[["one", 1], ["two", 2]]
  • 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]] => {["one", 1]=>["two", 2]}
  • 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]} 1.8.7-p358 :003 > a=["one", 1], ["two", 2]
  • 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] => [["one", 1], ["two", 2]]
  • 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]] 1.8.7-p358 :004 > Hash[a]
  • 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] => {"two"=>2, "one"=>1} 1.8.7-p358 :005 > b = [1,2,3,4]
  • 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] => [1,2,3,4]
  • 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] 1.8.7-p358 :006 > Hash[*b]
  • 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] => {1=>2, 3=>4}
  • 43. 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)
  • 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) => [[:one, 1], [:two, 2], [:three, 3]]
  • 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]] 1.8.7-p358 :004 > Hash[zip]
  • 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] => {:two=>2, :three=>3, :one=>1}
  • 48. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3] 1.8.7-p358 :002 > a.shuffle
  • 49. 1.8.7-p358 :001 > a = [1,2,3] => [1, 2, 3] 1.8.7-p358 :002 > a.shuffle => [1, 3, 2]
  • 50. 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
  • 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 => [3, 2, 1]
  • 53. 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}
  • 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} [1, 2] [2, 3] [3, 4] [4, 5] => nil
  • 56. 1.8.7-p358 :001 > require 'set' => true 1.8.7-p358 :002 > s = Set.new => #<Set: {}> 1.8.7-p358 :003 > s << 1
  • 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 => #<Set: {1}>
  • 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}> 1.8.7-p358 :004 > s << 1
  • 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 => #<Set: {1}>
  • 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}> 1.8.7-p358 :005 > s << 2
  • 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 => #<Set: {1, 2}>
  • 63. 1.8.7-p358 :001 > module A; def foo; "A"; end; end => nil
  • 64. 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
  • 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 1.8.7-p358 :003 > class C; include A; include B; end => C
  • 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 1.8.7-p358 :004 > C.new.foo
  • 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 => “B”
  • 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” 1.8.7-p358 :005 > class D; include A, B; end
  • 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 => D
  • 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 1.8.7-p358 :006 > D.new.foo
  • 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 => “A”
  • 73. 1.8.7-p358 :001 > def foo(x, y=2); print x; print y; end => nil 1.8.7-p358 :002 > foo 1
  • 74. 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
  • 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 1.8.7-p358 :003 > def bar(x, y=x); print x; print y; end => nil
  • 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 1.8.7-p358 :004 > bar 1
  • 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 11 => nil
  • 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 1.8.7-p358 :005 > bar 1,2
  • 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 12 => nil
  • 81. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end => nil
  • 82. 1.8.7-p358 :001 > def foo; puts caller; "foo"; end => nil 1.8.7-p358 :002 > def bar; foo; end => nil
  • 83. 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
  • 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 (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"
  • 86. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5]
  • 87. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > car, *cdr = a
  • 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 => [1, 2, 3, 4, 5]
  • 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] 1.8.7-p358 :003 > car
  • 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 => 1
  • 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 1.8.7-p358 :004 > cdr
  • 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 => [2, 3, 4, 5]
  • 94. 1.8.7-p358 :001 > words = %w{ foo bar yo stuff } => ["foo", "bar", "yo", "stuff"]
  • 95. 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}
  • 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} => {5=>["stuff"], 2=>["yo"], 3=>["foo", "bar"]}
  • 98. 1.8.7-p358 :001 > a = [*1..100] # or (1..100).to_a => [1, 2, 3, 4, ..., 99, 100]
  • 99. 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}
  • 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} => 5050
  • 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 1.8.7-p358 :003 > t = [*1..100].inject {|a,e| a += e} => 5050
  • 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 1.8.7-p358 :004 > t = [*1..100].inject(&:+) => 5050
  • 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 1.8.7-p358 :005 > t = [*1..100].inject(:+) => 5050
  • 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 1.8.7-p358 :006 > t = [*1..100].reduce(:+) => 5050
  • 106. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3, 4]
  • 107. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3, 4] 1.8.7-p358 :002 > a *= ","
  • 108. 1.8.7-p358 :001 > a = [1,2,3,4] => [1, 2, 3, 4] 1.8.7-p358 :002 > a *= "," => "1,2,3,4"
  • 109. 19 add method to instance
  • 110. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5]
  • 111. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil
  • 112. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [1, 2, 3, 4, 5]
  • 113. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul
  • 114. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [1, 2, 3, 4, 5] 1.8.7-p358 :004 > a.mul => 120
  • 115. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [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]
  • 116. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [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
  • 117. 1.8.7-p358 :001 > a = [1,2,3,4,5] => [1, 2, 3, 4, 5] 1.8.7-p358 :002 > module Summable; def mul; self.reduce(:*); end;end => nil 1.8.7-p358 :003 > a.extend Summable => [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
  • 119. 1.8.7-p358 :001 > class C; def foo; "foo"; end; end => nil 1.8.7-p358 :002 > c = C.new => #<C:0x10b3e0b28>
  • 120. 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/
  • 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/ => ["foo"]
  • 123. 1.8.7-p358 :001 > class A; @@foo="A"; def self.foo; @@foo; end; end => nil
  • 124. 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
  • 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 1.8.7-p358 :003 > A.foo
  • 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 => “A”
  • 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” 1.8.7-p358 :003 > C.foo
  • 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 => “A”
  • 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” 1.8.7-p358 :003 > class B < A; @@foo="B"; nil; end
  • 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 => nil
  • 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 1.8.7-p358 :003 > B.foo
  • 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 => “B”
  • 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” 1.8.7-p358 :003 > A.foo
  • 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 => “B”
  • 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” 1.8.7-p358 :003 > C.foo
  • 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 => “B”
  • 137. 22 int to hex to int
  • 138. 1.8.7-p358 :001 > 3405691582.to_s(16)
  • 139. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe”
  • 140. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe” 1.8.7-p358 :002 > "cafebabe".to_i(16)
  • 141. 1.8.7-p358 :001 > 3405691582.to_s(16) => “cafebabe” 1.8.7-p358 :002 > "cafebabe".to_i(16) => 3405691582
  • 143. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3, 4, 5, 6, .., 99, 100]
  • 144. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3, 4, 5, 6, .., 99, 100] 1.8.7-p358 :002 > a.each_with_index {|x,i| p x if (i==20..i==34)}
  • 145. 1.8.7-p358 :001 > a = [*1..100] => [1, 2, 3, 4, 5, 6, .., 99, 100] 1.8.7-p358 :002 > a.each_with_index {|x,i| p x if (i==20..i==34)} 21 22 ... 34 35 => [1, 2, 3, 4, 5, 6, .., 99, 100]
  • 146. 24 0b
  • 147. 1.8.7-p358 :001 > val = 0b11100100
  • 148. 1.8.7-p358 :001 > val = 0b11100100 => 228
  • 149. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002 > val.class
  • 150. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002 > val.class => Fixnum
  • 151. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002 > val.class => Fixnum 1.8.7-p358 :003 > val[4]
  • 152. 1.8.7-p358 :001 > val = 0b11100100 => 228 1.8.7-p358 :002 > val.class => Fixnum 1.8.7-p358 :003 > val[4] => 0
  • 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 1.8.7-p358 :004 > val[5]
  • 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] => 1
  • 156. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358 :002 > foo
  • 157. 1.8.7-p358 :001 > def foo; 0; ensure; 1; end 1.8.7-p358 :002 > foo => 0
  • 158. 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
  • 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 => 1
  • 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 1.8.7-p358 :005 > def foo; return 0; ensure; 1; end 1.8.7-p358 :006 > foo
  • 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 => 0
  • 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 1.8.7-p358 :007 > def foo; return 0; ensure; return 1; end 1.8.7-p358 :006 > foo
  • 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 => 1
  • 165. 1.8.7-p358 :001 > require ‘benchmark’ => true
  • 166. 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
  • 167. 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
  • 169. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil
  • 170. 1.8.7-p358 :001 > class ExceptionOne < Exception; end => nil 1.8.7-p358 :002 > ExceptionTwo = Class.new(Exception) => ExceptionTwo
  • 171. 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
  • 172. 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
  • 173. 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
  • 174. 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
  • 176. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] => [1,2,3,4,5] >> a.sample
  • 177. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] => [1,2,3,4,5] >> a.sample => 3
  • 178. Loading development environment (Rails 2.3.10) >> a = [1,2,3,4,5] => [1,2,3,4,5] >> a.sample => 3 >> a.sample => 4
  • 179. 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)
  • 180. 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]
  • 183. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100)
  • 184. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00"
  • 185. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00" >> helper.number_to_human_size(1000000000000000)
  • 186. Loading development environment (Rails 2.3.10) >> helper.number_to_currency(100) => "$100.00" >> helper.number_to_human_size(1000000000000000) => “909.5 TB”
  • 188. Loading development environment (Rails 3.0.7) jruby-1.5.6 :001 > DataSource.group(:beta).count
  • 189. Loading development environment (Rails 3.0.7) jruby-1.5.6 :001 > DataSource.group(:beta).count => #<OrderedHash {false=>4951, true=>233}>
  • 192. $ script/console --sandbox
  • 193. $ 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...
  • 195. $ rake stats
  • 196. $ 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
  • 198. $ rake notes
  • 199. $ 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? ...
  • 201. $ rake routes
  • 202. $ 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"} ...
  • 204. $ ruby -c app/models/email_campaign.rb
  • 205. $ ruby -c app/models/email_campaign.rb Syntax OK
  • 206. $ ruby -c app/models/email_campaign.rb Syntax OK $ ruby -c app/models/axe/outright/filter_chain.rb
  • 207. $ 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
  • 209. $ vim ~/.irbrc
  • 210. $ 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

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n
  185. \n
  186. \n
  187. \n
  188. \n
  189. \n
  190. \n
  191. \n
  192. \n
  193. \n
  194. \n
  195. \n
  196. \n
  197. \n
  198. \n
  199. \n
  200. \n
  201. \n
  202. \n
  203. \n
  204. \n
  205. \n
  206. \n
  207. \n
  208. \n
  209. \n
  210. \n