<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2559395734336150066</id><updated>2011-10-10T02:13:13.011-07:00</updated><category term='subversion svn cannot create directory tmp'/><title type='text'>Ruby Solutions</title><subtitle type='html'>Solutions to ruby programming issues that I encounter.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-6994364174689594745</id><published>2009-01-30T12:11:00.000-08:00</published><updated>2009-02-02T16:35:35.544-08:00</updated><title type='text'>Compiling ruby with debug symbols in windows</title><content type='html'>I want to use gdb to debug an application that embeds the ruby dll. I was running into the problem that the ruby configure scripts and makefile were stripping out debug symbols during the make process.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_YsVH0tTzKZY/SYSPqvT__7I/AAAAAAAACLE/lS0k4uikQFk/s1600-h/Capture-1.jpg"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 320px; height: 299px;" src="http://4.bp.blogspot.com/_YsVH0tTzKZY/SYSPqvT__7I/AAAAAAAACLE/lS0k4uikQFk/s320/Capture-1.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5297517026112176050" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The problem is the "-s" parameter, marked by the light blue box above.&lt;br /&gt;&lt;br /&gt;I ended up having to manually edit the files "Makefile" and "config.status". The "-s" part in "-shared $(if $(filter-out -g -g0,$(debugflags)),,-s)" needs to be deleted.&lt;br /&gt;&lt;br /&gt;I wonder if there is a better way to do this.&lt;br /&gt;&lt;br /&gt;UPDATE (2/2/2009):&lt;br /&gt;&lt;br /&gt;I posted this question to ruby-core and Nobuyoshi Nakada responded: I have to add the 'debugflags' command line option to the configure script and the "-s" parameter goes away:&lt;br /&gt;&lt;br /&gt;./configure --enable-shared --disable-install-doc optflags="-O0" debugflags="-g3 -ggdb"&lt;br /&gt;make&lt;br /&gt;&lt;br /&gt;More info from the ruby-core thread:&lt;br /&gt;http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/21769&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-6994364174689594745?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/6994364174689594745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=6994364174689594745' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/6994364174689594745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/6994364174689594745'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2009/01/compiling-ruby-with-debug-symbols-in.html' title='Compiling ruby with debug symbols in windows'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_YsVH0tTzKZY/SYSPqvT__7I/AAAAAAAACLE/lS0k4uikQFk/s72-c/Capture-1.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-3001779210419048638</id><published>2008-12-11T11:58:00.000-08:00</published><updated>2008-12-11T12:14:16.171-08:00</updated><title type='text'>The Best Ruby/SVN IDE setup for Hardy Heron</title><content type='html'>After experimenting with Aptana, Ganymede/Eclipse, the Ubuntu Eclipse package, and Netbeans on Ubuntu Hardy Heron 8.04, I came up with the following conclusions.&lt;br /&gt;&lt;br /&gt;Aptana:&lt;br /&gt;&lt;br /&gt;  * It does too much -- there are lots of plugins that pop up by default, and every once in a while you get annoyed by interactive ruby consoles and windows that want you to install various gems.&lt;br /&gt;  * The CSS editor and JS editors are slow on large files&lt;br /&gt;  * Otherwise, it's a great IDE -- with good SVN support (subclipse) and good ruby hilighting (RDT)&lt;br /&gt;&lt;br /&gt;Ganymede/Eclipse:&lt;br /&gt;&lt;br /&gt;  * I got the latest version (3.4) and installed dynamic languages support and subversive (which is now the default SVN plugin).&lt;br /&gt;  * The subversive commit window fetches from the repository when doing diffs -- way too slow.&lt;br /&gt;  * I ran into an occasional and hard-to-reproduce bug where funky characters were inserted at the end of a line instead of a real line break (when cutting/pasting)&lt;br /&gt;  * Dynamic languages support screws up auto-indenting&lt;br /&gt;&lt;br /&gt;Netbeans:&lt;br /&gt;&lt;br /&gt;  * Really good ruby highlighting&lt;br /&gt;  * Tries to do a little too much with rake tasks, ruby console, and gem plugins&lt;br /&gt;  * Nice and small download&lt;br /&gt;  * SVN integration doesn't work for me because you can't easily checkbox a few selective files, and you can't easily perform diffs on the commit dialog box&lt;br /&gt;&lt;br /&gt;Ubuntu Eclipse Package:&lt;br /&gt;&lt;br /&gt;  * Ubuntu ships with version 3.2. It will not work well with Java 6&lt;br /&gt;  * sudo vi /etc/eclipse/java_home (move /usr/lib/jvm/java-1.5.0-sun to the top of the list)&lt;br /&gt;  * Add eclipse update repositories: http://subclipse.tigris.org/update_1.2.x, http://update.aptana.com/install/rdt/3.2/&lt;br /&gt;  * Install Ruby Development Tools, Subclipse, Web Standard Tools&lt;br /&gt;  * Runs like a charm. Stable, and all features I want.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-3001779210419048638?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/3001779210419048638/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=3001779210419048638' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/3001779210419048638'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/3001779210419048638'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2008/12/best-rubysvn-ide-setup-for-hardy-heron.html' title='The Best Ruby/SVN IDE setup for Hardy Heron'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-7268159218171338112</id><published>2008-11-05T18:01:00.000-08:00</published><updated>2008-11-05T18:38:12.957-08:00</updated><title type='text'>Ubuntu Linux Command Line Background Magic (without screen)</title><content type='html'>This is useful when you are in an ssh session and you want to background a long-running task and log out. The job will continue running after you log out, and you can even log back in later and resume it. This solution does not require screen.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ nice -n10 -- super_long_running_script&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now say that the script is taking for ever, and you need to kill your ssh session. First, hit &lt;Ctrl&gt; + Z&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;...&lt;br /&gt;[1]+  Stopped(SIGTSTP)        nice -n10 -- super_long_running_script&lt;br /&gt;~$&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This will stop the task (but not kill it) and give you a console again. Note that the [1] indicates that the task is indexed as job 1. Next, we want to resume the task again, but in the background:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ bg 1&lt;br /&gt;[1] nice -n10 -- mysql -u root bamboo_staging &amp;lt;backup_20081105.sql &amp;&lt;br /&gt;~$&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;the number "1" corrolates with the job number above. The task is now running again in the background. Note that if you log out now bash will kill the task because bash kills its children on exit. To prevent bash from killing the child, do:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ disown -h 31968&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Where 31968 is the PID of the backgrounded process. Now you can exit your ssh shell:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ exit&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that your ssh session doesn't really close properly. However it is now safe to kill your ssh client. The backgrounded process will happily keep running.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-7268159218171338112?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/7268159218171338112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=7268159218171338112' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/7268159218171338112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/7268159218171338112'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2008/11/ubuntu-linux-command-line-background.html' title='Ubuntu Linux Command Line Background Magic (without screen)'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-1831582280896900509</id><published>2008-11-05T17:18:00.000-08:00</published><updated>2008-11-05T17:32:44.883-08:00</updated><title type='text'>Ubuntu/Debian and nfs mount issue solved</title><content type='html'>I spent a while trying to figure this one out: nfs client mounts were very slow on one of my servers. The dmesg output kept saying:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;portmap: server localhost not responding, timed out&lt;br /&gt;RPC: failed to contact portmap (errno -5).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Also, rpcinfo was not working for me:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ sudo rpcinfo -p 127.0.0.1&lt;br /&gt;rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused&lt;br /&gt;~$ sudo rpcinfo -p localhost&lt;br /&gt;rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;NFS mounts were working but were extremely slow:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ sudo mount hostname:/path&lt;br /&gt;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I was convinced that the problem lied with my hosts file, firewall, or hosts.allow or hosts.deny. It turns out that the problem was simply that a few packages had to be installed:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;~$ sudo apt-get install nfs-common&lt;br /&gt;...&lt;br /&gt;Selecting previously deselected package libevent1.&lt;br /&gt;Selecting previously deselected package libnfsidmap1.&lt;br /&gt;Selecting previously deselected package nfs-common.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-1831582280896900509?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/1831582280896900509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=1831582280896900509' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/1831582280896900509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/1831582280896900509'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2008/11/ubuntudebian-and-nfs-mount-issue-solved.html' title='Ubuntu/Debian and nfs mount issue solved'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-4428028036240707429</id><published>2008-10-21T15:36:00.000-07:00</published><updated>2008-10-21T15:55:12.617-07:00</updated><title type='text'>Unique Random Numbers &amp; Random Rows from Large ActiveRecord Tables</title><content type='html'>I was looking for an easy way to get unique and random numbers. In my case, I need a small quantity of numbers from a large pool. Here is the best solution I could come up with (derived from a message board):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def unique_randoms(n, max = nil)&lt;br /&gt; seen = {}&lt;br /&gt; n.times{x = rand max; seen[x] ? redo : seen[x] = 1}&lt;br /&gt; seen.keys&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It's a little more terse than it needs to be. Here is a more explicit version:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def unique_randoms(n, max = nil)&lt;br /&gt; seen = {}&lt;br /&gt; n.times do&lt;br /&gt;   x = rand max&lt;br /&gt;   redo if seen[x]&lt;br /&gt;   seen[x] = true&lt;br /&gt; end&lt;br /&gt; seen.keys&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you need a large number of randoms it is faster to use the Array sort method:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def unique_randoms(n, max)&lt;br /&gt;  (0..max).sort{rand}[0..n]&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This leads us to a solution to quickly getting random rows through ActiveRecord:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;def random(scope, num_randoms)&lt;br /&gt;  count = scope.count&lt;br /&gt;  unique_randoms(num_randoms, count){|i| scope.first :offset =&gt; i}&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The above solution is appropriate for large result sets where :order =&gt; 'RAND()' is inefficient, and for small quantities of random rows. Each random row adds a query to this solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-4428028036240707429?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/4428028036240707429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=4428028036240707429' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/4428028036240707429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/4428028036240707429'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2008/10/unique-random-numbers-random-rows-from.html' title='Unique Random Numbers &amp; Random Rows from Large ActiveRecord Tables'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-7432707035165407375</id><published>2008-06-02T10:28:00.000-07:00</published><updated>2008-06-02T10:31:56.821-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='subversion svn cannot create directory tmp'/><title type='text'>How to create missing subversion tmp files</title><content type='html'>After importing a project into my IDE, subversion started giving this error:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;svn: Your .svn/tmp directory may be missing or corrupt; run 'svn cleanup' and try again&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, 'svn cleanup' was unable to fix this problem.&lt;br /&gt;&lt;br /&gt;I was able to create all of the required .svn temporary directories with the following command:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;find . -iname '.svn' -exec mkdir {}/tmp \;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-7432707035165407375?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/7432707035165407375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=7432707035165407375' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/7432707035165407375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/7432707035165407375'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2008/06/how-to-create-missing-subversion-tmp.html' title='How to create missing subversion tmp files'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2559395734336150066.post-1241453768320029153</id><published>2007-11-09T08:44:00.001-08:00</published><updated>2007-11-09T09:46:50.436-08:00</updated><title type='text'>What are good techniques for Ruby Regular expressions?</title><content type='html'>using global variables (perl style):&lt;br /&gt;&lt;blockquote&gt;if uri =~ /^druby:\/\/(.*?):(\d+)(\?(.*))?$/&lt;br /&gt;host = $1&lt;br /&gt;port = $2.to_i&lt;br /&gt;option = $4&lt;/blockquote&gt;using square brackets:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;imagelist  = f[/ImageList.*?\((.+?)\)/, 1]&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2559395734336150066-1241453768320029153?l=railsquestions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://railsquestions.blogspot.com/feeds/1241453768320029153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2559395734336150066&amp;postID=1241453768320029153' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/1241453768320029153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2559395734336150066/posts/default/1241453768320029153'/><link rel='alternate' type='text/html' href='http://railsquestions.blogspot.com/2007/11/what-are-good-techniques-for-ruby.html' title='What are good techniques for Ruby Regular expressions?'/><author><name>tim</name><uri>http://www.blogger.com/profile/08568767447934812551</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
