<?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>Automate Everything &#187; Ruby</title>
	<atom:link href="http://automate-everything.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://automate-everything.com</link>
	<description>Ruby, Linux and other hints, tips and tricks.</description>
	<lastBuildDate>Tue, 13 Jul 2010 06:36:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Gnome and Autospec Notifications</title>
		<link>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications</link>
		<comments>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications#comments</comments>
		<pubDate>Tue, 04 Aug 2009 15:38:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://automate-everything.com/?p=45</guid>
		<description><![CDATA[I wanted to share how I set up autospec notifications on Ubuntu (Jaunty 9.04). I'm using XCFE but should work perfectly on Gnome as well.]]></description>
			<content:encoded><![CDATA[<p><span lang="en">I&#8217;m very keen on DBB with RSpec now and I wanted to share how I set up autospec notifications on Ubuntu (Jaunty 9.04) as long as the post I followed to do it is no longer available.</span></p>

<p><span lang="en">I&#8217;m using XCFE but should work perfectly on Gnome as well. This is an screenshot of what you&#8217;ll get in the end:</span><br />
</p>
<div id="attachment_46" class="wp-caption alignnone" style="width: 601px"><img class="size-full wp-image-46" title="autospec notification XFCE/Gnome" src="http://automate-everything.com/wp-content/uploads/2009/08/autospec.png" alt="autospec notification XFCE/Gnome" width="591" height="279" /><p class="wp-caption-text">autospec notification XFCE/Gnome</p></div>
<p><span lang="en">First you need the ZenTest gem, you probably already do:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> ZenTest
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> redgreen</pre></div></div>

<p><span lang="en">Then install the <em>libnotify-bin</em> package:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libnotify-bin</pre></div></div>

<p><span lang="en">Here is the trick. Create a file called <em>~/.autotest</em> with this:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/bin/ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'redgreen'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'autotest/timestamp'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::GnomeNotify</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">notify</span> title, msg, img
    <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;notify-send '#{title}' '#{msg}' -i #{img} -t 3000&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;">: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>
    image_root = <span style="color:#996600;">&quot;~/.autotest_images&quot;</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>
    results.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\\e\<span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">+</span>m<span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</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>\sexamples?,\s<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>\sfailures?<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> output.<span style="color:#9900CC;">inspect</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> output
      <span style="color:#9966CC; font-weight:bold;">if</span> $~<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span>
        notify <span style="color:#996600;">&quot;FAIL&quot;</span>, <span style="color:#996600;">&quot;#{output}&quot;</span>, <span style="color:#996600;">&quot;#{image_root}/fail.png&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        notify <span style="color:#996600;">&quot;Pass&quot;</span>, <span style="color:#996600;">&quot;#{output}&quot;</span>, <span style="color:#996600;">&quot;#{image_root}/pass.png&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>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><span lang="en">As you can see I use the fail.png and pass.png images to show those cheesy smileys : ). You can download them here and copy them to <em>~/.autotest_images/</em>.</span></p>

<p><a href="http://automate-everything.com/wp-content/uploads/2009/08/autotest_images.zip">autotest_images.zip</a></p>
<p><span lang="en">Make your tests go green and have a beer! : )</span></p>

<p><span lang="en">Update: Added redgreen gem and changed &#8220;require redgreen&#8221; as Rodrigo Flores and rakk suggested. Thanks!</span></p>

<p><span lang="en">Update: Changed mistakenly escaped <code>&#62;</code>. Thanks to Martin y Hunter for the comments.</span></p>

]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Converting Avi files to Mp4 for Nokia 5800</title>
		<link>http://automate-everything.com/lang/en/2009/03/converting-avi-files-to-mp4-for-nokia-5800</link>
		<comments>http://automate-everything.com/lang/en/2009/03/converting-avi-files-to-mp4-for-nokia-5800#comments</comments>
		<pubDate>Sun, 29 Mar 2009 16:30:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.team-trick.net/?p=28</guid>
		<description><![CDATA[I've come to following Ruby script for converting an avi to mp4, Nokia 5800 ready. Subtitles included and 2 pass (which means high quality results).]]></description>
			<content:encoded><![CDATA[<p>Recently I acquired a <strong>Nokia 5800 XpressMusic</strong> mobile phone. Great one! It comes with a native video player capable of playing video up to a resolution of 640&#215;480 at 30fps. The video player, in combination with its big screen and the TV-out capability, makes this phone a good device for watching a movie with an acceptable quality. It can play videos in the following formats:</p>
<ul>
<li>3GPP formats (H.263)</li>
<li>Flash Video</li>
<li>H.264/AVC</li>
<li>MPEG-4</li>
<li>RealVideo 7,8,9/10</li>
<li>WMV 9</li>
</ul>
<p>But as you can see, there is <strong>no AVI playback</strong>. Right now there is no AVI player that supports Symbian s60 5th. So we&#8217;ll have to transcode our .avi files to .mp4 before playing them on the Nokia 5800. Playing with mencoder I&#8217;ve come to following commands for <strong>converting an AVI to MP4</strong>, Nokia 5800 ready. <strong>Subtitles included and 2 pass</strong> (which means high quality results):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mencoder <span style="color: #660033;">-of</span> lavf <span style="color: #660033;">-lavfopts</span> <span style="color: #007800;">format</span>=mp4 <span style="color: #660033;">-oac</span> lavc <span style="color: #660033;">-ovc</span> lavc <span style="color: #660033;">-lavcopts</span> <span style="color: #007800;">aglobal</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">vglobal</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">acodec</span>=libfaac:<span style="color: #007800;">vcodec</span>=mpeg4:<span style="color: #007800;">abitrate</span>=<span style="color: #000000;">96</span>:<span style="color: #007800;">vbitrate</span>=<span style="color: #000000;">800</span>:<span style="color: #007800;">keyint</span>=<span style="color: #000000;">250</span>:<span style="color: #007800;">mbd</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">vqmax</span>=<span style="color: #000000;">10</span>:<span style="color: #007800;">lmax</span>=<span style="color: #000000;">10</span>:<span style="color: #007800;">vpass</span>=<span style="color: #000000;">1</span>:turbo <span style="color: #660033;">-ofps</span> <span style="color: #000000;">25</span> <span style="color: #660033;">-af</span> <span style="color: #007800;">lavcresample</span>=<span style="color: #000000;">44100</span> <span style="color: #660033;">-vf</span> harddup,<span style="color: #007800;">scale</span>=<span style="color: #000000;">640</span>:-<span style="color: #000000;">3</span> <span style="color: #660033;">-sub</span> <span style="color: #ff0000;">'input.srt'</span> <span style="color: #ff0000;">'input.avi'</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'output.mp4'</span>
mencoder <span style="color: #660033;">-of</span> lavf <span style="color: #660033;">-lavfopts</span> <span style="color: #007800;">format</span>=mp4 <span style="color: #660033;">-oac</span> lavc <span style="color: #660033;">-ovc</span> lavc <span style="color: #660033;">-lavcopts</span> <span style="color: #007800;">aglobal</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">vglobal</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">acodec</span>=libfaac:<span style="color: #007800;">vcodec</span>=mpeg4:<span style="color: #007800;">abitrate</span>=<span style="color: #000000;">96</span>:<span style="color: #007800;">vbitrate</span>=<span style="color: #000000;">800</span>:<span style="color: #007800;">keyint</span>=<span style="color: #000000;">250</span>:<span style="color: #007800;">mbd</span>=<span style="color: #000000;">1</span>:<span style="color: #007800;">vqmax</span>=<span style="color: #000000;">10</span>:<span style="color: #007800;">lmax</span>=<span style="color: #000000;">10</span>:<span style="color: #007800;">vpass</span>=<span style="color: #000000;">2</span> <span style="color: #660033;">-ofps</span> <span style="color: #000000;">25</span> <span style="color: #660033;">-af</span> <span style="color: #007800;">lavcresample</span>=<span style="color: #000000;">44100</span> <span style="color: #660033;">-vf</span> harddup,<span style="color: #007800;">scale</span>=<span style="color: #000000;">640</span>:-<span style="color: #000000;">3</span> <span style="color: #660033;">-sub</span> <span style="color: #ff0000;">'input.srt'</span> <span style="color: #ff0000;">'input.avi'</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'output.mp4'</span></pre></div></div>

<p>Messy huh? What I did is a Ruby script that takes AVI files as an argument an transcode them taking care of everything. I mean: </p>
<ul>
<li>Automatically names the output as &#8220;file.mp4&#8243; from &#8220;file.avi&#8221;</li>
<li>Checks if there are subtitles (as an SRT file) and add them.</li>
<li>Performs the 2 passes.</li>
<li>Deletes the useless &#8220;divx2pass.log&#8221; once finished.</li>
<li>Resize and resample video and audio to fit the phone specs.</li>
</ul>
<p>Here is the script:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
&nbsp;
ARGV.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>input_f<span style="color:#006600; font-weight:bold;">|</span>
  everything_ok = <span style="color:#0000FF; font-weight:bold;">true</span>
  log_file = <span style="color:#996600;">&quot;divx2pass.log&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Escapes single quotes</span>
  input_f = input_f.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</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;">\'</span><span style="color:#000099;">\\</span>'<span style="color:#000099;">\'</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Extracts the file name without extension</span>
  file_name = input_f.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span>0..<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;.&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>  
&nbsp;
  <span style="color:#008000; font-style:italic;"># Output file</span>
  output_f = file_name <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;.mp4&quot;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>Converting <span style="color:#000099;">\'</span>#{input_f}<span style="color:#000099;">\'</span> into <span style="color:#000099;">\'</span>#{output_f}<span style="color:#000099;">\'</span>:&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Check if there are subtitles to add to the file</span>
  subs_args = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>file_name <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;.srt&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> ? <span style="color:#996600;">&quot; -sub <span style="color:#000099;">\'</span>#{file_name}.srt<span style="color:#000099;">\'</span>&quot;</span> : <span style="color:#996600;">&quot;&quot;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Encodes with two pass</span>
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;:vpass=1:turbo&quot;</span>,<span style="color:#996600;">&quot;:vpass=2&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>vpass<span style="color:#006600; font-weight:bold;">|</span>
    command = <span style="color:#996600;">&quot;mencoder&quot;</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -of lavf -lavfopts format=mp4&quot;</span> <span style="color:#008000; font-style:italic;"># Set container format to mp4</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -oac lavc&quot;</span> <span style="color:#008000; font-style:italic;"># Audio will be encoded with a libavcodec codec</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -ovc lavc&quot;</span> <span style="color:#008000; font-style:italic;"># Video will be encoded with a libavcodec codec</span>
&nbsp;
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -lavcopts&quot;</span> <span style="color:#008000; font-style:italic;"># Begin of options for libavcodec</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; aglobal=1:vglobal=1&quot;</span> <span style="color:#008000; font-style:italic;"># Needed for mp4</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:acodec=libfaac&quot;</span> <span style="color:#008000; font-style:italic;"># Encode audio as AAC</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:vcodec=mpeg4&quot;</span> <span style="color:#008000; font-style:italic;"># Encode video as mp4 too</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:abitrate=96&quot;</span> <span style="color:#008000; font-style:italic;"># Audio bitrate in Kbps</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:vbitrate=800&quot;</span> <span style="color:#008000; font-style:italic;"># Video bitrate in Kbps</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:keyint=250&quot;</span> <span style="color:#008000; font-style:italic;"># Number of frames between keyframes, a bit lower than the default to save some Megabytes</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:mbd=1&quot;</span> <span style="color:#008000; font-style:italic;"># Macroblock decision algorithm set to minimize size of file</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot;:vqmax=10:lmax=10&quot;</span> <span style="color:#008000; font-style:italic;"># Don't know whay but raises the video quality</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> vpass <span style="color:#008000; font-style:italic;"># First pass or second pass</span>
&nbsp;
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -ofps 25&quot;</span> <span style="color:#008000; font-style:italic;"># Convert the video to 25 fps to avoid incompatible fps values</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -af lavcresample=44100&quot;</span> <span style="color:#008000; font-style:italic;"># Resample the audio</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; -vf harddup,scale=640:-3&quot;</span> <span style="color:#008000; font-style:italic;"># Scale the video to 640 px width mantaining aspect ratio</span>
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> subs_args <span style="color:#008000; font-style:italic;"># Add subs</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># command &lt;&lt; &quot; -endpos 10&quot; # Encode just the first 10 seconds of video, useful for testing</span>
&nbsp;
    command <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#996600;">&quot; <span style="color:#000099;">\'</span>#{input_f}<span style="color:#000099;">\'</span> -o <span style="color:#000099;">\'</span>#{output_f}<span style="color:#000099;">\'</span>&quot;</span> <span style="color:#008000; font-style:italic;"># file names</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">puts</span> command
    everything_ok = <span style="color:#CC0066; font-weight:bold;">system</span> command
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> !everything_ok
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;There were errors encoding #{input_f}, aborting.&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">break</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">delete</span> log_file <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>? log_file
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;File succesfully encoded as <span style="color:#000099;">\'</span>#{output_f}<span style="color:#000099;">\'</span>&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> everything_ok
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Use it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">avi2mp4 myfile.avi</pre></div></div>

<p>And it will generate &#8220;myfile.mp4&#8243;. It also can receive several files as argument and will encode each of them separately. Hope you find this useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/03/converting-avi-files-to-mp4-for-nokia-5800/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Piston and git</title>
		<link>http://automate-everything.com/lang/en/2009/03/piston-and-git</link>
		<comments>http://automate-everything.com/lang/en/2009/03/piston-and-git#comments</comments>
		<pubDate>Thu, 26 Mar 2009 18:15:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.team-trick.net/?p=19</guid>
		<description><![CDATA[As many Rails developers I have some projects that I haven&#8217;t migrated to git yet. Those are still under Subversion and I manage its plugins with Piston. But what happen when you want to import a plugin hosted on a git repository? That the gem &#8220;piston&#8221; doesn&#8217;t work. The trick is that the last version [...]]]></description>
			<content:encoded><![CDATA[<p>As many Rails developers I have some projects that I haven&#8217;t migrated to git yet. Those are still under Subversion and I manage its plugins with <a href="http://piston.rubyforge.org/">Piston</a>. But what happen when you want to import a plugin hosted on a git repository? That the gem &#8220;piston&#8221; doesn&#8217;t work.</p>
<p>The trick is that the last version of piston that supports git is not the gem called &#8220;piston&#8221; but <a href="http://github.com/francois/piston/tree/master">&#8220;francois-piston&#8221;</a>. So let&#8217;s go:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem sources <span style="color: #660033;">-a</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com 
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> francois-piston</pre></div></div>

<p>Now we can do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">piston import git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>activescaffold<span style="color: #000000; font-weight: bold;">/</span>active_scaffold.git vendor<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>active_scaffold</pre></div></div>

<p>Easy :).</p>
]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/03/piston-and-git/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to migrate a Subversion repository from one server to another</title>
		<link>http://automate-everything.com/lang/en/2009/02/how-to-migrate-a-subversion-repository-from-one-server-to-another</link>
		<comments>http://automate-everything.com/lang/en/2009/02/how-to-migrate-a-subversion-repository-from-one-server-to-another#comments</comments>
		<pubDate>Tue, 10 Feb 2009 10:50:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.team-trick.net/?p=5</guid>
		<description><![CDATA[Now I got a new server I had to migrate my old Subversion repository from the old server to the new one. Thanks to Subversion it was a cake easy task.]]></description>
			<content:encoded><![CDATA[<p>Now I got a new server I had to migrate my old Subversion repository from the old server to the new one. Thanks to Subversion it was a cake easy task:</p>
<p>First, we have to dump our old repository.</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">ssh old-server.com
svnadmin dump svn/my-project &gt; my-project.dump
exit</pre></div></div>

<p>Then, we transfer the dump from one server to the other:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">cd /tmp
rsync -Praz old-server.com:my-project.dump .
rsync -Praz my-project.dump new-server.com:~</pre></div></div>

<p>We are now ready to load the dump into the new repository:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">ssh new-server.com
mkdir svn
svnadmin create svn/my-project
svnadmin load svn/my-project &amp;lt; my-project.dump
exit</pre></div></div>

<p>Finally, we update our local copy of the code:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">mv my-project my-project.old
svn co svn+ssh://new-server.com/home/your-user-name/svn/my-project/trunk my-project</pre></div></div>

<p>And you are ready to code!</p>
]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/02/how-to-migrate-a-subversion-repository-from-one-server-to-another/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How I got Mephisto working on Dreamhost</title>
		<link>http://automate-everything.com/lang/en/2009/02/how-i-got-mephisto-working-on-dreamhost</link>
		<comments>http://automate-everything.com/lang/en/2009/02/how-i-got-mephisto-working-on-dreamhost#comments</comments>
		<pubDate>Tue, 10 Feb 2009 10:49:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.team-trick.net/?p=3</guid>
		<description><![CDATA[Installing the Ruby on Rails blog engine <a href="http://mephistoblog.com/">Mephisto</a> should be an easy task. However, I found this trickier than I expected. ]]></description>
			<content:encoded><![CDATA[<p>As long as <a href="http://www.dreamhost.com/r.cgi?498018">Dreamhost</a> supports <a href="http://www.modrails.com/">Phusion Passenger</a> now, installing the Ruby on Rails blog engine <a href="http://mephistoblog.com/">Mephisto</a> should be an easy task. However, I found this trickier than I expected. I followed the basic instructions and I was getting the following error on my <em><code>log/production.log</code></em>:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">ActionView::TemplateError (can't convert nil into String) on line #6 of app/views/admin/design/_sidebar.rhtml:
3: &lt;p&gt;Modify a template by selecting it from the list below.  Add a new layout by creating a Liquid template with an
4:   *_layout suffix (e.g custom_layout).&lt;/p&gt;
5: &lt;ul id=&quot;attachments&quot;&gt;
6:   &lt;% @theme.templates.template_types(@theme.extension).each do |template| -%&gt;
7:     &lt;li&gt;&lt;%= link_to h(template), url_for_theme(:controller =&gt; 'templates', :action =&gt; 'edit', :filename =&gt; template) %&gt;&lt;/li&gt;
8:   &lt;% end -%&gt;
9:   &lt;% @theme.templates.custom(@theme.extension).each_with_index do |template, i| -%&gt;
&nbsp;
    /home/manuelmorales/mephisto/app/models/templates.rb:6:in `+'
    /home/manuelmorales/mephisto/app/models/templates.rb:6:in `template_types'
    /home/manuelmorales/mephisto/app/models/templates.rb:6:in `collect'
    /home/manuelmorales/mephisto/app/models/templates.rb:6:in `template_types'
    ....</pre></div></div>

<p>The problem is that, in spite of the right <em>tzinfo</em> gem already comes with Mephisto, Phusion Passenger is ignoring local gems, taking the old version of <em>tzinfo</em> that Dreamhost provides. The solution is simple: Force Rails to load exactly that gem adding the following to your <em><code>config/environment.rb</code></em>.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">...
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'/home/&lt;yourusernamehere&gt;/mephisto/vendor/gems/tzinfo-0.3.12/lib/tzinfo'</span>
...</pre></div></div>

<p>And restarted the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> tmp<span style="color: #000000; font-weight: bold;">/</span>restart.txt</pre></div></div>

<p>Visited a working page of the blog twice to force the restart to make effect and <em>tzinfo</em> error gone.</p>
<p>In case that you are trying to install another application that doesn’t already come with the gem you have to override, you will have to install it locally before forcing Rails to load it. Directions about how to install gems locally in the <a href="http://wiki.dreamhost.com/index.php/RubyGems#Installing.2Fupdating_gems_without_installing_gem_2">Dreamhost wiki</a>.</p>
<p>But that wasn’t enough. Then I was getting the following error:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">ActionView::TemplateError (attempted to output tainted string: &lt;a href=&quot;mailto:email@domain.com&quot;&gt;email@domain.com&lt;/a&gt;) on line #14 of app/views/admin/sites/show.rhtml:
11: &lt;% form_for :site, :url =&gt; { :action =&gt; &quot;update&quot;, :id =&gt; @site } do |f| -%&gt;
12: &lt;%= f.error_messages %&gt;
13: &lt;div id=&quot;general&quot; class=&quot;setgroup&quot;&gt;
14:   &lt;h3&gt;&lt;%=h @site.title %&gt; &lt;small&gt;(&lt;%= mail_to @site.email %&gt;)&lt;/small&gt;&lt;/h3&gt;
15:   &lt;dl class=&quot;setform&quot;&gt;
16:             &lt;dt&gt;&lt;label for=&quot;site_host&quot;&gt;Host&lt;/label&gt;&lt;/dt&gt;
17:             &lt;dd&gt;&lt;%= f.text_field :host %&gt;&lt;/dd&gt;
&nbsp;
    /home/manuelmorales/mephisto/vendor/gems/emk-safe_erb-0.1.1/lib/safe_erb/common.rb:48:in `concat_unless_tainted'
    /home/manuelmorales/mephisto/app/views/admin/sites/show.rhtml:14
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:313:in `fields_for'
    ...</pre></div></div>

<p>As said here on the <a href="http://mephistoblog.com/2008/12/21/mephisto-security-advisory">Mephisto blog</a>:</p>
<blockquote><p>One debugging tip: If you see an error like ActionView::TemplateError (attempted to output tainted string), you’ve run afoul of SafeERB and you probably need to insert an h(…) somewhere. Don’t hesitate to ask for help on #mephisto.</p></blockquote>
<p>That’s it. I had to go to file <em><code>app/views/admin/sites/show.rhtml</code></em>, line 14,  and modify this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">&lt;h3&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>=h <span style="color:#0066ff; font-weight:bold;">@site</span>.<span style="color:#9900CC;">title</span> <span style="color:#006600; font-weight:bold;">%&gt;</span> &lt;small&gt;(<span style="color:#006600; font-weight:bold;">&lt;%</span>=<span style="color:#5A0A0A; font-weight:bold;">mail_to</span> <span style="color:#0066ff; font-weight:bold;">@site</span>.<span style="color:#9900CC;">email</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>)&lt;/small&gt;&lt;/h3&gt;</pre></div></div>

<p>to surround the <em><code>@site.email</code></em> with <em>h()</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">&lt;h3&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>=h <span style="color:#0066ff; font-weight:bold;">@site</span>.<span style="color:#9900CC;">title</span> <span style="color:#006600; font-weight:bold;">%&gt;</span> &lt;small&gt;(<span style="color:#006600; font-weight:bold;">&lt;%</span>=<span style="color:#5A0A0A; font-weight:bold;">mail_to</span> h<span style="color:#006600; font-weight:bold;">&#40;</span>@site.<span style="color:#9900CC;">email</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>)&lt;/small&gt;&lt;/h3&gt;</pre></div></div>

<p>And here is it. Fully working now! : )</p>
]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/02/how-i-got-mephisto-working-on-dreamhost/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
