<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>
  <channel>
    <title>Lucas Caton - English posts</title>
    <description>Blog about software development, Ruby, Rails, macOS, Linux, carrer, and entrepreneurship</description>

    <link>https://www.lucascaton.com.br</link>

    <atom:link href='https://www.lucascaton.com.br/english-feed.xml' rel='self' type='application/rss+xml' />
    
    <item>
      <title>How to run your feature specs using Capybara and Headless Chrome</title>

      
        <description>&lt;p&gt;Google has recently announced a way to run the &lt;a href=&quot;https://developers.google.com/web/updates/2017/04/headless-chrome&quot; target=&quot;_blank&quot;&gt;Chrome browser in a headless environment&lt;/a&gt;.
If you’re using &lt;a href=&quot;https://github.com/teamcapybara/capybara&quot; target=&quot;_blank&quot;&gt;Capybara&lt;/a&gt; gem, you can easily start using headless Chrome. Without further ado, let’s do it:&lt;/p&gt;

&lt;p&gt;1) Make sure you have one of the following &lt;strong&gt;Chrome versions&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;57+ on &lt;strong&gt;Linux&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;59+ on &lt;strong&gt;macOS&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;60+ on &lt;strong&gt;Windows&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Add (or update) the gem &lt;code&gt;selenium-webdriver&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;3) Make sure you’re using &lt;strong&gt;ChromeDriver&lt;/strong&gt; version 2.30 or higher.
You can install it by running:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;brew install chromedriver&lt;/code&gt; on &lt;strong&gt;macOS&lt;/strong&gt;;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;apt-get install chromium-chromedriver&lt;/code&gt; on &lt;strong&gt;Debian/Ubuntu Linux&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4) Add the following &lt;code class=&quot;highlighter-rouge&quot;&gt;driver&lt;/code&gt; to your &lt;code class=&quot;highlighter-rouge&quot;&gt;spec_helper.rb&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;rails_helper.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;Capybara&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;register_driver&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:chrome&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;app&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Capybara&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Selenium&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Driver&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;browser: :chrome&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;ss&quot;&gt;options: &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Selenium&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;WebDriver&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Chrome&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;args: &lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;%w[headless disable-gpu]&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;no&quot;&gt;Capybara&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;javascript_driver&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:chrome&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Done, enjoy headless Chrome! ᕕ( ᐛ )ᕗ&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;You might get a warning like the following:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;WARN Selenium &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DEPRECATION] :args or :switches is deprecated. Use Selenium::WebDriver::Chrome::Options#add_argument instead.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make sure you don’t have another registered driver, I made this mistake myself and had an &lt;code class=&quot;highlighter-rouge&quot;&gt;iphone&lt;/code&gt; driver, which was passing &lt;code class=&quot;highlighter-rouge&quot;&gt;args&lt;/code&gt; in the old way and turned out to be the reason why I was getting the warning.&lt;/p&gt;
</description>
      

      <pubDate>Thu, 22 Jun 2017 21:03:20 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2017/06/22/how-to-run-your-feature-specs-using-capybara-and-headless-chrome/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2017/06/22/how-to-run-your-feature-specs-using-capybara-and-headless-chrome/</guid>
    </item>
    
    <item>
      <title>How to setup multiple Heroku accounts (for heroku-cli)</title>

      
        <description>&lt;p&gt;Both &lt;a href=&quot;https://heroku.com/&quot; target=&quot;_blank&quot;&gt;Heroku&lt;/a&gt; and &lt;a href=&quot;https://devcenter.heroku.com/articles/heroku-cli&quot; target=&quot;_blank&quot;&gt;its CLI&lt;/a&gt; are great. However, there’s no way to access multiple accounts via terminal out of the box. If you have a personal and a work account and need an easy way to switch between them, I have good news for you! :)&lt;/p&gt;

&lt;p&gt;Heroku’s team has created a plugin called &lt;a href=&quot;https://github.com/heroku/heroku-accounts&quot; target=&quot;_blank&quot;&gt;heroku-accounts&lt;/a&gt;. You can find &lt;a href=&quot;https://github.com/heroku/heroku-accounts#installation&quot; target=&quot;_blank&quot;&gt;how to install&lt;/a&gt; and &lt;a href=&quot;https://github.com/heroku/heroku-accounts#usage&quot; target=&quot;_blank&quot;&gt;how to use&lt;/a&gt; in its project page on Github.&lt;/p&gt;

