<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-13890</id>
	<title>Nabble - ruby-talk</title>
	<updated>2009-11-26T15:31:53Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/ruby-talk-f13890.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/ruby-talk-f13890.html" />
	<subtitle type="html"></subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26536216</id>
	<title>Re: Heatmaps in Ruby</title>
	<published>2009-11-26T15:31:53Z</published>
	<updated>2009-11-26T15:31:53Z</updated>
	<author>
		<name>Michael Guterl</name>
	</author>
	<content type="html">On Thu, Nov 26, 2009 at 8:43 AM, Marc Hoeppner
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26536216&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;marc.hoeppner@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I am currently thinking about doing a heatmap for data visualization,
&lt;br&gt;&amp;gt; but I have very little experience with any type of graphical tools in
&lt;br&gt;&amp;gt; ruby (like the various SVG libs etc).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So I was hoping someone could point me in the right direction and save
&lt;br&gt;&amp;gt; me some time trying out useless libraries ;) Doesn't have to be ruby
&lt;br&gt;&amp;gt; either, but that way I could probably integrate it more easily into my
&lt;br&gt;&amp;gt; analysis pipeline.
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;a href=&quot;http://blog.revolution-computing.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blog.revolution-computing.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;I think there are ruby bindings for R too, so that may help.
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;Michael Guterl
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Heatmaps-in-Ruby-tp26529650p26536216.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535788</id>
	<title>Re: invalid date error when installing syntax gem</title>
	<published>2009-11-26T14:35:10Z</published>
	<updated>2009-11-26T14:35:10Z</updated>
	<author>
		<name>dondoman</name>
	</author>
	<content type="html">On Nov 4, 6:14 am, Joel VanderWerf &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26535788&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;vj...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Joel VanderWerf wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Anyone else getting this error? I didn't find any recent mention of it.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; gem install syntax --backtrace
&lt;br&gt;&amp;gt; &amp;gt; ERROR:  While executing gem ... (ArgumentError)
&lt;br&gt;&amp;gt; &amp;gt;     invalid date
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Forgot to say: this is the only gem with this problem. I set up a new
&lt;br&gt;&amp;gt; system today with about 40 other gems that installed fine, except the
&lt;br&gt;&amp;gt; ones dependent on syntax.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; There's no improvement when downloading the gem file and installing it.
&lt;br&gt;&amp;gt; The same version of syntax (1.0.0) has worked for me before, with the
&lt;br&gt;&amp;gt; same versions of ruby and gem.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; $ ruby -v
&lt;br&gt;&amp;gt; ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]
&lt;br&gt;&amp;gt; $ gem --version
&lt;br&gt;&amp;gt; 1.3.5
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; However, I'm using gcc 4.4.1 for the first time (ubuntu 9.10).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt;        vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
&lt;/div&gt;&lt;br&gt;Hi,
&lt;br&gt;&lt;br&gt;I was getting the same error when installing cucumber (it depends on
&lt;br&gt;diff-lcs, which depends on syntax). And after a few long hours of
&lt;br&gt;fighting with this bug I have found a solution!
&lt;br&gt;&lt;br&gt;It turns out there is a bug in ruby 1.8.6 for 64 bit architecture. And
&lt;br&gt;guess what, the problem is with date. You can read more about the bug,
&lt;br&gt;and the solution, here: &lt;a href=&quot;http://redmine.ruby-lang.org/issues/show/1735&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://redmine.ruby-lang.org/issues/show/1735&lt;/a&gt;.
&lt;br&gt;So, to solve the problem I had to compile ruby myself. Here are the
&lt;br&gt;steps I did:
&lt;br&gt;&lt;br&gt;1) wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p286.tar.gz
&lt;br&gt;2) tar zxf ruby-1.8.6-p286.tar.gz
&lt;br&gt;3) cd ruby-1.8.6-p286
&lt;br&gt;&lt;br&gt;Now I changed some ext settings, as described here: &lt;a href=&quot;http://blog.ghandal.net/2009/01/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blog.ghandal.net/2009/01/&lt;/a&gt;&lt;br&gt;&lt;br&gt;4) vim ext/Setup, and uncomment some extensions:
&lt;br&gt;&lt;br&gt;&amp;nbsp;#Win32API
&lt;br&gt;&amp;nbsp;#bigdecimal
&lt;br&gt;&amp;nbsp;curses
&lt;br&gt;&amp;nbsp;#dbm
&lt;br&gt;&amp;nbsp;digest
&lt;br&gt;&amp;nbsp;digest/md5
&lt;br&gt;&amp;nbsp;#digest/rmd160
&lt;br&gt;&amp;nbsp;digest/sha1
&lt;br&gt;&amp;nbsp;digest/sha2
&lt;br&gt;&amp;nbsp;dl
&lt;br&gt;&amp;nbsp;enumerator
&lt;br&gt;&amp;nbsp;#etc
&lt;br&gt;&amp;nbsp;#fcntl
&lt;br&gt;&amp;nbsp;#gdbm
&lt;br&gt;&amp;nbsp;iconv
&lt;br&gt;&amp;nbsp;#io/wait
&lt;br&gt;&amp;nbsp;#nkf
&lt;br&gt;&amp;nbsp;#pty
&lt;br&gt;&amp;nbsp;openssl
&lt;br&gt;&amp;nbsp;#racc/cparse
&lt;br&gt;&amp;nbsp;readline
&lt;br&gt;&amp;nbsp;#sdbm
&lt;br&gt;&amp;nbsp;socket
&lt;br&gt;&amp;nbsp;stringio
&lt;br&gt;&amp;nbsp;strscan
&lt;br&gt;&amp;nbsp;syck
&lt;br&gt;&amp;nbsp;syslog
&lt;br&gt;&amp;nbsp;#tcltklib
&lt;br&gt;&amp;nbsp;thread
&lt;br&gt;&amp;nbsp;#tk
&lt;br&gt;&amp;nbsp;#win32ole
&lt;br&gt;&amp;nbsp;zlib
&lt;br&gt;&lt;br&gt;5) ./configure --prefix=/usr/local --with-openssl-dir=/usr &amp;nbsp;--with-
&lt;br&gt;readline-dir=/usr --with-zlib-dir=/usr
&lt;br&gt;&lt;br&gt;This assumes ruby will be install under /usr/local
&lt;br&gt;&lt;br&gt;Now before you run make, you MUST apply the fix from here:
&lt;br&gt;&lt;a href=&quot;http://redmine.ruby-lang.org/issues/show/1735&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://redmine.ruby-lang.org/issues/show/1735&lt;/a&gt;&lt;br&gt;&lt;br&gt;6) vim Makefile
&lt;br&gt;&lt;br&gt;and apply the fix:
&lt;br&gt;&lt;br&gt;&amp;nbsp; - CFLAGS = -g -O2 -DRUBY_EXPORT -D_GNU_SOURCE=1
&lt;br&gt;&amp;nbsp; + CFLAGS = -g -DRUBY_EXPORT -D_GNU_SOURCE=1
&lt;br&gt;&lt;br&gt;save the file and then
&lt;br&gt;&lt;br&gt;7) make
&lt;br&gt;8) sudo make install
&lt;br&gt;&lt;br&gt;Then I would suggest installing rubygems manually:
&lt;br&gt;&lt;br&gt;9) wget &lt;a href=&quot;http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz&lt;/a&gt;&lt;br&gt;10) tar zxf rubygems-1.3.5.tgz
&lt;br&gt;11) cd rubygems-1.3.5/
&lt;br&gt;12) sudo ruby setup.rb
&lt;br&gt;&lt;br&gt;Now you should be all set and ready to install the syntax gem, and any
&lt;br&gt;others than depend on it, like cucumber in my case.
&lt;br&gt;&lt;br&gt;Wow, I must admit that was my longest ruby installation ever ...
&lt;br&gt;&lt;br&gt;Good luck!
&lt;br&gt;&lt;br&gt;Kind regards,
&lt;br&gt;Marcin Domanski
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/invalid-date-error-when-installing-syntax-gem-tp26190785p26535788.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535394</id>
	<title>Re: Help with regex</title>
	<published>2009-11-26T13:55:28Z</published>
	<updated>2009-11-26T13:55:28Z</updated>
	<author>
		<name>Benoit Daloze</name>
	</author>
	<content type="html">s = &amp;quot;Text1\n
