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
http://www.mikeperham.com/2010/11/22/the-ruby-stdlib-is-a-ghetto/ | |
http://architecturalatrocities.com/post/23659800703/the-ruby-standard-library-is-a-disgrace | |
http://apocryph.org/archives/579 | |
http://devblog.avdi.org/2015/09/04/poll-whats-your-favorite-ruby-http-client-library/ | |
http://www.jstorimer.com/pages/ruby-core-classes-arent-thread-safe | |
http://iamserg.io/writings/2014/queue-and-sized-queue/ | |
http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/ | |
https://robm.me.uk/ruby/2014/01/25/pstore.html | |
http://www.rubydoc.info/stdlib/set |
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
require "./src/benchmark" | |
def repetition1(ary, times) | |
ary = typeof(ary).new(ary.length * times) | |
times.times do | |
ary += ary | |
end | |
ary | |
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
$ ~/Downloads/crystal-0.6.1-1/bin/crystal | |
Usage: crystal [command] [switches] [program file] [--] [arguments] | |
Command: | |
build compile program file | |
browser open an http server to browse program file | |
deps install project dependencies | |
docs generate documentation | |
eval eval code | |
hierarchy show type hierarchy |
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 comprehend(*enums) | |
cycles = enums.map(&:cycle) | |
Enumerator.new do |comprehended| | |
loop do | |
value = cycles.map(&:peek) | |
value = yield value if block_given? | |
comprehended << value | |
(cycles.length - 1).downto(0) do |index| | |
cycles[index].next |
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 ObjectThatInsistsOnCallingRead | |
def initialize(io) | |
while s = io.read(10) | |
print s | |
end | |
end | |
end | |
class WrapperToWhichYouCanWrite | |
def initialize |
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 Object | |
def to_app | |
lambda do |env| | |
_, method, args = env['REQUEST_PATH'].split('/') | |
[200, {}, [self.send(method, *args).to_s]] | |
end | |
end | |
end | |
class HelloWorld |
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
>> require 'date' | |
=> true | |
>> Date.today.next_month | |
=> #<Date: 2014-09-19 (4913839/2,0,2299161)> | |
>> Date.today.next_month - 1 | |
=> #<Date: 2014-09-18 (4913837/2,0,2299161)> | |
>> Date.today.next_month -1 | |
=> #<Date: 2014-07-19 (4913715/2,0,2299161)> |
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 A | |
private | |
def self.a | |
:a | |
end | |
end | |
class B | |
class << self |
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):001:0> class A; private; attr_reader :a; end | |
=> nil | |
irb(main):002:0> A.new.a | |
NoMethodError: private method `a' called for #<A:0x007fbbca0403c0> | |
from (irb):2 | |
from /Users/sergiogil/.rbenv/versions/1.9.3-p448/bin/irb:12:in `<main>' |
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 FancyDSL | |
def initialize(&block) | |
instance_eval(&block) | |
end | |
def setup(value) | |
@setup = value | |
end | |
end |