<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Blog do Tino Gomes</title>
 <link href="https://blog.tinogomes.com" rel="self"/>
 <link href="https://blog.tinogomes.com"/>
 <updated>2025-12-07T01:23:45+00:00</updated>
 <id>https://blog.tinogomes.com</id>
 <author>
   <name>Celetino Ferreira Gomes</name>
   <email>contato@tinogomes.com</email>
 </author>

 
 <entry>
   <title>[SHELL] movendo a última linha de um arquivo para o topo</title>
   <link href="https://blog.tinogomes.com/2024/01/26/shell-movendo-a-ultima-linha-de-um-arquivo-para-o-topo"/>
   <updated>2024-01-26T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2024/01/26/shell-movendo-a-ultima-linha-de-um-arquivo-para-o-topo</id>
   <content type="html">
&lt;p&gt;Mais um post para funcionar de memória e não mais ficar buscando como fazer para mover a última linha de um arquivo para o topo.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt; 
 &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1h;1d;$!H;$!d;G&apos;&lt;/span&gt; file
 &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Referências:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.unix.com/shell-programming-and-scripting/128416-use-sed-move-last-line-top.html&quot;&gt;Use sed to move last line to top&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Metaprogramação em Ruby - Criando métodos de Classe</title>
   <link href="https://blog.tinogomes.com/2020/02/15/metaprogramacao-em-ruby-criando-metodos-de-classe"/>
   <updated>2020-02-15T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2020/02/15/metaprogramacao-em-ruby-criando-metodos-de-classe</id>
   <content type="html">
&lt;p&gt;Nem falo nada sobre quanto tempo sem escrever nada, mas vou contar uma novidade rapidinha: Agora &lt;a href=&quot;https://www.gaveteiro.com.br&quot;&gt;Gaveteiro&lt;/a&gt; virou &lt;a href=&quot;https://www.nei.com.br&quot;&gt;NEI&lt;/a&gt;. Mas vamos ao que interessa nesse post.&lt;/p&gt;

&lt;p&gt;Métodos de Classe? Bom, sabemos que isso não existe em Ruby. Na verdade são métodos &lt;em&gt;singleton&lt;/em&gt; da classe, mas enfim, vamos abistrair essa parte.&lt;/p&gt;

&lt;p&gt;Bom, então, digamos que você vai mapear um recurso de uma API e ela tem um campo/atributo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;type&lt;/code&gt;, e essa pode retornar os valores &lt;em&gt;ClientA.administrador&lt;/em&gt;, &lt;em&gt;ClientA.manager&lt;/em&gt; e &lt;em&gt;ClientA.buyer&lt;/em&gt; como valores para este atributo. Mas você quer ter um código mais limpo, algo que você possa perguntar ao seu objeto: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource.admin?&lt;/code&gt; em vez de ficar espalhado pelo seu código algo como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;resource.type == &quot;ClientA.administrador&quot;&lt;/code&gt; e etc. E o mesmo para criar uma instância desse objeto, teria que fazer algo como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Resource.new(type: &apos;ClientA.administrador&apos;)&lt;/code&gt;. Não seria melhor ter algo como &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Resource.new_admin(...)&lt;/code&gt;?. Nesse caso, vou apresentar dois métodos para criar dinamicamente métodos. o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;define_method&lt;/code&gt; serve para criar os métodos de instância e o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;define_singleton_method&lt;/code&gt; para criar os “métodos de classe”.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Resource&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenStruct&lt;/span&gt;
  &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveModel&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Validations&lt;/span&gt;

  &lt;span class=&quot;no&quot;&gt;TYPES&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;admin&quot;&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ClientA.administrator&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;manager&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ClientA.manager&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;buyer&quot;&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ClientA.buyer&quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;freeze&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;validates&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:api_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;presence: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;validates&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;inclusion: &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TYPES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;values&lt;/span&gt;

  &lt;span class=&quot;no&quot;&gt;TYPES&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# define &quot;question&quot; methods for each type (e.g.: def admin?; type == &quot;ClientA.administrador&quot;; end)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;define_method&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;?&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# define constructors for each type (e.g.: Resource.new_admin({...}))&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;define_singleton_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;new_&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_sym&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;merge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;type: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Então agora, é só usar&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new_admin&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;type&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns &quot;ClientA.administrator&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;admin?&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;buyer?&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns false&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new_buyer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;name: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Tino&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;type&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns &quot;ClientA.buyer&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;admin?&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns false&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;buyer?&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;resource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; it returns &quot;Tino&quot; - YOU DON&apos;T SAY?&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;O que achou?&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;PS1: Claro que ainda estamos limitados a conhecer todos os valores que virão no atributo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;type&lt;/code&gt;. Se quisermos que seja 100% dinâmico… (Será que rola outro post?)&lt;/p&gt;

  &lt;p&gt;PS2: Deu para perceber que desde o último post, estou fazendo integrações com APIs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Referências:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/3487403/how-to-dynamically-define-a-class-method-which-will-refer-to-a-local-variable-ou&quot;&gt;Stackoverflow - How to dynamically define a class method which will refer to a local variable outside?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/rubyinside/class-methods-in-ruby-a-thorough-review-and-why-i-define-them-using-class-self-af677ede9596&quot;&gt;Medium Ruby Inside &amp;lt;3 - Class Methods Are Singleton Methods&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Converter JSON para um Objeto Ruby</title>
   <link href="https://blog.tinogomes.com/2019/10/19/converter-json-para-um-objeto-ruby"/>
   <updated>2019-10-19T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2019/10/19/converter-json-para-um-objeto-ruby</id>
   <content type="html">