&lt;p&gt;To make it even easier, I’ve added the following aliases to my &lt;code&gt;~/.zshrc&lt;/code&gt; (or &lt;code&gt;~/.bashrc&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Heroku&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;hp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'heroku accounts:set personal'&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;hw&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'heroku accounts:set work'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Happy hacking!&lt;/p&gt;
</description>
      

      <pubDate>Mon, 13 Feb 2017 18:17:00 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2017/02/13/how-to-setup-multiple-heroku-accounts-in-heroku-cli/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2017/02/13/how-to-setup-multiple-heroku-accounts-in-heroku-cli/</guid>
    </item>
    
    <item>
      <title>[Ruby] How to get the name of the calling method?</title>

      
        <description>&lt;p&gt;I was about to run a rake task which would make important changes in my database.
My code was similar to this:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;migrate_active_accounts&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;accounts&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;active&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# Code to migrate accounts here...&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;migrate_inactive_accounts&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;accounts&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;inactive&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# Code to migrate accounts here...&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This migration was very critical. Thus, I decided to log everything to make sure it would run as expected.
So I wrote a separate method to log what accounts were going to run by which method.&lt;/p&gt;

&lt;p&gt;In order to do that, I’d need to know which method was calling my logger method.&lt;/p&gt;

&lt;p&gt;I ended up &lt;a href=&quot;http://stackoverflow.com/a/15098459/1445184&quot; target=&quot;_blank&quot;&gt;finding the answer on StackOverflow&lt;/a&gt; (where else would I? :p).&lt;/p&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;

&lt;p&gt;As usual, Ruby has a neat solution for it: &lt;code class=&quot;highlighter-rouge&quot;&gt;Kernel&lt;/code&gt; module has a &lt;a href=&quot;https://ruby-doc.org/core-2.3.1/Kernel.html#method-i-caller_locations&quot; target=&quot;_blank&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;caller_locations&lt;/code&gt;&lt;/a&gt; method, which returns an array with the current execution stack. So all we need to do is to use &lt;code class=&quot;highlighter-rouge&quot;&gt;caller_locations.first.label&lt;/code&gt; to get the first element from the stack and then get its label.&lt;/p&gt;

&lt;p&gt;My final code was looking like the following:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;migrate_active_accounts&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;accounts&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;active&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;log_migration_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# Code to migrate accounts here...&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;migrate_inactive_accounts&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;accounts&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;inactive&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;log_migration_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# Code to migrate accounts here...&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;kp&quot;&gt;private&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;log_migration_info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;caller_method&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;caller_locations&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;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;label&lt;/span&gt;

  &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;info&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Running [MyClass#&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;caller_method&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]
    for the following accounts: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_sentence&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;ruby-prior-to-20&quot;&gt;Ruby prior to 2.0&lt;/h2&gt;

&lt;p&gt;If you’re using an old version of Ruby (&lt;a href=&quot;/2014/02/28/have-a-rails-2-app-you-can-run-it-on-the-newest-ruby/&quot;&gt;even though you shouldn’t&lt;/a&gt;),
you’ll need to use &lt;code class=&quot;highlighter-rouge&quot;&gt;caller&lt;/code&gt; method along with a regular expression:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;caller&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;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/`(.*)'/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Happy hacking!&lt;/p&gt;
</description>
      

      <pubDate>Fri, 04 Nov 2016 13:36:04 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/11/04/ruby-how-to-get-the-name-of-the-calling-method/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/11/04/ruby-how-to-get-the-name-of-the-calling-method/</guid>
    </item>
    
    <item>
      <title>New blog theme</title>

      
        <description>&lt;p&gt;Last time &lt;a href=&quot;/2012/10/02/new-blog-layout/&quot;&gt;I updated this blog’s theme&lt;/a&gt; was in 2012!&lt;/p&gt;

&lt;p&gt;It was about time to have a fresh new look and there you have it! \o/&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2016/11/new-theme.png&quot; alt=&quot;new-theme&quot; /&gt;&lt;/p&gt;
</description>
      

      <pubDate>Fri, 04 Nov 2016 11:11:54 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/11/04/new-blog-theme/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/11/04/new-blog-theme/</guid>
    </item>
    
    <item>
      <title>Prevent Rails from writing development/test log files</title>

      
        <description>&lt;p&gt;I can’t remember the last time I needed to open/read &lt;code class=&quot;highlighter-rouge&quot;&gt;log/development.log&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;log/test.log&lt;/code&gt;.
These files usualy just consume disk space unnecessarily (some &lt;code class=&quot;highlighter-rouge&quot;&gt;test.log&lt;/code&gt; files can easily reach more than 1 GB).&lt;/p&gt;

&lt;p&gt;After talking to some other developers, all of them agreed they don’t use it as well.
So what I’ve been doing in my projects is adding the following code (note that it’ll still display logs through the &lt;code class=&quot;highlighter-rouge&quot;&gt;STDOUT&lt;/code&gt; though):&lt;/p&gt;

&lt;h2 id=&quot;rails-4&quot;&gt;Rails 4+&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/environments/development.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Prevents from writing logs on `log/development.log`&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;formatter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log_formatter&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TaggedLogging&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/environments/test.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Prevents from writing logs on `log/test.log`&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log_level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:warn&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;formatter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log_formatter&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TaggedLogging&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;rails-3&quot;&gt;Rails 3&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/environments/development.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Prevents from writing logs on `log/development.log`&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TaggedLogging&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Replace `config.active_support.deprecation = :log` with:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;active_support&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;deprecation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:stderr&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/environments/test.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Prevents from writing logs on `log/test.log`&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;log_level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:warn&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActiveSupport&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;TaggedLogging&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ps.: I’ve sent a suggestion to &lt;a href=&quot;https://groups.google.com/forum/?fromgroups#!searchin/rubyonrails-core/lucascaton%7Csort:relevance/rubyonrails-core/MGwMVsQPjzw/ubL8-54wAwAJ&quot; target=&quot;_blank&quot;&gt;rubyonrails-core mailing list&lt;/a&gt; to make it default from next Rails versions, let’s see their thoughts.&lt;/p&gt;
</description>
      

      <pubDate>Thu, 27 Oct 2016 10:44:27 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/10/27/prevent-rails-from-writing-developmenttest-log-files/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/10/27/prevent-rails-from-writing-developmenttest-log-files/</guid>
    </item>
    
    <item>
      <title>Puma vs. Unicorn</title>

      
        <description>&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;TL; DR&lt;/strong&gt; - Just use &lt;a href=&quot;http://puma.io/&quot; target=&quot;_blank&quot;&gt;Puma&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rails has &lt;a href=&quot;https://github.com/rails/rails/pull/23906/files&quot; target=&quot;_blank&quot;&gt;changed its default server from Webrick to Puma&lt;/a&gt; in Rails 5!&lt;/p&gt;

&lt;p&gt;It also supports &lt;strong&gt;Action Cable&lt;/strong&gt; (one of the new features from Rails 5) and Basecamp said &lt;a href=&quot;http://weblog.rubyonrails.org/2015/12/18/Rails-5-0-beta1/&quot; target=&quot;_blank&quot;&gt;they’re using Puma in production&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I was wondering if &lt;strong&gt;Puma&lt;/strong&gt; has been in fact better than &lt;strong&gt;Unicorn&lt;/strong&gt; so I’ve read some blog posts about it:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://blog.codeship.com/puma-vs-unicorn/&quot; target=&quot;_blank&quot;&gt;Codeship’s&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server&quot; target=&quot;_blank&quot;&gt;Heroku’s&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.engineyard.com/articles/rails-server&quot; target=&quot;_blank&quot;&gt;EngineYard’s&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, the answer is &lt;strong&gt;yes - it is a bit better&lt;/strong&gt;, but don’t wait for a huge improvement.&lt;/p&gt;

&lt;p&gt;It’d be a good idea if you’re either about to start a new project and migrating your current project to Rails 5 or newer.&lt;/p&gt;
</description>
      

      <pubDate>Sun, 13 Mar 2016 14:24:26 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/03/13/puma-vs-unicorn/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/03/13/puma-vs-unicorn/</guid>
    </item>
    
    <item>
      <title>Rake task to import a production DB dump</title>

      
        <description>&lt;p&gt;Every now and then I need to write a script (rake task) to import a production database dump.&lt;/p&gt;

&lt;p&gt;This is code I usually use:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'yaml'&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:db&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;desc&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Downloads and imports a production DB dump'&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;task&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:import_production_dump&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Generating production DB dump...'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;execute_on_server&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;%(
      PGPASSWORD=&quot;`cat /var/www/project/current/config/database.yml | \
        grep password | awk '{ print $2 }'`&quot; \
        pg_dump database_name -h custom_url.rds.amazonaws.com -U user_name \
        --column-inserts --no-owner --no-privileges &amp;gt; backup.sql
    )&lt;/span&gt;

    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Downloading production DB dump...'&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;scp &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;server_user_and_host&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;backup_file_name&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;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Deleting production DB dump...'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;execute_on_server&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;rm &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;backup_file_name&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;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Cleaning your local DB...'&lt;/span&gt;
    &lt;span class=&quot;sx&quot;&gt;%w[drop create]&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;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;task&lt;/span&gt;&lt;span class=&quot;o&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;s2&quot;&gt;&quot;db:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;task&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;invoke&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;s1&quot;&gt;'➙ Importing production DB dump...'&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;bin/rails db development &amp;lt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;backup_file_name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &amp;gt; /dev/null&quot;&lt;/span&gt;

    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Removing local dump...'&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;rm &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;backup_file_name&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;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'➙ Done!'&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;execute_on_server&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;%(ssh -T #{server_user_and_host} &amp;lt;&amp;lt; 'SSH'
      #{commands}
    SSH)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&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;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&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;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;server_user_and_host&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;'username@example.com'&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;backup_file_name&lt;/span&gt;
    &lt;span class=&quot;s1&quot;&gt;'backup.sql'&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let me know in the comments if you have a better solution! Perhaps a small gem? :)&lt;/p&gt;
</description>
      

      <pubDate>Sat, 12 Mar 2016 09:45:52 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/03/12/rake-task-to-import-a-production-db-dump/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/03/12/rake-task-to-import-a-production-db-dump/</guid>
    </item>
    
    <item>
      <title>Why I regenerated my SSH key and maybe you should too</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2016/02/security.jpg&quot; alt=&quot;security&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I think we all agree it’s a good practice to regenerate your SSH key from time to time. Not sure about you, but the first thing that comes to my mind when I think about that is: it’d take forever to replace my key in all servers I need to access, all online services that use my key, etc.&lt;/p&gt;

&lt;p&gt;Overcoming my laziness, I decided at least to list those place it turned out it was a small list:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Servers&lt;/li&gt;
  &lt;li&gt;Github&lt;/li&gt;
  &lt;li&gt;BitBucket&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although now it looks more reasonable, I was still lazy to do it. But then I noticed that &lt;a href=&quot;https://help.github.com/articles/which-remote-url-should-i-use/&quot; target=&quot;_blank&quot;&gt;Github recommends&lt;/a&gt; the use of &lt;strong&gt;HTTPS&lt;/strong&gt; instead of &lt;strong&gt;SSH&lt;/strong&gt; for Git repositories syncs:&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2016/02/1.jpg&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;What does one thing have to do with another? Well, by using &lt;code class=&quot;highlighter-rouge&quot;&gt;HTTPS&lt;/code&gt;, you don’t need to upload your SSH key to &lt;strong&gt;Github&lt;/strong&gt; (check this out: &lt;a href=&quot;https://github.com/lucascaton.keys&quot; target=&quot;_blank&quot;&gt;mine isn’t longer at Github&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BitBucket&lt;/strong&gt; also supports it, which means I’d be able to regenerate my SSH key without having to upload it again to these services.&lt;/p&gt;

&lt;h2 id=&quot;servers&quot;&gt;Servers&lt;/h2&gt;

&lt;p&gt;What’s left? Servers! From now on, every time I realise it’s time to regenerate my SSH key, all I need to update are the servers.
I ended up making a list of servers that I’d need to update and found out in the end it wasn’t a big list and it’d be way easier than I thought it would.&lt;/p&gt;

&lt;p&gt;Let’s face the truth: I had been using the same SSH key in the last 5 years or so and it’d be totally worth it to ensure my security as well as the security of the projects from the company I work for.&lt;/p&gt;

&lt;h2 id=&quot;becoming-safer&quot;&gt;Becoming safer&lt;/h2&gt;

&lt;p&gt;There’s more! This is the interesting part of this post: I’ve changed other things that made everything even safer:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;My new SSH key uses &lt;strong&gt;4096 bits&lt;/strong&gt; - &lt;a href=&quot;https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/&quot; target=&quot;_blank&quot;&gt;recommended by Github&lt;/a&gt; - instead of the default (&lt;strong&gt;2048 bits&lt;/strong&gt;).&lt;/li&gt;
  &lt;li&gt;As I mentioned before, I’ve changed all my local repositories to use &lt;code&gt;HTTPS&lt;/code&gt; instead of &lt;code&gt;SSH&lt;/code&gt; (see how in the end of this post).&lt;/li&gt;
  &lt;li&gt;I’m now using a &lt;a href=&quot;https://help.github.com/articles/creating-an-access-token-for-command-line-use/&quot; target=&quot;_blank&quot;&gt;personal access token&lt;/a&gt; rather than my Github password (you can &lt;a href=&quot;https://github.com/settings/tokens&quot; target=&quot;_blank&quot;&gt;create it here&lt;/a&gt;), along with &lt;a href=&quot;https://help.github.com/articles/about-two-factor-authentication/&quot; target=&quot;_blank&quot;&gt;two-factor authentication&lt;/a&gt;, which I was already using.&lt;/li&gt;
  &lt;li&gt;Cool, but would I need to type this token every time? Nope. There’s a nifty tool called &lt;code&gt;ssh-agent&lt;/code&gt; that can save your token. If you’re using macOS, it’s even easier: &lt;a href=&quot;https://help.github.com/articles/working-with-ssh-key-passphrases/#os-x-keychain&quot; target=&quot;_blank&quot;&gt;Keychain&lt;/a&gt; can save and encrypt your token for you.&lt;/li&gt;
  &lt;li&gt;My SSH key now has a &lt;a href=&quot;https://help.github.com/articles/working-with-ssh-key-passphrases/&quot; target=&quot;_blank&quot;&gt;passphrase&lt;/a&gt;, also saved encrypted on macOS’s Keychain, which means I don’t need to type it every time either.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;https-is-faster&quot;&gt;HTTPS is faster!&lt;/h2&gt;

&lt;p&gt;According to some tests I made here, &lt;code&gt;HTTPS&lt;/code&gt; is faster than &lt;code&gt;SSH&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# SSH&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;time &lt;/span&gt;git clone git@github.com:rails/rails.git
&lt;span class=&quot;c&quot;&gt;# 24.28s user 9.56s system 49% cpu 1:08.20 total&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# HTTPS&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;time &lt;/span&gt;git clone https://github.com/rails/rails.git
&lt;span class=&quot;c&quot;&gt;# 13.52s user 6.41s system 39% cpu 50.730 total&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;in-order-to-use-https-in-my-git-repos-do-i-need-to-re-clone-every-project&quot;&gt;In order to use HTTPS in my Git repos, do I need to re-clone every project?&lt;/h2&gt;

&lt;p&gt;Nope. Just open &lt;code class=&quot;highlighter-rouge&quot;&gt;.git/config&lt;/code&gt; file and replace:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;url &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; git@github.com:username/repo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;with:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;url &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; https://github.com/username/repo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Regenerating your SSH key every now and then isn’t as painful as you might think.
I’d recommend doing it every 3 years or even less if you’re paranoic or you work on something critic.&lt;/p&gt;
</description>
      

      <pubDate>Tue, 23 Feb 2016 18:55:15 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/02/23/why-i-regenerated-my-ssh-key-and-maybe-you-should-too/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/02/23/why-i-regenerated-my-ssh-key-and-maybe-you-should-too/</guid>
    </item>
    
    <item>
      <title>What is &quot;frozen_string_literal&quot; in Ruby?</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2016/01/ruby3.jpg&quot; alt=&quot;ruby3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freezing Strings&lt;/strong&gt; feature improves apps performance by freezing Strings. So, &lt;a href=&quot;https://twitter.com/yukihiro_matz&quot; target=&quot;_blank&quot;&gt;Matz&lt;/a&gt; - Ruby’s creator - decided to make all String literals frozen (immutable) &lt;a href=&quot;https://bugs.ruby-lang.org/issues/11473&quot; target=&quot;_blank&quot;&gt;by default in Ruby 3.0&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to have a transition path to this coming big change, it was decided to have a magic comment at the beginning of files, so you can use in &lt;strong&gt;Ruby 2.x&lt;/strong&gt;.
To do so, just add this comment in the first line of your files:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# frozen_string_literal: true&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;YourClass&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# ...&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Try adding it to your &lt;code class=&quot;highlighter-rouge&quot;&gt;spec_helper&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;rails_helper&lt;/code&gt; file and let me know in the comments if your performance gets any better.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;More info: &lt;a href=&quot;https://bugs.ruby-lang.org/issues/8976&quot; target=&quot;_blank&quot;&gt;Ruby issue #8976&lt;/a&gt;.&lt;/p&gt;
</description>
      

      <pubDate>Tue, 19 Jan 2016 09:33:30 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2016/01/19/what-is-frozen_string_literal-in-ruby/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2016/01/19/what-is-frozen_string_literal-in-ruby/</guid>
    </item>
    
    <item>
      <title>If you really need to create a monkey patch, do it properly</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2015/12/Top-5-Ruby-IDE-Solutions-for-Web-Developers.png&quot; alt=&quot;Top-5-Ruby-IDE-Solutions-for-Web-Developers&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Sometimes we need to create a monkey patch for a gem or external lib. In these cases, it’s good to force it to fail if the gem has been bumped up. Let’s use Paperclip as an example:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Paperclip&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'1.2.3'&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# If you see this message, please test removing this file&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# If it's still required, please bump up the version above&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;fail&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Please remove me, Paperclip version has changed'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If the gem doesn’t provide you the version through a method, you can solve it with:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Bundler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;specs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;find&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;n&quot;&gt;gem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gem&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;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'paperclip'&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;version&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;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'1.2.3'&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# If you see this message, please test removing this file&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# If it's still required, please bump up the version above&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;fail&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Please remove me, Paperclip version has changed'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or even when you’re waiting for a new Rails version, e.g.:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;fail&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Remove this file'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&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;VERSION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;MAJOR&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
      

      <pubDate>Thu, 10 Dec 2015 15:15:44 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2015/12/10/if-you-really-need-to-create-a-monkey-patch-do-it-properly/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2015/12/10/if-you-really-need-to-create-a-monkey-patch-do-it-properly/</guid>
    </item>
    
    <item>
      <title>CampJS 2014 - the best geek event I ever attended</title>

      
        <description>&lt;p&gt;A few days ago I was in CampJS, the best geek event I ever attended.&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/campjs.png&quot; alt=&quot;campjs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is the official website (which is pretty cool by the way): &lt;a href=&quot;http://campjs.com/&quot; target=&quot;_blank&quot;&gt;http://campjs.com/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Why it was the best in my opinion:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It happened at an amazing place - close to the nature and changing the usual environment is renewable. I’d definitely recommend it!&lt;/li&gt;
  &lt;li&gt;I had the chance to talk to a lot of other Javascript developers&lt;/li&gt;
  &lt;li&gt;Awesome talks and workshops&lt;/li&gt;
  &lt;li&gt;Good food and beers&lt;/li&gt;
  &lt;li&gt;A live podcast was recorded in there&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A friend of mine (&lt;a href=&quot;http://twitter.com/erikEcoologic&quot; target=&quot;_blank&quot;&gt;@erikEcoologic&lt;/a&gt;) has written an &lt;a href=&quot;http://netengine.com.au/blog/campjs_2014/&quot; target=&quot;_blank&quot;&gt;awesome blog post&lt;/a&gt; about the event, so check it out! ;)&lt;/p&gt;

&lt;p&gt;A special thanks to &lt;a href=&quot;http://twitter.com/brucestronge&quot; target=&quot;_blank&quot;&gt;@brucestronge&lt;/a&gt; and to &lt;a href=&quot;http://netengine.com.au/&quot; target=&quot;_blank&quot;&gt;NetEngine&lt;/a&gt; for the tickets!&lt;/p&gt;

&lt;h1 id=&quot;video--some-pictures&quot;&gt;Video &amp;amp; some pictures&lt;/h1&gt;

&lt;!-- Courtesy of embedresponsively.com //--&gt;
&lt;div class=&quot;responsive-video-container&quot;&gt;

  &lt;iframe src=&quot;https://www.youtube.com/embed/xVFY5VzJavQ&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;/div&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_0.jpg&quot; alt=&quot;IMG_0&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1067.jpg&quot; alt=&quot;IMG_1067&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1099.jpg&quot; alt=&quot;IMG_1099&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1199.jpg&quot; alt=&quot;IMG_1199&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1202.jpg&quot; alt=&quot;IMG_1202&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1206.jpg&quot; alt=&quot;IMG_1206&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/11/IMG_1267.jpg&quot; alt=&quot;IMG_1267&quot; /&gt;&lt;/p&gt;
</description>
      

      <pubDate>Fri, 21 Nov 2014 01:11:04 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2014/11/21/campjs-2014-the-best-nerd-event-i-ever-attended/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2014/11/21/campjs-2014-the-best-nerd-event-i-ever-attended/</guid>
    </item>
    
    <item>
      <title>How to use command line on macOS</title>

      
        <description>&lt;p&gt;A friend of mine (who used to use Windows) has bought a Mac recently and he asked me how to use the command line on macOS:&lt;/p&gt;

&lt;p&gt;My answer was:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;99% of commands are identical in Linux. This is good news as there are a lot of material about it available on the Internet;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Terminal.app&lt;/code&gt; from macOS is cool, but it’s not perfect. I (and 90% of developers I know) use &lt;code class=&quot;highlighter-rouge&quot;&gt;iTerm2&lt;/code&gt; (&lt;a href=&quot;http://iterm2.com/&quot; target=&quot;_blank&quot;&gt;http://iterm2.com/&lt;/a&gt;). It’s light (3mb), free, open-source, has a better interface than the native one and it rocks! Best terminal I’ve ever used.&lt;/li&gt;
  &lt;li&gt;This is the most useful topic in my answer: &lt;a href=&quot;http://www.git-tower.com/blog/command-line-cheat-sheet-detail/&quot; target=&quot;_blank&quot;&gt;an awesome cheat-sheet with command line commands&lt;/a&gt; made by the Git-tower team;&lt;/li&gt;
  &lt;li&gt;To finish: I’ve recorded a screencast (in Portuguese) explaining how to create scripts on macOS and Linux (similar to BAT files on Windows).:&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- Courtesy of embedresponsively.com //--&gt;
&lt;div class=&quot;responsive-video-container&quot;&gt;

  &lt;iframe src=&quot;https://www.youtube.com/embed/W84Ok6XGnow&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;/div&gt;

</description>
      

      <pubDate>Sun, 31 Aug 2014 21:49:02 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2014/08/31/how-to-use-command-line-on-mac-os-x/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2014/08/31/how-to-use-command-line-on-mac-os-x/</guid>
    </item>
    
    <item>
      <title>What's on my macOS menu bar</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/08/menubar.png&quot; alt=&quot;menubar&quot; /&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Application&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
      &lt;th&gt;Type&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;

  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://itunes.apple.com/au/app/caffeine/id411246225&quot;&gt;Caffeine&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Prevent your Mac from automatically going to sleep, dimming the screen or starting screen savers&lt;/td&gt;
      &lt;td&gt;Free&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://itunes.apple.com/app/colorsnapper/id418176775&quot;&gt; ColorSnapper &lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Color picker&lt;/td&gt;
      &lt;td&gt;Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://itunes.apple.com/au/app/1password-password-manager/id443987910&quot;&gt;1Password&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Password manager&lt;/td&gt;
      &lt;td&gt;Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.dropbox.com/&quot;&gt;Dropbox&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;File hosting service&lt;/td&gt;
      &lt;td&gt;Free / Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.code42.com/crashplan/&quot;&gt;CrashPlan&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Online data backup in real time&lt;/td&gt;
      &lt;td&gt;Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://spectacleapp.com/&quot;&gt;Spectacle&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Window control&lt;/td&gt;
      &lt;td&gt;Free / Open source&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://itunes.apple.com/au/app/evernote/id406056744&quot;&gt;Evernote&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Although Evernote is great, I don't use this icon at all.When I close it, it returns automatically &amp;macr;\_(ツ)_/&amp;macr;&lt;/td&gt;
      &lt;td&gt;Free / Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.google.com/intl/en-AU/chrome/browser/&quot;&gt;Chrome notifications&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;I never really use it, but I guess there's no way to remove it though&lt;/td&gt;
      &lt;td&gt;Free&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://smilesoftware.com/TextExpander/index.html&quot;&gt;Text Expander&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Custom keyboard shortcuts into frequently-used texts&lt;/td&gt;
      &lt;td&gt;Paid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://www.apple.com/airplay/&quot;&gt;AirPlay&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Play content on your TV via Apple TV&lt;/td&gt;
      &lt;td&gt;Free&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.apple.com/au/support/timemachine/&quot;&gt;Time Machine&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Built-in backup feature of macOS that works with an external HD or Time Capsule&lt;/td&gt;
      &lt;td&gt;Free&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
</description>
      

      <pubDate>Sun, 10 Aug 2014 20:56:30 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2014/08/10/what-do-i-have-on-my-macos-menu-bar/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2014/08/10/what-do-i-have-on-my-macos-menu-bar/</guid>
    </item>
    
    <item>
      <title>An awesome Wiki built with Ruby and Rails! </title>

      
        <description>&lt;p&gt;I’ve been worked on a small open-source project.
I’m talking about &lt;a href=&quot;https://github.com/lucascaton/ruby_wiki&quot;&gt;ruby_wiki&lt;/a&gt;, a simple wiki built with Ruby on Rails:&lt;/p&gt;

&lt;p&gt;If you’re interested, feel free to fork and contribute to the project.&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/1.png&quot; alt=&quot;1&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/2.png&quot; alt=&quot;2&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/3.png&quot; alt=&quot;3&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/4.png&quot; alt=&quot;4&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/5.png&quot; alt=&quot;5&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/04/6.png&quot; alt=&quot;6&quot; /&gt;&lt;/p&gt;
</description>
      

      <pubDate>Sat, 05 Apr 2014 04:14:53 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2014/04/05/an-awesome-wiki-built-with-ruby-and-rails/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2014/04/05/an-awesome-wiki-built-with-ruby-and-rails/</guid>
    </item>
    
    <item>
      <title>Have a Rails 2 app? You can run it on the newest Ruby!</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2014/02/old_rails_with_new_ruby.png&quot; alt=&quot;old_rails_with_new_ruby-1024x641&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Do you have a legacy Rails application which is still running on Rails 2?&lt;/p&gt;

&lt;p&gt;There are several reasons to migrate your application to new Rails versions, like to improve the security, to be able to use a better syntax, to take advantage of new features and also because most of current gems will only work on Rails 3 or higher. However, sometimes it’s hard to do that, especially for big projects. And certainly today there’re many project still running on Rails 2.&lt;/p&gt;

&lt;p&gt;But there’s one good thing you can (and should) do! I’m talking about to use the newest Ruby version. Yes, I’m serious. When I wrote this post, the current Ruby version was &lt;a href=&quot;https://www.ruby-lang.org/en/news/2014/02/24/ruby-2-1-1-is-released/&quot; target=&quot;_blank&quot;&gt;2.1.1&lt;/a&gt; - and it’s not so hard to get it working fine with Rails 2.&lt;/p&gt;

&lt;p&gt;Obviously, would be better if you have a good test coverage.&lt;/p&gt;

&lt;p&gt;That said, let’s do it in a few steps:&lt;/p&gt;

&lt;h2 id=&quot;replacements&quot;&gt;Replacements&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Gemfile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rails 2 apps don’t use Bundler by default, so if you don’t have Bundler managing your gems yet, you should &lt;a href=&quot;http://bundler.io/v1.3/rails23.html&quot; target=&quot;_blank&quot;&gt;check here&lt;/a&gt; how to do that.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## There's no way to ensure that the next Ruby versions will work,&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## but so far the current one works fine:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ruby&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'2.1.1'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## The same for rake:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rake&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'10.1.1'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## You might need the iconv gem:&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'iconv'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Rakefile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## Replace:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## require 'rake/rdoctask'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## with:&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rake/task'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config.ru&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## Replace:&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## require 'config/environment'&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## with:&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&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;dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;__FILE__&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;s1&quot;&gt;'/config/environment'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;FasterCSV&lt;/code&gt; ➙ &lt;code class=&quot;highlighter-rouge&quot;&gt;CSV&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Replace all &lt;code class=&quot;highlighter-rouge&quot;&gt;FasterCSV&lt;/code&gt; constants with &lt;code class=&quot;highlighter-rouge&quot;&gt;CSV&lt;/code&gt;.
Also, include &lt;code class=&quot;highlighter-rouge&quot;&gt;require 'csv'&lt;/code&gt; to relevant files (or include the &lt;code class=&quot;highlighter-rouge&quot;&gt;require&lt;/code&gt; to your &lt;code class=&quot;highlighter-rouge&quot;&gt;config/environment.rb&lt;/code&gt; file).&lt;/p&gt;

&lt;h2 id=&quot;inclusions&quot;&gt;Inclusions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/environment.rb&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## Include this before the `Rails::Initializer.run` line:&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RUBY_VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'2.0.0'&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Gem&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;source_index&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;sources&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;cache&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;sources&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;SourceIndex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Specification&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SourceList&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;# If you want vendor gems, this is where to start writing code.&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;search&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;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&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;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&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;kp&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Enumerable&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/initializers/paperclip.rb&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## The patches below are needed when using an old version of PaperClip + Ruby 2.x&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## https://github.com/thoughtbot/paperclip/issues/262&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## https://github.com/thoughtbot/paperclip/commit/1bcfc14388d0651c5fc70ab9ca3511144c698903&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Paperclip&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Tempfile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Tempfile&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;make_tmpname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;extension&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;extname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;nb&quot;&gt;sprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'%s,%d,%d%s'&lt;/span&gt;&lt;span class=&quot;p&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;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;basename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;vg&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extension&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;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;IOStream&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;to_tempfile&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;respond_to?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:original_filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;original_filename&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;respond_to?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'stream'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tempfile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Tempfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'stream'&lt;/span&gt;&lt;span class=&quot;p&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;extname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tempfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;binmode&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;stream_to&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tempfile&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;new-files&quot;&gt;New files&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/initializers/ruby2.rb&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## This is a very important monkey patch to make Rails 2.3.18 to work with Ruby 2+&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## If you're thinking to remove it, really, don't, unless you know what you're doing.&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&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;VERSION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;MAJOR&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RUBY_VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'2.0.0'&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ActiveRecord&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Associations&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AssociationProxy&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;method&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;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;proxy_respond_to?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;super&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;load_target&lt;/span&gt;
            &lt;span class=&quot;vi&quot;&gt;@target&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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;method&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;n&quot;&gt;args&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;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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;config/initializers/rails_generators.rb&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’ll prevent Rails migration generator from stop working, otherwise you’ll receive the following error message:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;undefined&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;variable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`vars' for # Rails::Generator::Commands::Create
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(Thanks to &lt;a href=&quot;https://disqus.com/by/disqus_J5madOMsmT/&quot; target=&quot;_blank&quot;&gt;Mr. S&lt;/a&gt; and &lt;a href=&quot;https://disqus.com/by/jnwheeler44/&quot; target=&quot;_blank&quot;&gt;jnwheeler44&lt;/a&gt; for helping me to fix this one)&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;## This is a very important monkey patch to make Rails 2.3.18 to work with Ruby 2+&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## If you're thinking to remove it, really, don't, unless you know what you're doing.&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&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;VERSION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;MAJOR&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;RUBY_VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'2.0.0'&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rails_generator'&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rails_generator/scripts/generate'&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;Generator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;class_eval&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;relative_source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;relative_destination&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template_options&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;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;relative_source&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;relative_destination&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template_options&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;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# Evaluate any assignments in a temporary, throwaway binding&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;vars&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template_options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:assigns&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;p&quot;&gt;{}&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template_options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:binding&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;nb&quot;&gt;binding&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# this no longer works, eval throws &quot;undefined local variable or method `vars'&quot;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# vars.each { |k, v| eval &quot;#{k} = vars[:#{k}] || vars['#{k}']&quot;, b }&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;vars&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;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;local_variable_set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Render the source file with the temporary binding&lt;/span&gt;
        &lt;span class=&quot;no&quot;&gt;ERB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&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;kp&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'-'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&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;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;rspec&quot;&gt;RSpec&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Make sure you’re using the last compatible version with &lt;code class=&quot;highlighter-rouge&quot;&gt;Rails 2.3.18&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rspec'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'1.3.2'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'rspec-rails'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'1.3.4'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Remove the file &lt;code class=&quot;highlighter-rouge&quot;&gt;script/spec&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Remove the following lines from the &lt;code class=&quot;highlighter-rouge&quot;&gt;lib/tasks/rspec.rake&lt;/code&gt; file:&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;```ruby
gem ‘test-unit’, ‘1.2.3’ if RUBY_VERSION.to_f &amp;gt;= 1.9&lt;/p&gt;

&lt;p&gt;rspec_gem_dir = nil&lt;/p&gt;

&lt;p&gt;Dir[”#{Rails.root}/vendor/gems/*”].each do |subdir|
  rspec_gem_dir = subdir if subdir.gsub(“#{Rails.root}/vendor/gems/”,””) =~ /^(\w+-)?rspec-(\d+)/ &amp;amp;&amp;amp; File.exist?(“#{subdir}/lib/spec/rake/spectask.rb”)
end&lt;/p&gt;

&lt;p&gt;rspec_plugin_dir = File.expand_path(File.dirname(&lt;strong&gt;FILE&lt;/strong&gt;) + ‘/../../vendor/plugins/rspec’)&lt;/p&gt;

&lt;p&gt;if rspec_gem_dir &amp;amp;&amp;amp; (test ?d, rspec_plugin_dir)
  raise “\n#{‘&lt;em&gt;‘&lt;/em&gt;50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{‘&lt;em&gt;‘&lt;/em&gt;50}&lt;/p&gt;

</description>
      

      <pubDate>Fri, 28 Feb 2014 10:36:17 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2014/02/28/have-a-rails-2-app-you-can-run-it-on-the-newest-ruby/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2014/02/28/have-a-rails-2-app-you-can-run-it-on-the-newest-ruby/</guid>
    </item>
    
    <item>
      <title>Interesting script written in Ruby: &quot;The Globe&quot;</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2013/04/the-globe.gif&quot; alt=&quot;The Globe&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ve just found this amazing Ruby script!&lt;/p&gt;

&lt;p&gt;In order to run it yourself, just create a Ruby file called &lt;code class=&quot;highlighter-rouge&quot;&gt;a.rb&lt;/code&gt; with the following content:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mo&quot;&gt;0000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;vg&quot;&gt;$s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sx&quot;&gt;%q~d=%!^Lcf&amp;lt;LK8,                  _@7gj*LJ=c5nM)Tp1g0%Xv.,S[&amp;lt;&amp;gt;YoP
4ZojjV)O&amp;gt;qIH1/n[|2yE[&amp;gt;:ieC       &quot;%.#%  :::##&quot;       97N-A&amp;amp;Kj_K_&amp;gt;&amp;lt;wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B     &quot;##%      ::##########&quot;     O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^&amp;lt;IiQ=5$'D-y?    &quot;##:         ###############&quot;    g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W    &quot;#            #.   .####:#######&quot;    lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB&amp;lt;.   &quot;              ##### # :############&quot;   R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5   &quot;              #######################&quot;   00x8RR%`Om7VDp4M5
PFixrPvl&amp;amp;&amp;lt;p[]1IJ   &quot;              ############:####  %#####&quot;   EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q   &quot;              .#############:##%   .##  .&quot;   /,}.YOIFj(k&amp;amp;q_V
zcaAi?]^lCVYp!;  &quot; %%            .################.     #.   &quot;  ;s=&quot;v=%04o;ev&quot;%
(;v=(v-($*+[45,  &quot;:####:          :##############%       :   &quot;  ])[n=0].to_i;)%
360)+&quot;al$s=%q#{  &quot;%######.              #########            &quot;  ;;&quot;%c&quot;%126+$s&amp;lt;&amp;lt;
126}&quot;;d.gsub!(/  &quot;##########.           #######%             &quot;  |\s|&quot;.*&quot;/,&quot;&quot;);;
require&quot;zlib&quot;||  &quot;###########           :######.             &quot;  ;d=d.unpack&quot;C*&quot;
d.map{|c|n=(n||  &quot;:#########:           .######: .           &quot;  )*90+(c-2)%91};
e=[&quot;%x&quot;%n].pack   &quot; :#######%           :###### #:          &quot;   &amp;amp;&amp;amp;&quot;H*&quot;;e=Zlib::
Inflate.inflate(   &quot;  ######%           .####% ::          &quot;   &amp;amp;&amp;amp;e).unpack(&quot;b*&quot;
)[0];22.times{|y|   &quot;  ####%             %###             &quot;   ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(;   &quot; .###:             .#%             &quot;   ;2))*23).floor;(w*
2-1).times{|x|u=(e+    &quot; %##                           &quot;    )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[(    &quot; #.                        &quot;    ;y*80)+120-w+x]=(&quot;&quot;&amp;lt;&amp;lt;
32&amp;lt;&amp;lt;&quot;.:%#&quot;)[4*u.count((     &quot; .                   &quot;     ;&quot;0&quot;))/u.size]}};;puts\
s+&quot;;_ The Qlobe#{&quot; &quot;*18+ (       &quot;#  :#######&quot;       ;&quot;Copyright(C).Yusuke End\
oh, 2010&quot;)}&quot;;exit~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;The&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Qlobe&lt;/span&gt;                  &lt;span class=&quot;no&quot;&gt;Copyright&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;C&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;Yusuke&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Endoh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2010&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, run the following line on your terminal:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;clear&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; ruby a.rb | &lt;span class=&quot;nb&quot;&gt;tee &lt;/span&gt;b.rb&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;0.2&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; b.rb a.rb&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Via &lt;a href=&quot;http://d.hatena.ne.jp/ku-ma-me/20100905/p1&quot;&gt;d.hatena.ne.jp&lt;/a&gt;&lt;/p&gt;
</description>
      

      <pubDate>Fri, 19 Apr 2013 20:35:03 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2013/04/19/interesting-script-written-in-ruby-the-globe/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2013/04/19/interesting-script-written-in-ruby-the-globe/</guid>
    </item>
    
    <item>
      <title>Hellо, I am a compiler</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2013/02/robot.jpg&quot; alt=&quot;robot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I’ve found the following text &lt;a href=&quot;http://stackoverflow.com/questions/2684364/why-arent-programs-written-in-assembly-more-often/2685541#2685541&quot;&gt;here&lt;/a&gt;
and thought it’d be nice to share it with you. Hope you enjoy it as much as I did :)&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Hellо, I am a compiler.&lt;/p&gt;

  &lt;p&gt;I just scanned thousands of lines of code while you were reading this sentence. I browsed through millions of possibilities of optimizing a single line of yours using hundreds of different optimization techniques based on a vast amount of academic research that you would spend years getting at. I won’t feel any embarrassment, not even a slight ick, when I convert a three-line loop to thousands of instructions just to make it faster. I have no shame to go to great lengths of optimization or to do the dirtiest tricks. And if you don’t want me to, maybe for a day or two, I’ll behave and do it the way you like. I can transform the methods I’m using whenever you want, without even changing a single line of your code. I can even show you how your code would look in assembly, on different processor architectures and different operating systems and in different assembly conventions if you’d like. Yes, all in seconds. Because, you know, I can; and you know, you can’t.&lt;/p&gt;

  &lt;p&gt;P.S. Oh, by the way you weren’t using half of the code you wrote. I did you a favor and threw it away.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
      

      <pubDate>Sat, 23 Feb 2013 11:37:55 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2013/02/23/hello-i-am-a-compiler/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2013/02/23/hello-i-am-a-compiler/</guid>
    </item>
    
    <item>
      <title>Getting root permission to change a file without leaving Vim</title>

      
        <description>&lt;p&gt;You know when you open a file on &lt;strong&gt;Vim&lt;/strong&gt; and after some changes you realise you’d need &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; permission to save the changes?&lt;/p&gt;

&lt;p&gt;I used to think that there isn’t other way other than:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Copy the content of the file&lt;/li&gt;
  &lt;li&gt;Close Vim&lt;/li&gt;
  &lt;li&gt;Re-open it with &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;And finally paste it again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It might be a bit harder if you’re using Vim on a remote SSH session.&lt;/p&gt;

&lt;p&gt;Well, it will no longer be a problem. Today I learned a neat way to achive the same thing:&lt;/p&gt;

&lt;div class=&quot;language-viml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;w&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!&lt;/span&gt;sudo tee %
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Thanks my friend &lt;a href=&quot;https://twitter.com/dlisboa&quot;&gt;Diogo Lisboa&lt;/a&gt; for the tip.&lt;/p&gt;
</description>
      

      <pubDate>Fri, 22 Feb 2013 15:33:41 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2013/02/22/getting-root-permissions-on-a-file-inside-of-vim/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2013/02/22/getting-root-permissions-on-a-file-inside-of-vim/</guid>
    </item>
    
    <item>
      <title>A simple way to deploy your Rails applications</title>

      
        <description>&lt;p&gt;When I have a very simple Rails app, I avoid adding &lt;a href=&quot;https://github.com/capistrano/capistrano&quot;&gt;Capistrano&lt;/a&gt; or any other complex tool to deploy it.&lt;/p&gt;

&lt;p&gt;Instead, I use a simple shell script, which access the server via SHH and do what needs to be done:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#! /bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# script/deploy.sh&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;TAG&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;deployed_at_&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +&lt;span class=&quot;s2&quot;&gt;&quot;%F_%H-%M&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;

git tag &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;''&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$TAG&lt;/span&gt;
git push &lt;span class=&quot;nt&quot;&gt;--tags&lt;/span&gt;

ssh user@your_domain.com &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SSH&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;'
  cd /var/rails_apps/my_app
  rm -rf public/assets
  git pull
  bundle install --without development test
  bundle exec rake db:migrate db:seed assets:clean assets:precompile
  touch tmp/restart.txt
  git describe &amp;gt; public/version
&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SSH
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After that, a tag will be created in the git repository.
Now, you know exactly the date and time when it was deployed.&lt;/p&gt;

&lt;p&gt;Also, you can find out which version (tag from git) is in production by accessing the URL http://your_domain.com/version.&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2013/01/your_domain.png&quot; alt=&quot;your_domain&quot; /&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;update-from-march-8-2013&quot;&gt;Update from March 8, 2013:&lt;/h3&gt;

&lt;p&gt;I’ve created another script which accepts a &lt;code class=&quot;highlighter-rouge&quot;&gt;-q&lt;/code&gt; (quick) flag:&lt;/p&gt;

&lt;p&gt;```sh
#! /bin/bash&lt;/p&gt;
&lt;h1 id=&quot;scriptdeploysh&quot;&gt;script/deploy.sh&lt;/h1&gt;

&lt;p&gt;create_tag(){
  TAG=deployed_at_$(date +”%F_%H-%M”)&lt;/p&gt;

&lt;p&gt;git tag -m ‘’ -a $TAG
  git push –tags
}&lt;/p&gt;

&lt;p&gt;quick_deploy(){
  echo ‘Starting quick deploy…’&lt;/p&gt;

&lt;p&gt;create_tag&lt;/p&gt;

&lt;p&gt;ssh yourserver.com « ‘SSH’
    cd /var/rails_apps/app_name
    git pull
    bundle install –without development test
    touch tmp/restart.txt
    git describe &amp;gt; public/version
SSH
}&lt;/p&gt;

&lt;p&gt;complete_deploy(){
  echo ‘Starting complete deploy…’&lt;/p&gt;

&lt;p&gt;create_tag&lt;/p&gt;

&lt;p&gt;ssh yourserver.com « ‘SSH’
    cd /var/rails_apps/app_name
    rm -rf public/assets
    git pull
    bundle install –without development test
    bundle exec rake db:migrate db:seed assets:clean assets:precompile
    touch tmp/restart.txt
    git describe &amp;gt; public/version
SSH
}&lt;/p&gt;

&lt;p&gt;if [ $1 ]; then
  if [ “$1” == ‘-q’ ] || [ “$1” == ‘–quick’ ]; then
    quick_deploy
  else
    echo -e ‘Usage: script/deploy [OPTIONS]&lt;/p&gt;

</description>
      

      <pubDate>Fri, 25 Jan 2013 19:24:40 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2013/01/25/a-simple-way-to-deploy-your-rails-applications/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2013/01/25/a-simple-way-to-deploy-your-rails-applications/</guid>
    </item>
    
    <item>
      <title>An easy way to split windows in Vim</title>

      
        <description>&lt;p&gt;There are several ways to split windows in &lt;strong&gt;Vim&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This one is now my favorite:&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2013/01/cell-division.png&quot; alt=&quot;cell-division&quot; /&gt;&lt;/p&gt;
</description>
      

      <pubDate>Thu, 03 Jan 2013 11:22:32 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2013/01/03/an-easy-way-to-split-windows-in-vim/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2013/01/03/an-easy-way-to-split-windows-in-vim/</guid>
    </item>
    
    <item>
      <title>New blog layout</title>

      
        <description>&lt;p&gt;I’ve finally changed my blog theme.&lt;/p&gt;

&lt;p&gt;This one is cleaner, I hope y’all enjoy it :)&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2012/10/Screen-Shot-2012-10-02-at-1.57.23-PM.png&quot; alt=&quot;Screen-Shot-2012-10-02-at-1.57.23-PM&quot; /&gt;&lt;/p&gt;
</description>
      

      <pubDate>Tue, 02 Oct 2012 14:08:09 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/10/02/new-blog-layout/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/10/02/new-blog-layout/</guid>
    </item>
    
    <item>
      <title>How to test ElasticSearch in a Rails application</title>

      
        <description>&lt;p&gt;When I started using ElasticSearch in my Rails applications, I had a problem to create separate indexes for the automated tests.&lt;/p&gt;

&lt;p&gt;The problem was: there is no way to create more than one database in ElasticSearch.
You can create different indexes, but no different databases.&lt;/p&gt;

&lt;p&gt;Even creating indexes with different names won’t solve the problem:
it’s necessary to configure our Rails models in order to work with a different index name when the tests are running.&lt;/p&gt;

&lt;p&gt;I’m using both &lt;a href=&quot;https://github.com/karmi/tire&quot; target=&quot;_blank&quot;&gt;tire&lt;/a&gt; and &lt;a href=&quot;http://relishapp.com/rspec&quot; target=&quot;_blank&quot;&gt;RSpec&lt;/a&gt; gems.
In this post, I’ll explain how to separate indexes for &lt;code class=&quot;highlighter-rouge&quot;&gt;development&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;test&lt;/code&gt; environments.&lt;/p&gt;

&lt;p&gt;First of all, I’ve included the code below in file &lt;code class=&quot;highlighter-rouge&quot;&gt;config/initializers/tire.rb&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;test?&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&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;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;parent_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;downcase&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;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;env&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;nf&quot;&gt;downcase&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;no&quot;&gt;Tire&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;index_prefix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prefix&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And I’ve manually set the index name in the model (assuming there is a &lt;code class=&quot;highlighter-rouge&quot;&gt;Movie&lt;/code&gt; model):&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;index_name&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;no&quot;&gt;Tire&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Search&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;index_prefix&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;movies&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Done! With that, the index name will be &lt;code class=&quot;highlighter-rouge&quot;&gt;movies&lt;/code&gt; in &lt;code class=&quot;highlighter-rouge&quot;&gt;development&lt;/code&gt; environment and  &lt;code class=&quot;highlighter-rouge&quot;&gt;appname_test_movies&lt;/code&gt; in &lt;code class=&quot;highlighter-rouge&quot;&gt;test&lt;/code&gt; environment.&lt;/p&gt;

&lt;h2 id=&quot;deleting-test-indexes&quot;&gt;Deleting test indexes&lt;/h2&gt;

&lt;p&gt;In order to delete the test indexes after the suite has finished running, just add the following code to file &lt;code class=&quot;highlighter-rouge&quot;&gt;spec/integration_helper.rb&lt;/code&gt; (or similar):&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;RSpec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&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;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;after&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;type: :request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;delete_movie_index&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And create a custom macro, which will delete the indexes:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;delete_movie_index&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Movie&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;delete&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;demo-app&quot;&gt;Demo app&lt;/h2&gt;

&lt;p&gt;I created a small application to demonstrate the technique explained in this post:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/lucascaton/elasticsearch_app_example&quot; target=&quot;_blank&quot;&gt;https://github.com/lucascaton/elasticsearch_app_example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope it helps!&lt;/p&gt;
</description>
      

      <pubDate>Wed, 01 Aug 2012 10:50:11 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/08/01/how-to-test-elasticsearch-in-a-rails-application/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/08/01/how-to-test-elasticsearch-in-a-rails-application/</guid>
    </item>
    
    <item>
      <title>Pair programming with tmux</title>

      
        <description>&lt;p&gt;Server:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmux &lt;span class=&quot;nt&quot;&gt;-2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; /tmp/pair new-session &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; PairProgramming
&lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;777 /tmp/pair
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Client:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tmux &lt;span class=&quot;nt&quot;&gt;-2&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-S&lt;/span&gt; /tmp/pair attach-session &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; PairProgramming
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
      

      <pubDate>Wed, 11 Jul 2012 17:39:00 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/07/11/pair-programming-with-tmux/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/07/11/pair-programming-with-tmux/</guid>
    </item>
    
    <item>
      <title>Replacing &quot;Selenium&quot; with &quot;Poltergeist&quot;</title>

      
        <description>&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/images/2012/06/Poltergeist.jpg&quot; alt=&quot;Poltergeist&quot; /&gt;&lt;/p&gt;

&lt;p&gt;My friend &lt;a href=&quot;http://twitter.com/pellegrino&quot; target=&quot;_blank&quot;&gt;@pellegrino&lt;/a&gt; gave me an awesome tip: to replace &lt;a href=&quot;http://seleniumhq.org/&quot; target=&quot;_blank&quot;&gt;“Selenium”&lt;/a&gt; with &lt;a href=&quot;https://github.com/jonleighton/poltergeist&quot; target=&quot;_blank&quot;&gt;“Poltergeist”&lt;/a&gt;. For those who don’t know, &lt;strong&gt;Poltergeist&lt;/strong&gt; is a &lt;a href=&quot;http://phantomjs.org/&quot; target=&quot;_blank&quot;&gt;PhantomJS&lt;/a&gt; driver for Capybara. I’ve done it in some projects and it works very well!&lt;/p&gt;

&lt;p&gt;In order to do it, include the gem to your &lt;code class=&quot;highlighter-rouge&quot;&gt;Gemfile&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'poltergeist'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Update your Capybara configuration:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;Capybara&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&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;config&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# config.javascript_driver = :selenium&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;javascript_driver&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:poltergeist&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the specs!&lt;/p&gt;

&lt;p&gt;If you are testing some &lt;code class=&quot;highlighter-rouge&quot;&gt;confirm()&lt;/code&gt; JavaScript method and you have a code similar to &lt;code class=&quot;highlighter-rouge&quot;&gt;page.driver.browser.switch_to.alert.accept&lt;/code&gt;, you’ll get this error:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;undefined&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`switch_to'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;While I was trying to fix it, I &lt;a href=&quot;https://github.com/jonleighton/poltergeist/issues/80#issuecomment-6237980&quot; target=&quot;_blank&quot;&gt;found out&lt;/a&gt; that Poltergeist always returns &lt;code class=&quot;highlighter-rouge&quot;&gt;true&lt;/code&gt; from &lt;code class=&quot;highlighter-rouge&quot;&gt;window.confirm&lt;/code&gt;.
There’s no way (at the moment) to make it return &lt;code class=&quot;highlighter-rouge&quot;&gt;false&lt;/code&gt;, but at least it won’t prevent your test from passing: all I had to do was to remove that particular line and it solved the issue.&lt;/p&gt;

&lt;p&gt;This is the results from the first project I’ve migrated:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Before: &lt;code class=&quot;highlighter-rouge&quot;&gt;Finished in 1 minute 35.45 seconds&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;After: &lt;code class=&quot;highlighter-rouge&quot;&gt;Finished in 41.03 seconds&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope you find it helpful as I did!&lt;/p&gt;
</description>
      

      <pubDate>Thu, 14 Jun 2012 22:13:15 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/06/14/replacing-selenium-by-poltergeist/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/06/14/replacing-selenium-by-poltergeist/</guid>
    </item>
    
    <item>
      <title>My dotfiles</title>

      
        <description>&lt;p&gt;I’ve finally created a repository with my dotfiles.
&lt;strong&gt;Dotfiles&lt;/strong&gt; are configurations files, usually with their names beginning with a dot (hidden files) and located on your home folder (&lt;code class=&quot;highlighter-rouge&quot;&gt;~/&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;You can check it out here:
&lt;a href=&quot;https://github.com/lucascaton/dotfiles&quot;&gt;github.com/lucascaton/dotfiles&lt;/a&gt;&lt;/p&gt;
</description>
      

      <pubDate>Sun, 29 Apr 2012 22:11:02 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/04/29/my-dotfiles/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/04/29/my-dotfiles/</guid>
    </item>
    
    <item>
      <title>Regex to match Youtube URLs (using Ruby)</title>

      
        <description>&lt;p&gt;I’ve created a regular expression in order to match Youtube URLs.
As Youtube URLs starts with &lt;code class=&quot;highlighter-rouge&quot;&gt;https://youtube.com&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;https://youtu.be&lt;/code&gt;, the following regex solves the problem:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;sr&quot;&gt;/^(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?([\w-]{10,})/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This regex will match:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;https://youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://www.youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://www.youtube.com/watch?v=12345-67890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;https://www.youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://youtu.be/1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;https://youtu.be/1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://www.youtu.be/1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;https://www.youtu.be/1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;http://www.youtube.com/watch?v=1234567890&amp;amp;feature=context&amp;amp;context=G2de15aaFAAAAAAAAAAA&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;www.youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtube.com/watch?v=1234567890&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtu.be/1234567890&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it won’t match:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtube.com&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtube.com/&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtube.com/watch&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtube.com/watch/&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtu.be&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;youtu.be/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
      

      <pubDate>Tue, 10 Apr 2012 11:19:34 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2012/04/10/regex-to-match-youtube-urls-using-ruby/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2012/04/10/regex-to-match-youtube-urls-using-ruby/</guid>
    </item>
    
    <item>
      <title>How to remove several lines in the Vim editor using Regex</title>

      
        <description>&lt;p&gt;A quick tip for those who use Vim: if you need to remove several lines that match your regular expression, you can achive that by running&lt;/p&gt;

&lt;div class=&quot;language-viml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;g&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/pattern/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s say you want to remove the commented lines from the following file:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# This is a comment&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;foo&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# This is another comment&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;bar&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run &lt;code class=&quot;highlighter-rouge&quot;&gt;:g /^#.*/d&lt;/code&gt; and your code will become:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;foo&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;bar&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple, hey? :)&lt;/p&gt;
</description>
      

      <pubDate>Tue, 06 Sep 2011 10:31:28 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2011/09/06/how-to-remove-several-lines-in-the-vim-editor-using-regex/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2011/09/06/how-to-remove-several-lines-in-the-vim-editor-using-regex/</guid>
    </item>
    
    <item>
      <title>My new gem &quot;code2pdf&quot;</title>

      
        <description>&lt;p&gt;I’ve created a gem called &lt;a href=&quot;https://github.com/lucascaton/code2pdf&quot;&gt;&lt;strong&gt;code2pdf&lt;/strong&gt;&lt;/a&gt;,
which is a simple and open-source tool to convert your codebase to a PDF file.
It might be especially useful in case you need to register you software.&lt;/p&gt;

&lt;p&gt;In order to install it, just run:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;code2pdf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, open a terminal and run:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;code2pdf &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;project path] &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;blacklist file]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The blacklist file is optional and must be a YML file, similar to the following:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s&quot;&gt;:directories&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.git&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;log&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;public/system&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;spec&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;tmp&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;vendor&lt;/span&gt;

&lt;span class=&quot;s&quot;&gt;:files&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.DS_Store&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.gitignore&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;database.yml&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;favicon.ico&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can find more information (including a &lt;a href=&quot;https://github.com/lucascaton/code2pdf/raw/master/examples/example.pdf&quot;&gt;PDF output example&lt;/a&gt; in the repository:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/lucascaton/code2pdf&quot;&gt;github.com/lucascaton/code2pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please, let me know in the comments if you like it :)&lt;/p&gt;
</description>
      

      <pubDate>Thu, 02 Jun 2011 16:11:18 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2011/06/02/my-new-gem-code2pdf/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2011/06/02/my-new-gem-code2pdf/</guid>
    </item>
    
    <item>
      <title>My Vimfiles</title>

      
        <description>&lt;p&gt;&lt;strong&gt;Vimfiles&lt;/strong&gt; are configuration files for the &lt;strong&gt;Vim&lt;/strong&gt; editor.
It includes the &lt;strong&gt;editor preferences&lt;/strong&gt;, &lt;strong&gt;theme&lt;/strong&gt; (color scheme), &lt;strong&gt;fonts&lt;/strong&gt;, &lt;strong&gt;plugins&lt;/strong&gt;, &lt;strong&gt;custom functions&lt;/strong&gt;, and more.&lt;/p&gt;

&lt;p&gt;I’ve finally created my own from scrach, which you can find here:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/lucascaton/vimfiles&quot;&gt;github.com/lucascaton/vimfiles&lt;/a&gt;&lt;/p&gt;
</description>
      

      <pubDate>Tue, 24 May 2011 20:36:18 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2011/05/24/my-vimfiles/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2011/05/24/my-vimfiles/</guid>
    </item>
    
    <item>
      <title>How to test Rails mailers using RSpec</title>

      
        <description>&lt;p&gt;&lt;strong&gt;ActionMailer&lt;/strong&gt; module has been reconstructed in &lt;strong&gt;Rails 3&lt;/strong&gt; and mailers have their own subdirectory (&lt;strong&gt;app/mailers&lt;/strong&gt;) since then.&lt;/p&gt;

&lt;p&gt;This blog post will demostrate how to test them in &lt;strong&gt;Rails&lt;/strong&gt; using &lt;strong&gt;RSpec&lt;/strong&gt;. Assuming that we have a mailer like the following:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Notifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActionMailer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Base&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;from: &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'noreply@company.com'&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;instructions&lt;/span&gt;&lt;span class=&quot;p&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;vi&quot;&gt;@name&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;name&lt;/span&gt;
    &lt;span class=&quot;vi&quot;&gt;@confirmation_url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;confirmation_url&lt;/span&gt;&lt;span class=&quot;p&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;n&quot;&gt;mail&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;to: &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;email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;subject: &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Instructions'&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To send an email through a method from &lt;code class=&quot;highlighter-rouge&quot;&gt;User&lt;/code&gt; model:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;User&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;send_instructions&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Notifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;instructions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&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;deliver_now&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Before test it, make sure the &lt;strong&gt;config/environments/test.rb&lt;/strong&gt; file has the following configuration:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;Rails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;configure&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;action_mailer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;delivery_method&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:test&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It ensures that emails won’t be sent, but instead be stored on &lt;strong&gt;ActionMailer::Base.deliveries&lt;/strong&gt; array.&lt;/p&gt;

&lt;p&gt;So, in order to create the tests:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# spec/models/user_spec.rb&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;RSpec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&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;ss&quot;&gt;type: :model&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:user&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'sends an email'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;send_instructions&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;change&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ActionMailer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;deliveries&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;p&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# spec/mailers/notifier_spec.rb&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;RSpec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;describe&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Notifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;type: :mailer&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'instructions'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mock_model&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;ss&quot;&gt;name: &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Lucas'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;email: &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'lucas@email.com'&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;described_class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;instructions&lt;/span&gt;&lt;span class=&quot;p&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;deliver_now&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'renders the subject'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;subject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;eq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Instructions'&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;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'renders the receiver email'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;eq&lt;/span&gt;&lt;span class=&quot;p&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;email&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;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'renders the sender email'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;eq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'noreply@company.com'&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;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'assigns @name'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;encoded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&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;name&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;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'assigns @confirmation_url'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;encoded&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://aplication_url/&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;id&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/confirmation&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;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Rails allows you to create very comprehensive tests for mailers.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;
</description>
      

      <pubDate>Mon, 25 Oct 2010 19:19:04 +1000</pubDate>
      <link>https://www.lucascaton.com.br/2010/10/25/how-to-test-mailers-in-rails-with-rspec/</link>
      <guid isPermaLink='true'>https://www.lucascaton.com.br/2010/10/25/how-to-test-mailers-in-rails-with-rspec/</guid>
    </item>
    
  </channel>
</rss>
