<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Lucas Húngaro</title>
 <link href="http://lucashungaro.github.com/atom.xml" rel="self"/>
 <link href="http://lucashungaro.github.com/"/>
 <updated>2009-09-29T21:51:29-07:00</updated>
 <id>http://lucashungaro.github.com/</id>
 <author>
   <name>Lucas Húngaro</name>
   <email>lucashungaro@gmail.com</email>
 </author>

 
 <entry>
   <title>Testing time-dependent code with the time-warp Ruby gem</title>
   <link href="http://lucashungaro.github.com/tdd/2009/09/30/testing-time-dependent-code-with-time-warp-ruby-gem.html"/>
   <updated>2009-09-30T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/tdd/2009/09/30/testing-time-dependent-code-with-time-warp-ruby-gem</id>
   <content type="html">&lt;h1&gt;Testing time-dependent code with the time-warp Ruby gem&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;30 Sep 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;The need to &amp;#8220;manipulate time&amp;#8221; is common when we&amp;#8217;re specifying code whose behavior depends on exact moments in time.&lt;/p&gt;
&lt;p&gt;A viable technique is to stub Ruby&amp;#8217;s Time class and manipulate it according to our needs. This works, but personally I have a gut feeling that says to me that whenever I&amp;#8217;m doing this kind of thing on &amp;#8220;system code&amp;#8221;, very bad things can happen. Specifically, stubbing or mocking &amp;#8220;internal&amp;#8221; classes may lead to obscure and hard to track bugs.&lt;/p&gt;
&lt;p&gt;Luckily, there is a neat Ruby gem called &lt;a target=&quot;_blank&quot; href=&quot;http://github.com/iridesco/time-warp/tree/master&quot;&gt;time-warp&lt;/a&gt;. It provides a layer over Ruby&amp;#8217;s time-related classes that allow us to control the clock inside a code block. Here&amp;#8217;s an example from our &lt;a target=&quot;_blank&quot; href=&quot;http://twtapp.info/&quot;&gt;Rails Rumble application&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;should only silence tweets with the desired word inside the configured time interval&amp;quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;pretend_now_is&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Time&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;utc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;beginning_of_day&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hour&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;n&quot;&gt;tweet1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sent_at&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;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;minutes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ago&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tweet2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sent_at&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;minutes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_now&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;tweet3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sent_at&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hour&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_now&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;collection&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;n&quot;&gt;tweet1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tweet2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tweet3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

    &lt;span class=&quot;no&quot;&gt;Silencer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&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;ss&quot;&gt;:word&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;soccer&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:until&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;minutes&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_now&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;tweet1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be_filtered&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;tweet2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be_filtered&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;tweet3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;should_not&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be_filtered&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The gem adds the method pretend_now_is, that receives the desired time as a parameter and a block. Inside this block, all code executed &amp;#8220;travels in time&amp;#8221; to the defined moment. Besides being a more secure way of dealing with time classes, the code is way more elegant and readable.&lt;/p&gt;
&lt;p&gt;For more details, consult the &lt;a target=&quot;_blank&quot; href=&quot;http://github.com/iridesco/time-warp/blob/884623fec90687c7f3c28b8e8074a39c96946cbb/README.md&quot;&gt;gem&amp;#8217;s &lt;span class=&quot;caps&quot;&gt;README&lt;/span&gt; file&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails Rumble 09 - the experience</title>
   <link href="http://lucashungaro.github.com/rails/2009/08/28/rails-rumble-the-experience.html"/>
   <updated>2009-08-28T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/rails/2009/08/28/rails-rumble-the-experience</id>
   <content type="html">&lt;h1&gt;Rails Rumble 09 &amp;#8211; the experience&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;28 Aug 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;Rails Rumble 2009 occurred this weekend and I have participated, together with &lt;a href=&quot;http://www.arthurgeek.net/&quot;&gt;ArthurGeek&lt;/a&gt; and &lt;a href=&quot;http://simplesideias.com.br/&quot;&gt;Nando Viera&lt;/a&gt;, of team Awesome.&lt;/p&gt;
