<?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>ricardo duarte</title>
	<atom:link href="http://ricardoduarte.com/log/feed/" rel="self" type="application/rss+xml" />
	<link>http://ricardoduarte.com/log</link>
	<description>ruby, rails, linux, php, seo and ui</description>
	<lastBuildDate>Thu, 04 Feb 2010 02:18:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Git: Push e Delete de branches remotos</title>
		<link>http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/</link>
		<comments>http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 02:18:02 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[dscm]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=182</guid>
		<description><![CDATA[Dica rápida
Para enviar um branch local para o servidor remoto, use o comando abaixo:
git push origin nova-funcionalidade
Já para deletar um branch remoto, é tão simples quanto:
git push origin :nova-funcionalidade
PS. Não esqueça de deletar o branch local também, se for o caso:
git branch -d nova-funcionalidade
Dica do git ready.





		
			Tweet This!
		
		
			Share this on Facebook
		
		
			Add this to Google Bookmarks
		
		
			Share [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Dica rápida</strong></p>
<p>Para enviar um branch local para o servidor remoto, use o comando abaixo:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">git push origin nova-funcionalidade</div></div>
<p>Já para deletar um branch remoto, é tão simples quanto:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">git push origin :nova-funcionalidade</div></div>
<p>PS. Não esqueça de deletar o branch local também, se for o caso:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">git branch <span style="color: #660033;">-d</span> nova-funcionalidade</div></div>
<p>Dica do <strong><a href="http://www.gitready.com/beginner/2009/02/02/push-and-delete-branches.html">git ready</a></strong>.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Git%3A+Push+e+Delete+de+branches+remotos+-+http://tr.im/MKxK+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/&amp;t=Git%3A+Push+e+Delete+de+branches+remotos" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/&amp;title=Git%3A+Push+e+Delete+de+branches+remotos" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/&amp;title=Git%3A+Push+e+Delete+de+branches+remotos" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/&amp;title=Git%3A+Push+e+Delete+de+branches+remotos&amp;summary=Dica%20r%C3%A1pida%0D%0A%0D%0APara%20enviar%20um%20branch%20local%20para%20o%20servidor%20remoto%2C%20use%20o%20comando%20abaixo%3A%0D%0A%5Bcc%20lang%3D%22bash%22%5D%0D%0Agit%20push%20origin%20nova-funcionalidade%0D%0A%5B%2Fcc%5D%0D%0A%0D%0AJ%C3%A1%20para%20deletar%20um%20branch%20remoto%2C%20%C3%A9%20t%C3%A3o%20simples%20quanto%3A%0D%0A%5Bcc%20lang%3D%22bash%22%5D%0D%0Agit%20push%20origin%20%3Anova-funcionalidade%0D%0A%5B%2Fcc%5D%0D%0A%0D%0APS.%20N%C3%A3o%20esque%C3%A7a%20de&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/&amp;title=Git%3A+Push+e+Delete+de+branches+remotos" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2010/02/git-push-e-delete-de-branches-remotos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filtrando as consultas com has_scope</title>
		<link>http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/</link>
		<comments>http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 02:50:53 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=176</guid>
		<description><![CDATA[A Plataforma Tecnologia lançou recentemente o has_scope, plugin/gem extraído do InheritedResources (o qual ainda não tive a capacidade de entender o funcionamento).
Ele permite criar filtros nas consultas usando os escopos (named_scopes) definidos no Model de uma forma simples e elegante, mantendo toda a lógica do negócio fora do Controller.
Vamos ao código:
No Model abaixo, implementei dois [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.plataformatec.com.br/">Plataforma Tecnologia</a> lançou recentemente o <a href="http://github.com/plataformatec/has_scope">has_scope</a>, plugin/gem extraído do <a href="http://github.com/josevalim/inherited_resources">InheritedResources</a> (o qual ainda não tive a capacidade de entender o funcionamento).</p>
<p>Ele permite criar filtros nas consultas usando os escopos (named_scopes) definidos no <em>Model</em> de uma forma simples e elegante, mantendo toda a lógica do negócio fora do <em>Controller</em>.</p>
<p>Vamos ao código:</p>
<p>No <em>Model</em> abaixo, implementei dois escopos que gostaria de usar para filtrar a consulta.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># /app/models/timesheet.rb</span><br />
<span style="color:#9966CC; font-weight:bold;">class</span> Timesheet <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; named_scope <span style="color:#ff3333; font-weight:bold;">:by_employee</span>, <span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>employee<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:employee_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> employee <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; named_scope <span style="color:#ff3333; font-weight:bold;">:by_place</span>, <span style="color:#CC0066; font-weight:bold;">proc</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>place<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:place_id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> place <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>No <em>Controller</em>, defini quais escopos que vou usar no filtro.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># /app/controllers/timesheets_controller.rb</span><br />
<span style="color:#9966CC; font-weight:bold;">class</span> TimesheetsController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController<br />
&nbsp; has_scope <span style="color:#ff3333; font-weight:bold;">:by_employee</span><br />
&nbsp; has_scope <span style="color:#ff3333; font-weight:bold;">:by_place</span> &nbsp; &nbsp;<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> index<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@timesheets</span> = apply_scopes<span style="color:#006600; font-weight:bold;">&#40;</span>Timesheet<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">all</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Na <em>View</em>, criei uma partial com os campos do filtro.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; # /app/views/timesheets/_filter.html.rb<br />
<span style="color:#006600; font-weight:bold;">&lt;%</span> form_tag <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'/timesheets'</span>, <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:get</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;">-%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= select_tag <span style="color:#996600;">'by_employee'</span>, options_for_select<span style="color:#006600; font-weight:bold;">&#40;</span>@employees, params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:by_employee</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= select_tag <span style="color:#996600;">'by_place'</span>, options_for_select<span style="color:#006600; font-weight:bold;">&#40;</span>@places, params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:by_place</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">&lt;%</span>= content_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:button</span>, <span style="color:#996600;">&quot;Search&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;submit&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">-%&gt;</span></div></div>
<p>Esse formulário do filtro irá chamar o método <em>index</em> usando GET (através da URL), como no exemplo:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http:<span style="color: #000000; font-weight: bold;">//</span>localhost:3000<span style="color: #000000; font-weight: bold;">/</span>timesheets?<span style="color: #007800;">by_employee</span>=1<span style="color: #000000; font-weight: bold;">&amp;</span><span style="color: #007800;">by_place</span>=<span style="color: #000000;">3</span></div></div>
<p>Como de costume, esse post é só um aperitivo. Acesse o completíssimo <a href="http://github.com/plataformatec/has_scope#readme">README no GitHub</a> para mais detalhes de utilização.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Filtrando+as+consultas+com+has_scope+-+http://tr.im/Jyxg+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/&amp;t=Filtrando+as+consultas+com+has_scope" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/&amp;title=Filtrando+as+consultas+com+has_scope" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/&amp;title=Filtrando+as+consultas+com+has_scope" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/&amp;title=Filtrando+as+consultas+com+has_scope&amp;summary=A%20Plataforma%20Tecnologia%20lan%C3%A7ou%20recentemente%20o%20has_scope%2C%20plugin%2Fgem%20extra%C3%ADdo%20do%20InheritedResources%20%28o%20qual%20ainda%20n%C3%A3o%20tive%20a%20capacidade%20de%20entender%20o%20funcionamento%29.%0D%0A%0D%0AEle%20permite%20criar%20filtros%20nas%20consultas%20usando%20os%20escopos%20%28named_scopes%29%20definidos%20no%20Model%20de%20uma%20forma%20simples%20e%20elegante%2C%20mant&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/&amp;title=Filtrando+as+consultas+com+has_scope" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2010/01/filtrando-as-consultas-com-has_scope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RPCFN #2: Average Arrival Time For A Flight</title>
		<link>http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/</link>
		<comments>http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 02:15:55 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=166</guid>
		<description><![CDATA[O Ruby Learning começou uma série de desafios para Rubistas iniciantes, na qual um profissional Ruby elabora um problema e os interessados em participar enviam as soluções desenvolvidas em Ruby para serem avaliadas. O autor do desafio escolhe a melhor implementação e sorteia uma entre as outras soluções funcionais. Os premios são screencasts da PeepCode [...]]]></description>
			<content:encoded><![CDATA[<p>O <a href="http://rubylearning.com/blog/">Ruby Learning</a> começou uma <a href="http://rubylearning.com/blog/2009/09/20/rpcfn-ruby-programming-challenge-for-newbies/">série de desafios para Rubistas iniciantes</a>, na qual um profissional Ruby elabora um problema e os interessados em participar enviam as soluções desenvolvidas em Ruby para serem avaliadas. O autor do desafio escolhe a melhor implementação e sorteia uma entre as outras soluções funcionais. Os premios são screencasts da <a href="http://peepcode.com/screencasts/ruby-on-rails">PeepCode</a> e <a href="http://bddcasts.com/">BDDCasts</a>.</p>
<p><em>Por que não participar?</em></p>
<p>O <a href="http://rubylearning.com/blog/2009/10/08/rpcfn-average-arrival-time-for-a-flight-2/">problema proposto</a> pelo <a href="http://japhr.blogspot.com/">Chris Strom</a> foi o seguinte:</p>
<blockquote><p>Você deve um grande favor e concordou em pegar um amigo no aeroporto toda Sexta-feira a noite. A linha área que seu amigo voa é barata, mas terrível quando se trata em reportar atrasos e horários de saída e chegada. Você rapidamente descobriu que o voos agendados para as 10pm nunca chegam no horário e usualmente atrasam mais de uma hora. Se o avião chegar as 11:15pm, 12:03am, 11:30pm, 11:23pm e 11:48pm, qual é o horário médio da chegada?</p>
<p>A solução funciona se seu amigo mudar o horário de chegada para 6 horas depois? E se for 12 horas depois?</p></blockquote>
<p>A saída esperada do programa é a seguinte:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> average_time_of_day<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;6:41am&quot;</span>, <span style="color: #ff0000;">&quot;6:51am&quot;</span>, <span style="color: #ff0000;">&quot;7:01am&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;06:51am&quot;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;</span> average_time_of_day<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;11:51pm&quot;</span>, <span style="color: #ff0000;">&quot;11:56pm&quot;</span>, <span style="color: #ff0000;">&quot;12:01am&quot;</span>, <span style="color: #ff0000;">&quot;12:06am&quot;</span>, <span style="color: #ff0000;">&quot;12:11am&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;12:01am&quot;</span></div></div>
<p><em>E qual foi a minha solução?</em></p>
<p>Eu identifiquei os seguintes passos a serem seguidos:</p>
<ul>
<li>Transformar as posições do array de String para Time, para poder calcular qual é o médio.</li>
<li>O problema deixa claro que todos os tempos são no futuro, então é preciso corrigir o parser de tempo das horas que são do dia seguinte. No exemplo: Se no momento da consulta são <strong>28/10/2009 19:00</strong>, o parser do Ruby irá converter 12:01am, 12:06am e 12:11am para 00:01, 00:06 e 00:11 do dia <strong>28/10/2009</strong>, quando o correto seria do dia <strong>29/10/2009</strong>).</li>
<li>Ordenar o array por tempo ascendente.</li>
<li>Pegar a posição do meio do array.</li>
</ul>
<p>O código para essa implementação foi o seguinte:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'time'</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> average_time_of_day<span style="color:#006600; font-weight:bold;">&#40;</span>times<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; clean = <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">new</span><br />
&nbsp; &nbsp; times.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parsed = <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>t<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; parsed <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006600; font-weight:bold;">&#40;</span>60<span style="color:#006600; font-weight:bold;">*</span>60<span style="color:#006600; font-weight:bold;">*</span>24<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> parsed <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; clean.<span style="color:#9900CC;">push</span><span style="color:#006600; font-weight:bold;">&#40;</span>parsed<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; clean<span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#006600; font-weight:bold;">&#40;</span>clean.<span style="color:#9900CC;">count</span> <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006666;">2.0</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">ceil</span> <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">1</span> <span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">strftime</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;%I:%M%p&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Executando os testes propostos, tenho o resultado esperado. Woooo!</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;&gt;</span> average_time_of_day<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;6:41am&quot;</span>, <span style="color: #ff0000;">&quot;6:51am&quot;</span>, <span style="color: #ff0000;">&quot;7:01am&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;06:51AM&quot;</span><br />
&nbsp;<br />
<span style="color: #000000; font-weight: bold;">&gt;&gt;</span> average_time_of_day<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;11:51pm&quot;</span>, <span style="color: #ff0000;">&quot;11:56pm&quot;</span>, <span style="color: #ff0000;">&quot;12:01am&quot;</span>, <span style="color: #ff0000;">&quot;12:06am&quot;</span>, <span style="color: #ff0000;">&quot;12:11am&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
=<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #ff0000;">&quot;12:01AM&quot;</span></div></div>
<p>As soluções vencedoras foram:</p>
<ul>
<li><a href="https://gist.github.com/5b371226faf83af50d7e">Charles Feduke</a></li>
<li><a href="http://gist.github.com/205002">Othmane Benkirane</a></li>
</ul>
<p><strong>UPDATE:</strong> o <a href="http://japhr.blogspot.com/2009/10/newbie-feedback.html">Chris Storm publicou um feedback</a> sobre as soluções do teste. Leitura obrigatória.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight+-+http://tr.im/Dif8+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/&amp;t=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/&amp;title=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/&amp;title=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/&amp;title=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight&amp;summary=O%20Ruby%20Learning%20come%C3%A7ou%20uma%20s%C3%A9rie%20de%20desafios%20para%20Rubistas%20iniciantes%2C%20na%20qual%20um%20profissional%20Ruby%20elabora%20um%20problema%20e%20os%20interessados%20em%20participar%20enviam%20as%20solu%C3%A7%C3%B5es%20desenvolvidas%20em%20Ruby%20para%20serem%20avaliadas.%20O%20autor%20do%20desafio%20escolhe%20a%20melhor%20implementa%C3%A7%C3%A3o%20e%20sorteia%20uma%20entre%20as%20outra&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/&amp;title=RPCFN+%232%3A+Average+Arrival+Time+For+A+Flight" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/10/rpcfn-2-average-arrival-time-for-a-flight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Criando um Rails Application Template</title>
		<link>http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/</link>
		<comments>http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 02:42:45 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=158</guid>
		<description><![CDATA[Quando vamos criar uma aplicação Rails, normalmente executamos uma série de passos (instalação de plugins, gems, controllers, etc.) iguais. Por que não automatizar esse processo?
Usando o ótimo guia escrito pelo Nando Vieira sobre Rails Application Templates, escrevi o meu primeiro template:
# Removendo porcarias
run &#34;rm README&#34;
run &#34;rm public/index.html&#34;
run &#34;rm public/favicon.ico&#34;
run &#34;rm public/robots.txt&#34;
&#160;
# Git
git :init
file&#40;&#34;.gitignore&#34;&#41; do
&#60;&#60;-EOF
log/*.log
tmp/**/*
doc/api
doc/app
EOF
end
file&#40;&#34;log/.gitignore&#34;, ''&#41;
file&#40;&#34;tmp/.gitignore&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-159" title="Rails Application Templates" src="http://ricardoduarte.com/log/wp-content/uploads/2009/09/rails.gif" alt="Rails Application Templates" width="180" height="141" />Quando vamos criar uma aplicação Rails, normalmente executamos uma série de passos (instalação de plugins, gems, controllers, etc.) iguais. Por que não automatizar esse processo?</p>
<p>Usando o ótimo <a href="http://howto.simplesideias.com.br/rails-application-templates" target="_blank">guia escrito pelo Nando Vieira sobre Rails Application Templates</a>, escrevi o meu primeiro template:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Removendo porcarias</span><br />
run <span style="color:#996600;">&quot;rm README&quot;</span><br />
run <span style="color:#996600;">&quot;rm public/index.html&quot;</span><br />
run <span style="color:#996600;">&quot;rm public/favicon.ico&quot;</span><br />
run <span style="color:#996600;">&quot;rm public/robots.txt&quot;</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># Git</span><br />
git <span style="color:#ff3333; font-weight:bold;">:init</span><br />
file<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;.gitignore&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
<span style="color:#006600; font-weight:bold;">&lt;&lt;-</span>EOF<br />
log<span style="color:#006600; font-weight:bold;">/*</span>.<span style="color:#9900CC;">log</span><br />
tmp<span style="color:#006600; font-weight:bold;">/**/*</span><br />
doc<span style="color:#006600; font-weight:bold;">/</span>api<br />
doc<span style="color:#006600; font-weight:bold;">/</span>app<br />
EOF<br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
file<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;log/.gitignore&quot;</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
file<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;tmp/.gitignore&quot;</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
git <span style="color:#ff3333; font-weight:bold;">:add</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.&quot;</span><br />
git <span style="color:#ff3333; font-weight:bold;">:commit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-a -m 'Initial commit'&quot;</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># Gems</span><br />
gem <span style="color:#996600;">&quot;authlogic&quot;</span><br />
gem <span style="color:#996600;">&quot;rspec&quot;</span><br />
gem <span style="color:#996600;">&quot;rspec-rails&quot;</span><br />
gem <span style="color:#996600;">&quot;less&quot;</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># Plugins</span><br />
plugin <span style="color:#996600;">&quot;less-for-rails&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/augustl/less-for-rails.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;jrails&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/aaronchi/jrails.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;i18n_label&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/iain/i18n_label.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;activerecord_i18n_defaults&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/dcrec1/activerecord_i18n_defaults.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;brazilian-rails&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/tapajos/brazilian-rails.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;asset_packager&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/sbecker/asset_packager.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;formtastic&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/justinfrench/formtastic.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;paperclip&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/thoughtbot/paperclip.git&quot;</span><br />
plugin <span style="color:#996600;">&quot;will_paginate&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:git</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;git://github.com/mislav/will_paginate.git&quot;</span><br />
git <span style="color:#ff3333; font-weight:bold;">:add</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.&quot;</span><br />
git <span style="color:#ff3333; font-weight:bold;">:commit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-a -m 'Installing basic plugins'&quot;</span><br />
&nbsp;<br />
<span style="color:#008000; font-style:italic;"># I18n - pt-br</span><br />
file <span style="color:#996600;">&quot;config/locales/pt-BR.yml&quot;</span>, <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;http://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/pt-BR.yml&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">read</span><br />
gsub_file <span style="color:#996600;">'config/environment.rb'</span>, <span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;"># (config.i18n.default_locale = ):de/, '\1' + &quot;'pt-BR'&quot;</span><br />
gsub_file <span style="color:#996600;">'config/environment.rb'</span>, <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>config.<span style="color:#9900CC;">time_zone</span> = <span style="color:#996600;">')UTC'</span><span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">'<span style="color:#000099;">\1</span>'</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'Brasilia'</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'<span style="color:#000099;">\'</span>'</span><br />
git <span style="color:#ff3333; font-weight:bold;">:add</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;.&quot;</span><br />
git <span style="color:#ff3333; font-weight:bold;">:commit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;-a -m 'Configure locale and language'&quot;</span></div></div>
<p>Para usar o template, basta chama-lo durante a criação da aplicação com o parametro -m:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ricardo<span style="color: #000000; font-weight: bold;">@</span>earth:~<span style="color: #000000; font-weight: bold;">/</span> $ rails <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-m</span> template.rb</div></div>
<p>Esse template é bem simples e faz apenas o que eu uso sempre em todas as aplicações:</p>
<ul>
<li><strong>Gems</strong>: authlogic, rspec, rspec-rails e less</li>
<li><strong>Plugins</strong>: less-for-rails, jrails, i18n_label, activerecord_i18n_defaults, brazilian-rails, asset_packager, formtastic, paperclip e will_paginate.</li>
<li><strong>Git</strong>: Inicia um repositório e faz os primeiros commits</li>
<li><strong>Rails</strong>: Configura a linguagem para pt-br e o timezone para UTC-3.</li>
</ul>
<p>Pode melhorar esse script? <a href="http://gist.github.com/189987" target="_blank">Faça um fork no Github</a></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Criando+um+Rails+Application+Template+-+http://tr.im/zfBu+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/&amp;t=Criando+um+Rails+Application+Template" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/&amp;title=Criando+um+Rails+Application+Template" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/&amp;title=Criando+um+Rails+Application+Template" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/&amp;title=Criando+um+Rails+Application+Template&amp;summary=Quando%20vamos%20criar%20uma%20aplica%C3%A7%C3%A3o%20Rails%2C%20normalmente%20executamos%20uma%20s%C3%A9rie%20de%20passos%20%28instala%C3%A7%C3%A3o%20de%20plugins%2C%20gems%2C%20controllers%2C%20etc.%29%20iguais.%20Por%20que%20n%C3%A3o%20automatizar%20esse%20processo%3F%0D%0A%0D%0AUsando%20o%20%C3%B3timo%20guia%20escrito%20pelo%20Nando%20Vieira%20sobre%20Rails%20Application%20Templates%2C%20escrevi%20o%20meu%20primeiro%20templat&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/&amp;title=Criando+um+Rails+Application+Template" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/09/criando-um-rails-application-template/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deployment automatizado de aplicação PHP com Capistrano</title>
		<link>http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/</link>
		<comments>http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 22:44:48 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=138</guid>
		<description><![CDATA[Os que me conhecem sabe quanto o Rails Summit 2008 mudou a minha vida profissionalmente. Eu já sabia que as coisas haviam evoluído mas sinceramente nunca tinha dado muita bola, pois os meus processos sempre funcionaram bem. Lá eu pude ver que muita coisa legal estava sendo feita e eu que não podia ficar de [...]]]></description>
			<content:encoded><![CDATA[<p>Os que me conhecem sabe quanto o <a href="http://www.flickr.com/photos/rduarte/sets/72157608092300235/" target="_blank">Rails Summit 2008</a> mudou a minha vida profissionalmente. Eu já sabia que as coisas haviam evoluído mas sinceramente nunca tinha dado muita bola, pois os meus processos sempre funcionaram bem. Lá <strong>eu pude ver</strong> que muita coisa legal estava sendo feita e eu que não podia ficar de fora. Uma delas foi o <strong>deployment automatizado</strong>.</p>
<h2>Capistrano</h2>
<p>O <a href="http://www.capify.org/" target="_blank">Capistrano</a> é uma RubyGem que permite que você escreva receitas para publicação em servidores web. É possível usa-la integrada com o seu repositório (centralizado ou distribuído) ou mesmo <em>copiar-tudo-compactar-e-enviar</em> automaticamente. Ele permite manter várias versões da aplicação no servidor (e fazer rollback se necessário) e utiliza links simbólicos para dizer qual delas é a atual.</p>
<p>A instalação é mais facil que fazer miojo:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> capistrano</div></div>
<p>É necessário ter o <a href="http://www.ruby-lang.org/pt/" target="_blank">Ruby</a> e o <a href="http://rubygems.org/" target="_blank">RubyGems</a> instalado no seu sistema. <a href="http://wiki.github.com/rduarte/boep/instalando-ruby-rails-git" target="_blank">Se você usa Ubuntu, eu posso ajudar</a>.</p>
<h2>Configurando o seu projeto</h2>
<p>Dentro do diretório do seu projeto, crie a estrutura basica do capistrano:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ capify .<br />
<span style="color: #666666; font-style: italic;"># [add] writing `./Capfile'</span><br />
<span style="color: #666666; font-style: italic;"># [skip] `./Capfile' already exists</span><br />
<span style="color: #666666; font-style: italic;"># [add] writing `./config/deploy.rb'</span><br />
<span style="color: #666666; font-style: italic;"># [done] capified!</span></div></div>
<p>Notem que o arquivo <em>config/deploy.rb</em> foi criado. É nele que você irá escrever a sua receita.</p>
<h2>Exemplo de receita usando estratégia de cópia</h2>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;dominio.com.br&quot;</span><br />
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;dominio.com.br&quot;</span><br />
<br />
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;aplicacao&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:repository</span>, <span style="color:#996600;">&quot;.&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:none</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_via</span>, <span style="color:#ff3333; font-weight:bold;">:copy</span><br />
set <span style="color:#ff3333; font-weight:bold;">:copy_compression</span>, <span style="color:#ff3333; font-weight:bold;">:bz2</span><br />
set <span style="color:#ff3333; font-weight:bold;">:copy_exclude</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;lixo&quot;</span>, <span style="color:#996600;">&quot;config&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:user</span>, <span style="color:#996600;">&quot;usuario&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:use_sudo</span>, <span style="color:#0000FF; font-weight:bold;">false</span><br />
set <span style="color:#ff3333; font-weight:bold;">:keep_releases</span>, 5<br />
set <span style="color:#ff3333; font-weight:bold;">:app_symlinks</span>, <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;f&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:normalize_asset_timestamps</span>, <span style="color:#0000FF; font-weight:bold;">false</span><br />
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;~/php_apps/#{application}&quot;</span><br />
set <span style="color:#ff3333; font-weight:bold;">:public_path</span>, <span style="color:#996600;">&quot;~/public_html&quot;</span><br />
<br />
ssh_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:keys</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;#{ENV['HOME']}/.ssh/id_rsa&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
namespace <span style="color:#ff3333; font-weight:bold;">:deploy</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp;<span style="color:#008000; font-style:italic;"># Anula o restart do servidor</span><br />
&nbsp; &nbsp;desc <span style="color:#996600;">&quot;Fake restart&quot;</span><br />
&nbsp; &nbsp;task <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:app</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; run <span style="color:#996600;">&quot;exit&quot;</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
task <span style="color:#ff3333; font-weight:bold;">:define_conf_files</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:app</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp;run <span style="color:#996600;">&quot;rm -rfd #{release_path}/conf.php&quot;</span><br />
&nbsp; &nbsp;run <span style="color:#996600;">&quot;ln -nfs #{release_path}/conf-online.php #{release_path}/conf.php&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
desc <span style="color:#996600;">&quot;Setup application symlinks in the public&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:symlinks_setup</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:web</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">if</span> app_symlinks<br />
&nbsp; &nbsp; &nbsp; app_symlinks.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>link<span style="color:#006600; font-weight:bold;">|</span> run <span style="color:#996600;">&quot;mkdir -p #{shared_path}/public/#{link}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
desc <span style="color:#996600;">&quot;Link public directories to shared location.&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:symlinks_update</span>, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:web</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">if</span> app_symlinks<br />
&nbsp; &nbsp; &nbsp; app_symlinks.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>link<span style="color:#006600; font-weight:bold;">|</span> run <span style="color:#996600;">&quot;ln -nfs #{shared_path}/public/#{link} #{current_path}/#{link}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp;<span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp;run <span style="color:#996600;">&quot;ln -nfs #{current_path} #{public_path}&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
after <span style="color:#996600;">&quot;deploy:update_code&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:define_conf_files</span><br />
after <span style="color:#996600;">&quot;deploy:symlink&quot;</span>, <span style="color:#996600;">&quot;symlinks_update&quot;</span></div></div>
<h2>Usando o Capistrano</h2>
<p>Após estar com a receita devidamente escrita, é hora de configurar o servidor online para a estrutura do Capistrano.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cap deploy:setup</div></div>
<p>O <em>setup</em> só precisa ser rodado uma única vez.</p>
<p>Depois de configurado, para publicar a sua aplicação basta fazer isso:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cap deploy</div></div>
<p>Mágico né?</p>
<p>Fez merda e publicou alguma coisa que não devia? Faça um rollback!</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cap deploy:rollback</div></div>
<p>Algumas considerações sobre essa receita:</p>
<ol>
<li><strong><span style="text-decoration: underline;"><span style="color: #ff0000;">FAÇA BACKUP!</span></span></strong> Antes de começar a testar o capistrano, tenha certeza que os arquivos da sua aplicação estão protegidos e você não irá fazer cagada.</li>
<li>Por se tratar de uma aplicação em <strong>PHP</strong>, não é necessário reiniciar o servidor como em aplicações <strong>Rails</strong>. Por isso reescrevi a tarefa <em>restart</em> para que ele não faça nada.</li>
<li>A aplicação em questão permite o upload de arquivos pelos usuários, sendo necessário criar links simbólicos para manter esses dados fisicamente fora da estrutura da aplicação que será enviada pelo Capistrano. Nesse caso, todos os arquivos que serão enviados pelos usuários ficam no diretório <em>/f/</em>.</li>
<li>Como os ambientes de desenvolvimento e produção são sensivelmente diferentes, optei por manter dois arquivos de configurações separados: conf.php e conf-online.php. A aplicação faz referência ao conf.php e durante a publicação, o Capistrano se encarrega de <em>apagar</em> o arquivo de desenvolvimento e faz um link simbólico para o arquivo de produção.</li>
<li>Essa receita resolve O MEU PROBLEMA. Espero que possa ser útil para você.</li>
</ol>
<p>Se ficou interessado em usar o Capistrano para publicar a sua aplicação, sugiro fortemente que <a href="http://www.capify.org/index.php/Documentation">leia a documentação</a> para maiores detalhes.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano+-+http://tr.im/xrwc+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/&amp;t=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/&amp;title=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/&amp;title=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/&amp;title=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano&amp;summary=Os%20que%20me%20conhecem%20sabe%20quanto%20o%20Rails%20Summit%202008%20mudou%20a%20minha%20vida%20profissionalmente.%20Eu%20j%C3%A1%20sabia%20que%20as%20coisas%20haviam%20evolu%C3%ADdo%20mas%20sinceramente%20nunca%20tinha%20dado%20muita%20bola%2C%20pois%20os%20meus%20processos%20sempre%20funcionaram%20bem.%20L%C3%A1%20eu%20pude%20ver%20que%20muita%20coisa%20legal%20estava%20sendo%20feita%20e%20eu%20que%20n%C3%A3o%20pod&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/&amp;title=Deployment+automatizado+de+aplica%C3%A7%C3%A3o+PHP+com+Capistrano" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/08/deployment-automatizado-de-aplicacao-php-com-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Filezilla sem senha usando SFTP + ssh-key</title>
		<link>http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/</link>
		<comments>http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 23:43:15 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[filezilla]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ssh-key]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=123</guid>
		<description><![CDATA[Ok, eu sei que usar cliente de FTP é coisa do passado, mas quem não tem um projeto sem o deployment  automatizado que atire a primeira pedra.
Na versão 3.0.8 do Filezilla foi adicionado o suporte a chaves públicas nas conexões por SFTP. Com isso, podemos aproveitar a mesma chave que usamos para conectar sem [...]]]></description>
			<content:encoded><![CDATA[<p><em>Ok, eu sei que usar cliente de FTP é coisa do passado, mas quem não tem um projeto sem o deployment  automatizado que atire a primeira pedra.</em></p>
<p><img class="size-full wp-image-129 alignright" title="Filezilla" src="http://ricardoduarte.com/log/wp-content/uploads/2009/08/filezilla.png" alt="Filezilla" width="48" height="48" />Na versão <em>3.0.8</em> do <strong>Filezilla</strong> foi adicionado o suporte a chaves públicas nas conexões por SFTP. Com isso, podemos aproveitar a mesma chave que usamos para <strong>conectar sem senha</strong> por ssh para autenticar no cliente de FTP.</p>
<h2>Instalando a nova versão</h2>
<ol>
<li>Baixe a versão atualizada do <a href="https://www.ohloh.net/p/filezilla/download?filename=FileZilla_3.2.7.1_i586-linux-gnu.tar.bz2">Filezilla: 3.2.7.1</a>.</li>
<li>Descompacte o arquivo em <strong>/opt/</strong>:
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>opt <span style="color: #660033;">-xvjf</span> FileZilla_3.2.7.1_i586-linux-gnu.tar.bz2</div></div>
</li>
<li>Crie um link simbólico:
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>FileZilla3<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>filezilla <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>filezilla</div></div>
</li>
</ol>
<h2>Convertendo sua chave privada para o <strong>formato .ppk</strong>:</h2>
<ol>
<li>Já com o Filezilla aberto, acesse <strong>Editar</strong> -&gt; <strong>Configurações</strong></li>
<li>No menu interno, selecione <strong>Conexão</strong> -&gt; <strong>SFTP</strong></li>
<li>Clique no botão <strong>Adicionar keyfile</strong></li>
<li>Localize e selecione sua chave privada (Provavelmente ela deve estar em <em>~/.ssh/id_rsa</em>)</li>
<li>O Filezilla irá informar que a chave não está num formato suportado e se oferecerá para converte-la. Responda <strong>Sim</strong>.<img class="aligncenter size-full wp-image-128" style="margin-top: 10px; margin-bottom: 10px;" title="Filezilla - Converter chave-privada para ppk" src="http://ricardoduarte.com/log/wp-content/uploads/2009/08/Captura_de_tela-Converter-o-keyfile.png" alt="Filezilla - Converter chave-privada para ppk" width="370" height="130" /></li>
<li>Escolha o local para salvar a chave convertida para o formato do Putty. Sugiro manter no mesmo diretório <em>~/.ssh/</em></li>
<li>Pronto. Nos hosts que sua chave for autorizada, o Filezilla não pedirá mais senha nas conexões por SFTP.</li>
</ol>
<h2>Criando uma conexão:</h2>
<ol>
<li>Acesse <strong>Arquivo</strong> -&gt; <strong>Gerenciador de sites</strong></li>
<li>Clique em <strong>Novo site</strong></li>
<li>Preencha apenas os campos:
<ol>
<li><strong>Host</strong>: dominio.com</li>
<li><strong>Tipo de servidor</strong>: SFTP &#8211; SSH File Transfer Protocol</li>
<li><strong>Tipo de login</strong>: Normal</li>
<li><strong>Usuário</strong>: seulogin</li>
</ol>
</li>
</ol>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-132" title="Filezilla-Conexao" src="http://ricardoduarte.com/log/wp-content/uploads/2009/08/Filezilla-Conexao.png" alt="Filezilla-Conexao" width="518" height="378" /></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key+-+http://tr.im/xdbU+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/&amp;t=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/&amp;title=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/&amp;title=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/&amp;title=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key&amp;summary=Ok%2C%20eu%20sei%20que%20usar%20cliente%20de%20FTP%20%C3%A9%20coisa%20do%20passado%2C%20mas%20quem%20n%C3%A3o%20tem%20um%20projeto%20sem%20o%20deployment%20%20automatizado%20que%20atire%20a%20primeira%20pedra.%0D%0A%0D%0ANa%20vers%C3%A3o%203.0.8%20do%20Filezilla%20foi%20adicionado%20o%20suporte%20a%20chaves%20p%C3%BAblicas%20nas%20conex%C3%B5es%20por%20SFTP.%20Com%20isso%2C%20podemos%20aproveitar%20a%20mesma%20chave%20que%20usamos%20p&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/&amp;title=Filezilla+sem+senha+usando+SFTP+%2B+ssh-key" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/08/filezilla-sem-senha-usando-sftp-ssh-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails plugin: asset_packager</title>
		<link>http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/</link>
		<comments>http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 03:36:21 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[asset_packager]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=113</guid>
		<description><![CDATA[Comentei há alguns dias atrás no Twitter sobre um plugin para Rails que instalei na aplicação que desenvolvemos na Tecmedia: o asset_packager.
O objetivo deste plugin é reduzir o número de requisições e o tamanho dos assets(arquivos javascript e css) em aplicações Rails. Como a maioria das soluções, é quase mágico:
Instalando e configurando
script/plugin install git://github.com/sbecker/asset_packager.git
Gere o [...]]]></description>
			<content:encoded><![CDATA[<p>Comentei <a href="http://twitter.com/rduarte/status/2738149149">há alguns dias</a> atrás no <a href="http://twitter.com/rduarte/">Twitter</a> sobre um plugin para Rails que instalei na aplicação que desenvolvemos na <a href="http://www.tecmedia.com.br/">Tecmedia</a>: o <a href="http://github.com/sbecker/asset_packager"><strong>asset_packager</strong></a>.</p>
<p>O objetivo deste plugin é <strong>reduzir o número de requisições</strong> e o <strong>tamanho dos assets</strong>(arquivos javascript e css) em aplicações Rails. Como a maioria das soluções, é quase mágico:</p>
<h3>Instalando e configurando</h3>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">script<span style="color: #000000; font-weight: bold;">/</span>plugin <span style="color: #c20cb9; font-weight: bold;">install</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>sbecker<span style="color: #000000; font-weight: bold;">/</span>asset_packager.git</div></div>
<p>Gere o arquivo .yml com os assets a serem unificados e comprimidos:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rake asset:packager:create_yml</div></div>
<p>Ele irá gerar uma estrutura semelhante a essa no arquivo <strong>config/asset_packages.yml</strong>, já com os assets que estão configurados no seu projeto:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">---</span><br />
javascripts:<br />
<span style="color:#006600; font-weight:bold;">-</span> base:<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> prototype<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> effects<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> controls<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> dragdrop<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> application<br />
stylesheets:<br />
<span style="color:#006600; font-weight:bold;">-</span> base:<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> screen<br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> header</div></div>
<p>E no seu layout, basta remover as chamadas antigas e colocar apenas:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&lt;%</span>= stylesheet_link_merged <span style="color:#ff3333; font-weight:bold;">:base</span> <span style="color:#006600; font-weight:bold;">%&gt;</span><br />
<span style="color:#006600; font-weight:bold;">&lt;%</span>= javascript_include_merged <span style="color:#ff3333; font-weight:bold;">:base</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></div></div>
<p>Ele ainda tem a <em>sacada</em> de chamar os assets unificados somente em produção, evitando problemas de cache durante o desenvolvimento.</p>
<h3>Resultado</h3>
<p>Na nossa aplicação, a redução em número de requisições foi de <strong>22</strong> para <strong>12</strong>. Já em tamanho, a redução foi de <strong>80kb</strong>.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Rails+plugin%3A+asset_packager+-+http://tr.im/vOpY+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/&amp;t=Rails+plugin%3A+asset_packager" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/&amp;title=Rails+plugin%3A+asset_packager" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/&amp;title=Rails+plugin%3A+asset_packager" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/&amp;title=Rails+plugin%3A+asset_packager&amp;summary=Comentei%20h%C3%A1%20alguns%20dias%20atr%C3%A1s%20no%20Twitter%20sobre%20um%20plugin%20para%20Rails%20que%20instalei%20na%20aplica%C3%A7%C3%A3o%20que%20desenvolvemos%20na%20Tecmedia%3A%20o%20asset_packager.%0D%0A%0D%0AO%20objetivo%20deste%20plugin%20%C3%A9%20reduzir%20o%20n%C3%BAmero%20de%20requisi%C3%A7%C3%B5es%20e%20o%20tamanho%20dos%20assets%28arquivos%20javascript%20e%20css%29%20em%20aplica%C3%A7%C3%B5es%20Rails.%20Como%20a%20maioria%20&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/&amp;title=Rails+plugin%3A+asset_packager" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/07/rails-plugin-asset_packager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails delegate</title>
		<link>http://ricardoduarte.com/log/2009/07/rails-delegate/</link>
		<comments>http://ricardoduarte.com/log/2009/07/rails-delegate/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 12:15:06 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[delegate]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=104</guid>
		<description><![CDATA[Uma funcionalidade interessante do Rails que descobri através do RubyFlow foi o delegate.
No exemplo simples abaixo, mostra como mapear atributos de um model em outro.
# app/models/customer.rb
class Customer &#60; ActiveRecord::Base
&#160; &#160; has_one :user
&#160; &#160; delegate :login, :login=, :password, :password=, :to =&#62; :user
end
# app/models/user.rb
class User &#60; ActiveRecord::Base
&#160; belongs_to :customer
end
E o que isso faz? Olhe abaixo:
&#62;&#62; c = [...]]]></description>
			<content:encoded><![CDATA[<p>Uma funcionalidade interessante do Rails que descobri através do <a href="http://www.rubyflow.com/items/2510">RubyFlow</a> foi o <em>delegate</em>.</p>
<p>No exemplo simples abaixo, mostra como mapear atributos de um model em outro.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># app/models/customer.rb</span><br />
<span style="color:#9966CC; font-weight:bold;">class</span> Customer <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; &nbsp; has_one <span style="color:#ff3333; font-weight:bold;">:user</span><br />
&nbsp; &nbsp; delegate <span style="color:#ff3333; font-weight:bold;">:login</span>, <span style="color:#ff3333; font-weight:bold;">:login</span>=, <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#ff3333; font-weight:bold;">:password</span>=, <span style="color:#ff3333; font-weight:bold;">:to</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:user</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># app/models/user.rb</span><br />
<span style="color:#9966CC; font-weight:bold;">class</span> User <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:customer</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>E o que isso faz? Olhe abaixo:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> c = Customer.<span style="color:#9900CC;">last</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#008000; font-style:italic;">#&lt;Customer id: 1, name: &quot;Ricardo&quot;, created_at: &quot;2009-07-19 00:50:01&quot;, updated_at: &quot;2009-07-19 00:50:01&quot;&gt;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> c.<span style="color:#9900CC;">user</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#008000; font-style:italic;">#&lt;User id: 1, login: &quot;ricardo&quot;, password: &quot;123456&quot;, customer_id: 1, created_at: &quot;2009-07-19 00:50:36&quot;, updated_at: &quot;2009-07-19 00:50:53&quot;&gt;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> c.<span style="color:#9900CC;">login</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;ricardo&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&gt;&gt;</span> c.<span style="color:#9900CC;">password</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;123456&quot;</span></div></div>
<p>Os atributos que foram declarados com <em>delegate</em> passam a responder como atributos do model <em>Customer</em>.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Rails+delegate+-+http://tr.im/vOq1+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/07/rails-delegate/&amp;t=Rails+delegate" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/07/rails-delegate/&amp;title=Rails+delegate" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/07/rails-delegate/&amp;title=Rails+delegate" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/07/rails-delegate/&amp;title=Rails+delegate&amp;summary=Uma%20funcionalidade%20interessante%20do%20Rails%20que%20descobri%20atrav%C3%A9s%20do%20RubyFlow%20foi%20o%20delegate.%0D%0A%0D%0ANo%20exemplo%20simples%20abaixo%2C%20mostra%20como%20mapear%20atributos%20de%20um%20model%20em%20outro.%0D%0A%0D%0A%5Bcc%20lang%3D%27ruby%27%5D%0D%0A%23%20app%2Fmodels%2Fcustomer.rb%0D%0Aclass%20Customer%20%3C%20ActiveRecord%3A%3ABase%0D%0A%20%20%20%20has_one%20%3Auser%0D%0A%20%20%20%20delegate%20%3Alogin%2C%20%3Alog&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/07/rails-delegate/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/07/rails-delegate/&amp;title=Rails+delegate" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/07/rails-delegate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH: Economizando teclado</title>
		<link>http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/</link>
		<comments>http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 23:47:07 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=76</guid>
		<description><![CDATA[Sempre tive a necessidade de conectar em diversos servidores, todos com usuários e senhas diferentes. Cheguei até a ter um arquivo criptografado no Desktop com todos os usuários e senhas mais usados. Bobagem a minha.
Dica 1: Acessar servidor SSH sem senha
Criando o diretório .ssh no servidor
ricardo@local:~$ ssh user@host
user@host:~$ cd ~/
user@host:~$ mkdir .ssh
user@host:~$ chmod 700 .ssh/
Você [...]]]></description>
			<content:encoded><![CDATA[<p>Sempre tive a necessidade de conectar em diversos servidores, todos com usuários e senhas diferentes. Cheguei até a ter um arquivo criptografado no Desktop com todos os usuários e senhas mais usados. Bobagem a minha.</p>
<h2>Dica 1: Acessar servidor SSH sem senha</h2>
<p>Criando o diretório .ssh no servidor</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>host<br />
user<span style="color: #000000; font-weight: bold;">@</span>host:~$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span><br />
user<span style="color: #000000; font-weight: bold;">@</span>host:~$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> .ssh<br />
user<span style="color: #000000; font-weight: bold;">@</span>host:~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> .ssh<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>Você já tem uma chave &#8216;rsa&#8217;? Então crie uma:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> rsa<br />
<span style="color: #666666; font-style: italic;"># Generating public/private rsa key pair.</span><br />
<span style="color: #666666; font-style: italic;"># Enter file in which to save the key (/home/ricardo/.ssh/id_rsa): [ENTER]</span><br />
<span style="color: #666666; font-style: italic;"># Enter passphrase (empty for no passphrase): [ENTER]</span><br />
<span style="color: #666666; font-style: italic;"># Enter same passphrase again: [ENTER]</span></div></div>
<p>Agora basta enviar sua chave pública (id_rsa.pub) para o servidor:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">scp</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub user<span style="color: #000000; font-weight: bold;">@</span>host:~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys<br />
ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>host<br />
user<span style="color: #000000; font-weight: bold;">@</span>host:~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> .ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</div></div>
<p>E pronto! Quando você acessar novamente a sua conta por SSH, ele não pedirá mais senha.</p>
<h2>Dica 2: Apelidos para os user@host</h2>
<p>Algumas pessoas perdem a noção e criam domínios gigantescos, aliados com políticas de criação de login dos provedores, está formado o inferno na hora de conectar um servidor.</p>
<p>Crie/edite o arquivo &#8216;~/.ssh/config&#8217; com o seguinte conteúdo</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">host site1<br />
&nbsp; user username_gigante<br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">hostname</span> sub.dominiosemnocao.com.br<br />
<br />
host site2<br />
&nbsp; user username_maior_ainda<br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">hostname</span> sistemax.empresay.com.br</div></div>
<p>Observem a diferença para conectar:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># Antes</span><br />
ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> username_gigante<span style="color: #000000; font-weight: bold;">@</span>sub.dominiosemnocao.com.br<br />
<br />
<span style="color: #666666; font-style: italic;"># Depois</span><br />
ricardo<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">local</span>:~$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> site1</div></div>
<p>Bem melhor né?</p>
<p><em>Fontes:</em><br />
Dica 1: <a href="http://wiki.locaweb.com.br/pt-br/Usando_GIT_na_Hospedagem_Linux" target="_blank">http://wiki.locaweb.com.br/pt-br/Usando_GIT_na_Hospedagem_Linux</a><br />
Dica 2: <a href="http://logbr.reflectivesurface.com/2009/06/04/reduzindo-nomes-no-git-e-ssh/" target="_blank">http://logbr.reflectivesurface.com/2009/06/04/reduzindo-nomes-no-git-e-ssh/</a></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=SSH%3A+Economizando+teclado+-+http://tr.im/vOq3+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/&amp;t=SSH%3A+Economizando+teclado" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/&amp;title=SSH%3A+Economizando+teclado" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/&amp;title=SSH%3A+Economizando+teclado" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/&amp;title=SSH%3A+Economizando+teclado&amp;summary=Sempre%20tive%20a%20necessidade%20de%20conectar%20em%20diversos%20servidores%2C%20todos%20com%20usu%C3%A1rios%20e%20senhas%20diferentes.%20Cheguei%20at%C3%A9%20a%20ter%20um%20arquivo%20criptografado%20no%20Desktop%20com%20todos%20os%20usu%C3%A1rios%20e%20senhas%20mais%20usados.%20Bobagem%20a%20minha.%0D%0A%0D%0ADica%201%3A%20Acessar%20servidor%20SSH%20sem%20senha%0D%0ACriando%20o%20diret%C3%B3rio%20.ssh%20no%20servidor&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/&amp;title=SSH%3A+Economizando+teclado" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/07/ssh-economizando-teclado/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nokia E71: Meu top 10 apps</title>
		<link>http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/</link>
		<comments>http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 01:37:04 +0000</pubDate>
		<dc:creator>Ricardo</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[e-series]]></category>
		<category><![CDATA[e71]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://ricardoduarte.com/log/?p=70</guid>
		<description><![CDATA[No final do ano passado comprei o meu primeiro(e único até agora) smartphone: Nokia E71. Aparelho fantástico, não tenho do que reclamar (Ok, a camera não é fantástica).

Depois de testar muitos aplicativos, compilei minha lista de favoritos:

Nokia Browser(nativo): Roda sem problemas a maioria dos sites, com suporte a Flash e leitor de RSS embutido.
Nokia Podcasting [...]]]></description>
			<content:encoded><![CDATA[<p>No final do ano passado comprei o meu primeiro(e único até agora) smartphone: <strong>Nokia E71</strong>. Aparelho fantástico, não tenho do que reclamar (Ok, a camera não é fantástica).</p>
<p><img class="aligncenter size-full wp-image-73" title="nokia-e71" src="http://ricardoduarte.com/log/wp-content/uploads/2009/07/nokia-e71.jpg" alt="nokia-e71" width="410" height="495" /></p>
<p>Depois de testar muitos aplicativos, compilei minha lista de favoritos:</p>
<ol>
<li><strong>Nokia Browser(nativo)</strong>: Roda sem problemas a maioria dos sites, com suporte a Flash e leitor de RSS embutido.</li>
<li><strong><a href="http://nokia.com/podcasting" target="_blank">Nokia Podcasting</a><strong> (nativo)</strong></strong>: Apesar de não ouvir muitos podcasts, esse app supre a necessidade básica de baixar os feeds e já é integrado com a biblioteca do smartphone. <em>[Dica: Assine o <a href="http://feeds2.feedburner.com/PretinhoBasico" target="_blank">podcast do Pretinho Básico da Atlantida</a>]</em></li>
<li><strong><a href="http://mobileways.de/gravity" target="_blank">Gravity</a> (pago): </strong>Ótimo cliente para rede do Twitter e Laconica. Valeu o investimento.</li>
<li><strong><a href="http://www.palringo.com/" target="_blank">Palringo</a> (gratuito):</strong> Cliente de IM(Google Talk, MSN, ICQ, etc.)</li>
<li><strong><a href="http://www.google.com/mobile/products/maps.html#p=nokia_smart" target="_blank">Google Maps</a> (gratuito):</strong> Integrado com o GPS, supre a necessidade básica de localização de endereços. Se você precisa de ajuda inclusive no transito, esse NÃO é o app ideal.</li>
<li><strong><a href="http://blogen.junnikokuki.com/2009/01/freetimebox-v105-released-symbian-signed-version/" target="_blank">FreeTimeBox</a> (gratuito):</strong> Além de sincronizar o horário do celular com servidores NTP, ele tem a opção de adicionar a hora de forma persistente, sendo que ela sempre fique visivel. Ótimo para quem custuma perder a hora.</li>
<li><strong><a href="http://www.killermobile.com/newsite/content/view/40/82/" target="_blank">TotalRecall </a>(pago):</strong> Grava todas as ligações do celular, sem que a outra pessoa saiba. Ótimo para paranoicos e para quem não gosta de ficar anotando recados e/ou informações importantes durante as ligações.</li>
<li><strong><a href="http://email.nokia.com/" target="_blank">Nokia Email</a> (gratuito):</strong> Leitor de email push, com suporte HTML e múltiplas contas.</li>
<li><strong><a href="http://www.businesssoftware.nokia.com/mail_for_exchange_downloads.php" target="_blank">Nokia Mail for Exchange</a> (gratuito):</strong> Aplicativo que sincroniza com servidor Microsoft Exchange. Uso somente para sincronizar Contatos, Tarefas e Calendário.</li>
<li><strong><a href="http://themes.tehkseven.net/featured-articles/prestige-solace/" target="_blank">Tema Prestige(Solace)</a>: </strong>Não gosto de temas muito coloridos e que atrapalhem a leitura da tela inicial do celular. Esse tema é discreto e tem um pacote de ícones bem agradável.</li>
</ol>
<p>Espero que seja útil.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center sexy-bookmarks-bg-sexy">
<ul class="socials">
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Nokia+E71%3A+Meu+top+10+apps+-+http://tr.im/vOq4+(via+@rduarte)" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/&amp;t=Nokia+E71%3A+Meu+top+10+apps" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/&amp;title=Nokia+E71%3A+Meu+top+10+apps" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/&amp;title=Nokia+E71%3A+Meu+top+10+apps" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/&amp;title=Nokia+E71%3A+Meu+top+10+apps&amp;summary=No%20final%20do%20ano%20passado%20comprei%20o%20meu%20primeiro%28e%20%C3%BAnico%20at%C3%A9%20agora%29%20smartphone%3A%20Nokia%20E71.%20Aparelho%20fant%C3%A1stico%2C%20n%C3%A3o%20tenho%20do%20que%20reclamar%20%28Ok%2C%20a%20camera%20n%C3%A3o%20%C3%A9%20fant%C3%A1stica%29.%0D%0A%0D%0A%0D%0A%0D%0ADepois%20de%20testar%20muitos%20aplicativos%2C%20compilei%20minha%20lista%20de%20favoritos%3A%0D%0A%0D%0A%09Nokia%20Browser%28nativo%29%3A%20Roda%20sem%20problemas&amp;source=ricardo duarte" rel="nofollow" class="external" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/&amp;title=Nokia+E71%3A+Meu+top+10+apps" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://ricardoduarte.com/log/2009/07/nokia-e71-meu-top-10-apps/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
