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 URI | |
def self.parse_with_options(uri_str, opts = {}) | |
parsed_uri = self.parse(uri_str) | |
sing = (class << parsed_uri; self end) | |
sing.send :define_method, :options do | |
opts | |
end | |
parsed_uri | |
end | |
end |
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
# Parallel map | |
# Originally from http://project.ioni.st/post/2332#snippet_2332 | |
class Array | |
def pmap | |
threads = [] | |
0.upto(size - 1) do |n| | |
threads << Thread.new do | |
yield(at(n)) | |
end | |
end |
NewerOlder