This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActionController::Base.new.read_fragment('key') | |
| ActionController::Base.new.expire_fragment('key') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FATAL -- : error adding listener addr= | |
| /Users/k/.rbenv/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:200:in `server_cast': undefined method `getsockname' for nil:NilClass (NoMethodError) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| command Ruby19Hashes %s/\v:(\w+)(\s*)\=\>/\1:/g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h = ActiveSupport::HashWithIndifferentAccess.new {|h,k| h[k] = [] } | |
| # => {} | |
| h[:key1] | |
| # => [] | |
| h[:key1] << 13 | |
| # => [13] | |
| h | |
| # => {"key1"=>[13]} | |
| h[:key2] << 31 | |
| # => [31] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):003:0> def assign=(val); raise "THE WORLD IS BROKEN!"; end | |
| => nil | |
| irb(main):004:0> self.assign = 10 | |
| RuntimeError: THE WORLD IS BROKEN! | |
| from (irb):3:in `assign=' | |
| from (irb):4 | |
| from C:/Program Files (x86)/ruby-1.9.2/bin/irb:12:in `<main>' | |
| irb(main):005:0> assign = 10 | |
| => 10 | |
| irb(main):006:0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class C | |
| attr_accessor :counter | |
| def initialize | |
| @counter = 1 | |
| end | |
| def increment | |
| counter = counter + 1 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def val | |
| 13 | |
| end | |
| def assign | |
| val = val.to_s | |
| end | |
| p assign | |
| # => "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f | |
| p x | |
| end | |
| f() | |
| # undefined local variable or method `x' for main:Object (NameError) | |
| def f | |
| if false | |
| x = 13 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h = {a: 13, b: 31} | |
| # => {:a=>13, :b=>31} | |
| h.merge(h) {|k, v0, v1| v0 * 2 } | |
| # => {:a=>26, :b=>62} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class C | |
| attr_reader :read_only | |
| def assert(assertion, message="assertion failed") | |
| raise RuntimeError, message unless assertion | |
| end | |
| def initialize | |
| @read_only = 13 | |
| assert read_only == 13 |