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

 <title>Developer Studies</title>
 <link href="http://fabioyamate.com/atom.xml" rel="self"/>
 <link href="http://fabioyamate.com/"/>
 <updated>2014-08-21T22:16:51-03:00</updated>
 <id>http://fabioyamate.com/</id>
 <author>
   <name>Fabio Yamate</name>
   <email>fabioyamate@gmail.com</email>
 </author>

 
 <entry>
   <title>Playing with Elixir streams in IEx</title>
   <link href="http://fabioyamate.com/2014/08/15/playing-with-elixir-streams-in-iex/"/>
   <updated>2014-08-15T00:31:17-03:00</updated>
   <id>http://fabioyamate.com/2014/08/15/playing-with-elixir-streams-in-iex</id>
   <content type="html">&lt;p&gt;Today I wanted to play with &lt;a href=&quot;http://elixir-lang.org/&quot;&gt;Elixir&lt;/a&gt; &lt;a href=&quot;http://elixir-lang.org/docs/stable/elixir/Stream.html&quot;&gt;Stream&lt;/a&gt; to mimic the ideas of Observable collections from the &lt;a href=&quot;http://msdn.microsoft.com/en-us/data/gg577609.aspx&quot;&gt;Rx&lt;/a&gt; (Reactive Extension) concepts. The best playground is the IEx, the interactive shell for Elixir. However, in order to achieve the results that I wanted there was a lot of details that you need to know before having fun with it.&lt;/p&gt;

&lt;p&gt;I&amp;#39;m glad that I had some help from &lt;a href=&quot;https://github.com/rcillo&quot;&gt;@rcillo&lt;/a&gt; a co-worker of mine that have been studying Elixir for quite some time. We paired to achieve the results that we wanted. It took just 10~15min to get the desired result.&lt;/p&gt;

&lt;p&gt;So what are we going to see in this posts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;running multiples shells&lt;/li&gt;
&lt;li&gt;naming process&lt;/li&gt;
&lt;li&gt;IO device&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, let&amp;#39;s start!&lt;/p&gt;

&lt;p&gt;Elixir version used 0.15.1&lt;/p&gt;

&lt;h2&gt;The Elixir stream code snippet&lt;/h2&gt;

&lt;p&gt;The concept that I wanted to try is use the &lt;code&gt;GenEvent&lt;/code&gt; stream support and the &lt;code&gt;for&lt;/code&gt; syntax. This is the snippet:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&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;GenEvent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_link&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&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;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Pretty simple. I&amp;#39;m not going to dig each line of the snippet, the basic idea is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;given a stream of events, for each event published I want to print it on the screen&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;Side note&lt;/h3&gt;

&lt;p&gt;(You can advance to the next section if you want)&lt;/p&gt;

&lt;p&gt;I&amp;#39;m passionate for new programming languages learning new ones is a way to always keep thinking different. The &lt;code&gt;for&lt;/code&gt; notation in Elixir is available in other languages. (Each have different details in implementation, but all proposes the same feature)&lt;/p&gt;

&lt;p&gt;Haskell have the do-notation and list-comprehension&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- list comprehension&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;&amp;lt;-&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;o&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In Scala we would have:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-scala&quot; data-lang=&quot;scala&quot;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And C# LINQ also supports it&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;doSomeComputation&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So, go check this stuff if you never saw them.&lt;/p&gt;

&lt;h3&gt;Running on IEx&lt;/h3&gt;

&lt;p&gt;So, to run the &lt;code&gt;IEx&lt;/code&gt; you just do&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt; iex&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then you can start writing Elixir code on it. So we the code that we want to test, but it didn&amp;#39;t worked as expected.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&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;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_link&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#PID&amp;lt;0.172.0&amp;gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;manager&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;nc&quot;&gt;GenEvent.Stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:infinity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&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;no&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:ack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:infinity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;BOOM&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;console&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;freezes&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Well, once you write the &lt;code&gt;for&lt;/code&gt; code, the console is blocked because the stream is infinity. The &lt;code&gt;&amp;lt;-&lt;/code&gt; notation can be considered as a generator. You can read it as &amp;quot;for each x generated by stream, do...&amp;quot;. We could stop it by stopping the &lt;code&gt;GenEvent&lt;/code&gt; process. But, how to do that if the console is blocked?&lt;/p&gt;

&lt;h2&gt;Spawning local shells&lt;/h2&gt;

&lt;p&gt;I didn&amp;#39;t know about it, but &lt;a href=&quot;https://github.com/rcillo&quot;&gt;@rcillo&lt;/a&gt; showed me some tricks. You can type the &lt;code&gt;C-g&lt;/code&gt; (control-g) and you will get a prompt where you can type some commands.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;User switch command&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt; --&amp;gt; h&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  c [nn]            - connect to job&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  i [nn]            - interrupt job&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  k [nn]            - kill job&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  j                 - list all jobs&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  s [shell]         - start local shell&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  r [node [shell]]  - start remote shell&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  q                 - quit erlang&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;  ? | h             - this message&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Type &lt;code&gt;h&lt;/code&gt; to get some helps. If you type &lt;code&gt;j&lt;/code&gt; you will get all shells running with its job number.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;--&amp;gt; j&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;   1  {erlang,apply,[#Fun&amp;lt;Elixir.IEx.CLI.0.105530432&amp;gt;,[]]}&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;   2  {&amp;#39;Elixir.IEx&amp;#39;,start,[]}&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;   3* {&amp;#39;Elixir.IEx&amp;#39;,start,[]}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With this you are able to switch between shells by using &lt;code&gt;c &amp;lt;job-number&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In order to spawn a new shell with IEx, you do:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;--&amp;gt; s &amp;#39;Elixir.IEx&amp;#39;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Note that it is with single quotes (double quotes will fail). In case the shell is seems not to be responsive, just hit ENTER and you it will show the &lt;code&gt;iex&amp;gt;&lt;/code&gt; prompt.&lt;/p&gt;

&lt;p&gt;So, now that you have two shells, you just go and try:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;hello world&amp;quot;&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;nc&quot;&gt;RuntimeError&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;undefined&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Well, it didn&amp;#39;t work. How can we fix this? We need to register the process with a name.&lt;/p&gt;

&lt;h2&gt;Registering processes&lt;/h2&gt;

&lt;p&gt;Erlang provides a &lt;code&gt;register/2&lt;/code&gt; method that allows you bind a PID process to a name, this way we will have access to it.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&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;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_link&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#PID&amp;lt;0.185.0&amp;gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;whereis&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#PID&amp;lt;0.185.0&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ok, now we are able to just &lt;code&gt;GenEvent.notify(:eventor, &amp;quot;Hello World&amp;quot;)&lt;/code&gt; from both shells.&lt;/p&gt;

&lt;p&gt;But, you just send &lt;code&gt;notify&lt;/code&gt; messages but nothing prints in the console. You might think that it will the test the shell that is listening for events, but it don&amp;#39;t. What is the problem? In order to print the texts in console there is the concept of devices in Erlang (that I will not discuss it here, because I don&amp;#39;t know anything about it). But, let&amp;#39;s think that it is similar to the STDOUT. The problem is that the shell with &lt;code&gt;for&lt;/code&gt; snippet is blocked, and the &lt;code&gt;IO.puts&lt;/code&gt; there can&amp;#39;t flush its content, and your second shell have a different &amp;quot;device&amp;quot;.&lt;/p&gt;

&lt;p&gt;We need to specify which device do we want the &lt;code&gt;IO.puts&lt;/code&gt; to print out.&lt;/p&gt;

&lt;h3&gt;Specifying the device where IO.puts prints out&lt;/h3&gt;

&lt;p&gt;If you check the &lt;code&gt;IO.puts&lt;/code&gt; doc you will see the following doc:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;device&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;\\&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_leader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So, we can specify the first argument the device that we want to output.&lt;/p&gt;

&lt;p&gt;Each shell, has its own &lt;code&gt;:erlang.group_leader()&lt;/code&gt;, what we will do is register the group_leader that we want the text to output.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:globalio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_leader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:globalio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Hello&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;World&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;So what we have to do is just rewrite the &lt;code&gt;for&lt;/code&gt; code with the following code:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:globalio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now, every &lt;code&gt;notify&lt;/code&gt; event that you send will be printed out on the console! Yay =)&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;We saw a lot of things, so let&amp;#39;s reproduce the steps in order. Considering the &lt;code&gt;iex(n)&amp;gt;&lt;/code&gt; to identify each shell.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-elixir&quot; data-lang=&quot;elixir&quot;&gt;&lt;span class=&quot;n&quot;&gt;iex&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;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&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;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_link&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#PID&amp;lt;0.185.0&amp;gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&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;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;Elixir.IEx&amp;#39;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:globalio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:erlang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_leader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;--&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&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;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;manager&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;nc&quot;&gt;GenEvent.Stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:infinity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&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;no&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;manager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:ack&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:infinity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&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;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;do&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;puts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:globalio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Type&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;--&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;iex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;GenEvent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;notify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:eventor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Hello&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;World&lt;/span&gt;
&lt;span class=&quot;ss&quot;&gt;:ok&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Ok, now you can keep exploring the Stream API in Elixir. Have fun!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Why you should know fold</title>
   <link href="http://fabioyamate.com/2013/11/07/why-you-should-know-fold/"/>
   <updated>2013-11-07T00:15:00-02:00</updated>
   <id>http://fabioyamate.com/2013/11/07/why-you-should-know-fold</id>
   <content type="html">&lt;p&gt;When you start with functional programming you will probably meet &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt; which are
pretty useful functions. &lt;code&gt;map&lt;/code&gt; is used to transform by applying a function over a structure. &lt;code&gt;filter&lt;/code&gt;
allows you to give a predicate (a function that returns a boolean). Let&amp;#39;s see an example written in
clojure:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map &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;nb&quot;&gt;* &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;%&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;filter &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;odd?&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;range &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; (2 4 6 8 10)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Writing map and filter in terms of fold.&lt;/h2&gt;

&lt;p&gt;A good exercise would be write both in terms of &lt;code&gt;fold&lt;/code&gt;. Before that, &lt;code&gt;fold&lt;/code&gt; is also know as &lt;code&gt;inject&lt;/code&gt;,
&lt;code&gt;reduce&lt;/code&gt;, &lt;code&gt;accumulator&lt;/code&gt; and maybe other names that I&amp;#39;m not aware of.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;reduce + &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;#39;&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;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; 6&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is the most trivial example. It could be represented as &lt;code&gt;(+ (+ 1 2) 3)&lt;/code&gt;, in this case we are
accumulating the sums of each element in the list.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coll&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;reverse &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;reduce &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fn &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;xs&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;x&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;cons &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We defined a &lt;code&gt;map&lt;/code&gt; function over collection using reduce. We apply &lt;code&gt;f&lt;/code&gt; to each element in the collection
and concatenate it into the accumulated list. We needed to use &lt;code&gt;reverse&lt;/code&gt; because the reduce reads
from left to write, and &lt;code&gt;cons&lt;/code&gt; created a linked list in reverse order, where the last element add
is the &lt;code&gt;head&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;a3&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;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;a2&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;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;a1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Writing filter is pretty simple:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;my-filter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coll&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;reverse &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;reduce &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fn &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;xs&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;x&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;if &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;x&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;cons &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                       &lt;span class=&quot;nv&quot;&gt;xs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Similar to &lt;code&gt;map&lt;/code&gt;, the difference is that we check if the element returns true from predicate function,
if so it adds to the accumulated list, otherwise ignore it, and return the current accumulated list.&lt;/p&gt;

&lt;h2&gt;Foldable type&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.haskell.org/&quot;&gt;Haskell&lt;/a&gt; has a Foldable type class which defines how a data structure can be folded. In the previous
example, I showed the list data structure, which is the most common one.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In functional programming, fold (or reduce) is a family of higher order functions that
process a data structure in some order and build a return value. - &lt;a href=&quot;http://www.haskell.org/haskellwiki/Fold&quot;&gt;Haskell Wiki&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And it has the following type class:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Foldable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;where&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;foldMap&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Monoid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;foldr&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;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;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Be calm, I&amp;#39;ll not dig deep into it here, because there a lot in just those 3 lines. Let&amp;#39;s look at
the interesting parts. It says that a foldable type needs to define &lt;code&gt;foldMap&lt;/code&gt; and &lt;code&gt;foldr&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So lets consider the scenario that we have a &lt;code&gt;Tree&lt;/code&gt; data structure, we could have operations to
map over it or filter for specific nodes. If we implement &lt;code&gt;Tree&lt;/code&gt; as foldable, we can have those functions!&lt;/p&gt;

&lt;p&gt;I&amp;#39;m oversimplfying things here. But my point here is that &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt; are not functions
applicable only to lists, we can have different data types that can be folded to produce a value.&lt;/p&gt;

&lt;p&gt;I hope that I was clear enough, I&amp;#39;m still digesting all these concepts and would like to share with
you.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The Identity function</title>
   <link href="http://fabioyamate.com/2013/10/26/the-identity-function/"/>
   <updated>2013-10-26T13:42:00-02:00</updated>
   <id>http://fabioyamate.com/2013/10/26/the-identity-function</id>
   <content type="html">&lt;p&gt;When you are not used to functional programming you may have seen that there is a function called
&lt;code&gt;identity&lt;/code&gt; which seems to be useless.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;f(x) = x
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Why would I use such a function?&lt;/p&gt;

&lt;p&gt;In functional programming, functions are first-class citizens, which means that they can be passed
as arguments and returned as value.&lt;/p&gt;

&lt;p&gt;Once you start to read about it you will face some type of functions called high order functions (HOFs),
which are functions that receives functions as arguments. This kind of functions improve its flexibility.&lt;/p&gt;

&lt;p&gt;I&amp;#39;ll use Javascript as a language to explain:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&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;// implementation&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;Paul&amp;#39;&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;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;John&amp;#39;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}],&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;o&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;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&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;// =&amp;gt; [{ name: &amp;#39;John&amp;#39; }, { name: &amp;#39;Paul&amp;#39; }]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ok, &lt;code&gt;sortBy&lt;/code&gt; is nice when you have a collection of complex object, where you want to specify the
property to sort by. But, simple collections of numbers and strings, we don&amp;#39;t need to pass this
function.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nx&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&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;nx&quot;&gt;identity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// =&amp;gt; [1, 2, 3]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So we could easily rewrite a &lt;code&gt;sort&lt;/code&gt; function that delegates to &lt;code&gt;sortBy&lt;/code&gt;, to avoid writting it every
time.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&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;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;identity&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;nx&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&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;</content>
 </entry>
 
 <entry>
   <title>Cracking my head with Clojure laziness</title>
   <link href="http://fabioyamate.com/2013/10/13/cracking-my-head-with-clojure-laziness/"/>
   <updated>2013-10-13T22:20:00-03:00</updated>
   <id>http://fabioyamate.com/2013/10/13/cracking-my-head-with-clojure-laziness</id>
   <content type="html">&lt;p&gt;Recently I was working in personal Clojure project. I&amp;#39;m aware of the laziness behaviour of Clojure,
and I love it. Even knowing it, some issues you will only realize when you first met it.&lt;/p&gt;

&lt;p&gt;Giving some context, my initial version was up and running, and I was very happy. After some days,
I decided to do some improvements on the code.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;do-something-strict&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;-&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;extract-contents&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;map &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;content-&amp;gt;data&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;remove &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;already-exist?&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;map &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;persist-data&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;do-final-thing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Everything was fine. So I started to some refactor. But the most innocent of the changes made my
code stop working.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;do-final-thing&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;c&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;debug&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Collection data: &amp;quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;do-final-thing&lt;/code&gt; did some debugging log, and I remove this line. Can you imagine what it caused?&lt;/p&gt;

&lt;p&gt;If you do the following snippet in REPL, you got:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;remove &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;odd?&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;range &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; (2 4 6 8)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But if you do:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;foo&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;map prn &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;range &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;bar&amp;quot;&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;foo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; &amp;quot;bar&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You will not see the prints on REPL. This is due to the laziness of &lt;code&gt;map&lt;/code&gt;. The same applies to
&lt;code&gt;remove&lt;/code&gt; and some other collection functions.&lt;/p&gt;

&lt;p&gt;When you run on the REPL it has to print the result of the function call, this is why &lt;code&gt;remove&lt;/code&gt;
example worked.&lt;/p&gt;

&lt;p&gt;This detail made me lost quite some time investigating it. How did I fix it?&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;defn &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;do-something-strict&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;let &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;contents&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;extract-contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;content-&amp;gt;data&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;contents&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nv&quot;&gt;newer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;remove &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;already-exist?&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;data&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;doall&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;persist-data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since I want the function eval all data, I had to use the &lt;code&gt;doall&lt;/code&gt;. My initial code only worked
because the &lt;code&gt;debug&lt;/code&gt; did eval the lazy collection.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Fixing website</title>
   <link href="http://fabioyamate.com/2013/10/13/fixing-website/"/>
   <updated>2013-10-13T22:18:00-03:00</updated>
   <id>http://fabioyamate.com/2013/10/13/fixing-website</id>
   <content type="html">&lt;p&gt;Since my migration to Octopress many links were broken and images. I&amp;#39;ve spent some time and fixed
all them. Sorry for taking so long.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Moving to Octopress</title>
   <link href="http://fabioyamate.com/2012/09/16/moving-to-octopress/"/>
   <updated>2012-09-16T10:12:00-03:00</updated>
   <id>http://fabioyamate.com/2012/09/16/moving-to-octopress</id>
   <content type="html">&lt;p&gt;It has been a long time since my last post. A great mark of one post per year in the last couple
years. Since then, I&amp;#39;ve learned a lot a things, and I hope to be able to get back with this blog and
start to share my thoughs and learns again.&lt;/p&gt;

&lt;p&gt;I&amp;#39;ve procastinated quite a bit to relauch the blog, because it took some time to migrate posts from
Wordpress to Octopress. Besides the tool to migrate, I wanted to normalize every post with inline
HTML to markdown, and also apply nome highlighted code.&lt;/p&gt;

&lt;p&gt;I already have some posts in mind, and hope to get back  as soon as possible.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Upgrading NPM 0.2.x to 1.0.x</title>
   <link href="http://fabioyamate.com/2011/05/02/upgrading-npm-0-2-x-to-1-0-x/"/>
   <updated>2011-05-02T12:06:39-03:00</updated>
   <id>http://fabioyamate.com/2011/05/02/upgrading-npm-0-2-x-to-1-0-x</id>
   <content type="html">&lt;p&gt;I&amp;#39;m gonna do quick post about migrating &lt;a href=&quot;http://npmjs.org/&quot; title=&quot;Node Package Manager&quot;&gt;NPM&lt;/a&gt; (Node Package Manager) from 0.2 to 1.0.x.
Basically, you can check this &lt;a href=&quot;http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/&quot; title=&quot;NPM 1.0 Global vs Local Instalation&quot;&gt;post&lt;/a&gt; for more information.&lt;/p&gt;

&lt;p&gt;So, since I started to play with Node.js you basically starts installing NPM, which allows you to
install libraries and manage them. So, with some libraries that I test, I usually do:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This command updates your installed libraries, but it doesn&amp;#39;t upgrades NPM. To upgrade your
installation you require to run this complex command:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; curl http://npmjs.org/install.sh &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It will notice you that your current libraries installed will be lost, and is advised you to backup
them, so you can reinstall it. And them, you are done. But, why NPM removes my current installed
libraries?&lt;/p&gt;

&lt;p&gt;NPM 1.0.x was mainly focused on path/managing your Node.js libraries in a better way, so it requires
that your libs be installed with these path changes, which can be local or global paths. In resume,
you can now install through:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm install &amp;lt;lib&amp;gt;
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm install &amp;lt;lib&amp;gt; -g
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The latter installs it globally, and usually installed at &lt;code&gt;/usr/local/lib/node_modules&lt;/code&gt;. For
development and deployment stuff, you would choose the first, since you will use it as libraries,
and require it at your projects. You will need it globally when it has a CLI (Command Line
Interpreter). When doing so, you get access to it, for example:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm install ender -g
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; which ender
&lt;span class=&quot;go&quot;&gt;/usr/local/bin/ender&amp;lt;/code&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But, if I wanna both locally and global, do I have to install it twice? The quick answers is, yes.
But NPM can do it more intelligent, so you don&amp;#39;t need to upgrade/manage it twice. NPM comes with
&lt;code&gt;link&lt;/code&gt; command that allows you to symlink global installs to your local installs. So, every time you
upgrade it globally you get your local also. So, you should be aware of this, since you don&amp;#39;t get a
&lt;code&gt;lib@version&lt;/code&gt; install, you will get &lt;code&gt;lib&lt;/code&gt; install, so it might broke your code, so use it with this
in mind.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; node install express -g
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; npm link express
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; ls -l ~/node_modules/
&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;...&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; express -&amp;gt; /usr/local/lib/node_modules/express&amp;lt;/code&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Doing this steps you can get back to work when upgrading your NPM installation. For more information
read Node.js &lt;a href=&quot;http://blog.nodejs.org/&quot; title=&quot;Node.js Blog&quot;&gt;blog&lt;/a&gt;, which has some posts related to NPM.&lt;/p&gt;