&lt;br&gt;Text2\n
&lt;br&gt;Text3---&amp;quot;
&lt;br&gt;&lt;br&gt;irb(main):036:0&amp;gt; s.scan( /(\w+?)(?:\n|-+)/ )
&lt;br&gt;=&amp;gt; [[&amp;quot;Text1&amp;quot;], [&amp;quot;Text2&amp;quot;], [&amp;quot;Text3&amp;quot;]]
&lt;br&gt;&lt;br&gt;Usually, it's easier to use scan when you feel your code in the Regexp gonna
&lt;br&gt;be repeated.
&lt;br&gt;If the text is so simple, you could iterate which String#each_line, and then
&lt;br&gt;remove any '-' at the end.
&lt;br&gt;&lt;br&gt;2009/11/26 Lucas Fialho &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26535394&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;lucasfazprograma@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello everyone.
&lt;br&gt;&amp;gt; I'm trying to match the following pattern:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Text1\n
&lt;br&gt;&amp;gt; Text2\n
&lt;br&gt;&amp;gt; Text3---
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please note that Text3 can contain \n.
&lt;br&gt;&amp;gt; I tried using this regex:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; /(.*?)\n(.*?)\n(.*?)---/
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The pattern matches and I have three matches, but they're like this:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; match[0] =&amp;gt; &amp;quot;Text2\nText3---&amp;quot;
&lt;br&gt;&amp;gt; macth[1] =&amp;gt; 'Text2'
&lt;br&gt;&amp;gt; match[2] =&amp;gt; 'Text3'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; How can I get the first one to be 'Text1' ?
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-regex-tp26535132p26535394.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535356</id>
	<title>Re: Help with regex</title>
	<published>2009-11-26T13:51:35Z</published>
	<updated>2009-11-26T13:51:35Z</updated>
	<author>
		<name>Louis-Philippe</name>
	</author>
	<content type="html">try putting word metacharacter instead of an any metacharacter
&lt;br&gt;&lt;br&gt;\w*
&lt;br&gt;&lt;br&gt;instead of
&lt;br&gt;&lt;br&gt;.*
&lt;br&gt;&lt;br&gt;2009/11/26 Lucas Fialho &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26535356&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;lucasfazprograma@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello everyone.
&lt;br&gt;&amp;gt; I'm trying to match the following pattern:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Text1\n
&lt;br&gt;&amp;gt; Text2\n
&lt;br&gt;&amp;gt; Text3---
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please note that Text3 can contain \n.
&lt;br&gt;&amp;gt; I tried using this regex:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; /(.*?)\n(.*?)\n(.*?)---/
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The pattern matches and I have three matches, but they're like this:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; match[0] =&amp;gt; &amp;quot;Text2\nText3---&amp;quot;
&lt;br&gt;&amp;gt; macth[1] =&amp;gt; 'Text2'
&lt;br&gt;&amp;gt; match[2] =&amp;gt; 'Text3'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; How can I get the first one to be 'Text1' ?
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-regex-tp26535132p26535356.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535342</id>
	<title>Re: Pattern match to fail if two periods in a row</title>
	<published>2009-11-26T13:49:22Z</published>
	<updated>2009-11-26T13:49:22Z</updated>
	<author>
		<name>Louis-Philippe</name>
	</author>
	<content type="html">so then only trying to match:
&lt;br&gt;&lt;br&gt;/\w+\.?\w*/
&lt;br&gt;&lt;br&gt;should do
&lt;br&gt;&lt;br&gt;2009/11/26 Ralph Shnelvar &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26535342&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ralphs@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt; &amp;quot;abc..def&amp;quot; !~ /\.\./
&lt;br&gt;&amp;gt; =&amp;gt;&amp;gt; false
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I don't think that
&lt;br&gt;&amp;gt; &amp;nbsp;&amp;quot;abc..def&amp;quot; !~ /\.\./
&lt;br&gt;&amp;gt; is a regular expression.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp; /\.\./
&lt;br&gt;&amp;gt; is a regular expression.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Basically ... I need something that will work in a Rails
&lt;br&gt;&amp;gt; validates_format_of
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;# Reject if the email address has two periods in a row
&lt;br&gt;&amp;gt; &amp;nbsp;validates_format_of &amp;nbsp; &amp;nbsp; :email,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# See &lt;a href=&quot;http://en.wikipedia.org/wiki/E-mail_address&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/E-mail_address&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;:with =&amp;gt; ????,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;:message =&amp;gt; 'invalid email format'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Pattern-match-to-fail-if-two-periods-in-a-row-tp26534209p26535342.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26535132</id>
	<title>Help with regex</title>
	<published>2009-11-26T13:28:37Z</published>
	<updated>2009-11-26T13:28:37Z</updated>
	<author>
		<name>Lucas Fialho</name>
	</author>
	<content type="html">Hello everyone.
&lt;br&gt;I'm trying to match the following pattern:
&lt;br&gt;&lt;br&gt;Text1\n
&lt;br&gt;Text2\n
&lt;br&gt;Text3---
&lt;br&gt;&lt;br&gt;Please note that Text3 can contain \n.
&lt;br&gt;I tried using this regex:
&lt;br&gt;&lt;br&gt;/(.*?)\n(.*?)\n(.*?)---/
&lt;br&gt;&lt;br&gt;The pattern matches and I have three matches, but they're like this:
&lt;br&gt;&lt;br&gt;match[0] =&amp;gt; &amp;quot;Text2\nText3---&amp;quot;
&lt;br&gt;macth[1] =&amp;gt; 'Text2'
&lt;br&gt;match[2] =&amp;gt; 'Text3'
&lt;br&gt;&lt;br&gt;How can I get the first one to be 'Text1' ?
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Help-with-regex-tp26535132p26535132.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534890</id>
	<title>Ruby byte access to disk sectors like dd does</title>
	<published>2009-11-26T13:07:20Z</published>
	<updated>2009-11-26T13:07:20Z</updated>
	<author>
		<name>Gary Hasson</name>
	</author>
	<content type="html">I have been unable to find any reference to Ruby methods that provide
&lt;br&gt;raw disk access the way dd does. I frequently use the Linux utility
&lt;br&gt;program, dd, and would like to be able to do the same type of byte-level
&lt;br&gt;and sector-level access to the hard drive with Ruby. (What I am looking
&lt;br&gt;for is not file access.) Are there Ruby methods to provide this
&lt;br&gt;capability (other than having Ruby access dd)?
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;Gary
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-byte-access-to-disk-sectors-like-dd-does-tp26534890p26534890.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534725</id>
	<title>Re: Net::Telnet - How to send keystrokes like ESC</title>
	<published>2009-11-26T12:46:58Z</published>
	<updated>2009-11-26T12:46:58Z</updated>
	<author>
		<name>Brian Candler</name>
	</author>
	<content type="html">Babu Raj wrote:
&lt;br&gt;&amp;gt; Hi
&lt;br&gt;&amp;gt; Could you pls let me know how I can send in keystrokes such as ENTER and
&lt;br&gt;&amp;gt; ESC to a telnet session. I have the session created using
&lt;br&gt;&amp;gt; Net::Telnet.new().
&lt;br&gt;&lt;br&gt;Have you tried
&lt;br&gt;&lt;br&gt;&amp;nbsp; sess.puts
&lt;br&gt;&lt;br&gt;&amp;nbsp; sess.print &amp;quot;\x1b&amp;quot;
&lt;br&gt;&lt;br&gt;?
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Net%3A%3ATelnet---How-to-send-keystrokes-like-ESC-tp26530219p26534725.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534713</id>
	<title>Re: Pattern match to fail if two periods in a row</title>
	<published>2009-11-26T12:46:06Z</published>
	<updated>2009-11-26T12:46:06Z</updated>
	<author>
		<name>Ralph Shnelvar</name>
	</author>
	<content type="html">&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;abc..def&amp;quot; !~ /\.\./
&lt;br&gt;=&amp;gt;&amp;gt; false
&lt;br&gt;&lt;br&gt;I don't think that
&lt;br&gt;&amp;nbsp; &amp;quot;abc..def&amp;quot; !~ /\.\./
&lt;br&gt;is a regular expression.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;/\.\./
&lt;br&gt;is a regular expression.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Basically ... I need something that will work in a Rails validates_format_of
&lt;br&gt;&lt;br&gt;&amp;nbsp; # Reject if the email address has two periods in a row
&lt;br&gt;&amp;nbsp; validates_format_of &amp;nbsp; &amp;nbsp; :email,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # See &lt;a href=&quot;http://en.wikipedia.org/wiki/E-mail_address&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/E-mail_address&lt;/a&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :with =&amp;gt; ????,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :message =&amp;gt; 'invalid email format'
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Pattern-match-to-fail-if-two-periods-in-a-row-tp26534209p26534713.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534580</id>
	<title>Re: Net::Telnet - How to send keystrokes like ESC</title>
	<published>2009-11-26T12:32:41Z</published>
	<updated>2009-11-26T12:32:41Z</updated>
	<author>
		<name>Ryan Davis-2</name>
	</author>
	<content type="html">&lt;br&gt;On Nov 26, 2009, at 06:28 , Babu Raj wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; Could you pls let me know how I can send in keystrokes such as ENTER and
