<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: tiny code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 23:23:10 GMT</pubDate>
    <description>DZone Snippets: tiny code</description>
    <item>
      <title>Generate short URLs using Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5140</link>
      <description>This Ruby code generates shortened URLs. It has the added feature that it will not allow words to be created accidentally  eg. swear words.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/ruby&lt;br /&gt;&lt;br /&gt;class ShortUrl&lt;br /&gt;  def initialize()&lt;br /&gt;    @chars = ('a'..'z').to_a + ('1'..'9').to_a + ('A'..'Z').to_a&lt;br /&gt;    @array_size = @chars.size&lt;br /&gt;    @h = Hash.new&lt;br /&gt;    @chars.each {|c| @h[c] = '0'}&lt;br /&gt;    vowels = %w(a e i o u A E I O U 4 3 1 0)&lt;br /&gt;    vowels.each {|v| @h[v] = '1'}&lt;br /&gt;    nums = %w(2 5 6 7 8 9)&lt;br /&gt;    nums.each {|n| @h[n] = '2'}&lt;br /&gt;    @count = 0&lt;br /&gt;    @a = Array.new(7, -1)&lt;br /&gt;    @k = 0&lt;br /&gt;  end &lt;br /&gt;&lt;br /&gt;  def iterate_chars(array_size)&lt;br /&gt;    (0..array_size).each {|i| &lt;br /&gt;      increment_index(@k)&lt;br /&gt;      convert_to_chars()&lt;br /&gt;    }&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def convert_to_chars()&lt;br /&gt;    buffer = ''&lt;br /&gt;    @a.each {|i|&lt;br /&gt;      buffer &lt;&lt; @chars[i] if i &gt;= 0&lt;br /&gt;    }&lt;br /&gt;    a = buffer.reverse.scan(/./)&lt;br /&gt;    k = a.length  &lt;br /&gt;    if  (k &gt; 1)  &lt;br /&gt;      if ((@h[a[k-2]] + @h[a[k-1]]) != '10')&lt;br /&gt;        puts buffer.reverse &lt;br /&gt;      end&lt;br /&gt;    else&lt;br /&gt;      puts buffer.reverse&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def get_short_url(count)&lt;br /&gt;    if count &gt;  @array_size&lt;br /&gt;      new_count = count - @array_size&lt;br /&gt;      iterate_chars(@array_size)&lt;br /&gt;      get_short_url(new_count)&lt;br /&gt;    else&lt;br /&gt;      iterate_chars(count)&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def increment_a(i)&lt;br /&gt;    if @a[i] &lt; @array_size - 1&lt;br /&gt;      @a[i] = @a[i] + 1&lt;br /&gt;      return i &lt;br /&gt;    else&lt;br /&gt;      @a[i] = 0&lt;br /&gt;      return i += 1&lt;br /&gt;    end &lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def increment_index(k)&lt;br /&gt;    old_k = k&lt;br /&gt;    k = increment_a(k)&lt;br /&gt;    &lt;br /&gt;    if k != old_k&lt;br /&gt;      increment_index(k)&lt;br /&gt;    else&lt;br /&gt;      k = 0&lt;br /&gt;    end&lt;br /&gt;    k&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if __FILE__ == $0&lt;br /&gt;  su = ShortUrl.new  &lt;br /&gt;  su.get_short_url(222761)&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: You will most likely see the " `convert_to_chars': stack level too deep (SystemStackError)" error message after around 253950 iterations, I'm presuming this is expected due to the memory constraints of the language. However 253k short urls is enough for linking my website to itself.&lt;br /&gt;</description>
      <pubDate>Thu, 14 Feb 2008 05:00:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5140</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>tiny.conf</title>
      <link>http://snippets.dzone.com/posts/show/4202</link>
      <description>// Configuration for tiny.py&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;config = "tiny.conf"&lt;br /&gt;service = "urltea"&lt;br /&gt;urltea url = "http://urltea.com/api/text/?url="&lt;br /&gt;tinyurl url = "http://tinyurl.com/api-create.php?"&lt;br /&gt;description delimeter = "?"&lt;br /&gt;description = ""&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 24 Jun 2007 17:10:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4202</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>tea.py</title>
      <link>http://snippets.dzone.com/posts/show/4196</link>
      <description>// Converts long URLs to tiny URLs with URLTea.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;__author__="Andrew Pennebaker (andrew.pennebaker@gmail.com)"&lt;br /&gt;__date__="22 Jun 2007"&lt;br /&gt;__copyright__="Copyright 2007 Andrew Pennebaker"&lt;br /&gt;__license__="GPL"&lt;br /&gt;__version__="0.0.1"&lt;br /&gt;__URL__="http://urltea.com/to8"&lt;br /&gt;__credits__="http://tinyurl.com/yswqg3"&lt;br /&gt;&lt;br /&gt;import sys, urllib, getopt&lt;br /&gt;&lt;br /&gt;CREATE_URL="http://urltea.com/api/text/?url="&lt;br /&gt;COMMENT_DELIMETER="?"&lt;br /&gt;&lt;br /&gt;def tiny(url, description=""):&lt;br /&gt;	global CREATE_URL&lt;br /&gt;	global COMMENT_DELIMETER&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		encodedurl=CREATE_URL+urllib.urlencode({"url":url})&lt;br /&gt;		instream=urllib.urlopen(encodedurl)&lt;br /&gt;		tinyurl=instream.read()&lt;br /&gt;		instream.close()&lt;br /&gt;&lt;br /&gt;		if len(tinyurl)==0:&lt;br /&gt;			return url&lt;br /&gt;&lt;br /&gt;		if len(description)&gt;0:&lt;br /&gt;			tinyurl+=COMMENT_DELIMETER+description&lt;br /&gt;&lt;br /&gt;		return tinyurl&lt;br /&gt;	except IOError, e:&lt;br /&gt;		raise "Could not connect."&lt;br /&gt;&lt;br /&gt;def usage():&lt;br /&gt;	print "Usage: %s &lt;url1&gt; &lt;url2&gt; &lt;url3&gt; ..." % (sys.argv[0])&lt;br /&gt;	print "-d|--description &lt;comment&gt;"&lt;br /&gt;	print "-h|--help (usage)"&lt;br /&gt;&lt;br /&gt;	sys.exit()&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;	systemArgs=sys.argv[1:]&lt;br /&gt;	oplist, args=[], []&lt;br /&gt;&lt;br /&gt;	comment=""&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		optlist, args=getopt.getopt(systemArgs, "d:h", ["description=", "help"])&lt;br /&gt;	except:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-h" or option=="--help":&lt;br /&gt;			usage()&lt;br /&gt;		elif option=="-d" or option=="--description":&lt;br /&gt;			comment=value&lt;br /&gt;&lt;br /&gt;	if len(args)&lt;1:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for u in args:&lt;br /&gt;		print tiny(u, comment)&lt;br /&gt;&lt;br /&gt;if __name__=="__main__":&lt;br /&gt;	try:&lt;br /&gt;		main()&lt;br /&gt;	except KeyboardInterrupt, e:&lt;br /&gt;		pass&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Jun 2007 18:54:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4196</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>tiny.py</title>
      <link>http://snippets.dzone.com/posts/show/4195</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;"""Converts long URLs to tiny URLs, with either tinyurl, urltea, or a custom url."""&lt;br /&gt;&lt;br /&gt;__author__="Andrew Pennebaker (andrew.pennebaker@gmail.com)"&lt;br /&gt;__date__="22 Jun 2007 - 24 Jun 2007"&lt;br /&gt;__copyright__="Copyright 2007 Andrew Pennebaker"&lt;br /&gt;__license__="GPL"&lt;br /&gt;__version__="0.0.1"&lt;br /&gt;__URL__="http://snippets.dzone.com/posts/show/4195"&lt;br /&gt;__credits__="http://lateral.netmanagers.com.ar/weblog/2007/04/08.html#BB548"&lt;br /&gt;&lt;br /&gt;import sys, getopt, urllib&lt;br /&gt;&lt;br /&gt;import configreader&lt;br /&gt;&lt;br /&gt;def tiny(url, settings):&lt;br /&gt;	try:&lt;br /&gt;		encodedurl=settings["posting url"]+urllib.urlencode({"url":url})&lt;br /&gt;		instream=urllib.urlopen(encodedurl)&lt;br /&gt;		tinyurl=instream.read()&lt;br /&gt;		instream.close()&lt;br /&gt;&lt;br /&gt;		if len(tinyurl)==0:&lt;br /&gt;			return url&lt;br /&gt;&lt;br /&gt;		if settings["service"]=="urltea" and len(settings["description"])&gt;0:&lt;br /&gt;				tinyurl+=settings["description delimeter"]+settings["description"]&lt;br /&gt;&lt;br /&gt;		return tinyurl&lt;br /&gt;	except IOError, e:&lt;br /&gt;		raise "Could not connect."&lt;br /&gt;&lt;br /&gt;def usage():&lt;br /&gt;	print "Usage: %s [options] &lt;url1&gt; &lt;url2&gt; &lt;url3&gt; ..." % (sys.argv[0])&lt;br /&gt;	print "\nDefaults to urlTea unless specified in options or a config file."&lt;br /&gt;	print "\n-s|--service [tinyurl|urltea]"&lt;br /&gt;	print "-u|--custom-url &lt;posting url&gt;"&lt;br /&gt;	print "-d|--description &lt;comment&gt; May only be used with urltea."&lt;br /&gt;	print "-c|--config &lt;configfile&gt;"&lt;br /&gt;	print "-h|--help (usage)"&lt;br /&gt;&lt;br /&gt;	sys.exit()&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;	systemArgs=sys.argv[1:]&lt;br /&gt;	oplist, args=[], []&lt;br /&gt;&lt;br /&gt;	settings={&lt;br /&gt;		"config":"tiny.conf",&lt;br /&gt;		"service":"urltea",&lt;br /&gt;		"urltea url":"http://urltea.com/api/text/?url=",&lt;br /&gt;		"tinyurl url":"http://tinyurl.com/api-create.php?",&lt;br /&gt;		"description delimeter":"?",&lt;br /&gt;		"description":""&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		optlist, args=getopt.getopt(systemArgs, "s:u:d:c:h", ["service=", "custom-url=", "description=", "config=", "help"])&lt;br /&gt;	except:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-c" or option=="--config":&lt;br /&gt;			settings["config"]=value&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		configreader.load(open(settings["config"], "r"), settings)&lt;br /&gt;	except IOError, e:&lt;br /&gt;		pass&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-h" or option=="--help":&lt;br /&gt;			usage()&lt;br /&gt;		elif option=="-s" or option=="--service":&lt;br /&gt;			settings["service"]=value&lt;br /&gt;		elif option=="-d" or option=="--description":&lt;br /&gt;			settings["description"]=value&lt;br /&gt;&lt;br /&gt;	if settings["service"]!="urltea" and len(settings["description"])&gt;0:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	try:&lt;br /&gt;		settings["posting url"]=settings[settings["service"]+" url"]&lt;br /&gt;	except:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for option, value in optlist:&lt;br /&gt;		if option=="-u" or option=="--custom-url":&lt;br /&gt;			settings["posting url"]=value&lt;br /&gt;&lt;br /&gt;	if len(args)&lt;1:&lt;br /&gt;		usage()&lt;br /&gt;&lt;br /&gt;	for u in args:&lt;br /&gt;		print tiny(u, settings)&lt;br /&gt;&lt;br /&gt;if __name__=="__main__":&lt;br /&gt;	try:&lt;br /&gt;		main()&lt;br /&gt;	except KeyboardInterrupt, e:&lt;br /&gt;		pass&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Jun 2007 18:32:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4195</guid>
      <author>mcandre (Andrew Pennebaker)</author>
    </item>
    <item>
      <title>simple IRC bot written in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/1785</link>
      <description>A simple IRC bot written in Ruby. It's only 100 lines long!&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/local/bin/ruby&lt;br /&gt;&lt;br /&gt;require "socket"&lt;br /&gt;&lt;br /&gt;# Don't allow use of "tainted" data by potentially dangerous operations&lt;br /&gt;$SAFE=1&lt;br /&gt;&lt;br /&gt;# The irc class, which talks to the server and holds the main event loop&lt;br /&gt;class IRC&lt;br /&gt;    def initialize(server, port, nick, channel)&lt;br /&gt;        @server = server&lt;br /&gt;        @port = port&lt;br /&gt;        @nick = nick&lt;br /&gt;        @channel = channel&lt;br /&gt;    end&lt;br /&gt;    def send(s)&lt;br /&gt;        # Send a message to the irc server and print it to the screen&lt;br /&gt;        puts "--&gt; #{s}"&lt;br /&gt;        @irc.send "#{s}\n", 0 &lt;br /&gt;    end&lt;br /&gt;    def connect()&lt;br /&gt;        # Connect to the IRC server&lt;br /&gt;        @irc = TCPSocket.open(@server, @port)&lt;br /&gt;        send "USER blah blah blah :blah blah"&lt;br /&gt;        send "NICK #{@nick}"&lt;br /&gt;        send "JOIN #{@channel}"&lt;br /&gt;    end&lt;br /&gt;    def evaluate(s)&lt;br /&gt;        # Make sure we have a valid expression (for security reasons), and&lt;br /&gt;        # evaluate it if we do, otherwise return an error message&lt;br /&gt;        if s =~ /^[-+*\/\d\s\eE.()]*$/ then&lt;br /&gt;            begin&lt;br /&gt;                s.untaint&lt;br /&gt;                return eval(s).to_s&lt;br /&gt;            rescue Exception =&gt; detail&lt;br /&gt;                puts detail.message()&lt;br /&gt;            end&lt;br /&gt;        end&lt;br /&gt;        return "Error"&lt;br /&gt;    end&lt;br /&gt;    def handle_server_input(s)&lt;br /&gt;        # This isn't at all efficient, but it shows what we can do with Ruby&lt;br /&gt;        # (Dave Thomas calls this construct "a multiway if on steroids")&lt;br /&gt;        case s.strip&lt;br /&gt;            when /^PING :(.+)$/i&lt;br /&gt;                puts "[ Server ping ]"&lt;br /&gt;                send "PONG :#{$1}"&lt;br /&gt;            when /^:(.+?)!(.+?)@(.+?)\sPRIVMSG\s.+\s:[\001]PING (.+)[\001]$/i&lt;br /&gt;                puts "[ CTCP PING from #{$1}!#{$2}@#{$3} ]"&lt;br /&gt;                send "NOTICE #{$1} :\001PING #{$4}\001"&lt;br /&gt;            when /^:(.+?)!(.+?)@(.+?)\sPRIVMSG\s.+\s:[\001]VERSION[\001]$/i&lt;br /&gt;                puts "[ CTCP VERSION from #{$1}!#{$2}@#{$3} ]"&lt;br /&gt;                send "NOTICE #{$1} :\001VERSION Ruby-irc v0.042\001"&lt;br /&gt;            when /^:(.+?)!(.+?)@(.+?)\sPRIVMSG\s(.+)\s:EVAL (.+)$/i&lt;br /&gt;                puts "[ EVAL #{$5} from #{$1}!#{$2}@#{$3} ]"&lt;br /&gt;                send "PRIVMSG #{(($4==@nick)?$1:$4)} :#{evaluate($5)}"&lt;br /&gt;            else&lt;br /&gt;                puts s&lt;br /&gt;        end&lt;br /&gt;    end&lt;br /&gt;    def main_loop()&lt;br /&gt;        # Just keep on truckin' until we disconnect&lt;br /&gt;        while true&lt;br /&gt;            ready = select([@irc, $stdin], nil, nil, nil)&lt;br /&gt;            next if !ready&lt;br /&gt;            for s in ready[0]&lt;br /&gt;                if s == $stdin then&lt;br /&gt;                    return if $stdin.eof&lt;br /&gt;                    s = $stdin.gets&lt;br /&gt;                    send s&lt;br /&gt;                elsif s == @irc then&lt;br /&gt;                    return if @irc.eof&lt;br /&gt;                    s = @irc.gets&lt;br /&gt;                    handle_server_input(s)&lt;br /&gt;                end&lt;br /&gt;            end&lt;br /&gt;        end&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;# The main program&lt;br /&gt;# If we get an exception, then print it out and keep going (we do NOT want&lt;br /&gt;# to disconnect unexpectedly!)&lt;br /&gt;irc = IRC.new('efnet.skynet.be', 6667, 'Alt-255', '#cout')&lt;br /&gt;irc.connect()&lt;br /&gt;begin&lt;br /&gt;    irc.main_loop()&lt;br /&gt;rescue Interrupt&lt;br /&gt;rescue Exception =&gt; detail&lt;br /&gt;    puts detail.message()&lt;br /&gt;    print detail.backtrace.join("\n")&lt;br /&gt;    retry&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://rubystuff.org/"&gt;rubystuff.org&lt;/a&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 28 Mar 2006 16:10:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1785</guid>
      <author>413x ()</author>
    </item>
    <item>
      <title>uP2P &#8212; micro P2P file sharing application</title>
      <link>http://snippets.dzone.com/posts/show/1783</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;# uP2P.sh 0.0.1, 436 characters (excluding comments)&lt;br /&gt;[ $3 ]&amp;&amp;export W=$1 H="$2 $3" K=`mktemp`;Z=/dev/null;e(){ echo "$*";};n(){&lt;br /&gt;nc $* 2&gt;$Z;};x(){ nc -lp ${H#* } -e $1 &amp;&gt;$Z &lt;$Z&amp;};f(){ cat $K|while read h;do&lt;br /&gt;e $W $1 "$2"|n $h;done };case $# in 4)e $W s "$4"|n $H|while read h p f; do&lt;br /&gt;e $W g "$f"|n $h $p&gt;"$f";done;;5)e $H&gt;$K;e $W d $H|n $4 $5&gt;&gt;$K;x $0;;0)x $0&lt;br /&gt;read w c r;[ $W = $w ]&amp;&amp;case $c in s)f l "$r";;g)cat "$r";;a)e $r&gt;&gt;$K;;d)cat $K&lt;br /&gt;f a "$r";;l)ls|grep "$r"|sed "s/^/$H /";;esac;;esac&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://www.crossflux.org/uP2P/"&gt;uP2P&lt;/a&gt;, mentioned &lt;a href="http://ansuz.sooke.bc.ca/software/molester/"&gt;here&lt;/a&gt;</description>
      <pubDate>Tue, 28 Mar 2006 15:45:07 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1783</guid>
      <author>413x ()</author>
    </item>
    <item>
      <title>six line peer-to-peer client/server in ruby</title>
      <link>http://snippets.dzone.com/posts/show/1782</link>
      <description>&lt;pre&gt;&lt;br /&gt;slonik AZ wrote:&lt;br /&gt;&gt; slashdot published an article on someone's&lt;br /&gt;&gt; 15 lines long Peer-2-Peer application&lt;br /&gt;&gt; http://developers.slashdot.org/article.pl?sid=04/12/15/1953227&lt;br /&gt;&lt;br /&gt;&gt; Another person followed up with a 9 line equivalent Perl code.&lt;br /&gt;&lt;br /&gt;&gt; I wonder what an equivalent Ruby program would look like?&lt;br /&gt;&lt;br /&gt;I did this 9.5 hours ago. Compared to the python one it is not&lt;br /&gt;vulnerable to File stealing attacks (a client can request a file&lt;br /&gt;../foobar and ~/foobar from the python server and will get it back&lt;br /&gt;AFAIK) and 6 lines long. It is however vulnerable to the DRb style&lt;br /&gt;.instance_eval exploits. I will fix this shortly, but I might have to&lt;br /&gt;use 7 lines then.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Server: ruby p2p.rb password server server-uri merge-servers&lt;br /&gt;# Sample: ruby p2p.rb foobar server druby://localhost:1337 druby://foo.bar:1337&lt;br /&gt;# Client: ruby p2p.rb password client server-uri download-pattern&lt;br /&gt;# Sample: ruby p2p.rb foobar client druby://localhost:1337 *.rb&lt;br /&gt;require'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[/[^|].*/])[-1&lt;br /&gt;]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M=="client"&amp;&amp;c(U).f(&lt;br /&gt;x(U)).each{|n|p,c=x(n),c(n);(c.f(p,O[0],0).map{|f|s f}-D["*"]).each{|f|F.open(f,&lt;br /&gt;"w"){|o|o&lt;&lt;c.f(p,f,1)}}}||(DRb.start_service U,C.new{def f(c,a=[],t=2)c==x(U)&amp;&amp;(&lt;br /&gt;t==0&amp;&amp;D[s(a)]||t==1&amp;&amp;F.read(s(a))||p(a))end;def y()(p(U)+p).each{|u|c(u).f(x(u),&lt;br /&gt;p(U))rescue()};self;end;private;def p(x=[]);O.push(*x).uniq!;O;end}.new.y;sleep) &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: &lt;a href="http://groups.google.ca/group/comp.lang.ruby/msg/8fc335f67f99536c"&gt;p2p.rb (Florian Gross)&lt;/a&gt;, mentioned &lt;a href="http://ansuz.sooke.bc.ca/software/molester/"&gt;here&lt;/a&gt;&lt;br /&gt;</description>
      <pubDate>Tue, 28 Mar 2006 15:39:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1782</guid>
      <author>413x ()</author>
    </item>
  </channel>
</rss>
