<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codes and Thoughts</title>
	<atom:link href="http://www.thiagoalves.com.br/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thiagoalves.com.br</link>
	<description>Just another programmer&#039;s blog</description>
	<lastBuildDate>Mon, 16 Apr 2012 21:38:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>A C/C++ feature that helped me to log better</title>
		<link>http://www.thiagoalves.com.br/2010/06/12/a-cc-feature-that-helped-me-to-log-better/</link>
		<comments>http://www.thiagoalves.com.br/2010/06/12/a-cc-feature-that-helped-me-to-log-better/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 14:17:47 +0000</pubDate>
		<dc:creator>Thiago Alves</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[dev]]></category>

		<guid isPermaLink="false">http://thiagoalves.org/?p=72</guid>
		<description><![CDATA[I read an article some time ago where it claims that you take at least 10 years to learn C/C++ entirely. I don&#8217;t remember if was Bjarne Stroustrup or someone else that said that but I completely agree! I program &#8230; <a href="http://www.thiagoalves.com.br/2010/06/12/a-cc-feature-that-helped-me-to-log-better/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I read an article some time ago where it claims that you take at least 10 years to learn C/C++ entirely. I don&#8217;t remember if was Bjarne Stroustrup or someone else that said that but I completely agree!</p>
<p>I program professionally for about 8 years and most of my career was developing in C/C++, still I don&#8217;t consider I know everything about this terrific language. One prove is that I found an interesting feature available regarding <code>#define</code> macros!<span id="more-72"></span></p>
<p><img class="aligncenter size-full wp-image-73" title="C/C++" src="http://thiagoalves.org/wp-content/uploads/2010/06/c_cpp.jpg" alt="" width="300" height="299" /> <strong>Let&#8217;s LOG</strong></p>
<p>One important thing of every program is log. It&#8217;s used to trace program&#8217;s flow or even debug on some cases where you cannot use GDB/DBX.</p>
<p>That being said, one important thing to put on your logs is the file name and line number where the it occurs. On my early days I though to have found a smart way to do it!</p>
<p>Well, I created a log function that here I&#8217;ll simplify it a little:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include</span>
<span style="color: #339900;">#include </span>
&nbsp;
<span style="color: #0000ff;">void</span> <span style="color: #0000dd;">log</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> fileName, <span style="color: #0000ff;">int</span> line, <span style="color: #0000ff;">const</span> <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> msg, ...<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">va_list</span> args<span style="color: #008080;">;</span>
    <span style="color: #0000dd;">va_start</span><span style="color: #008000;">&#40;</span>args, msg<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000dd;">fprintf</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">stdout</span>, <span style="color: #FF0000;">&quot;%s, %d:&quot;</span>, fileName, line<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000dd;">vfprintf</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">stdout</span>, msg, args<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
    <span style="color: #0000dd;">fprintf</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">stdout</span>, <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000dd;">va_end</span><span style="color: #008000;">&#40;</span>args<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Now I can use this just like a simple printf:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
11
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> var <span style="color: #000080;">=</span> <span style="color: #0000dd;">50</span><span style="color: #008080;">;</span>
<span style="color: #0000dd;">log</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;MyFile.cpp&quot;</span>, <span style="color: #0000dd;">11</span>, <span style="color: #FF0000;">&quot;Hello var: %d&quot;</span>, var<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>The problem with this, show up when I add couple lines before it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
11
12
13
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// trace var value</span>
<span style="color: #0000ff;">int</span> var <span style="color: #000080;">=</span> <span style="color: #0000dd;">50</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000dd;">log</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;MyFile.cpp&quot;</span>, <span style="color: #0000dd;">11</span>, <span style="color: #FF0000;">&quot;Hello var: %d&quot;</span>, var<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>This time the output of this will still be:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">MyFile.cpp, 11: Hello var: 50</pre></div></div>

<p>The problem is this line is wrong now! And imagine fixing all the logs of a 1000 LOC file if you just add an include?</p>
<p>How to solve this?</p>
<h3>Standard Predefined Macros</h3>
<p>If you check <a href="http://gcc.gnu.org/onlinedocs/cpp/index.html">The GNU C Preprocessor</a> page that talks about <a href="http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html">Standard Predefined Macros</a> you&#8217;ll find two interesting macros that solve our problem:</p>
<ul>
<li><code>__FILE__</code> &#8211; This macro expands to the name of the current input file, in the form of a C string constant.</li>
<li><code>__LINE__</code> &#8211; This macro expands to the current input line number, in the form of a decimal integer constant.</li>
</ul>
<p>Well, now if we use our <code>log</code> function with this macros we&#8217;re safe:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
11
12
13
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// trace var value</span>
<span style="color: #0000ff;">int</span> var <span style="color: #000080;">=</span> <span style="color: #0000dd;">50</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000dd;">log</span><span style="color: #008000;">&#40;</span>__FILE__, __LINE__, <span style="color: #FF0000;">&quot;Hello var: %d&quot;</span>, var<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>This time the output of this will be:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">MyFile.cpp, 13: Hello var: 50</pre></div></div>

<p>Cool right?</p>
<p>Yes but if you start working with a bunch of people you&#8217;ll realize that use this standard macros might confuse some folks and others tend to use plain <code>printf</code> just because they don&#8217;t know how to use it.</p>
<p>Now, how to solve THIS problem?</p>
<h3>#define Macros to save us</h3>
<p>It turns out there is a feature on standard C called Variadic Macros that I didn&#8217;t know before this week that simply solve this issue and make log functions elegant and efficient.<br />
I&#8217;ll point you again to the <a href="http://gcc.gnu.org/onlinedocs/cpp/index.html">The GNU C Preprocessor</a> on the <a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2//cpp/Variadic-Macros.html">Variadic Macros</a> page so you can read the details, but in a glimpse here is its syntax:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#define MACRO_NAME(arg, ...) somefunc(arg, __VA_ARGS__)</span></pre></div></div>

<p>One thing to notice though is that with this syntax you must pass at least one argument as variable arguments due the comma on your macro definition. But don&#8217;t look to this post with this face! There is a second syntax of Variadic Macros that will calm you down:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#define MACRO_NAME(arg, ...) somefunc(arg, ##__VA_ARGS__)</span></pre></div></div>

<p>With those double pounds before the <code>__VA_ARGS__</code> keyword, the C preprocessor will know if you don&#8217;t add variable arguments and will take the comma out.</p>
<p>Now, how this will help us on our log function?</p>
<p>Easy, we create this macro:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#define LOG(msg, ...) log(__FILE__, __LINE__, msg, ##__VA_ARGS__)</span></pre></div></div>

<p>Now our code snippet can be re-writen to use this new macro:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>10
11
12
13
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// trace var value</span>
<span style="color: #0000ff;">int</span> var <span style="color: #000080;">=</span> <span style="color: #0000dd;">50</span><span style="color: #008080;">;</span>
&nbsp;
LOG<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Hello var: %d&quot;</span>, var<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>

<p>As I said: cleaner and more elegant <img src='http://www.thiagoalves.com.br/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thiagoalves.com.br/2010/06/12/a-cc-feature-that-helped-me-to-log-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My Workflow With Git</title>
		<link>http://www.thiagoalves.com.br/2010/05/24/my-workflow-with-git/</link>
		<comments>http://www.thiagoalves.com.br/2010/05/24/my-workflow-with-git/#comments</comments>
		<pubDate>Mon, 24 May 2010 18:38:35 +0000</pubDate>
		<dc:creator>Thiago Alves</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://thiagoalves.org/?p=38</guid>
		<description><![CDATA[I know the last post was something slightly better than crap, but I just tried to give a brief introduction about Source Control Management to write this post about git, the one I choose for all my personal work. Sometimes &#8230; <a href="http://www.thiagoalves.com.br/2010/05/24/my-workflow-with-git/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I know the last post was something slightly better than crap, but I just tried to give a brief introduction about Source Control Management to write this post about git, the one I choose for all my personal work.</p>
<p>Sometimes you&#8217;re doing some personal project like a test algorithm, your personal web site or the next millionaire software; doesn&#8217;t meter, if you&#8217;re like me and like to test on your own stuff, you probably get to a point were you changed so much that going back to the original state takes so long that you choose keep trying to fix the current one.</p>
<p>Well, for me git came to save me for those hassles and once I started to do it, I install git on every machine I work&#8230; even in my day job!</p>
<p>Keep reading to find out how it works for me!<span id="more-38"></span></p>
<p style="text-align: left;"><a href="http://git-scm.org"><img class="aligncenter size-full wp-image-39" title="The fast version control system" src="http://thiagoalves.org/wp-content/uploads/2010/05/GitHeader.jpg" alt="The fast version control system" width="300" height="106" /></a></p>
<p>From now on, I&#8217;ll assume that you, at least, knows what git is and how it basically works. If you don&#8217;t, check<a href="http://git-scm.org"> git&#8217;s official site</a> and its documentation, but to make your life easier I&#8217;ll recommend you the first 4 tutorials on the documentation section:</p>
<ul>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html">The official Git tutorial</a></li>
<li><a href="http://www.kernel.org/pub/software/scm/git/docs/everyday.html">Everyday Git in 20 commands</a></li>
<li><a href="http://git-scm.com/course/svn.html">The SVN Crash Course</a></li>
<li><a href="http://www.spheredev.org/wiki/Git_for_the_lazy">Git for the lazy</a></li>
</ul>
<p>We&#8217;re good? Ok, lets move one!</p>
<h3>The start up of a new project</h3>
<p>By a &#8220;new project&#8221; I mean &#8220;every thing you do on your computer that can be isolated&#8221;. This means that a project can be a shell script, a word processing document, a spreadsheet, an entire site or even a complete program.</p>
<p>I&#8217;ll not lie to you, there are many &#8220;projects&#8221; on my computer that don&#8217;t have a git repository but trust me, from now and then I always regret myself to not had created one.</p>
<p>Anyway, first thing most people do is to create an empty repository and start doing their stuff inside it. Well, that quite doesn&#8217;t work for me. See, most of the times I create 3 or 4 start up projects before be completely satisfied with it and start coding, for that reason I only create a git repository when I have the basic skeleton of my future project. When I&#8217;m satisfied with my starting project, then I issue the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> init
$ <span style="color: #c20cb9; font-weight: bold;">git</span> add .
$ <span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial revision&quot;</span></pre></div></div>

<p>I use these commands so much that I have an alias to do them for me:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">projinit</span>=<span style="color: #ff0000;">'git init &amp;amp;&amp;amp; git add . &amp;amp;&amp;amp; git commit -m &quot;Initial revision&quot;'</span></pre></div></div>

<p>Ok, with that ready my next step is to ignore some files that I don&#8217;t want to track, like <code>.o</code> files in C/C++ project. To do so I edit the <code>.gitignore</code> file and add those extensions there. Again, I&#8217;ll assume you know how to do it, if you don&#8217;t, check my recommended links above.</p>
<h3>The code workflow</h3>
<p>You might ask:</p>
<blockquote><p>&#8220;How often you commit your work?&#8221;</p></blockquote>
<p>Well, I always do commits when I finish a small milestone of my project, and when I say small, I mean it. For instance, if I&#8217;m doing a Vim plugin, when I finish the start code snippet that contains a check if the plugin is already loaded, I commit. Check it out:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="vim" style="font-family:monospace;"><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #adadad; font-style: italic;">
&quot; AutoClose.vim - Automatically close pair of characters: ( with ), [ with ], { with }, etc.</span><span style="color: #adadad; font-style: italic;">
&quot; Version: 2.0</span><span style="color: #adadad; font-style: italic;">
&quot; Author: Thiago Alves &amp;lt;thiago.salves@gmail.com&amp;gt;</span><span style="color: #adadad; font-style: italic;">
&quot; Maintainer: Thiago Alves &amp;lt;thiago.salves@gmail.com&amp;gt;</span><span style="color: #adadad; font-style: italic;">
&quot; URL: http://thiagoalves.org</span><span style="color: #adadad; font-style: italic;">
&quot; Licence: This script is released under the Vim License.</span><span style="color: #adadad; font-style: italic;">
&quot; Last modified: 05/11/2010</span>
<span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span><span style="color: #C5A22D;">&quot;&quot;</span>
&nbsp;
<span style="color: #804040;">let</span> s<span style="color: #000000;">:</span><span style="color: #668080;">debug</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #adadad; font-style: italic;">
&nbsp;
&quot; check if script is already loaded</span>
<span style="color: #804040;">if</span> s<span style="color: #000000;">:</span><span style="color: #668080;">debug</span> == <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&amp;</span>amp;<span style="color: #000000;">&amp;</span>amp; <span style="color: #25BB4D;">exists</span><span style="color: #000000;">&#40;</span><span style="color: #C5A22D;">&quot;g:loaded_AutoClose&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #804040;">finish</span> <span style="color: #C5A22D;">&quot;stop loading the script&quot;</span>
<span style="color: #804040;">endif</span>
<span style="color: #804040;">let</span> g<span style="color: #000000;">:</span>loaded_AutoClose = <span style="color: #000000; font-weight:bold;">1</span>
&nbsp;
<span style="color: #804040;">let</span> s<span style="color: #000000;">:</span>global_cpo = <span style="color: #000000;">&amp;</span>amp;cpo<span style="color: #adadad; font-style: italic;"> &quot; store compatible-mode in local variable</span>
<span style="color: #804040;">set</span> cpo<span style="color: #000000;">&amp;</span>amp;vim<span style="color: #adadad; font-style: italic;">             &quot; go into nocompatible-mode</span></pre></td></tr></table></div>

<p>For me, this worth a commit!</p>
<p>Of course I forgot to commit that often, but when that happens I use the cherry pick commit from git where you can selective choose which lines you want to stage, then I create as many commits as it needs.</p>
<p>Please, don&#8217;t think I keep committing my code every dozen lines, is not like that. Some times it takes me one or two days and about 5-6 files to I feel like my changes worth a commit. Honestly this is up to you decide how often you&#8217;ll gonna commit.</p>
<p>Here is a snapshot of my git repository from my Vim plugin called Autoclose:</p>
<p><a style="text-decoration: none;" href="http://github.com/Townk/vim-autoclose"><img class="aligncenter size-full wp-image-59" title="autoclose_git" src="http://thiagoalves.org/wp-content/uploads/2010/05/autoclose_git1.jpg" alt="Ggit repository from vim Autoclose plugin" width="600" height="420" /></a></p>
<p>At this point I have a growing repository with a bunch of commits that keeps track of what I&#8217;m doing and suddenly I get to a point where I&#8217;ll try a crazy change on my code that will delete a big chunk of code. What do I do?</p>
<h4>Branching</h4>
<p>I create a branch! On git it is as easy as type one command line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #660033;">-b</span> mycrazytest</pre></div></div>

<p>Done! I&#8217;m on a new branch ready to rape my code as much as I want without loosing any code done so far.</p>
<p>When I finish this crazy test I check if it worth something and if it is, I go back to my master branch and merge the changes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> checkout master
$ <span style="color: #c20cb9; font-weight: bold;">git</span> merge mycrazytest</pre></div></div>

<p>And if I feel like this was all crap, I just delete the branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">git</span> checkout master
$ <span style="color: #c20cb9; font-weight: bold;">git</span> branch <span style="color: #660033;">-d</span> mycrazytest</pre></div></div>

<p>This way I never loose code and I feel confident to change  as much as I want.</p>
<h3>Going pro</h3>
<p>Some project demand a better approach then a master repository and a bunch of test ones. For these cases I always follow this steps:</p>
<ol>
<li>Initialize my repository;</li>
<li>Create a development branch</li>
<li>Do all my coding on development branch</li>
<li>When project reaches some release milestone I merge development with master and tag master with the milestone description</li>
<li>Get back to development branch and continue coding</li>
</ol>
<p>This small recipe is helping me doing some Indie projects on a more professional way and so far it&#8217;s working like a charm.</p>
<p>Now that you know my workflow be prepare to 2 or 3 more posts about git. I&#8217;m planning to write about git host (public and private, specially on Webfaction) and about repository conversion (from SVN to git, Mercurial to Git, etc.).</p>
<p>With some luck I make the action of writing here a habit and sooner or later I will have some people actually reading this blog <img src='http://www.thiagoalves.com.br/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thiagoalves.com.br/2010/05/24/my-workflow-with-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VCS: Choose yours, but go distributive!</title>
		<link>http://www.thiagoalves.com.br/2010/05/19/vcs/</link>
		<comments>http://www.thiagoalves.com.br/2010/05/19/vcs/#comments</comments>
		<pubDate>Wed, 19 May 2010 04:24:11 +0000</pubDate>
		<dc:creator>Thiago Alves</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[dvcs]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://thiagoalves.org/?p=31</guid>
		<description><![CDATA[On this post I'll talk very quick about my Versioning Control System of choice, git, and how I cross my path with it. <a href="http://www.thiagoalves.com.br/2010/05/19/vcs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I started to develop I always was fascinated by versioning my code so I could keep a history of my development, but until couple years ago I never could get any VCS (Version Control System) up and running on my machines.</p>
<p>I don&#8217;t know if was the complexity of having a server machine to host my repositories or was just pure laziness but the fact was I never used a VCS until I knew git!<span id="more-31"></span></p>
<p style="text-align: center;"><a style="text-decoration: none;" href="http://thiagoalves.org/wp-content/uploads/2010/05/rebase3.png"><img class="size-medium wp-image-32 aligncenter" title="rebase3" src="http://thiagoalves.org/wp-content/uploads/2010/05/rebase3-300x146.png" alt="Git Branches" width="300" height="146" /></a></p>
<h3>The joy of a DVCS</h3>
<p>What most call my attention was the possibility to have my whole repository locally, independent of a separate server! I would have no excuses to not use it, just run couple commands on your directory and I would be done.</p>
<p>Not that fast! One thing kept poking my mind:</p>
<blockquote><p>And if I loose everything on my hard drive?</p></blockquote>
<p>If I use a &#8220;traditional&#8221; VCS I would have all my code backup on the server, and with git? Well,  it turns out that git has a smarted solution for this and is the D on DVCS: Distribution. Linus Torvalds had this idea that every copy of the repository should be a backup of the entire source tree, this way if you look your copy, you can just grab a copy of your neighbor and you have a full copy of your tree.</p>
<p>Of course there are some details about it that you should check on the links at the end of this post, but the important thing here is: I founded a software that would keep history of my projects locally plus allowing me to share my work and as result have multiple backups of my source code.</p>
<p>You might be thinking: Git is the way to go? There are any alternatives out there?</p>
<p>In fact there are!</p>
<h3>Alternatives to Git</h3>
<p>If you read about git and like the concept but something looked weird, you can still try couple more DVCS. The most famous are:</p>
<ul>
<li>Bazaar</li>
<li>Mercurial</li>
</ul>
<p>Both are awesome and looks very similar to each other including git.</p>
<p>Anyway, doesn&#8217;t meter which software do you choose, the only thing that meters is that now there is no more excuses to not versioning your personal code! Believe me, if you spend some time reading about DVCS you&#8217;ll find out that you should be doing it already.</p>
<p>And where can you read more about it?</p>
<h3>Further knowledge</h3>
<p>First I would like to point you out to the 3 main pages of each DVCS:</p>
<ul>
<li>git: <a href="http://git-scm.com/">http://git-scm.com/</a></li>
<li>Bazaar: <a href="http://bazaar.canonical.com/en/">http://bazaar.canonical.com/en/</a></li>
<li>Mercurial: <a href="http://mercurial.selenic.com/">http://mercurial.selenic.com/</a></li>
</ul>
<p>Then if you want to dig deeper into git I indicate the following links:</p>
<ul>
<li><a href="http://book.git-scm.com">The Git Book</a> (which is the place where I took the image of this post)</li>
<li><a href="http://peepcode.com/products/git">PeepCode</a> (this one is paid, but definitively worth the money)</li>
</ul>
<p>I know this post is just too small to talk about git or DVCS but I just wanted to spit it out to start a path for future posts and perhaps one or two articles/tutorials. Keep tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thiagoalves.com.br/2010/05/19/vcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The iPad controverse</title>
		<link>http://www.thiagoalves.com.br/2010/01/30/the-ipad-controverse/</link>
		<comments>http://www.thiagoalves.com.br/2010/01/30/the-ipad-controverse/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 13:49:50 +0000</pubDate>
		<dc:creator>Thiago Alves</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[gadgets]]></category>

		<guid isPermaLink="false">http://thiagoalves.org/?p=10</guid>
		<description><![CDATA[On this post I discuss the Apple iPad gadget, its possible usages and target public. Also I do a brief comparison with Netbooks and expose what I think iPads can be better and worst on. <a href="http://www.thiagoalves.com.br/2010/01/30/the-ipad-controverse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="clear: both;">
  On January 28th Apple launch its new product the iPad. Since a month or more before the launch everyone is speculating and try to guess what this new product will be and how it should change the world.
</p>
<p>Well the day to know it come and almost everybody was disappointed with it. The question is: Why?</p>
<p style="text-align: center;">
  <a href="http://thiagoalves.org/wp-content/uploads/2010/01/safari_20100127.jpg"><img title="iPad" src="http://thiagoalves.org/wp-content/uploads/2010/01/safari_20100127-272x300.jpg" alt="Apple iPad" width="272" height="300" /></a>
</p>
<p style="text-align: left;">
  In my humble opinion the problem happen because everyone was expecting a step above the laptop and no one like it when they realize that this new product come below laptops.
</p>
<p style="text-align: left;">
  The dreamed tablet running MacOS X unmodified has to wait, but lets face it, what are the main uses for a tablet?I can come up with some:
</p>
<ul style="clear: both;">
<li>
    Specialized softwares like medical or coaches play book
  </li>
<li>
    Reading
  </li>
<li>
    Students notes
  </li>
</ul>
<p style="clear: both;">
  Honestly I can&#8217;t see further use for it since they first appears in 2001 as the first public prototype from Microsoft.
</p>
<p style="clear: both;">
  The industry didn&#8217;t put any effort to bring tablets to the mass until they realize that Apple was doing it. But we cannot talk about tablets before say a word or two about NetBooks for two reasons: First they came to life as the gadget between smart phones and laptops (which is exactly what Apple claims iPad is) and the second because Steve Jobs talk about then on his Key Note.
</p>
<p style="clear: both;">
  Unfortunately I have to agree with Mr. Jobs. I can&#8217;t see my self programming, writing long texts, playing a game or even watching a movie on a NetBook. But I can see myself taking notes from a class on it, reading an email on the road and doing a quick post on this blog.
</p>
<p style="clear: both;">
  But for those tasks that a NetBook will fit I can&#8217;t avoid to think in: open my bag, take the little gadget from it, open the lid, wait for it come to life, start the desired application, use it, close the application, shutdown the NetBook and put it back on the bag.
</p>
<p style="clear: both;">
  This is exactly the same process to use my laptop only the gadget is smaller. Sorry but I can&#8217;t see any different for me.
</p>
<p style="clear: both;">
  Also we have to think about NetBooks performances. I don&#8217;t have one so I cannot talk to much about it but I wonder if a NetBook is faster enough to a &#8220;quick post&#8221; before an appointment. Imagine your self coming to an office for a meeting and the secretary says that you&#8217;ll have to wait a little.
</p>
<blockquote style="clear: both;"><p>
  &#8220;No problem I can take my NetBook and do some notes on it while I&#8217;m waiting!&#8221;
</p></blockquote>
<p style="clear: both;">
  Well, if the waiting time is shorter than the time your gadget takes to turn on it will be embarrassing.
</p>
<p style="clear: both;">
  So why NetBooks exists in first place? Contrary to Mr. Jobs, NetBooks do 2 things way better then a laptop:
</p>
<p style="clear: both;">
  They are <strong>smaller</strong> and <strong>cheaper</strong> then laptops!
</p>
<p style="clear: both;">
  And that are two things that mobile professionals love!
</p>
<blockquote style="clear: both;"><p>
  &#8220;A full computer a little bigger then my smartphone? Who cares if this computer doesn&#8217;t do as much as my laptop! I can put it in a purse and it cost way less than a laptop!!!!&#8221;
</p></blockquote>
<p style="clear: both;">
  And the NetBook market was formed. The industry starts to think in ways to improve it, make it better, bigger, smaller, prepare your breakfast and everything you can imagine until Apple did what they are really good about:
</p>
<p style="clear: both;">
  Get a small set of tasks and do them in the best possible way.
</p>
<p style="clear: both;">
  You can see this in MP3 players. Everybody knows that a generic MP3 player does a bunch of tasks more than an iPod but for those tasks that an iPod does every one else fails miserably. Microsoft felt this with its Zune.
</p>
<p style="clear: both;">
  And what are those tasks Apple try to embrace with iPad? As I can see (disregard what Mr. Jobs said) these are the key features that iPad intent to do:
</p>
<ul style="clear: both;">
<li>
    Reading
  </li>
<li>
    Browsing
  </li>
<li>
    Email
  </li>
<li>
    Movies
  </li>
<li>
    Specialized apps
  </li>
</ul>
<p style="clear: both;">
  And I&#8217;m pretty sure that Apple will do them brilliantly as always.
</p>
<p style="clear: both;">
  So imagine your self reading a book or a magazine on a NetBook, than imagine the same thing with an iPad. Which one is better?
</p>
<blockquote style="clear: both;"><p>
  &#8220;Aha! But for read books I have a Kindle and iPad will never be a Kindle killer!&#8221;
</p></blockquote>
<p style="clear: both;">
  Exactly! iPad is not a Kindle killer either because it doesn&#8217;t intent to! Remember that iPad has its place between smartphones and laptops and eBook Readers are a whole different category.
</p>
<blockquote style="clear: both;"><p>
  &#8220;But Apple launch the iBookStore! How can you say that this is not their intent?&#8221;
</p></blockquote>
<p style="clear: both;">
  Well I think on iBookStore as another media store for Apple devices. Imagine 3 years from now with iBookStore having almost the same books as Amazon and then Apple launch an eBook Reader with eInk. It&#8217;s device will have all those title available just like Apps for iPad!So reading on iPad is probably way better then any other device except eBook readers.
</p>
<p style="clear: both;">
  Now, on the category of Specialized Apps that iPad will shine. Which you think is better, play a game on a NetBook or play a game on an iPad? A medical care software used on hospitals being used on a NetBook or on an iPad?
</p>
<p style="clear: both;">
  That&#8217;s the point! Apple didn&#8217;t tried to launch a concurrent for laptops or smartphones, even because they will not have two products concurring with each other (they already learned that lesson), they launch a new platform for new possibilities and we&#8217;ll only see what iPad is good for in a year from now with help of iPad developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thiagoalves.com.br/2010/01/30/the-ipad-controverse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

