Skip to content

Instantly share code, notes, and snippets.

View dagbrown's full-sized avatar

Dave Brown dagbrown

View GitHub Profile
# 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
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
#!/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'