&lt;p&gt;Quem nunca quis validar um JSON usando as validações do ActiveModel do Rails? Mas transformar um JSON multinível em um objeto Ruby parece ser um passo chato de realizar, né? Bom, hoje eu descobri que não.&lt;/p&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;strong&gt;Exemplo de um JSON bem simples&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;id&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;740b3e24-8686-48b6-9eb0-1b09d04bf18e&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Carl Johnson&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;document&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;12345&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;addresses&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;street&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;414, East 137th Street&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;neiborhood&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Compton&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;city&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Los Angeles&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;state&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;CA&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;zipcode&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;90061&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;strong&gt;Importando o JSON para uma classe&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AccountFromJson&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenStruct&lt;/span&gt;
  &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveModel&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Validations&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;validates&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;presence: &lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;


&lt;span class=&quot;n&quot;&gt;json&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;./any/path/file.json&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;object_class: &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;AccountFromJson&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;valid?&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; &quot;Carl Johnson&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;addresses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;street&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; &quot;414, East 137th Street&quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ah, e Também funciona se no JSON for um array.&lt;/p&gt;

&lt;p&gt;Pois é, quem diz que macaco velho não aprende “novos” truques?&lt;/p&gt;

&lt;p&gt;Referências:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://coderwall.com/p/74rajw/convert-a-complex-nested-hash-to-an-object&quot;&gt;Convert a complex nested hash to an object&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/@somethvictory/converting-json-to-an-object-in-ruby-e64e6acf8a3b&quot;&gt;Converting JSON to an Object in Ruby&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Mais DRY no seu YAML</title>
   <link href="https://blog.tinogomes.com/2019/03/01/mais-dry-no-seu-yaml"/>
   <updated>2019-03-01T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2019/03/01/mais-dry-no-seu-yaml</id>
   <content type="html">
&lt;p&gt;Olha quem está vivo? Sim, sou eu. Sem mais enrolação.&lt;/p&gt;

&lt;p&gt;Como já publicado no post do &lt;a href=&quot;/2008/03/23/dry-configdatabaseyml&quot;&gt;DRY config/database.yml&lt;/a&gt;, é possível usar &lt;em&gt;aliases&lt;/em&gt; para evitar duplicidade de valores, mas como fazer isso para chaves simples? E porque eu tive essa necessidade?&lt;/p&gt;

&lt;p&gt;Em uma &lt;em&gt;view&lt;/em&gt; onde eu preciso exibir uma mensagem de disponibilidade de expedição de um produto, tenho algo como:&lt;/p&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;strong&gt;app/views/products/show.html&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-erb&quot; data-lang=&quot;erb&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;...
&lt;span class=&quot;nt&quot;&gt;&amp;lt;dl&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;dt&amp;gt;&lt;/span&gt;Prazo para expição&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dt&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;dd&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;%=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;I18n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;.delivery_days&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;count: &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;delivery_days&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;cp&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dd&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/dl&amp;gt;&lt;/span&gt;
...
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;strong&gt;config/locales/pt-BR.yml&lt;/strong&gt; com repetição&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;na&quot;&gt;pt-BR&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;products&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;delivery_days&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Pronta Entrega&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Disponível em %{count} dias úteis&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;zero&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Pronta Entrega&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Considerando que eu tenha que mostrar a mensagem quando da disponibilidade de entrega é de zero ou um dia, mas não quero duplicar a mensagem. O que podemos fazer?&lt;/p&gt;

&lt;p&gt;Antes da chave que nós queremos “copiar”, criamos o &lt;em&gt;alias&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;alias_name&lt;/code&gt;, e no lugar do valor que vamos repetir, usamos o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*alias_name&lt;/code&gt;&lt;/p&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;strong&gt;config/locales/pt-BR.yml&lt;/strong&gt; sem repetição&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;na&quot;&gt;pt-BR&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;products&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;delivery_days&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;nl&quot;&gt;&amp;amp;oneDeliveryDay&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Pronta Entrega&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Disponível em %{count} dias úteis&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;zero&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;*oneDeliveryDay&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;No exemplo acima, nós identificamos a chave &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:one&lt;/code&gt; com o &lt;em&gt;alias&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;onDeliveryDay&lt;/code&gt; e aplicanos na chave &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:zero&lt;/code&gt;&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Usando Git Hook para fazer análise do código</title>
   <link href="https://blog.tinogomes.com/2016/12/29/usando-git-hook-para-fazer-analise-do-codigo"/>
   <updated>2016-12-29T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2016/12/29/usando-git-hook-para-fazer-analise-do-codigo</id>
   <content type="html">