&lt;br&gt;&amp;gt; ESC to a telnet session. I have the session created using
&lt;br&gt;&amp;gt; Net::Telnet.new().
&lt;br&gt;&lt;br&gt;Depends on what you're trying to do. Either something like this:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://groups.google.com/group/ruby-talk-google/browse_frm/thread/96cabb08c34182c/77c0843d27e95dd3?lnk=gst&amp;q=berger+password&amp;rnum=1#77c0843d27e95dd3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ruby-talk-google/browse_frm/thread/96cabb08c34182c/77c0843d27e95dd3?lnk=gst&amp;q=berger+password&amp;rnum=1#77c0843d27e95dd3&lt;/a&gt;&lt;br&gt;&lt;br&gt;or you want to look at expect.rb.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Net%3A%3ATelnet---How-to-send-keystrokes-like-ESC-tp26530219p26534580.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534413</id>
	<title>Re: Pattern match to fail if two periods in a row</title>
	<published>2009-11-26T12:14:08Z</published>
	<updated>2009-11-26T12:14:08Z</updated>
	<author>
		<name>Louis-Philippe</name>
	</author>
	<content type="html">if ! /\.{2,}/
&lt;br&gt;&lt;br&gt;or something
&lt;br&gt;&lt;br&gt;2009/11/26 Ralph Shnelvar &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26534413&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ralphs@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Ok ... I really tried. &amp;nbsp;And I used &lt;a href=&quot;http://rubular.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rubular.com/&lt;/a&gt;&amp;nbsp; (really nice)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; And I read and reread the pickaxe book section on regular
&lt;br&gt;&amp;gt; expressions.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In other words ... I tried.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So ..
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; How does one create an expression that fails if there are two or more
&lt;br&gt;&amp;gt; periods
&lt;br&gt;&amp;gt; (e.g. &amp;quot;..&amp;quot;) in a row?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Pattern-match-to-fail-if-two-periods-in-a-row-tp26534209p26534413.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534398</id>
	<title>Re: Pattern match to fail if two periods in a row</title>
	<published>2009-11-26T12:12:16Z</published>
	<updated>2009-11-26T12:12:16Z</updated>
	<author>
		<name>Jesús Gabriel y Galán</name>
	</author>
	<content type="html">On Thu, Nov 26, 2009 at 8:51 PM, Ralph Shnelvar &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26534398&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ralphs@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Ok ... I really tried.  And I used &lt;a href=&quot;http://rubular.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rubular.com/&lt;/a&gt;&amp;nbsp; (really nice)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; And I read and reread the pickaxe book section on regular
&lt;br&gt;&amp;gt; expressions.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In other words ... I tried.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So ..
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; How does one create an expression that fails if there are two or more periods
&lt;br&gt;&amp;gt; (e.g. &amp;quot;..&amp;quot;) in a row?
&lt;/div&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;abc..def&amp;quot; !~ /\.\./
&lt;br&gt;=&amp;gt; false
&lt;br&gt;&lt;br&gt;One easy way is to use the negated match operator (!~). Then the
&lt;br&gt;regexp is trivial.
&lt;br&gt;&lt;br&gt;Jesus.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Pattern-match-to-fail-if-two-periods-in-a-row-tp26534209p26534398.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26534209</id>
	<title>Pattern match to fail if two periods in a row</title>
	<published>2009-11-26T11:51:02Z</published>
	<updated>2009-11-26T11:51:02Z</updated>
	<author>
		<name>Ralph Shnelvar</name>
	</author>
	<content type="html">Ok ... I really tried. &amp;nbsp;And I used &lt;a href=&quot;http://rubular.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rubular.com/&lt;/a&gt;&amp;nbsp; (really nice)
&lt;br&gt;&lt;br&gt;And I read and reread the pickaxe book section on regular
&lt;br&gt;expressions.
&lt;br&gt;&lt;br&gt;In other words ... I tried.
&lt;br&gt;&lt;br&gt;So ..
&lt;br&gt;&lt;br&gt;How does one create an expression that fails if there are two or more periods
&lt;br&gt;(e.g. &amp;quot;..&amp;quot;) in a row?
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Pattern-match-to-fail-if-two-periods-in-a-row-tp26534209p26534209.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26532798</id>
	<title>Re: Ruby a good choice for CGI?</title>
	<published>2009-11-26T09:40:33Z</published>
	<updated>2009-11-26T09:40:33Z</updated>
	<author>
		<name>Brian Candler</name>
	</author>
	<content type="html">&amp;gt; Ok I tried sinatra. It seems like it fires up webrick on port 4567, so I 
&lt;br&gt;&amp;gt; take it there's some config file I need to mess with, or my hosting 
&lt;br&gt;&amp;gt; provider deals with so it'll run on Apache instead?
&lt;br&gt;&lt;br&gt;If you have a Rails hosting provider, they can probably host Sinatra 
&lt;br&gt;too. Both just run on top of Rack.
&lt;br&gt;&lt;br&gt;If your hosting provider uses Phusion Passenger (= mod_rails), that can 
&lt;br&gt;host Sinatra.
&lt;br&gt;&lt;a href=&quot;http://www.modrails.com/documentation/Users%20guide%20Apache.html#_sinatra&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.modrails.com/documentation/Users%20guide%20Apache.html#_sinatra&lt;/a&gt;&lt;br&gt;&lt;br&gt;If you have a totally generic hosting provider then you may be stuck 
&lt;br&gt;running your app as a cgi-bin or fastcgi (although obviously they'll 
&lt;br&gt;still have to provide you with a ruby interpreter). That may be enough 
&lt;br&gt;to get you started, but you'd probably be best changing to a different 
&lt;br&gt;hosting provider longer term.
&lt;br&gt;&lt;br&gt;I've run small fastcgi apps successfully; experience from many Rails 
&lt;br&gt;users has been that it has a tendency to explode. As a result, most ruby 
&lt;br&gt;people (and developers) are staying away from fastcgi. But it still 
&lt;br&gt;*should* be possible to build rack to work under fastcgi; see the README 
&lt;br&gt;in the rack gem. You'll need the ruby fcgi gem, which in turn depends on 
&lt;br&gt;the C fcgi library.
&lt;br&gt;&lt;br&gt;&amp;gt; Also, I can hit my sinatra ruby script from my browser, but when I tried 
&lt;br&gt;&amp;gt; to hit it from a jQuery AJAX request, I get nothing back and the sinatra 
&lt;br&gt;&amp;gt; console says that it was an OPTIONS request instead of the GET request 
&lt;br&gt;&lt;br&gt;No idea on that. It all works for me. Use tcpdump to prove or disprove 
&lt;br&gt;that jQuery is sending an OPTIONS request; that would show if it's a 
&lt;br&gt;problem with your jQuery code.
&lt;br&gt;&lt;br&gt;&amp;gt; So I can just use the Sinatra lib to route the request, deal with 
&lt;br&gt;&amp;gt; cookies and sessions, and then hand it to my hosting provider and 
&lt;br&gt;&amp;gt; they'll set it up properly?
&lt;br&gt;&lt;br&gt;Depends on how clued up and helpful your hosting provider is :-)
&lt;br&gt;&lt;br&gt;&amp;gt; if one person
&lt;br&gt;&amp;gt; requested it, it started running, hitting the db etc, and then another 
&lt;br&gt;&amp;gt; person requested it before it was finished, what happens?
&lt;br&gt;&lt;br&gt;Sinatra has a request lock turned on by default, so that the second 
&lt;br&gt;request will wait until the first completes, but you can turn it off if 
&lt;br&gt;you are sure your application is thread-safe.
&lt;br&gt;&lt;br&gt;However, running under fastcgi or mod_rails, only one request would be 
&lt;br&gt;sent at a time to your application. Therefore you will need to spawn 
&lt;br&gt;multiple processes to handle concurrent requests. This should be done 
&lt;br&gt;for you, but you may wish to tune the parameters for min/max processes 
&lt;br&gt;spawned.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-a-good-choice-for-CGI--tp26518629p26532798.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26532442</id>
	<title>Re: Ruby a good choice for CGI?</title>
	<published>2009-11-26T09:11:17Z</published>
	<updated>2009-11-26T09:11:17Z</updated>
	<author>
		<name>Nick Dr</name>
	</author>
	<content type="html">Seebs wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On 2009-11-25, Nick Dr &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26532442&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nickhannum@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; Can someone point me in the right direction here? My app is VERY small.
