<?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>A Tempest of Thoughts &#187; Programming</title>
	<atom:link href="http://tempe.st/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 07 Apr 2011 08:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Change your terminal theme when you ssh into a server</title>
		<link>http://tempe.st/2011/04/change-your-terminal-theme-when-you-ssh-into-a-server/</link>
		<comments>http://tempe.st/2011/04/change-your-terminal-theme-when-you-ssh-into-a-server/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 08:24:09 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random Stuff]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=343</guid>
		<description><![CDATA[I am in a tough spot. I am a technician, but I also am a design whore, so when I had to find a solution to one common problem (forgetting that your terminal tab is not on localhost), I couldn&#8217;t just solve the problem, but I had to find a good looking solution to that. [...]]]></description>
			<content:encoded><![CDATA[	<p>I am in a tough spot. I am a technician, but I also am a design whore, so when I had to find a solution to one common problem (forgetting that your terminal tab is not on localhost), I couldn&#8217;t just solve the problem, but I had to find a good looking solution to that.</p>
	<p>A #lazytweet only partially helped me, directing me to <a href="http://www.rngtng.com/2011/01/14/mac-os-x-terminal-visual-indication-for-your-ssh-connection/">this useful post</a>. I liked the approach, it was close, but not there.</p>
	<p>I played with shell functions for a bit and came up with this:<br />
<script src="https://gist.github.com/905583.js?file=.profile"></script></p>
	<p>The way it works is simple, it tells terminal to change it&#8217;s theme before ssh-ing and changes it back when ssh quits.</p>
	<p>You might be wondering what Solarized Dark and Light are. It&#8217;s quite simple, they are two flavors of <a href="https://github.com/altercation/solarized">the best theme ever made</a>.</p>
	<p>If you&#8217;re still reading, a shameless plug: use my version of <a href="https://github.com/intinig/git-prompt">git-prompt</a> for the best command prompt ever made <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2011/04/change-your-terminal-theme-when-you-ssh-into-a-server/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>BetterSoftware 2010: Agile Tricks</title>
		<link>http://tempe.st/2010/05/bettersoftware-2010-agile-tricks/</link>
		<comments>http://tempe.st/2010/05/bettersoftware-2010-agile-tricks/#comments</comments>
		<pubDate>Fri, 07 May 2010 19:52:05 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bsw2010]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[doomboard]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[presentation]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=324</guid>
		<description><![CDATA[This week I attended Better Software 2010, where I gave a presentation about the making of the DoomBoard . I had a lot of fun and attended a lot of interesting presentations from great professionals. Here&#8217;s my slides. Agile tricksView more presentations from intinig.]]></description>
			<content:encoded><![CDATA[	<p>This week I attended <a href="http://bettersoftware.it">Better Software 2010</a>, where I gave a presentation about the making of the <a href="https://github.com/mikamai/doomboardhd">DoomBoard</a> . I had a lot of fun and attended a lot of interesting presentations from great professionals.</p>
	<p>Here&#8217;s my slides.</p>
<div style="width:425px" id="__ss_4009306"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/intinig/agile-tricks" title="Agile tricks">Agile tricks</a></strong><object id="__sse4009306" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=agiletricks-100507140716-phpapp02&#38;rel=0&#38;stripped_title=agile-tricks" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse4009306" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=agiletricks-100507140716-phpapp02&#38;rel=0&#38;stripped_title=agile-tricks" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/intinig">intinig</a>.</div></div>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2010/05/bettersoftware-2010-agile-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The unrestful programmer</title>
		<link>http://tempe.st/2009/04/the-unrestful-programmer/</link>
		<comments>http://tempe.st/2009/04/the-unrestful-programmer/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 14:21:08 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=285</guid>
		<description><![CDATA[Yesterday in Mikamai we had a Ruby Social Club meeting. I did a small presentation about the need to never stop learning. Here&#8217;s the slides: New TechsView more presentations from intinig.]]></description>
			<content:encoded><![CDATA[	<p>Yesterday in <a href="http://mikamai.com">Mikamai</a> we had a Ruby Social Club meeting. I did a small presentation about the need to never stop learning. Here&#8217;s the slides:</p>
<div style="width:425px;text-align:left" id="__ss_1301945"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/intinig/new-techs?type=powerpoint" title="New Techs">New Techs</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=newtechs-090416162943-phpapp02&#38;stripped_title=new-techs" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=newtechs-090416162943-phpapp02&#38;stripped_title=new-techs" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/intinig">intinig</a>.</div></div>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2009/04/the-unrestful-programmer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The thrill of a new technology: CouchDB</title>
		<link>http://tempe.st/2009/03/the-thrill-of-a-new-technology-couchdb/</link>
		<comments>http://tempe.st/2009/03/the-thrill-of-a-new-technology-couchdb/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 13:05:14 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=270</guid>
		<description><![CDATA[It has been a long time since I fell in love with a new technology (maybe Ruby on Rails when it first came out?), and the time I am spending with CouchDB lately has been a nice return to the pleasure of programming. I&#8217;ll probably write some in-depth articles on Document based DBs later, but [...]]]></description>
			<content:encoded><![CDATA[	<p>It has been a long time since I fell in love with a new technology (maybe Ruby on Rails when it first came out?), and the time I am spending with CouchDB lately has been a nice return to the pleasure of programming.</p>
	<p>I&#8217;ll probably write some in-depth articles on Document based DBs later, but let me show you how complex operations on relational DBs can become really simple with a document based approach.</p>
	<p>Let&#8217;s say you have a db of tagged objects, and you want to get a report with a &#8220;per tag&#8221; distribution of your objects. In a relational environment you would need at least three tables, objects, tags and a join table and a select operation involving two joins to get the results you needed:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> tags<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">,</span> group_concat<span style="color: #66cc66;">&#40;</span>people<span style="color: #66cc66;">.</span>name<span style="color: #66cc66;">&#41;</span> 
<span style="color: #993333; font-weight: bold;">FROM</span> tags 
<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> tags_people <span style="color: #993333; font-weight: bold;">ON</span> tags<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> tags_people<span style="color: #66cc66;">.</span>tag_id
<span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> people <span style="color: #993333; font-weight: bold;">ON</span> people<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;">=</span> tags_person<span style="color: #66cc66;">.</span>id 
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> tags<span style="color: #66cc66;">.</span>name</pre></div></div>

	<p>This isn&#8217;t rocket science but I guess not everyone knows about group_concat <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>In a document based environment I would just have a document for each person, with a tags property that holds an array of tags. The map and reduce functions would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// map</span>
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>doc<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>doc<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'couchrest-type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Person'</span> <span style="color: #339933;">&amp;&amp;</span> doc.<span style="color: #660066;">tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doc.<span style="color: #660066;">tags</span>.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>tag<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      emit<span style="color: #009900;">&#40;</span>tag<span style="color: #339933;">,</span> doc.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// reduce</span>
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>keys<span style="color: #339933;">,</span> values<span style="color: #339933;">,</span> rereduce<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> values<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

	<p>Using Javascript to manipulate data may seem counter intuitive, but as you can see we have a much simpler datastore (just people documents thrown in the db) and an easy way of manipulating them to extract the info we need.</p>
	<p>I love CouchDB.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2009/03/the-thrill-of-a-new-technology-couchdb/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>How I made Autotest RedGreen and Growl party together</title>
		<link>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/</link>
		<comments>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/#comments</comments>
		<pubDate>Sat, 31 May 2008 11:22:19 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[redgreen]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=217</guid>
		<description><![CDATA[If you&#8217;re like me and like autotest as a sort of private continous integration system, and if you like pretty output, you will probably have used some kind of autotest + redgreen and/or growl. Unfortunately I had strange quirks in my growl notifications. Sometimes they worked, sometimes they didn&#8217;t (I was using the standard :ran_command [...]]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re like me and like autotest as a sort of private continous integration system, and if you like pretty output, you will probably have used some kind of autotest + redgreen and/or growl.</p>
	<p>Unfortunately I had strange quirks in my growl notifications. Sometimes they worked, sometimes they didn&#8217;t (I was using the standard :ran_command autotest hook at the time), so I switched to the newer :red and :green hooks, and only worsened the problem. No matter what the test output was, I always got a green notification.</p>
	<p>I was able to trace the problem to the redgreen gem. Its colorized output wasn&#8217;t being recognized correctly by autotest and it kept thinking everything was ok.</p>
	<p>A little ruby fiddling and this is my new improved (and working!) .autotest file:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># -*- ruby -*-</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::RedGreen</span>
  Autotest.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:alias_method</span>, <span style="color:#ff3333; font-weight:bold;">:real_ruby</span>, <span style="color:#ff3333; font-weight:bold;">:ruby</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  Autotest.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:define_method</span>, <span style="color:#ff3333; font-weight:bold;">:ruby</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|*</span>args<span style="color:#006600; font-weight:bold;">|</span>
      real_ruby <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#006600; font-weight:bold;">-</span>rrubygems <span style="color:#006600; font-weight:bold;">-</span>e <span style="color:#996600;">&quot;require 'redgreen'&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span> 
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Clean the output so other modules can work correctly</span>
  Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:ran_command</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
    at.<span style="color:#9900CC;">results</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>r<span style="color:#006600; font-weight:bold;">|</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[31m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[32m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[33m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[0m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::Growl</span>
  AUTOTEST_IMAGE_ROOT = <span style="color:#996600;">&quot;~/.autotest_images&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">growl</span><span style="color:#006600; font-weight:bold;">&#40;</span>title, msg, img, pri=<span style="color:#006666;">0</span>, sticky=<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg.inspect} #{title}' #{sticky}&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:red</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
    growl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;FAIL&quot;</span>, <span style="color:#996600;">&quot;#{get_results(at)}&quot;</span>, <span style="color:#996600;">&quot;#{AUTOTEST_IMAGE_ROOT}/fail.png&quot;</span>, <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:green</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
    growl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Pass&quot;</span>, <span style="color:#996600;">&quot;#{get_results(at)}&quot;</span>, <span style="color:#996600;">&quot;#{AUTOTEST_IMAGE_ROOT}/pass.png&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">get_results</span><span style="color:#006600; font-weight:bold;">&#40;</span>at<span style="color:#006600; font-weight:bold;">&#41;</span>
    results = <span style="color:#006600; font-weight:bold;">&#91;</span>at.<span style="color:#9900CC;">results</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">flatten</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> results.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">'tests'</span>
      output = results.<span style="color:#9900CC;">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>tests?,\s<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>assertions?,\s<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>failures?<span style="color:#006600; font-weight:bold;">&#40;</span>,\s<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>errors<span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      output = results.<span style="color:#9900CC;">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>examples?,\s<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span>failures?<span style="color:#006600; font-weight:bold;">&#40;</span>,\s<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\s<span style="color:#006600; font-weight:bold;">+</span><span style="color:#9966CC; font-weight:bold;">not</span> implemented<span style="color:#006600; font-weight:bold;">&#41;</span>?<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    output
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Esclusioni</span>
Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:initialize</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#123;</span>.<span style="color:#9900CC;">hg</span> .<span style="color:#9900CC;">git</span> .<span style="color:#9900CC;">svn</span> stories tmtags Rakefile Capfile README spec<span style="color:#006600; font-weight:bold;">/</span>spec.<span style="color:#9900CC;">opts</span> spec<span style="color:#006600; font-weight:bold;">/</span>rcov.<span style="color:#9900CC;">opts</span> vendor<span style="color:#006600; font-weight:bold;">/</span>gems autotest svn<span style="color:#006600; font-weight:bold;">-</span>commit .<span style="color:#9900CC;">DS_Store</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>exception<span style="color:#006600; font-weight:bold;">|</span>
    at.<span style="color:#9900CC;">add_exception</span><span style="color:#006600; font-weight:bold;">&#40;</span>exception<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  at.<span style="color:#9900CC;">add_mapping</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>spec\<span style="color:#006600; font-weight:bold;">/</span>defaults.<span style="color:#9900CC;">rb</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f, _<span style="color:#006600; font-weight:bold;">|</span>
    at.<span style="color:#9900CC;">files_matching</span> <span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">%</span>^spec<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>controllers<span style="color:#006600; font-weight:bold;">|</span>helpers<span style="color:#006600; font-weight:bold;">|</span>lib<span style="color:#006600; font-weight:bold;">|</span>models<span style="color:#006600; font-weight:bold;">|</span>views<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>\.<span style="color:#9900CC;">rb</span>$<span style="color:#006600; font-weight:bold;">%</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

 
	<p>Our setup had apache as webserver so I don&#8217;t need any special code to restart the application. In addition to this recipe, made to deploy to production I also wrote a couple of tasks that shine during development. </p>
	<p>Drupal has the problem of storing most of the important stuff in the database, and if you do local development, showing the status of the work to your clients can be a chore. The following tasks allow you to easily dump the development db and import the dump to the staging server to show your progresses to your customers and allow testing the site:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Callbacks</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'drupal:db:import:production'</span>
&nbsp;
before <span style="color:#996600;">'deploy:restart'</span>, <span style="color:#996600;">'mikamai:permissions:fix'</span>, <span style="color:#996600;">'mikamai:production:symlink'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'mikamai:permissions:fix'</span>, <span style="color:#996600;">'mikamai:production:symlink'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:cold'</span>, <span style="color:#996600;">'drupal:db:dump:development'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># DB Stuff</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:mysqldump</span>, <span style="color:#996600;">&quot;/opt/local/bin/mysqldump5&quot;</span> <span style="color:#008000; font-style:italic;"># your path to mysqldump</span>
<span style="color:#008000; font-style:italic;"># local db credentials</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_user</span>, <span style="color:#996600;">&quot;root&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_password</span>, <span style="color:#996600;">&quot;&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_name</span>, <span style="color:#996600;">&quot;database&quot;</span>
<span style="color:#008000; font-style:italic;"># remote db credentials</span>
set <span style="color:#ff3333; font-weight:bold;">:db_user</span>, <span style="color:#996600;">&quot;user&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_password</span>, <span style="color:#996600;">&quot;secret&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_name</span>, <span style="color:#996600;">&quot;database&quot;</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:drupal</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
  namespace <span style="color:#ff3333; font-weight:bold;">:configure</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.production.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.development.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  namespace <span style="color:#ff3333; font-weight:bold;">:db</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    namespace <span style="color:#ff3333; font-weight:bold;">:dump</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">RuntimeError</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;failed dump&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;#{mysqldump} -u #{local_db_user} --password=#{local_db_password} #{local_db_name} &gt; dump.sql&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    namespace <span style="color:#ff3333; font-weight:bold;">:import</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;FILES&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;dump.sql&quot;</span>
        deploy::upload
        run <span style="color:#996600;">&quot;mysql -u #{db_user} --password=#{db_password} #{db_name} &lt; #{latest_release}/dump.sql&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>



 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How I worked with thirty amazing people and lived to tell: Stacktrace</title>
		<link>http://tempe.st/2007/12/how-i-worked-with-thirty-amazing-people-and-lived-to-tell-stacktrace/</link>
		<comments>http://tempe.st/2007/12/how-i-worked-with-thirty-amazing-people-and-lived-to-tell-stacktrace/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 23:41:10 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Italy]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Random Stuff]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Stacktrace]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/12/how-i-worked-with-thirty-amazing-people-and-lived-to-tell-stacktrace/</guid>
		<description><![CDATA[I&#8217;ve had the pleasure of working with thirty brilliant techies for the launch of Stacktrace, an Italian website about technology in its various forms. Stacktrace was and idea of Antonio Cangiano. He felt that Italy missed an authoritative and original technology reference, and contacted about thirty of the best Italy has to offer, people I [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve had the pleasure of working with thirty brilliant techies for the launch of <a href="http://stacktrace.it">Stacktrace</a>, an Italian website about technology in its various forms.</p>
	<p>Stacktrace was and idea of <a href="http://antoniocangiano.com">Antonio Cangiano</a>. He felt that Italy missed an authoritative and original technology reference, and contacted about thirty of the best Italy has to offer, people I am very proud I could work with, to prepare the lightning quick launch of a wonderful site, full of original, well written and interesting content.</p>
	<p>If you can understand Italian, even a bit of it, I strongly suggest you check <a href="http://stacktrace.it">Stacktrace</a>. You&#8217;ll be glad you did.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/12/how-i-worked-with-thirty-amazing-people-and-lived-to-tell-stacktrace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A couple of capistrano 2 recipes libraries</title>
		<link>http://tempe.st/2007/09/a-couple-of-capistrano-2-recipes-libraries/</link>
		<comments>http://tempe.st/2007/09/a-couple-of-capistrano-2-recipes-libraries/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 15:26:58 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Nimboo]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/09/a-couple-of-capistrano-2-recipes-libraries/</guid>
		<description><![CDATA[I kept playing with Capistrano 2 after my last article, and I&#8217;ve refactored quite a bit my recipes, finally moving them in their own subversion repository. This allows much quicker deployment with my new rails applications. Here&#8217;s how I do it: $ rails my_new_application $ cd my_new_application $ capify . Then I edit Capfile: load [...]]]></description>
			<content:encoded><![CDATA[	<p>I kept playing with Capistrano 2 after my last article, and I&#8217;ve refactored quite a bit my recipes, finally moving them in their own subversion repository. This allows much quicker deployment with my new rails applications. Here&#8217;s how I do it:</p>
<pre>
$ rails my_new_application
$ cd my_new_application
$ capify .
</pre>
	<p>Then I edit <em>Capfile</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'deploy'</span> <span style="color:#9966CC; font-weight:bold;">if</span> respond_to?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:namespace</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># cap2 differentiator</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'lib/recipes/site5'</span> <span style="color:#008000; font-style:italic;"># This is my site5 recipe</span>
<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'lib/recipes/medlar'</span> <span style="color:#008000; font-style:italic;"># The general use recipes</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#996600;">'config/deploy'</span></pre></div></div>

	<p>The <em>site5</em> and <em>medlar</em> namespaces hold default configuration values, define some callbacks and the following tasks:</p>
<pre>
cap deploy:medlar:rails:freezer:edge   # Fetch Rails edge and puts it into sh...
cap deploy:medlar:rails:freezer:stable # Fetch Rails stable and puts it into ...
cap deploy:medlar:rails:link           # Links Rails to application/vendor
cap deploy:medlar:rails:update         # Updates the fetched version of rails.
	<p>cap deploy:site5:kill_dispatch_fcgi    # Kills Ruby instances on Site5<br />
cap deploy:site5:link_public_html      # Links public_html to current_path/pu...<br />
</pre></p>
	<p>Last but not least, here&#8217;s the simple, clean and elegant <em>deploy.rb</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;my_new_application&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;the_username&quot;</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:repository</span>,  <span style="color:#996600;">&quot;repo_address&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/home/#{user}/apps/#{application}&quot;</span>
&nbsp;
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;server.com&quot;</span>
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;server.com&quot;</span>
role <span style="color:#ff3333; font-weight:bold;">:db</span>,  <span style="color:#996600;">&quot;server.com&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span></pre></div></div>

	<p>Quite readable, isn&#8217;t it? <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>The recipes are available via anonymous subversion: <a href="https://svn1.hosted-projects.com/medlar/recipes/">https://svn1.hosted-projects.com/medlar/recipes/</a></p>
	<p>Enjoy and let me know if you found them useful.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/09/a-couple-of-capistrano-2-recipes-libraries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails and JavaScript: page.call gotchas</title>
		<link>http://tempe.st/2007/08/rails-and-javascript-pagecall-gotchas/</link>
		<comments>http://tempe.st/2007/08/rails-and-javascript-pagecall-gotchas/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 13:38:17 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Prototype.js]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/08/rails-and-javascript-pagecall-gotchas/</guid>
		<description><![CDATA[Ruby on Rails has wonderful out of the box javascript support, but sometimes implementing dynamic user interfaces is not so easy as it seems. In an application I&#8217;m working on I have a list of people with a checkbox each. In the load event of the page I add a click handler to every checkbox [...]]]></description>
			<content:encoded><![CDATA[	<p>Ruby on Rails has wonderful out of the box javascript support, but sometimes implementing dynamic user interfaces is not so easy as it seems.</p>
	<p>In an application I&#8217;m working on I have a list of people with a checkbox each. In the load event of the page I add a click handler to every checkbox using this javascript code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.ConfermaInvitati'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> clickHandler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// ... </span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> clickHandler<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> Event.<span style="color: #660066;">element</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Updater</span><span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'my/invited/toggle'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    parameters<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> id<span style="color: #339933;">:</span> e.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">up</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">id</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    onLoading<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> e.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;/images/admin/spinner.gif&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    onSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #660066;">Request</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'my/refresh'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span></pre></div></div>

	<p>This works fine until I add a new person via an Ajax call. That person won&#8217;t have a <em>clickHandler</em> because the element wasn&#8217;t on the page when I called the click handler. So I thought it was time to test <em>page.call</em> in the  <em>render :update</em> block I had in the rails application.</p>
	<p>I tried this code:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">render <span style="color:#ff3333; font-weight:bold;">:update</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>page<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#008000; font-style:italic;"># Do stuff that creates the new objects and adds it to the page</span>
  <span style="color:#008000; font-style:italic;"># The data I need is in @invited</span>
  page.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Event.observe($$('##{@invited.permalink} .ConfermaInvitati').first()), 'click', clickHandler)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

	<p>Obviously that didn&#8217;t work, and it turned out I have to read documentation before doing fancy things <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>The rails docs told me that I had to use <em>call</em> passing the function name as the first argument and an array of parameters as the second argument, the problem is that <em>call</em> turns all the parameters into strings&#8212;this means I could not pass the <em>clickHandler</em> function to <em>Event.observe</em>. </p>
	<p>I found the solution in <em><<</em>. If you do <em>page << "foo"</em>, foo will be evaluated as raw javascripts. This meant I was able to do</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">page <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;Event.observe($$('##{@invited.permalink} .ConfermaInvitati').first()), 'click', clickHandler)</span></pre></div></div>

	<p>and finally have the functionality I was looking for. So remember, don&#8217;t <em>page.call</em> if you need to pass javascript variables to your functions.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/08/rails-and-javascript-pagecall-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoless Rails Stack on OSX</title>
		<link>http://tempe.st/2007/08/sudoless-rails-stack-on-osx/</link>
		<comments>http://tempe.st/2007/08/sudoless-rails-stack-on-osx/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 08:38:02 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/08/sudoless-rails-stack-on-osx/</guid>
		<description><![CDATA[More and more of my developer friends are switching to OSX as time goes by, and they keep asking me for directions on the best setup for rails development: how to install ruby, how to install the missing libraries, and so on. My professional development life started on a PB Titanium running OSX 10.2, and [...]]]></description>
			<content:encoded><![CDATA[	<p>More and more of my developer friends are switching to OSX as time goes by, and they keep asking me for directions on the best setup for rails development: how to install ruby, how to install the missing libraries, and so on.</p>
	<p>My professional development life started on a PB Titanium running OSX 10.2, and continued through a PB Aluminium and a Macbook Pro. Each time I changed laptop I also reinstalled everything again, and each time I tried to come up with a better setup. </p>
	<p>Now I&#8217;ve finally found a setup I&#8217;m comfortable with, and it has the following advantages:</p>
	<ul>
		<li>Sudoless: everything runs from my user directory</li>
		<li>Non-system-tampering: doesn&#8217;t touch files in the original osx installation</li>
		<li>Crash-proof-easy-reinstall: you can just delete everything and reinstall without fear of rendering your system unstable</li>
		<li>Fink based: uses everything it can use from the fink repositories</li>
	</ul>
	<p>Now that I&#8217;ve sold you on my setup <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  it&#8217;s time to explain how to implement it. </p>
	<h3>Step one: XCode and Developer Tools</h3>
	<p>If you don&#8217;t have XCode already installed you can install it from the disks you got with your Mac or, better, download the newest version from <a href="http://connect.apple.com">Apple Developer Connection</a>. Once you got it installed you can proceed to the next step.</p>
	<h3>Step two: Fink</h3>
	<p>Go to the <a href="http://www.finkproject.org/download/index.php?phpLang=en">Fink Download Page</a>, and get the package that works best on your Mac (intel or powerpc). Follow the installation instructions and install the base fink system. After you&#8217;ve done that add these lines to your <em><sub>/.profile</em></p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;"># Dev Enviroment
&nbsp;
LDFLAGS=-L/sw/lib
export LDFLAGS
&nbsp;
CPPFLAGS='-I/Users/your_username/unix/include -I/sw/include'
export CPPFLAGS</pre></div></div>

	<p>_/Users/your_username/unix/include_ doesn&#8217;t exist yet, but we&#8217;ll create it when installing ruby.</p>
	<h3>Step three: Ruby from Sources</h3>
	<p>This is the first tricky part. Before OSX 10.4.6 the Ruby version shipped by Apple didn&#8217;t work with rails, so you were on your own. Now it works, but I prefer to have ruby in my home directory so I can mess with the sources and with the gem files and upgrade painlessly. So <a href="http://www.ruby-lang.org/en/downloads">download the latest ruby</a> sources and unpack them wherever you wish (I like <em></sub>/src</em>).</p>
	<p>Now you&#8217;re ready to go. First make sure you have readline and readline5-shlibs installed via fink so you can have a comfortable irb environment:</p>
<pre>
user$ fink install readline readline5-shlibs
</pre> 
	<p>After that it&#8217;s time for ruby:</p>
<pre>
user$ cd &lt;sub&gt;/src/ruby-1.8.6
user$ ./configure &lt;del&gt;-prefix=/Users/your_username/unix
user$ make &#38;&#38; make install
</pre>
	<p>The whole magic (and it&#8217;s not a big magic btw) is in <em></del>-prefix</em>. Installing ruby will create the /Users/your_username/unix path. Now it&#8217; time to add the <em>unix</em> dir to $PATH. Edit <em></sub>/profile</em> once again and add these lines:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">PATH=/Users/your_username/unix/bin:/usr/local/mysql/bin:/usr/local/sbin:$PATH
export PATH</pre></div></div>

	<h3>Step four: MySQL</h3>
	<p>Quite simple with the packages from <a href="http://mysql.com">mysql.com</a>.</p>
	<h3>Step five: Last but not least, rubygems</h3>
	<p>Fetch the gem package from <a href="http://rubyforge.org/frs/?group_id=126">RubyForge</a> and install it:</p>
<pre>
user$ cd src/unpacked-rubygems-directory
user$ ruby setup.rb
</pre>
	<h3>Step six: This is the real last step <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8211; Rails and a little hack</h3>
	<p>Now you&#8217;re free to install rails (and friends) using</p>
<pre>
user$ gem install rails --include-dependencies
user$ gem install mysql-ruby
user$ gem install capistrano --include-dependencies
user$ gem install mongrel --include-dependencies
</pre>
	<p>The small hack I was talking about is a symlink:</p>
<pre>
user$ sudo mv /usr/bin/ruby /usr/bin/ruby-apple
user$ sudo ln -s /Users/your_username/unix/bin/ruby /usr/bin/ruby
</pre>
	<p>This way applications that insist on using <em>/usr/bin/ruby</em> (TextMate&#8217;s RubyMate for example) will work fine. </p>
	<p>Have fun with your self-made rails stack <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/08/sudoless-rails-stack-on-osx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Capistrano 2 Callbacks</title>
		<link>http://tempe.st/2007/08/capistrano-2-callbacks/</link>
		<comments>http://tempe.st/2007/08/capistrano-2-callbacks/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 09:09:28 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/08/capistrano-2-callbacks/</guid>
		<description><![CDATA[Converting the callbacks in my cap recipes to the new capistrano 2 format wasn&#8217;t as easy as I thought it would be. It turned out I had to use fully qualified task names in the after callback instead of the non-namespaced-names. Here&#8217;s a sample of working callbacks: namespace :deploy do after &#34;deploy:setup&#34;, &#34;deploy:sposivip:create_galleries&#34;, &#34;deploy:sposivip:freeze_rails&#34; after [...]]]></description>
			<content:encoded><![CDATA[	<p>Converting the callbacks in my cap recipes to the new capistrano 2 format wasn&#8217;t as easy as I thought it would be. It turned out I had to use fully qualified task names in the after callback instead of the non-namespaced-names.</p>
	<p>Here&#8217;s a sample of working callbacks:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  after <span style="color:#996600;">&quot;deploy:setup&quot;</span>, <span style="color:#996600;">&quot;deploy:sposivip:create_galleries&quot;</span>, <span style="color:#996600;">&quot;deploy:sposivip:freeze_rails&quot;</span>
  after <span style="color:#996600;">&quot;deploy:update&quot;</span>, <span style="color:#996600;">&quot;deploy:site5:link_public_html&quot;</span>, <span style="color:#996600;">&quot;deploy:sposivip:link_rails&quot;</span>, <span style="color:#996600;">&quot;deploy:sposivip:link_galleries&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

	<p>Here I have two callbacks. The first one runs after setup, creating shared paths and freezing rails in the shared directory, so I avoid having a copy on rails in each release.</p>
	<p>The second callback runs after deploy:update, so it will be called whenever I do a simple deploy or a cold deploy, it links back various directories in the shared path and it links the shared rails in vendor.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/08/capistrano-2-callbacks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