&lt;p&gt;This is my first post published in english, so there might be some english errors.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Homebrew the new package system!</title>
   <link href="http://fabioyamate.com/2010/01/01/homebrew-the-new-package-system/"/>
   <updated>2010-01-01T16:16:47-02:00</updated>
   <id>http://fabioyamate.com/2010/01/01/homebrew-the-new-package-system</id>
   <content type="html">&lt;p&gt;Como mencionei em meus posts anteriores, tenho deixado de usar o MacPorts como package manager. Além 
de eu já ter passado por alguns problemas com ele ao fazer build existem outros problemas relatados 
no github do projeto, vale a pena dar uma conferida. Assim, estou deixando de usar o MacPorts 
(apesar de não desinstalado ainda, já não tenho mais nada instalado via port).&lt;/p&gt;

&lt;p&gt;Bom, vou passar os passos que usei para ter o Homebrew funcionando no Mac OSX. Não sou dos mais 
experiêntes com *nix, ainda me perco em onde colocar cada coisa e desconheço boas práticas sobre 
isso. Infelizmente, não tive muita sorte em encontrar bons textos sobre isso, por isso fiz do meu 
jeito, baseando na instalação 3 (Gogolinux).&lt;/p&gt;

&lt;p&gt;Para obter a versão do Homebrew eu apenas criei um diretório Cellar no &lt;code&gt;/usr/local&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;sudo mkdir /usr/local/Cellar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora baixei a versão do github para este diretório&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;cd /usr/local/Cellar&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;sudo git clone git://github.com/mxcl/homebrew.git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim, teremos o projeto em &lt;code&gt;/usr/local/Cellar/homebrew&lt;/code&gt;. Se quiser fazer o primeiro teste, basta 
digitar&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar $ homebrew/bin/brew --prefix&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt; /usr/local/Cellar/homebrew
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ok, vemos que o brew já está ok, mas tive que digitar &lt;code&gt;homebrew/bin/brew&lt;/code&gt;, se digitar o comando 
&lt;code&gt;brew&lt;/code&gt;, tive como resposta&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew
&lt;span class=&quot;go&quot;&gt;-bash: brew: command not found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isso por que o comando brew não se encontra no &lt;code&gt;/usr/local/bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Ok, basta fazermos um link simbólico:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;cd /usr/local/bin&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/bin $ sudo ln -s /usr/local/Cellar/homebrew/bin/brew brew&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim, teremos um link simbólico para o brew. Note que é como o atalho do Windows, se eu mudar o 
&lt;code&gt;brew&lt;/code&gt; ele irá refletir no brew do bin. Digo isto por que no *nix podemos criar hard links que 
aponta para o arquivo físico, o que é diferente de link.&lt;/p&gt;

&lt;p&gt;Agora podemos testar digitando apensa:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew --prefix
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt; /usr/local
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Bom, eu no momento me sinto confortável em usar sudo para instalar, mas no site do projeto é 
sugerido em alterar os donos do diretório &lt;code&gt;/usr/local&lt;/code&gt; de root para o seu usuário, eliminando 
completamente a necessidade de digitar sudo. Talvez faça isto no futuro.&lt;/p&gt;

&lt;p&gt;Bom, teste simples&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo brew install wget

&lt;span class=&quot;go&quot;&gt;Warning: It appears you have Macports or Fink installed&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Although, unlikely, this can break builds or cause obscure runtime issues.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;If you experience problems try uninstalling these tools.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;==&amp;gt; Downloading http://ftp.gnu.org/gnu/wget/wget-1.12.tar.bz2&lt;/span&gt;
&lt;span class=&quot;gp&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;c&quot;&gt;####################################################################### 100.0%&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;==&amp;gt; ./configure --disable-debug --prefix=/usr/local/Cellar/wget/1.12&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;==&amp;gt; make install&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar/wget/1.12: 9 files, 784K, built in 31 seconds&lt;/span&gt;

&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; which wget
&lt;span class=&quot;gp&quot;&gt;&amp;gt;&lt;/span&gt; /usr/local/bin/wget
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora para vermos onde ele está instalado:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew list wget