&lt;br&gt;&amp;gt;&amp;gt; Practically no code, no HTML output. All I need is to execute the 2 or 3
&lt;br&gt;&amp;gt;&amp;gt; Ruby functions I already have, on the net, with some basic
&lt;br&gt;&amp;gt;&amp;gt; cookie/session support. What's the least headache(and not terribly slow)
&lt;br&gt;&amp;gt;&amp;gt; way to do this?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; How many hundred thousand hits a day do you have to process?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; If the answer is &amp;quot;less than one&amp;quot;, you probably don't care much about
&lt;br&gt;&amp;gt; speed in practice.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Past that... If you want something more interesting, I am pretty happy
&lt;br&gt;&amp;gt; with rails/passenger. &amp;nbsp;Relatively low setup effort and works great, and
&lt;br&gt;&amp;gt; while it might be overkill for what you want to do, I really do find
&lt;br&gt;&amp;gt; it pretty rewarding.
&lt;/div&gt;&lt;br&gt;Well, HOPEFULLY I'm expecting a lot of hits, but these scripts will also 
&lt;br&gt;be available via a facebook app, so hopefully the time zones will spread 
&lt;br&gt;it out for me, and I'll be getting several hit per minute, 24/7, but 
&lt;br&gt;never a lot at once.
&lt;br&gt;&lt;br&gt;That brings up another question I had. Does 
&lt;br&gt;FastCGI/Mongrel/Thin/Passenger deal with multithreading for me? Like if 
&lt;br&gt;two people request an HTML page I figure it can just serve two copies of 
&lt;br&gt;it. But what about scripts? In theory my scripts only take milliseconds 
&lt;br&gt;from request to response, but just for arguments sake, if one person 
&lt;br&gt;requested it, it started running, hitting the db etc, and then another 
&lt;br&gt;person requested it before it was finished, what happens?
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-a-good-choice-for-CGI--tp26518629p26532442.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26532394</id>
	<title>Re: Ruby a good choice for CGI?</title>
	<published>2009-11-26T09:08:04Z</published>
	<updated>2009-11-26T09:08:04Z</updated>
	<author>
		<name>Paul Smith-38</name>
	</author>
	<content type="html">On Thu, Nov 26, 2009 at 5:03 PM, Nick Dr &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26532394&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nickhannum@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; =
&lt;br&gt;&amp;gt;&amp;gt; That sounds tailor-made for Sinatra. However, you should learn something
&lt;br&gt;&amp;gt;&amp;gt; about
&lt;br&gt;&amp;gt;&amp;gt; REST, first -- are you sure POST is appropriate?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Ok I tried sinatra. It seems like it fires up webrick on port 4567, so I
&lt;br&gt;&amp;gt; take it there's some config file I need to mess with, or my hosting
&lt;br&gt;&amp;gt; provider deals with so it'll run on Apache instead?
&lt;br&gt;&lt;br&gt;You can use Sinatra with JRuby to host the app via Google AppEngine,
&lt;br&gt;that seems quite elegant. &amp;nbsp;I don't know how AppEngine's pricing
&lt;br&gt;compares to your other hosting offer of course.
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://blog.bigcurl.de/2009/04/running-sinatra-apps-on-google.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blog.bigcurl.de/2009/04/running-sinatra-apps-on-google.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Paul Smith
&lt;br&gt;&lt;a href=&quot;http://www.nomadicfun.co.uk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.nomadicfun.co.uk&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26532394&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;paul@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-a-good-choice-for-CGI--tp26518629p26532394.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26532326</id>
	<title>Re: Ruby a good choice for CGI?</title>
	<published>2009-11-26T09:03:41Z</published>
	<updated>2009-11-26T09:03:41Z</updated>
	<author>
		<name>Nick Dr</name>
	</author>
	<content type="html">=
&lt;br&gt;&amp;gt; That sounds tailor-made for Sinatra. However, you should learn something 
&lt;br&gt;&amp;gt; about
&lt;br&gt;&amp;gt; REST, first -- are you sure POST is appropriate?
&lt;br&gt;&lt;br&gt;Ok I tried sinatra. It seems like it fires up webrick on port 4567, so I 
&lt;br&gt;take it there's some config file I need to mess with, or my hosting 
&lt;br&gt;provider deals with so it'll run on Apache instead?
&lt;br&gt;&lt;br&gt;Also, I can hit my sinatra ruby script from my browser, but when I tried 
&lt;br&gt;to hit it from a jQuery AJAX request, I get nothing back and the sinatra 
&lt;br&gt;console says that it was an OPTIONS request instead of the GET request 
&lt;br&gt;it reports when firefox asks for the page. What am I doing wrong here? 
&lt;br&gt;The idea was to jquery post to a ruby script for some JSON data and then 
&lt;br&gt;update my canvas based on that data.
&lt;br&gt;&lt;br&gt;&amp;gt; FastCGI is obsolete, so scratch that.
&lt;br&gt;&lt;br&gt;The host I was considering, HostingRails, says they'll do a FastCGI 
&lt;br&gt;deployment for me. I am (hopefully) expecting pretty high frequency 
&lt;br&gt;traffic. Like several hits/min 24/7, but never &amp;gt; 1000 hits per minute, 
&lt;br&gt;because this will be a global app available via facebook, so the time 
&lt;br&gt;zones should spread it out for me.
&lt;br&gt;Are you sure FastCGI isn't a good option for this?
&lt;br&gt;&lt;br&gt;&amp;gt; Passenger and mod_ruby are essentially the same thing, IIRC. But my
&lt;br&gt;&amp;gt; understanding is that Passenger works with Rack, which doesn't feel at 
&lt;br&gt;&amp;gt; all
&lt;br&gt;&amp;gt; like CGI. So these might be deployment options, but they have nothing to 
&lt;br&gt;&amp;gt; do
&lt;br&gt;&amp;gt; with how you write and develop your app.
&lt;br&gt;&lt;br&gt;So I can just use the Sinatra lib to route the request, deal with 
&lt;br&gt;cookies and sessions, and then hand it to my hosting provider and 
&lt;br&gt;they'll set it up properly?
&lt;br&gt;&lt;br&gt;Thanks for all the advice!
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-a-good-choice-for-CGI--tp26518629p26532326.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530925</id>
	<title>fft for Ruby?</title>
	<published>2009-11-26T07:20:13Z</published>
	<updated>2009-11-26T07:20:13Z</updated>
	<author>
		<name>Dalthon [BR]</name>
	</author>
	<content type="html">Anyone know any library for Ruby that implements low level fft n-
&lt;br&gt;dimensional algorithm?
&lt;br&gt;&lt;br&gt;Dalthon
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/fft-for-Ruby--tp26530925p26530925.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530547</id>
	<title>Module.nesting strangeness</title>
	<published>2009-11-26T06:53:42Z</published>
	<updated>2009-11-26T06:53:42Z</updated>
	<author>
		<name>Alexandre Mutel</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;i'm encountering a weird behavior of the Module.nesting methodd. Here is
&lt;br&gt;my testcase from the irb:
&lt;br&gt;&lt;br&gt;____________________________
&lt;br&gt;&lt;br&gt;class A
&lt;br&gt;&amp;nbsp; class B
&lt;br&gt;&amp;nbsp; &amp;nbsp; def test()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; puts &amp;quot;Module.nesting : &amp;quot; + Module.nesting * &amp;quot;,&amp;quot;
&lt;br&gt;&amp;nbsp; &amp;nbsp; end
&lt;br&gt;&amp;nbsp; end
&lt;br&gt;end
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;&lt;br&gt;b = A::B.new
&lt;br&gt;=&amp;gt; #&amp;lt;A::B:0x24102d8&amp;gt;
&lt;br&gt;&lt;br&gt;b.test
&lt;br&gt;Module.nesting : A::B,A
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;&lt;br&gt;b.instance_eval { puts &amp;quot;Module.nesting : &amp;quot; + Module.nesting * &amp;quot;,&amp;quot; }
&lt;br&gt;Module.nesting :
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;____________________________
&lt;br&gt;&lt;br&gt;The documentation says : &amp;quot;Returns the list of Modules nested at the
&lt;br&gt;point of call. &amp;quot;. But how Module.nesting in test() method knows that it
&lt;br&gt;was declared inside the class A/classB and not outside?
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Module.nesting-strangeness-tp26530547p26530547.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530422</id>
	<title>Re: problem with gempath</title>
	<published>2009-11-26T06:45:11Z</published>
	<updated>2009-11-26T06:45:11Z</updated>
	<author>
		<name>jney</name>
	</author>
	<content type="html">Just fix it.