&lt;p&gt;Our application is called &lt;a href=&quot;http://twtapp.info&quot;&gt;&lt;span class=&quot;caps&quot;&gt;TWT&lt;/span&gt;&lt;/a&gt; and here is its original description:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It&amp;#8217;s a Twitter web client that aims to provide a set of flexible filters so one can only receive tweets with real value, not random &amp;#8220;mundane&amp;#8221; ones that really drains time and attention.&lt;/p&gt;
&lt;p&gt;Among the filters we plan to do: mute (indefinitely and time based), by words (both &amp;#8220;don&amp;#8217;t show tweets with these words&amp;#8221; and &amp;#8220;show only tweets with these words&amp;#8221;) and &amp;#8220;valuable&amp;#8221; tweets (i.e. only tweets that have been re-tweeted at least 3 times by friends).&lt;/p&gt;
&lt;p&gt;It will be also an &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, so later on we can develop desktop and mobile clients&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Needless to say, there wasn&amp;#8217;t enough time to finish all that features, but the application is online with some basic ones (and some bugs too): &lt;a href=&quot;http://twtapp.info&quot;&gt;Twtapp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The weekend was fun and stressful. Here is the summary of the experience and some thoughts/tips:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Your app should be really small: seriously, &lt;strong&gt;really&lt;/strong&gt; small. My advice is that the entire application shoulb be ready by the end of the first 24 hours. The second day should be spent polishing the application, bug fixing and &amp;#8220;marketing&amp;#8221; aspects: a product tour, standard static pages (about, feedback), 404 and 500 pages, a screencast and so on;&lt;/li&gt;
	&lt;li&gt;The team should be &amp;#8220;physically together&amp;#8221;: remote work &lt;strong&gt;will&lt;/strong&gt; hurt the team&amp;#8217;s overall productivity;&lt;/li&gt;
	&lt;li&gt;Brainstorm and define the entire application before the Rumble starts: do not let doubts to be discussed during the competition. The team should know clearly what each member should do and exactly how the application behaves before start developing any code;&lt;/li&gt;
	&lt;li&gt;Sleep;&lt;/li&gt;
	&lt;li&gt;Don&amp;#8217;t do last minute changes: please, don&amp;#8217;t write any Ruby code during the Rumble&amp;#8217;s last hour. You can fix css, static text and images, but don&amp;#8217;t code anything;&lt;/li&gt;
	&lt;li&gt;Limit test/specs to the application&amp;#8217;s core: do not spend time writing specs for boilerplate code. Write only the specs for the critical parts of the application. During the Rumble the team shouldn&amp;#8217;t try new things, just use things all members know and work with daily &amp;#8211; this way you can let basic, well-know aspects, without specs;&lt;/li&gt;
	&lt;li&gt;Having a specialized web designer on the team will help as developers can focus the application core;&lt;/li&gt;
	&lt;li&gt;If a member decides to abandon the team hours before the competition starts, kill him/her. ;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We expect to continue to develop the application. Soon it will be the application we&amp;#8217;ve planned and we&amp;#8217;ll let you know.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Increasing your productivity by eliminating distractions</title>
   <link href="http://lucashungaro.github.com/productivity/2009/08/27/how-i-increased-my-productivity.html"/>
   <updated>2009-08-27T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/productivity/2009/08/27/how-i-increased-my-productivity</id>
   <content type="html">&lt;h1&gt;Increasing your productivity by eliminating distractions&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;27 Aug 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;(or: How I learned to stop worrying and unsubscribed from feeds)&lt;/p&gt;
&lt;p&gt;No, I&amp;#8217;m still not a super-hyper-productive person, but here&amp;#8217;s how I managed to increase my productivity using some tricks (and the awesome operational system that is Mac OS X with some wonderful applications on top of it):&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Don&amp;#8217;t check your e-mail more then four times a day: if you are expecting some important e-mail, ask the sender to alert you when he/she sends it &amp;#8211; using something like an &lt;span class=&quot;caps&quot;&gt;SMS&lt;/span&gt;;&lt;/li&gt;
	&lt;li&gt;Don&amp;#8217;t check your e-mails if you won&amp;#8217;t be able to act upon them immediately: an example is checking work e-mail on Friday afternoon, do it on the Monday;&lt;/li&gt;
	&lt;li&gt;Get rid of your feeds subscriptions: you won&amp;#8217;t miss something until you stay some time without it. If, after some days, you miss a feed, subscribe back to it, but don&amp;#8217;t check it more than once a day;&lt;/li&gt;
	&lt;li&gt;Let people be your filter: trust me, if something is really important (or banal, but  &amp;#8220;hot&amp;#8221;) it will get to you, you don&amp;#8217;t have to dig for it. The Google Reader shared items feature is awesome in this point, and I&amp;#8217;m on my way to start using only it, unsubscribing from every feed I currently subscribe to. If you need to find something, Google is your friend;&lt;/li&gt;
	&lt;li&gt;Disable unnecessary notifications: like the Growl ones or the &amp;#8220;red counters&amp;#8221; on app icons in the OS X Dock &amp;#8211; keep only the ones that you really want to be notified about (for example, I keep the Propane one, as knowing what my co-workers are saying on Campfire is important);&lt;/li&gt;
	&lt;li&gt;Don&amp;#8217;t use a monitor that is too large: it may sound weird, but some &lt;a href=&quot;http://lifehacker.com/367391/do-larger-monitors-make-you-more-productive&quot;&gt;research&lt;/a&gt; shows that after a size around 26-inch, user productivity starts to decrease. It&amp;#8217;s obvious: too much things in your visual field will distract you. Use Spaces and split screens by the kind of task you have to do (one for programming, one for internet browsing and so on);&lt;/li&gt;
	&lt;li&gt;Increase screen real estate and eliminate items from your desktop: configure Finder to don&amp;#8217;t show hard disks on the Desktop (I let only optical disks and removable devices appearing when connected). Eliminate from the Dock the apps you don&amp;#8217;t use very frequently. Use QuickSilver or something similar to reach the apps and files you don&amp;#8217;t use often, just don&amp;#8217;t let them pile up on your Dock or Desktop;&lt;/li&gt;
	&lt;li&gt;Eliminate fom the Menu Bar the items you don&amp;#8217;t need, like the Bluetooth status icon, the AM/PM indicator (it&amp;#8217;s ease to know that by looking outside your window), the Time Machine icon and so on;&lt;/li&gt;
	&lt;li&gt;Use &lt;a href=&quot;http://adium.im/&quot;&gt;Adium&lt;/a&gt; and configure it to be hidden unless it&amp;#8217;s the active application (see here: &lt;a href=&quot;http://yfrog.com/amactivep&quot;&gt;active&lt;/a&gt;, &lt;a href=&quot;http://yfrog.com/ajinactive2p&quot;&gt;inactive&lt;/a&gt;, &lt;a href=&quot;http://yfrog.com/e3picture2fuap&quot;&gt;settings 1&lt;/a&gt;, &lt;a href=&quot;http://yfrog.com/avpicture12xp&quot;&gt;settings 2&lt;/a&gt;);&lt;/li&gt;
	&lt;li&gt;Use &lt;a href=&quot;http://fluidapp.com/&quot;&gt;Fluid&lt;/a&gt; to create SSBs for the web applications you need to work: the reason behind this is to avoid having a &amp;#8220;full&amp;#8221; browser opened with a lot of tabs distracting you. With Fluid &amp;#8220;apps&amp;#8221; you can focus only on the task at hand;&lt;/li&gt;
	&lt;li&gt;Use &lt;a href=&quot;http://www.gravityapps.com/tags/&quot;&gt;Tags&lt;/a&gt; to ease the process of organizing and finding files.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some actions are really hard to take, like getting rid of your feed subscriptions &amp;#8211; especially because nerds/geeks usually are bragging about how many feed subscriptions they have. It&amp;#8217;s plain stupidity, like competing to see who &lt;a href=&quot;http://37signals.com/svn/posts/1006-sleep-deprivation-is-not-a-badge-of-honor&quot;&gt;stays up coding for more time and sleep less&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Anyway, give it a try. You will miss the things you really need (I recommend trying for at least 10 days) and can get them back anytime you want.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Firefox add-ons that I use and recommend</title>
   <link href="http://lucashungaro.github.com/firefox/2009/06/08/firefox-addons.html"/>
   <updated>2009-06-08T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/firefox/2009/06/08/firefox-addons</id>
   <content type="html">&lt;h1&gt;Firefox add-ons that I use and recommend&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;08 Jun 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;Even using just Macs I prefer Firefox to Safari (which I use through Fluid for some web apps) &amp;#8216;cause of it&amp;#8217;s great extensibility and variety of add-ons. Below is a list of the ones I use and recommend for web development and general internet surfing:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/1843&quot;&gt;Firebug&lt;/a&gt; &amp;#8211; you know it, it&amp;#8217;s obligatory (Safari 4&amp;#8217;s developer tools are great too);&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/5369&quot;&gt;YSlow&lt;/a&gt; &amp;#8211; brings to you Yahoo&amp;#8217;s performance guidelines for web pages;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://code.google.com/speed/page-speed/&quot;&gt;Page Speed&lt;/a&gt; &amp;#8211; a Firebug extension from Google similar to YSlow;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/6683&quot;&gt;Firecookie&lt;/a&gt; &amp;#8211; an extension to Firebug that allows you to view and manage cookie&amp;#8217;s contents;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/60&quot;&gt;Web Developer Toolbar&lt;/a&gt; &amp;#8211; a collection of nice tools for web development (like markup validation, browser window resizing, page elements manipulation and a lot of other tools);&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/9527&quot;&gt;Ubiquity&lt;/a&gt; &amp;#8211; many describe it as &lt;a href=&quot;http://is.gd/T4XW&quot;&gt;Spotlight&lt;/a&gt; for Firefox &amp;#8211; I agree;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/12006&quot;&gt;Wolfram Alpha Google&lt;/a&gt; &amp;#8211; integrates Google and Wolfram Alpha knowledge engine (really nice);&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/4810&quot;&gt;Speed Dial&lt;/a&gt; &amp;#8211; enables direct access to your favorite websites through Firefox&amp;#8217;s start page;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/26&quot;&gt;Download Statusbar&lt;/a&gt; &amp;#8211; less intrusive download management (think Google Chrome);&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/5081&quot;&gt;TwitterFox&lt;/a&gt; &amp;#8211; simple integrated Twitter client;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/4014&quot;&gt;Locationbar²&lt;/a&gt; &amp;#8211; enhance your browser&amp;#8217;s location bar (highlights domain name to prevent spoofing, linkifies &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; segments and other options).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What add-ons you like the most?&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Reclaiming disk space from MacPorts</title>
   <link href="http://lucashungaro.github.com/macports/2009/05/26/reclaiming-disk-space-from-macports.html"/>
   <updated>2009-05-26T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/macports/2009/05/26/reclaiming-disk-space-from-macports</id>
   <content type="html">&lt;h1&gt;Reclaiming disk space from MacPorts&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;26 May 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;I use and like MacPorts for some software that have a too cumbersome/bugged compilation process. Many people use it extensively and others just dislike and ignore it.&lt;/p&gt;
&lt;p&gt;A frequent complain about MacPorts is that it takes too much disk space (since it installs its own libraries instead of using the system ones). This is a valid concern and there&amp;#8217;s a way to mitigate it. MacPorts allows you to clear files used to build a port, namely work files, distribution files and archives. To remove all of them from all installed ports, execute the following command:&lt;/p&gt;
&lt;code&gt;
sudo port clean --all all
&lt;/code&gt;
&lt;p&gt;This will clean all kinds of file for all ports. The syntax is simple. Let&amp;#8217;s say you want to clear only work files from the port icu:&lt;/p&gt;
&lt;code&gt;
sudo port clean --work icu
&lt;/code&gt;
&lt;p&gt;More information can be obtained on the port command man files.&lt;/p&gt;
&lt;p&gt;Another thing you can do to reclaim some disk space is uninstall inactive ports:&lt;/p&gt;
&lt;code&gt;
sudo port uninstall inactive
&lt;/code&gt;
&lt;p&gt;These two commands worked very well for me, managing to reduce MacPorts directory (/opt/local/var/macports) size from 1.3 Gb to 730 Mb.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Read more&lt;/strong&gt;:&lt;/p&gt;
&lt;a href=&quot;http://spicycode.com/2009/05/17/sudo-port-install-turbo.html&quot;&gt;Speeding up port install&lt;/a&gt; &lt;br/&gt;
&lt;a href=&quot;http://spicycode.com/2009/02/23/cleaning-up-with-macports.html&quot;&gt;Keeping things clean when using MacPorts&lt;/a&gt;</content>
 </entry>
 
 <entry>
   <title>Over-mocking, over-stubbing and avoiding over-stubbing with Mocha</title>
   <link href="http://lucashungaro.github.com/tdd/2009/05/13/avoiding-over-stubbing-with-mocha.html"/>
   <updated>2009-05-13T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/tdd/2009/05/13/avoiding-over-stubbing-with-mocha</id>
   <content type="html">&lt;h1&gt;Over-mocking, over-stubbing and avoiding over-stubbing with Mocha&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;13 May 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not a &amp;#8220;fan&amp;#8221; of the way most of the developers community make use of mocks and stubs. In my humble opinion, it&amp;#8217;s a bad use of a very useful tool.&lt;/p&gt;
&lt;p&gt;With this kind of use some issues arise, like over-mocking and over-stubbing &amp;#8211; the overuse of mocks and stubs. Over-mocking makes your tests brittle, which means that they fail when you change the code even if there are no change on the behavior of the component under verification. Over-stubbing makes your tests weak, which means they pass even if they&amp;#8217;re unsynchronized with the code, verifying behavior that isn&amp;#8217;t real anymore.&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s an example of over-mocking:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110797.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Note that even &amp;#8220;setter&amp;#8221; methods are under expectations here. If you make a simple change on the implementation and, for example, one of these methods aren&amp;#8217;t called anymore, even if you don&amp;#8217;t change the behavior, the test will fail. This will end up happening anyway when you use mocks (that&amp;#8217;s why you need integration tests), but you can diminish the bad consequences.&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s an example of over-stubbing:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110799.js&quot;&gt;&lt;/script&gt;&lt;p&gt;With this approach you can end up with stubs of methods that no longer exists or even of objects that are no longer a dependency.&lt;/p&gt;
&lt;p&gt;The best way to avoid this issues is to learn from trying and studying but, if you use Mocha, you can configure it to help prevent over-stubbing through the class Configuration:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110802.js&quot;&gt;&lt;/script&gt;&lt;p&gt;In the above examples, when Mocha finds an &amp;#8220;improper&amp;#8221; use of stubs, it will throw an exception of the type Mocha::StubbingError. This occurs &amp;#8216;cause we&amp;#8217;ve made use of the method prevent. There are three levels of &amp;#8220;protection&amp;#8221;:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110804.js&quot;&gt;&lt;/script&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: of course, you shouldn&amp;#8217;t use this as a solution for problems with over-stubbing. I think this feature is a good help for teams learning to do &lt;span class=&quot;caps&quot;&gt;TDD&lt;/span&gt; or migrating from a &amp;#8220;isolationist&amp;#8221; style to a more traditional one.&lt;/p&gt;
&lt;p&gt;Read more:&lt;/p&gt;
&lt;a href=&quot;http://mocha.rubyforge.org/classes/Mocha/Configuration.html&quot;&gt;Mocha::Configuration RDoc&lt;/a&gt; &lt;br/&gt;
&lt;a href=&quot;http://blog.floehopper.org/articles/2009/02/09/mocha-configuration&quot;&gt;Mocha Configuration &amp;#8211; James Mead&lt;/a&gt;</content>
 </entry>
 
 <entry>
   <title>Tests should reveal code intent</title>
   <link href="http://lucashungaro.github.com/tdd/2009/05/12/tests-should-reveal-code-intent.html"/>
   <updated>2009-05-12T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/tdd/2009/05/12/tests-should-reveal-code-intent</id>
   <content type="html">&lt;h1&gt;Tests should reveal code intent&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;12 May 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;This is nothing new to anyone &amp;#8211; or, at least, it shouldn&amp;#8217;t be. However, it&amp;#8217;s much easier to say it than to do it for real.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s a really good thing that the testing mentality has spread around. This way many approaches to the practices of test driven development have been developed and improved. One good example are the testing frameworks. While they get more extensible and efficient by building cleaner beautiful DSLs, many people forget that, independently of the tool, of the syntax and of the technical approach being used, the intent of the written code is what really matters and has to be explicit.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: throughout this article I&amp;#8217;ll use the expression &amp;#8220;test driven development&amp;#8221;, but you can replace it with &amp;#8220;behavior driven development&amp;#8221; or with any similar approach.&lt;/p&gt;
&lt;h2&gt;What is code intention?&lt;/h2&gt;
&lt;p&gt;The code intention has much to do with something that has been extensively discussed: the software behavior. A definition of behavior is &amp;#8220;a system&amp;#8217;s observable response to stimulus&amp;#8221;. So we can say that what really matters is to verify if the observable response of a software component is the expected one, given one or more predefined stimulus.&lt;/p&gt;
&lt;p&gt;In some cases this means just to define a state, call some method and verify the result. In other cases, means to verify the effect propagation too (that&amp;#8217;s where mock objects are very useful). This depends on the component under development and on the approach you like the most.&lt;/p&gt;
&lt;h2&gt;How?&lt;/h2&gt;
&lt;p&gt;The question is: how tests help me to reveal code intent?&lt;/p&gt;
&lt;p&gt;If you write a lot of confuse code and, after that, write some tests to validate this work, these tests won&amp;#8217;t help on that goal. But, if you use tests to drive your implementation process, you will discover the fundamental role that they play on creating code that is clear and easy to understand, extend and modify. With a scenario specification (the predefined state where the stimulus will occur), it&amp;#8217;s much easier to design and verify the necessary behavior.&lt;/p&gt;
&lt;p&gt;Usually, when writing tests before the implementation, you get other benefits like: good naming, simplicity and code that&amp;#8217;s easy to refactor. All of this thanks to the fact that, by practicing test driven development, you effectively think more about what you&amp;#8217;re writing before you do it.&lt;/p&gt;
&lt;h2&gt;Example&lt;/h2&gt;
&lt;p&gt;I&amp;#8217;ll try to exemplify the steps to create a simple component with and without tests driving the implementation. This way, by the end, we&amp;#8217;ll have a better perspective of the effects of the process.&lt;/p&gt;
&lt;p&gt;So I want to write an application to catalog my movie collection. I need a class that represents the movie:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110560.js&quot;&gt;&lt;/script&gt;&lt;p&gt;That&amp;#8217;s enough for this example.&lt;/p&gt;
&lt;p&gt;Now let&amp;#8217;s start the implementation of the class responsible by the management of the collection. First, no tests.&lt;/p&gt;
&lt;p&gt;I know I need a class that have a list of movies and allows me to add, remove, seek and list all the movies. So we have:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110563.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Ok, that&amp;#8217;s simple and it&amp;#8217;s ready in two minutes. Let&amp;#8217;s use it (on irb):&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110567.js&quot;&gt;&lt;/script&gt;&lt;p&gt;It works and meets our requirements. But, the code isn&amp;#8217;t consistent. The movie collection (in practice, an instance of Array) is exposed and can be manipulated directly. This can be especially bad if some method of MovieShelf do some additional actions while operating the collection (like some logging when adding/removing a movie), &amp;#8216;cause it won&amp;#8217;t happen when we manipulate the collection directly. The naming isn&amp;#8217;t very clear too, among other small issues. I also don&amp;#8217;t like the way I&amp;#8217;m creating objects of the class Movie.&lt;/p&gt;
&lt;p&gt;Now, let&amp;#8217;s start with a bit of specification of what is needed. This way I&amp;#8217;ll have more time to think about good names and about a direct and clean way to use the code.&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110589.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Just by establishing this first expectation regarding the behavior of this component, we have the idea of a initial implementation:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110590.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Continuing:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110592.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Implementing:&lt;/p&gt;
&lt;script src=&quot;http://gist.github.com/110593.js&quot;&gt;&lt;/script&gt;&lt;p&gt;Of course this is a contrived and somewhat &amp;#8220;silly&amp;#8221; example, but note how the interface is way better now and also how we discover new functionalities in the process. This is one of the main advantages you get with test driven development: rich interfaces through code that is modular, flexible and have clear intent.&lt;/p&gt;
&lt;p&gt;I won&amp;#8217;t go on with the coding avoid a huge article. I believe I managed to expose the importance of clear code intent and how tests can help we reach this goal and obtain clear code.&lt;/p&gt;
&lt;p&gt;What do you thing about this subject? Give your opinion, comment, example, criticism or suggestion. :)&lt;/p&gt;
&lt;p&gt;Read more:&lt;/p&gt;
&lt;a href=&quot;http://www.informit.com/articles/article.aspx?p=357688&quot;&gt;Test Driven Development: Programming by Intention&lt;/a&gt; &lt;br/&gt;
&lt;a href=&quot;http://blog.aslakhellesoy.com/2006/12/11/the-bdd-cargo-cult&quot;&gt;The &lt;span class=&quot;caps&quot;&gt;BDD&lt;/span&gt; cargo culting&lt;/a&gt;</content>
 </entry>
 
 <entry>
   <title>Ready. Set. GO!</title>
   <link href="http://lucashungaro.github.com/blog/2009/05/10/ready-set-go.html"/>
   <updated>2009-05-10T00:00:00-07:00</updated>
   <id>http://lucashungaro.github.com/blog/2009/05/10/ready-set-go</id>
   <content type="html">&lt;h1&gt;Ready. Set. GO!&lt;/h1&gt;
&lt;p&gt;&lt;a href=&quot;#disqus_thread&quot;&gt;View Comments&lt;/a&gt;&lt;/p&gt;
&lt;p class=&quot;meta&quot;&gt;10 May 2009 &amp;#8211; São Paulo, SP &amp;#8211; Brazil&lt;/p&gt;
&lt;p&gt;Hello there! This is the first post of this blog.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve been blogging since 2007 in portuguese and now I think it&amp;#8217;s time to try to reach a wider public &amp;#8211; the developers from all around the world. This will help to learn more from comments and criticism and also help to improve my communication ability in english.&lt;/p&gt;
&lt;p&gt;Sometimes I&amp;#8217;ll cross-post translated articles on my blogs, but there will be &amp;#8220;exclusive&amp;#8221; content on both of them too.&lt;/p&gt;
&lt;p&gt;I like many facets of software development &amp;#8211; from agile methodologies and the human aspects of a knowledge based activity to frameworks and dynamic languages. My current main interest is &lt;span class=&quot;caps&quot;&gt;TDD&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;BDD&lt;/span&gt;, so you&amp;#8217;ll be reading many articles concerning this practice if you chose to follow me along. Thank you and welcome!&lt;/p&gt;
&lt;p&gt;Ready. Set. GO!&lt;/p&gt;</content>
 </entry>
 
 
</feed>