<?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>7fff - think max value &#187; Ruby</title>
	<atom:link href="http://7fff.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://7fff.com</link>
	<description></description>
	<lastBuildDate>Fri, 02 Jul 2010 13:21:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Running the gem doc server at startup on OS/X</title>
		<link>http://7fff.com/2010/06/18/running-the-gem-doc-server-at-startup-on-osx/</link>
		<comments>http://7fff.com/2010/06/18/running-the-gem-doc-server-at-startup-on-osx/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 14:08:20 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://7fff.com/?p=448</guid>
		<description><![CDATA[I&#8217;ve been traveling a fair bit lately, and have occasionally had spotty Internet access. So my access to documentation for gems and whatnot has been limited.
It would be nice to have all of my gem documentation available locally. But I&#8217;m lazy. I don&#8217;t want to be typing &#8220;gem server&#8221; all the time.
So here&#8217;s what you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been traveling a fair bit lately, and have occasionally had spotty Internet access. So my access to documentation for gems and whatnot has been limited.</p>
<p>It would be nice to have all of my gem documentation available locally. But I&#8217;m lazy. I don&#8217;t want to be typing &#8220;gem server&#8221; all the time.</p>
<p>So here&#8217;s what you do. Locate your appropriate gem command with &#8220;which gem&#8221;; I&#8217;m using rvm to run Ruby 1.9.1, so my answer is: /Users/jgn/.rvm/rubies/ruby-1.9.1-p376/bin/gem</p>
<p>Then create a gemserver.plist file like so, replacing the path to my gem with the path to yours:</p>
<pre name="code" class="xml">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
	&lt;key&gt;Label&lt;/key&gt;
	&lt;string&gt;localhost.gem.server&lt;/string&gt;
	&lt;key&gt;ProgramArguments&lt;/key&gt;
	&lt;array&gt;
		&lt;string&gt;/Users/jgn/.rvm/rubies/ruby-1.9.1-p376/bin/gem&lt;/string&gt;
		&lt;string&gt;server&lt;/string&gt;
	&lt;/array&gt;
	&lt;key&gt;RunAtLoad&lt;/key&gt;
	&lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</pre>
<p>Now copy to /Library/LaunchDaemons</p>
<p>The next type you reboot, you&#8217;ll have your gem docs at http://localhost:8808/</p>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2010/06/18/running-the-gem-doc-server-at-startup-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>favicon at ruby-doc.org the wrong size? And what is it?</title>
		<link>http://7fff.com/2010/06/02/favicon-at-ruby-doc-org-the-wrong-size-and-what-is-it/</link>
		<comments>http://7fff.com/2010/06/02/favicon-at-ruby-doc-org-the-wrong-size-and-what-is-it/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 10:57:09 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://7fff.com/?p=439</guid>
		<description><![CDATA[Here&#8217;s the favicon (the image that should show up next to the URL in the browser) for ruby-doc.org:



What IS that? Some kind of stylized &#8220;R&#8221; + &#8220;D&#8221;? And why is it the wrong size? Sheesh.
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the favicon (the image that should show up next to the URL in the browser) for ruby-doc.org:</p>
<p><center><br />
<img src="http://ruby-doc.org/favicon.ico" alt="ruby-doc.org favicon" /><br />
</center></p>
<p>What IS that? Some kind of stylized &#8220;R&#8221; + &#8220;D&#8221;? And why is it the wrong size? Sheesh.</p>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2010/06/02/favicon-at-ruby-doc-org-the-wrong-size-and-what-is-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>If you must rescue Exception . . .</title>
		<link>http://7fff.com/2009/10/29/if-you-must-rescue-exception/</link>
		<comments>http://7fff.com/2009/10/29/if-you-must-rescue-exception/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 15:03:04 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://7fff.com/?p=345</guid>
		<description><![CDATA[Sometimes you see Ruby code that rescue an exception at the top of the hierarchy:


rescue Exception =&#62; e

If you must do that, how about providing a means to control-C, by putting this in the method with the rescue:


trap(&#34;INT&#34;) do
  puts &#34;Terminating . . . &#34;
 return # or maybe exit
end

]]></description>
			<content:encoded><![CDATA[<p>Sometimes you see Ruby code that rescue an exception at the top of the hierarchy:</p>
<pre name="code" class="ruby">

rescue Exception =&gt; e
</pre>
<p>If you must do that, how about providing a means to control-C, by putting this in the method with the rescue:</p>
<pre name="code" class="ruby">

trap(&quot;INT&quot;) do
  puts &quot;Terminating . . . &quot;
 return # or maybe exit
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2009/10/29/if-you-must-rescue-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Faster Net::HTTP for Ruby 1.8.6</title>
		<link>http://7fff.com/2008/12/20/faster-nethttp-for-ruby-186/</link>
		<comments>http://7fff.com/2008/12/20/faster-nethttp-for-ruby-186/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 15:11:27 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://7fff.com/2008/12/20/faster-nethttp-for-ruby-186/</guid>
		<description><![CDATA[We&#8217;ve been a bit frustrated at work with Net::HTTP performance (as have so many others) so here&#8217;s a monkeypatch for 1.8.6 that combines the buffer size increase in 1.8.7 with Aaron Patterson&#8217;s recent tweak to use non-blocking IO (unfortunately, the non-blocking IO patch doesn&#8217;t work with HTTPS, which is why we use the buffer size [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been a bit frustrated at work with Net::HTTP performance (<a href="http://apocryph.org/2008/11/09/more_indepth_analysis_ruby_http_client_performance/">as have so many others</a>) so here&#8217;s a monkeypatch for 1.8.6 that combines <a href="http://github.com/rubyspec/matzruby/commit/eeaf6f95d65041018916572971635b49d2f7ae52">the buffer size increase in 1.8.7</a> with <a href="http://redmine.ruby-lang.org/repositories/diff/ruby-19/lib/net/protocol.rb?rev=20443">Aaron Patterson&#8217;s recent tweak to use non-blocking IO</a> (unfortunately, the non-blocking IO patch doesn&#8217;t work with HTTPS, which is why we use the buffer size tweak when the @io variable suggests that HTTPS is happening. No guarantee implied, etc.</p>
<pre name="code" class="ruby">

class Net::BufferedIO #:nodoc:

  alias <img src='http://7fff.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> ld_rbuf_fill :rbuf_fill

  def rbuf_fill

    BUFSIZE = 1024 * 16

    # HTTPS can't use the non-blocking strategy below in 1.8.6; so at least
    # increase buffer size over 1.8.6 default of 1024
    if !@io.respond_to? :read_nonblock
      timeout(@read_timeout) {
        @rbuf &lt;&lt; @io.sysread(BUFSIZE)
      }
      return
    end

    # non-blocking
    begin
      @rbuf &lt;&lt; @io.read_nonblock(BUFSIZE)
    rescue Errno::EWOULDBLOCK
      if IO.select([@io], nil, nil, @read_timeout)
        @rbuf &lt;&lt; @io.read_nonblock(BUFSIZE)
      else
        raise Timeout::TimeoutError
      end
    end

  end

end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2008/12/20/faster-nethttp-for-ruby-186/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Teaching Ruby and Ruby on Rails again at Harvard</title>
		<link>http://7fff.com/2008/08/07/teaching-ruby-and-ruby-on-rails-again-at-harvard/</link>
		<comments>http://7fff.com/2008/08/07/teaching-ruby-and-ruby-on-rails-again-at-harvard/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 00:47:11 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://7fff.com/2008/08/07/teaching-ruby-and-ruby-on-rails-again-at-harvard/</guid>
		<description><![CDATA[Once again, I&#8217;m pleased to be offering a course on Ruby and Ruby on Rails at Harvard: course; course site.
We&#8217;ll try to avoid this anti-pattern:

]]></description>
			<content:encoded><![CDATA[<p>Once again, I&#8217;m pleased to be offering a course on Ruby and Ruby on Rails at Harvard: <a href="http://extension.harvard.edu/2008-09/courses/csci.jsp#e-168">course</a>; <a href="http://e168f08.plugh.org/">course site</a>.</p>
<p>We&#8217;ll try to avoid this anti-pattern:</p>
<p><a href="http://www.flickr.com/photos/slworking/2218655624/"><img src="http://farm3.static.flickr.com/2238/2218655624_61b2cbbaca.jpg?v=0"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2008/08/07/teaching-ruby-and-ruby-on-rails-again-at-harvard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby: eval, rescue, and Exception</title>
		<link>http://7fff.com/2008/06/07/ruby-eval-rescue-and-exception/</link>
		<comments>http://7fff.com/2008/06/07/ruby-eval-rescue-and-exception/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 00:10:45 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://7fff.com/2008/06/07/ruby-eval-rescue-and-exception/</guid>
		<description><![CDATA[Recently I needed to store bits of Ruby code in the database, and then evaluate them in the context of a particular instance. But one thing I flubbed up was the handling of exceptions. You see, in this situation, if you have bad Ruby code, you will likely raise an exception. My first attempt was, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to store bits of Ruby code in the database, and then evaluate them in the context of a particular instance. But one thing I flubbed up was the handling of exceptions. You see, in this situation, if you have bad Ruby code, you will likely raise an exception. My first attempt was, roughly, this code (<strong><em>wrong!</em></strong>):</p>
<pre name="code" class="ruby">

begin
  eval s
rescue
  # log the fact that s couldn't be eval'ed
end
</pre>
<p>The catch is that when you use rescue without specify an exception, you are only catching StandardError or one of its subclasses. But eval will raise a SyntaxError (or worse), which is a subclass of ScriptError, which is not a subclass of StandardError. Therefore, you want to rescue an Exception that is further up the hierarchy. In short, <strong><em>better</em></strong>:</p>
<pre name="code" class="ruby">

begin
  eval s
rescue Exception =&gt; e
  # log the fact that s couldn't be eval'ed
end
</pre>
<p><a href="http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy">Nick Sieger provides a post with the Ruby Exception hierarchy,</a> along with some code to generate it dynamically. Too bad this info isn&#8217;t in the on-line Pickaxe (<a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html">http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://7fff.com/2008/06/07/ruby-eval-rescue-and-exception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