&lt;p&gt;Senta que lá vem história.&lt;/p&gt;

&lt;p&gt;Atualmente temos algumas ferramentas online, como &lt;a href=&quot;https://codeclimate.com/&quot;&gt;Code Climate&lt;/a&gt; e &lt;a href=&quot;https://www.codacy.com/&quot;&gt;Codacy&lt;/a&gt;, para fazer análise do código do nosso projeto, em busca de falhas de segurança, duplicação de código e etc. Também estamos diante da possibilidade de levantar um servidor de &lt;a href=&quot;http://www.martinfowler.com/articles/continuousIntegration.html&quot;&gt;CI&lt;/a&gt;, como o &lt;a href=&quot;http://jenkins-ci.org/&quot;&gt;jenkins&lt;/a&gt;, e configurar para fazer o mesmo processo. Usando essas ferramentas, nossos códigos são avaliados somente após feito o commit e enviado (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git push&lt;/code&gt;) para o repositório “central”. No caso, havendo algum problema no resultado dos testes, podemos ser somos notificados por e-mail e, sendo isso parte do fluxo do CI, teoricamente, nossas últimas atualizações serão um bloqueio para continuar nosso trabalho em outra coisa.&lt;/p&gt;

&lt;p&gt;Eu tenho preferido passar essas ferramentas antes de fazer o commit, aproveitando que estou com a mente fresca com as minhas últimas atualizações, ficando mais fácil resolver o problema detectado por alguma dessas ferramentas.&lt;/p&gt;

&lt;p&gt;Com isso, resolver colocar o &lt;em&gt;git hook&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pre_commit&lt;/code&gt;. No caso em questão, estou em um projeto Ruby on Rails e nele estão configurados algumas ferramentas de análise de código, como &lt;a href=&quot;http://brakemanscanner.org/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;brakeman&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/bbatsov/rubocop&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rucobop&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://rails-bestpractices.com/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rails_best_practices&lt;/code&gt;&lt;/a&gt; e &lt;a href=&quot;https://github.com/whitesmith/rubycritic&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rubycritic&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Segue abaixo o hook pre-commit:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/tinogomes/4bd4344d72ccd133cb0dc5059ceaac24.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Outras referências:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://infinum.co/the-capsized-eight/top-8-tools-for-ruby-on-rails-code-optimization-and-cleanup&quot;&gt;https://infinum.co/the-capsized-eight/top-8-tools-for-ruby-on-rails-code-optimization-and-cleanup&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>[Dicas] Bash - Aprendendo a usar XARGS de uma vez por todas</title>
   <link href="https://blog.tinogomes.com/2016/10/20/dicas-bash-aprendendo-a-usar-xargs-de-uma-vez-por-todas"/>
   <updated>2016-10-20T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2016/10/20/dicas-bash-aprendendo-a-usar-xargs-de-uma-vez-por-todas</id>
   <content type="html">
&lt;p&gt;Depois da milésia vez &lt;a href=&quot;http://bfy.tw/4YJ5&quot;&gt;buscando por como usar o &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xargs&lt;/code&gt;&lt;/a&gt; resolvi escrever esse post para não precisar mais.&lt;/p&gt;

&lt;p&gt;O comando &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xargs&lt;/code&gt; é utilizado para, dado uma lista de argumentos, executar um comando passando essa lista como argumento(s) desse comando. Então, você pode juntar todos os itens da lista para serem passados como argumentos de um comando, ou para que se execute um comando por item da lista. Por padrão, cada termo separado por espaço é considerado um item de lista e toda a lista é passada como argumentos para o comando.&lt;/p&gt;

