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
# A nice demonstration of how much faster Ruby 1.9 is than Ruby 1.8 | |
require "complex" | |
class Complex | |
def m | |
z=self | |
1024.times { |i| z=z*z+self; return i+1 if z.abs > 2 } | |
return 1024 | |
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
class AnagramDict | |
begin | |
@@anagramdict = Marshal.load "anagramdict.marshal" | |
rescue | |
@@anagramdict ||= Hash.new | |
File.read("/usr/share/dict/word.list").split(/\n/).each do |word| | |
sortedword=word.split('').sort.join | |
@@anagramdict[sortedword] ||= [] | |
@@anagramdict[sortedword] << word | |
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
#!/usr/bin/ruby | |
# | |
# tvrss - a BitTorrent torrent-RSS puller | |
# | |
# Make a directory called ~/.tvrss | |
# Make another called ~/.tvrss/torrents | |
# Put URLs of RSS feeds in ~/.tvrss/feeds | |
# Bob's your uncle! | |
require 'rubygems' |
NewerOlder