&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar/wget/1.12/bin/wget&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar/wget/1.12/etc/wgetrc&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar/wget/1.12/share/info/ (2 files)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;/usr/local/Cellar/wget/1.12/share/man/man1/wget.1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Podemos ver que o wget foi instalado no &lt;code&gt;/usr/local/Cellar&lt;/code&gt; como queríamos. Quando precisarmos 
remover qualquer coisa instalada, basta removermos tudo que há no Cellar e os links simbólicos 
gerados automaticamente pelo brew (i.e. &lt;code&gt;/usr/local/bin/wget&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Qualquer sugestão ou correção me envie nos comentários.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Ruby gems no Snow Leopard</title>
   <link href="http://fabioyamate.com/2009/12/30/ruby-gems-no-snow-leopard/"/>
   <updated>2009-12-30T13:01:35-02:00</updated>
   <id>http://fabioyamate.com/2009/12/30/ruby-gems-no-snow-leopard</id>
   <content type="html">&lt;p&gt;Infelizmente, depois de fazer o upgrade para o Snow Leopard algumas gems pararam de funcionar, como por exemplo o Rails não consegui subir o servidor. Pesquisando pela internet, não consegui achar informações relevantes para o meu problema.&lt;/p&gt;

&lt;p&gt;Minha solução foi remover todas as gems que instalei desde que comecei com o Leopard, mas antes faça um backup da sua lista&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;gem list &amp;gt; gems_list_backup.txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim, você sabera todas as gems que tinha e versões.&lt;/p&gt;

&lt;p&gt;Agora é so fazer:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;sudo gem clean&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isso irá remover todas as gems que você instalou. Se você der um gem list, verá que existem algumas gems ainda instaladas. Estas gems são as versões que vem pré-instaladas com o Leopard. Você pode remover, mas eu optei por deixá-las. As gems pré-instaladas podem ser vistas usando o comando:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;gem list -d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora vá instalando uma a uma as gems e pronto, e tudo funcionará normalmente.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Snow Leopard para Desenvolvedores (Ruby)</title>
   <link href="http://fabioyamate.com/2009/12/30/snow-leopard-para-desenvolvedores-ruby/"/>
   <updated>2009-12-30T12:51:52-02:00</updated>
   <id>http://fabioyamate.com/2009/12/30/snow-leopard-para-desenvolvedores-ruby</id>
   <content type="html">&lt;p&gt;A primeira coisa para qualquer desenvolvedor fazer é instalar a nova versão do Xcode do Mac que vem junto ao DVD como Extras. Diferente de distros Linux como Ubuntu em que você usa o apt-get como package manager para instalar todas as libraries. Só que no Xcode ele instala várias libraries (atualizações) no Mac de uma vez. (Faça os Software Updates, sempre há)&lt;/p&gt;

&lt;p&gt;Quando comecei a usar o Mac OSX posso dizer que minha experiência com ambientes *nix era quase zero. Instalar libraries? src path? e etc é algo que o Windows nos protege. Esta ignorância acaba sendo uma porrada grande nos primeiros dias de uso de ambientes linux. O importante é que, para desenvolvedores o Terminal é seu amigo então aprenda! Posso dizer que não vivo mais sem ele.&lt;/p&gt;

&lt;p&gt;O gerenciador de pacotes mais comum é o Mac Ports, a primeira coisa que você tem que fazer é atualizá-lo. Só que, eu tive alguns problemas com ele para atualizar algumas gems. Primeiro, algumas libs tem de ser recompiladas para a nova arquitetura, que antes era apenas x86 e passaram a ser x86_64.&lt;/p&gt;

&lt;p&gt;Posso dizer que os melhores passos que fiz foi o deste wiki do ports para reinstalar as dependências. Acontece que eu sugiro que você remova completamente todas e esqueça do Mac Ports. Lendo em alguns posts da internet, é comum ver os problemas que o Mac Ports tem, como duplicação de bibliotecas entre outros. Quando tinha o Mac Ports ele não conseguia recompilar algumas gems do ruby, como curb, após remover todas, ele passou a usar o do Mac, que vem com o Xcode, e foi uma beleza.&lt;/p&gt;

&lt;p&gt;Acho que depois que passei a usar apenas as libs do Xcode não tive problemas algunas para instalar native build gems como nokogiri e entre outros.&lt;/p&gt;

&lt;p&gt;Uma outra opção que tem ganhado espaço é o Homebrew que é uma ferramenta para gerar scripts de instalação de libraries, ainda não tive tempo de explorar ele, mas muitos desenvolvedores tem começado a usá-lo por resolver alguns problemas do Mac Ports.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Moving to Snow Leopard</title>
   <link href="http://fabioyamate.com/2009/12/30/moving-to-snow-leopard/"/>
   <updated>2009-12-30T12:28:34-02:00</updated>
   <id>http://fabioyamate.com/2009/12/30/moving-to-snow-leopard</id>
   <content type="html">&lt;p&gt;Após 1 ano de experiência com Mac OSX Leopard estou migrando para o Snow Leopard.&lt;/p&gt;

&lt;p&gt;Como um usuário de anos de uso do Windows, meu velho costume é o de sempre fazer um fresh/clean install do sistema operacional. Normalmente, no Windows o motivo de fazer um clean install é para conseguir de volta o desempenho do sistema operacional depois de inúmeros programas, de certo modo, inúteis, e como muitos sabem o uninstall não faz um uninstall completo. Por este motivo formatação para mim tem sido sempre a melhor opção.&lt;/p&gt;

&lt;p&gt;Já no Mac não tive muito este problema de queda no desempenho. Claro que com o tempo você começa a instalar inúmeros aplicativos existem vários serviços para serem subidos no sistema operacional e isso reduz um pouco o desempenho do boot. Então resolvi fazer o upgrade do Leopard para o Snow Leopard e ver no que dá.&lt;/p&gt;

&lt;p&gt;Tudo que fiz foi dar uma pesquisada na internet sobre quais os melhores procedimentos para se realizar o upgrade. Como a maioria dos sites, as recomendações foram:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Backup dos dados com Time Machine + DVD: neste caso eu só optei pelo Time Machine para um HD externo&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limpeza: uma das partes mais demoradas (&amp;quot;chatas&amp;quot;) do trabalho de instalação do sistema operacional. É uma ótima oportunidade para remover todo aquele &amp;quot;lixo&amp;quot; que você nem sabia que existia, principalmente do Downloads, cheguei a remover +5Gb só neste diretório&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remoção de aplicativos: Aproveitei para remover algums Apps trials que instalei, utilizando junto o AppSweeper do Hazel que notifica arquivos não removidos da remoção do App.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Limpeza do Sistema Operacional: recomendo o Onyx principalmente por que ele faz uma verificação do &amp;quot;estado&amp;quot; do seu HD, e vendo se não existe nenhum problema que poderia prejudicar o upgrade. Outra opção é o Cocktail que é pago.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feito estas etapas, foi somente colocar o DVD de instalação do Snow Leopard e esperar por volta de 1h e BOOM, Snow Leopard instalado.&lt;/p&gt;

&lt;p&gt;Infelizmente, existem alguns efeitos colaterais do upgrade, mas que para mim não foram muito significativos. Um deles foi apenas que uma conta de usuário (para desenvolvimento) sumiu. Como esta conta não tinha nada, para mim foi indiferente, mas de uma buscada na internet se para você isto for importante.&lt;/p&gt;

&lt;p&gt;Bom, depois da instalação não tive muitos problemas, os principais aplicativos continuaram funcionando. Todos os apps com suporte a 64-bits já começaram a aparecer no Activity Monitor. Nós próximos posts estarei reportando alguns problemas e soluções que apliquei após a atualização.&lt;/p&gt;

&lt;p&gt;Só posso dizer que até o momento não sinto problema em não ter feito um clean install, mas posso dizer que sinto falta deste trabalho após longos anos de experiência do Windows...&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Configuração NAT em VMs no VMWare Fusion e Workstation</title>
   <link href="http://fabioyamate.com/2009/05/24/configuracao-nat-em-vms-no-vmware-fusion-e-workstation/"/>
   <updated>2009-05-24T20:23:20-03:00</updated>
   <id>http://fabioyamate.com/2009/05/24/configuracao-nat-em-vms-no-vmware-fusion-e-workstation</id>
   <content type="html">&lt;p&gt;Recentemente tenho trabalhado com muitas aplicações e não dá para ter tudo instalado na mesma máquina por que vários serviços podem conflitar entre si, seja por versões ou duplicidade de instâncias, por exemplo versões de banco de dados de diferentes verões na mesma máquina.&lt;/p&gt;

&lt;p&gt;O que fazer? Configurar VMs (Virtual Machines)!&lt;/p&gt;

&lt;p&gt;Se você tem um PC relativamente novo já deve ter experimentado utilizar máquinas virtuais para emular algum sistema, por exemplo linux ou versões de sistemas betas e etc. Digamos que você queira ter um servidor *NIX rodando na sua máquina com um servidor web para desenvolvimento, seja Java/PHP/Python o que for, uma vez que em grande parte esses sistemas são colocados em produção nesses tipos de sistemas e não no Windows.&lt;/p&gt;

&lt;p&gt;Estou usando o VMWare 2.0 para isso, agora estou de Mac e portanto estou usando a versão Fusion que é a única disponível dos produtos da VMWare. No caso do mundo Windows, temos Player, Workstation e Server. Usei também a versão Workstation 6.5.x.&lt;/p&gt;

&lt;h2&gt;Um pouco de teoria...&lt;/h2&gt;

&lt;p&gt;Acontece que a configuração padrão de rede é &lt;a title=&quot;NAT&quot; href=&quot;http://en.wikipedia.org/wiki/Network_address_translation&quot; target=&quot;_blank&quot;&gt;NAT&lt;/a&gt; que é um tradutor de endereços de rede. Veja a imagem abaixo para ilustrar a configuração NAT:&lt;/p&gt;

&lt;p&gt;&lt;img title=&quot;NAT Configuração&quot; src=&quot;http://communities.vmware.com/servlet/JiveServlet/downloadImage/102-2527-9-1651/nat1.PNG&quot; alt=&quot;VM NAT&quot; width=&quot;476&quot; height=&quot;173&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Como pode ver na figura acima, você tem uma máquina virtual rodando no seu computador e utiliza a interface de rede dele para acessar sua rede local. Veja que o recurso de rede é compartilhado, de modo que sua VM não fica exposta na rede externa, onde o seu computador atua como um &amp;quot;firewall&amp;quot;.&lt;/p&gt;

&lt;p&gt;Digamos que eu queira expor meu servidor web para o resto da rede, neste caso na VM estou com a porta 80 aberta, porém o IP virtual que é configurado na VM não é visto pela rede. Entenda isso como o analogo a sua configuração de rede que provavelmente deve ter um roteador que interfaceia sua rede local com o seu provedor de acesso a internet. Ou seja, o pessoal de fora não vê seu PC e sim o roteador. Se desejarmos expor precisamos &amp;quot;traduzir&amp;quot; as requisições para que sejam enviadas ao destino correto, em nosso caso seu PC-Roteador ou VM-Computador.&lt;/p&gt;

&lt;p&gt;Para entendermos melhor, precisamos entender como uma comunicação é feita, não vou entrar em muitos detalhes.&lt;/p&gt;

&lt;p&gt;Para que você se conecte a uma máquina precisamos do endereço IP e a porta de comunicação. Digamos que vá acessar uma página na Web pelo seu navegador predileto. Você digita www.fabioyamate.com este endereço será traduzido para um endereço IP por servidores DNS e a requisição será enviada para a porta 80 (default), que é padronizada para servidores Web. Neste caso não explicitamos a porta, pois o navegador já estabelece isso por padrão. Se precisássemos de outra porta, digamos 8080, precisaríamos requisitar www.fabioyamate.com:8080.&lt;/p&gt;

&lt;p&gt;Ok, agora que sabemos disso, como expomos a porta 80 da minha máquina virtual? Se você não entendeu o problema, veja que a porta 80 da sua máquina não é a mesma da máquina virtual. Precisamos ensinar que as requições que cheguem na porta 80 do meu computador vão para a porta 80 da minha máquina virtual, essa etapa é que chamamos de tradução.&lt;/p&gt;

&lt;p&gt;Assim, queremos relacionar &lt;code&gt;vm:80 &amp;lt;-&amp;gt; comp:80&lt;/code&gt;, poderíamos associar a portas diferentes, digamos: &lt;code&gt;vm:80 &amp;lt;-&amp;gt; comp:12345&lt;/code&gt;. Então faríamos requisições para a porta &lt;code&gt;12345&lt;/code&gt; para acessarmos o serviço rodando na máquina virtual.&lt;/p&gt;

&lt;h2&gt;Colocando em Prática&lt;/h2&gt;

&lt;p&gt;Agora que entendemos o conceito do funcionamento, precisamos saber como configurar isso na VM. No VMWare, novas interfaces de redes são adicionadas, que neste caso são virtuais. No VMWare Fusion, a tabela de tradução de endereços encontra-se no diretório:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;/Library/Application Support/VMWare Fusion/vmnet8/nat.conf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Uma boa prática é sempre mantermos uma cópia da verão em funcionamento para caso realizemos uma besteira podemos restaurar.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;sudo cp nat.conf nat.conf.backup&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;sudo vi nat.conf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora basta adicionarmos a tradução da seguinte forma:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;porta_local_maquina = endereco_vm:porta_vm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Exemplo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;# Servidor Web
8080 = 172.16.250.130:80
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Basta salvar o arquivo usando &lt;code&gt;:wq!&lt;/code&gt; (pois o arquivo é readonly) no vi, se sentir dificuldade de uma navegada na internet, ou use outro editor a sua escolha.&lt;/p&gt;

&lt;p&gt;Agora precisamos reconfigurar a interface virtual para que as alterações tenham efeito.&lt;/p&gt;

&lt;p&gt;No diretório &lt;code&gt;/Library/Application Support/VMWare Fusion&lt;/code&gt; temos um script &lt;code&gt;boot.sh&lt;/code&gt;, assim digite:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;sudo ./boot.sh --restart&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isso irá reconfigurar. Pode ser que necessite desligar a máquina virtual, mas normalmente não é necessário.&lt;/p&gt;

&lt;p&gt;Com isso você já pode acessar de fora a máquina virtual configurada.&lt;/p&gt;

&lt;p&gt;No Windows o processo é igual, mas é feito por interface gráfica, se não me engando Network Editor ou algo do gênero.&lt;/p&gt;

&lt;p&gt;Note que se você usa algum firewall você deve liberar as portas da máquina virtual para que o serviço seja realmente exposto.&lt;/p&gt;

&lt;p&gt;Um utilitário muito bom é o &lt;a href=&quot;http://nmap.org/&quot; target=&quot;_blank&quot;&gt;nmap&lt;/a&gt; que tem tanto para todas as plataformas. Basta usar o comando:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;nmap -p &amp;lt;PORTA&amp;gt; &amp;lt;ENDERECO_IP&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;ou&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;nmap -p &amp;lt;PORTA_INICIAL&amp;gt;-&amp;lt;PORTA_FINAL&amp;gt; &amp;lt;ENDERECO_IP&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Caso ping esteja restrito no firewall, use &lt;code&gt;-PN&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Espero que este texto seja de ajuda.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Java Development</title>
   <link href="http://fabioyamate.com/2009/04/25/java-development/"/>
   <updated>2009-04-25T14:26:48-03:00</updated>
   <id>http://fabioyamate.com/2009/04/25/java-development</id>
   <content type="html">&lt;p&gt;Nos meus últimos 2 anos tenho dedicado a maior parte da minha evolução técnica no mundo .NET. Primeiramente, comecei a trabalhar com essa tecnologia, ao invés de java e, isto, de certa forma me influênciou, mas com o tempo acabei me apaixonando pela linguagem C#. A realidade é que prefiro muito mais C# do que Java, porém não se pode ignorar a comunidade Java que existem muito mais soluções em nível Enterprise.&lt;/p&gt;

&lt;p&gt;A plataforma .NET é muito fechada as decisões da Microsoft. O ASP.NET é uma das plataformas das quais não me sinto vontade de trabalhar, ela fica extremamente difícil de aplicar padrões. De uns dois ou três anos para cá é que isso tem modificado com o surgimento de frameworks opensource, como &lt;a href=&quot;http://www.castleproject.org/&quot; target=&quot;_blank&quot;&gt;Castle Project&lt;/a&gt;, &lt;a href=&quot;http://www.hibernate.org/&quot; target=&quot;_blank&quot;&gt;NHibernate&lt;/a&gt;, IoC e muitos outros. Contudo, todos são originários de frentes vindas do Java.&lt;/p&gt;

&lt;p&gt;A linguagem Java, em si, nem é o aspecto mais importante para mim, e sim, as tecnologias que envolvem para se desenvolver uma aplicação.&lt;/p&gt;

&lt;p&gt;Por este motivo, estou pensando em começar a trabalhar com Java, novamente, mas como uma visão de soluções corporativas.&lt;/p&gt;

&lt;p&gt;Vou começar a estudar alguns frameworks web, principalmente pelo aspecto de arquitetura, que é uma área a qual tenho um grande interesse em me aprofundar.&lt;/p&gt;

&lt;p&gt;Não vou deixar o mundo .NET, mas tentarei escrever algumas coisas sobre Java contando minhas experiências.&lt;/p&gt;

&lt;p&gt;Não me esqueci dos posts sobre &lt;a href=&quot;http://www.asp.net/mvc&quot; target=&quot;_blank&quot;&gt;ASP.NET MVC&lt;/a&gt; não.&lt;/p&gt;

&lt;p&gt;Até a próxima!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Batch Download Legendas.TV (Greasemonkey)</title>
   <link href="http://fabioyamate.com/2009/04/24/batch-download-legendastv-greasemonkey/"/>
   <updated>2009-04-24T20:09:48-03:00</updated>
   <id>http://fabioyamate.com/2009/04/24/batch-download-legendastv-greasemonkey</id>
   <content type="html">&lt;p&gt;Semana passada precisava baixar algumas legendas antigas do site Legendas.TV, e nunca achei prático baixar legendas por que tem popups. Com isso, acabei fazendo meu primeiro script para o greasemonkey+jquery. Foi bem simples. Quem quiser baixar é só ir na &lt;a title=&quot;Batch Download Legendas.TV&quot; href=&quot;http://projects.fabioyamate.com/&quot;&gt;páginas de projetos&lt;/a&gt; ou clicando &lt;a href=&quot;http://projects.fabioyamate.com/greasemonkey&quot;&gt;aqui&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>ASP.NET MVC 1.0</title>
   <link href="http://fabioyamate.com/2009/04/08/aspnet-mvc-10/"/>
   <updated>2009-04-08T20:00:25-03:00</updated>
   <id>http://fabioyamate.com/2009/04/08/aspnet-mvc-10</id>
   <content type="html">&lt;p&gt;Ei, o ASP.NET MVC RTM 1.0 foi lançado!&lt;/p&gt;

&lt;p&gt;Ok ok... todo mundo já deve estar sabendo, não estou querendo fazer anúncio.&lt;/p&gt;

&lt;p&gt;Bom, nas últimas semanas tenho trabalho com ele para fazer um projeto de um sistema de matrículas, não entrarei em detalhes pois não é o interesse aqui.&lt;/p&gt;

&lt;p&gt;Meu primeiro contato, real, com MVC foi pelo Castle Project MonoRails. Até então não conhecia exatamente como funcionava, e sabe o que aconteceu? Adorei. Meus primeiros passos não foram programando em C. Comecei realmente por PHP. Ok, tive meus primeiros passos com QBasic no colégio, por conta própria, mas deixo essas histórias para um outro dia.&lt;/p&gt;

&lt;p&gt;Nos próximos dias, talvez meses, tentarei falar um pouco das minhas experiências com ele, incluindo diversos outros frameworks que estou começando a ver como NHibernate, IoC e etc.&lt;/p&gt;

&lt;p&gt;Espero conseguir realizar este projeto, e tornar o blog mais ativo.&lt;/p&gt;

&lt;p&gt;Ainda estou atras de um bom editor de blogs, estou agora usando Mac, e infelizmente acabei perdendo o Live Writer da Microsoft nesta migração. Veremos o que farei com relação a isso, até lá irei de Wordpress.&lt;/p&gt;

&lt;p&gt;Abraços&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>MacHeist 3 Bundle Party Chega Ao Fim...</title>
   <link href="http://fabioyamate.com/2009/04/08/macheist-3-bundle-party-chega-ao-fim/"/>
   <updated>2009-04-08T19:49:28-03:00</updated>
   <id>http://fabioyamate.com/2009/04/08/macheist-3-bundle-party-chega-ao-fim</id>
   <content type="html">&lt;p&gt;Para aqueles que tem a oportunidade de ter um Mac pode aproveitar um dos grandes eventos que ocorrem na comunidade Mac. Imagino por que algo deste tipo não poderia ocorrer no mundo windows, existem tantas ferramentas utilitárias que poderiam ser vendidas, minimizando um pouco a pirataria que circula aos montes.&lt;/p&gt;

&lt;p style=&quot;text-align: center;&quot;&gt;&lt;a rel=&quot;attachment wp-att-149&quot; href=&quot;http://fabioyamate.com/2009/04/08/macheist-3-bundle-party-chega-ao-fim/macheist-3-logo/&quot;&gt;&lt;img class=&quot;size-full wp-image-149 aligncenter&quot; title=&quot;macheist-3-logo&quot; src=&quot;http://fabioyamate.com/images/2009/04/macheist-3-logo.png&quot; alt=&quot;macheist-3-logo&quot; width=&quot;218&quot; height=&quot;46&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Eu estou começando a fazer meus investimentos em aplicativos que acho realmente interessante e que vale a pena pagar por ele.&lt;/p&gt;

&lt;p&gt;Com o MacHeist pude adquirir diversas ferramentas que esta interessande, posso citar Espresso, The Hit List e Little Snapper. Ok, Tinha em mente o Coda e Things, mas estou estremamente satisfeito com essas duas ferramentas, e sabe o que mais? Paguei apenas US$31, e ainda recebi muitos outros aplicativos que havia deixando na minha listinha de futuras compras (quando viesse a ter dinheiro sobrando).&lt;/p&gt;

&lt;p&gt;Quem perdeu, infelizmente terá que esperar até o ano que vem.&lt;/p&gt;

&lt;p&gt;O final do evento surpreendeu ao desbloquear todos os aplicativos do bundle, passando de 400k arreacados para US$850k!&lt;/p&gt;

&lt;p&gt;Se der faço algum review de alguns aplicativos.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>MacHeist 3 Bundle Lançado</title>
   <link href="http://fabioyamate.com/2009/03/24/macheist-3-bundle-lancado/"/>
   <updated>2009-03-24T20:50:47-03:00</updated>
   <id>http://fabioyamate.com/2009/03/24/macheist-3-bundle-lancado</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.macheist.com/bundle/u/143582/&quot;&gt;&lt;img class=&quot;size-full wp-image-143&quot; title=&quot;macheist-3-bundle1&quot; src=&quot;http://fabioyamate.com/images/2009/03/macheist-3-bundle1.png&quot; alt=&quot;MacHeist 3 Bundle 2009&quot; width=&quot;530&quot; height=&quot;601&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hoje, as 9hs de Brasília tivemos um &lt;a title=&quot;UStream&quot; href=&quot;http://ustream.com&quot; target=&quot;_blank&quot;&gt;livecast&lt;/a&gt; do &lt;a title=&quot;MacHeist Reveal Show&quot; href=&quot;http://www.macheist.com/revealshow&quot; target=&quot;_blank&quot;&gt;MacHeist Reveal Show&lt;/a&gt; lançamento do &lt;a href=&quot;http://www.macheist.com/bundle/u/143582/&quot; target=&quot;_blank&quot;&gt;bundle&lt;/a&gt; (pacote  de programas) pelo &lt;a title=&quot;MacHeist&quot; href=&quot;http://www.macheist.com/&quot; target=&quot;_blank&quot;&gt;MacHeist&lt;/a&gt;. Este ano esta ocorrendo o terceiro evento e ao final uma série de produtos pagos são lançados a um preço baixíssimo, desta vez foi um conjunto de pacotes totalizando +US$500 por apenas US$39.&lt;/p&gt;

&lt;p&gt;A transmissão foi apresentada por &lt;a href=&quot;http://chris.pirillo.com&quot;&gt;Chris Pirillo&lt;/a&gt;, &lt;a href=&quot;http://www.veronicabelmont.com&quot;&gt;Veronica Belmont&lt;/a&gt; e &lt;a href=&quot;http://www.mostlylisa.com&quot;&gt;Lisa Bettany&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Para aqueles que participaram do evento todo ganhou um desconto de US$8 ao realizar uma série de missões, reduzindo para US$31. Incluíndo muitas outras aplicações entregues ao completar cada missão.&lt;/p&gt;

&lt;p&gt;Não vou dizer que todos os Apps ofertados são 100% úteis a todos os usuários. O pacote pretende atender uma série de pessoas usuárias de Mac.&lt;/p&gt;

&lt;p&gt;Existem desde softwares profissionais a softwares para pessoas comuns em geral, que precisam de uma ferramenta de fácil uso e que remova aquelas simplicidades que todo mundo sabe fazer.&lt;/p&gt;

&lt;p&gt;A figura acima foi usada o Little Snapper (screen capture) e o Picturesque (estilizador de imagem), tudo em questão de segundos.&lt;/p&gt;

&lt;p&gt;O projeto visa arrecadar dinheiro para doar a diversas instituições (25% do lucro) e de especial se for atingido uma cota de US$100k mais quatro aplicativos serão destravados (unlocked).&lt;/p&gt;

&lt;p&gt;Se voce é usuario de Mac vale a pena dar uma conferida e pelo preço vale a pena.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Configurando Wireshark para Mac: MIBS e Interfaces</title>
   <link href="http://fabioyamate.com/2009/02/14/configurando-wireshark-para-mac-mibs-e-interfaces/"/>
   <updated>2009-02-14T14:48:04-02:00</updated>
   <id>http://fabioyamate.com/2009/02/14/configurando-wireshark-para-mac-mibs-e-interfaces</id>
   <content type="html">&lt;p&gt;Olá, estive sumido ultimamente, alías isto ocorre frequentemente.&lt;/p&gt;

&lt;p&gt;Bom, já tem um tempo que adquiri um mac para mim e estou aos poucos aprendendo. Nem tudo é tão simples como no Windows que nas instalações basta clicar em &amp;quot;next&amp;quot;. Veja bem, eu não disse que Windows é melhor.&lt;/p&gt;

&lt;p&gt;Hoje, precisei instalar o &lt;a href=&quot;http://wireshark.org&quot; target=&quot;_blank&quot;&gt;Wireshark&lt;/a&gt; (antigo Ethereal) para Mac. Já havia instalado anteriormente (versao 1.0.5) porém tive alguns erros e na epoca não fui atrás em como resolver.&lt;/p&gt;

&lt;p&gt;Hoje, dediquei um pouco mais de tempo para resolver esses problemas de uso que tive. Para o pessoal não habituado ao mundo UNIX/Linux, as documentações que acompanham são extremamente úteis e não podem ser descartados como ocorre no Windows.&lt;/p&gt;

&lt;p&gt;Sugiro sempre ler os README que mostram passo a passo de como proceder para instalar nestes ambientes. Apesar de na maioria dos casos, no Mac a instalação chega a ser mais simples que no Windows onde basta arrastar o aplicativo para o diretório Applications.&lt;/p&gt;

&lt;p&gt;Bom, voltando, há dois problemas extremamente comum ao usar o Wireshark no Mac:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;nenhuma interface foi encontrada&lt;/li&gt;
&lt;li&gt;MIBS error&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A segunda é a mais simples. O diretório padrao do MIBS mudou (acredito que ocorreu no Leopard, não tenho contexto histórico para afirmar isso) e agora encontra-se no caminho &lt;code&gt;/usr/share/snmp/mibs&lt;/code&gt; em Preferences &amp;gt; Name Resolution do Wireshark (basta adicionar este caminho novo). A fonte da solução pode ser encontrada &lt;a href=&quot;http://www.wireshark.org/lists/wireshark-bugs/200902/msg00002.html&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;O primeiro é um problema de permissão que tem de ser concedida aos dispositivos &lt;code&gt;/dev/bpf*&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A solução imediata seria ir no Terminal e digitar:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;sudo chown &amp;quot;seu usuario&amp;quot; /dev/bpf*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Porém ao reiniciar o Mac o problema volta por que esta configuração não é persistida. O jeito é configurar isso no startup do Mac. O Wireshark conta com um diretório Utilities que tem um diretório Startup com um script ChmodBPF.&lt;/p&gt;

&lt;p&gt;Basta copiar o script para o diretório &lt;code&gt;/Library/StartupItem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Para aqueles que apenas arrastaram o Wireshark para o diretório Applications, pode ter faltado copiar os scripts para algum diretório /bin configurado no path. Eu coloquei os script do diretório Utilities/CommandLines para o caminho &lt;code&gt;/usr/local/bin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Para os familiarizados em janelas, basta abrir o Finder e pressionar cmd + shift + G, e digitar o caminho.&lt;/p&gt;

&lt;p&gt;Com isso, basta reiniciar o Wireshark e tudo estará configurado.&lt;/p&gt;

&lt;p&gt;Até um próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Desabilite o Spotlight em seus PDFs – mdworker</title>
   <link href="http://fabioyamate.com/2009/01/12/desabilite-o-spotlight-em-seus-pdfs-mdworker/"/>
   <updated>2009-01-12T16:32:44-02:00</updated>
   <id>http://fabioyamate.com/2009/01/12/desabilite-o-spotlight-em-seus-pdfs-mdworker</id>
   <content type="html">&lt;p&gt;Acabei de pegar de volta meu HD que mandei reparar e agora tenho muito trabalho a fazer, gerar uma versão de backup para os documentos mais importantes e assim evitar a dor de cabeça que foi (e no bolso também).&lt;/p&gt;

&lt;p&gt;Uma das etapas consistiu em guardar muitos documentos PDFs que tinha tanto em DVD como em outro dispositivo. Inicialmente, todos os PDFs que possuo estavam numa máquina compartilhada dentro da LAN, posso dizer que ela é um mini-servidor-multimídia-que-faz-trabalhos-secundários, operando 24/7, conhecido como &amp;quot;escravo&amp;quot; (the pcguy).&lt;/p&gt;

&lt;p&gt;Brincadeiras a parte, copiei todos os PDFs para o meu Macbook Pro, pois frequentemente acesso alguns documentos e para manter um &amp;#39;mirror&amp;#39; deles coloquei no meu notebook. Acontece que o volume de dados era tão grande que o Spotlight ficou louco. Alguns diagnosticaram problemas com um volume de documentos de 300 Mb, no meu caso ultrapassou a barreira dos 10Gb.&lt;/p&gt;

&lt;p&gt;O Spotlight para quem não sabe, é o mecanismo de busca do MAC OSX que varre grande parte do conteúdo de informação que ali reside e que você comumente busca por eles (o Vista inclui este tipo de recurso no menu iniciar). Neste caso, o Spotlight tentou varrer (alias, ficou tentando até eu dar um fim na brincadeira) todos os PDFs e indexá-los para permitir uma busca efetiva. Porém, era muita informação e isso iria custar muito processamento e que na prática, para mim, seria inútil.&lt;/p&gt;

&lt;p&gt;Você pode diagnosticar isso vendo que o processo &lt;em&gt;mdworker&lt;/em&gt; consome uma certa quantia de processamento, aqui ficou em 20%, mas que deixou meu macbook pro na casa dos 73C a 3000 rpm. O jeito de resolver esse trabalho desnecessário foi acessar:&lt;/p&gt;

&lt;p&gt;Preferences &amp;gt; Spotlight &amp;gt; Privacy e adicionar o diretório com os documentos PDFs, ou qualquer outra coisa que você não queira tornar público e de fácil acesso (acho que você consegue imaginar outra situação).&lt;/p&gt;

&lt;p&gt;Com isso o notebook deve voltar ao seu estado normal.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Windows 7 beta 1 x64 installed!</title>
   <link href="http://fabioyamate.com/2009/01/10/windows-7-beta-1-x64-installed/"/>
   <updated>2009-01-10T20:32:01-02:00</updated>
   <id>http://fabioyamate.com/2009/01/10/windows-7-beta-1-x64-installed</id>
   <content type="html">&lt;p&gt;Postando diretamente do Windows 7 beta 1 64-bit. Ainda não testei as funcionalidades, mas estou apenas reportando que é possível instalar o Windows 7 no Macbook Pro Unibody (late 2008).&lt;/p&gt;

&lt;p&gt;A instalação é feito como usual. Execute o Boot Camp Assistant no Leopard e defina uma partição, recomendo o default de 32 Gb, por que a instalação consumiu quase 16Gb. Eu sei que memória esta barato hoje, mas 16 Gb é demais.&lt;/p&gt;

&lt;p&gt;Bom, após a instalação coloquei o CD de instalação do Macbook Pro para instalar os drivers do boot camp 2.1. E reiniciei a máquina.&lt;/p&gt;

&lt;p&gt;Bom, agora acontece o problema que eu já havia encontrando quando tentei instalar o Windows Vista Business 32-bit. Após a instalação do boot camp ao logar aconteciam duas cituações: BSOD (sim por causa do driver de vídeo) ou ficava travado depois da autenticação.&lt;/p&gt;

&lt;p&gt;Bom, no Windows 7 foi a mesma coisa. Para contornar este problema reiniciei em modo seguro (safe mode), basta pressionar a tecla F8 quando a máquina estiver carregando.&lt;/p&gt;

&lt;p&gt;Desinstalei o driver da NVidia e reiniciei a máquina. Após o reinicio o Windows voltou a instalar um driver default e assim baixei o driver no site da nVidia para notebook versão 179.28 for Windows Vista x64 (beta). Instalei e reiniciei a máquina e assim consegui me autenticar no sistema normalmente.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2009/01/windows7b1-full1.png&quot; target=&quot;_blank&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;windows7b1_full&quot; border=&quot;0&quot; alt=&quot;windows7b1_full&quot; src=&quot;http://fabioyamate.com/images/2009/01/windows7b1-full-thumb1.png&quot; width=&quot;500&quot; height=&quot;320&quot; /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Aparentemente está funcionando normalmente. Instalei antes de tudo o fix do problema com MP3 (KB961367 – x64).&lt;/p&gt;

&lt;p&gt;Após isso configurei o IE8 e instalei o Firefox 3.0.5 (x86) em seguida, nenhum problema encontrado.&lt;/p&gt;

&lt;p&gt;Rodei o Windows Experience para ver a minha nota e obtive o seguinte resultado:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2009/01/windows7b1-score1.png&quot; target=&quot;_blank&quot;&gt;&lt;img style=&quot;border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px&quot; title=&quot;windows7b1_score&quot; border=&quot;0&quot; alt=&quot;windows7b1_score&quot; src=&quot;http://fabioyamate.com/images/2009/01/windows7b1-score-thumb1.png&quot; width=&quot;500&quot; height=&quot;340&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Score de 2.9 por causa do Hard Disk. Sinceramente, fiquei desapontado com o resultado, não espera um valor tão baixo para o HD, se levar em conta que agora o ranking vai até 7,9.&lt;/p&gt;

&lt;p&gt;O resto foi aceitável. Não esperava obter tudo no máximo visto que estou usando um notebook.&lt;/p&gt;

&lt;p&gt;Agora outro problema já muito comentado em vários lugares. Sim, o notebook esquenta… e muito! Pelo fato de ele executar em high performance usando a NVidia Geforce 9600M GT a temperatura eleva-se muito rápido se comparado o uso no Leopard.&lt;/p&gt;

&lt;p&gt;Infelizmente, este problema não tem uma solução simples e prática. Não existe um utilitário que possamos usar para gerenciar a rotação das FANs e eles só entram em ação com o notebook bem quente.&lt;/p&gt;

&lt;p&gt;A maioria do pessoal recomenda usar o smcFanController (do Mac OSX) e definir um valor de rotação e reiniciar a máquina botando o Windows Vista/7b1, pois uma vez setado a configuração permanece fixa até que o computador seja desligado.&lt;/p&gt;

&lt;p&gt;Um último detalhe é o trackpad. Instalei o update do multitouch da Apple, porém se habilitado o click com tap (sem o click do botão) a sensibilidade esta muito alta. Quando tento navegar com o mouse pela tela, normalmente você vai executando vários tappings, por que o trackpad não é grande o suficiente, e isso acaba causa misclicks indesejáveis, acabei optando por usar o click button mesmo.&lt;/p&gt;

&lt;p&gt;Bom, basicamente é isso sobre a instalação. Vou experimentar a instalação do Visual Studio 2008 Professional SP1 e o SQL Express 2008. E vários outros utilitários que não podem faltar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[dica]&lt;/strong&gt; Para tirar screenshot o atalho é Fn + Shift + F11 (full) e só a janela ativa Fn + Shift + Alt (Option) + F11&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[update]&lt;/strong&gt; Não sei por que mas o eject do driver não está mais funcionando, funcionou antes da instalação dos drivers do boot camp. Achando uma solução atualizo o post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Google muda o favicon, again...</title>
   <link href="http://fabioyamate.com/2009/01/10/google-muda-o-favicon-again/"/>
   <updated>2009-01-10T19:07:07-02:00</updated>
   <id>http://fabioyamate.com/2009/01/10/google-muda-o-favicon-again</id>
   <content type="html">&lt;p&gt;Ano passado num &lt;a href=&quot;http://fabioyamate.com/2008/06/16/google-para-que-mudar-o-favicon/&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; passado, eu comentei sobre a mudança do favicon do &lt;a href=&quot;http://www.google.com/&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; e seus serviços.&lt;/p&gt;

&lt;p&gt;Pelo visto, começando um novo ano, 2009, eles resolveram mudar novamente o ícone, para uma versão mais colorida.&lt;/p&gt;

&lt;p&gt;Confesso que novamente me incomoda essa mudança, para quem usa muita aba fica confuso achar as abas especificas se o site muda a identidade dele.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2009/01/image.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;45&quot; alt=&quot;image&quot; src=&quot;http://fabioyamate.com/images/2009/01/image-thumb.png&quot; width=&quot;119&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Cuide bem de seus dados</title>
   <link href="http://fabioyamate.com/2009/01/10/cuide-bem-de-seus-dados/"/>
   <updated>2009-01-10T16:41:01-02:00</updated>
   <id>http://fabioyamate.com/2009/01/10/cuide-bem-de-seus-dados</id>
   <content type="html">&lt;p&gt;Um tópico fora do assunto comum do blog, mas queria alertar aquilo que todo mundo sabe e só ficamos realmente cientes depois que ocorre conosco aquilo que achavamos impossível.&lt;/p&gt;

&lt;p&gt;Viagei por cinco dias e deixei meu computador (PC) ligado durante este período. Porém, esqueci ligado o HD externo, eu sei burrice minha. Quando retorno, o que aconteceu? O HD parou de funcionar.&lt;/p&gt;

&lt;p&gt;Qual o problema disso? O HD que não foi, hoje em dia memória é a coisa mais barata, estamos entrando na era dos tera bytes, que alguns anos atras parecia impossível de se consumir tanta informação.&lt;/p&gt;

&lt;p&gt;O problema são os dados pessoais que não estão em backup, eu sei, burrice minha again. O preço para ter os dados de volta me custou caro $$$. Se tivesse gravado os dados em mídias de DVDs teria economizado a um custo infímo.&lt;/p&gt;

&lt;p&gt;Por isso, cuide bem de seus dados pessoais, dedique algumas horas (sim horas, a menos que você seja organizado, preparar tudo que você tem para gravar custa tempo) e tenha uma versão dos dados de 3 em 3 meses, se for mais preguiçoso de 6 em 6 meses. É um trabalho que vale a pena pela dor de cabeça que você poderá ter caso isso venha a acontecer. Lembre-se, os HDs ainda sáo mecânicos o que os tornam componentes frágeis.&lt;/p&gt;

&lt;p&gt;Talvez hoje, com o barateamento da memória ter dados guardados em RAID 1 pode ser uma boa opção, embora isso não seja uma realidade para todos.&lt;/p&gt;

&lt;p&gt;Lição aprendida:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Realize backup com regularidade de seus dados pessoais, é bem provável que aquilo que realmente importa, caibam em 4 ou 5 mídias de DVD;&lt;/li&gt;
&lt;li&gt;Não deixe seu HD Externo ligado 24hs, eles não são dispositivos para se usar diariamente, são locais de armazenamento secundário;&lt;/li&gt;
&lt;li&gt;Se dispor de mais de uma máquina, distribua os dados entre elas, redundância nunca é demais.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Windows 7 beta 1</title>
   <link href="http://fabioyamate.com/2009/01/10/windows-7-beta-1/"/>
   <updated>2009-01-10T16:28:22-02:00</updated>
   <id>http://fabioyamate.com/2009/01/10/windows-7-beta-1</id>
   <content type="html">&lt;p&gt;Wow, com atraso mas estou postando noticia sobre o Windows 7 public beta 1. Na CES 2009, no dia 7 de janeiro de 2009 o Steve Ballmer abriu o keynote falando sobre os planos da Microsoft e os diversos produtos, entre eles o aguardado Windows 7. Muitas notícias já circulam a internet sobre o public beta prometido pelo Steve Ballmer para sexta-feira passada (09/01/2009).&lt;/p&gt;

&lt;p&gt;O lançamento ocorreu, porém num curto período. O pessoal da Microsoft for surpreendido pelo volume de acessos e requisições do download. Sabe como é, coisa de graça todo mundo quer, mesmo que não vá usar.&lt;/p&gt;

&lt;p&gt;Os downloads da Microsoft podem ser encontrados aqui:&lt;/p&gt;

&lt;p&gt;[1] &lt;a title=&quot;https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx&quot; href=&quot;https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx&quot;&gt;https://msdn.microsoft.com/en-us/subscriptions/securedownloads/default.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Foi um grande achado para mim, por que neste link temos acesso a todas as imagens de todos os produtos da Microsoft. Eu estou habituado a usar softwares em inglês e por isso adorei o link encontrado.&lt;/p&gt;

&lt;p&gt;Voltando sobre o assunto, alguém deveria ensinar o pessoal da Microsoft que existe algo chamado Torrent e que tem o propósito de aliviar os servidores distribuindo a carga pelos próprios usuários. Assim, a obtenção das chaves seria algo mais rápido e prático.&lt;/p&gt;

&lt;p&gt;Enquanto as chaves de uso do Windows 7b1, não estão disponíveis é possível baixar as imagens dos dois releases x86 e x64.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://download.microsoft.com/download/6/3/3/633118BD-6C3D-45A4-B985-F0FDFFE1B021/EN/7000.0.081212-1400_client_en-us_Ultimate-GB1CULFRE_EN_DVD.iso&quot; target=&quot;_blank&quot;&gt;Windows 7 beta1 (32bit)&lt;/a&gt; e &lt;a href=&quot;http://download.microsoft.com/download/6/3/3/633118BD-6C3D-45A4-B985-F0FDFFE1B021/EN/7000.0.081212-1400_client_en-us_Ultimate-GB1CULXFRE_EN_DVD.ISO&quot; target=&quot;_blank&quot;&gt;Windows 7 beta1 (64bit)&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SHA1 (32bit): 6071184282B2156FF61CDC5260545C078CCA31EE&lt;/li&gt;
&lt;li&gt;SHA1 (64bit): E09FDBC1CB3A92CF6CC872040FDAF65553AB62A5&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(use o &lt;a href=&quot;http://www.slavasoft.com/fsum/&quot; target=&quot;_blank&quot;&gt;fsum&lt;/a&gt; caso para conferência dos arquivos)&lt;/p&gt;

&lt;p&gt;Já realizei o download das duas imagens e correspondem aos releases do link [1]. (links funcionando em 10/01/2009)&lt;/p&gt;

&lt;p&gt;Estarei instalando o beta 1 e posto os resultados.&lt;/p&gt;

&lt;h4&gt;[Update 1]&lt;/h4&gt;

&lt;p&gt;Esqueci de mencionar, o Windows 7 beta tem um problema com os MP3 que ao tentar obter as tags de informações das músicas ele acaba danificando elas. O primeiro fix para o Windows 7 já esta disponível e corresponde ao KB961367&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://download.microsoft.com/download/7/D/0/7D0A4440-7B8F-4ABC-8BEE-1AF6D80047EE/Windows6.1-KB961367-x86.msu&quot; target=&quot;_blank&quot;&gt;Windows 7b1 x86 KB961367&lt;/a&gt; e &lt;a href=&quot;http://download.microsoft.com/download/F/B/7/FB7BC04D-66E6-413F-94F0-A54D0196EBDE/Windows6.1-KB961367-x64.msu&quot; target=&quot;_blank&quot;&gt;Windows 7b1 x64 KB961367&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SHA1 KB961367 (x86): 5D89B057874F5D10A4C90EB2021F23EA9850DEB9 &lt;/p&gt;

&lt;p&gt;SHA1 KB961367 (x64): 5228F60EDAE124203AC08CCED57539CA0EEB1113&lt;/p&gt;

&lt;h4&gt;[Update 2]&lt;/h4&gt;

&lt;p&gt;Acabei de obter as chaves para o beta do Windows 7, basta seguir os passos do post do &lt;a href=&quot;http://www.neowin.net&quot; target=&quot;_blank&quot;&gt;neowin.net&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a title=&quot;http://www.neowin.net/news/main/09/01/10/psstheres-how-to-get-your-windows-7-beta-key&quot; href=&quot;http://www.neowin.net/news/main/09/01/10/psstheres-how-to-get-your-windows-7-beta-key&quot;&gt;http://www.neowin.net/news/main/09/01/10/psstheres-how-to-get-your-windows-7-beta-key&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Funcionando as 20:00h (GMT-3) 2009/01/10&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>SQL Types: char, nchar, varchar e nvarchar</title>
   <link href="http://fabioyamate.com/2008/12/15/sql-types-char-nchar-varchar-e-nvarchar/"/>
   <updated>2008-12-15T10:31:16-02:00</updated>
   <id>http://fabioyamate.com/2008/12/15/sql-types-char-nchar-varchar-e-nvarchar</id>
   <content type="html">&lt;p&gt;Um post bem rápido sobre os tipos de dados para texto que temos no SQL Server.&lt;/p&gt;

&lt;p&gt;Temos duas variações com &amp;#39;n&amp;#39; e sem o &amp;#39;n&amp;#39;. O &amp;#39;n&amp;#39; explicita que os caracteres são armazenados em unicode, o que corresponde a 2 bytes ou 16 bits, enquanto que os sem &amp;#39;n&amp;#39; são armazenados em ASCII 1 byte ou 8bits.&lt;/p&gt;

&lt;p&gt;Basicamente, se você criar uma coluna do tipo char ou varchar de tamanho 50, teremos alocado 50 bytes para tais colunas. Entretanto no caso de nvarchar(50) ou nchar(50) teremos alocado 100 como tamanho máximo, uma vez que os tamanhos são definidos em bytes e não em tamanhos absolutos.&lt;/p&gt;

&lt;p&gt;No SQL Server 2005, o tamanho máximo para estes campos são de 8000 bytes. Portanto para char e varchar o máximo é 8000, enquanto que para nchar e nvarchar o máximo é 4000 por causa do tipo de codificação usado.&lt;/p&gt;

&lt;p&gt;Outro ponto é o uso de MAX para varchar e nvarchar. Poderíamos usar varchar(max) e nvarchar(max), permitindo a eles um valor superior a 8000 bytes, ou 8000 e 4000 caracteres, respectivamente.&lt;/p&gt;

&lt;p&gt;As colunas com o parâmetro MAX aceitam até 2^31 bytes, ou 2 Gbytes.&lt;/p&gt;

&lt;p&gt;Podemos observar a system view &lt;code&gt;sys.columns&lt;/code&gt; e pegar a coluna max_length. Note que para colunas com o atributo MAX o valor é -1, justamente pelo fato de o valor exceder o limite.&lt;/p&gt;

&lt;p&gt;Este post foi um pouco diferente do que costumo escrever, é por que nos últimos meses mexi muito com banco de dados. Vou ver se consigo escrever posts menores, com maior regularidade. Até o próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Como descobrir quais tabelas foram modificadas recentemente</title>
   <link href="http://fabioyamate.com/2008/11/27/como-descobrir-quais-tabelas-foram-modificadas-recentemente/"/>
   <updated>2008-11-27T10:40:05-02:00</updated>
   <id>http://fabioyamate.com/2008/11/27/como-descobrir-quais-tabelas-foram-modificadas-recentemente</id>
   <content type="html">&lt;p&gt;Depois de semanas sem postar, vou colocar um post bem breve aqui sobre SQL.&lt;/p&gt;

&lt;p&gt;Recentemente precisei descobri quais tabelas foram modificadas recentemente sem ter que ver uma a uma. Se você tivesse poucas tabelas, isso não seria um problema, ver uma-a-uma, digamos umas 15 ou 20 seria até rápido. Mas podemos facilitar um pouco a nossa vida, limitando nossa amostra.&lt;/p&gt;

&lt;p&gt;Isto aqui vale para SQL Server, não sei como seria em outras databases (Oracle, Postgree, MySQL e etc).&lt;/p&gt;

&lt;p&gt;No SQL Server temos várias Views de sistema, no caso usaremo a View sys.tables, que nos fornece informações diversas sobre as tabelas do banco de dados.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sql&quot; data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tables&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Executando um select sobre esta tabela obteremos um resultado semelhante a este:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/11/sys-tables1.png&quot;&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; src=&quot;http://fabioyamate.com/images/2008/11/sys-tables1-thumb.png&quot; border=&quot;0&quot; alt=&quot;sys_tables1&quot; width=&quot;420&quot; height=&quot;124&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A imagem mostra apenas algumas colunas, existem muitas outras, mas vamos nos focar naquelas que precisamo no momento.&lt;/p&gt;

&lt;p&gt;Veja que temos os nomes de todas as tabelas, e duas colunas de datas, create&lt;em&gt;date e modify&lt;/em&gt;date.&lt;/p&gt;

&lt;p&gt;A primeira instância, achariamos que teríamos que observer a tabela modify_date e ordenar por ordem decrescente por ela.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sql&quot; data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tables&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;BY&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;modify_date&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;DESC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Infelizmente, a informação de data de modificação refere-se a inserção de dados, e não sobre sua estrutura.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/11/sys-tables2.png&quot;&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; src=&quot;http://fabioyamate.com/images/2008/11/sys-tables2-thumb.png&quot; border=&quot;0&quot; alt=&quot;sys_tables2&quot; width=&quot;420&quot; height=&quot;125&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A coluna que temos que ver é create&lt;em&gt;date. Na figura não é possível observar isso, mas a data contida em create&lt;/em&gt;date refere-se a última modificação estrutural realizada sobre ela.&lt;/p&gt;

&lt;p&gt;Então bastaríamos fazer:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sql&quot; data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;k&quot;&gt;SELECT&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tables&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;BY&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;create_date&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;DESC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Eu sei que este post não é muito informativo, é mais uma dica.&lt;/p&gt;

&lt;p&gt;Abraços e até o próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Delegates em C# (Ponteiros de Função)</title>
   <link href="http://fabioyamate.com/2008/11/04/delegates-em-c-ponteiros-de-funo/"/>
   <updated>2008-11-04T09:23:07-02:00</updated>
   <id>http://fabioyamate.com/2008/11/04/delegates-em-c-ponteiros-de-funo</id>
   <content type="html">&lt;p&gt;Recentemente recordei uma das dificuldades que tive quando entrei no mundo .NET, aliás minha experiência era extremamente limitada se comparada a hoje, apesar de ter muita coisa para estudar.&lt;/p&gt;

&lt;p&gt;Pretendo neste post abordar um tópico muito importante do .NET framework que poucas pessoas usam ou desconhecem.&lt;/p&gt;

&lt;p&gt;Quem já programou em linguagens como C/C++ isso não deve ser um problema, a menos que tenha feito somente algoritmos básicos de estrutura de dados (pilhas, filas, listas e etc).&lt;/p&gt;

&lt;p&gt;Delegates é nada mais nada menos que um ponteiro para função. Ponteiro para muitos é um pesadelo, eu ainda tenho dificuldade quando começo a escrever um programa em C, sempre me esqueço das notações, pois em linguagens de alto nível como Java e C# elas ficam escondidas.&lt;/p&gt;

&lt;p&gt;Bom, entenda da seguinte maneira, digamos que você possua uma subrotina/função, se você souber onde ela se encontra em memória é possível invocá-la. Um ponteiro é um endereço para uma região da memória, no caso do delegate é ponteiro para uma subrotina/função.&lt;/p&gt;

&lt;p&gt;A questão é que em C# as coisas são tipadas, quando você define um delegate você define um contrato com quem quer &amp;quot;disponibilizar&amp;quot; um rotina ou função.&lt;/p&gt;

&lt;p&gt;A sintaxe é a seguinte:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;return_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyDelegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;params&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Por exemplo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Calcula&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Podemos referenciar um função qualquer que aceite dois inteiros e retorne um inteiro como resultado, poderiamos utilizar:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Soma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&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;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora definimos que um ponteiro para essa rotina da seguinte forma:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Calcula&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Soma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Simples, nâo?&lt;/p&gt;

&lt;p&gt;Antigamente para eventos usava-se a seguinte nomenclatura:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Calcula&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Calcula&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Soma&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Com o C# 2.0 podemos fazer assim:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Calcula&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&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;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&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;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ou podemos fazer, neste caso estranho:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Calcula&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// magic number detected!&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;O exemplo acima é meramente ilustrativo.&lt;/p&gt;

&lt;p&gt;Ok, agora que conhecemos as sintaxes vamos conhecer alguns delegates muito úteis já existentes no C#:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Action&lt;/strong&gt; (C#2)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Predicate&lt;/strong&gt; (C#2)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Func&lt;/strong&gt; (C#3)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Action&lt;/h2&gt;

&lt;p&gt;Action corresponde a uma ação a ser executada sobre um valor, onde T define o tipo de valor. Se você nâo conhece generics, sugiro que estude um pouco, não é nada complicado, só não entrarei em detalhes por que não é o escopo deste texto.&lt;/p&gt;

&lt;p&gt;O action recebe um parametro do tipo T, por exemplo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;printText&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&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;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Invocando:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;printText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Hello World&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Simples não? No caso, podemos alterar o valor de &amp;#39;s&amp;#39;, pois &amp;#39;s&amp;#39; é um reference type, ou seja, poderiamos tratar o texto, retirando por exemplo, todas as vírgulas do texto:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Action&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;removeVirgula&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&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;s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Replace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Empty&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;removeVirgula&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;“&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;World&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;”&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// produz Hello World&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Predicate&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A predicate is the portion of a clause, excluding the subject, that expresses something about the subject&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Predicate ou predicado corresponde a uma clausula a qual expressa alguma coisa. Digamos que desejamos saber se um número é par (even):&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Predicate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;even&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;delegate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&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;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&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;even&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// true&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;even&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Veja que retornamos um booleano para predicates, pois desejamos saber se o &amp;#39;number&amp;#39; que foi passado a rotina expressa o que meu predicado quer, no caso saber se o número é par.&lt;/p&gt;

&lt;h2&gt;Func (C#3)&lt;/h2&gt;

&lt;p&gt;E por último, existente apenas no C# 3.0 o Func. Diferente do Action e Predicate, o Fund possui 5 variações:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;T1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;T4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Bom, as assinaturas são muito claras e são lidas da seguinte forma: o tipo de retorno e nenhum parâmetro ou o tipo de retorno com 1 a 4 parâmetros.&lt;/p&gt;

&lt;p&gt;Acredito que o número de parâmetros são mais que suficientes, se a rotina começar a ter mais que esse número de parâmetros é possível que ela esteja fazendo mais coisas do que precisaria e podendo ser sub-divida em menores rotinas, facilitando tanto a leitura como reuso. Se você ainda assim achar que precisa de mais, bastaria criar uma outra assinatura com N parâmetros.&lt;/p&gt;

&lt;p&gt;Ok, você poderia pensar em fazer uma Func que tratasse a string e não retornasse nada por exemplo. Entretanto, esse tipo de retorno não é possível. Se você pretende usar Func&amp;lt;&amp;gt; você deve fato deseja retornar um valor.&lt;/p&gt;

&lt;p&gt;Quando lembro de function e subroutine me recordo de um trecho do texto do livro Code Complete 2nd Edition onde diferenciava o uso das duas palavras.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function&lt;/strong&gt;: é como definido na matemática, y = f(x), onde f é uma função. Ou seja, a função recebe um parâmetro e retorna um valor por definição.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subrountine&lt;/strong&gt;: já sub-rotina corresponde a uma tarefa a ser realizada, e não retorna valor. Se você já programou em Visual Basic deve ter notado a distinção delas.&lt;/p&gt;

&lt;p&gt;Bom, voltando. O correto se deseja usar um delegate com retorno void seria Action, porém ele só possui 1 parâmetro. Mas segundo este &lt;a href=&quot;http://www.google.com.br/url?sa=t&amp;amp;source=web&amp;amp;ct=res&amp;amp;cd=1&amp;amp;url=http%3A%2F%2Fforums.microsoft.com%2FMSDN%2FShowPost.aspx%3FPostID%3D1503788%26SiteID%3D1&amp;amp;ei=Q1IQSZL3EJXwvAWvuZ3dCg&amp;amp;usg=AFQjCNEew0h9mdJw9mUDfoGFeGswxYwfgA&amp;amp;sig2=G_rkx2m_geE866y41XVo1w&quot;&gt;link&lt;/a&gt; me parece que futuramente será extendido para mais parâmetros como o Func.&lt;/p&gt;

&lt;p&gt;O uso é praticamente o mesmo como mostrado para predicate e action, sendo um mix de ambos.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum&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;a&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;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&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;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// return 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Se não tivermos parâmetro algum, podemos usar:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Func&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CreateObject&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;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;object&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;kt&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CreateObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Observe que as delegates predefinidas como &lt;code&gt;Action&lt;/code&gt;, &lt;code&gt;Predicate&lt;/code&gt; e &lt;code&gt;Func&lt;/code&gt; não precisam ser obrigatóriamente usadas, você pode criar suas próprias assinaturas como foi feito no início deste post, mas se for possível usar as já existentes use, pois é uma linguagem comum para todos os programadores em C#, poderíamos ter um delegate &lt;code&gt;Process&amp;lt;T&amp;gt;&lt;/code&gt; igual a &lt;code&gt;Action&amp;lt;T&amp;gt;&lt;/code&gt;, se usasse &lt;code&gt;Action&lt;/code&gt;, seria muito claro o que pretende-se fazer. Não é uma regra, mas sempre que possível use as já predefinidas.&lt;/p&gt;

&lt;p&gt;Bom, o post ficou bem grande, tentei ser o mais detalhado e claro possível. Até um próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Proxy Pattern: Exemplo e Aplicação</title>
   <link href="http://fabioyamate.com/2008/09/20/proxy-pattern-exemplo-e-aplicao/"/>
   <updated>2008-09-20T17:05:12-03:00</updated>
   <id>http://fabioyamate.com/2008/09/20/proxy-pattern-exemplo-e-aplicao</id>
   <content type="html">&lt;p&gt;Desde meu último post acabei não cumprindo com o que esperava. Como já devo ter mencionado, estou cursando Engenharia da Computação Cooperativo, onde o curso intercala módulo acadêmico e estágio, permitindo tempo integral (desde que não tenha DPs para pagar). Comento sobre isso em outro post, vamos voltar ao assunto.&lt;/p&gt;

&lt;p&gt;Depois de realizar meu primeiro laboratório de engenharia de software, não adotar um framework na minha camada de persistência tornou muito trabalhoso sua modelagem e manutenção. Cada operação exigia escrita em código ou stored procedure o que tornava &amp;quot;uma tarefa simples&amp;quot; em trabalhosa, não que demorasse muito, mas depois de muitas linhas de coisas para coisas tão banais o processo ficava um tanto... chato.&lt;/p&gt;

&lt;p&gt;Desde então, tenho como objetivo aprender um framework para essa finalidade. Claro, não podia ficar de lado o &lt;a href=&quot;http://www.hibernate.org/&quot; target=&quot;_blank&quot;&gt;Hibernate&lt;/a&gt;, mas no momento estou curtindo C# e no caso temos o NHibernate. Conversei com um colega do trabalho e ele aparentemente não gostou muito do &lt;a href=&quot;http://www.nhibernate.org/&quot; target=&quot;_blank&quot;&gt;NHibernate&lt;/a&gt;. Não entrei muito em detalhes do por que ele era ruim, mas a comparação era bem direta se comparado com o Hibernate do Java. Portanto, ele costuma usar o ActiveRecord que usa como base o NHibernate.&lt;/p&gt;

&lt;p&gt;Mas nas últimas semanas saiu o NHibernate 2.0, apesar de a página não estar atualizada. E concerteza deve ter melhorado em muitos aspectos. Por isso escolhi o NHibernate como estudo. Pretendo falar mais sobre ele em outro post (quando der).&lt;/p&gt;

&lt;h2&gt;Resumo&lt;/h2&gt;

&lt;p&gt;O uso do (N)Hibernate é bem direto, use &lt;em&gt;POJO&lt;/em&gt; (Plain Old Java Object) ou &lt;em&gt;POCO&lt;/em&gt; (Plain Old C# Object), onde os objetos contém basicamente get/set. Talvez minha definição esteja um tanto incompleta, então me corrijam se falei absurdos.&lt;/p&gt;

&lt;p&gt;No Java todos os métodos por default podem ser overrided, bastando reescrevê-lo em sua classe estendida. Já no C# a coisa fica mais explicita. Por default nenhum método/property pode ser overrided, para tal é necessário acrescentar a keyword &amp;quot;virtual&amp;quot;, e quando realizamos um override a keyword &amp;quot;override&amp;quot;, já veremos um código.&lt;/p&gt;

&lt;p&gt;O que quero dizer com isso? Bem, como no Java isso já é default para todos os objetos então só é necessário definir os getters e setters da classe, já para o NHibernate todos os properties devem vir com a keyword virtual, caso contrário a coisa não funciona.&lt;/p&gt;

&lt;p&gt;Então me perguntei: por que tenho que colocar todas as properties como &amp;#39;virtual&amp;#39;?&lt;/p&gt;

&lt;p&gt;Bom, inicialmente achei que o NHibernate deveria simplesmente instanciar um objeto da entidade mapeada e então preencher todos os properties um a um. Mas o (N)Hibernate existe uma funcionalidade chamada de &lt;em&gt;Lazy Load&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;O que é Lazy Load?&lt;/h2&gt;

&lt;p&gt;Serei bem breve, digamos que você tenha um objeto e este possui uma referência para um outro objeto, seria um desperdício recurarmos o estado do objeto referenciado se nem usassémos ele. O que o lazy load faz é carregar este objeto (realizar a query no banco de dados) realmente quando precisamos. Mas como diabos isso ocorre?&lt;/p&gt;

&lt;p&gt;A resposta é usando &lt;em&gt;Proxy Pattern&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;O que ele faz é atuar como um proxy entre a chamada de um property/método. Uau, entendi nada, o que é proxy? &lt;/p&gt;

&lt;p&gt;Eu sempre me perguntava isso. Um proxy é digamos um &amp;quot;passo&amp;quot; intermediário de um fluxo. O exemplo mais comum é em redes de computadores. Digamos que sua máquina acesse a internet diretamente, ou seja, o seu computador e a &amp;quot;nuvem&amp;quot;. Se quisessemos realizar um filtro no neste tráfego, poderíamos utilizar um serviço de proxy que atua entre a nuvem e seu computador, de modo que todas as requisições passem sempre pelo proxy, tratando os dados trafegados e aplicando filtros adequadamente.&lt;/p&gt;

&lt;p&gt;Como implementamos um proxy pattern? Veja um exemplo bem simples abaixo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyClass&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Message&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&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;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;DoSomething&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;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Doing something really important.&amp;quot;&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;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyClassProxed&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyClass&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Message&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Proxying on reading...&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Message&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;set&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Proxying on saving...&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Message&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;value&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;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;override&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;DoSomething&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;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Proxying DoSomething() before&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Proxying DoSomething() after&amp;quot;&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;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;O que basicamente fazemos é extender a classe &lt;code&gt;MyClass&lt;/code&gt; criando uma &lt;code&gt;MyClassProxed&lt;/code&gt; dando override nos métodos e properties. Para testarmos, seria muito simples:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;MyClass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyClass&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;Message&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Normal behavior&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;MyClass.Message = {0}&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;MyClass.DoSomething()&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Normal behavior plus proxying&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MyClassProxed&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;Message&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;HelloWorld!&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;MyClass.Message = {0}&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;MyClass.DoSomething()&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;myClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Como a classe &lt;code&gt;MyClassProxed&lt;/code&gt; extende a class &lt;code&gt;MyClass&lt;/code&gt; basicamente a interface não muda, logo do nosso ponto de vista qual implementação usamos não importa, seja &lt;code&gt;MyClass&lt;/code&gt; ou &lt;code&gt;MyClassProxed&lt;/code&gt;, para nós o que importa é a interface da property Message e o método &lt;code&gt;DoSomething()&lt;/code&gt;. O resultado esperado é algo como:&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;216&quot; alt=&quot;proxy&quot; src=&quot;http://fabioyamate.com/images/2008/09/proxy.png&quot; width=&quot;519&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;h2&gt;Conclusão&lt;/h2&gt;

&lt;p&gt;Utilizando este pattern é possível realizar o lazy load de forma transparente para o desenvolvedor.&lt;/p&gt;

&lt;p&gt;Esse pattern é bem conhecido e pode ser encontrado no livro Design Patterns, Elements of Reusable Object-Oriented Software do GoF (Gang Of Four), que por sinal é uma leitura básica para qualquer desenvolver.&lt;/p&gt;

&lt;p&gt;Infelizmente, o conteúdo do livro não é de fácil digestão quando sua experiência como desenvolvedor é pequena, muitos patterns não fazem sentido pois você não consegue comporrender os problemas de implementação que existem.&lt;/p&gt;

&lt;p&gt;Espero poder dar continuidade neste tipo de post, até uma próxima vez.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Acabaram as aulas… de volta a ativa!</title>
   <link href="http://fabioyamate.com/2008/08/26/acabaram-as-aulas-de-volta-a-ativa/"/>
   <updated>2008-08-26T08:42:36-03:00</updated>
   <id>http://fabioyamate.com/2008/08/26/acabaram-as-aulas-de-volta-a-ativa</id>
   <content type="html">&lt;p&gt;Com 1 dia de atraso, informo que estou de volta a ativa. Essas últimas duas semanas e 1 dia foram extremamente carregadas para mim na faculdade (&lt;a href=&quot;http://www.poli.usp.br&quot; target=&quot;_blank&quot;&gt;POLI-USP&lt;/a&gt;). Foram muitas provas e trabalhados que ficaram agrupados num curto espaço de tempo. Ontem, foi o último dia e não escrevi por que eu não dormi, de domingo para segundo, pois estava tentando fechar a apresentação de um projeto de software para segunda. Infelizmente não foi possível concluí-lo, mais um dia e teríamos concluído.&lt;/p&gt;

&lt;p&gt;De fato, isso é muito ruim do ponto de vista comercial, se pensarmos que a data de prazo não foi possível concluir o sistema. Entretanto, eu não tive um mês dedicado para executar o projeto, tinha que organizar o horário, aula-provas-trabalhos de outras matérias também. Bom, chega disso.&lt;/p&gt;

&lt;p&gt;Com esse termíno estarei em tempo integral em período de estágio e com isso tenho mais liberdade para voltar a escrever e estudar coisas novas!&lt;/p&gt;

&lt;p&gt;Como hoje é so o primeiro dia, aproveitei ontem para recarregar as energias e poder voltar a me integrar no mundo tecnológico o qual estive por fora nas últimas duas semanas.&lt;/p&gt;

&lt;p&gt;Só para encerrar o post, para quem ainda não viu, brinquem com o &lt;a href=&quot;http://www.photosynth.com/&quot; target=&quot;_blank&quot;&gt;Photosynth&lt;/a&gt; da &lt;a href=&quot;http://www.microsoft.com/&quot; target=&quot;_blank&quot;&gt;Microsoft&lt;/a&gt;, é muito divertido e incrível o que ele faz!&lt;/p&gt;

&lt;p&gt;Abraços e até um próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Programando para Office 2007 com C#... que nada, VB.NET!</title>
   <link href="http://fabioyamate.com/2008/08/02/programando-para-office-2007-com-c-que-nada-vbnet/"/>
   <updated>2008-08-02T22:48:09-03:00</updated>
   <id>http://fabioyamate.com/2008/08/02/programando-para-office-2007-com-c-que-nada-vbnet</id>
   <content type="html">&lt;p&gt;Não você não leu errado, escrevi VB.NET (Visual Basic dot Net), isso mesmo.&lt;/p&gt;

&lt;p&gt;Eu nunca pensei que algum dia programaria em VB, já programei com VBScript na primeira versão do ASP (há muitos anos atrás), nem conhecia PHP. Nesta época, eu procurava por uma forma de fazer páginas dinâmicas, que para mim naquela época pensava: &amp;quot;Essas páginas HTML não fazem p@&amp;amp;*# nenhuma?&amp;quot;, então tinha que ver um jeito de resolver isso. Depois migrei para PHP onde gostei mais, por haver servidores públicos abertos (open source e bla-bla-bla), mas essas histórias ficam para outro post.&lt;/p&gt;

&lt;p&gt;Bom, já tive de programar com VBA para Excel, cheguei a escrever um post sobre isso, minha experiência não foi boa, apesar de ter concluído tarefa que tinha de fazer.&lt;/p&gt;

&lt;p&gt;Mas VBA é coisa do &amp;quot;passado&amp;quot;, a partir do Office 2003 foi incorporado o VSTO (Visual Studio Tools for Office) que permite fazer coisas mais &amp;quot;bacanas&amp;quot;, assim dizendo, através de addins para o Excel (posso estar completamente errado, talvez isso já exista há anos mas para mim é coisa nova).&lt;/p&gt;

&lt;p&gt;Como a plataforma é .NET, fica a escolha do programador escolher entre C# ou VB. Entretanto para esses tipos de desenvolvimento em particular, acredito que para o pessoal do VB a tarefa seja um tanto mais, prática.&lt;/p&gt;

&lt;p&gt;Eu nunca gostei da sintaxe do VB, acho muito poluído, odeio o esquema de declaração de váriaveis:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vb.net VB
Dim texto As String = &amp;quot;texto&amp;quot;
Dim conn As SqlConnection = New SqlConnection(cs)
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;csharp C#
string texto = &amp;quot;texto&amp;quot;;
SqlConnection conn = new SqlConnection(cs)
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Argh, coisa feia! Em termos de tamanho não varia muito, mas em clareza e facilidade de leitura prefiro o C#.&lt;/p&gt;

&lt;p&gt;Mas vou dizer aqui algum dos motivos do por que VB é melhor que C# para desenvolvimento Office:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;VBA para VB é parecido (senão igual)&lt;/li&gt;
&lt;li&gt;Todos as macros de VBA são facilmente portáveis para VB&lt;/li&gt;
&lt;li&gt;Passagem de parâmetros para rotinas &amp;quot;dinâmico&amp;quot;&lt;/li&gt;
&lt;li&gt;Properties ou métodos diretos, como: Value e Offset&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Até onde eu estou estudando essas foram os grandes motivos de se trabalhar com VB.&lt;/p&gt;

&lt;p&gt;``` vb.net VB
Dim wb As Excel.Workbook = Me.Application.Workbook
Dim ws As Excel.Worksheet = wb.Sheets(1)&lt;/p&gt;

&lt;p&gt;Dim range As Excel.Range = ws.Range(&amp;quot;A1&amp;quot;) // posso passar apenas row ou (row, col)
```&lt;/p&gt;

&lt;p&gt;``` csharp C#
Excel.Workbook wb = this.Application.Workbook;
Excel.Worksheet ws = wb.Sheets[1];&lt;/p&gt;

&lt;p&gt;Excel.Range range = ws.get_Range(&amp;quot;A1&amp;quot;, missing); // tenho que preencher todos
```&lt;/p&gt;

&lt;p&gt;Em C#, eu preciso passar todos os campos, ou seja, quando não desejado é preciso passar &lt;code&gt;missing&lt;/code&gt;. Também não temos um método direto como &lt;code&gt;Range(cell, cell)&lt;/code&gt;. Temos que usar os métodos, &lt;code&gt;set_Range&lt;/code&gt;, &lt;code&gt;get_Offset&lt;/code&gt; entre muitos outros.&lt;/p&gt;

&lt;p&gt;Outro ponto que é irritante também é em rotinas:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vb.net VB
Dim ws As Excel.Worksheet = ...
ws.Protect(&amp;quot;password&amp;quot;) // simples e direto
// quero content como false
ws.Protect(&amp;quot;password&amp;quot;, Content := False) // indolor
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;csharp C#
Excel.Worksheet ws = ...;
// preciso passar todos os parametros
ws.Protect(&amp;quot;password&amp;quot;, missing, missing, missing, ..., missing);
// quero content como false
ws.Protect(&amp;quot;password&amp;quot;, missing, false, missing, missing, ...); // meu deus...
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Infelizmente para o pessoal do C# trabalhar com Office fica um tanto irritante.&lt;/p&gt;

&lt;p&gt;Por este motivo acho que trabalhar com VB agiliza e facilita as coisas, embora tenha que aprender como é a sintaxe do VB, mas aposto que o ganho será muito maior do que ter que programar em C#.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Banco de Dados e Null values</title>
   <link href="http://fabioyamate.com/2008/07/30/banco-de-dados-e-null-values/"/>
   <updated>2008-07-30T19:30:13-03:00</updated>
   <id>http://fabioyamate.com/2008/07/30/banco-de-dados-e-null-values</id>
   <content type="html">&lt;p&gt;É comum na modelagem de banco de dados termos colunas com valores nulos. Para tipos como string, que são &amp;quot;reference type&amp;quot;, valor null é extremamente comum, mas e quanto a valores primitivos como: int, float, double, DateTime (struct no C#) e entre outros?&lt;/p&gt;

&lt;p&gt;Na versão 2.0 do .NET, sim numa versão já adotada no mercado (.NET 1.1 é bem pouco, espero) apresentou o conceito de Nullable Types que permite você inferir valores nulos à built-in types (ou tipos primitos). Não irei entrar em detalhes muito profundos, pois pretendo ser breve nest post.&lt;/p&gt;

&lt;p&gt;A sintaxe é bem simples:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;kt&quot;&gt;int?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// dois properties para Nullable Types, HasValue e Value&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HasValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WriteLine&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Assim podemos atribuir valores para nulos e não mais valores &lt;em&gt;default&lt;/em&gt; para estes tipos de dados.&lt;/p&gt;

&lt;p&gt;Ok, isso é bonito mas o &lt;code&gt;IDataReader&lt;/code&gt; não possui um método para tratar quando valores são nulos, o que fazemos? Realizamos uma checagem com o método &lt;code&gt;IsDbNull&lt;/code&gt;, e se for podemos retornar nulo ou o valor caso OK. Veja abaixo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;int? coluna = reader.IsDBNull(i) ? (int?)null : (int?)reader.GetInt32(i);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Isso resolveria o nosso problema, mas e se tivermos 10 colunas na tabela, esse código polui um pouco, não? Pena que o GetInt32(int i) não lida com campos nulos.&lt;/p&gt;

&lt;p&gt;Como podemos melhorar isso?&lt;/p&gt;

&lt;p&gt;Podemos usar &lt;strong&gt;Extension Methods&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Num &lt;a href=&quot;http://www.fabioyamate.com/blog/2008/05/23/extension-methods-is-like-a-magic/&quot; target=&quot;_blank&quot;&gt;post anterior&lt;/a&gt; eu cheguei a falar bem básicamente sobre extension methods, veja como resolveríamos este problema:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DataReaderTypeHelper&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GetNullOrInt32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IDataReader&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&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;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsDBNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;null&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;kt&quot;&gt;int?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetInt32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;GetNullOrString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IDataReader&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&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;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsDBNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;null&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GetNullOrDateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IDataReader&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&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;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsDBNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;null&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;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;?)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetDateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&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;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora podemos este método e tornar a coisa mais bonita e direta:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;kt&quot;&gt;int?&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;coluna&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetNullOrInt32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Muito mais simples, fácil e direto de usar. Podemos fazer também para inserção, remoção ou atualização onde valores nulos encrencam no banco de dados também. Normalmente teríamos que fazer:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AddWithValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;@param1&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;param1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AddWithValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;@param2&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;param2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Se usassemos o código acima, se &lt;em&gt;@param2&lt;/em&gt; &lt;u&gt;pudesse ser nulo&lt;/u&gt; no banco de dados, este código geraria uma &lt;em&gt;SqlException&lt;/em&gt; caso o valor de &lt;em&gt;param2&lt;/em&gt; fosse nulo, pois o null do c# é diferente do null para o banco de dados, então teríamos que verificar o valor e assim retornar &lt;em&gt;DBNull.Value&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Com Nullable Types, isso ficaria extremamente simples, nada de &lt;code&gt;if&lt;/code&gt;&amp;#39;s:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AddWithValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;@param2&amp;quot;&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;kt&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param2&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DBNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Observe que temos de fazer um cast para object em &lt;code&gt;param2&lt;/code&gt;, pois para o compilador o operador &lt;code&gt;??&lt;/code&gt; deve garantir que &lt;code&gt;param2&lt;/code&gt; e &lt;code&gt;DBNull.Value&lt;/code&gt; sejam do mesmo tipo, por que Nullable usa Generics para inferir tipos, embora mascare isso.&lt;/p&gt;

&lt;p&gt;Usando novamente Extension Methods podemos fazer uma classe que nos ajude nisso:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DbHelper&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;AddWithValueOrNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SqlParameterCollection&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;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;param&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;value&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;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AddWithValue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;param&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;kt&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;??&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DBNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Agora temos um método &lt;strong&gt;AddWithValueOrNull&lt;/strong&gt; para o Parameters que é do tipo SqlParametersCollection. Assim encapsulamos tudo numa sintaxe mais limpa:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Parameters&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AddWithValueOrNull&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;@param2&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;param2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt; usamos este método apenas para valores que possam ser nulos e não para todos, no caso de &lt;em&gt;chaves primárias&lt;/em&gt; devemos usar o &lt;code&gt;AddWithValue&lt;/code&gt; mesmo por que devemos reforçar a necessidade de valores não nulos.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Projetos do Visual Studio com Subversion</title>
   <link href="http://fabioyamate.com/2008/07/22/projetos-do-visual-studio-com-subversion/"/>
   <updated>2008-07-22T16:28:08-03:00</updated>
   <id>http://fabioyamate.com/2008/07/22/projetos-do-visual-studio-com-subversion</id>
   <content type="html">&lt;p&gt;Baseado no post anterior, pretendo escrever uma série de posts usando o &lt;a href=&quot;http://tortoisesvn.tigris.org/&quot; target=&quot;_blank&quot;&gt;TortoiseSVN&lt;/a&gt; para trabalhar com controle de versão num projeto que estou realizando, que se der pretendo colocar minhas experiências aqui, mas isto fica para outros posts.&lt;/p&gt;

&lt;p&gt;O Visual Studio não possui integrado outros controles de versão senão o &lt;a href=&quot;http://msdn.microsoft.com/en-us/vs2005/aa718670.aspx&quot; target=&quot;_blank&quot;&gt;Visual Source Safe&lt;/a&gt; (VSS) da própria Microsoft. Eu já trabalhei com o VSS numa empresa o qual estagiei, mas era disponível para desenvolvimento numa rede local. Ter um servidor rodando Windows e com o VSS não é nada comum. Por este motivo optei pelo &lt;a href=&quot;http://subversion.tigris.org/&quot; target=&quot;_blank&quot;&gt;Subversion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;No post anterior, expliquei sobre como importar um projeto no repositório, dar checkout e realizar um commit simples. Agora vou citar algumas configurações que devem ser feitas quando lidamos com solutions do Visual Studio.&lt;/p&gt;

&lt;p&gt;Uma solução é composta de 1 ou mais projetos, estas informações ficam no arquivo &lt;code&gt;*.sln&lt;/code&gt;. Cada projeto é compilado e gera dois diretórios &lt;code&gt;bin&lt;/code&gt; e &lt;code&gt;obj&lt;/code&gt;. Estes arquivos não são de interesse ao controle de versão, uma vez que a responsabilidade dele é apenas gerenciar códigos.&lt;/p&gt;

&lt;p&gt;Portanto, devemos eliminar estes diretórios do repositório para isso utilizamos properties do SVN, usando a property svn:ignore.&lt;/p&gt;

&lt;p&gt;A configuração do property é particular de um diretório e fica registrado nos arquivos contidos no diretório &lt;code&gt;.svn&lt;/code&gt; (ou &lt;code&gt;_svn&lt;/code&gt;) que só podem ser vistos se alterar a visualização de arquivos do Windows para exibir arquivos ocultos. Pelo fato desta configuração ser inserida nestes diretórios, ao criarmos um projeto novo que não esta no repositório, esta informação não fica registrada para este projeto, resultando na adição dos diretórios &lt;code&gt;bin&lt;/code&gt; e &lt;code&gt;obj&lt;/code&gt;. Seria necessário selecionar manualmente cada arquivo que seria submetido excluindo tudo que tem relação com o diretório &lt;code&gt;bin&lt;/code&gt; e &lt;code&gt;obj&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Para este problema podemos declarar globalmente o que remover. Assim teremos de remover os seguintes arquivos para uma solução no SVN:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;bin obj *.suo *.user
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;bin&lt;/strong&gt; e &lt;strong&gt;obj&lt;/strong&gt; - são diretório de arquivos binários (compilados)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;*.suo&lt;/strong&gt; - corresponde às configurações de usuário para a solução&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;*.user&lt;/strong&gt; - corresponde às configurações de usuário para o projeto&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A seguir vou apresentar como realizar cada operação (inserindo properties e &lt;em&gt;global ignore&lt;/em&gt;) e comentários sobre problemas que tive e como tratei eles.&lt;/p&gt;

&lt;h2&gt;Ignorando Diretórios e Arquivos no Subversion&lt;/h2&gt;

&lt;p&gt;Num diretório com o projeto gerenciado pelo SVN, clique com o direito e TortoiseSVN &amp;gt; Properties, como ilustra a figura abaixo:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/07/tsvn-04.jpg&quot;&gt;&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;443&quot; alt=&quot;tsvn_04&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-04-thumb.jpg&quot; width=&quot;399&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;

&lt;p&gt;Em seguida vamos adicionar uma properti svn:ignore com valores&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;bin obj *.suo *.user
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Com espaços entre cada entrada&lt;/em&gt;, marque a opção: Apply property recursively. Isso irá aplicar a todos os subdiretórios recursivamente a mesma property facilitando o trabalho de ter que replicar a mesma configuração para todos os diretórios.&lt;/p&gt;

&lt;p&gt;Entretanto, os diretórios que não estão sobre controle (sem .svn/_svn) não terão esta restrição, entao ao dar um Add os arquivos não desejados serão adicionados, sendo necessário fazer a seleção manual. Para este problema a melhor solução é usar configurações globais de ignore aplicando isso a qualquer diretório.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;320&quot; alt=&quot;tsvn_03&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-031.jpg&quot; width=&quot;362&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;h2&gt;Ignorando Globalmente Arquivos e Diretórios&lt;/h2&gt;

&lt;p&gt;Vá em TortoiseSVN &amp;gt; Settings&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;381&quot; alt=&quot;tsvn_01&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-011.jpg&quot; width=&quot;417&quot; border=&quot;0&quot;&gt;&lt;/p&gt;

&lt;p&gt;Adicione os elementos &amp;quot;bin obj *.suo *.user&amp;quot; como feito acima em &amp;quot;&lt;em&gt;Global ignore patterns&lt;/em&gt;&amp;quot;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/07/tsvn-022.jpg&quot;&gt;&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;300&quot; alt=&quot;tsvn_02&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-02-thumb1.jpg&quot; width=&quot;420&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Agora o trabalho de dar Add simplificou, garantindo que será adicionado apenas arquivos de código ou necessários para a solução.&lt;/p&gt;

&lt;h2&gt;Problemas e Soluções&lt;/h2&gt;

&lt;p&gt;Um dos detalhes que tem que se considerar quando se trata de Visual Studio é que os arquivos que gerenciam os arquivos de solução e projeto, são atualizados somente se for realizando um build da solução e projeto.&lt;/p&gt;

&lt;p&gt;Por exemplo, se adicionamos uma referência a um projeto ou *.dll o arquivo que gerencias estas referências será alterando somente se houver alguma classe que referêncie a ela, usando o using por exemplo.&lt;/p&gt;

&lt;p&gt;Da mesma forma, para remover uma referência não utilizada mais, é preciso removê-la do references e em seguida executar um Build do projeto ou solução para que as alterações sejam registradas no arquivo e assim resultar numa nova versão do arquivo.&lt;/p&gt;

&lt;p&gt;Outra situação é se você já deu commit nos arquivos que devem ser ignorados. O jeito é removê-los antes de aplicar o ignore, senão você não terá como dar commit nos arquivos deletados. Realize estas operações com a solução fechada no Visual Studio.&lt;/p&gt;

&lt;p&gt;Uma vez corrigido você poderá aplicar as restrições e assim colocar ordem no repositório.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Usando TortoiseSVN como cliente para o Subversion</title>
   <link href="http://fabioyamate.com/2008/07/21/usando-tortoisesvn-como-cliente-para-o-subversion/"/>
   <updated>2008-07-21T16:19:05-03:00</updated>
   <id>http://fabioyamate.com/2008/07/21/usando-tortoisesvn-como-cliente-para-o-subversion</id>
   <content type="html">&lt;p&gt;Todo desenvolvedor um dia irá trabalhar em equipe e não há como trabalhar sem um controle de versão. Temos vários sistemas para esta tarefa mas há dois principais: &lt;a href=&quot;http://en.wikipedia.org/wiki/Concurrent_Versions_System&quot; target=&quot;_blank&quot;&gt;CVS&lt;/a&gt; (Concurrent Versions System) e &lt;a href=&quot;http://subversion.tigris.org/&quot; target=&quot;_blank&quot;&gt;SVN&lt;/a&gt; (Subversion). Entre eles o SVN, do que vejo, tem sido o mais usado.&lt;/p&gt;

&lt;p&gt;Novamente, como no post anterior sobre o Grep, sou usuário Windows e interface é mais prático que linha de comando, pelo menos para mim.&lt;/p&gt;

&lt;p&gt;Em termos de cliente para SVN o TortoiseSVN é o mais popular, e é mantido pelo próprio pessoal do SVN.&lt;/p&gt;

&lt;p&gt;Pretendo, nos próximos posts mostrar como usar ele para trabalhar. Já trabalhei com Eclipse e Netbeans quando programei em Java e ambos integram diretamente com o IDE tanto para CVS como SVN.&lt;/p&gt;

&lt;p&gt;No momento estou realizando um projeto em .NET usando Visual Studio, e infelizmente ele só trabalha com o Source Safe (da Microsoft) como controle de versão, não sendo possível usar o SVN nem o CVS diretamente. Existem soluções para isso, mas não é o intuito deste post.&lt;/p&gt;

&lt;p&gt;Este post também não pretende mostrar como configurar um servidor local SVN, pode ficar para um outro post.&lt;/p&gt;

&lt;p&gt;Baixe o TortoiseSVN &lt;a href=&quot;http://tortoisesvn.tigris.org/&quot; target=&quot;_blank&quot;&gt;aqui&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Importando o Projeto Inicial&lt;/h2&gt;

&lt;p&gt;Agora vou entrar num ponto em que me confundiu demais e acredito para outros também. No SVN o Import refere-se a Importar um projeto ao SVN e não importar um projeto do SVN, como da-se a entender.&lt;/p&gt;

&lt;p&gt;Selecione o diretório com o projeto existe e clique com o botão direito sobre ele e TortoiseSVN &amp;gt; Import&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;157&quot; alt=&quot;tsvn_01&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-01.jpg&quot; width=&quot;449&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;p&gt;Uma janela irá aparecer e será pedido a URL do servidor SVN e uma mensagem import.&lt;/p&gt;

&lt;h2&gt;Checkout&lt;/h2&gt;

&lt;p&gt;Uma vez feito isso é possível realizar o primeiro Checkout. O Checkout irá baixar uma versão do repositório podendo ser HEAD (a corrente) ou uma versão qualquer existente. Cada commit corresponde a uma versão.&lt;/p&gt;

&lt;p&gt;Crie um diretório e com o botão direito Checkout SVN...&lt;/p&gt;

&lt;p&gt;Após o checkout o diretório irá ficar marcado com um símbolo de OK.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;99&quot; alt=&quot;tsvn_02&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-02.jpg&quot; width=&quot;87&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;h2&gt;Adicionando Arquivos ao Repositório&lt;/h2&gt;

&lt;p&gt;Crie um arquivo no diretório o qual o projeto está guardado e clique em TortoiseSVN &amp;gt; Add.&lt;/p&gt;

&lt;p&gt;Um sinal de &amp;quot;+&amp;quot; será marcado no arquivo dizendo que ele foi adicionado. Isso é necessário sempre que um novo arquivo for criado. O diretório com alterações ficará marcado com uma &amp;quot;!&amp;quot;&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;97&quot; alt=&quot;tsvn_03&quot; src=&quot;http://fabioyamate.com/images/2008/07/tsvn-03.jpg&quot; width=&quot;90&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;p&gt;Feito esta etapa o arquivo ainda não foi submetido ao repositório, para isso é necessário realizar um commit.&lt;/p&gt;

&lt;p&gt;TortoiseSVN &amp;gt; Commit&lt;/p&gt;

&lt;p&gt;Será pedido uma mensagem identificando o motivo do commit. É importante ser claro e objetivo para que quando necessário retornar um versão saber a que ela representa.&lt;/p&gt;

&lt;p&gt;Uma vez realizado o commit a revisão será incrementada e o diretório ficará marcado com um OK novamente.&lt;/p&gt;

&lt;p&gt;Até um próximo post sobre o TortoiseSVN.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Buscando palavras em arquivos com Windows Grep</title>
   <link href="http://fabioyamate.com/2008/07/12/buscando-palavras-em-arquivos-com-windows-grep/"/>
   <updated>2008-07-12T10:30:42-03:00</updated>
   <id>http://fabioyamate.com/2008/07/12/buscando-palavras-em-arquivos-com-windows-grep</id>
   <content type="html">&lt;p&gt;Mudando um pouco o estilo do blog que era postar coisas técnicas, apesar de não ter feito isso ultimamente.&lt;/p&gt;

&lt;p&gt;Recentemente tive que implementar um driver para um projeto do curso de Sistemas Operacionais que estou fazendo. O sistema operacional estudado é o &lt;a href=&quot;http://www.minix3.org/&quot; target=&quot;_blank&quot;&gt;Minix 3&lt;/a&gt; que é opensource é apresenta elementos básicos de sistemas operacionais.&lt;/p&gt;

&lt;p&gt;Entretanto, minha experência com C é muito básica, e é um tanto chato ficar varrendo arquivos e arquivos, mesmo usando o visual studio, para ir atrás de referências ou coisas do tipo. O intellisense para C/C++ não é tão bom como para C#, mas ajuda bastante.&lt;/p&gt;

&lt;p&gt;O que precisei fazer era ficar buscando palavras ou códigos que usassem determinada rotina para fazer inspeção de código e entender como o mecanismo funciona.&lt;/p&gt;

&lt;p&gt;Apesar de Visual Studio ter o &amp;quot;Find All References&amp;quot; ele não funciona muito bem. Tem também a opção de usar o Ctrl+F e fazer um &amp;quot;bookmark all&amp;quot; de todas as buscas, mas não sei por que diabos ele não funciona para buscam no projeto, ele só vale para o &amp;quot;Current Document&amp;quot;.&lt;/p&gt;

&lt;p&gt;Para o pessoal do linux os shells scripts (ou qualquer outro script) são poderosos. O pessoal do Windows é meio ignorante com linha de comando. Eu estou tentando usar o shell mas as vezes demoro muito para fazer coisas simples, mas é so tentando que se aprende. Nós sempre precisamos de uma alternativa gráfica, por que é muito mais simples e prático.&lt;/p&gt;

&lt;p&gt;Pensando nisso estou escrevendo sobre o &lt;a href=&quot;http://www.wingrep.com/&quot; target=&quot;_blank&quot;&gt;Windows Grep&lt;/a&gt; ou wingrep que faz esse serviço para nós.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;469&quot; alt=&quot;mainwindow1&quot; src=&quot;http://fabioyamate.com/images/2008/07/mainwindow11.png&quot; width=&quot;500&quot; border=&quot;0&quot;&gt; &lt;/p&gt;

&lt;p&gt;Você coloca os diretório de onde quer buscar e escreve a expressão regular que deseja como filtro e esperar ele fazer a busca. Uma coisa muito boa é que ele lista arquivo por arquivo e mostra trechos de código do arquivo. Vale a pena.&lt;/p&gt;

&lt;p&gt;Existe também uma versão do grep para console, não tem muito segredo o código, mas coisa que notei que o windows não vem! Eu usava no meu PC achando que era nativo do windows até usar outro computador e não existe o comando. No lugar dele usa-se o find.&lt;/p&gt;

&lt;p&gt;Nota. Não estou ganhando nada pela divulgação, apenas sugerindo uma ferramenta que todo mundo deveria ter.&lt;/p&gt;

&lt;p&gt;Até um próximo post!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Logitech VX Nano chegou!</title>
   <link href="http://fabioyamate.com/2008/06/30/logitech-vx-nano-chegou/"/>
   <updated>2008-06-30T16:08:28-03:00</updated>
   <id>http://fabioyamate.com/2008/06/30/logitech-vx-nano-chegou</id>
   <content type="html">&lt;p&gt;Comprei recentemente um mouse para o notebook o qual tenho trabalhado bastante. Depois que comprei o
&lt;a href=&quot;http://fabioyamate.com/2008/06/13/refrescando-o-notebook/&quot; target=&quot;_blank&quot;&gt;cooler de
notebook&lt;/a&gt; o rendimento melhor muito, tornando o trabalho muito mais agradável.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px;
border-right-width: 0px&quot; height=&quot;380&quot; alt=&quot;logitech_vx_nano_03&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-03.jpg&quot; width=&quot;500&quot;
border=&quot;0&quot;&gt;&lt;/p&gt;

&lt;p&gt;Entretanto, o notebook estava sem um mouse próprio. Estava usando o mouse do desktop junto com o
notebook, mas desktop sem mouse é bem diferente de notebook sem mouse, por que tem o trackpad.&lt;/p&gt;

&lt;p&gt;Bom, apesar de gostar de mouses ergonômicos, desta vez resolvi escolher um mouse para notebooks.
Muitas opções. Foquei inicialmente nos mouses da Microsoft. Mas alguns reviews me deixavam em
dúvida, até que vi boas recomendações para o &amp;quot;Logitech VX Nano Cordless Laser Mouse for Notebooks&amp;quot;
(nome pequeno não?) e resolvi comprá-lo.&lt;/p&gt;

&lt;p&gt;Um dos principais fatores de escolher foi o receptor. O menor receptor que existe. Tenho experiência
com esses dispositivos USB que ficam salientes no notebook, e é horrível. Tenho um receptor USB
Wireless (por que o notebook é de 2003 e não vinha com wireless de fábrica como existe hoje em dia),
e se ocorre um problema de contato da crash no Windows (problemas com driver). Não. Não estou
reclamando do windows, estou dizendo que por um problema de driver ele trava.&lt;/p&gt;

&lt;p&gt;Ainda estou experimentando o mouse, minha primeira experiência também com mouse wireless, até então
todos eram com fio.&lt;/p&gt;

&lt;p&gt;Hardware/acessório tem sido um dos elementos que tenho priorizado na minha compra, não compro o
barato, prefiro comprar um hardware realmente bom que me vai durar anos e anos do que trocar a cada
&amp;quot;X&amp;quot; meses. (Meus mouses da microsoft já tem anos de vida e funcionam perfeitamente.)&lt;/p&gt;

&lt;p&gt;Vamos ao que interessa, o review.&lt;/p&gt;

&lt;h2&gt;Review&lt;/h2&gt;

&lt;p&gt;O mouse é pequeno. Repito. O mouse é pequeno. Para quem gosta de mouse que encaixa perfeitamente na
mão, não compre por que vai reclamar. Apesar disso o mouse é confortável de usar, é estranho a
migração mas é algo que precisa acostumar.&lt;/p&gt;

&lt;p&gt;A primeira coisa que senti foi a sensibilidade. Ainda não consegui ajustar perfeitamente a
sensibilidade do mouse. A precisão que estou tendo com ele não está tão bom como estava com o antigo
mouse, preciso ajustar ele nas configurações.&lt;/p&gt;

&lt;p&gt;Outro detalhe é que por ele ser sensível demais ele acaba afetando a configuração do trackpad, por
que preciso reduzir ele (nem sempre temos o mouse por perto).&lt;/p&gt;

&lt;p&gt;Os botões que existem para avançar/voltar são muito estranhos. Ainda não me adaptei. Estou
acostumado ao mouse da Microsoft que tem os botões auxiliares nas laterais, ficando sob o dedão e
anelar, ficando muito fácil avançar e voltar, enquanto que no logitech eles ficam acessíveis pelo
indicador.&lt;/p&gt;

&lt;p&gt;Outra coisa que me decepcionou muito foi o botão do meio que não funciona pelo scroller (como na
maioria dos mouses). Tive que configurar o botão central (que vem configurado como botão de busca)
para essa finalidade, por que adoro fechar as abas clicando com o botão do mouse ao invés de clicar
no &amp;#39;x&amp;#39;.&lt;/p&gt;

&lt;p&gt;Essas são as primeiras impressões de muitos anos usando um mouse diferente deste, não considere as
descrições acima como destruição do mouse. O mouse não é ruim, só deixa a desejar nessas
funcionalidades.&lt;/p&gt;

&lt;p&gt;Em breve devo fazer um update sobre após 1 semana de uso com ele.&lt;/p&gt;

&lt;p&gt;Abaixo segue umas fotos que tirei dele.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[update 02.07.2008]&lt;/strong&gt; Já estou usando o mouse por 48hs, e tenho boas impressões sobre, apesar de
pequeno e não encaixar corretamente na minha mão.&lt;/p&gt;

&lt;p&gt;Uma das funcionalidades que o mouse vem é o &lt;strong&gt;Hyper-fast scrolling&lt;/strong&gt; que permite uma scroll rápido e
suave. Ao contrário de muitos mouse, o scroller tem um certo &amp;quot;atrito&amp;quot; que de certo modo da mais
controle ao usuário no scroll, podendo dosar melhor a velocidade e posição. O &lt;strong&gt;Hyper-fast
scrolling&lt;/strong&gt; não possui atrito, e se você aplicar uma aceleração no scroller ele fica girando até que
ele para, existe atrito ele não é ideal. Isso é muito bom para rolar bastante páginas, mas em
determinados momentos ele é ruim para precisão, as vezes se quer deslocar um pedaço e ele desloca
demais. Isto estava me incomodando um pouco. Até que tirei ele do case que vem junto e o scroll
estava diferente, pensei &amp;quot;putz quebrou&amp;quot;, mas não era isso. O scroll do mouse possui dois estados, ou
com o hyper-fast ou o normal que havia dito, basta pressionar o botão central, não é um simples
click, tem que pressionar mesmo que ele alterna entre os modos, muito bom!&lt;/p&gt;

&lt;p&gt;Até agora não me queixo, já estou me adaptando aos botões auxiliares que ficam no click esquerdo.
Quando tiver mais impressões sobre ele eu atualizo o post.&lt;/p&gt;

&lt;p&gt;Nota: quando procurei pelo VX Nano foquei principalmente no tamanho e o receptor do nano me chamou
muita atenção. Existem muitas pessoas que gostam que o mouse se encaixe perfeitamente na mão. Eu
também concordo com a opinião deles, mas nesse caso acho que o nano está de bom tamanho. Mas para
quem quer uma outra opção existe o VX Revolution que é maior, consequentemente o receptor também.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-05.jpg&quot;&gt;&lt;img
style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width:
0px&quot; height=&quot;200&quot; alt=&quot;logitech_vx_nano_05&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-05-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot;&gt;&lt;/a&gt; &lt;a
href=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-08.jpg&quot;&gt;&lt;img
style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width:
0px&quot; height=&quot;200&quot; alt=&quot;logitech_vx_nano_08&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-08-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot;&gt;&lt;/a&gt; &lt;a
href=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-10.jpg&quot;&gt;&lt;img
style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width:
0px&quot; height=&quot;200&quot; alt=&quot;logitech_vx_nano_10&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-10-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot;&gt;&lt;/a&gt; &lt;a
href=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-12.jpg&quot;&gt;&lt;img
style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width:
0px&quot; height=&quot;200&quot; alt=&quot;logitech_vx_nano_12&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-12-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot;&gt;&lt;/a&gt; &lt;a
href=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-14.jpg&quot;&gt;&lt;img
style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width:
0px&quot; height=&quot;200&quot; alt=&quot;logitech_vx_nano_14&quot;
src=&quot;http://fabioyamate.com/images/2008/06/logitech-vx-nano-14-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Metal Gear Solid 4... o Filme!</title>
   <link href="http://fabioyamate.com/2008/06/17/metal-gear-solid-4-o-filme/"/>
   <updated>2008-06-17T18:44:20-03:00</updated>
   <id>http://fabioyamate.com/2008/06/17/metal-gear-solid-4-o-filme</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/mgs4-release.png&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;236&quot;
alt=&quot;mgs4_release&quot; src=&quot;http://fabioyamate.com/images/2008/06/mgs4-release-thumb.png&quot;
width=&quot;500&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Já tarde, o lançamento mundial foi quinta feira passada, 12/06/2008. Menos de um dia já era possível
conferir inúmeros vídeos sobre o jogo no &lt;a href=&quot;http://www.youtube.com/&quot;
target=&quot;_blank&quot;&gt;YouTube&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Simplesmente incrível, numa telinha do youtube já é possível ver a qualidade do jogo em modo High
Definition, quem dirá numa TV Full HD (1080p).&lt;/p&gt;

&lt;p&gt;Dizem que o final possui 80 min. de duração!&lt;/p&gt;

&lt;p&gt;O PS3 já está na minha lista de desejos, mas não virá tão cedo assim...&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Firefox 3 lançado!</title>
   <link href="http://fabioyamate.com/2008/06/17/firefox-3-lanado/"/>
   <updated>2008-06-17T15:54:20-03:00</updated>
   <id>http://fabioyamate.com/2008/06/17/firefox-3-lanado</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.spreadfirefox.com/pt-BR/worldrecord&quot;&gt;&lt;img title=&quot;Download Day 2008&quot;
alt=&quot;Download Day 2008&quot;
src=&quot;http://www.spreadfirefox.com/sites/all/themes/spreadfirefox_RCS/images/download-day/buttons/pt-BR/468x60_dday.png&quot;
border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hoje é o grande dia do &lt;a href=&quot;http://www.spreadfirefox.com/en-US/worldrecord&quot;
target=&quot;_blank&quot;&gt;Download Day 2008&lt;/a&gt;, uma tentativa de estabelecer um recorde mundial de downloads.&lt;/p&gt;

&lt;p&gt;Acabei de instalar o &lt;a href=&quot;http://www.mozilla.com/en-US/firefox/&quot; target=&quot;_blank&quot;&gt;Firefox 3&lt;/a&gt;,
até então não havia usado, estava no 2.0.0.14 ainda. Apesar de ter visto outros usuários usando, não
me foi atrativo experimentar o beta, e olha que adoro instalar programas demos e etc.&lt;/p&gt;

&lt;p&gt;Estou aproveitando ainda as funcionalidades, que alguns já devem estar usando.&lt;/p&gt;

&lt;p&gt;A que me chamou atenção logo de cara foi o Zoom! (coisa que o IE7 já veio). Chega de aumentar o
tamanho da fonte e desfigurar completamente o site, agora basta usar o Ctrl+&amp;#39;+&amp;#39; ou Ctrl+&amp;#39;-&amp;#39; para
realizar o zoom da página, excelente!&lt;/p&gt;

&lt;p&gt;Outro detalhe é o autocomplete/suggestion que esta embutido na barra de endereços quando se começa a
digitar, buscando links do favoritos e da internet.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/firefox3-autocomplete.png&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;178&quot;
alt=&quot;firefox3_autocomplete&quot;
src=&quot;http://fabioyamate.com/images/2008/06/firefox3-autocomplete-thumb.png&quot; width=&quot;520&quot;
border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A parte de favoritos ainda acho mais prátido usar o Ctrl+D, mas para o pessoal do mouse agora é
possível adicionar nos favoritos diretamente pela barra de endereço.&lt;/p&gt;

&lt;p&gt;É possível sentir um ganho em performance na navegação, mas não vou fazer uma análise completa da
nova versão, mesmo por que muitos irão e com melhores detalhes do que eu faria.&lt;/p&gt;

&lt;p&gt;Mas vale visitar o site: &lt;a href=&quot;http://en-us.www.mozilla.com/en-US/firefox/tips/&quot;
target=&quot;_blank&quot;&gt;Firefox 3 - Tips &amp;amp; Trips&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A maioria dos atalhos já existiam, acredito que a principal novidade nisso seja o zoom.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Google para que mudar o favicon?</title>
   <link href="http://fabioyamate.com/2008/06/16/google-para-que-mudar-o-favicon/"/>
   <updated>2008-06-16T19:26:17-03:00</updated>
   <id>http://fabioyamate.com/2008/06/16/google-para-que-mudar-o-favicon</id>
   <content type="html">&lt;p&gt;Concordo já é tarde... o favicon do Google mudou desde maio, mas tem me incomodado demais. Eu
costumo usar &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/3780&quot;
target=&quot;_blank&quot;&gt;faviconize&lt;/a&gt;, extensão do firefox e fica dificil me acostumar com essa
mudança.&lt;img style=&quot;border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin:
10px 0px; border-right-width: 0px&quot; height=&quot;169&quot; alt=&quot;google_new_favicon&quot;
src=&quot;http://fabioyamate.com/images/2008/06/google-new-favicon.png&quot; width=&quot;420&quot;
border=&quot;0&quot;&gt;&lt;/p&gt;

&lt;p&gt;Eu gosto quando o &lt;a href=&quot;http://www.google.com/holidaylogos.html&quot; target=&quot;_blank&quot;&gt;Google brinca
com os logos em eventos especiais&lt;/a&gt;, mas no favicon, um detalhe tão pequeno e marcante no mundo
das abas em que os navegadores estão, chega a incomodar.&lt;/p&gt;

&lt;p&gt;O pessoal de marketing diz que brincar com o logo agride a imagem da empresa. Nesse caso do favicon
tenho que concordar, essa brincadeira mexeu demais com a imagem deles, mesmo que seja um detalhe
pequeno.&lt;/p&gt;

&lt;p&gt;Só me recordo que o favicon mudou por que fico com pelo menos 5 abas de consulta do Google, senão já
teria me perdido e esquecido...&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Server Explorer sumiu...</title>
   <link href="http://fabioyamate.com/2008/06/13/server-explorer-sumiu/"/>
   <updated>2008-06-13T17:28:40-03:00</updated>
   <id>http://fabioyamate.com/2008/06/13/server-explorer-sumiu</id>
   <content type="html">&lt;p&gt;Esta semana estava trabalhando no notebook e por um problema de aquecimento o notebook desligou
(problema que espero resolver com o cooler, &lt;a
href=&quot;http://fabioyamate.com/2008/06/13/refrescando-o-notebook/&quot;&gt;vide post anterior&lt;/a&gt;), e
acabou danificando o Visual Studio 2008 o qual estava usando.&lt;/p&gt;

&lt;p&gt;O problema é que toda vez que eu carregava uma mensagem de erro surgia dizendo que ia remover uma
referência (a qual não me recordo agora) e desde entao o Server Explorer parou de aparecer.&lt;/p&gt;

&lt;p&gt;Não sei por que eu não fui direto no google e procurar sobre o problema, ao invés disso fui querer
reparar o Visual Studio 2008.&lt;/p&gt;

&lt;p&gt;Muitos minutos depois... nada de corrigir, ai optei por reinstalar o VS.... muitos e muitos minutos
depois o problema persistia.&lt;/p&gt;

&lt;p&gt;Bastou ir no google e digitar &amp;quot;visual studio 2008 not showing server explorer&amp;quot; e lá estava a
correção.&lt;/p&gt;

&lt;p&gt;Basta ir no Visual Studio 2008 Command Prompt e digitar: &lt;code&gt;devenv /setup&lt;/code&gt; (e esperar alguns
minutos).&lt;/p&gt;

&lt;p&gt;Está solução também é válida para o 2005.&lt;/p&gt;

&lt;p&gt;Não sei por que as vezes gostamos de complicar as coisas...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[update 14.06.2008]&lt;/strong&gt; Esta solução de refazer a configuração do VS não resolveu completamente o
problema, voltei a receber a mensagem de erro:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;&amp;#39;Visual Studio Explorer and Designers Package&amp;#39; has failed to load properly&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Procurei mais profundamente sobre o problema depois que a mensagem voltou a surgir e, não fui o
único a ter este problema. O problema não era o fato de o notebook ter desligado acidentalmente e
sim conflito com o &lt;a href=&quot;http://code.msdn.microsoft.com/sourceanalysis&quot;
target=&quot;_blank&quot;&gt;&lt;strong&gt;Microsoft Source Analysis for C#&lt;/strong&gt;&lt;/a&gt; que tem este problema &lt;a
href=&quot;http://code.msdn.microsoft.com/sourceanalysis/WorkItem/View.aspx?WorkItemId=9&quot;
target=&quot;_blank&quot;&gt;&lt;strong&gt;aqui&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;O estranho é que logo que instalei o Source Analysis não tive este problema.&lt;/p&gt;

&lt;p&gt;Agora o VS 2008 voltou a funcionar corretamente sem esta mensagem.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Refrescando o Notebook</title>
   <link href="http://fabioyamate.com/2008/06/13/refrescando-o-notebook/"/>
   <updated>2008-06-13T11:23:22-03:00</updated>
   <id>http://fabioyamate.com/2008/06/13/refrescando-o-notebook</id>
   <content type="html">&lt;p&gt;Acredito que muitos hoje devem usar notebook tanto em casa como trabalho, claro que desktop ainda é
maioria, mas acredito que a tendência é a maioria passar a comprar notebooks devido a mobilidade de
poder estar trabalhando em qualquer lugar sem ser em casa.&lt;/p&gt;

&lt;p&gt;Eu no momento estou com um notebook ~~velho~~ antigo, é um Dell Inspiron 5100. O problema deste
modelo é que o processador é um Pentium IV, o que eleva absurdamente a temperatura do seu computador
por que ele não possue um gerenciador de consumo que existe nesses novos processadores core duo.&lt;/p&gt;

&lt;p&gt;Usando o everest para verificar a temperatura, após 1-2 horas de uso ele chegava a 75 graus celsus,
o que tornava o uso dele bastante complicado. Eu sou o tipo de pessoa que carrega muitos programas
(navegador, editor, musica e etc.) e fico com muitas abas abertas no firefox.&lt;/p&gt;

&lt;p&gt;Em janeiro havia pensando em comprar um cooler para notebook, mas achei muito caro, so encontrei o
modelo da Zalman que custava R$170,00 no ML.&lt;/p&gt;

&lt;p&gt;Esta semana encontrei um modelo da Cooler Master Notepal Infinite.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/dsc05501-medium.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;200&quot;
alt=&quot;DSC05501 (Medium)&quot;
src=&quot;http://fabioyamate.com/images/2008/06/dsc05501-medium-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caixa do CoolerMaster Notepal Infinite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/dsc05505-medium.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;200&quot;
alt=&quot;DSC05505 (Medium)&quot;
src=&quot;http://fabioyamate.com/images/2008/06/dsc05505-medium-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tamanho do Notebook e Notepal Infinite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Acabei de receber o produto e estou testando. A primeira coisa que fiz foi assistir vídeo no
youtube, por que era uma das tarefas que menos conseguia executar, o processador ia para o máximo
junto com a temperatura quebrando o vídeo.&lt;/p&gt;

&lt;p&gt;No momento a temperatura esta em 56-57 graus. Em uso mais intenso chega a 65 graus.&lt;/p&gt;

&lt;p&gt;A parte de baixo do notebook fica bem fresquinho, deixando o notebook mais confortável para uso, mas
isso não quer dizer que ele fica frio, a regia do HD fica quentinho, mas melhor que sem o cooler.&lt;/p&gt;

&lt;p&gt;So pelo fato de estar podendo usar o notebook de forma mais estável já é um ganho.&lt;/p&gt;

&lt;p&gt;Outro ponto é, ele faz barulho, a mim não incomoda, pois já estou acostumando com o cooler
barulhento do DELL. Mas para quem se irrita fácil, o acréscimo de ruído é significado.&lt;/p&gt;

&lt;p&gt;Não verifiquei ainda a diferença de uso para 1000, 1500 e 2000 rpm.&lt;/p&gt;

&lt;p&gt;O produto não é tão pesado, tem 700g, é um custo adicional na mochila? Sem dúvida, mas para quem
precisa (como eu) vale a pena.&lt;/p&gt;

&lt;p&gt;O valor do produto custa R$100,00, e acredito que nestes tipos de acessórios vale a pena pagar mais
do que escolher pelo barato, alias digo isso para qualquer acessório de hardware. Escolher por esses
modelos de R$40 é pedir para se arrempender.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/dsc05506-medium.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;200&quot;
alt=&quot;DSC05506 (Medium)&quot;
src=&quot;http://fabioyamate.com/images/2008/06/dsc05506-medium-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/06/dsc05507-medium.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img
style=&quot;border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px&quot; height=&quot;200&quot;
alt=&quot;DSC05507 (Medium)&quot;
src=&quot;http://fabioyamate.com/images/2008/06/dsc05507-medium-thumb.jpg&quot; width=&quot;260&quot;
border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Se der eu posto um vídeo com o ruído do cooler.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Extension Methods Is Like a Magic!</title>
   <link href="http://fabioyamate.com/2008/05/23/extension-methods-is-like-a-magic/"/>
   <updated>2008-05-23T14:54:17-03:00</updated>
   <id>http://fabioyamate.com/2008/05/23/extension-methods-is-like-a-magic</id>
   <content type="html">&lt;p&gt;Estou voltando depois de muito tempo sem escrever. Não é difícil notar a dificuldade de se manter um
blog. Pensar no que escrever as vezes é fácil, o problema é colocar no papel, ou melhor, na tela.&lt;/p&gt;

&lt;p&gt;Ultimamente tenho estudado C#3, que tem o LINQ como o grande &amp;#39;boom&amp;#39; do novo framework. Contudo, uma
das coisas que mais me intrigou até o momento é Extension methods.&lt;/p&gt;

&lt;p&gt;Acredito que muitos já devem ter usando e/ou criado static classes como classes utilitárias (util)
ou auxliares (helpers) por que uma classe não possuia um método de que precisassemos no momento, ou
até teria uma outra classe que executa a operação mas acaba gerando um overhead grande por que teria
de instanciar um objeto que teria inúmeras operações que talvez não teria utilidade.&lt;/p&gt;

&lt;p&gt;Um exemplo em Java é que os tipos Integer, Long e etc, não possui um conversor para bytes proprio da
classe como getBytes() da String. Existe duas opções para realizar essa operação, uma delas é usar o
BitInteger e a outra seria o DataOutputStream. Mas seria tão mais simples se tivessemos um
getBytes() da classe String. Então recorre-se a uma classe auxliar para realizar essa conversão.
Algo do tipo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;NumberHelper&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;intToBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;longToBytes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Um pouco feio mas resolve. Agora seria muito melhor ter algo do tipo &lt;code&gt;Integer.toBytes();&lt;/code&gt; ou
&lt;code&gt;Long.toBytes()&lt;/code&gt; não seria?  Então é ai que entra o Extension methods.&lt;/p&gt;

&lt;p&gt;No C#3 é possível criarmos uma classe estática que estenda os métodos de uma classe. É muito simples
veja:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&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;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PersonUtil&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;ChangeName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&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;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&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;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fabio&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Fabio&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fabio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ChangeName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Fábio&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Viram como é simples? Ok, o exemplo não é muito útil uma vez que o property set do Name é publico,
mas estou sem idéia no momento. A idéia esta fresca na cabeça então estou escrevendo um post rápido.&lt;/p&gt;

&lt;p&gt;Entretanto existem algumas restrições para isso:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A classe que contêm os Extension Methods não podem ser genêricos e internos, e os métodos precisam&lt;/li&gt;
&lt;li&gt;ser static.&lt;/li&gt;
&lt;li&gt;O método precisa ter pelo menos um paramêtro onde este (o primeiro) deve ser prefixado com this e&lt;/li&gt;
&lt;li&gt;não pode ser ref, out ou ponteiro. Ou seja, os demais parâmetros (segundo, terceiro e etc) pode&lt;/li&gt;
&lt;li&gt;ser genêricos, ref/out/ponteiro&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Espero que tenham gostado do post, devo colocar outras coisas a mais sobre C#3 pois estou muito
interessado nessas novidades.&lt;/p&gt;

&lt;p&gt;Até um próximo post.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Aplicando diferentes Cabeçalhos num documento Word</title>
   <link href="http://fabioyamate.com/2008/02/24/aplicando-diferentes-cabealhos-num-documento-word/"/>
   <updated>2008-02-24T19:07:26-03:00</updated>
   <id>http://fabioyamate.com/2008/02/24/aplicando-diferentes-cabealhos-num-documento-word</id>
   <content type="html">&lt;p&gt;Estava formatando um documento no Word 2007, que acredito ser a melhor versão do Office, e precisei
colocar diferentes layouts no documento, desde orientação de páginas diferentes à cabeçalhos e
rodapés.&lt;/p&gt;

&lt;p&gt;Nas referências básicas do Word que se encontram na internet pouco se fala em como fazer este tipo
de tarefa.&lt;/p&gt;

&lt;p&gt;Nos meus anos de uso do Office, nunca havia usado Sections num documento. As sections servem para
diferenciar partes de um documento, possibilitando assim aplicar diferentes cabeçalhos e layouts num
mesmo documento.&lt;/p&gt;

&lt;p&gt;No Word 2007, basta ir em Page Layout e aplicar um break adicionando uma nova section como mostrado
na figura.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/02/diff-format-word-2007-01.png&quot;&gt;&lt;img
style=&quot;border: 0px none;&quot;
src=&quot;http://fabioyamate.com/images/2008/02/diff-format-word-2007-01-thumb.png&quot;
border=&quot;0&quot; alt=&quot;diff_format_word_2007_01&quot; width=&quot;486&quot; height=&quot;527&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uma vez adionado uma nova section no documento, é possível aplicar diferentes formatações do
documento como orientação e cabeçalho. Para realizar isso, é preciso desmarcar a opção &amp;quot;Link to
Previous&amp;quot; para que a formatação existente não seja aplicada nesta section&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fabioyamate.com/images/2008/02/diff-format-word-2007-02.png&quot;&gt;&lt;img
style=&quot;border: 0px none;&quot;
src=&quot;http://fabioyamate.com/images/2008/02/diff-format-word-2007-02-thumb.png&quot;
border=&quot;0&quot; alt=&quot;diff_format_word_2007_02&quot; width=&quot;561&quot; height=&quot;508&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Desse modo é possível ter diferentes formatações num mesmo documento.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Foreach vs Iterator</title>
   <link href="http://fabioyamate.com/2008/02/03/foreach-vs-iterator/"/>
   <updated>2008-02-03T08:10:10-02:00</updated>
   <id>http://fabioyamate.com/2008/02/03/foreach-vs-iterator</id>
   <content type="html">&lt;p&gt;Nos últimos dias tenho trabalhado bastante com coleções (collections) do java. Estava habituado a
usar Iterator para varrer as coleções. Na versão do Java 5, houve a implementação do foreach para
java que mudou a forma como iteramos sobre uma coleção.&lt;/p&gt;

&lt;p&gt;Normalmente fazíamos da forma:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;obj1&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;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objn&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasNext&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;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// do something with the object &amp;#39;o&amp;#39;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Quando precisamos realmente trabalhar com o objeto, precisamos de uma referência aquele objeto, caso
contrário:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hastNext&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;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;method1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;method2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// could result exception&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Neste caso it.next() lê o objeto corrente e incrementa um marcador para o elemento seguinte. Se
usarmos o it.next() novamenete, estaremos trabalhando com outra referência, o que poderia ser um
vazio ou um ponteiro nulo.&lt;/p&gt;

&lt;p&gt;Por estes motivos a forma de iterar sobre coleções foi mudado para o foreach, que possui a seguinte
implementação:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objects&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;c1&quot;&gt;// do something with the object &amp;#39;o&amp;#39;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Na prática, quando compilamos o código o resultado do o foreach é o mesmo para a iteração do
primeiro caso apresentado, onde criamos um marcador para referênciar o objeto da coleção lido.
Usando o for-each trabalhamos de forma mais segura quando iteramos, resultando também num código
mais legível, mantendo a tipagem sobre generics collections.&lt;/p&gt;

&lt;p&gt;Se tiver dúvidas basta criar um código e compilá-lo.&lt;/p&gt;

&lt;p&gt;Depois use o comando &lt;code&gt;javap -c CompiledClass&lt;/code&gt; note que não há extensão .class&lt;/p&gt;

&lt;p&gt;Relembrando, o uso de foreach só é válido na versão do Java 5+&lt;/p&gt;

&lt;h4&gt;update&lt;/h4&gt;

&lt;p&gt;Uma observação que gostária de fazer é a seguinte, alguns programadores gostam de usar a seguinte
codifição para iteração:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;iterator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasNext&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;o&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;// do something&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;É uma opção de cada um, mas acredito que o uso do while fornece um legibilidade de código muito
maior, o for ele tende a amontar muita informaçao numa unica linha o que prejudica a leitura. O
resultado de compilação é o mesmo tanto para for como while, uma vez que o for é uma expansão para
while, ou seja, durante o processo de compilação o bloco de código do for será convertido para o
formato do while.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>DVD: Problema de Tela Preta</title>
   <link href="http://fabioyamate.com/2008/01/24/dvd-problema-de-tela-preta/"/>
   <updated>2008-01-24T21:49:03-02:00</updated>
   <id>http://fabioyamate.com/2008/01/24/dvd-problema-de-tela-preta</id>
   <content type="html">&lt;p&gt;Hoje estava reinstalando os aplicativos num computador formatado recentemente. Aplicativos tudo OK,
agora a parte de reprodução de multimidia, que não poderia deixar de faltar o K-lite codec pack, que
não minha opinião é o melhor pacote de codecs existentes junto com o maravilhoso Media Player
Classic.&lt;/p&gt;

&lt;p&gt;Instalei o pacote e fui tentar reproduzir um DVD e eis o problema: possue som mas não tem imagem,
fica numa tela preta.&lt;/p&gt;

&lt;p&gt;Removi e reinstalei varias vezes, fiz downgrade de versão e nada de resolver.&lt;/p&gt;

&lt;p&gt;Como última alternativa fui testar no VLC. Instalei e não é que rodou o DVD bunitinho. Assim,
concluo que não é erro de DVD ou coisa similar, muito menos do computador. Se o vídeo não reproduz
no VLC nada irá reproduzir a mídia, já consegui rodar arquivos danificados nele, ou seja, não roda
no VLC o problema é sério.&lt;/p&gt;

&lt;p&gt;Bom, só me restou mexer nos codecs de reprodução. A solução foi mudar o codec de reprodução.&lt;/p&gt;

&lt;p&gt;Vá em Start &amp;gt; All Programs &amp;gt; K-Lite Codec Pack &amp;gt; Configuration &amp;gt; ffdshow video decoder&lt;/p&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;a
href=&quot;http://fabioyamate.com/images/2008/01/ffdshow.png&quot; title=&quot;FFDSHOW Video
Decoder&quot;&gt;&lt;img src=&quot;http://fabioyamate.com/images/2008/01/ffdshow.png&quot; alt=&quot;FFDSHOW Video
Decoder&quot; height=&quot;366&quot; width=&quot;458&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Na tela de configuração, selecione a opção &amp;quot;Codecs&amp;quot;, e busquepor Format = MPEG2 (o usado por DVD).
Por default, o decoder está &amp;quot;disable&amp;quot;, mude-o para libmpeg2 e marque a opção DVD decoding (sem essas
duas opções não vai funcionar).&lt;/p&gt;

&lt;p&gt;Agora é possível reproduzir corretamente os DVDs no seu computador.&lt;/p&gt;

&lt;p&gt;O Decoder libavcodec também reproduz mas a imagem fica travada, por isso a melhor solução é o
libmpeg2.&lt;/p&gt;

&lt;p&gt;obs. Apesar disso resolver o problema, normalmente não é necessário alterar esta configuração para
assistir DVD. Tenho outro computador onde as configurações estão todas default, e consegue
reproduzir qualquer vídeo por completo.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>VBA, ADODB de Access para Excel</title>
   <link href="http://fabioyamate.com/2007/12/21/vba-adodb-de-access-para-excel/"/>
   <updated>2007-12-21T23:22:27-02:00</updated>
   <id>http://fabioyamate.com/2007/12/21/vba-adodb-de-access-para-excel</id>
   <content type="html">&lt;p&gt;Precisei mexer com ADODB em VBA para poder acessar dados armazenados em Access usando linguagem SQL.&lt;/p&gt;

&lt;p&gt;Estava eu testando um tutorial encontrado na internet (obrigado Google) e usava o objeto
&lt;code&gt;ADODB.Resultset&lt;/code&gt;, mas cada ele? Erro de execução. E o Ctrl+Espaço nem funcionava (aliás já não
funciona nem pro básico). Mas como pode ter um ferramente como o Office 2007 e não estar integrado
ou não ter suporte para isso. Tentei buscar os drivers pela internet ou coisa parecida e nada. Raros
os casos de problema sobre isso.&lt;/p&gt;

&lt;p&gt;O problema estava que o Driver vem desabilitado e você tem de habilitá-lo no IDE/Editor do VBA do
Office.&lt;/p&gt;

&lt;p&gt;Basta ir em Tools &amp;gt; References, e ativar o Microsoft ActiveX Data Objects 2.8 Library&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://fabioyamate.com/images/2007/12/ref.jpg&quot; alt=&quot;Excel Refences ADODB&quot;&gt;&lt;/p&gt;

&lt;p&gt;Ai você terá acesso ao ADODB.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nota.&lt;/strong&gt; Aqui sempre desabilita quando abro um novo Excel, então é necessário sempre marcar
novamente a opção. Num arquivo onde o procedimento já foi executado, não há necessidade.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>VBA Para Excel</title>
   <link href="http://fabioyamate.com/2007/12/11/vba-para-excel/"/>
   <updated>2007-12-11T23:01:36-02:00</updated>
   <id>http://fabioyamate.com/2007/12/11/vba-para-excel</id>
   <content type="html">&lt;p&gt;Esses últimos dias peguei um trabalho que era fora do mundo em que costumo estar. Nunca havia
programado em VBA e muito menos mexido com macros em Excel, ou para qualquer aplicação do office.&lt;/p&gt;

&lt;p&gt;Estou trabalhando com o Office 2007, que cá entre nós está excelente. Talvez a interface seja um
pouco estranha para o pessoal que usava no seu cotidiano o office e conhecia os atalhos e blá blá
blá. Eu, para os meus trabalhos, o uso do office sempre foi superficial, apesar de usar os recursos
além da grande maioria que pensa que Excel é um gerador de tabelas melhor que o do Word.&lt;/p&gt;

&lt;p&gt;Voltando ao assunto, nunca havia usado no Office 2003, mas o Office 2007 torna muito fácil e visível
a importação de dados externos. Entretanto, ele apenas puxa dados e deixa para o usuário trabalhar
com eles. Tá, até ai tudo bem, mas se eu quiser ficar puxando dados com filtros e etc, vou sempre
ter que criar uma conexão e setar os paramêtros e etc. Muito trabalhoso.&lt;/p&gt;

&lt;p&gt;Para isso comecei a estudar VBA básico. Comecei a manipular com planilhas, folhas e etc.
Sinceramente, foi um stress trabalhar com VBA. Quem já programou com linguagens mais estruturadas
deve concordar. Cheguei até pensar em abrir o Visual Studio e passar a programar em C# com Interop.&lt;/p&gt;

&lt;p&gt;Mas não, pensei, Office/Macros é sempre VBA deve ter milhares de suportes pela internet. Até tinha,
mas muitas vezes é difícil encontrar realmente o que você quer. Senti a IDE que é fornecida no Excel
extramente fraca. Os auto-completes deixam a desejar, e muitas vezes não é nem possível obter a
interface. Fiquei pensando que só a experiência e saco fará de você um bom programador de macros.&lt;/p&gt;

&lt;p&gt;Será que estou enganado?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>JDBC e SQLEXPRESS 2005</title>
   <link href="http://fabioyamate.com/2007/08/23/jdbc-e-sqlexpress-2005/"/>
   <updated>2007-08-23T13:43:52-03:00</updated>
   <id>http://fabioyamate.com/2007/08/23/jdbc-e-sqlexpress-2005</id>
   <content type="html">&lt;p&gt;Comecei a usar o eclipse para trabalhar com java. Você começa fazendo aqueles programas básicos
para conhecer o ambiente em que vai trabalhar. Ai chega na parte que toda aplicação usa, banco de
dados.&lt;/p&gt;

&lt;p&gt;Primeiro é necessário baixar o driver jdbc para SQL Server que pode ser encontrado na
&lt;a href=&quot;http://msdn2.microsoft.com/pt-br/data/aa937724.aspx&quot; title=&quot;Microsoft SQL Server JDBC&quot;&gt;aqui&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Neste caso estou trabalhando com o &lt;a href=&quot;http://www.microsoft.com/sql/editions/express/default.mspx&quot; title=&quot;SQL Server Express Edition 2005&quot;&gt;SQL Server Express Edition 2005&lt;/a&gt; que já estava
instalado por ter usado o Visual Studio 2005 anteriormente.&lt;/p&gt;

&lt;p&gt;No management studio tudo ok. Mas na hora de configurar um Data Source no eclipse... SEM RESPOSTA!&lt;/p&gt;

&lt;p&gt;Um dos problemas básicos é que o SQL Express 2005 pode estar autenticando apenas através do Windows
Authentication, que é o seu login no windows.&lt;/p&gt;

&lt;p&gt;O que temos que fazer é habilitar o modo hibrido, de modo que seja aceito autenticação por SQL
Server.&lt;/p&gt;

&lt;p&gt;Vamos usar o &lt;a href=&quot;http://msdn2.microsoft.com/en-us/express/bb410792.aspx&quot; title=&quot;SQL Server Management Studio Express&quot;&gt;Microsoft SQL Server Management Studio Express&lt;/a&gt; para gerenciar. Conecte ao
servidor usando a sua conta do windows para autenticar.&lt;/p&gt;

&lt;p&gt;Uma vez conectado clique com o botão direito sobre o servidor e em &lt;strong&gt;propriedades&lt;/strong&gt;. Será aberta a
janela Server Properties, vá no item Security e marque a opcao &lt;em&gt;Server Authentication &amp;gt; SQL
Server and Windows Authentication&lt;/em&gt;. Clique em &lt;em&gt;OK&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Antes de reiniciarmos o serviço teremos que adicionar uma conta SQL Server. Existe a conta sa por
default mas é recomendável criar outra.&lt;/p&gt;

&lt;p&gt;Na árvore do servidor, clique em &lt;em&gt;Security &amp;gt; Logins &amp;gt; New Login&lt;/em&gt;... Cadastre uma nova conta
SQL Server. Salve e agora reinicie a aplicação.&lt;/p&gt;

&lt;p&gt;Entretanto isso não é o suficiente para usarmos o SQL Server Express 2005, por que ele não está
habilitado para conexões TCP/IP que é o que usaremos no JDBC. Para habilitarmos usaremos o SQL
Server Configuration Manager que se encontra em: &lt;em&gt;Start &amp;gt; All Programs &amp;gt; Microsoft Server 2005
&amp;gt; Configuration Tools &amp;gt; SQL Server Configuration Manager&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Selecione SQL Server 2005 Network Configuration &amp;gt; Protocols for SQLEXPRESS &amp;gt; TCP/IP &amp;gt;
Properties. Na aba Protocol marque &lt;code&gt;enable = yes&lt;/code&gt; e na aba IP Addresses coloque o que tiver IP
127.0.0.1 com:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;active e enable: Yes&lt;/li&gt;
&lt;li&gt;TCP Dynamic Ports: 0&lt;/li&gt;
&lt;li&gt;TCP Port: 1433&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Se você vai trabalhar apenas na sua máquina sem que outra pessoa utilize, use apenas o IP 2, e
mantenha o IP1 desabilitado. O que ele representa é que ele habilitará a sua interface de rede para
conexões com o servidor.&lt;/p&gt;

&lt;p&gt;Uma vez finalizado reinicie o serviço.&lt;/p&gt;

&lt;p&gt;Para configurar o JDBC agora basta usar a url &lt;code&gt;jdbc:sqlserver://localhost\SQLEXPRESS&lt;/code&gt; e o usuário e
senha que você criou.&lt;/p&gt;

&lt;p&gt;Pronto, agora você já pode usar o SQL Server&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>NHibernate inicio</title>
   <link href="http://fabioyamate.com/2007/06/22/nhibernate-inicio/"/>
   <updated>2007-06-22T09:35:51-03:00</updated>
   <id>http://fabioyamate.com/2007/06/22/nhibernate-inicio</id>
   <content type="html">&lt;p&gt;Estou no momento trabalhando com .NET e estudando o modelamento de aplicações em camadas. Por isso
comecei a estudar um pouco sobre o NHibernate, um sucesso já vindo do Hibernate para Java.&lt;/p&gt;

&lt;p&gt;Infelizmente nem tudo ocorreu tão fácil para um primeiro teste para a partir de algo em funcionamento
começar a mexer nele.&lt;/p&gt;

&lt;p&gt;As primeira coisa que é bom fazer é colocar o schema do mapping e configuration do NHibernate.&lt;/p&gt;

&lt;p&gt;Para o Visual Studio 2005 a pasta se encontra em: &lt;code&gt;%ProgramFiles%\Microsoft Visual Studio 8\Xml\Schemas&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Basta colocar os arquivos &lt;code&gt;nhibernate-configuration.xsd&lt;/code&gt; e &lt;code&gt;nhibernate-mapping.xsd&lt;/code&gt; neste diretório.&lt;/p&gt;

&lt;p&gt;Um dos problemas que eu tinha era com relação a configuração do &lt;code&gt;connection_string&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Usei uma vez Data Source para determinar o local onde o banco de dados se encontra, e isso causava
erro na aplicação. Para corrigir bastou mudar para Server que a aplicação rolou.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Interfaces em C#</title>
   <link href="http://fabioyamate.com/2007/06/15/interfaces-em-c-sharp/"/>
   <updated>2007-06-15T16:00:57-03:00</updated>
   <id>http://fabioyamate.com/2007/06/15/interfaces-em-c-sharp</id>
   <content type="html">&lt;p&gt;Interfaces são classes assinaturas que determinam uma série de métodos que podem ser feitos com um
quem a implementá-la. Como havia mencionado, interface são usadas para determinar tipos de dados.
Uma classe pode implementar quantas interfaces desejar.  Mas existem algumas considerações que
devem ser consideradas.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;methodB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Algumas pessoas usam o I no início para determinar que é uma interface. Você pode determinar métodos
genéricos como methodA ou pode determinar métodos com uma certa assinatura obrigatória como methodB
que necessita de um inteiro como parâmetro.&lt;/p&gt;

&lt;p&gt;Em geral, todo método é declarado públic numa interface, mas é possível criá-lo privado.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Class&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;methodA&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;// sub-rotina&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;IClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;methodB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&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;// bla bla bla...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;methodC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&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;IClass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ic&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;methodB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&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;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;methodA&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// call método A&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;methodB&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// error&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;methodC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// call método C &amp;gt;&amp;gt; call método B&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Como remover o conflito de duas interfaces que assinam o mesmo método?&lt;/p&gt;

&lt;p&gt;Usando a implementação privada é possível  resolver este problema, cria-se cada método privadamente,
e cria funções diferentes para acesso de cada um deles.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Pilares do Paradigma Orientado a Objetos (Parte 1)</title>
   <link href="http://fabioyamate.com/2007/06/05/pilares-do-paradigma-orientado-a-objetos-parte-1/"/>
   <updated>2007-06-05T16:05:27-03:00</updated>
   <id>http://fabioyamate.com/2007/06/05/pilares-do-paradigma-orientado-a-objetos-parte-1</id>
   <content type="html">&lt;p&gt;O paradigma orientado a objetos é algo que não há como evitar caso deseje ser um desenvolvedor.
Toda aplicação exige uma organização e metodologia para desenvolvimento, não basta abrir o editor
de texto e digitar.&lt;/p&gt;

&lt;p&gt;Alguns princípios da orientação a objetos estão listadas abaixo:&lt;/p&gt;

&lt;p&gt;Encapsulamento (encapsulation)&lt;/p&gt;

&lt;p&gt;Toda aplicação é composta de pequenos elementos que unidos concluem o produto final. É comum a
ocorrência de métodos (&amp;quot;funções&amp;quot;) que dependem de outros para concluir sua operação. Um método que
delega um objeto a fazer uma determinada parte de sua operação não precisa saber como ele faz, para
ele é suficiente saber que dada uma entrada ele manipula ela e retorna o que deseja. Essa metodologia
de tratamento da entrada não transparente é o que se chama de encapsulamento.&lt;/p&gt;

&lt;p&gt;Esse encapsulamento pode ocorrer de duas formas: por delegação ou métodos privados.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;delegação é quando usamos um objeto instânciado de outra classe que contém métodos que auxiliam a
função de um método&lt;/li&gt;
&lt;li&gt;métodos privados são métodos internos da classe, ou seja, não são vistos externamente, servem
apenas para concluir pequenas operações&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Na orientação a objetos é comum subdividir tarefas criando pequenos blocos com uma única finalidade
e não classes lotadas de linhas de códigos.&lt;/p&gt;

&lt;p&gt;Em resumo, todo método de uma classe é encapsulada, apresentando ao exterior apenas as suas operações
(nomes dos métodos), para o usuário não importa como ela faz.&lt;/p&gt;

&lt;p&gt;Especialização (specialization)&lt;/p&gt;

&lt;p&gt;A especialização esta relacionada a herança. Em geral, muitas coisas compartilham propriedades bases.
Uma moto, carro e bicicleta são meios de transporte. Embora cada um possua suas particularidades que
os diferenciam. Poderiamos partir de uma base admitindo que todos sejam veiculos, e poderíamos
especificar/especializar essa classe consideram veiculos motorizados ou não. Tudo dependeria da
forma que tratamos nosso projeto. Poderíamos subdividir em classes de objetos de 2 rodas ou 4 rodas.&lt;/p&gt;

&lt;p&gt;Uma caracteristica importante é que uma classe pode apenas especializar uma outra classe, ou seja,
deve-se projetar bem.&lt;/p&gt;

&lt;p&gt;Quando desejamos caracterizar mais uma classe podemos implementar uma interface. Em geral, uma
interface representa um tipo de dado. Uma propriedade que se mantem a todos que a implementarem,
não importando como cada um faz.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Keywords for properties and methods in C#</title>
   <link href="http://fabioyamate.com/2007/05/07/keywords-for-properties-and-methods-on-c-sharp/"/>
   <updated>2007-05-07T07:39:44-03:00</updated>
   <id>http://fabioyamate.com/2007/05/07/keywords-for-properties-and-methods-on-c-sharp</id>
   <content type="html">&lt;p&gt;Em linguagens orientadas a objeto temos meios de definir o acesso e uso dos elementos. Segue uma
lista de algumas dessas palavras e sua funcionalidade.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;public&lt;/strong&gt;: declara que uma propriedade/método possa ser acessado externamente, ou seja, é visível
fora do objeto&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;private&lt;/strong&gt;: oposto do public, toda propriedade/método só pode ser acessada internamente da classe&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;protected&lt;/strong&gt;: semelhante ao private, ou seja, não é visível fora do objeto, mas é compartilhado
entre seus derivados transmida hierarquicamente&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;static&lt;/strong&gt;: um método/propriedade estática são elementos da classe em si, ou seja, não independem
de sua implementação, são compartilhadas por todas e não podem ser alteradas. Em geral são
constantes ou métodos que não dependem de parâmetros da classe&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Algumas outras keywords frequentemente usadas:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;virtual&lt;/strong&gt;: um método virtual é um método que pode ser sobreposto (&lt;strong&gt;override&lt;/strong&gt;); ou seja, um
método non-override não poderá ser sobreposto. Uma forma de lidar com isso seria usar a keyword
new method, escondendo o método base na derivada. Por default, no Java todos os métodos são
virtuais e, portanto, podem ser sobrepostos. &lt;strong&gt;Obs&lt;/strong&gt;: não aplicável a métodos abstratos e
estáticos.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;override&lt;/strong&gt;: declara que um método esta sobrepondo um método base - aspecto do polimorfismo -
&amp;quot;&lt;strong&gt;one interface, multiple methods&lt;/strong&gt;&amp;quot; (uma interface, múltiplos métodos)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;abstract&lt;/strong&gt;: declara uma classe semi-implementada, ou seja, possui método que não puderam ser
implementadas genericamente, e portanto, devem ser implementadas por seus derivados&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;interface&lt;/strong&gt;: define uma assinatura para um tipo de dado (data type). É uma forma de dizer que
todo tipo que implementa uma dada interface terá certos elementos, sempre! É muito semelhante a
abstract, a diferença é que num algumas implementações já estão feitas. Outro detalhe relevante é
que na herança uma classe pode apenas derivar de uma única classe base mas pode implementar
quantas interfaces desejar. Todos os métodos de uma interface são públicos, um tanto óbvio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;sealed&lt;/strong&gt;: impede que uma classe seja herdada. Semelhante ao &lt;strong&gt;final&lt;/strong&gt; no Java&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Starting...</title>
   <link href="http://fabioyamate.com/2007/04/27/starting/"/>
   <updated>2007-04-27T12:50:07-03:00</updated>
   <id>http://fabioyamate.com/2007/04/27/starting</id>
   <content type="html">&lt;p&gt;Enquanto o blog não tem a sua cara, por que o blog é um &amp;quot;Beta&amp;quot; - como tudo na nova web 2.0 - vamos
ficando os temas do wordpress.&lt;/p&gt;

&lt;p&gt;O blog tem como intuito seguir o progresso de meus estudos como desenvolvedor. Portanto, inúmeros
erros de código, abordagem e etc que qualquer iniciante passa poderá ser postado aqui e sintam-se
livres para comentar, criticar qualquer erro cometido. Só não vale ofensas.&lt;/p&gt;

&lt;p&gt;Vejamos como se sairá este blog &amp;quot;beta&amp;quot; já que começar um blog é fácil, o problema é dar continuidade.&lt;/p&gt;

&lt;p&gt;Bom até mais!&lt;/p&gt;
</content>
 </entry>
 

</feed>