&lt;p&gt;Sintaxe com os parâmetros que mais eu uso:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;command-list | xargs &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt; | &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; NUM] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-I&lt;/span&gt; NAME] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;command-exec &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;args]]&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Argumentos&lt;/th&gt;
      &lt;th&gt;Descrição&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command-list&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Qualquer comando que gere uma lista. Pode ser &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find&lt;/code&gt; e etc…&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-0&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Muda o separador padrão para o caracter nulo. Muito útil quando os itens da lista possuem espaço.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-n NUM&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Pega NUM itens da lista para executar o comando.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-I NAME&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Dá um nome para o(s) item(ns) a ser passado para o comando.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-p&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Exibe o comando com os argumentos que serão executados e pede confirmação para executar o comando.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command-exec [args]&lt;/code&gt;&lt;/td&gt;
      &lt;td&gt;Comando a ser executado com os argumentos lidos pelo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xargs&lt;/code&gt;. Por padrão, é usado um &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Exemplos:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs
    1 item 2 item 3 item

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-0&lt;/span&gt;
    item 1
    item 2
    item 3

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 1
    1
    item
    2
    item
    3
    item

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 2
    item 1
    item 2
    item 3

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; 3
    1 item 2
    item 3 item

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;
    /bin/echo 1 item 2 item 3 item?...

    &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos; item\n&apos;&lt;/span&gt; 3 | xargs &lt;span class=&quot;nt&quot;&gt;-INUM&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;NUM arg
    1 item arg
    2 item arg
    3 item arg&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Agora espero não mais buscar por isso.&lt;/p&gt;

&lt;p&gt;Segue algumas referências que usei:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.bosontreinamentos.com.br/linux/certificacao-lpic-1/comando-xargs-construir-e-executar-linhas-de-comando-no-linux/&quot;&gt;http://www.bosontreinamentos.com.br/linux/certificacao-lpic-1/comando-xargs-construir-e-executar-linhas-de-comando-no-linux/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.cyberciti.biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/&quot;&gt;http://www.cyberciti.biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.dicas-l.com.br/cantinhodoshell/cantinhodoshell_20070226.php#.WAi-BJMrIy5&quot;&gt;http://www.dicas-l.com.br/cantinhodoshell/cantinhodoshell_20070226.php#.WAi-BJMrIy5&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.vivaolinux.com.br/dica/Dupla-diabolica-find-e-xargs&quot;&gt;https://www.vivaolinux.com.br/dica/Dupla-diabolica-find-e-xargs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://udgwebdev.com/dicas-de-terminal-processamento-paralelo-com-xargs&quot;&gt;https://udgwebdev.com/dicas-de-terminal-processamento-paralelo-com-xargs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Novos desafios: Gaveteiro. Obrigado Hotel Urbano</title>
   <link href="https://blog.tinogomes.com/2015/04/30/novos-desafios-gaveteiro-obrigado-hotel-urbano"/>
   <updated>2015-04-30T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2015/04/30/novos-desafios-gaveteiro-obrigado-hotel-urbano</id>
   <content type="html">
&lt;p&gt;&lt;img src=&quot;/images/obrigado-hu.jpg&quot; alt=&quot;Obrigado HU&quot; title=&quot;Obrigado HU&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Hoje (30/abril/2015) foi meu último dia no &lt;a href=&quot;http://hotelurbano.com/&quot; title=&quot;Hotel Urbano&quot;&gt;Hotel Urbano (HU)&lt;/a&gt;. Muita coisa mudou em menos de um ano, onde era uma empresa que era 100% PHP e hoje trabalha com várias tecnologias, como PHP, Ruby, Python, NodeJS, Scala e Java. Tive o prazer de trabalhar em diversas equipes, com diversas pessoas, tudo gente boa, tanto no pessoal como no profissional. Um obrigado especial ao &lt;a href=&quot;http://twitter.com/bplsilva/&quot; title=&quot;Siga Bruno Pereire no Twitter&quot;&gt;Bruno&lt;/a&gt; que me convidou para me juntar ao HU a um ano atrás. Desejo todo sucesso a todos e ao HU (uhull - \o/)&lt;/p&gt;

&lt;p&gt;Um novo ciclo começa e com isso, um novo desafio. Estou me juntando ao time do &lt;a href=&quot;http://www.gaveteiro.com.br/&quot; title=&quot;Gaveteiro&quot;&gt;Gaveteiro&lt;/a&gt;, a convite do &lt;a href=&quot;http://twitter.com/lsdr/&quot; title=&quot;Siga Luiz Rocha no Twitter&quot;&gt;Luiz Rocha&lt;/a&gt;.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Criando gemset e arquivos de carregamento do RVM</title>
   <link href="https://blog.tinogomes.com/2015/03/23/criando-gemset-e-arquivos-de-carregamento-do-rvm"/>
   <updated>2015-03-23T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2015/03/23/criando-gemset-e-arquivos-de-carregamento-do-rvm</id>
   <content type="html">
&lt;p&gt;Essa é mais para ficar para lembrança do que uma dica, mas enfim, sempre que vou começar um novo projeto em &lt;a href=&quot;https://www.ruby-lang.org/en/&quot;&gt;Ruby&lt;/a&gt;, eu costumo a usar o &lt;a href=&quot;https://rvm.io/&quot;&gt;RVM&lt;/a&gt; (sim, ainda o RVM) e gosto de separar os projetos por &lt;a href=&quot;https://rvm.io/gemsets&quot;&gt;gemsets&lt;/a&gt; (sim, isso também ocupa mais espaço).&lt;/p&gt;

