<?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>Flavio Castelli &#187; Ruby</title>
	<atom:link href="http://flavio.castelli.name/category/programming/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://flavio.castelli.name</link>
	<description>debugging my life</description>
	<lastBuildDate>Fri, 20 Jan 2012 08:27:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Introducing dister, a Heroku like solution for SUSE Studio</title>
		<link>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio</link>
		<comments>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio#comments</comments>
		<pubDate>Tue, 29 Mar 2011 14:39:21 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[openSUSE]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[suse studio]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=353</guid>
		<description><![CDATA[SUSE Studio is  an awesome tool, with a couple of clicks you can create an openSUSE/SUSE based system and deploy to your hard drive, an usb flash,  a live dvd, a VMware/VirtualBox/Xen server and even Amazon EC2 cloud. Suppose you want to create a tailored SUSE Studio appliance to run a Ruby on Rails app, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://susestudio.com" target="_blank">SUSE Studio</a> is  an awesome tool, with a couple of clicks you can create an openSUSE/SUSE based system and deploy to your hard drive, an usb flash,  a live dvd, a VMware/VirtualBox/Xen server and even Amazon EC2 cloud.</p>
<p>Suppose you want to create a tailored SUSE Studio appliance to run a Ruby on Rails app, this is a list of things you have to take care of:</p>
<ul>
<li>install all the gems required by the app (this can be a long list).</li>
<li>install and configure the database used by the app.</li>
<li>install and configure a webserver.</li>
<li>ensure all the required services are started at boot time.</li>
</ul>
<p>You can save some time by cloning <a href="http://susegallery.com/a/CZ0T0D/rails-in-a-box" target="_blank">this</a> appliance shared on <a href="http://susegallery.com/" target="_blank">SUSE Gallery</a>, but this is still going to be boring.</p>
<h2>Dister to the rescue!</h2>
<p>Dister is a command line tool similar to the one used by <a href="http://heroku.com" target="_blank">Heroku</a> (one of the coolest ways to run your Rails app into the cloud). Within a few steps you will be able to create a SUSE Studio appliance running your rails application, download it and deploy wherever you want.</p>
<p>Dister is named after SUSE Studio robot. It has been created by  <a href="http://opensuse.blip.tv/file/4678185/" target="_blank">Dominik Mayer</a> and me during the latest <a href="http://en.opensuse.org/Portal:Hackweek" target="_blank">hackweek</a>.</p>
<h2>How it works</h2>
<p>We are going to create a SUSE Studio appliance running a rails application called <em>&#8220;SUSE history&#8221;</em>. The app uses <a href="http://gembundler.com/" target="_blank">bundler</a> to handle its dependencies.<br />
This is its Gemfile file:</p>
<pre name="code" class="ruby:nocontrols">
﻿﻿source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'pg'
gem "flutie", "~&gt; 1.1"
</pre>
<p>As you can see the app uses rails3, the <a href="https://github.com/thoughtbot/flutie" target="_blank">flutie</a> gem and PostgreSQL as database.</p>
<h3>Appliance creation</h3>
<p>Move into the suse_history directory and execute the following command:</p>
<pre name="code" class="bash:nocontrols">
dister create suse_history
</pre>
<p><div id="attachment_361" class="wp-caption aligncenter" style="width: 635px"><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/create.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/create.png" alt="dister create" title="dister create" width="625" height="213" class="size-full wp-image-361" /></a><p class="wp-caption-text">Creating a SUSE Studio appliance with dister</p></div><br />
As you can see dister has already done a couple of things for you:</p>
<ul>
<li>created an appliance using latest version of openSUSE supported by SUSE Studio (you can use a different base system of course)</li>
<li>added the <em>devel:language:ruby:extensions</em> repository to the appliance:  this repo contains tons of ruby packages (like <em>mod_passenger</em>)</li>
<li>installed a couple of things:
<ul>
<li><em>devel_C_C++</em> pattern: this will allow you to build native gems.
<li><em>devel_ruby</em> pattern: provides ruby, rubygems and a couple of development packages needed to build native gems.</li>
<li><em>rubygem-bundler</em>: bundler is required by dister in order to handle the dependencies of your rails application.</li>
<li><em>rubygem-passenger-apache2</em>: dister uses <a href="http://www.modrails.com/" target="_blank">passenger</a> and apache2 to deploy your rails application.</li>
<li><em>postgresql-server</em>: dister noticed suse_history uses PostgreSQL as database, hence it automatically installs it.</li>
<li><em>rubygem-pg</em>: dister noticed suse_history uses PostgreSQL as database, hence it automatically installs the ruby&#8217;s library forPostgreSQL.</li>
</ul>
</li>
<li>uploaded a custom build script which ensures:
<ul>
<li>mod_passenger module is loaded by Apache</li>
<li>both Apache and PostgreSQL are always started at boot time.</li>
<li>all dependencies are installed: this is done only during the first boot using bundler.</li>
<li>the database user required by your rails app is created. This is done only during the first boot using some SQL code.</li>
<li>the database used by the appliance is properly initialized (aka <em>rails db:create db:migrate</em>). This is done only during the first boot.</li>
</ul>
</li>
</ul>
<h3>Upload your code</h3>
<p>It&#8217;s time to upload suse_history code. This is done using the following command:</p>
<pre name="code" class="bash:nocontrols">
dister push
</pre>
<p><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/push.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/push.png" alt="dister push output" title="dister push" width="770" height="1016" class="aligncenter size-full wp-image-366" /></a><br />
As you can see dister packaged the application source code and all its dependencies into a single archive. Then uploaded the archive to SUSE Studio as an overlay file. Dister uploaded also the configuration files required by Apache and by PostgreSQL setup.</p>
<h3>Build your appliance</h3>
<p>It&#8217;s build time!</p>
<pre name="code" class="bash:nocontrols">
dister build
</pre>
<p><a href="http://flavio.castelli.name/wp-content/uploads/2011/03/build.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/build.png" alt="dister build" title="dister build" width="1275" height="84" class="aligncenter size-full wp-image-370" /></a><br />
The appliance has automatically being built using the <em>raw disk</em>. You can use different formats of course.</p>
<h3>Testdrive</h3>
<p>Testdrive is one of the coolest features of SUSE Studio. Unfortunately dister doesn&#8217;t support it yet. Just visit your appliance page and start testdrive from your browser.<br />
Just enable testdrive networking and connect to your appliance:<br />
<a href="http://flavio.castelli.name/wp-content/uploads/2011/03/testdrive.png" rel="lightbox[353]"><img src="http://flavio.castelli.name/wp-content/uploads/2011/03/testdrive.png" alt="suse history running inside of testdrive" title="suse history running inside of testdrive" width="720" height="865" class="aligncenter size-full wp-image-374" /></a></p>
<h3>Download</h3>
<p>Your appliance is working flawlessly. Download it and deploy it wherever you want.</p>
<pre name="code" class="bash:nocontrols">
dister download
</pre>
<h2>Current status</h2>
<p>As you can see dister handles pretty fine a simple Rails application, but there&#8217;s still room for improvements.</p>
<p>Here&#8217;s a small list of the things on my TODO list:</p>
<ul>
<li>The dependency management should install gems using rpm packages. This would make the installation of native gems easier, right now the user has to manually add all the development libraries required by the gem. Moreover it would reduce the size of the overlay files uploaded to SUSE Studio.</li>
<li>SUSE Studio Testdrive should be supported.</li>
<li>It should be possible to deploy the SUSE Studio directly to EC2.</li>
<li>Fix bugs!</li>
</ul>
<p>Bugs and enhancements are going to be tracked <a target="_blank" href="https://github.com/flavio/dister/issues">here</a>. </p>
<h2>Contribute</h2>
<p>Dister code can be found here on <a target="_blank" href="https://github.com/flavio/dister">github</a>, fork it and start contributing.</p>
<p>If you are a student you can work on dister during the next <a target="_blank" href="http://en.opensuse.org/openSUSE:GSOC_2011_Ideas#Heroku_like_solution_for_SUSE_Studio">Google Summer of code</a>, apply now!</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/introducing-dister-a-heroku-like-solution-for-suse-studio/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jump: a bookmarking system for the bash shell</title>
		<link>http://flavio.castelli.name/jump</link>
		<comments>http://flavio.castelli.name/jump#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:29:29 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[bash]]></category>

		<guid isPermaLink="false">http://flavio.castelli.name/?p=335</guid>
		<description><![CDATA[Let me introduce a small project I&#8217;ve been working on with a friend of mine, Giuseppe Capizzi. The project is called jump and ﻿allows you to quickly change directories in the bash shell using bookmarks. Thanks to Jump, you won&#8217;t have to type those long paths anymore. You can find jump&#8217;s source code, detailed documentation and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump.jpeg" rel="lightbox[335]"></a>Let me introduce a small project I&#8217;ve been working on with a friend of mine, <a href="http://twitter.com/gcapizzi" target="_blank">Giuseppe Capizzi</a>. The project is called <strong>jump</strong> and ﻿allows you to quickly change directories in the bash shell using bookmarks.</p>
<p>Thanks to Jump, you won&#8217;t have to type those long paths anymore.</p>
<p style="text-align: center;"><a href="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump.jpeg" rel="lightbox[335]"><img class="aligncenter" title="van-halen-jump" src="http://flavio.castelli.name/wp-content/uploads/2010/08/van-halen-jump-300x222.jpg" alt="" width="300" height="222" /></a></p>
<p>You can find jump&#8217;s source code, detailed documentation and installation instructions <a href="http://github.com/flavio/jump" target="_blank">here</a>.</p>
<p>SUSE packages can be found <a href="http://software.opensuse.org/search?baseproject=ALL&amp;p=1&amp;q=rubygem-jump" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/jump/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ruby downloader for Jamendo</title>
		<link>http://flavio.castelli.name/ruby-downloader-for-jamendo</link>
		<comments>http://flavio.castelli.name/ruby-downloader-for-jamendo#comments</comments>
		<pubDate>Fri, 03 Oct 2008 10:28:28 +0000</pubDate>
		<dc:creator>Flavio</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[jamendo]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.flavio.castelli.name/?p=90</guid>
		<description><![CDATA[Also this year I&#8217;ll attend the Linux day (a day dedicated to Gnu/Linux  and FLOSS that occurs every year in Italy) organized by my LUG. Guess what I&#8217;ll be talking about&#8230; While organizing the event somebody proposed to setup a local server with some music released under CC license. He suggested to download some albums [...]]]></description>
			<content:encoded><![CDATA[<p>Also this year I&#8217;ll attend the Linux day (a day dedicated to Gnu/Linux  and FLOSS that occurs every year in Italy) organized by my <a href="http://bglug.it">LUG</a>. Guess what I&#8217;ll be talking about&#8230; <img src='http://flavio.castelli.name/wp-content/plugins/smilies-themer/tango/face-wink.png' alt=';)' class='wp-smiley' /> </p>
<p>While organizing the event somebody proposed to setup a local server with some music released under CC license. He suggested to download some albums from <a href="http://www.jamendo.com" target="_blank">Jamendo</a> (due to network issues we won&#8217;t be able to provide direct access to the website).</p>
<p>Since nobody wanted to download the albums by hand, last night I wrote a small ruby program that does the dirty job.</p>
<h3>Requirements:</h3>
<p>Ruby and json gem have to be installed on you machine.</p>
<h3>Usage:</h3>
<p>Help:<a href="http://www.flavio.castelli.name/wp-content/uploads/2008/10/jamendo_downloader.rb"></a></p>
<blockquote><p>./jamendo_downloader.rb &#8211;help</p></blockquote>
<p>Download the top 10 rock albums:</p>
<blockquote><p>./jamendo_downloader.rb -g rock -t 10</p></blockquote>
<h3>Have fun</h3>
<p>I think there&#8217;s nothing more to say&#8230; enjoy my <a href="http://www.flavio.castelli.name/wp-content/uploads/2008/10/jamendo_downloaderrb.zip">jamendo_downloader</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flavio.castelli.name/ruby-downloader-for-jamendo/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

