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
| # mv prefix_filename.txt filename.txt | |
| find -type f | sed 's/prefix_\(.\+\)/mv \0 \1/' | sh |
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
| count = 1 | |
| сount = 2 | |
| count # => 1 | |
| local_variables # => [:o_0, :сount, :count, :_] |
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
| ... | |
| private | |
| def use_dsl(&block) | |
| proxy = Proxy.new(self, @api) | |
| proxy.call(&block) | |
| end | |
| end | |
| class Proxy < BasicObject |
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
| Date.current.beginning_of_year + 0xFF.days # => Sun, 13 Sep 2015 | |
| # 0001011000101110001011100000111011001110010111001111010011110100 | |
| # 1010011001110110011101001110111010010110110101101001011000001110 | |
| # 1010011000100110100101101000011001110100111101100100111011100110 | |
| # 1111010011101110100101101101011010010110111101000000101001001110 | |
| # 1111011011100110010011101000011010110110101101101010011001001110 | |
| # 110011101110010011111010001000101000011010011110 |
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
| hash1 = {"x" => 1} | |
| xml = hash1.to_xml # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n <x type=\"integer\">1</x>\n</hash>\n" | |
| hash2 = Hash.from_xml(xml) # => {"hash"=>{"x"=>1}} | |
| hash1 == hash2 # => false |
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
| Date.today # => Mon, 10 Aug 2015 | |
| Date.current # => Sun, 09 Aug 2015 | |
| # File activesupport/lib/active_support/core_ext/date_and_time/calculations.rb, line 24 | |
| # def today? | |
| # to_date == ::Date.current | |
| # end | |
| Date.today.today? # => false |
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
| Object.class_eval { def self.private; Object; end } | |
| def MyClass | |
| private | |
| def some_method | |
| end | |
| end | |
| MyClass.private_instance_methods.include? :some_method # => false |
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
| public.class_eval { def say_hello; 'Hello!'; end } | |
| :ruby.say_hello # => "Hello!" |
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
| input_array = [1, 2, 1, 4, 1.0, 1r] | |
| require 'set' | |
| Set.new(input_array).to_a | |
| # => [1, 2, 4, 1.0, (1/1)] | |
| unique_elements = [] | |
| input_array.each { |el| unique_elements << el unless unique_elements.include?(el) } | |
| unique_elements | |
| # => [1, 2, 4] |
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
| # List of available dates you can see at https://static.rust-lang.org/dist/ | |
| curl -s https://static.rust-lang.org/rustup.sh | sudo sh -s -- --date="2015-03-25" |