<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>greenideas &#187; ruby</title>
	<atom:link href="http://mwhenry.com/blog/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://mwhenry.com/blog</link>
	<description>A blog by Matt Henry</description>
	<lastBuildDate>Fri, 02 Jul 2010 23:26:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>zsh: Scratching a geeky itch</title>
		<link>http://mwhenry.com/blog/2009/04/zsh-scratching-a-geeky-itch/</link>
		<comments>http://mwhenry.com/blog/2009/04/zsh-scratching-a-geeky-itch/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 22:47:50 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[irb]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=40</guid>
		<description><![CDATA[I’ll apologize right out of the gate for the resemblance this post bears to one Rafe Colburn made today. We sit across from each other at work, and we’re both diving into zsh at the moment, so cross-pollination was probably inevitable. The other day, I switched my shell from bash to zsh. Just like Rafe, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ll apologize right out of the gate for the resemblance this post bears to <a href="http://rc3.org/2009/04/04/my-zsh-adventure/">one Rafe Colburn made today</a>. We sit across from each other at work, and we’re both diving into zsh at the moment, so cross-pollination was probably inevitable.</p>
<p>The other day, I switched my shell from bash to zsh. Just like Rafe, I read the <a href="http://friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need/">Fried CPU post about zsh</a>, and was convinced to give it a whirl. It’s been in the back of my mind for a while now, since I’ve notice that a lot of people whom I respect (<a href="http://railscasts.com">Ryan Bates</a>, for one) are using it, but the concise list of really powerful features in the Fried CPU article was the tipping point. I’ll admit that, never having switched shells before, I thought it was going to be a heck of a lot more complicated than just typing <code>chsh</code> and replacing “/bin/bash” with “/bin/zsh” in the config file that pops up. Had I known it would be that easy, I would’ve tried it a lot sooner.</p>
<p>At first, I tried copying huge chunks out of the zshrc &amp; other zsh config files that Joe Ferris maintains in a <a href="http://github.com/jferris/config_files/tree/master">repo at Github</a>, but eventually decided I’d get more out of this experiment if I took more bite-sized chunks out of other peoples configurations, and only added them to my own when I understood what they were doing.</p>
<p>That’s when things got out of hand.</p>
<p>When I was copying bits of my old bash configs over to my zshrc, I noticed how disorganized all of my dotfiles were–not just the shell ones, but my irbrc, and vim &amp; emacs configs, etc., etc., etc. So I  basically decided to scrap all of them and take the same approach to them as I was taking with my shell configs. So basically, I’m starting over with Unix, and slowly rebuilding what I’m hoping will be a super-organized and super-optimized environment for future work and play.</p>
<p>If you’re interested in seeing how things develop, you can follow along with my <a href="http://github.com/greenideas/dotfiles/tree/master">dotfiles repo on Github</a>. But what I’m sure will be infinitely more interesting will be to start on your own adventure in Unix configuration. If you go down that road, here are some of the resources I’ve used in rebuilding my environment:</p>
<ul>
<li><a href="http://github.com/jferris/config_files/tree/master">Joe Ferris’s config_files repo</a>: I mentioned this before, but it’s worth mentioning again, due to its being awesome.
<li><a href="http://dotfiles.org/">dotfiles.org</a>: User-conributed dotfiles for just about every *nix-based utility that uses a text-based configuration file.</li>
<li><a href="http://giantrobots.thoughtbot.com/2008/12/23/script-console-tips">irb &amp; script/console tips</a>: Obviously these are only useful to Rubyists, but if you swing that way, theses are well worth checking out. Ever since I first saw the SQL generated by an ActiveRecord query show up in someone’s script/console, I’ve coveted that functionality. Dan Croak shows how it’s done.</li>
<li>Dr. Nic also has some <a href="http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/">great irb tips</a></li>
<li>Finally, I cribbed a git-aware prompt from <a href="http://smartic.us/2009/04/02/more-git-prompt-goodies-with-zsh/">this screencast</a>. A very neat trick.</li>
</ul>
<p>So yeah, it’s been really fun getting back to basics with my Unix configs. That said, I have had one small hiccup in this process. After going through all of this with my OSX terminal, I went to switch my shiny new <a href="http://intranation.com/entries/2009/03/development-virtual-machines-os-x-using-vmware-and/">Ubuntu JeOS VM</a>’s shell over to zsh, but found that after doing so, my delete key wasn’t behaving like a backspace as it had been doing when I was using bash. Apparently this is a known issue when using zsh or screen over ssh. I still haven’t found a good workaround for this, and so am still using bash in Ubuntu.</p>
<p>All in all, switching from bash to zsh has been an extremely rewarding experience, and definitely one I’d recommend to anyone looking to change up their routine and learn something new and useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2009/04/zsh-scratching-a-geeky-itch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Mongrel &amp; Hpricot Under Ubuntu</title>
		<link>http://mwhenry.com/blog/2008/03/install-mongrel-hpricot-under-ubuntu/</link>
		<comments>http://mwhenry.com/blog/2008/03/install-mongrel-hpricot-under-ubuntu/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 12:09:23 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=11</guid>
		<description><![CDATA[Whenever I do a fresh install of Ubuntu, and I’m setting up Ruby, Rails, I always run into the same problem with a handful of gems (such as Mongrel &#38; Hpricot). This is how things usually go down: matt@thinkpad:~$ sudo gem install hpricot Building native extensions.  This could take a while... ERROR:  Error installing hpricot: [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I do a fresh install of Ubuntu, and I’m setting up Ruby, Rails, I always run into the same problem with a handful of gems (such as Mongrel &amp; Hpricot). This is how things usually go down:</p>
<pre class="code">
matt@thinkpad:~$ sudo gem install hpricot
Building native extensions.  This could take a while...
ERROR:  Error installing hpricot:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install hpricot
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1
Gem files will remain installed in
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6 for inspection.
Results logged to
/usr/lib/ruby/gems/1.8/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out</pre>
<p>Now what? The main problem here is that Hpricot and Mongrel both contain some C code that needs to be compiled. In order to fix this, you’ll need to install the Ruby &amp; C development libraries for Ubuntu. To do that, just fire up Terminal and enter:</p>
<pre class="code">sudo apt-get install ruby1.8-dev linux-libc-dev libc6-dev</pre>
<p>You should now be able to install Hpricot, Mongrel, or any other gem that requires you to build some C. It’s that easy!</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/03/install-mongrel-hpricot-under-ubuntu/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stupid Ruby Problem</title>
		<link>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/</link>
		<comments>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 13:44:39 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=5</guid>
		<description><![CDATA[Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic Baseball Hacks from Perl to Ruby. I’m coming back to this project after letting it go for a while, and sure enough, the [...]]]></description>
			<content:encoded><![CDATA[<p>Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic <a href="http://books.google.com/books?id=51PS5G2Y2a4C&amp;dq=baseball+hacks&amp;pg=PP1&amp;ots=3YeuWSj5wn&amp;sig=J1V9kEnm1rtM1mD5_6sKtjFVRtQ&amp;hl=en&amp;prev=http://www.google.com/search?q=baseball+hacks&amp;ie=utf-8&amp;oe=utf-8&amp;rls=com.ubuntu:en-US:official&amp;client=firefox-a&amp;sa=X&amp;oi=print&amp;ct=title&amp;cad=one-book-with-thumbnail"><em>Baseball Hacks</em></a> from Perl to Ruby.</p>
<p>I’m coming back to this project after letting it go for a while, and sure enough, the problem I was having when I put it down is still vexing me.</p>
<p>One script is intended to grab all of the play-by-play data from <a href="http://retrosheet.org/">retrosheet.org</a>. The files all have urls like this:</p>
<pre class="code">

http://www.retrosheet.org/1957/1957al.zip

http://www.retrosheet.org/1957/1957nl.zip

http://www.retrosheet.org/1957/1957ml.zip</pre>
<p>The snippet below is a simplified version of the code I’m using to build the urls. It’s intended to print the urls of each zip file for each league from 1957 to  2006:</p>
<pre class="code">
year = 1957
leagues = ['al', 'nl', 'ml']leagues.each do |league|
  while year &lt;= 2006
    url = "http://www.retrosheet.org/#{year}/#{year}#{league}.zip"
    puts url
    year += 1
  end
end</pre>
<p>However, it doesn’t do that. It only generates the urls for the AL files, and I can’t get my brain around why.</p>
<p>I’ll be sure to add the solution when I figure it out, but for now I wanted to just document some of the struggles of a Ruby n00b.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