&lt;br&gt;GEM_PATH env var was set by rvm (&lt;a href=&quot;http://rvm.beginrescueend.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rvm.beginrescueend.com/&lt;/a&gt;).
&lt;br&gt;&lt;br&gt;On 18 nov, 19:21, jney &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26530422&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeansebastien....@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi jan-Erik, i should precise that, gempath isn't define in my
&lt;br&gt;&amp;gt; ~/.gemrc
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On 18 nov, 18:53, Jan-Erik Rediger &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26530422&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;bad...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; On Thu, Nov 19, 2009 at 02:40:06AM +0900, jney wrote:
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; hi, I recently got problem with installing gem. when i execute &amp;quot;gem
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; install xxx&amp;quot; it install to the current directory.
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; here is what i've got when i execute &amp;quot;gem env&amp;quot;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;   - GEM PATHS:
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;      -
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;      - /Users/jsney/.gem/ruby/1.8
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;      - /opt/local/lib/ruby/gems/1.8
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; i don't know how to remove the first record. anyone can help ?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; if it is in your ~/.gemrc then editing this file should help
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; badboy_
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;Just fix it.
&lt;br&gt;GEM_PATH env var was set by rvm (&lt;a href=&quot;http://rvm.beginrescueend.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://rvm.beginrescueend.com/&lt;/a&gt;).
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/problem-with-gempath-tp26412300p26530422.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530335</id>
	<title>creating certificates and public and private keys</title>
	<published>2009-11-26T06:37:10Z</published>
	<updated>2009-11-26T06:37:10Z</updated>
	<author>
		<name>Adam Akhtar</name>
	</author>
	<content type="html">Hi im going to have to create a lot of public and private keys for
&lt;br&gt;clients and would like to automate the process by using a script (in
&lt;br&gt;ruby of course).
&lt;br&gt;&lt;br&gt;This is for an openvpn setup and currently ive been MANUALY creating
&lt;br&gt;keys with the easy-rsa bat file that comes with it but id like to
&lt;br&gt;automate it.
&lt;br&gt;&lt;br&gt;Is there a ruby libary available that would allow me to create public
&lt;br&gt;and private keys if i already have a CA. Would openvpn recognize these
&lt;br&gt;keys (are keys, keys no matter what language they are created in??? im
&lt;br&gt;not hot on cryptology)
&lt;br&gt;&lt;br&gt;The other option would be to just execute the bat file from my ruby
&lt;br&gt;script and simulate the keyboard to respond to the various prompts. I
&lt;br&gt;havent doent this before so im not sure if this is easier or harder than
&lt;br&gt;above. Any tips or pointers will really help!
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/creating-certificates-and-public-and-private-keys-tp26530335p26530335.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530321</id>
	<title>Re: Ruby a good choice for CGI?</title>
	<published>2009-11-26T06:33:31Z</published>
	<updated>2009-11-26T06:33:31Z</updated>
	<author>
		<name>Marnen Laibow-Koser</name>
	</author>
	<content type="html">Brian Candler wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Marnen Laibow-Koser wrote:
&lt;br&gt;&amp;gt;&amp;gt; And running multiple Rails apps with one Passenger installation is 
&lt;br&gt;&amp;gt;&amp;gt; likwise a breeze.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; - although there's some possibility for interaction between them. In 
&lt;br&gt;&amp;gt; particular, PassengerUseGlobalQueue gives one global queue across all 
&lt;br&gt;&amp;gt; apps, rather than one queue per application. Also, 
&lt;br&gt;&amp;gt; PassengerMaxInstancesPerApp can only be set globally rather than per 
&lt;br&gt;&amp;gt; app.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; At least it was like that last time I enquired, but the current 
&lt;br&gt;&amp;gt; documentation suggests this is still the case.
&lt;/div&gt;&lt;br&gt;I think it may not be, but don't quote me. :)
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;--
&lt;br&gt;Marnen Laibow-Koser
&lt;br&gt;&lt;a href=&quot;http://www.marnen.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.marnen.org&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26530321&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;marnen@...&lt;/a&gt;
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-a-good-choice-for-CGI--tp26518629p26530321.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26530219</id>
	<title>Net::Telnet - How to send keystrokes like ESC</title>
	<published>2009-11-26T06:28:23Z</published>
	<updated>2009-11-26T06:28:23Z</updated>
	<author>
		<name>Babu Raj</name>
	</author>
	<content type="html">Hi
&lt;br&gt;Could you pls let me know how I can send in keystrokes such as ENTER and
&lt;br&gt;ESC to a telnet session. I have the session created using
&lt;br&gt;Net::Telnet.new().
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Net%3A%3ATelnet---How-to-send-keystrokes-like-ESC-tp26530219p26530219.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26529966</id>
	<title>Re: DRB class in array</title>
	<published>2009-11-26T06:09:06Z</published>
	<updated>2009-11-26T06:09:06Z</updated>
	<author>
		<name>Brian Candler</name>
	</author>
	<content type="html">Master Marv wrote:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; include DRbUndumped
&lt;br&gt;&amp;gt; this seems to let the class reside wherever it has been generated.
&lt;br&gt;&amp;gt; is it possible to generate a class on a drb client, copy it to the 
&lt;br&gt;&amp;gt; server and then let it stay there (ie. further interaction with the 
&lt;br&gt;&amp;gt; class should be made with the the class on the server and not with local 
&lt;br&gt;&amp;gt; copies).
&lt;br&gt;&lt;br&gt;DRb has no real concept of a &amp;quot;server&amp;quot; or a &amp;quot;client&amp;quot; - connections can be 
&lt;br&gt;opened and method calls made from either side.
&lt;br&gt;&lt;br&gt;You could originate your object, pass it across to another place, and at 
&lt;br&gt;that point do
&lt;br&gt;&amp;nbsp; &amp;nbsp; obj.extend DRbUndumped
&lt;br&gt;which will lock it there.
&lt;br&gt;&lt;br&gt;But perhaps more sensible is to pass across the *parameters* needed to 
&lt;br&gt;make the object, i.e. have a class method on the server such as
&lt;br&gt;&lt;br&gt;&amp;nbsp; def Foo.make_status(*args)
&lt;br&gt;&amp;nbsp; &amp;nbsp; IEB_wrapper1.new(*args)
&lt;br&gt;&amp;nbsp; end
&lt;br&gt;&lt;br&gt;and you share the Foo object via DRb.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/DRB-class-in-array-tp26527093p26529966.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26529650</id>
	<title>Heatmaps in Ruby</title>
	<published>2009-11-26T05:43:29Z</published>
	<updated>2009-11-26T05:43:29Z</updated>
	<author>
		<name>Marc Hoeppner</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I am currently thinking about doing a heatmap for data visualization,
&lt;br&gt;but I have very little experience with any type of graphical tools in
&lt;br&gt;ruby (like the various SVG libs etc).
&lt;br&gt;&lt;br&gt;So I was hoping someone could point me in the right direction and save
&lt;br&gt;me some time trying out useless libraries ;) Doesn't have to be ruby
&lt;br&gt;either, but that way I could probably integrate it more easily into my
&lt;br&gt;analysis pipeline.
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;&lt;br&gt;Marc
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Heatmaps-in-Ruby-tp26529650p26529650.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26529190</id>
	<title>Re: DRB class in array</title>
	<published>2009-11-26T05:06:56Z</published>
	<updated>2009-11-26T05:06:56Z</updated>
	<author>
		<name>Master Marv</name>
	</author>
	<content type="html">&amp;gt; &amp;nbsp; include DRbUndumped
&lt;br&gt;this seems to let the class reside wherever it has been generated.
&lt;br&gt;is it possible to generate a class on a drb client, copy it to the 
&lt;br&gt;server and then let it stay there (ie. further interaction with the 
&lt;br&gt;class should be made with the the class on the server and not with local 
&lt;br&gt;copies).
&lt;br&gt;&lt;br&gt;what i want to do is the following:
&lt;br&gt;i have a class that has a run and a status function. when the run 
&lt;br&gt;function is invoked the class computes something for ~5minutes.
&lt;br&gt;the calculation should happen on the drb server.
&lt;br&gt;multiple drb clients should generate classes on the server(or locally 
&lt;br&gt;and copy them to the server), so that the server does the computation. 
&lt;br&gt;after the jobs have been started (remote_job_array[x].start) the clients 
&lt;br&gt;terminate. other clients that should check the status of the computation 
&lt;br&gt;via a status function (remote_job_array[x].status) of the class on the 
&lt;br&gt;server.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/DRB-class-in-array-tp26527093p26529190.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26529141</id>
	<title>Net::SSH and STDIN / Pending jobs</title>
	<published>2009-11-26T05:01:27Z</published>
	<updated>2009-11-26T05:01:27Z</updated>
	<author>
		<name>Felipe Gonçalves Coury</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I am writing a library that allows the user to run some commands over
&lt;br&gt;SSH into a server and I have two problems right now:
&lt;br&gt;&lt;br&gt;1) The code get stuck whenever the executed code needs STDIN, it just
&lt;br&gt;sits there. How can I indicate that my STDIN is not interactive using
&lt;br&gt;Net::SSH?
&lt;br&gt;&lt;br&gt;2) When the user runs background jobs (like nohup
&lt;br&gt;/etc/init.d/start-something &amp;) the script just sits there as well,
&lt;br&gt;waiting for jobs to finish.
&lt;br&gt;&lt;br&gt;Considering the script that is executed is a user input and, being so, I
&lt;br&gt;don't have control over it, what would be the best way to avoid those 2
&lt;br&gt;issues?
&lt;br&gt;&lt;br&gt;Thanks a lot!
&lt;br&gt;&lt;br&gt;Best regards,
&lt;br&gt;Felipe.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;-- 
&lt;br&gt;Felipe Gonçalves Coury
&lt;br&gt;Software Engineer and Java Specialist
&lt;br&gt;contact@felipecoury.com
&lt;br&gt;Mobile: +55 19 9305-3619
&lt;br&gt;Home: +55 19 3307-2982
&lt;br&gt;&lt;br&gt;Hey, visit my blogs:
&lt;br&gt;&lt;a href=&quot;http://blogs.felipecoury.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blogs.felipecoury.com&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;http://felipecoury.wordpress.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://felipecoury.wordpress.com&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Net%3A%3ASSH-and-STDIN---Pending-jobs-tp26529141p26529141.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26528841</id>
	<title>Re: Mocha multiple_yields with arrays</title>
	<published>2009-11-26T04:36:17Z</published>
	<updated>2009-11-26T04:36:17Z</updated>
	<author>
		<name>floehopper</name>
	</author>
	<content type="html">2009/11/26 Raymond O'Connor &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26528841&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nappin713@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; I believe there's a bug in mocha that causes an unnecessary and annoying
