<?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>Web Development Advice and Tips &#187; Linux</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>SmartLogic Solutions Blog</description>
	<lastBuildDate>Thu, 09 May 2013 14:52:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Installing PostGIS 1.5 on PostgreSQL 8.4 on Ubuntu</title>
		<link>http://blog.smartlogicsolutions.com/2010/03/04/installing-postgis-1-5-0-on-postgresql-8-4-on-ubuntu-9-10/</link>
		<comments>http://blog.smartlogicsolutions.com/2010/03/04/installing-postgis-1-5-0-on-postgresql-8-4-on-ubuntu-9-10/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 19:54:02 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[postgis]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=867</guid>
		<description><![CDATA[<p>I had a bit of trouble installing the latest PostGIS 1.5 under PostgreSQL 8.4. Here are my instructions. These work on Ubuntu 8.04, 9.04, 9.10, 10.04, and 10.10. UPDATE This post has been updated to include the awesome instructions from Leo regarding using the postgis-unstable ppa. Thanks Leo! 1. Install PostGIS from PPA System -> [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/03/28/adding-factory-girl-steps-to-turnip/"     class="crp_title">Adding Factory Girl steps to Turnip</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/12/how-user-stories-help-software-developers-know-what-the-___-to-do/"     class="crp_title">How User Stories Help Software Developers Know What The ___&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/12/12/api-versioning-3-ways-to-architect-your-api-to-handle-versioned-requests/"     class="crp_title">API Versioning: 3 Ways to Architect Your API to Handle&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/02/ios-development-dtattributedtextview-instead-of-uiwebview/"     class="crp_title">iOS Development with DTCoreText: Rendering HTML as App&hellip;</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2010/03/04/installing-postgis-1-5-0-on-postgresql-8-4-on-ubuntu-9-10/">Installing PostGIS 1.5 on PostgreSQL 8.4 on Ubuntu</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I had a bit of trouble installing the latest PostGIS 1.5 under PostgreSQL 8.4. Here are my instructions. These work on Ubuntu 8.04, 9.04, 9.10, 10.04, and 10.10.</p>
<p><span id="more-867"></span></p>
<p><strong>UPDATE</strong></p>
<p>This post has been updated to include the awesome instructions from Leo regarding using the postgis-unstable ppa. Thanks Leo!</p>
<h3>1. Install PostGIS from PPA</h3>
<p>System -> Administration -> Software Sources</p>
<p>Click on the &#8220;Other Software&#8221; tab.</p>
<p>Click on &#8220;+Add&#8221;</p>
<p>Enter: &#8220;ppa:ubuntugis/ubuntugis-unstable&#8221;</p>
<p>More info: <a href="https://launchpad.net/~ubuntugis/+archive/ubuntugis-unstable">https://launchpad.net/~ubuntugis/+archive/ubuntugis-unstable</a></p>
<p>Now install the package &#8220;postgresql-8.4-postgis&#8221;</p>
<h3>2. Setup your database</h3>
<pre class="wp-code-highlight prettyprint">createdb my_db
createlang plpgsql my_db
psql -d my_db -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
psql -d my_db -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
psql -d my_db -f /usr/share/postgresql/8.4/contrib/postgis_comments.sql</pre>
<p>Now you should be able to make a geometry table.</p>
<h3>3. Setup your geometry table</h3>
<p>At this point I&#8217;m showing how to make an example table. Your usage of the PostGIS library will probably differ.</p>
<pre class="wp-code-highlight prettyprint">create sequence points_id_seq;
create table points ( id integer primary key default nextval(&#039;points_id_seq&#039;) );
select AddGeometryColumn(&#039;points&#039;, &#039;location&#039;, 4326, &#039;POINT&#039;, 2);
create index points_location_idx on points using GIST ( location );

// Create a point
insert into points(location) values (ST_GeomFromText(&#039;POINT(-76.615657 39.327052)&#039;));

// Returns the point
select * from points where ST_Distance(location, ST_GeomFromText(&#039;POINT(-76 39)&#039;)) &lt; 1;

// Does not return the point
select * from points where ST_Distance(location, ST_GeomFromText(&#039;POINT(-76 39)&#039;)) &lt; .1;
</pre>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/03/28/adding-factory-girl-steps-to-turnip/"     class="crp_title">Adding Factory Girl steps to Turnip</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/12/how-user-stories-help-software-developers-know-what-the-___-to-do/"     class="crp_title">How User Stories Help Software Developers Know What The ___&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/12/12/api-versioning-3-ways-to-architect-your-api-to-handle-versioned-requests/"     class="crp_title">API Versioning: 3 Ways to Architect Your API to Handle&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/02/ios-development-dtattributedtextview-instead-of-uiwebview/"     class="crp_title">iOS Development with DTCoreText: Rendering HTML as App&hellip;</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2010/03/04/installing-postgis-1-5-0-on-postgresql-8-4-on-ubuntu-9-10/">Installing PostGIS 1.5 on PostgreSQL 8.4 on Ubuntu</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2010/03/04/installing-postgis-1-5-0-on-postgresql-8-4-on-ubuntu-9-10/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Setting Up Ubuntu 9.10 for Ruby On Rails Development</title>
		<link>http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/</link>
		<comments>http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 21:09:31 +0000</pubDate>
		<dc:creator>Adam Bachman</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Passenger]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Enterprise Edition]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[environment]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=860</guid>
		<description><![CDATA[<p>This is a document I put together at the beginning of 2010 while building yet another Ubuntu VM, digging through our internal documentation to try and find out what I needed. We've got the answers, and generally Ruby, Rails, and Ubuntu are pretty good about telling you how to install tools if you don't have them yet.

But the answers are spread out and distributed randomly. Plus, I can only see "The program '______' is currently not installed. You can install it by typing: sudo apt-get install ______" so many times before I lose interest and put off the task.

So, to prevent future headaches and help all of us out, I put together a how-to that can take a new Rails system from zero to code in a few minutes (depending on network speed) instead of half a day.<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/09/27/automate-away-the-pain-of-multiple-database-yml-files/"     class="crp_title">Automate Away the Pain of Multiple Database.yml Files</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/">Setting Up Ubuntu 9.10 for Ruby On Rails Development</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>This is a document I put together at the beginning of 2010 while building yet another Ubuntu VM, digging through our internal documentation to try and find out what I needed. We&#8217;ve got the answers, and generally Ruby, Rails, and Ubuntu are pretty good about telling you how to install tools if you don&#8217;t have them yet.</p>
<p>But the answers are spread out and distributed randomly. Plus, I can only see &#8220;The program &#8216;______&#8217; is currently not installed. You can install it by typing: sudo apt-get install ______&#8221; so many times before I lose interest and put off the task.</p>
<p><span id="more-860"></span></p>
<p>So, to prevent future headaches and help all of us out, I put together a how-to that can take a new Rails system from zero to code in a few minutes (depending on network speed) instead of half a day. With no further ado,</p>
<h2>Setting up an Ubuntu box for Rails Development (including virtual machines)</h2>
<h4>Update everything</h4>
<pre class="wp-code-highlight prettyprint">$ sudo aptitude update &amp;amp;&amp;amp; sudo aptitude dist-upgrade</pre>
<h4>Install necessary packages</h4>
<pre class="wp-code-highlight prettyprint">$ sudo aptitude install build-essential vim \
  vim-runtime git-core subversion libsqlite3-dev</pre>
<p>We have projects in git (the newer ones) and svn, so we have to be able to switch fluidly between the two.</p>
<p>And I&#8217;m not trying to start a flame war, but Vim is the first choice for Rails development. You don&#8217;t have to take my word for it; <a href="http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim">Jamis Buck</a>, <a href="http://github.com/tpope">Tim Pope</a>, and <a href="http://www.adamlowe.me/2009/12/vim-destroys-all-other-rails-editors.html">Adam Lowe</a> all say the same. I recommend the NERDTree, FuzzyFinderTextMate, BufExplorer, and rails.vim plugins if nothing else.</p>
<h4>Install ruby</h4>
<pre class="wp-code-highlight prettyprint">$ sudo aptitude install ruby1.8 ruby rdoc ruby1.8-dev \
  libpgsql-ruby1.8 libmysql-ruby1.8 irb libopenssl-ruby</pre>
<h4>Get rubygems from source. <a href="http://docs.rubygems.org/">http://docs.rubygems.org/</a></h4>
<pre class="wp-code-highlight prettyprint">$ wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz</pre>
<pre class="wp-code-highlight prettyprint">$ tar xzvf rubygems-1.3.5.tgz</pre>
<pre class="wp-code-highlight prettyprint">$ cd rubygems-1.3.5</pre>
<pre class="wp-code-highlight prettyprint">$ sudo ruby setup.rb</pre>
<pre class="wp-code-highlight prettyprint">$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem</pre>
<pre class="wp-code-highlight prettyprint">$ sudo gem update --system</pre>
<h4>Update ~/.gemrc (at least the :sources: chunk)</h4>
<pre class="wp-code-highlight prettyprint">---
gem: --no-ri --no-rdoc
:benchmark: false
:verbose: true
:backtrace: false
:update_sources: true
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
- http://gems.github.com</pre>
<h4>Install and setup Passenger (optional)</h4>
<pre class="wp-code-highlight prettyprint">$ sudo apt-get install apache2-prefork-dev</pre>
<pre class="wp-code-highlight prettyprint">$ sudo gem install passenger</pre>
<pre class="wp-code-highlight prettyprint">$ sudo passenger-install-apache2-module</pre>
<p>and follow the instructions passenger gives you. Most folks in the office run some form of an Apache-Passenger stack for development purposes. I can explain how that setup works in a future post.</p>
<h4>Install geminstaller</h4>
<pre class="wp-code-highlight prettyprint">$ sudo gem install geminstaller</pre>
<p>Almost all of our legacy projects use <a href="http://geminstaller.rubyforge.org/">geminstaller</a> to manage gem dependencies. In the future, new projects will be moving to <a href="http://github.com/wycats/bundler">Bundler</a>, but legacy projects matter and upgrading subsystems is not always justified.</p>
<p>&#8220;If it ain&#8217;t broke, don&#8217;t fix it&#8221; and the corollary: &#8220;because you probably won&#8217;t be able to bill it to the client&#8221; both apply.</p>
<h4>Install common packages (optional, may be required by projects)</h4>
<pre class="wp-code-highlight prettyprint">$ sudo aptitude install imagemagick</pre>
<pre class="wp-code-highlight prettyprint">$ sudo gem install utility_belt open_gem redgreen</pre>
<p>The first (imagemagick) is used by the Paperclip gem to manage files attached to Rails models. The second are tools that make Rails development more manageable on the command line. I highly recommend them. Besides, I&#8217;ve been sneaking redgreen in as a test dependency on our projects, so if you&#8217;re a developer here you&#8217;ll have to install it anyways.</p>
<h4>Create an ssh key (follow instructions)</h4>
<pre class="wp-code-highlight prettyprint">$ ssh-keygen</pre>
<h3>EXAMPLE PROJECT</h3>
<p>All the stuff above won&#8217;t let you test-code-deploy without hassles, so here&#8217;s a sample run through of what the last mile of project-specific setup looks like.</p>
<h4>Get the project. SVN, Git, whatever. Go to it.</h4>
<pre class="wp-code-highlight prettyprint">$ svn co rails-project</pre>
<pre class="wp-code-highlight prettyprint">$ cd rails-project</pre>
<h4>Run geminstaller</h4>
<pre class="wp-code-highlight prettyprint">$ sudo geminstaller                                 # normal</pre>
<pre class="wp-code-highlight prettyprint">$ sudo geminstaller -c config/test/geminstaller.yml # test env</pre>
<h4>Install necessary aptitude packages</h4>
<pre class="wp-code-highlight prettyprint">$ sudo aptitude install texlive-latex-base</pre>
<p>Don&#8217;t ask.</p>
<h4>Create the test database</h4>
<p>Mysql:</p>
<pre class="wp-code-highlight prettyprint">$ rake RAILS_ENV=test db:create</pre>
<p>Postgres (using your username or DB username in place of &#8220;username&#8221;):</p>
<pre class="wp-code-highlight prettyprint">$ sudo -u postgres psql</pre>
<pre class="wp-code-highlight prettyprint">postgres=# CREATE USER username SUPERUSER;</pre>
<pre class="wp-code-highlight prettyprint">postgres=# CREATE DATABASE username OWNER username;</pre>
<p>If you get an error regarding PGconn.quote_ident (Rails 2.3.x on Ubuntu 8.04) patch <code>activerecord-2.3.4/lib/active_record/connection_adapters/postgresql_adapter.rb</code> and add the following:</p>
<pre class="wp-code-highlight prettyprint">def PGconn.quote_ident(name)
  %(&quot;#{name}&quot;)
end</pre>
<p>immediately after the &#8220;class PGresult&#8221; definition at the top of the file. Once that&#8217;s all done, the following:</p>
<pre class="wp-code-highlight prettyprint">$ rake RAILS_ENV=test db:create</pre>
<pre class="wp-code-highlight prettyprint">$ rake RAILS_ENV=test db:schema:load</pre>
<pre class="wp-code-highlight prettyprint">$ rake RAILS_ENV=test test</pre>
<p>should work.</p>
<h3>go have fun, write code, blow our minds</h3>
<p>So that&#8217;s how we roll. Awkward requirements will still crop up as we pick up new projects (or very old projects) so you&#8217;ll always need a bit of apt/gem fu to get you through the day. Leave questions here or drop me a line at <a href="mailto:adam@smartlogicsolutions.com">adam@smartlogicsolutions.com</a> or <a href="http://twitter.com/abachman">http://twitter.com/abachman</a>.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/09/27/automate-away-the-pain-of-multiple-database-yml-files/"     class="crp_title">Automate Away the Pain of Multiple Database.yml Files</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/">Setting Up Ubuntu 9.10 for Ruby On Rails Development</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2010/02/01/setting-up-ubuntu-9-10-for-ruby-on-rails-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using Byobu and Landscape to improve remote Ubuntu sessions</title>
		<link>http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/</link>
		<comments>http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 20:44:11 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=827</guid>
		<description><![CDATA[<p>SSHing into remote servers can be an awkward experience, but it doesn&#8217;t have to be. You can turn your ssh console into a terminal-style window manager with Byobu, and get more system information via landscape. &#8220;Byobu is a Japanese term for decorative, multi-panel screens that serve as folding room dividers. As an open source project, [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/09/11/rest-fest-3-things-im-looking-forward-to/"     class="crp_title">REST Fest: 3 Things I&#8217;m Looking Forward To</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/02/20/ios-development/"     class="crp_title">iOS Development: How to Create a Lightbox Effect</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/">Using Byobu and Landscape to improve remote Ubuntu sessions</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>SSHing into remote servers can be an awkward experience, but it doesn&#8217;t have to be. You can turn your ssh console into a terminal-style window manager with Byobu, and get more system information via landscape.<br />
<span id="more-827"></span></p>
<blockquote><p><em>&#8220;Byobu is a Japanese term for decorative, multi-panel screens that serve as folding room dividers. As an open source project, Byobu is an elegant enhancement of the otherwise functional, plain, practical GNU Screen.&#8221;</em></p>
<p><a href="https://wiki.ubuntu.com/MeetingLogs/openweekKarmic/Byobu">https://wiki.ubuntu.com/MeetingLogs/openweekKarmic/Byobu</a></p></blockquote>
<p>SSH into your server and install the two packages:</p>
<blockquote><p><code><strong>sudo apt-get install byobu landscape-common update-motd</strong></code></p></blockquote>
<p>Next, run byobu-config:</p>
<div id="attachment_832" class="wp-caption aligncenter" style="width: 652px"><img class="size-full wp-image-832" title="byobu-config" src="http://blog.smartlogicsolutions.com/wp-content/uploads/2010/01/byobu-config.png" alt="Change Byobu settings with byobu-config" width="642" height="400" /><p class="wp-caption-text">Change byobu settings with byobu-config</p></div>
<p>You can change Byobu&#8217;s colors if you&#8217;d like. I like the &#8220;dark&#8221; theme.</p>
<p>The important setting to change is the last one: &#8220;<strong>Byobu currently does not launch at login</strong>&#8220;. Select that and press return. Now you can go back to the menu and exit byobu-config (tab to the exit choice and hit return).</p>
<p>Now log out and log back in again. You&#8217;ll now access Byobu automatically.</p>
<div id="attachment_841" class="wp-caption aligncenter" style="width: 652px"><img class="size-full wp-image-841" title="byobu-login" src="http://blog.smartlogicsolutions.com/wp-content/uploads/2010/01/byobu-login.png" alt="Byobu as your session manager" width="642" height="400" /><p class="wp-caption-text">Byobu as your session manager</p></div>
<p>The new MOTD (that&#8217;s &#8220;Message of the Day&#8221;, which is the text that is displayed when you login) has system information, thanks to <strong>landscape-common</strong>. This will let you know if your almost out of memory or disk space, or if you&#8217;re under heavy load.</p>
<p>Now let&#8217;s look at the information Byobu provides. The bottom row of Byobu contains, from left to right, your Distribution logo and name, uptime, load, cpu frequencies, ram amount and usage, and the date.</p>
<p>The upper row are your windows. Press <strong>F2</strong> to create a new window. Along the bottom of the screen you&#8217;ll now see two entries in the top row of the footer. Press <strong>F3</strong> to move to the previous window and <strong>F4</strong> to move to the next window.</p>
<p>Press <strong>F8</strong>, then give the window a name, like &#8220;echo&#8221;. I like to name each tab with the task I&#8217;m doing, like &#8220;console&#8221;, &#8220;mysql&#8221;, and &#8220;top&#8221;.</p>
<p>You can press <strong>F7</strong> to enter copy/scrollback mode. Use the arrow and page-up/down keys to move around your session. Press the spacebar to start copying. Now move your cursor somewhere else. Then press space again to copy the selection. Byobu doesn&#8217;t have a paste hotkey, so you have to use the screen hotkey, which is <strong>CTRL-a ]</strong> (thats <strong>CTRL-a</strong>, then let go of control and press <strong>]</strong>).</p>
<p>You can press <strong>F12</strong> to quickly lock your terminal, to grab a quick cup of coffee (or read this blog!).</p>
<p>Let&#8217;s explore how to maintain a session. Issue the following command:</p>
<blockquote><p><code><strong>echo hi</strong></code></p></blockquote>
<p>That will print out &#8220;hi&#8221; on the screen. Now let&#8217;s exit this session. Press the Byobu hotkey <strong>F6</strong> to &#8220;Detach&#8221; from Byobu.</p>
<p>You&#8217;ll notice you&#8217;re still logged in, this is because Byobu is an application that runs on top of your session. So now you have to exit again to get back to your local machine.</p>
<p>Now SSH back into your machine. You&#8217;ll notice that command is still on the screen! &#8220;Detaching&#8221; does not end your session, it just detaches you from it. That means you can log in, run a long running task, and then Detach and come back in the morning when your task is done.</p>
<p>For extended information on Byobu, check out its <a href="http://manpages.ubuntu.com/manpages/karmic/en/man1/byobu.1.html">Ubuntu Man Page</a>.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/09/11/rest-fest-3-things-im-looking-forward-to/"     class="crp_title">REST Fest: 3 Things I&#8217;m Looking Forward To</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/02/20/ios-development/"     class="crp_title">iOS Development: How to Create a Lightbox Effect</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/">Using Byobu and Landscape to improve remote Ubuntu sessions</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2010/01/22/ubuntu-byobu-landscape/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mount options to improve ext4 file system performance</title>
		<link>http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 15:15:26 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=677</guid>
		<description><![CDATA[<p>I recently boosted my rails test suite running time by around 30% by adding certain mount options for my ext4 partition (works for ext3 too). I thought I&#8217;d blog about it because the first time I tried my system wouldn&#8217;t boot! So here are the step by step instructions: 2) Run: > tune2fs -o journal_data_writeback [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/11/28/using-pull-requests-to-improve-code-quality-process-and-skills/"     class="crp_title">Using Pull Requests to Improve Code Quality, Process, and&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/08/testing-ajax-with-testunit/"     class="crp_title">Testing AJAX with Test::Unit</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/">Mount options to improve ext4 file system performance</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I recently boosted my rails test suite running time by around <strong>30%</strong> by adding certain mount options for my ext4 partition (works for ext3 too). I thought I&#8217;d blog about it because the first time I tried my system wouldn&#8217;t boot! So here are the step by step instructions:</p>
<p><span id="more-677"></span></p>
<p><strong>2) Run:</strong><br />
> tune2fs -o journal_data_writeback /dev/sdXY<br />
Where /dev/sdXY is replaced by the partition that you want to boost</p>
<p><strong>4) Edit fstab</strong></p>
<p>> nano -w /mnt/sdXY/etc/fstab</p>
<p>Find the line that references sdXY. It will look something like:</p>
<p><code># /dev/sda2<br />
UUID=be2f0ac2-4683-4550-bcd1-704a1a840b3e / ext4 relatime,errors=remount-ro 0 1</code></p>
<p>The first entry is the UUID (although on your system this could just be /dev/sdXY). The second entry is the path (/ for me). Third is the fstype (ext3/4). Fourth are the options. Fifth is for dump and sixth is pass. See man fstab(5) for more info.</p>
<p>Change the options to:</p>
<p><code>noatime,data=writeback,barrier=0,nobh,errors=remount-ro</code></p>
<p>(you can leave all of yours in place, if they weren&#8217;t the same as mine.</p>
<p>The main ones are replacing atime/relatime with <strong>noatime</strong>. This causes the FS to not write read-times to a file when read. Think about it. Writing to the FS for every read of the FS? crazy!</p>
<p>Next is <strong>data=writeback</strong>. This means that metadata for files can be written lazily after the file is written. This will not cause file system corruption, but it may cause the most recent changes to be lost in the event of a crash (so you may jump back into the past a bit).</p>
<p>Next is barrier, which is slightly more dangerous:</p>
<blockquote><p>barrier=<0|1(*)> This enables/disables the use of write barriers in<br />
the jbd code. barrier=0 disables, barrier=1 enables.<br />
This also requires an IO stack which can support<br />
barriers, and if jbd gets an error on a barrier<br />
write, it will disable again with a warning.<br />
Write barriers enforce proper on-disk ordering<br />
of journal commits, making volatile disk write caches<br />
safe to use, at some performance penalty. If<br />
your disks are battery-backed in one way or another,<br />
disabling barriers may safely improve performance.</p></blockquote>
<p>Next is nobh:</p>
<blockquote><p>bh (*) ext4 associates buffer heads to data pages to<br />
nobh (a) cache disk block mapping information<br />
(b) link pages into transaction to provide<br />
ordering guarantees.<br />
&#8220;bh&#8221; option forces use of buffer heads.<br />
&#8220;nobh&#8221; option tries to avoid associating buffer<br />
heads (supported only for &#8220;writeback&#8221; mode).</p></blockquote>
<p>You can skip barrier and nobh if you&#8217;d like. noatime and data=writeback are the big ones.</p>
<p><strong>6) Reboot to your system.</strong></p>
<p>If you have any trouble booting, just boot a recovery disk and revert the fstab changes.</p>
<p>EDIT: Updated to no longer require recovery disk booting thanks to <a href="http://www.notgeeklycorrect.com/resources/2010/01/06/accelerate-your-tests-in-rails-with-ubuntu/">Nicolas Alpi&#8217;s response post</a>.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/11/28/using-pull-requests-to-improve-code-quality-process-and-skills/"     class="crp_title">Using Pull Requests to Improve Code Quality, Process, and&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/08/testing-ajax-with-testunit/"     class="crp_title">Testing AJAX with Test::Unit</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/">Mount options to improve ext4 file system performance</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Find the Unique Sessions for a Rails Application</title>
		<link>http://blog.smartlogicsolutions.com/2009/05/04/find-the-unique-sessions-for-a-rails-application/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/05/04/find-the-unique-sessions-for-a-rails-application/#comments</comments>
		<pubDate>Mon, 04 May 2009 15:32:47 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[log files]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=617</guid>
		<description><![CDATA[<p>Today we&#8217;re going to look at how to find the number of unique sessions over a specific time frame for a rails application. We&#8217;ll be using the slow-actions gem. Slow-Actions is great tool for determining the slow areas of a rails application. Since it is built on a rails log parser, it can be used [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/10/25/api-development/"     class="crp_title">API Development: Turning Controller Actions into Services</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/05/04/find-the-unique-sessions-for-a-rails-application/">Find the Unique Sessions for a Rails Application</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Today we&#8217;re going to look at how to find the number of unique sessions over a specific time frame for a rails application. We&#8217;ll be using the <a href="http://github.com/ngauthier/slow-actions/tree/master">slow-actions</a> gem.</p>
<p><span id="more-617"></span></p>
<p>Slow-Actions is great tool for determining the slow areas of a rails application. Since it is built on a rails log parser, it can be used for many other things. For example, here is some standard output from slow-actions when you want to know the speed of different user sessions within a specific date range:</p>
<pre class="wp-code-highlight prettyprint">
slow-actions log/development.log --sessions --start-date=2009-03-01 --end-date=2009-04-01
           Cost    Average Max
+ ece0e17b48a5fe0fc766fa42f199fb66 (51 entries, 58% Error)
| Total:   2883.262 732.948 3100.00 
| Render:  0.00000 0.00000 0.00000 
| DB:      55.8220 14.1900 99.0000 

+ e1181ad94b34b41aff2a74ee62d5fb57 (10 entries, 30% Error)
| Total:   1563.912 676.276 1426.00 
| Render:  0.00000 0.00000 0.00000 
| DB:      14.5350 6.28500 19.0000 

+ 867bc340e6d65e673f29c57189feaf2b (133 entries, 0% Error)
| Total:   1083.138 221.450 386.000 
| Render:  0.00000 0.00000 0.00000 
| DB:      44.2030 9.03700 90.0000 

Etc...
</pre>
<p>Now, if we grep for &#8220;entries&#8221; we get a line for each session:</p>
<pre class="wp-code-highlight prettyprint">
slow-actions log/development.log --sessions --start-date=2009-03-01 --end-date=2009-04-01 | grep entries
+ ece0e17b48a5fe0fc766fa42f199fb66 (51 entries, 58% Error)
+ e1181ad94b34b41aff2a74ee62d5fb57 (10 entries, 30% Error)
+ 867bc340e6d65e673f29c57189feaf2b (133 entries, 0% Error)
+ 99b39c7a9af55fc01056b5f127dc4c98 (75 entries, 0% Error)
+ 6ee15c4f3bc804ac68e9e868d9c3f7e6 (14 entries, 0% Error)
+ 80928c25c83590c4f89b91f8d4c8896d (9 entries, 0% Error)
+ c78cfa1cb086b3f473015b212ca3da11 (12 entries, 0% Error)
+ 48cd02cf6544493077c84eb16821bda2 (3 entries, 66% Error)
+ ac027817dcf87d473efb54cd737b2a80 (2 entries, 0% Error)
+ dff2ca2678852b06bbb6c7ca0a85b0a9 (1 entries, 0% Error)
+ 08ed3bc031c23bd3b2572ef7ce60d066 (1 entries, 0% Error)
</pre>
<p>Pipe that to word count, and we have the number of unique sessions within a specified time period:</p>
<pre class="wp-code-highlight prettyprint">
slow-actions log/development.log --sessions --start-date=2009-03-01 --end-date=2009-04-01 | grep entries | wc -l
11
</pre>
<p>On a 54m log file, that takes only 0.761s!</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/05/how-to-save-time-when-reformatting-dates-in-vim/"     class="crp_title">Vim Tip: How to Reformat Dates in 7 Steps</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/10/25/api-development/"     class="crp_title">API Development: Turning Controller Actions into Services</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/20/10-cocoaconf-dc-2013-sessions/"     class="crp_title">10 CocoaConf DC 2013 Sessions to Be Excited About</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/05/04/find-the-unique-sessions-for-a-rails-application/">Find the Unique Sessions for a Rails Application</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/05/04/find-the-unique-sessions-for-a-rails-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Sanitize Email to Preview HTML Emails Locally</title>
		<link>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 13:26:04 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=605</guid>
		<description><![CDATA[<p>John Trupiano has a great post to get you started with sanitize_email for Ruby on Rails. I wanted to preview my HTML emails without having to fill up my online email inboxes with tons of email (and then I&#8217;d have to make filters too). I also didn&#8217;t want to manage actually sending real email. So, [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/03/28/adding-factory-girl-steps-to-turnip/"     class="crp_title">Adding Factory Girl steps to Turnip</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/">Using Sanitize Email to Preview HTML Emails Locally</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.smartlogicsolutions.com/wiki/John_Trupiano">John Trupiano</a> has <a href="http://blog.smartlogicsolutions.com/2009/04/25/reintroducing-sanitize_email-work-with-production-email-without-fear/">a great post</a> to get you started with <a href="http://github.com/jtrupiano/sanitize_email/tree/master">sanitize_email</a> for Ruby on Rails.</p>
<p>I wanted to preview my HTML emails without having to fill up my online email inboxes with tons of email (and then I&#8217;d have to make filters too). I also didn&#8217;t want to manage actually sending real email. So, I set up my machine for local delivery. Read on for instructions.<br />
<span id="more-605"></span><br />
I am running Ubuntu 9.04, however these instructions should be fine at least back to 8.04.</p>
<h3>Step 1 &#8211; Install Postfix</h3>
<p><code>sudo aptitude install postfix</code></p>
<p>During the install, choose &#8220;Local Delivery Only&#8221;</p>
<h3>Step 2 &#8211; Configure Evolution for Receiving Locally</h3>
<p>Open up Evolution &#8220;Applications->Internet->Evolution Mail&#8221;</p>
<p>Set up a new account and choose local delivery. When it asks you for a path, put in:</p>
<p><code>/var/mail/&lt;username&gt;</code></p>
<p>Note that this path may not exist if you&#8217;ve never received mail.</p>
<h3>Step 3 &#8211; Configure Sanitize Email</h3>
<p>In your rails test environment.rb put:</p>
<p><code>config.action_mailer.delivery_method = :sendmail</code></p>
<p>Then, in the initializer where you set up sanitize email:</p>
<p><code>ActionMailer::Base.sanitized_recipients = ["<username>@<hostname>"]<br />
ActionMailer::Base.local_environments = %w( test )</code></p>
<p>If you need to know your username or hostname, just open up a terminal. The command &#8220;whoami&#8221; will give you your username, and &#8220;hostname&#8221; will give you the hostname.</p>
<h3>Step 4 &#8211; Run your tests</h3>
<p>Now, run your rails tests. You <em>should</em> have a test for every email you send, and that should trigger them to be sent locally. You may have to tell Evolution to Send/Receive. Keep in mind your tests will probably fail because they will expect email to be in test mode.</p>
<h3>Step 5 &#8211; Set it back</h3>
<p>Remember, when you&#8217;re done previewing your email, reset config.action_mailer.delivery_method!</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/03/28/adding-factory-girl-steps-to-turnip/"     class="crp_title">Adding Factory Girl steps to Turnip</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/">Using Sanitize Email to Preview HTML Emails Locally</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/04/30/using-sanitize-email-to-preview-html-emails-locally/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</title>
		<link>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 17:38:28 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[Integrity]]></category>
		<category><![CDATA[Passenger]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Enterprise Edition]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[ree]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=592</guid>
		<description><![CDATA[<p>I just spent a few hours trying to get this configuration sorted out, so I thought I&#8217;d share my notes. My goal was to get Integrity running on Passenger with Ruby Enterprise Edition. However, I couldn&#8217;t get the user Integrity/Apache was running as to use the proper PATH. Whenever Integrity would try to build my [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/08/20/testing-pdf-content-with-capybara/"     class="crp_title">Testing PDF Content with Capybara</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/27/cocoaconf-dc-5-highlights/"     class="crp_title">Looking Back on CocoaConf DC: 5 Highlights</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/">Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I just spent a few hours trying to get this configuration sorted out, so I thought I&#8217;d share my notes.  My goal was to get <a href="http://integrityapp.com/">Integrity</a> running on <a href="http://modrails.com/">Passenger</a> with <a href="http://rubyenterpriseedition.com/">Ruby Enterprise Edition</a>.  However, I couldn&#8217;t get the user Integrity/Apache was running as to use the proper PATH.</p>
<p>Whenever Integrity would try to build my project, I&#8217;d get an error about rake not being able to be found: <code>sh: rake: not found</code></p>
<p><span id="more-592"></span></p>
<p>This totally threw me.  I had added it to /etc/environment</p>
<pre class="wp-code-highlight prettyprint">
PATH=&quot;/opt/ruby/bin:$PATH&quot;
</pre>
<p>and so it was certainly on my PATH:</p>
<pre class="wp-code-highlight prettyprint">
john@john-ci:~$ echo $PATH
/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</pre>
<p>I had also added it to /root/.bash_profile so that root would have it picked up:</p>
<pre class="wp-code-highlight prettyprint">
john@john-ci:~$ sudo su -
root@john-ci:~# echo $PATH
/opt/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</pre>
<p>So why wasn&#8217;t Apache/Integrity picking it up?  To seek this out, I opened up the Integrity source and edited /opt/ruby/lib/ruby/gems/1.8/gems/integrity-0.1.9.3/lib/integrity/project_builder.rb to output the values of `whoami` and $PATH to help me troubleshoot.</p>
<pre class="wp-code-highlight prettyprint">
IO.popen(&quot;(echo `whoami` &amp;&amp; echo $PATH &amp;&amp; cd #{scm.working_directory} &amp;&amp; $
          |output| build.output = output.read }
</pre>
<p>Doing this yielded the following output:</p>
<pre class="wp-code-highlight prettyprint">
www-data
/usr/local/bin:/usr/bin:/bin
</pre>
<p>At this point, I wholly expected the PATH to not include /opt/ruby/bin, so this isn&#8217;t a surprise.  But why is this being set?</p>
<h3>The Real Problem</h3>
<p>The real issue here was that I was trying to set the PATH in scripts that only get run when a shell is entered.  Since apache starts up as a system process, it is not started from a shell, and does not have a PATH associated with it.  In fact, if you open up /etc/init.d/apache, you&#8217;ll see on one of the first few lines that the PATH is distinctly set:</p>
<pre class="wp-code-highlight prettyprint">
ENV=&quot;env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin&quot;
</pre>
<p>This was precisely the PATH I was seeing when I hacked Integrity to output its PATH just prior to failing the Rake command.  Now it&#8217;s fairly obvious that I just need to add in /opt/ruby/bin to the front of that PATH, and Integrity will be able to execute all of my ruby/rubygem executables (most importantly rake).</p>
<h3>Recap of Steps to Install</h3>
<ol>
<li><a href="http://rubyenterpriseedition.com/download.html">Download</a> and install REE</li>
<li>Create a symlink for /opt/ruby so it&#8217;s dead simple to upgrade when a new REE comes out: <code>sudo ln -s /opt/ruby-enterprise-whatever-version-you-installed /opt/ruby</code></li>
<li>edit /etc/environment to add /opt/ruby/bin to your shell PATH : <code>PATH=/opt/ruby/bin:$PATH</code></li>
<li>edit ~/.bash_profile to alias sudo so that sudo can inherit your environment : <code>alias sudo='sudo env PATH=$PATH'</code></li>
<li>Reload your environment to pick up the new PATH: <code>source /etc/environment &#038;&#038; source ~/.bash_profile</code></li>
<li>Install Passenger: <code>sudo gem install passenger &#038;&#038; passenger-install-apache2-module</code></li>
<li>Install Integrity Gem: <code>sudo gem install integrity</code></li>
<li>Install Integrity Home: <code>sudo integrity install --passenger ~www-data/integrity</code></li>
<li>Install do_sqlite3 Gem: <code>sudo gem install do_sqlite3</code></li>
<li>Prepare Integrity Database: <code>cd ~www-data/integrity &#038;&#038; sudo integrity migrate_db config.yml</code></li>
<li>Grant ownership of all integrity files to www-data: <code>sudo chown -R www-data:www-data ~www-data/integrity</code></li>
<li>Create Apache config for Integrity: <code>sudo nano -w /etc/apache2/sites-available/integrity</code>:
<pre class="wp-code-highlight prettyprint">
&lt;VirtualHost *&gt;
  ServerName ci.yourdomain.com
  DocumentRoot /var/www/integrity/public
&lt;/VirtualHost&gt;
</pre>
</li>
<li>Enable the site: <code>sudo ln -s /etc/apache2/sites-available/integrity /etc/apache2/sites-enabled/002-integrity</code></li>
<li>Edit /etc/init.d/apache2 and add /opt/ruby/bin to the PATH as described above: <code>ENV="env -i LANG=C PATH=/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin"</code></li>
<li>Restart Apache: <code>sudo /etc/init.d/apache2 restart</code></li>
<li>Navigate to http://ci.yourdomain.com/ and start adding projects.</li>
</ol>
<p>Boy, that was a mouthful.  Please let me know if you&#8217;ve also been successful, and if there are any other steps you take to set up Integrity with REE and Passenger.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/08/20/testing-pdf-content-with-capybara/"     class="crp_title">Testing PDF Content with Capybara</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/03/27/cocoaconf-dc-5-highlights/"     class="crp_title">Looking Back on CocoaConf DC: 5 Highlights</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/">Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>EXT4 On Ubuntu 9.04</title>
		<link>http://blog.smartlogicsolutions.com/2009/01/16/ext4-on-ubuntu-904/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/01/16/ext4-on-ubuntu-904/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 19:50:18 +0000</pubDate>
		<dc:creator>Nick Gauthier</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=485</guid>
		<description><![CDATA[<p>Ext4 got some attention recently because it was able to boot ubuntu to the login screen in about 20 seconds. However, the current daily release doesn&#8217;t support installing with Ext4. Here are the instructions for installing Ext4 onto the Ubuntu 9.04 (Jaunty Jackalope) daily-live cd. First of all. Back up all your data. Don&#8217;t do [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/20/3288-slices-the-baltimore-tech-communitys-2012-growth-measured-in-pizza/"     class="crp_title">3288 Slices: The Baltimore Tech Community’s 2012 Growth&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/11/nicks-highlights-from-windy-city-rails/"     class="crp_title">Nick&#8217;s Highlights from Windy City Rails</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/12/12/api-versioning-3-ways-to-architect-your-api-to-handle-versioned-requests/"     class="crp_title">API Versioning: 3 Ways to Architect Your API to Handle&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/01/16/ext4-on-ubuntu-904/">EXT4 On Ubuntu 9.04</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Ext4 got some attention recently because it was able to boot ubuntu to the login screen in about 20 seconds. However, the current daily release doesn&#8217;t support installing with Ext4. Here are the instructions for installing Ext4 onto the Ubuntu 9.04 (Jaunty Jackalope) daily-live cd.<br />
<span id="more-485"></span><br />
First of all. Back up all your data. Don&#8217;t do this on your primary computer. This is still ALPHA software. If you have an existing Windows or Linux install, you&#8217;ll have to do partitioning differently. If you don&#8217;t know how to do that, this guide probably isn&#8217;t for you.</p>
<p>Now then, the guide:</p>
<p>1) Download the 9.04 daily live from here:</p>
<p>http://cdimage.ubuntu.com/daily-live/current/</p>
<p>2) Burn or mount in a VM<br />
3) Boot<br />
4) Run the installer. When it asks for partitioning, select manual.<br />
5) Create a small (128m is good) Ext2 primary partition and mount it at /boot<br />
6) Create a swap primary partition (1024m is a good min, up to however much ram you have is good. No more than 4096m is necessary).<br />
7) Create a third primary partition that uses the rest of the space, type Ext3, mount as root.<br />
8) Proceed through the rest of the install.<br />
9) When it asks you if you want to reboot, say &#8220;Continue using livecd&#8221;<br />
10) Open a terminal<br />
11) Your root partition should be /dev/sda3 if you just had those three partitions. If not, substitude /dev/sdaX for /dev/DEV when I mention it.<br />
12) On the terminal, run &#8220;sudo tune2fs -O extents,uninit_bg,dir_index /dev/DEV&#8221;<br />
13) Then run:</p>
<pre class="wp-code-highlight prettyprint">sudo fsck -pf /dev/DEV
sudo mkdir /mnt/root
sudo mount /dev/DEV /mnt/root
sudo nano -w /mnt/root/etc/fstab
</pre>
<p>and change the &#8220;ext3&#8243; to &#8220;ext4&#8243; on the / partition.<br />
14) Reboot</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2012/12/20/3288-slices-the-baltimore-tech-communitys-2012-growth-measured-in-pizza/"     class="crp_title">3288 Slices: The Baltimore Tech Community’s 2012 Growth&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/11/nicks-highlights-from-windy-city-rails/"     class="crp_title">Nick&#8217;s Highlights from Windy City Rails</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/12/12/api-versioning-3-ways-to-architect-your-api-to-handle-versioned-requests/"     class="crp_title">API Versioning: 3 Ways to Architect Your API to Handle&hellip;</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/01/16/ext4-on-ubuntu-904/">EXT4 On Ubuntu 9.04</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/01/16/ext4-on-ubuntu-904/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benchmark Ruby Code with R, rsruby and better-benchmark</title>
		<link>http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 16:53:38 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[Benchmarking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[mac osx]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[rsruby]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=275</guid>
		<description><![CDATA[<p>I&#8217;ve found myself on a benchmarking kick these last couple of weeks. Sometime last week, I dug up the better-benchmark library written by Pistos. Pistos&#8217; library is basically just a wrapper for the rsruby gem, which is more or less an interface to R (similar to what rmagick is to ImageMagick). Combining these tools together, [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2010/10/08/testing-ajax-with-testunit/"     class="crp_title">Testing AJAX with Test::Unit</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/">Benchmark Ruby Code with R, rsruby and better-benchmark</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve found myself on a benchmarking kick these last couple of weeks.  Sometime last week, I dug up the <a href="http://github.com/Pistos/better-benchmark/tree/master">better-benchmark</a> library written by <a href="http://github.com/Pistos">Pistos</a>.  Pistos&#8217; library is basically just a wrapper for the <a href="http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/">rsruby gem</a>, which is more or less an interface to <a href="http://www.r-project.org/">R</a> (similar to what <a href="http://rmagick.rubyforge.org/">rmagick</a> is to <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a>).</p>
<p>Combining these tools together, we can do some pretty nifty code performance analysis in very few lines of code, e.g.</p>
<pre class="wp-code-highlight prettyprint">
require &#039;rubygems&#039;
require &#039;better-benchmark&#039;

result = Benchmark.compare_realtime(:iterations =&gt; 10) { |iteration|
  save_the_world()
}.with { |iteration|
  save_the_world_and_save_the_girl()
}
Benchmark.report_on result
</pre>
<p>I have <a href="http://github.com/jtrupiano/better-benchmark/tree/master">forked better-benchmark</a> and wrapped the library up into a <a href="http://www.rubygems.org/">RubyGem</a>.  </p>
<p><span id="more-275"></span></p>
<p>Currently, the gem is available from github:</p>
<pre class="wp-code-highlight prettyprint">
$&gt; sudo gem install jtrupiano-better-benchmark
</pre>
<p>Based on preliminary discussions with Pistos, he intends to merge my changes back into his branch.  I&#8217;ll update this post with the relevant details when that has been completed.</p>
<p>So, let&#8217;s get started by preparing your box for better-benchmark!</p>
<h2>Installing R</h2>
<h3>On Mac OSX</h3>
<p>This one&#8217;s simple.  AT&#038;T Research provides us with a <a href="http://r.research.att.com/">DMG</a>.</p>
<h3>On Ubuntu 8.0.4</h3>
<p>I first built this just fine on a Mac.  But, I decided that I wanted a dedicated VM where I could run some fairly intense benchmarks.  You&#8217;ll need to ensure you have the following apt packages installed:</p>
<p>* build-essential<br />
* g77 (fortran compiler)<br />
* x11-common</p>
<p>There may be a few others that are required, but I started on a pre-built box more or less ready to host rails apps, and so there may be a few other necessities I missed.  The following steps will install R from source on Ubuntu (I was unable to get the necessary R headers installed using apt-get or apititude), and prepare you for installing the rsruby gem.</p>
<pre class="wp-code-highlight prettyprint">
$&gt; sudo apt-get install build-essential g77 x11-common
$&gt; cd /opt
$&gt; wget http://lib.stat.cmu.edu/R/CRAN/src/base/R-2/R-2.7.2.tar.gz
$&gt; tar xzf R-2.7.2.tar.gz
$&gt; cd R-2.7.2
# --enable-R-shlib is important...it signals the installer to build and make available libR.so
$&gt; ./configure --enable-R-shlib
$&gt; make
$&gt; sudo make install
</pre>
<h2>Installing rsruby</h2>
<p>Assuming you installed R fine, rsruby should be easily installed using gem.  If you have trouble, see the <a href="http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/">installation instructions</a> on the project&#8217;s README.</p>
<p>Note that you&#8217;ll need to set the R_HOME environment variable prior to installing the gem.  On Mac, R_HOME=/Library/Frameworks/R.framework/Resources.  On Ubuntu (when installed from source), R_HOME=/usr/local/lib/R.  I find it helpful to just drop this into /etc/environment (on Ubuntu) so that this variable is set upon login.</p>
<pre class="wp-code-highlight prettyprint">
$&gt; export R_HOME=/path/to/R/for/your/OS
$&gt; sudo gem install rsruby -- --with-R-dir=$R_HOME
</pre>
<h2>Installing better-benchmark</h2>
<p>Currently, you can get this directly off of my fork on github.</p>
<pre class="wp-code-highlight prettyprint">
$&gt; gem sources -a http://gems.github.com/
$&gt; sudo gem install jtrupiano-better-benchmark
</pre>
<h2>Great, I have it, now what do I do with it??</h2>
<p>So now we&#8217;re ready to benchmark something.  The most important thing to understand when benchmarking is that you need to clearly identify what is part of the benchmark, and what is not.  Let&#8217;s take a look at a real-world example.  We&#8217;ll go through the following steps:</p>
<ol>
<li><strong>Hypothesize: </strong>define exactly what you&#8217;re looking to test, and take special care to describe what you are NOT testing.</li>
<li><strong>Plan: </strong>write out step by step how you will accomplish your benchmark</li>
<li><strong>Refine: </strong>identify which steps belong in the benchmark, and which are really setup/teardown aspects of the benchmark, and thus shouldn&#8217;t be included in the test.</li>
<li><strong>Test: </strong>run the benchmarks</li>
<li><strong>Rinse/Repeat: </strong>(as necessary) tweak your test parameters, tweak the tests, re-test </li>
</ol>
<h2>Real world example</h2>
<p>I was building a set of services that needed to download tens to hundreds of thousands of feeds regularly and perform some post-processing.  I pulled in the <a href="http://feed-normalizer.rubyforge.org/">feed-normalizer</a> gem.  My implementation plan called for me to write separate services, one for &#8220;pulling down&#8221; the feed, and one for &#8220;processing&#8221; the feed.  </p>
<p>My first approach entailed storing the feeds on the hard-drive as YAML (using the to_yaml function).  After running into <a href="http://blog.smartlogicsolutions.com/2008/09/04/ruby-patch-to-fix-broken-yamldump-for-multi-line-strings-stringto_yaml/">some obscure problems with YAML and multi-line strings</a>, I started to explore alternative persistence formats.  One that caught my attention was using the Marshall standard library to store the content as bytecode.  This brings me to my hypothesis:</p>
<p><strong>1) Hypothesis: </strong>Converting FeedNormalizer::Feed objects to bytecode using the Marshal library is faster than converting those same obejcts to YAML using the YAML library.</p>
<p>I also like to list out my goals at this stage:</p>
<ol>
<li>We only want to test the #dump conversion (object &#8211;> string) and the #read conversion (string &#8211;> object).  We do not want to test the write to disk and the read from disk portions.</li>
<li>We specifically want to test FeedNormalizer::Feed objects, since that&#8217;s what we&#8217;re using in our code.</li>
<li>Let&#8217;s benchmark YAML / Marshal #dump and #read methods specifically on FeedNormalizer::Feed objects</li>
</ol>
<p><strong>2) Plan: </strong> </p>
<ol>
<li>We have already grabbed roughly 100 feed downloads, and they are sitting as raw xml in test/raw_rss.</li>
<li>We&#8217;ll read them in, then benchmark YAML.dump vs. Marshal.dump</li>
<li>Then we&#8217;ll independently benchmark YAML.read vs. Marshal.read</li>
</ol>
<p><strong>3) Refine: </strong><br />
Here&#8217;s where we need to ensure that unnecessary processing doesn&#8217;t make its way into our benchmarks.  For instance, in order to benchmark Marshal#dump against YAML#dump, we&#8217;ll need to load up all of the FeedNormalizer::Feed objects (by reading them from disk and instantiating them) prior to starting the benchmark.</p>
<p><strong>4) Test: </strong><br />
It&#8217;s a ruby script, so go ahead and run it.  The set of options provided by better-benchmark are easily discernible from the <a href="http://github.com/jtrupiano/better-benchmark/tree/master/lib/better-benchmark/better-benchmark.rb">source file</a>.</p>
<p><strong>5) Rinse/Repeat: </strong><br />
Same story as always.</p>
<h2>Real Script Example</h2>
<pre class="wp-code-highlight prettyprint">
#!/usr/bin/env ruby
# Author: John Trupiano
# 2008-09-28
#
# In order to run this benchmark, you need to have the better-benchmark library installed (http://github.com/Pistos/better-benchmark/tree/master)
# better-benchmark depends on the rsruby gem (http://web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/)
# rsruby depends on an installation of the computing package R (http://mirrors.ibiblio.org/pub/mirrors/CRAN/)
#
# For details on setting up R, rsruby, and better-benchmark, see this blog post: http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark

# This is intended to be run from RAILS_ROOT, e.g.
# /path/to/rails/root $&gt; ruby test/benchmark/yaml_bytecode_test.rb

require &#039;openssl&#039;
require &#039;yaml&#039;
require &#039;rubygems&#039;
require &#039;feed-normalizer&#039;
require &#039;lib/rss_parser&#039;
require &#039;better-benchmark&#039;

# GOALS 
# 1) We only want to test the #dump conversion (object --&gt; string) and the #read conversion (string --&gt; object).  We do not want to test the write to disk and the read from disk portions.
# 2) We specifically want to test FeedNormalizer::Feed objects, since that&#039;s what we&#039;re using in our code.
# 3) Let&#039;s benchmark YAML / Marshal #dump and #read methods specifically on FeedNormalizer objects

# PLAN
# 1) We&#039;ve grabbed roughly 100 feed downloads sitting in test/raw_rss.
# 2) We&#039;ll read them in, then benchmark YAML.dump vs. Marshal.dump
# 3) Then we&#039;ll independently benchmark YAML.read vs. Marshal.read

fn_feeds = {}
root_dir = File.join(&quot;test&quot;, &quot;raw_rss&quot;)
feed_ids = (1..62).to_a + (64..108).to_a

# build a global hash fn_feeds that contains the FeedNormalizer::Feed entries
feed_ids.each do |feed_id|
  infile = File.join(root_dir, feed_id.to_s, feed_id.to_s + &#039;_dump.rss&#039;)
  fn_feeds[feed_id] = RssParser.parse(infile, :file)
end

#### BENCHMARK 1 ####
result = Benchmark.compare_realtime(
  :iterations =&gt; 25,
  :verbose =&gt; true
) { |iteration|
  fn_feeds.each_pair do |feed_id, feed|
    YAML.dump(feed)
  end
}.with { |iteration|
  fn_feeds.each_pair do |feed_id, feed|
    Marshal.dump(feed)
  end
}
Benchmark.report_on result


# now, let&#039;s create separate collections storing the dumps
yaml_dumps = {}
marshal_dumps = {}
fn_feeds.each_pair do |feed_id, feed|
  yaml_dumps[feed_id] = YAML.dump(feed)
  marshal_dumps[feed_id] = Marshal.dump(feed)
end

#### BENCHMARK 2 ####
result = Benchmark.compare_realtime(
  :iterations =&gt; 25,
  :verbose =&gt; true
) { |iteration|
  yaml_dumps.each_pair do |feed_id, yaml|
    YAML.dump(yaml)
  end
}.with { |iteration|
  marshal_dumps.each_pair do |feed_id, marshal|
    Marshal.dump(marshal)
  end
}
Benchmark.report_on result
</pre>
<p>And for good measure, let&#8217;s take a look at the results.</p>
<pre class="wp-code-highlight prettyprint">
john-trupianos-macbook-pro:trunk john$ ruby test/benchmark/yaml_bytecode_test.rb 
.........................
Set 1 mean: 2.095 s
Set 1 std dev: 0.071
Set 2 mean: 0.123 s
Set 2 std dev: 0.019
p.value: 1.58214572048972e-14
W: 625.0
The difference (-94.1%) IS statistically significant.
.........................
Set 1 mean: 0.191 s
Set 1 std dev: 0.015
Set 2 mean: 0.022 s
Set 2 std dev: 0.012
p.value: 1.58214572048972e-14
W: 625.0
</pre>
<p>As R plainly tells us, the difference is statistically significant (those who remember their p-values from stats class raise your hands) for both benchmarks (note that I did run two separate benchmarks in this example, one for dumping and one for reading).  That said, considering I don&#8217;t have a need for this data to be human readable on my filesystem, I can safely conclude that using the Marshal library in lieu of the YAML library will give me a performance boost on both the read/dump methods.  Now, whether or not this boost is negligible in the scope of the greater system, well that&#8217;s a question for a separate benchmark.</p>
<p>(What I mean by this last part is that this #dump/#read portion of my whole system may be tiny.  If it only represents 0.5% of the processing time, then the improvement my example shows may be more or less negligible in the context of the whole system.  These are the types of questions you need to ask yourself when benchmarking.)</p>
<p>Primary take-home point:  <strong>know what you&#8217;re benchmarking, and benchmark what you don&#8217;t know</strong>.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2010/10/08/testing-ajax-with-testunit/"     class="crp_title">Testing AJAX with Test::Unit</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/02/21/using-rspec-macros-and-metadata/"     class="crp_title">Using RSpec Macros and Metadata</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/">Benchmark Ruby Code with R, rsruby and better-benchmark</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2008/10/08/benchmark-ruby-code-with-r-rsruby-and-better-benchmark/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I can&#8217;t upgrade RubyGems from 1.1.1 to 1.2.0 on Ubuntu</title>
		<link>http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/</link>
		<comments>http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 16:38:04 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/</guid>
		<description><![CDATA[<p>Just a quick little snippet here. RubyGems 1.2.0 dropped roughly two weeks ago&#8230;.however, I&#8217;d been having trouble getting my 1.1.1 installs on Ubuntu to update properly. john@john-ubuntu:~/passenger-recipes$ gem -v 1.1.1 john@john-ubuntu:~/passenger-recipes$ sudo gem update --system Updating RubyGems Nothing to update john@john-ubuntu:~/passenger-recipes$ gem -v 1.1.1 john@john-ubuntu:~/passenger-recipes$ sudo gem update --system Updating RubyGems Nothing to update The [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/11/nicks-highlights-from-windy-city-rails/"     class="crp_title">Nick&#8217;s Highlights from Windy City Rails</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/">I can&#8217;t upgrade RubyGems from 1.1.1 to 1.2.0 on Ubuntu</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Just a quick little snippet here.  RubyGems 1.2.0 dropped roughly two weeks ago&#8230;.however, I&#8217;d been having trouble getting my 1.1.1 installs on Ubuntu to update properly.</p>
<pre class="wp-code-highlight prettyprint">
john@john-ubuntu:~/passenger-recipes$ gem -v
1.1.1
john@john-ubuntu:~/passenger-recipes$ sudo gem update --system
Updating RubyGems
Nothing to update
john@john-ubuntu:~/passenger-recipes$ gem -v
1.1.1
john@john-ubuntu:~/passenger-recipes$ sudo gem update --system
Updating RubyGems
Nothing to update
</pre>
<p>The first few times I ran into this, I was too busy to figure out what was wrong and ignored it.  However, there is one HUGE TIME SAVER in 1.2.0 that I just couldn&#8217;t wait for any longer.  Up through 1.1.1, gem update and gem install calls both updated all locally cached gemspec&#8217;s from your gem sources.  This not only led to large memory consumption (anyone on a VPS got a horror story?), but was also just a plain waste of time.  If I know which gem I want to update, it should just update that gem.  The onus should be on me specify that I want to fully update my cache.</p>
<p>That said, I finally came across <a href="http://www.ruby-forum.com/topic/157185#694165">Eric Hodel&#8217;s notice</a> addressing this very problem.  The solution:</p>
<pre class="wp-code-highlight prettyprint">
john@john-ubuntu:~/passenger-recipes$ &lt;strong&gt;sudo gem install rubygems-update -v 1.1.1&lt;/strong&gt;
Bulk updating Gem source index for: http://gems.rubyforge.org/
Successfully installed rubygems-update-1.1.1
1 gem installed
john@john-ubuntu:~/passenger-recipes$ &lt;strong&gt;sudo gem update --system&lt;/strong&gt;
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.2.0
Updating version of RubyGems to 1.2.0
Installing RubyGems 1.2.0
...
... (success)
...
john@john-ubuntu:~/passenger-recipes$ &lt;strong&gt;gem -v&lt;/strong&gt;
1.2.0

</pre>
<p>Happy upgrading.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/01/15/guide-to-application-development-infrastructure-pairing-and-ci-servers/"     class="crp_title">Guide to Application Development Infrastructure: Pairing and</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/07/nicks-highlights-from-ruby-hoedown/"     class="crp_title">Nick&#8217;s Highlights from Ruby Hoedown</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/10/26/testpilot-rails-integration-testing-pattern/"     class="crp_title">TestPilot &#8211; Rails Integration Testing Pattern</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/09/11/nicks-highlights-from-windy-city-rails/"     class="crp_title">Nick&#8217;s Highlights from Windy City Rails</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/">I can&#8217;t upgrade RubyGems from 1.1.1 to 1.2.0 on Ubuntu</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2008/07/07/i-cant-upgrade-rubygems-from-111-to-120-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