&lt;p&gt;Para criar um novo gemset, na versão do Ruby correta e os arquivos de carregamento automático, executo o comando abaixo:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rvm 2.2.1@project_name &lt;span class=&quot;nt&quot;&gt;--create&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--ruby-version&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pronto!&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>[Dicas] Bash - Usando Array e criando arquivos temporários</title>
   <link href="https://blog.tinogomes.com/2015/02/04/dicas-bash-array-e-arquivos-temporarios"/>
   <updated>2015-02-04T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2015/02/04/dicas-bash-array-e-arquivos-temporarios</id>
   <content type="html">
&lt;p&gt;As dicas abaixo foram extraídas do post &lt;a href=&quot;http://hacktux.com/bash/script/efficient&quot; title=&quot;10 tips for writing efficient Bash scripts&quot;&gt;10 tips for writing efficient Bash scripts&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;usar-array-em-lugar-de-múltiplas-variáveis&quot;&gt;Usar Array em lugar de múltiplas variáveis&lt;/h2&gt;

&lt;p&gt;Ao invés de criar muitas variáveis para valores em um mesmo contexto.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;color1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Red&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;color2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Green&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;color3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Blue&apos;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$color1&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$color2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Crie um array.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;$colors&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Red&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Green&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Blue&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[0]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;colors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[1]&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;criar-arquivosdiretórios-temporários&quot;&gt;Criar arquivos/diretórios temporários&lt;/h2&gt;

&lt;p&gt;Precisa de um arquivo temporário? Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mktemp&lt;/code&gt; para criar arquivos ou diretórios temporários.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nv&quot;&gt;tempfile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mktemp&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;tempdir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mktemp&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$tempfile&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$tempdir&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;PS: No FreeBSD (OSX), tem que passar um template para o nome do arquivo/diretório&lt;/strong&gt;&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Hotel Urbano aí vou eu</title>
   <link href="https://blog.tinogomes.com/2014/05/10/hotel-urbano-ai-vou-eu"/>
   <updated>2014-05-10T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2014/05/10/hotel-urbano-ai-vou-eu</id>
   <content type="html">
&lt;p&gt;Nesta minha última saga em busca de uma nova oportunidade, entre conversas em várias empresas, startups e amigos, minha decisão foi ingressar no &lt;a href=&quot;http://hotelurbano.com.br&quot;&gt;Hotel Urbano&lt;/a&gt;, a convite do &lt;a href=&quot;https://twitter.com/blpsilva&quot;&gt;Bruno&lt;/a&gt;, onde pessoalmente o grande desafio será a tecnologia, pois a linguagem base usada no HU é &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; e nos últimos 7 anos venho trabalhando com &lt;a href=&quot;https://www.ruby-lang.org/&quot;&gt;Ruby&lt;/a&gt; (ou &lt;a href=&quot;http://tinogom.es/raby-image&quot;&gt;rãby&lt;/a&gt;?). Também serão outros desafios que no momento não estou habilitado a compartilhar, mas esperamos a curto prazo compartilhamos o sucesso desses desafios.&lt;/p&gt;

&lt;p&gt;Então, este post é de agradecimento a todos que me indicaram, outros que se despuseram em me ouvir oferecendo uma oportunidade de me juntar a seus negócios e, principalmente, ao Bruno por efetivamente me aceitar a unir ao time do HU.&lt;/p&gt;

&lt;p&gt;PS: Espero não fazer &lt;a href=&quot;https://www.google.com.br/search?q=phuby+on+phails&quot;&gt;PHuby on PHails&lt;/a&gt; :P&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Criando branches no git muito mais rápido</title>
   <link href="https://blog.tinogomes.com/2014/03/21/dica-criando-branches-no-git"/>
   <updated>2014-03-21T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2014/03/21/dica-criando-branches-no-git</id>
   <content type="html">
&lt;p&gt;Cansei de criar git branches assim:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$ git checkout -b fix/some_bugfix_with_long_name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Agora é só:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$ fix-branch some bugfix with long name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Segue abaixo minhas novas funções bash:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;function fix-branch() {
    local new_branch_name=$(echo &quot;$*&quot; | tr &quot; &quot; _)
    git checkout -b fix/$new_branch_name
}