&lt;br&gt;&amp;gt; warning message.  If you call multiple_yields with arrays as the arg you
&lt;br&gt;&amp;gt; want yielded it will complain.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; object.multiple_yields([1,2], [3,4], [5,6])
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; =&amp;gt; prints a warning to the effect: &amp;quot;multiple values for a block
&lt;br&gt;&amp;gt; parameter 2 for 1&amp;quot;
&lt;br&gt;&lt;br&gt;That code snippet looks wrong. The multiple_yields method is a method
&lt;br&gt;on an expectation, so you must call it on the result of e.g.
&lt;br&gt;object.stubs or object.expects. I suspect this was a typo and assume
&lt;br&gt;you meant something more like this :-
&lt;br&gt;&lt;br&gt;&amp;nbsp; object.stubs(:wibble).multiple_yields([1,2], [3,4], [5,6])
&lt;br&gt;&lt;br&gt;In this case, Mocha will invoke the block supplied to the wibble
&lt;br&gt;method 3 times and passing in 2 parameters on each invocation.
&lt;br&gt;&lt;br&gt;If you supply a block which defines only one parameter you will see
&lt;br&gt;the warning you described :-
&lt;br&gt;&lt;br&gt;&amp;nbsp; parameters = []
&lt;br&gt;&amp;nbsp; object.wibble { |parameter| parameters &amp;lt;&amp;lt; parameter }
&lt;br&gt;&amp;nbsp; # =&amp;gt; warning: multiple values for a block parameter (2 for 1)
&lt;br&gt;&amp;nbsp; p parameters # =&amp;gt; [[1,2], [3,4], [5,6]]
&lt;br&gt;&lt;br&gt;If you supply a block which defines two parameters you will not see
&lt;br&gt;the warning :-
&lt;br&gt;&lt;br&gt;&amp;nbsp; parameters = []
&lt;br&gt;&amp;nbsp; object.wibble { |parameter_1, parameter_2| parameters &amp;lt;&amp;lt;
&lt;br&gt;[parameter_1, parameter_2] }
&lt;br&gt;&amp;nbsp; p parameters # =&amp;gt; [[1,2], [3,4], [5,6]]
&lt;br&gt;&lt;br&gt;So the warning you are seeing is not a problem with Mocha, but due to
&lt;br&gt;normal Ruby behaviour which you can see in irb :-
&lt;br&gt;&lt;br&gt;irb&amp;gt; def wibble
&lt;br&gt;irb&amp;gt; &amp;nbsp; yield(1,2)
&lt;br&gt;irb&amp;gt; end
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;irb&amp;gt; wibble { |x| p x }
&lt;br&gt;(irb):4: warning: multiple values for a block parameter (2 for 1)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from (irb):2
&lt;br&gt;[1, 2]
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;irb&amp;gt; wibble { |x,y| p [x,y] }
&lt;br&gt;[1, 2]
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;irb&amp;gt; wibble { |(x,y)| p [x,y] }
&lt;br&gt;[1, 2]
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;&lt;br&gt;I hope this helps. If you have any further questions about this,
&lt;br&gt;please post to the Mocha mailing list [1] which would be a more
&lt;br&gt;appropriate forum.
&lt;br&gt;&lt;br&gt;Cheers, James.
&lt;br&gt;&lt;br&gt;[1] &lt;a href=&quot;http://groups.google.com/group/mocha-developer&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/mocha-developer&lt;/a&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Mocha-multiple_yields-with-arrays-tp26523073p26528841.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26527959</id>
	<title>Re: Distinct Sets (#225)</title>
	<published>2009-11-26T03:22:14Z</published>
	<updated>2009-11-26T03:22:14Z</updated>
	<author>
		<name>Benoit Daloze</name>
	</author>
	<content type="html">Here is my array-based combination solution:
&lt;br&gt;&lt;br&gt;def multiple(start)
&lt;br&gt;&amp;nbsp; &amp;nbsp; sets = start.uniq
&lt;br&gt;&amp;nbsp; &amp;nbsp; while (f=sets.flatten) &amp;&amp; f != f.uniq
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sets.combination(2) { |(a, b)|
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if sets.include?(a) &amp;&amp; sets.include?(b) &amp;&amp; a != b &amp;&amp; (a &amp;
&lt;br&gt;b).length &amp;gt; 0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # include? ensure the set has not been mixed with another
&lt;br&gt;one already
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # a != b ensure we are not playing with a == b, what would
&lt;br&gt;delete a (and b) or not find the index
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sets[sets.index(a)] = (a | b)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sets.delete(b)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; end
&lt;br&gt;&amp;nbsp; &amp;nbsp; sets.map { |s| s.sort }
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;It just combinate by 2 sets, and look if they can merge.
&lt;br&gt;The while loop is then rarely met, because sets merge 2 by 2.
&lt;br&gt;&lt;br&gt;This solution is quite fast for small sets(as I said before, 0.22 for the
&lt;br&gt;first test), but is completely out for larger sets.
&lt;br&gt;&lt;br&gt;This is another, using Array#partition to modify itself, while merging all
&lt;br&gt;the elements with the common value in one iteration
&lt;br&gt;&lt;br&gt;def better(start)
&lt;br&gt;&amp;nbsp; &amp;nbsp; sets = start.dup
&lt;br&gt;&amp;nbsp; &amp;nbsp; f = sets.flatten
&lt;br&gt;&amp;nbsp; &amp;nbsp; (f.uniq.select { |e| f.count(e)&amp;gt;1 }).each { |reducing_on|
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = sets.index { |set| set.include? reducing_on }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sets2merge, sets = sets.partition { |set| set.include? reducing_on }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sets.insert( i, sets2merge.inject(:|) )
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; sets.map { |s| s.sort }
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;2009/11/26 lith &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26527959&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;minilith@...&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; Here is a graph-based approach:
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt;&lt;a href=&quot;http://pastie.org/714759&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://pastie.org/714759&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Running the small approximative benchmark:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Here is a modified version that should have slightly improved runtime
&lt;br&gt;&amp;gt; characteristics:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://pastie.org/715755&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://pastie.org/715755&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Regards,
&lt;br&gt;&amp;gt; Tom
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-QUIZ--Distinct-Sets-%28-225%29-tp26453165p26527959.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26527376</id>
	<title>Re: DRB class in array</title>
	<published>2009-11-26T02:30:57Z</published>
	<updated>2009-11-26T02:30:57Z</updated>
	<author>
		<name>Brian Candler</name>
	</author>
	<content type="html">Master Marv wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; if a client modifies the status variable of a class instance in the
&lt;br&gt;&amp;gt; array it does not get changed.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; dump = DRbObject.new nil, ARGV.shift
&lt;br&gt;&amp;gt; myclass = IEB_wrapper1.new
&lt;br&gt;&amp;gt; dump.push myclass
&lt;br&gt;&amp;gt; dump[0].status = &amp;quot;Hello&amp;quot;
&lt;br&gt;&amp;gt; p dump[0].status =&amp;gt; results in &amp;quot;ready&amp;quot; not in &amp;quot;Hello&amp;quot;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; how can i modify the status of my class in the array on the drb server?
&lt;/div&gt;&lt;br&gt;class IEB_wrapper1
&lt;br&gt;&amp;nbsp; include DRbUndumped
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;This means that instead of passing across a *copy* of the object (made 
&lt;br&gt;using Marshal.dump and load), it will pass across a DRb *proxy object*. 
&lt;br&gt;All operations made on that proxy are sent across as remote method calls 
&lt;br&gt;and therefore made on the server.
&lt;br&gt;&lt;br&gt;I wrote a document called &amp;quot;DrbTutorial&amp;quot; on rubygarden.org, which 
&lt;br&gt;unfortunately is long since gone. You might be able to find a cached 
&lt;br&gt;copy somewhere.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/DRB-class-in-array-tp26527093p26527376.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26527190</id>
	<title>Re: Difference between &lt;&lt; and += for Strings and Arrays. Bug?</title>
	<published>2009-11-26T02:16:40Z</published>
	<updated>2009-11-26T02:16:40Z</updated>
	<author>
		<name>Robert Klemme-2</name>
	</author>
	<content type="html">2009/11/26 Robert Klemme &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26527190&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;shortcutter@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt; As far as I can see you only need an inclusion check not the complete
&lt;br&gt;&amp;gt; list of ancestors.  A simple iterative solution with a BFS could do
&lt;br&gt;&amp;gt; the job for you
&lt;br&gt;&lt;br&gt;Here's a more modularized version:
&lt;br&gt;&lt;br&gt;require 'set'
&lt;br&gt;&lt;br&gt;def ancestor_bfs
&lt;br&gt;&amp;nbsp;visited = Set.new
&lt;br&gt;&amp;nbsp;queue = [self]
&lt;br&gt;&lt;br&gt;&amp;nbsp;until queue.empty?
&lt;br&gt;&amp;nbsp; &amp;nbsp;n = queue.shift
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;if visited.add? n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;yield n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;queue.concat(n.ancestors)
&lt;br&gt;&amp;nbsp; &amp;nbsp;end
&lt;br&gt;&amp;nbsp;end
&lt;br&gt;&lt;br&gt;&amp;nbsp;false
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;def ancestor?(candidate)
&lt;br&gt;&amp;nbsp; ancestor_bfs {|n| return true if candidate == n}
&lt;br&gt;&amp;nbsp; false
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;# or even without a method but still fast exit when the node is found:
&lt;br&gt;folder.to_enum(:ancestor_bfs).any? {|n| candidate == n}
&lt;br&gt;&lt;br&gt;# fully modularized
&lt;br&gt;&lt;br&gt;def bfs(next_meth, start = self)
&lt;br&gt;&amp;nbsp;visited = Set.new
&lt;br&gt;&amp;nbsp;queue = [start]
&lt;br&gt;&lt;br&gt;&amp;nbsp;until queue.empty?
&lt;br&gt;&amp;nbsp; &amp;nbsp;n = queue.shift
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;if visited.add? n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;yield n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;queue.concat(n.send(next_meth))
&lt;br&gt;&amp;nbsp; &amp;nbsp;end
&lt;br&gt;&amp;nbsp;end
&lt;br&gt;&lt;br&gt;&amp;nbsp;false
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;def bfs_ancestors(&amp;b)
&lt;br&gt;&amp;nbsp; bfs(:ancestors, &amp;b)
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;Now you can do
&lt;br&gt;&lt;br&gt;class Integer
&lt;br&gt;&amp;nbsp; def n; [self * 2, self * 2 + 1] end
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;irb(main):057:0&amp;gt; bfs(:n, 3) {|x| p x; break if x &amp;gt; 20}
&lt;br&gt;3
&lt;br&gt;6
&lt;br&gt;7
&lt;br&gt;12
&lt;br&gt;13
&lt;br&gt;14
&lt;br&gt;15
&lt;br&gt;24
&lt;br&gt;=&amp;gt; nil
&lt;br&gt;irb(main):058:0&amp;gt;
&lt;br&gt;&lt;br&gt;:-)
&lt;br&gt;&lt;br&gt;Cheers
&lt;br&gt;&lt;br&gt;robert
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;remember.guy do |as, often| as.you_can - without end
&lt;br&gt;&lt;a href=&quot;http://blog.rubybestpractices.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blog.rubybestpractices.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Difference-between-%3C%3C-and-%2B%3D-for-Strings-and-Arrays.-Bug--tp26497230p26527190.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26527093</id>
	<title>DRB class in array</title>
	<published>2009-11-26T02:08:02Z</published>
	<updated>2009-11-26T02:08:02Z</updated>
	<author>
		<name>Master Marv</name>
	</author>
	<content type="html">hi,
&lt;br&gt;i would like to store an array of this very simple class on a drb server
&lt;br&gt;&lt;br&gt;class IEB_wrapper1
&lt;br&gt;&amp;nbsp;attr_accessor :status
&lt;br&gt;&lt;br&gt;&amp;nbsp;def initialize
&lt;br&gt;&amp;nbsp; @status=&amp;quot;ready&amp;quot;
&lt;br&gt;&amp;nbsp;end
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;the object on the drb server is an array:
&lt;br&gt;dump=[]
&lt;br&gt;DRb.start_service &amp;quot;druby://BLA:55555&amp;quot;, dump
&lt;br&gt;&lt;br&gt;&lt;br&gt;if a client modifies the status variable of a class instance in the
&lt;br&gt;array it does not get changed.
&lt;br&gt;&lt;br&gt;dump = DRbObject.new nil, ARGV.shift
&lt;br&gt;myclass = IEB_wrapper1.new
&lt;br&gt;dump.push myclass
&lt;br&gt;dump[0].status = &amp;quot;Hello&amp;quot;
&lt;br&gt;p dump[0].status =&amp;gt; results in &amp;quot;ready&amp;quot; not in &amp;quot;Hello&amp;quot;
&lt;br&gt;&lt;br&gt;how can i modify the status of my class in the array on the drb server?
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/DRB-class-in-array-tp26527093p26527093.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26527086</id>
	<title>Re: Ruby gem , require and version problem</title>
	<published>2009-11-26T02:07:06Z</published>
	<updated>2009-11-26T02:07:06Z</updated>
	<author>
		<name>Ryan Davis-2</name>
	</author>
	<content type="html">&lt;br&gt;On Nov 26, 2009, at 00:59 , Marc Hoeppner wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; require 'rubygems'
&lt;br&gt;&amp;gt; gem 'ruby-foo-bar', '0.9.2'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; That doesn't throw an error, but the game is apparently not loaded as
&lt;br&gt;&amp;gt; the modules and classes are not recognized subsequently.
&lt;br&gt;&lt;br&gt;gem doesn't load any files, it just activates the right gem.
&lt;br&gt;&lt;br&gt;require 'rubygems'
&lt;br&gt;gem 'ruby-foo-bar', '0.9.2'
&lt;br&gt;require 'bar'
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Ruby-gem-%2C-require-and-version-problem-tp26526397p26527086.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26526634</id>
	<title>Re: Difference between &lt;&lt; and += for Strings and Arrays. Bug?</title>
	<published>2009-11-26T01:28:24Z</published>
	<updated>2009-11-26T01:28:24Z</updated>
	<author>
		<name>Robert Klemme-2</name>
	</author>
	<content type="html">2009/11/26 Pieter Hugo &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26526634&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;pieter@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi Robert (and everyone else) - thanks for the well reasoned responses.
&lt;br&gt;&amp;gt; I'll get the hang of it I'm sure
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Why do you want to have two copies of your Array?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a setup where I have Folder objects. A folder can have many other
&lt;br&gt;&amp;gt; children (members) as sub folders, but it can also have many other
&lt;br&gt;&amp;gt; folders as parents (groups it belongs to). I get this done via a
&lt;br&gt;&amp;gt; crosslink table. When creating a new parent-child relationship I need to
&lt;br&gt;&amp;gt; make sure that the child is not somehow an ancestor or the parent I am
&lt;br&gt;&amp;gt; trying to subordinate it to (as I need to avoid circular reference)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So I wrote the folder function:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  def ancestors
&lt;br&gt;&amp;gt;    ancestors = self.groups  #all the immediate parents are obviously
&lt;br&gt;&amp;gt; ancestors
&lt;br&gt;&amp;gt;  scanfolders = [] #set up a stack to iterate through,
&lt;br&gt;&amp;gt;                         #looking for grandparents etc
&lt;br&gt;&amp;gt;  scanfolders += ancestors #the stack starts with the current ancestors
&lt;br&gt;&amp;gt;  if !scanfolders.nil? then
&lt;br&gt;&amp;gt;    while scanfolders.length &amp;gt; 0 do # while there are items on the stack
&lt;br&gt;&amp;gt;      scanitem = scanfolders.pop # get the last one and reduce the stack
&lt;br&gt;&amp;gt;      if scanitem then
&lt;br&gt;&amp;gt;        if !scanitem.groups.nil? then #if this item has parents
&lt;br&gt;&amp;gt;                                            #add them to the stack
&lt;br&gt;&amp;gt;         scanfolders += scanitem.groups
&lt;br&gt;&amp;gt;         scanfolders.uniq!
&lt;br&gt;&amp;gt;         ancestors += scanitem.groups #and record this item as an
&lt;br&gt;&amp;gt;                                            #ancestor
&lt;br&gt;&amp;gt;         ancestors.uniq!
&lt;br&gt;&amp;gt;        end
&lt;br&gt;&amp;gt;      end
&lt;br&gt;&amp;gt;    end
&lt;br&gt;&amp;gt;  end
&lt;br&gt;&amp;gt;  return ancestors
&lt;br&gt;&amp;gt;  end
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; So - to answer the question - I need to arrays that are initially the
&lt;br&gt;&amp;gt; same (direct parents), But the one will eventually contain all ancestors
&lt;br&gt;&amp;gt; and the other will be empty after iterating through all ancestors and
&lt;br&gt;&amp;gt; testing them for further ancestors.
&lt;/div&gt;&lt;br&gt;As far as I can see you only need an inclusion check not the complete
&lt;br&gt;list of ancestors. &amp;nbsp;A simple iterative solution with a BFS could do
&lt;br&gt;the job for you
&lt;br&gt;&lt;br&gt;require 'set'
&lt;br&gt;&lt;br&gt;def ancestor?(candidate)
&lt;br&gt;&amp;nbsp; visited = Set.new
&lt;br&gt;&amp;nbsp; queue = [self]
&lt;br&gt;&lt;br&gt;&amp;nbsp; until queue.empty?
&lt;br&gt;&amp;nbsp; &amp;nbsp; n = queue.shift
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if visited.add? n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return true if candidate == n
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; queue.concat(n.ancestors)
&lt;br&gt;&amp;nbsp; &amp;nbsp; end
&lt;br&gt;&amp;nbsp; end
&lt;br&gt;&lt;br&gt;&amp;nbsp; false
&lt;br&gt;end
&lt;br&gt;&lt;br&gt;Note: I prefer a BFS over a DFS in these cases because the stack depth
&lt;br&gt;is far more limited than the memory:
&lt;br&gt;&lt;br&gt;10:26:50 ~$ ruby19 -e 'def r(x) p x; r(x+1) end; r 0' | tail -3
&lt;br&gt;-e:1:in `r': stack level too deep (SystemStackError)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... 8175 levels...
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `&amp;lt;main&amp;gt;'
&lt;br&gt;8184
&lt;br&gt;8185
&lt;br&gt;8186
&lt;br&gt;10:27:04 ~$ ruby -e 'def r(x) p x; r(x+1) end; r 0' | tail -3
&lt;br&gt;-e:1:in `inspect': stack level too deep (SystemStackError)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `p'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1:in `r'
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; from -e:1
&lt;br&gt;12623
&lt;br&gt;12624
&lt;br&gt;12625
&lt;br&gt;10:27:08 ~$
&lt;br&gt;&lt;br&gt;&lt;br&gt;Kind regards
&lt;br&gt;&lt;br&gt;robert
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Breadth-first_search&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://en.wikipedia.org/wiki/Breadth-first_search&lt;/a&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;remember.guy do |as, often| as.you_can - without end
&lt;br&gt;&lt;a href=&quot;http://blog.rubybestpractices.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://blog.rubybestpractices.com/&lt;/a&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Difference-between-%3C%3C-and-%2B%3D-for-Strings-and-Arrays.-Bug--tp26497230p26526634.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26526528</id>
	<title>Re: Difference between &lt;&lt; and += for Strings and Arrays. Bug?</title>
	<published>2009-11-26T01:17:22Z</published>
	<updated>2009-11-26T01:17:22Z</updated>
	<author>
		<name>Brian Candler</name>
	</author>
	<content type="html">Pieter Hugo wrote:
&lt;br&gt;&amp;gt; So I wrote the folder function:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; def ancestors
&lt;br&gt;&lt;br&gt;For me the natural way to do this would be recursively, but an iterative 
&lt;br&gt;solution is of course fine, and probably more efficient anyway.
&lt;br&gt;&lt;br&gt;As for your problem of not modifying the 'groups' array you are looking 
&lt;br&gt;at, I'd suggest:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; scanfolders = []
&lt;br&gt;&amp;nbsp; &amp;nbsp; scanfolders.concat(ancestors)
&lt;br&gt;&amp;nbsp; &amp;nbsp; ...
&lt;br&gt;&amp;nbsp; &amp;nbsp; scanfolders.concat(scanitem.groups)
&lt;br&gt;&lt;br&gt;This creates a new array (scanfolders), then mutates that array by 
&lt;br&gt;tacking on the contents of some other array, without modifying that 
&lt;br&gt;other array. The first two lines could also be scanfolders = 
&lt;br&gt;ancestors.dup of course.
&lt;br&gt;&lt;br&gt;Not that there's anything really wrong with scanfolders += foo. It's 
&lt;br&gt;just that if you're going to be mutating this array (with pop), then you 
&lt;br&gt;might as well go for mutation across the board. It's also more efficient 
&lt;br&gt;if this array becomes large, as there's less array copying and object 
&lt;br&gt;creation going on.
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; scanfolders = [] #set up a stack to iterate through,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#looking for grandparents etc
&lt;br&gt;&amp;gt; &amp;nbsp; scanfolders += ancestors #the stack starts with the current ancestors
&lt;br&gt;&amp;gt; &amp;nbsp; if !scanfolders.nil? then
&lt;br&gt;&lt;br&gt;I observe that this condition is *always* true, since scanfolders is 
&lt;br&gt;never nil, so can be removed.
&lt;br&gt;&lt;br&gt;Other ways you can simplify your code:
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; while scanfolders.length &amp;gt; 0 do # while there are items on the stack
&lt;br&gt;&lt;br&gt;one option: &amp;nbsp;until scanfolders.empty?
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; while scanfolders.length &amp;gt; 0 do # while there are items on the stack
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanitem = scanfolders.pop # get the last one and reduce the stack
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if scanitem then
&lt;br&gt;&lt;br&gt;If your scanfolders never contains any nil items (and I don't see why it 
&lt;br&gt;should), then all three lines could shrink to
&lt;br&gt;&lt;br&gt;&amp;nbsp; while scanitem = scanfolders.pop
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if !scanitem.groups.nil? then #if this item has parents
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #add them to the stack
&lt;br&gt;&lt;br&gt;&amp;nbsp; if scanitem.groups
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanfolders += scanitem.groups
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanfolders.uniq!
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ancestors += scanitem.groups #and record this item as an
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #ancestor
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ancestors.uniq!
&lt;br&gt;&lt;br&gt;The problem I see here is that you might already have scanned a folder 
&lt;br&gt;and popped it from scanfolders, then add it back again, therefore 
&lt;br&gt;scanning it extra times unnecessarily. I can't convince myself whether 
&lt;br&gt;there is a possibility of ending up in an infinite loop.
&lt;br&gt;&lt;br&gt;One solution is to keep an explicit mark of folders you have traversed 
&lt;br&gt;(e.g. a hash of folder =&amp;gt; true)
&lt;br&gt;&lt;br&gt;But since everything you've added to scanfolders has been added to 
&lt;br&gt;ancestors already, it may be sufficient to do:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; scanfolders += scanitem.groups
&lt;br&gt;&amp;nbsp; &amp;nbsp; scanfolders -= ancestors
&lt;br&gt;&amp;nbsp; &amp;nbsp; ancestors += scanitem.groups
&lt;br&gt;&lt;br&gt;Or something like that. Actually I'm not sure if there's a mutating 
&lt;br&gt;version of -=
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&lt;br&gt;Brian.
&lt;br&gt;-- 
&lt;br&gt;Posted via &lt;a href=&quot;http://www.ruby-forum.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.ruby-forum.com/&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Difference-between-%3C%3C-and-%2B%3D-for-Strings-and-Arrays.-Bug--tp26497230p26526528.html" />
</entry>

</feed>
