<?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>Baroquebobcat &#187; ruby</title>
	<atom:link href="http://blog.baroquebobcat.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.baroquebobcat.com</link>
	<description>Ruby, Computer Science, Japan and Stuff</description>
	<lastBuildDate>Wed, 08 Sep 2010 15:25:55 +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>Speaking at Ruby&#124;Web Conference on Friday</title>
		<link>http://blog.baroquebobcat.com/2010/09/08/speaking-at-rubyweb-conference-on-friday/</link>
		<comments>http://blog.baroquebobcat.com/2010/09/08/speaking-at-rubyweb-conference-on-friday/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 14:23:11 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=447</guid>
		<description><![CDATA[On Friday morning I am speaking at the Ruby&#124;Web Conference at Snowbird in Utah. I&#8217;ll be giving a talk entitled &#8220;Extreme Performance with Mirah and Dubious&#8220;. I&#8217;ll be talking about a project I&#8217;ve been helping out with called Dubious, which is a web framework written in Mirah. Check out the source: http://www.mirah.org/ http://github.com/mirah/dubious]]></description>
			<content:encoded><![CDATA[<p>On Friday morning I am speaking at the <a title="Ruby|Web Conf Website" href="http://rubywebconf.org">Ruby|Web Conference</a> at Snowbird in Utah. I&#8217;ll be giving a talk entitled &#8220;<a href="http://rubywebconf.org/sessions#baroquebobcat">Extreme Performance with Mirah and Dubious</a>&#8220;. I&#8217;ll be talking about a project I&#8217;ve been helping out with called Dubious, which is a web framework written in Mirah.</p>
<p>Check out the source:</p>
<p><a href="http://www.mirah.org/">http://www.mirah.org/</a></p>
<p><a href="http://github.com/mirah/dubious">http://github.com/mirah/dubious</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2010/09/08/speaking-at-rubyweb-conference-on-friday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mountain West Ruby Conf Rocked This Year</title>
		<link>http://blog.baroquebobcat.com/2010/03/22/mountain-west-ruby-conf-rocked-this-year/</link>
		<comments>http://blog.baroquebobcat.com/2010/03/22/mountain-west-ruby-conf-rocked-this-year/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 05:51:21 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=421</guid>
		<description><![CDATA[Mountain West Ruby Conf this year was awesome. I totally had a blast. It was the third time I&#8217;ve gone to it. It was my first conference and still is my favorite. I got to meet Matz, I gave a lightning talk, I met all sorts of interesting people and I learned a bunch of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mtnwestrubyconf.org/2010/">Mountain West Ruby Conf</a> this year was awesome. I totally had a blast.</p>
<p>It was the third time I&#8217;ve gone to it. It was my first conference and still is my favorite. I got to meet Matz, I gave a lightning talk, I met all sorts of interesting people and I learned a bunch of new things. To quote Matz, <a href="http://twitter.com/yukihiro_matz/status/10408740916">MountainWest RubyConfはすばらしかった。</a></p>
<p><a title="Matz &amp; me by baroquebobcat, on Flickr" href="http://www.flickr.com/photos/baroquebobcat/4453467686/"><img src="http://farm3.static.flickr.com/2728/4453467686_b9358d6ff0.jpg" alt="Matz &amp; me" width="500" height="375" /></a></p>
<p>Things to revisit</p>
<ul>
<li><a href="http://github.com/gilesbowkett/archaeopteryx">Archaeopteryx</a></li>
</ul>
<ul>
<li><a href="http://weblog.rubyonrails.org/2010/2/5/rails-3-0-beta-release/"> Rails 3</a></li>
</ul>
<ul>
<li> <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/354528">Rack</a>(1.1.0 in particular)</li>
</ul>
<ul>
<li> <a href="http://wiki.opscode.com/display/chef/Home">Chef</a>(looks better than the last time I poked at it)</li>
</ul>
<ul>
<li> <a href="http://timetobleed.com/eventmachine-scalable-non-blocking-io-in-ruby/">EventMachine</a></li>
</ul>
<ul>
<li> <a href="http://github.com/lsegal/yard">Yard</a></li>
</ul>
<p>New things(to me)</p>
<ul>
<li><a href="http://rvm.beginrescueend.com/">RVM</a>(rvm looks pretty handy, especially for cross vm library development)</li>
</ul>
<ul>
<li><a href="http://github.com/jashkenas/ruby-processing"> Ruby-Processing</a></li>
</ul>
<ul>
<li> <a href="http://github.com/mwotton/Hubris">Hubris</a>(this might be a neat way to get into Haskell development)</li>
</ul>
<ul>
<li><a href="http://timetobleed.com/descent-into-darkness-understanding-your-systems-binary-interface-is-the-only-way-out/"> Mucking about with the binary interfaces</a>(because it is awesome.)</li>
</ul>
<p><strong>My lightning talk</strong></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="560" height="340" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/OjOpCX_OBP4&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="560" height="340" src="http://www.youtube.com/v/OjOpCX_OBP4&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2010/03/22/mountain-west-ruby-conf-rocked-this-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Usdo. Misspellings turn into gem-fu practice</title>
		<link>http://blog.baroquebobcat.com/2009/11/14/usdo-misspellings-turn-into-gem-fu-practice/</link>
		<comments>http://blog.baroquebobcat.com/2009/11/14/usdo-misspellings-turn-into-gem-fu-practice/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 21:03:28 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=383</guid>
		<description><![CDATA[A few weeks ago, during a period of frustration, I found myself repeatedly mistyping &#8216;sudo.&#8217; So, in a fit of silliness I wrote a short script to insult me when I did it, and put it in the path. Later, I packaged it as a gem, because a) I had never built a gem with [...]]]></description>
			<content:encoded><![CDATA[<p><a style="float:left;padding: 1em" title="Indian Paintbrush by baroquebobcat, on Flickr" href="http://www.flickr.com/photos/baroquebobcat/4103285795/"><img src="http://farm3.static.flickr.com/2584/4103285795_7bc6bc33a4_m.jpg" alt="Indian Paintbrush" width="180" height="240" /></a><br />
A few weeks ago, during a period of frustration, I found myself repeatedly mistyping &#8216;sudo.&#8217; So, in a fit of silliness I wrote a<a title="usdo.rb gist" href="http://gist.github.com/198514"> short script</a> to insult me when I did it, and put it in the path.</p>
<p>Later, I packaged it as a gem, because a) I had never built a gem with an executable and b) gems are a great way to share things.</p>
<p>The end result?</p>
<p><a href="http://github.com/baroquebobcat/usdo">http://github.com/baroquebobcat/usdo</a></p>
<p>It isn&#8217;t particularly smart, but I happen to find it funny. It also showed to me how far gem packaging has come. <a href="http://www.gemcutter.org/">Gemcutter</a> and <a href="http://github.com/technicalpickles/jeweler">Jeweler</a> make building and distributing ruby gems freakishly easy. This is especially awesome in light of the recent announcement that <a href="http://update.gemcutter.org/2009/10/26/transition.html">gemcutter is going to be the default gems host</a>(though at <a href="rubygems.org">rubygems.org</a>)<strong><br />
</strong></p>
<p><strong>How I put it together</strong></p>
<p>I ran jeweler to create the default directory structure and added a bin dir to it, for the files I wanted to end up in the path.</p>
<pre lang="bash">$ jeweler usdo
cd usdo
mkdir bin</pre>
<p>I put my gist from before in the bin directory, and set up git.</p>
<p>Set up my gem info in my Rakefile</p>
<pre>#...
Jeweler::Tasks.new do |gem|
  gem.name = "usdo"
  gem.summary = %Q{adds usdo command to ridicule mispellings of sudo}
  gem.description = %Q{...}
  gem.email = "ndh@baroquebobcat.com"
  gem.homepage = "http://github.com/baroquebobcat/usdo"
  gem.authors = ["Nick Howard"]
end</pre>
<p>then did the jeweler gem initialization dance</p>
<pre>rake version:write
rake gemspec
rake install</pre>
<p>Testing it out:</p>
<pre>$ usdo -l
----USDO----
    You mispelled sudo
    You can't do anything, you can't even spell sudo
    are you really sure you want to try running
    'sudo -l'????</pre>
<p>Now that was working, to send it up for distribution.</p>
<p>Jeweler is awesome and now has gemcutter support. I followed the jeweler <a href="http://github.com/technicalpickles/jeweler">README</a>&#8216;s directions on uploading to gemcutter. Which makes pushing your gem as simple as</p>
<pre>$ rake gemcutter:release</pre>
<p>Awesome.</p>
<p>Check out <a href="http://github.com/baroquebobcat/usdo">my code</a> if you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/11/14/usdo-misspellings-turn-into-gem-fu-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scrubyt On A Server Workaround</title>
		<link>http://blog.baroquebobcat.com/2009/11/04/scrubyt-on-a-server-workaround/</link>
		<comments>http://blog.baroquebobcat.com/2009/11/04/scrubyt-on-a-server-workaround/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 06:47:37 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=387</guid>
		<description><![CDATA[So you got some awesome scraper script and you want to deploy it to your server but you don&#8217;t want to have to install firewatir. Or, you don&#8217;t want to pull in the firewatir gem because you are not planning on using it. Whatever. Problem: scrubyt requires the firewatir gem Hacky Solution: comment out the [...]]]></description>
			<content:encoded><![CDATA[<p>So you got some awesome scraper script and you want to deploy it to your server but you don&#8217;t want to have to install <a href="http://code.google.com/p/firewatir/">firewatir</a>. Or, you don&#8217;t want to pull in the firewatir gem because you are not planning on using it. Whatever.</p>
<p><strong>Problem:</strong> scrubyt<br />
requires the firewatir gem</p>
<p><strong>Hacky Solution</strong>: comment out the require</p>
<p>But where you ask?</p>
<pre>/lib/scrubyt/core/navigation/agents/firewatir.rb line 1</pre>
<p>This works on the current rubyforge version(0.4.1).<br />
<strong>Recommended: </strong>Or, you could just use the version on github that is fixed(<a href="http://github.com/scrubber/scrubyt/commit/b1bfe0498939d3836cf5c4261d82889cd05ffd68">see commit</a>)</p>
<p>grab the files via git or archive from <a href="http://github.com/scrubber/scrubyt">github.com/scrubber/scrubyt</a></p>
<p>then</p>
<pre>cd scrubyt-somehash
rake gem
gem install pkg/scrubyt-0.4.26.gem</pre>
<p>Not as nice as using <a href="http://github.com/technicalpickles/jeweler">jeweler </a>where you can just `rake install` it, but pretty nifty none the less.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/11/04/scrubyt-on-a-server-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenID Provider in Sinatra</title>
		<link>http://blog.baroquebobcat.com/2009/09/17/openid-provider-in-sinatra/</link>
		<comments>http://blog.baroquebobcat.com/2009/09/17/openid-provider-in-sinatra/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 05:31:35 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=376</guid>
		<description><![CDATA[As part of a personal project, I have been working on an OpenID Provider written in Sinatra. The idea is to make it ridiculously easy to set up an openid provider within a rack middleware stack. It&#8217;s just a single sinatra app without any tests using code I cribbed from the example rails implementation in [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a personal project, I have been working on an OpenID Provider written in Sinatra.</p>
<p>The idea is to make it ridiculously easy to set up an openid provider within a rack middleware stack.</p>
<p>It&#8217;s just a single sinatra app without any tests using code I cribbed from the example rails implementation in <a href="http://openidenabled.com/ruby-openid/">ruby-openid</a>. But, I intend on rewriting it once I get a better feel for how it should go.</p>
<p>The problem I face is a matter of interface, specifically application programming interface. I want it to be simple to use. But that is alittle complicated underneath.</p>
<p>Today I read <a href="http://chaos.troll.no/~shausman/api-design/api-design.pdf">The Little Manual of API Design</a>(pdf), which made me think about my approach to building things in, I think, a good way. It talks about the goals of building a good API and boils it down to five things.</p>
<ul>
<li>Easy to learn and memorize</li>
<li>Leads to readable code</li>
<li>Hard to misuse</li>
<li>Easy to extend</li>
<li>Complete</li>
</ul>
<p>For my app, complete is pretty easy. I&#8217;ve boiled the interface down to two main things:</p>
<ul>
<li>OpenID Store</li>
<li>User/Identity</li>
</ul>
<p>First, for an openid app, you need an openid store to put all the associations, nonces etc.</p>
<p>Then, the meaty bit, the users and their identities. The stuff we are serving up. My current thought is to have one of the app&#8217;s parameters be a lambda or Proc that returns the current user, or nil when called with the request.env. So that using it would look somewhat like this.<br />
<script src="http://gist.github.com/188358.js"></script> It&#8217;s kind of ugly, but I like it better than some of my other options.  One other way I could get the user to the app would be to use rack request hash. I could have users put the user object in the request env before the OpenID provider gets it and tell the provider where to look. But the problem with that is that I would need to add another middleware layer that added the user to the environment.  That would look something like this:   <script src="http://gist.github.com/188360.js"></script></p>
<p>Maybe that would be better.</p>
<p>Ultimately I just need to pick something and run with it.</p>
<p>The thing I wonder about though, is what is the most idomatic way of doing this. Using the most rubyish, most Rack like interface would make it easier to learn and memorize.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/09/17/openid-provider-in-sinatra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RubyNation: Preparing for 1.9</title>
		<link>http://blog.baroquebobcat.com/2009/06/25/rubynation-preparing-1-9/</link>
		<comments>http://blog.baroquebobcat.com/2009/06/25/rubynation-preparing-1-9/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 05:45:20 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=315</guid>
		<description><![CDATA[David A Black &#8212; Preparing for 1.9 &#8220;open a 1.8.6 [irb] and you&#8217;ll see all the stuff I&#8217;m showing you not work&#8221; David showed us some of the differences between the 1.9 and 1.8.6 with live code demos. generic to_a gone. I&#8217;d seen it in the docs for 1.8.6, but never used it. It doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<h4><a href="http://rubynation.org/speakers#david_a_black">David A Black &#8212; Preparing for 1.9</a></h4>
<blockquote><p>&#8220;open a 1.8.6 [irb] and you&#8217;ll see all the stuff I&#8217;m showing you not work&#8221;</p></blockquote>
<p>David showed us some of the differences between the 1.9 and 1.8.6 with <strong>live</strong> code demos.</p>
<p><strong>generic to_a gone.</strong> I&#8217;d seen it in the docs for 1.8.6, but never used it. It doesn&#8217;t make sense for a number to know how to wrap itself in an array. Seeing it go makes me happy.</p>
<p><strong>Strings</strong></p>
<p><strong>String no longer mixes in Enumerable.</strong> Instead of each, et al it has new each_* methods.</p>
<ul>
<li>each_byte  &#8211;again duh</li>
<li>each_char &#8212; duh</li>
<li>each_checkpoint &#8212; gives you the bits for the would be character regardless of encoding</li>
<li>each_line  &#8211;duh</li>
</ul>
<pre lang="ruby">
"string"[0]
# 1.9
#=> "s"
#1.8.6
#=> 115
</pre>
<p>str[0] returns a string of length one rather than a Fixnum representing the nth byte as 1.8.6 does. To get the same behavior in 1.8.6 you need to write str[0,1] which is not at all intuitive. I had run into that a few times and always thought it was odd for a language with  such an awesome string manipulation toolkit to do.</p>
<p>case statements no longer have the optional &#8216;:&#8217;. when x: blah won&#8217;t work, it will have to be when x; blah</p>
<p>rubygems now part of core, so no need to require &#8216;rubygems&#8217; before requiring a gem. <strong>Sweet.</strong></p>
<p>{1,2,3,4} does not turn into {1=>2,3=>4} you always need the hashrockets(=>).</p>
<p>Also, hashes retain insertion order so you can now rely on what use to be coincidental. Cool. This also means that you can use position as well as key to refer to values&#8230;which confuses me because hashes can have numeric keys.ruby</p>
<p>Block local variables(let () anyone?). done like so</p>
<pre lang="ruby">
local_var = 'something to not overwrite'
do |a;local_var|
  local_var = cool_intermediate_method a
  some_method local_var
end
# local_var == 'something to not overwrite'
</pre>
<p>String encoding got some smarts. Ruby knows more about how to deal with string encoding in 1.9. David showed us some examples. If you change a string to ASCII and then try to add a Unicode character to it, the system will convert the string&#8217;s encoding to Unicode first.</p>
<p><strong>Enumerators.</strong><br />
Like java iterators, only with more awesome. Apparently, these have been around for a while(1.8.7), but I hadn&#8217;t used them before. You can do cool stuff like:</p>
<pre lang="ruby">
e = (1..3).cycle
e.take 5
 #=> [1, 2, 3, 1, 2]
e2 = e.each_slice 2
e2.take 5
  #=> [[1, 2], [3, 1], [2, 3], [1, 2], [3, 1]]
e3 = e.each_cons(2)
e3.take 5
  #=> [[1, 2], [2, 3], [3, 1], [1, 2], [2, 3]]
</pre>
<p>Then there is the new <a href="http://www.ruby-doc.org/core-1.9/classes/BasicObject.html">BasicObject</a>. It is like <a href="http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc">Jim Weirich&#8217;s BlankSlate</a>, but baked in. Objects with no default methods are really handy for building DSLs, like <a href="http://builder.rubyforge.org/">builder</a>.</p>
<pre lang="ruby">
a = BasicObject.new
p a
#=> NoMethodError: undefined method `inspect' for #<BasicObject:0x8441f94>
</pre>
<p>I want to talk about some of the other presentations from <a href="http://rubynation.org/">RubyNation</a>, but I have been busier recently than I thought I would be. So, we will see what happens.</p>
<p>For David A. Black&#8217;s  own stuff, check out <a href="http://dablog.rubypal.com/">his blog.</a></p>
<p>Also, according to my admin interface, this is my 100th post. Cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/06/25/rubynation-preparing-1-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RubyNation Etc</title>
		<link>http://blog.baroquebobcat.com/2009/06/16/rubynation-etc/</link>
		<comments>http://blog.baroquebobcat.com/2009/06/16/rubynation-etc/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 04:38:00 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[anecdote]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=318</guid>
		<description><![CDATA[I am back from RubyNation and reapplying my nose to the grindstone, wheel to the asphalt and hands to the keyboard. I am still planning a big summary and commentary post based on my notes, but as I started working on that, I realized it might need more than one night to see to completion. [...]]]></description>
			<content:encoded><![CDATA[<p>I am back from RubyNation and reapplying my nose to the grindstone, wheel to the asphalt and hands to the keyboard. I am still planning a big summary and commentary post based on my notes, but as I started working on that, I realized it might need more than one night to see to completion.</p>
<p>So, I give you this:</p>
<p><strong>Me</strong><br />
<a href="http://www.flickr.com/photos/baroquebobcat/3630829655/" title="Hyatt Ceiling Pastry and Me in My Hat by baroquebobcat, on Flickr"><img src="http://farm4.static.flickr.com/3345/3630829655_a2dd943865.jpg" width="500" height="375" alt="Hyatt Ceiling Pastry and Me in My Hat" /></a><br />
<strong><br />
Carrot Cake(Thanks Hyatt catering)</strong></p>
<p><a href="http://www.flickr.com/photos/baroquebobcat/3631643308/" title="Mmm Carrot Cake by baroquebobcat, on Flickr"><img src="http://farm4.static.flickr.com/3325/3631643308_60297a6e0c.jpg" width="500" height="375" alt="Mmm Carrot Cake" /></a></p>
<p><strong>And Lys, the cat who is strangely fond of white ceramics.</strong></p>
<p><a href="http://www.flickr.com/photos/baroquebobcat/3631643722/" title="Lys, Sink and You by baroquebobcat, on Flickr"><img src="http://farm3.static.flickr.com/2427/3631643722_95ee64b192.jpg" width="500" height="375" alt="Lys, Sink and You" /></a></p>
<p>Tune in some indeterminate point in the future for a fuller update. Or, you could just read <a href="http://blog.prognosoft.biz/2009/06/12/ruby-nation-2009-first-day/">this guy&#8217;s take.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/06/16/rubynation-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sprinkle and Passenger Stack</title>
		<link>http://blog.baroquebobcat.com/2009/04/21/sprinkle-and-passenger-stack/</link>
		<comments>http://blog.baroquebobcat.com/2009/04/21/sprinkle-and-passenger-stack/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 05:03:11 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=224</guid>
		<description><![CDATA[I started using sprinkle with the passenger-stack recently. So far, it has been easy to get started with and fairly intuitive. I chose it rather than puppet or some of the other declarative server configuration DSL because it doesn&#8217;t need to install anything extra on the server to work. This is great for the kinds [...]]]></description>
			<content:encoded><![CDATA[<p>I started using <a href="http://github.com/crafterm/sprinkle/">sprinkle</a> with the <a href="http://github.com/benschwarz/passenger-stack/">passenger-stack</a> recently. So far, it has been easy to get started with and fairly intuitive. I chose it rather than <a href="http://github.com/lak/puppet">puppet</a> or some of the other declarative server configuration <abbr title="Domain Specific Language">DSL</abbr> because it doesn&#8217;t need to install anything extra on the server to work.</p>
<p>This is great for the kinds of things I have been working on, because they are fairly small, and don&#8217;t need many servers.<br />
I think if I were managing more things, I might choose puppet, because the overhead would be justified.</p>
<p>One of the things I like about sprinkle, is the DSL is pretty straight forward, eg the package definition for passenger looks like this:</p>
<pre lang="ruby">
package :passenger, :provides => :appserver do
  description 'Phusion Passenger (mod_rails)'
  version '2.1.3'
  gem 'passenger' do
    post :install, 'echo -en "\n\n\n\n" | sudo passenger-install-apache2-module'

    # Create the passenger conf file
    post :install, 'mkdir -p /etc/apache2/extras'
    post :install, 'touch /etc/apache2/extras/passenger.conf'
    post :install, 'echo "Include /etc/apache2/extras/passenger.conf"|sudo tee -a /etc/apache2/apache2.conf'

    [%Q(LoadModule passenger_module /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so),
    %Q(PassengerRoot /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}),
    %q(PassengerRuby /usr/local/bin/ruby),
    %q(RailsEnv production)].each do |line|
      post :install, "echo '#{line}' |sudo tee -a /etc/apache2/extras/passenger.conf"
    end

    # Restart apache to note changes
    post :install, '/etc/init.d/apache2 restart'
  end
</pre>
<p>I had some problems, like the version of passenger in the passenger-stack master branch on github is a point release behind the phusion&#8217;s, which is annoying because when passenger updates itself to 2.2.0, the configs are not updated and apache tells you it can&#8217;t find the <code>mod_passenger.so</code> file.</p>
<p>Also, it puts the passenger config in a slightly unusual place(/etc/apache/extras), for an apache module, as well as appending stuff to /etc/apache2/apache2.conf. This prevents it from idempotency, because if you run it twice, it will add additional lines to the config files. So, in the vein of scratching my own itch and what have you&#8211;you know, that open source thing&#8211;I <a href="http://github.com/baroquebobcat/passenger-stack/blob/3448a943ef51cbde327bdea37f7ae4a9a8389027/config/stack/apache.rb#L19">rewrote</a> it.</p>
<pre lang="ruby">
package :passenger, :provides => :appserver do
  description 'Phusion Passenger (mod_rails)'
  version '2.2.0'
  gem 'passenger' do
    post :install, 'echo -en "\n\n\n\n" | sudo passenger-install-apache2-module'

    # Create the passenger conf file
    loading = %Q(LoadModule passenger_module /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so)
    conf = %Q(PassengerRoot /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}
PassengerRuby /usr/local/bin/ruby
RailsEnv production)

    post :install, "echo '#{conf}' >> /etc/apache2/mods-available/passenger.conf"
    post :install, "echo '#{loading}' >> /etc/apache2/mods-available/passenger.load"
    post :install, 'a2enmod passenger'
    # Restart apache to note changes
    post :install, '/etc/init.d/apache2 restart'
  end

  verify do
    has_file "/etc/apache2/mods-enabled/passenger.load"
    has_file "/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so"
    has_directory "/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}"
  end

  requires :apache, :apache2_prefork_dev, :ruby_enterprise
end
</pre>
<p>Now, it takes advantage of the debian convention of keeping module loading and configuration files go in <code>/etc/apache2/mods-available</code> that are symlinked into <code>/etc/apache2/mods-enabled</code> by the <code>a2enmod</code> utility. This is immediately obviously awesome to anyone who has contemplated the horror of trying to parse the apache main config to see if the stuff they want to add is already there and needs updating.</p>
<p>I also added some verifiers so that it won&#8217;t rerun if there were no errors. Pretty cool, no?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/04/21/sprinkle-and-passenger-stack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby is awesome&#8211;lazy scripting</title>
		<link>http://blog.baroquebobcat.com/2009/04/20/ruby-is-awesome-lazy-scripting/</link>
		<comments>http://blog.baroquebobcat.com/2009/04/20/ruby-is-awesome-lazy-scripting/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 05:51:21 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=230</guid>
		<description><![CDATA[Sometimes I find myself doing tedious things like trying to grab the dollar amounts from text copied from the web. More and more often I turn to irb for these sort of things. For example, a few minutes ago, when I wanted to analyze my spending habits I copied the data into a file and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I find myself doing tedious things like trying to grab the dollar amounts from text copied from the web. More and more often I turn to irb for these sort of things. For example, a few minutes ago, when I wanted to analyze my spending habits I copied the data into a file and manipulated it.</p>
<p>I grabbed the lines from the file</p>
<pre lang="ruby">
irb(main):001:0> lines = File.readlines 'transactions'
</pre>
<p>&#8230;<br />
And <a href="http://www.ruby-doc.org/core/classes/Enumerable.html#M003156">selected</a> those with dollar signs (with a little effort&#8211;sometimes I forget whether it is <code>=~</code> or <code>~=</code>).</p>
<pre lang="ruby">
irb(main):002:0> monies = lines.select {|l| l ~=  /\$(.*)/}
SyntaxError: compile error
(irb):2: syntax error, unexpected '='
monies = lines.select {|l| l ~=  /\$(.*)/}
                               ^
	from (irb):2
	from :0
irb(main):003:0> monies = lines.select {|l| l =~  /\$(.*)/}
</pre>
<p>Then I grabbed the numbers using <a href="http://www.ruby-doc.org/core/classes/Enumerable.html#M003159">map</a>.</p>
<pre lang="ruby">
irb(main):008:0> nums =monies.map {|m| m.sub( /\$(.*)/,$1).to_f}
</pre>
<p>From there, I could do all sorts of things.</p>
<p>I could sum numbers.</p>
<pre lang="ruby">
 total =nums.inject(0){|sum,i|sum+i}
</pre>
<p>I could get the average.</p>
<pre lang="ruby">
total/nums.length
</pre>
<p>I could even see how much of the total was due to transactions under $20.</p>
<pre lang="ruby">
nums.reject {|i|i>20}.inject{|s,i|s+i}
</pre>
<p>In short, I like ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/04/20/ruby-is-awesome-lazy-scripting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby in Practice is Good</title>
		<link>http://blog.baroquebobcat.com/2009/04/16/ruby-in-practice-is-good/</link>
		<comments>http://blog.baroquebobcat.com/2009/04/16/ruby-in-practice-is-good/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 06:25:15 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.baroquebobcat.com/?p=217</guid>
		<description><![CDATA[I have been reading Ruby in Practice over the past week or so as you know. Currently, I am on page 114 which talks about using active resource to consume RESTful webservices( you could use RESTClient, but thats another story) and has a box about the ever awesome BlankSlate class. I haven&#8217;t really learned many [...]]]></description>
			<content:encoded><![CDATA[<p>I have been reading <a href="http://www.manning.com/mcanally/">Ruby in Practice</a> over the past week or so as you know. Currently, I am on page 114 which talks about using active resource to consume RESTful webservices( you could use <a href="http://rest-client.heroku.com/rdoc/">RESTClient</a>, but thats another story) and has a box about the ever awesome <a href="http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc">BlankSlate</a> class. </p>
<p>I haven&#8217;t really learned many &#8220;whoah, ruby does what?? Sweet&#8221; things from it, most of those are behind me. Now, I get more &#8220;Whoah, X project really abstracts that annoying thing into a nice interface.&#8221; kind of feelings, which are more satisfying in some ways and less in others. I guess what I am saying is that I have grown to know ruby much better over the past six months or so using it at work every day, than the past, uh, five? years. Which is sweet.<br />
<strong><br />
But back to the book( I ramble when I feel braindead):</strong></p>
<p>The things I have learned from reading this book remind me of ruby itself. It has glued together various bits of ruby that I know, in the same way you can use ruby to glue together other technologies. Most of my ruby smarts have been picked up through hacking at things and reading blog posts by knowledgeable people, but that sometimes leaves some gaps in my knowledge. This book has helped me to tie some of the things I have learned together(w00t <a href="http://en.wikipedia.org/wiki/Hebbian_theory">Hebbian Learning</a>).</p>
<p><strong>For instance, spec tasks</strong></p>
<p>While I know that rspec has a set of extensions for rake, I had not used them outside rails, in fact in the project I was working on I just wrote the following.</p>
<pre lang="ruby">
task :spec do
  sh "spec --colour --reverse #{FileList['spec/**/*_spec.rb']}"
end
</pre>
<p>The problem with this is that when any of the specs fail, I get a huge trace from the ran shell script that I have to scroll past before I can see the failed specs.</p>
<p>But, if I included the spec tasks I could do stuff more like this.</p>
<pre lang="ruby">
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new('spec') do |task|
  task.spec_files =FileList['spec/**/*_spec.rb']
  task.spec_opts = ['--colour','--reverse']
end
</pre>
<p>Now things work like they do when you generate the tasks from within rails. I had read the <code>lib/tasks/rspec.rake</code> file when I was looking over the generated code in one of my rails apps, but it was a little too complicated to grok easily.</p>
<p>The other things I am looking for are cool projects that I should be more aware of. Sometimes, they are only mentioned but that doesn&#8217;t mean they are not awesome. Some that I would like to play with include:</p>
<ul>
<li><strong><a href="http://chronic.rubyforge.org/">Chronic</a></strong> a date string parser that tries to be able to handle stuff like: &#8220;next tuesday&#8221; and &#8220;summer&#8221;</li>
<li><strong><a href="http://fastercsv.rubyforge.org/">FasterCSV</a></strong><a href="http://blog.baroquebobcat.com/2009/03/14/mountain-west-ruby-conf-day-1-2/"> I saw this</a> at <a href="http://mtnwestrubyconf.org/2009/">Mountain West Ruby Conf</a> and made a mental note to read it at some point(so much for mental notes)</li>
<li><strong><a href="http://ruby.sadi.st/Heckle.html">Heckle</a></strong> runs tests. Breaks your code. Sees if the tests fail like they should.</li>
</ul>
<p>Later.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.baroquebobcat.com/2009/04/16/ruby-in-practice-is-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
