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
require 'benchmark' | |
Benchmark.bmbm do |x| | |
x.report "double quotes" do | |
10_000_000.times do | |
"foo" | |
end | |
end | |
x.report "single quotes" do | |
10_000_000.times do |
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
[foo] | |
key = value | |
[foo.key] | |
bar = sausage |
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
traceroute to 216.81.59.173 (216.81.59.173), 100 hops max, 60 byte packets | |
1 router1-dal.linode.com (67.18.7.161) 0.698 ms 0.685 ms 0.756 ms | |
2 xe-2-0-0.car03.dllstx2.networklayer.com (67.18.7.89) 0.341 ms 0.326 ms 0.311 ms | |
3 po101.dsr02.dllstx2.networklayer.com (70.87.254.77) 0.584 ms 0.663 ms 0.665 ms | |
4 po22.dsr02.dllstx3.networklayer.com (70.87.255.69) 0.809 ms 0.861 ms 0.947 ms | |
5 ae17.bbr02.eq01.dal03.networklayer.com (173.192.18.230) 0.501 ms 0.478 ms 0.451 ms | |
6 ae7.bbr01.eq01.dal03.networklayer.com (173.192.18.208) 0.475 ms 0.653 ms 10gigabitethernet3-1.core1.dal1.he.net (206.223.118.37) 6.020 ms | |
7 10gigabitethernet3-1.core1.dal1.he.net (206.223.118.37) 1.455 ms 1.581 ms 10gigabitethernet5-4.core1.atl1.he.net (184.105.213.114) 21.941 ms | |
8 10gigabitethernet5-4.core1.atl1.he.net (184.105.213.114) 22.013 ms 216.66.0.26 (216.66.0.26) 20.970 ms 21.238 ms | |
9 10.26.26.102 (10.26.26.102) 58.340 ms 56.423 ms 216.66.0.26 (216.66.0.26) 20.832 ms |
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
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:31: warning: method redefined; discarding old visit_String | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:4: warning: previous definition of visit_String was here | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:39: warning: method redefined; discarding old register | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:12: warning: previous definition of register was here | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:43: warning: method redefined; discarding old format_time | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/psych_tree.rb:16: warning: previous definition of format_time was here | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/syck_hack.rb:115: warning: method redefined; discarding old to_s | |
/Users/alex/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/rubygems/syck_hack.rb:44: warning: previ |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
require 'coderay' | |
json = ::JSON.pretty_generate(JSON.parse(STDIN.read)) | |
puts ::CodeRay.encode(json, :json, :terminal) |
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
H4sIAE5CHU4AA31UQY7cOAy86xW89aV3vrCYS4AFFrkkwGKPapuyiZZFR5TG69+nKM8M9hDk1jLFUlWx2F+kWqO28kl7bxSPePqJZo6Zq93Dk3kn7ZWeMhtZTEyxzKQpjXvWKnN7Cd9XLr+A2atak9Ybf0BtsVbhmTbcn7KKNa44xkarbvwS/odkq6qXPsAefbM7hfZ54cFoczaPaCtu+qUfnQfv1mv5aI525r79YcxPr1FIqHSo6bbLJFpsoCSO1V7CP1Avc7k1qlGMh/g3lYnv4fgsbfEJIyh1Q8df7Wb4WcrgWZmOaFSUtDBlTvBXcWyACMcn+SluTEkriED136pPoyxAPaRNK4MSgKSQcTQt93Bqh+AGuyjlk06nlXJcLgPYlVYOmnA+/eFjVdpkWRslae8ztanK3sThZnmDF9JOEud6DJkPWRZGHtwJkPqKz2CzjtqkxTtiG361uO88hxEFFGdJCcLLBN78367G8z2saD8jXN7HB3ch6xtf1AuD20Nr+HxgkzJfg5h6bVHwCgKCxj99JP0d4dBaT7o9FDEDXXpUdc/vwTVgPosiEqOSohcGYCzEbzB+6MNLowUCX1FzX5HRnGFiFlxDwMTdRzR1qnE6aYFXNqY9PSmOp9E1Qn/l3d3dFEXMa+btahvmDPQj5qwH+AMd5BHr5xV07BNE1Q4H8KSP+DYjdYN3Um+6lmxCSwY49Pu5cAu3KcISYMsG45CC7EPHPiAvFMZML15PGetKCYs664ZvcdCnOLUOYifSWrDB4ZvCPKwSZOCdMSTE5TEMNFeuBR5gm8O4ZkOtv4DgbT7DdDXNEnd391+oQYSRseYEPcqrXPu6i0HusUrmAT0EwGYQoT1OksQnGpG5Xhoc81TPPTeAJNzBwrxisRYk0Uv4K2kxIz/zws1+1/d7TJhBlRckz/lAmWA5C3Jv+I/oVtgs/AQjLCYcMAUAAA== |
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
# = delegate -- Support for the Delegation Pattern | |
# | |
# Documentation by James Edward Gray II and Gavin Sinclair | |
# | |
# == Introduction | |
# | |
# This library provides three different ways to delegate method calls to an | |
# object. The easiest to use is SimpleDelegator. Pass an object to the | |
# constructor and all methods supported by the object will be delegated. This | |
# object can be changed later. |
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 Array | |
def powerset | |
inject([[]]){ |c,y| | |
c.inject([]) {|r,i| | |
r+=[i,i+[y]] | |
} | |
} | |
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
# from http://moonbase.rydia.net/mental/blog/programming/eavesdropping-on-expressions | |
# For debugging and getting a puts in there, tap is nice | |
def blah | |
@things.map { |x| | |
x.length | |
}.inject( 0 ) { |a, b| | |
a + b | |
} | |
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
require 'benchmark' | |
require 'set' | |
some_numbers = [] | |
1_000_000.times do | |
num = rand(100_000) | |
rand(5).times do | |
some_numbers << {:id => num} | |
end |