<?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>Katipo Developers Blog &#187; ruby</title>
	<atom:link href="http://blog.katipo.co.nz/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.katipo.co.nz</link>
	<description></description>
	<lastBuildDate>Fri, 04 Jun 2010 02:39:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A more concise way to call single test file in ruby</title>
		<link>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/</link>
		<comments>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 03:52:12 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=118</guid>
		<description><![CDATA[I&#8217;ve been working with Rails and Ruby since 2006 and I&#8217;m surprised I hadn&#8217;t put this together for myself:

$ cd test # from your rails app root
$ ruby unit/a_model_test.rb

As compared to:

$ ruby -I"lib:test" "/usr/local/Cellar/ruby-enterprise-edition/1.8.7-20090928/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/a_model_test.rb"

Definitely a hand to forehead moment when I read that! Found it in a comment here:
https://rails.lighthouseapp.com/projects/16213/tickets/8
*Assumes your ruby command is set [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with Rails and Ruby since 2006 and I&#8217;m surprised I hadn&#8217;t put this together for myself:</p>
<pre>
<div class="codesnip-container" >$ cd test # from your rails app root
$ ruby unit/a_model_test.rb</div>
</pre>
<p>As compared to:</p>
<pre>
<div class="codesnip-container" >$ ruby -I"lib:test" "/usr/local/Cellar/ruby-enterprise-edition/1.8.7-20090928/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/a_model_test.rb"</div>
</pre>
<p>Definitely a hand to forehead moment when I read that! Found it in a comment here:</p>
<p><a href="https://rails.lighthouseapp.com/projects/16213/tickets/8">https://rails.lighthouseapp.com/projects/16213/tickets/8</a></p>
<p>*Assumes your ruby command is set up correctly in your shell&#8217;s environment, of course.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/04/25/a-more-concise-way-to-call-single-test-files-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing MongoDB on Mac OS X using Homebrew</title>
		<link>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/</link>
		<comments>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 01:20:42 +0000</pubDate>
		<dc:creator>walter</dc:creator>
				<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[kete development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=108</guid>
		<description><![CDATA[I&#8217;ve moved from MacPorts to Homebrew which includes a recipe for installing MongoDB. After installing Homebrew, just run this as your normal user:
brew install mongodb
If you prefer to store your MongoDB data all under your home directory, you might find Mislav&#8217;s gist suits your needs instead:
http://gist.github.com/265272
If you prefer installing from source, check out this post:
http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x
Enjoy.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve moved from MacPorts to <a href="http://github.com/mxcl/homebrew">Homebrew</a> which includes a recipe for installing MongoDB. After installing Homebrew, just run this as your normal user:</p>
<div class="codesnip-container" >brew install mongodb</div>
<p>If you prefer to store your MongoDB data all under your home directory, you might find Mislav&#8217;s gist suits your needs instead:</p>
<p><a href="http://gist.github.com/265272">http://gist.github.com/265272</a></p>
<p>If you prefer installing from source, check out this post:</p>
<p><a href="http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x">http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x</a></p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/03/16/installing-mongodb-on-mac-os-x-using-homebrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three ways to increase New Relic RPM&#8217;s usefulness</title>
		<link>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/</link>
		<comments>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 04:13:07 +0000</pubDate>
		<dc:creator>kieran</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[new relic]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rpm]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=104</guid>
		<description><![CDATA[Three recent and little known features of New Relic RPM which help increase usefulness.]]></description>
			<content:encoded><![CDATA[<p>Here at Katipo, we&#8217;re using New Relic RPM to monitor our deployed <a href="http://kete.net.nz">Kete</a> applications, to help make things as fast as possible. In order to make New Relic as useful as possible, I&#8217;ve been trying out three New Relic RPM features, some available in only the latest versions of RPM, on one of those sites. These recent and little-known features aren&#8217;t enabled by default, so I&#8217;m going to run you through them and how to set them up in this post.</p>
<p>If you don&#8217;t yet use New Relic RPM, you can get a Lite account for free by going to <a href="http://newrelic.com">newrelic.com</a>, where you can also test drive New Relic RPM on a real application. <span id="more-104"></span></p>
<p><strong>Custom request parameters</strong></p>
<p>New Relic does it&#8217;s best to record as much information about the current request as possible. The URL, split down into controller, action, id etc, the request referrer, GET and POST data&#8230;. but there is data that it doesn&#8217;t know about. Things like the current locale, the user who is currently logged in, or custom session params. Thankfully, there is a solution.</p>
<p>New Relic RPM contains a method for adding custom data to each transaction or error that is sent to it&#8217;s servers. Utilize this method inside of a before_filter in your application controller, and you&#8217;ll be gathering that extra data in no time. Here is the code we use.</p>
<blockquote>
<pre># Collect additional debug details for New Relic RPM is available
# Do this after all other before filters so details are present
before_filter :set_new_relic_custom_parameters
def set_new_relic_custom_parameters
  return unless defined?(NewRelic)
  NewRelic::Agent.add_custom_parameters(
    :locale =&gt; (I18n.locale if I18n.locale),
    :account =&gt; (logged_in? ? current_user.login : 'guest'),
    :return_to =&gt; (session[:return_to] if session[:return_to])
  )
end
private :set_new_relic_custom_parameters</pre>
</blockquote>
<p>Now, whenever RPM sends information about slow web requests or error reports, you&#8217;ll have more data to help replicate the issue.</p>
<p><strong>Passenger Queue Wait</strong></p>
<p>Sometimes the slowness might not be your app, but your app server. How do you tell if it&#8217;s serving requests fast enough? New Relic RPM now has the ability to report how long your visits were waiting in the &#8216;queue&#8217;, that is, the time between requesting the site and Apache actually processing that request. Getting this working is fairly simple.</p>
<blockquote><p>RequestHeader set X-REQUEST_START &#8220;%t&#8221;</p></blockquote>
<p>Simply set that in either your main apache.conf file, the VirtualHost directive, or a Directory directive.</p>
<p>Also, ensure that the headers Apache module is enabled. On Debian, you can do this by running the following as root.</p>
<blockquote><p># a2enmod headers</p></blockquote>
<p>That&#8217;s all it takes. Now, when RPM sends along information, it&#8217;ll send how long each request stayed in the queue, and display it at New Relic RPM&#8217;s web interface, on all graphs as &#8216;Queue Wait&#8217;. This should give you an indication of whether your application server is performing well.</p>
<p><span style="text-decoration: underline;"><span style="color: #000000;">Important Note:</span></span> If you run your application across multiple machines, each machine needs this header, and the clock on each machine must be synced with NTP or similar, or you&#8217;ll end up with very incorrect queue times. Users who run the entire site off one box need not worry about this issue.</p>
<p><strong>Garbage Collection delays</strong></p>
<p>I&#8217;m not going to go into much detail about Ruby Garbage collection here. Google &#8216;Ruby Garbage Collection&#8217; if you want to know more. Put simply though, in Ruby, while Garbage Collection runs, it stops the processing of your app. This could lead to slow page requests if it garbage collector, or GC, runs multiple times in the same request.</p>
<p>There are ways to tweak this using settings, but how do you know if it&#8217;s a problem to begin with? If you use Ruby Enterprise Edition, or another version of Ruby with the Railsbench GC patches compiled in, then all you need is the following line in your application.</p>
<blockquote><p>GC.enable_stats if defined?(GC) &amp;&amp; GC.respond_to?(:enable_stats)</p></blockquote>
<p>For Ruby on Rails users, you can stick that at the bottom of your config/environment.rb file. Basically, if GC is defined, and responds to the correct method, then use it. RPM will send this information back to New Relic, where you can view how long GC took in each of your requests, and deal with it accordingly.</p>
<p><strong>Conclusion</strong></p>
<p>Well, that&#8217;s all for now. Please feel free to share any additional features which help make New Relic even more useful in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/03/03/three-ways-to-increase-new-relic-rpms-usefulness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating from Github to Gemcutter</title>
		<link>http://blog.katipo.co.nz/2010/01/19/migrating-from-github-to-gemcutter/</link>
		<comments>http://blog.katipo.co.nz/2010/01/19/migrating-from-github-to-gemcutter/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 02:53:29 +0000</pubDate>
		<dc:creator>kieran</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[gemcutter]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[github]]></category>

		<guid isPermaLink="false">http://blog.katipo.co.nz/?p=100</guid>
		<description><![CDATA[Quick quote to migrating your gem list from Github to Gemcutter, the newest (and soon, only) gem hoster on the scene.]]></description>
			<content:encoded><![CDATA[<p>For those of you who follow this sort of thing, <a href="http://github.com">Github</a> shut down their gem building. Thankfully, a newer and easier gem hoster, <a href="http://gemcutter.org">Gemcutter</a>, appeared on the scene not long before that happened. The idea behind it, for those who haven&#8217;t heard of it, is that you manage your own gem building. Gemcutter doesn&#8217;t wait for your Gem spec to change before it makes a new gem. You simply build it locally, and push it to Gemcutter, using a handy gem they provide that extends Rubygems &#8216;gem&#8217; console command.</p>
<p>But Github was building gems for some time, and due to it&#8217;s continuing popularity, many well known Ruby on Rails developers and companies switched permanently to Github for their gem building/hosting at the time, so it&#8217;s likely that quite a few gems you&#8217;ve got installed are from Github.</p>
<p>To help transition over from Github to Gemcutter, <a href="http://github.com/maxim">Maxim Chernyak</a> wrote a great utility called <a href="http://github.com/maxim/off_github">off_github</a>, which looks at your list of gems, and tells you which ones you&#8217;re installed from Github, and whether they can be reinstalled from Gemcutter. It saves a lot of time and effort  than having to do it manually. So here&#8217;s how to get started&#8230;.</p>
<p><span id="more-100"></span>Firstly, lets get the latest version of Rubygems. This may not be needed for the off_github gem to function, but it pays to keep this up to date to prevent any issues with newer gems. Usually, you&#8217;ll want Rubygems version 1.3.0 or higher. At the time of this post, the current version is 1.3.5.</p>
<blockquote><p>$ gem &#8211;version<br />
1.2.1<br />
$ [sudo] gem update &#8211;system<br />
&#8230;&#8230;<br />
$ gem &#8211;version<br />
1.3.5</p></blockquote>
<p>Once that&#8217;s done, install the off_github gem. To do that, add Gemcutter as a source and run the gem install command.</p>
<blockquote><p>$ gem sources -a http://gemcutter.org<br />
$ [sudo] gem install off_github</p></blockquote>
<p><strong>Note: </strong>Rubyforge gems now points to Gemcutter, so the gem source adding isn&#8217;t technically needed to install off_github. That said, the off_github gem still checks for the Gemcutter source (it&#8217;s a bit outdated) and won&#8217;t work without it, so to get around it, install it before running, and you can remove it afterwards.</p>
<p>Now go ahead and run the off_github command. If you don&#8217;t use sudo to install gems, then be sure to add &#8211;no-sudo the end.</p>
<blockquote><p>$ off_github [--no-sudo]</p></blockquote>
<p>This&#8217;ll go ahead and return a list of gems that were installed from Github, what there Gemcutter gem name is, and the action it&#8217;ll take on that gem (usually reinstall). It&#8217;ll then ask you if you want to install. Type &#8216;Y&#8217;, hit enter, and then choose y/n/a at each prompt.</p>
<p>If everything went smoothly, you&#8217;re all done. You can now go ahead and delete both the Github and Gemcutter sources.</p>
<blockquote><p>$ gem sources -r http://gems.github.com<br />
$ gem sources -r http://gemcutter.org</p></blockquote>
<p>So know, you should have Rubyforge as your only gem source.</p>
<blockquote><p>$ gem sources<br />
*** CURRENT SOURCES ***<br />
http://gems.rubyforge.org</p></blockquote>
<p><strong>Additional Material:</strong></p>
<ul>
<li><a href="# http://www.rubypulse.com/episode-0.16_off_github.html">http://www.rubypulse.com/episode-0.16_off_github.html</a></li>
<li><a href="# http://www.rubypulse.com/episode-0.16.1_off_github_revisited.html">http://www.rubypulse.com/episode-0.16.1_off_github_revisited.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.katipo.co.nz/2010/01/19/migrating-from-github-to-gemcutter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