function feature-branch() {
    local new_branch_name=$(echo &quot;$*&quot; | tr &quot; &quot; _)
    git checkout -b feature/$new_branch_name
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Luto por Jim Weirich</title>
   <link href="https://blog.tinogomes.com/2014/02/20/luto-por-jim-weirich"/>
   <updated>2014-02-20T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2014/02/20/luto-por-jim-weirich</id>
   <content type="html">
&lt;p&gt;Mudei o tema do blog apenas por luto pelo falecimento de &lt;a href=&quot;http://twitter.com/jimweirich&quot;&gt;Jim Weirich&lt;/a&gt;, 
criador do &lt;a href=&quot;http://rake.rubyforge.org&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Rake&lt;/code&gt;&lt;/a&gt; e &lt;a href=&quot;http://github.com/jimweirich&quot;&gt;outras ferramentas&lt;/a&gt; incriveis para &lt;em&gt;Ruby&lt;/em&gt;.
Também rolou uma homenagem da comunidade no &lt;a href=&quot;https://github.com/jimweirich/wyriki/commit/d28fac7f18aeacb00d8ad3460a0a5a901617c2d4&quot;&gt;último commit do Jim&lt;/a&gt; no github.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/luto_jim_weirich.png&quot; alt=&quot;Tema de luto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Descanse em paz e força aos familiares!&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Busca em campos de texto passando valores numéricos no MySQL</title>
   <link href="https://blog.tinogomes.com/2013/12/23/busca-em-campos-de-texto-passando-valores-numericos-no-mysql"/>
   <updated>2013-12-23T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2013/12/23/busca-em-campos-de-texto-passando-valores-numericos-no-mysql</id>
   <content type="html">
&lt;blockquote&gt;
  &lt;p&gt;&lt;cite&gt;Como em toda casa de ferreiro, nem sempre o espero é de ferro.&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Em nosso dia a dia, as vezes precisamos fazer umas intervenções via console do Rails e, com isso, temos alguns métodos auxiliares para fazer tarefas simples, porém rotineiras.&lt;/p&gt;

&lt;p&gt;Entre essas rotinas, fazemos busca de uma conta através do e-mail de um usuário e então atualizamos a informação necessária. Como as vezes temos somente o e-mail do usuário, precisamos fazer uma busca do usuário pelo e-mail e, dado o usuário, obtemos a lista de contas e então, temos a conta para fazer o ajuste. Outras vezes já temos o ID da conta a ser ajustada, o que agiliza o processo. Para auxiliar essa busca, estava criando mais um método para encontrar a conta, dado o e-mail do usuário, algo como:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# ./lib/console_helpers.rb&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ConsoleHelper&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{})&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find_by_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find_by_email!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;User have more than 1 account: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;account_ids&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;update_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;New data for account#&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inspect&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# ./config/application.rb&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;console&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ConsoleMethods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;send&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;ConsoleHelpers&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Neste caso, quando entro no console, posso facilmente fazer:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;=&amp;gt; update_info &apos;johndoe@domain.com&apos;, {attribute: &apos;new_value&apos;}
New data for account #123: {:attribute =&amp;gt; &apos;new_value&apos;}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Porém, fazendo os testes no console (após os testes automatizados, claro!), ao passar um número de ID que não existia (número zero), fui surpreendido com a atualização de uma conta que eu não esperava.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;=&amp;gt; update_info 0, {attribute: &apos;new_value&apos;}
New data for account #456: {:attribute =&amp;gt; &apos;new_value&apos;}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O que notei, foi que a busca do MySQL retornou um usuário, cujo o e-mail dele era &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;00022e34f23a72@domain.com&lt;/code&gt;, pois a query SQL criada foi:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; SELECT `users`.* FROM `users` WHERE `users`.`email` = 0 ORDER BY email ASC LIMIT 1;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ou seja, o MySQL tem o mesmo comportamento do Ruby, ao tentar converter uma string para número.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;=&amp;gt; &apos;102-string&apos;.to_i # results: 102
102
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Logo, fiz o ajuste na função para converter para string na busca por e-mail.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# ./lib/console_helpers.rb&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ConsoleHelper&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{})&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find_by_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find_by_email!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id_or_email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;User have more than 1 account: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;account_ids&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;update_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;New data for account#&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new_date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inspect&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Não caia da mesma armadilha.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Últimas nem tão novidades assim e agradecimentos</title>
   <link href="https://blog.tinogomes.com/2013/11/22/ultimas-nem-tao-novidades-assim-e-agradecimentos"/>
   <updated>2013-11-22T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2013/11/22/ultimas-nem-tao-novidades-assim-e-agradecimentos</id>
   <content type="html">
&lt;p&gt;Em agosto, minha família e eu, voltamos a morar na &lt;a href=&quot;http://pt.wikipedia.org/wiki/Rio_de_Janeiro_(cidade)&quot;&gt;Cidade Maravilhosa&lt;/a&gt; e desde então, estou trabalhando na &lt;a href=&quot;http://www.myfreecomm.com.br&quot;&gt;Myfreecomm&lt;/a&gt;, no produto &lt;a href=&quot;http://www.myfinance.com.br&quot;&gt;MyFinance&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Com isso, deixamos para trás a &lt;a href=&quot;http://pt.wikipedia.org/wiki/Terra_da_garoa&quot;&gt;Terra da Garoa&lt;/a&gt; e muito amigos que vão deixar saudades do convívio diário, principalmente os com espírito &lt;a href=&quot;https://web.archive.org/web/20090720025053/http://www.webcointernet.com/&quot;&gt;Webco&lt;/a&gt;, que já espalharam mundo afora.&lt;/p&gt;

&lt;p&gt;Quero agradecer a &lt;del&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=K6lO1rfW6F8&quot;&gt;toda família Balbino&lt;/a&gt;&lt;/del&gt; todos que conviveram comigo durante esses 5 anos paulistamos, em especial: &lt;a href=&quot;http://twitter.com/lsdr&quot;&gt;Rocha&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/fnando&quot;&gt;Nando&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/zagari&quot;&gt;Zagari&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/lfcipriani&quot;&gt;Cipriani&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/nuxlli&quot;&gt;Pluguinho&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/darthmv&quot;&gt;MV&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/lucasfais&quot;&gt;Fais&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/gbenatti&quot;&gt;GB&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/lucashungaro&quot;&gt;Hungaro&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/shiota&quot;&gt;Shiota&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/wilsorsouza&quot;&gt;Bibinha&lt;/a&gt;, &lt;a href=&quot;http://twitter.com/fabinhot&quot;&gt;Fabinho&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Esse mundo é pequeno e em breve estaremos juntos novamente…&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Livro Conhecendo Ruby por TaQ, gratuito mas você pode contribuir</title>
   <link href="https://blog.tinogomes.com/2013/06/17/livro-conhecendo-ruby-por-taq-gratuito-mas-voce-pode-contribuir"/>
   <updated>2013-06-17T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2013/06/17/livro-conhecendo-ruby-por-taq-gratuito-mas-voce-pode-contribuir</id>
   <content type="html">
&lt;p&gt;O que é bom, tem que ser divulgado!&lt;/p&gt;

&lt;iframe width=&quot;100%&quot; height=&quot;400&quot; src=&quot;https://leanpub.com/conhecendo-ruby/embed&quot; frameborder=&quot;0&quot; allowtransparency=&quot;true&quot;&gt;&lt;/iframe&gt;
</content>
 </entry>
 
 <entry>
   <title>DEV in SAMPA 2013 - precisamos do seu feedback</title>
   <link href="https://blog.tinogomes.com/2013/05/19/dev-in-sampa-2013-como-foi"/>
   <updated>2013-05-19T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2013/05/19/dev-in-sampa-2013--como-foi</id>
   <content type="html">
&lt;p&gt;Precisamos do seu feedback, para saber no que podemos melhorar para o próximo DEV in SAMPA.&lt;/p&gt;

&lt;p&gt;Por favor, acesse &lt;a href=&quot;http://say2me.com.br/devinsampa&quot;&gt;http://say2me.com.br/devinsampa&lt;/a&gt; e responda ao questionário.&lt;/p&gt;

&lt;p&gt;Obrigado.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>DEV in SAMPA 2013</title>
   <link href="https://blog.tinogomes.com/2013/05/14/devinsampa-2013"/>
   <updated>2013-05-14T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2013/05/14/devinsampa-2013</id>
   <content type="html">
&lt;p&gt;Para tirar um pouco a poeira do site, segue abaixo um anúncio.&lt;/p&gt;

&lt;p&gt;Este ano, o &lt;a href=&quot;http://devinsampa.com.br&quot;&gt;&lt;strong&gt;DEVinSAMPA&lt;/strong&gt;&lt;/a&gt; vai acontecer dia 18 de maio e as &lt;a href=&quot;http://abr.ai/devinsampa2013&quot;&gt;inscrições estão abertas através do site da Eventick&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Para ter mais informações sobre a programação, acesse: &lt;a href=&quot;http://devinsampa.com.br#agenda&quot;&gt;http://devinsampa.com.br#agenda&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Não vai ficar de fora!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Testando seu código em várias versões de dependência</title>
   <link href="https://blog.tinogomes.com/2012/06/04/testando-seu-cdigo-em-vrias-verses-de-dependncia"/>
   <updated>2012-06-04T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2012/06/04/testando-seu-cdigo-em-vrias-verses-de-dependncia</id>
   <content type="html">
&lt;p&gt;&lt;strong&gt;ATUALIZAÇÃO 1:&lt;/strong&gt; Se você, como nós, tem uma gem pública, existe a possibilidade de usar o &lt;a href=&quot;http://travis-ci.org/tapajos/brazilian-rails&quot;&gt;Travis CI&lt;/a&gt; para verificação em várias versões de Rails e Rubies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ATUALIZAÇÃO 2:&lt;/strong&gt; deve-se usar o comando &lt;em&gt;DO&lt;/em&gt; do RVM &lt;a href=&quot;https://rvm.io/set/do/&quot;&gt;https://rvm.io/set/do/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Preciso verificar se o &lt;a href=&quot;https://github.com/tapajos/brazilian-rails/&quot;&gt;Brazilian Rails&lt;/a&gt; funciona em várias versões do &lt;a href=&quot;https://github.com/rails/rails/&quot;&gt;Rails&lt;/a&gt;, 2.3.x, 3.0.x, 3.1.x e 3.2.x e &lt;a href=&quot;http://ruby-lang.org/&quot;&gt;Ruby&lt;/a&gt; 1.8.7 e 1.9.x. Como faz?&lt;/p&gt;

&lt;p&gt;Com &lt;a href=&quot;https://rvm.io/&quot;&gt;RVM&lt;/a&gt;, seria:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ rvm 1.8.7@rails23x,1.8.7@rails30x,1.8.7@rails31x,1.8.7@rails32x,[até],1.9.3@rails32x do rake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Claro, existe um script automatizando isto, mas ainda sim é feio d+.&lt;/p&gt;

&lt;p&gt;Uma solução, seria usar o &lt;a href=&quot;https://github.com/tomas-stefano/infinity_test&quot;&gt;infinity_test&lt;/a&gt;, mas o Brazilian Rails tem testes em TestUnit e também em &lt;a href=&quot;http://github.com/rspec/rspec&quot;&gt;RSpec&lt;/a&gt; e como o infity_test é para execução em apenas um “ambiente”, não sei se irá funcionar (não testei)&lt;/p&gt;

&lt;p&gt;Outra é usar o &lt;a href=&quot;https://github.com/thoughtbot/appraisal&quot;&gt;Appraisal&lt;/a&gt;, que se integra com o Bundler e Rake, o que fica bastante flexível.&lt;/p&gt;

&lt;p&gt;Seguindo os passos conforme indicado no README do projeto, no meu ambiente fico com apenas um gemset por versão de Ruby.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ rvm 1.8.7@brazilianrails,1.9.1@brazilianrails,1.9.2@brazilianrails,1.9.3@brazilianrails do rake test_spec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Para quem não separa as instalações por gemset, usando apenas o default, fica ainda mais limpo.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ rvm 1.8.7,1.9.1,1.9.2,1.9.3 do rake test_spec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;E se seguir a sugestão de David Czarneck, basta criar uma tarefa Rake,&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;c1&quot;&gt;# Rakefile&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Ruby test units and RSpec&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:test_spec&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Rake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Rake&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;spec&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Runs tests on Ruby 1.8.7 and 1.9.2&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:test_all&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;rvm 1.8.7@brazilianrails,1.9.1@brazilianrails,1.9.2@brazilianrails,1.9.3@brazilianrails do rake test_spec&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;e executar:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ rake test_all
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Referências:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.agoragames.com/blog/2011/05/27/testing-multiple-ruby-versions-and-gemsets-using-rvm/&quot;&gt;http://blog.agoragames.com/blog/2011/05/27/testing-multiple-ruby-versions-and-gemsets-using-rvm/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Como configurar o timezone no Heroku</title>
   <link href="https://blog.tinogomes.com/2012/05/14/como-configurar-o-timezone-no-heroku"/>
   <updated>2012-05-14T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2012/05/14/como-configurar-o-timezone-no-heroku</id>
   <content type="html">
&lt;p&gt;Basta apenas adicionar uma configuração, em uma variável de ambiente&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ heroku config:add TZ=America/Sao_Paulo
Adding config vars and restarting app... done, v24
  TZ =&amp;gt; America/Sao_Paulo
$ heroku run console
Running console attached to terminal... Time.oup, run.1
Time.now
irb(main):001:0&amp;gt; Time.now
=&amp;gt; 2012-05-14 09:51:51 -0300
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_tz_database_time_zones&quot;&gt;lista de timezones disponíveis&lt;/a&gt; está na Wikipedia.&lt;/p&gt;

&lt;p&gt;Referências:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://tamersalama.com/2010/10/05/heroku-timezone-adjustment/&quot;&gt;http://tamersalama.com/2010/10/05/heroku-timezone-adjustment/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://clarkli.wordpress.com/2011/12/29/set-timezone-on-heroku-servers/&quot;&gt;http://clarkli.wordpress.com/2011/12/29/set-timezone-on-heroku-servers/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Git na porta SSH diferente da padrão</title>
   <link href="https://blog.tinogomes.com/2012/04/03/git-na-porta-ssh-diferente-da-padrao"/>
   <updated>2012-04-03T00:00:00+00:00</updated>
   <id>https://blog.tinogomes.com/2012/04/03/git-na-porta-ssh-diferente-da-padrao</id>
   <content type="html">
&lt;p&gt;Digamos que por motivo de segurança, resolveram mudar o número da porta SSH e você não consegue mais fazer um simples &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git pull&lt;/code&gt; então, basta adicionar o prefixo do protocolo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh://&lt;/code&gt; e então adicionar o número da porta. Considerando que a porta agora é 2222.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git clone ssh://user@git.repo:2222/path/repo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Referências:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.bramschoenmakers.nl/en/node/720&quot;&gt;http://www.bramschoenmakers.nl/en/node/720&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 

</feed>
