This file contains 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
od --skip-bytes=4 --read-bytes=8 -t fD -An teste.bin | printf "%.0f" $(tr -d ' ') |
This file contains 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
#!/bin/ruby | |
require "cgi" | |
STDOUT.print CGI.escapeHTML(ARGV.size>0 ? File.read(ARGV[0]) : STDIN.read) |
This file contains 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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>HTML escape test</title> | |
</head> | |
<body> | |
<p>This is a test.</p> | |
</body> | |
</html> |
This file contains 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
p [:ruby, :"2.0", :symbol, :array, :literal] | |
#=> [:ruby, :"2.0", :symbol, :array, :literal] | |
p %i(ruby 2.0 symbol array literal) | |
#=> [:ruby, :"2.0", :symbol, :array, :literal] |
This file contains 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 foo(str: "foo", num: 123456) | |
[str, num] | |
end | |
p foo(str: 'buz', num: 9) #=> ['buz', 9] | |
p foo(str: 'bar') # => ['bar', 123456] | |
p foo(num: 123) # => ['foo', 123] | |
p foo # => ['foo', 123456] | |
p foo(bar: 'buz') # => ArgumentError |
This file contains 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 | |
def x; "x"; end | |
end | |
module M | |
def x; '[' + super + ']'; end | |
def y; "y"; end | |
end | |
class C |
This file contains 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 | |
def x; "x"; end | |
end | |
module M | |
def x; '[' + super + ']'; end | |
def y; "y"; end | |
end | |
class C |
This file contains 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
module TimeExtensions | |
refine Fixnum do | |
def minutes; self * 60; end | |
end | |
end | |
class MyApp | |
using TimeExtensions | |
def initialize | |
p 2.minutes |
This file contains 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
regexp = /^([A-Z])?[a-z]+(?(1)[A-Z]|[a-z])$/ | |
p regexp =~ "foo" #=> 0 | |
p regexp =~ "foO" #=> nil | |
p regexp =~ "FoO" #=> 0 |
This file contains 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
natural_numbers = Enumerator.new do |yielder| | |
number = 1 | |
loop do | |
yielder.yield number | |
number += 1 | |
end | |
end | |
p natural_numbers.select { |n| n.odd? }.take(5).to_a |