<?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>Henrique Barroso</title>
	<atom:link href="http://www.henriquebarroso.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.henriquebarroso.com</link>
	<description>My thoughts on software development and stuff...</description>
	<lastBuildDate>Fri, 22 Mar 2013 16:49:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Gowork@ my job board aggregator</title>
		<link>http://www.henriquebarroso.com/gowork-my-job-board-aggregator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gowork-my-job-board-aggregator</link>
		<comments>http://www.henriquebarroso.com/gowork-my-job-board-aggregator/#comments</comments>
		<pubDate>Sat, 02 Feb 2013 23:52:17 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Startups]]></category>
		<category><![CDATA[3heap]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[job board]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=423</guid>
		<description><![CDATA[Back in 2011 I&#8217;ve created a simple, yet powerful job board called Gowork@. However, at the time I didn&#8217;t put too much effort into spread the word. Also, I had the chicken and egg problem. No jobs, no visitors and vice-versa. So, after I while I cowardly gave up on the project and I&#8217;ve put [...]]]></description>
				<content:encoded><![CDATA[<p>Back in 2011 I&#8217;ve created a simple, yet powerful job board called <strong><a href="http://www.gowork.at">Gowork@</a></strong>.<br />
However, at the time I didn&#8217;t put too much effort into spread the word. Also, I had the chicken and egg problem. No jobs, no visitors and vice-versa. So, after I while I cowardly gave up on the project and I&#8217;ve put it aside.</p>
<p><span id="more-423"></span><br />
However, recently I decided to  make a come back, but instead of being a job board, I decided to use it as an aggregator to other job boards out there.</p>
<p>Currently is includes jobs from <a href="http://jobs.37signals.com/">37 Signals</a>, <a href="http://www.authenticjobs.com/">Authentic jobs</a> and <a href="http://www.krop.com/">Krop</a>.</p>
<p><a href="http://www.gowork.at">Gowork@</a> has an awesome search engine that can easy filter jobs out. And users can save their searches and be notified when new jobs meet their criteria.</p>
<p>I personally believe that this is the best job aggregator for IT jobs out there. Let me know what you think <img src='http://www.henriquebarroso.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/gowork-my-job-board-aggregator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Test web apps on iOS by DNS spoofing your LAN with Ettercap</title>
		<link>http://www.henriquebarroso.com/test-web-apps-on-ios-by-dns-spoofing-your-lan-with-ettercap/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=test-web-apps-on-ios-by-dns-spoofing-your-lan-with-ettercap</link>
		<comments>http://www.henriquebarroso.com/test-web-apps-on-ios-by-dns-spoofing-your-lan-with-ettercap/#comments</comments>
		<pubDate>Tue, 29 Jan 2013 19:10:57 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[dns spoofing]]></category>
		<category><![CDATA[ettercap]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[MITM]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=381</guid>
		<description><![CDATA[Problem One of the things that annoys me is the fact the I can&#8217;t change the &#8220;/etc/hosts&#8221; file in the iOS (except if you jailbreak, I know I know). I say this because I have lots of web apps in my local linux server that I would love to test it on mobile devices. I [...]]]></description>
				<content:encoded><![CDATA[<h2>Problem</h2>
<p>One of the things that annoys me is the fact the I can&#8217;t change the <i>&#8220;/etc/hosts&#8221;</i> file in the iOS (except if you jailbreak, I know I know).<br />
I say this because I have lots of web apps in my local linux server that I would love to test it on mobile devices.<br />
<span id="more-381"></span><br />
I normally add a virtual host for each site on Apache. However in order to make this work on my local computers, I need to change the file &#8220;/etc/hosts&#8221; and add something like</p>
<pre class="brush: plain; light: true; title: ; notranslate">
...
192.168.1.3 local.myapp.com
</pre>
<p>And every time I go to my desktop browser and type http://local.myapp.com/ this request is going to be redirected to 192.168.1.3 where my apache is installed.</p>
<p>Well, this is all fine and dandy, but you can&#8217;t do this on iOS (Again, not without jailbreaking it&#8230;) .</p>
<p>So how do you solve this?</p>
<h2>Alternative solutions&#8230;meh&#8230;</h2>
<p>There are various ways of solving it.<br />
Some people install a proxy server like <a href="http://www.squid-cache.org/">Squid</a>, others install a DNS server like <a href="https://www.isc.org/software/bind">BIND</a>. </p>
<p>Personally, I think this is a little bit overkill. I don&#8217;t want to configure proxies on and off on Safari, in my case I have an iPhone and an iPad, I would need configure both every time I needed to test it. And I definitely don&#8217;t want to waste time managing a DNS server, plus wasting system resources for such sporadic testing.</p>
<h2>My solution</h2>
<p>So what do you do ?<br />
You <strong>hack</strong> your own LAN for fun and (possibly) profit.</p>
<p>What I do is, I &#8220;attack&#8221; my own LAN computers by performing a MITM (man-in-the-middle) attack and DNS spoofing the living shit out of my target router clients with <a href="http://ettercap.github.com/ettercap/">Ettercap</a>.</p>
<h2>POC</h2>
<p>The first thing you want to do is to install <a href="http://ettercap.github.com/ettercap/">Ettercap</a> in your Linux box.<br />
I&#8217;m using Debian dist, but I know you can install it on OSX and Windows as well.</p>
<h4>Install ettercap</h4>
<pre class="brush: bash; light: true; title: ; notranslate">
$ sudo apt-get update &amp;&amp; apt-get install ettercap
</pre>
<h4>Enable IP forwarding</h4>
<pre class="brush: bash; light: true; title: ; notranslate">
$ echo 1 &gt; /proc/sys/net/ipv4/ip_forward
</pre>
<h4>Edit /usr/share/ettercap/etter.dns</h4>
<pre class="brush: bash; light: true; title: ; notranslate">
$ sudo vim /usr/share/ettercap/etter.dns
</pre>
<h4>Add a new entry for your local domain host</h4>
<pre class="brush: plain; title: ; notranslate">
...
################################
# My local web sites
#
local.myapp.com       A       192.168.1.3
*.myapp.com           A       192.168.1.3
</pre>
<p>192.168.1.3 should be the IP address of your local server where Apache is installed.<br />
Save the file and quit to shell.</p>
<h4>Start ettercap</h4>
<pre class="brush: bash; light: true; title: ; notranslate">
$ sudo ettercap -i eth0 -T -q -M ARP:remote -P dns_spoof /192.168.1.5/ //
</pre>
<p>Make sure to change the IP address to match the one in your iPad/iPhone.<br />
If you don&#8217;t know your IP, just touch in &#8220;Settings&#8221; > &#8220;Wi-Fi&#8221; > and touch in the blue arrow circle icon.</p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/wi-fi-settings-300x274.jpeg" alt="wi-fi-settings" width="300" height="274" class="size-medium wp-image-402" /></p>
<p>If you want to, you can target your whole LAN by using:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ sudo ettercap -i eth0 -T -q -M ARP:remote -P dns_spoof 
</pre>
<p>After your entered that command you should see something like this:</p>
<pre class="brush: plain; title: ; notranslate">
ettercap NG-0.7.3 copyright 2001-2004 ALoR &amp; NaGA

Listening on eth0... (Ethernet)

  eth0 -&gt;	00:0C:29:90:8D:1F       192.168.1.3     255.255.255.0

  28 plugins
  39 protocol dissectors
  53 ports monitored
7587 mac vendor fingerprint
1698 tcp OS fingerprint
2183 known services

Randomizing 255 hosts for scanning...
Scanning the whole netmask for 255 hosts...
* |==================================================&gt;| 100.00 %

6 hosts added to the hosts list...

ARP poisoning victims:

 GROUP 1 : 192.168.1.5 64:20:0C:06:FC:FB

 GROUP 2 : ANY (all the hosts in the list)
Starting Unified sniffing...


Text only Interface activated...
Hit 'h' for inline help

Activating dns_spoof plugin...
</pre>
<p>BAM ! We are all set, now open Safari in iPad/iPhone and visit http://local.myapp.com/ you should be seeing your local website. </p>
<p>This should show up in the shell terminal:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
...
dns_spoof: [local.myapp.com] spoofed to [192.168.1.3]
</pre>
<p>Press &#8216;q&#8217; to quit Ettercap.</p>
<p>Note: When you quit Ettercap, iOS will still cache this new IP. So make sure you refresh again your connection to flush you DNS cache when you no longer need it.</p>
<h4>Erm&#8230;not working dude.</h4>
<p>- Make sure you flush your DNS cache on iOs. You can do this by restarting your wi-fi connection. Sometimes it requires a few tries before it actually gets to work.</p>
<p>- Try the &#8220;ping&#8221; command and see if it&#8217;s pinging the right host.</p>
<h4>Conclusion</h4>
<p>And that&#8217;s it, for some it may seem a bit complicated, but remember that after the installation and configuration, you just need to run one command.</p>
<p>I think this is a much easier and cleaner way of testing websites with a virtual-host organisation.</p>
<p>Have another approach on this ? Leave it in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/test-web-apps-on-ios-by-dns-spoofing-your-lan-with-ettercap/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a dynamic modular multi-page app with Backbone.js and RequireJs</title>
		<link>http://www.henriquebarroso.com/creating-a-dynamic-modular-multi-page-app-with-backbone-js-and-requirejs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creating-a-dynamic-modular-multi-page-app-with-backbone-js-and-requirejs</link>
		<comments>http://www.henriquebarroso.com/creating-a-dynamic-modular-multi-page-app-with-backbone-js-and-requirejs/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 12:13:01 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Front-end]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[backbonejs]]></category>
		<category><![CDATA[bower]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[requirejs]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=290</guid>
		<description><![CDATA[So, as part of my To-Learn list for 2013 I&#8217;m currently messing around with Javascript tools and libraries. It has been a long way since we used Javascript mostly to validate forms and show alert boxes. Today we have so many good tools that allows us to write better front-end applications, that&#8217;s hard to keep [...]]]></description>
				<content:encoded><![CDATA[<p>So, as part of my <a href="http://www.henriquebarroso.com/my-to-learn-list-for-2013/">To-Learn list for 2013</a>  I&#8217;m currently messing around with Javascript tools and libraries.</p>
<p>It has been a long way since we used Javascript mostly to validate forms and show alert boxes.</p>
<p>Today we have so many good tools that allows us to write better front-end applications, that&#8217;s hard to keep up.</p>
<p>Recently I&#8217;ve been playing with <a href="http://backbonejs.org/">Backbone.js</a>, an awesome library that helps you separate content/logic in your front-end application. And while I&#8217;m no expert on it, one of the first things I noticed is that Backbone doesn&#8217;t explain how you should lay out your code. </p>
<p><span id="more-290"></span><br />
This can be good, but it can also lead to architecture design disasters if not used correctly. Specially if you are developing multi-pages website.</p>
<p>So, in this tutorial I&#8217;m going to show you how to create a good foundation for your application using AMD design pattern with <a href="http://backbonejs.org/">Backbone.js</a> and <a href="http://requirejs.org/">RequireJs</a>.</p>
<p><code><strong>Notice:</strong> This is not a tutorial for beginners on BackboneJs or RequireJs. It's expected that you have some experiencie with these tools.<br />
</code></p>
<h2>TL;DR</h2>
<p>I show you how to create a basic boilerplate multi-page using Backbone.js and RequireJs.<br />
I&#8217;ve placed a improved version of this tutorial on <a href="https://github.com/hbarroso/backbone-boilerplate">github</a>.</p>
<h2>Intro</h2>
<p>I&#8217;m not going to explain in full detail what each of these libraries do, I assume most of you already know it, if not, just click on the likes above.</p>
<p>We&#8217;re going to create a sort of boilerplate, that can be reused in future projects, so in order to do this we will need a few extra things  to keep everything tidy.</p>
<h2>Bower Setup</h2>
<p>The first thing you want to do, is to install <a href="https://github.com/twitter/bower">Bower</a>. This is a very light and solid package manager for the web. You can install/update/remove external vendor packages from your command line. </p>
<p>From your command line, create a folder somewhere in your web root folder.</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ mkdir myapp &amp;&amp; cd myapp/
</pre>
<p>At the root of myapp/ create a new file called <i>&#8220;.bowerrc&#8221;</i> and add this</p>
<pre class="brush: jscript; title: myapp/.bowerrc; notranslate">
{
  &quot;directory&quot;: &quot;src/scripts/vendors&quot;
}
</pre>
<p>This will make bower install it&#8217;s dependencies under the &#8220;directory&#8221; param.<br />
Save the file and go back to the command line.</p>
<p>Create another file called <i>&#8220;component.json&#8221;</i> and past this.</p>
<pre class="brush: jscript; title: myapp/component.json; notranslate">
{
	&quot;name&quot;: &quot;MyApp&quot;,
	&quot;version&quot; : &quot;1.0.0&quot;,
	&quot;dependencies&quot;: {
		&quot;jquery&quot;: null,
		&quot;backbone-amd&quot;: null,
		&quot;underscore-amd&quot;: null,
		&quot;requirejs&quot;: null,
	}
}
</pre>
<p>This file will allow Bower to install all of this dependencies for us.</p>
<p>Let the magic begin. From the command line type:</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ bower install
</pre>
<p>You should start see Bower fetching all those libraries from git and copying them into <i>&#8220;src/scripts/vendors&#8221;</i>.<br />
By default, Bower copies the entire repository of each library. So it&#8217;s up to you if you want to delete some extra files you don&#8217;t want. You can also just specify a single file, but read the Bower documentation for more info about this.</p>
<h2>Defining a directory structure</h2>
<p>Now, let&#8217;s create our bundle root folder.</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ mkdir src/scripts/bundles
</pre>
<p>This folder will be the home of our bundles.</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ mkdir build/
</pre>
<p>This folder will contain our building scripts, that will merge and minify our dirs into an output dir.</p>
<h2>Loading&#8230;</h2>
<p>Now, let&#8217;s get our hands dirty.<br />
Open up your favourite code editor, and create a file <i>&#8220;src/index.html&#8221;</i></p>
<pre class="brush: xml; title: myapp/src/index.html; notranslate">
&lt;!DOCTYPE HTML&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;meta name='viewport' content='width=device-width'/&gt;
    &lt;title&gt;Backbone Boilerplate&lt;/title&gt;
    &lt;script data-main=&quot;scripts/main&quot; 
        data-root=&quot;/myapp/src/&quot;
        src=&quot;scripts/vendors/requirejs/require.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

    &lt;h1&gt;My title&lt;/title&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Notice that <strong>data-root</strong> is a custom field we add. This field defines the default web url root path. If your root path is &#8220;/&#8221; you can remove this.</p>
<p><strong>data-main</strong> is the main entry point for RequireJs, this will load the file <i>&#8220;src/scripts/main.js&#8221;</i>, notice that we didn&#8217;t need to add &#8220;.js&#8221; extension. RequireJs does this for us.</p>
<p>So let&#8217;s create this file.</p>
<pre class="brush: jscript; title: myapp/src/scripts/main.js; notranslate">
(function () {

    'use strict';

    requirejs.config({
        baseUrl: &quot;scripts/&quot;,
        paths: {
            &quot;jquery&quot;: &quot;vendors/jquery/jquery&quot;,
            &quot;underscore&quot;: &quot;vendors/underscore-amd/underscore&quot;,
            &quot;backbone&quot;: &quot;vendors/backbone-amd/backbone&quot;,
        }
    });

    require(['app'], function (app) {
        app.initialize();
    });

}());

</pre>
<p>This file will be responsible for creating a config structure that will be used by RequireJs.</p>
<p>On line 17, RequireJs will need to include a &#8220;app.js&#8221; file, so let&#8217;s create it.</p>
<pre class="brush: jscript; title: myapp/src/scripts/app.js; notranslate">
define([
    'jquery',
    'underscore',
    'backbone',
    'router'
], function ($, _, Backbone, router) {

    'use strict';

    // Add your modules routing here
    router.route(&quot;/*&quot;, &quot;home&quot;, function () {
        this.loadModule(&quot;bundles/todos/main&quot;);
    });

    var root = $(&quot;[data-main][data-root]&quot;).data(&quot;root&quot;);
    root = root ? root : '/';

    return {
        initialize: function () {
            Backbone.history.start({
                pushState: true,
                root: root
            });
        }
    };
});
</pre>
<p>This file will allows to create our routing patterns for our bundles.<br />
Inside the define() function, you&#8217;ll notice that it will include our dependencies and a new file, called &#8220;router&#8221;, you haven&#8217;t created this yet.<br />
It will also start the Backbone History. Also, notice that it&#8217;s using our custom data-field &#8220;data-root&#8221; around line 15.</p>
<p>To complete our basic dynamic loading, we just need to create one last file. The router.js.</p>
<pre class="brush: jscript; title: myapp/src/scripts/router.js; notranslate">
define([&quot;underscore&quot;, &quot;backbone&quot;], function (_, Backbone) {

    'use strict';

     // Router
    var Router = Backbone.Router.extend({
        loadModule: function (module) {
            require([module], function (module) {
                module();
            });
        }
    });

    return new Router();
});
</pre>
<p>This file will create a new Object from Backbone.Router and add a new function called loadModule(). This function will load our Bundles dynamically. If you look at the file &#8220;app.js&#8221; you will see the following code.</p>
<pre class="brush: jscript; title: ; notranslate">
router.route(&quot;/*&quot;, &quot;home&quot;, function () {
    this.loadModule(&quot;bundles/demo/main&quot;);
});
</pre>
<p>This must be added by you. What this means is that everytime a url matches &#8220;/*&#8221; this will trigger an event that will load the &#8220;bundles/todos/main.js&#8221; file. We haven&#8217;t created this yet.</p>
<p>And we are done with the basic foundation for our multi-page app.<br />
To wrap it up, here&#8217;s the file tree.</p>
<pre class="brush: plain; title: ; notranslate">
.
├── .bowerrc
├── component.json
└── src
    ├── index.html
    └── scripts
        ├── app.js
        ├── bundles
        ├── main.js
        ├── router.js
        └── vendors
</pre>
<h2>Creating our bundle</h2>
<p>The idea behind a bundle is to isolate specific sections of our websites in it.<br />
For example.</p>
<p>http://www.myhost.com/ &#8212;> /src/scripts/bundles/home<br />
http://www.myhost.com/users &#8212;> /src/scripts/bundles/users<br />
http://www.myhost.com/invoices &#8212;> /src/scripts/bundles/invoices</p>
<p>And since we are using requireJs, we can easily create dependencies and share resources between bundles.</p>
<p>So let&#8217;s create a basic bundle.<br />
Inside <i>&#8220;myapp/src/scripts/bundles&#8221;</i> create a directory named &#8220;demo&#8221; with the following structure</p>
<pre class="brush: plain; title: ; notranslate">
.
├── collections     --&gt; Backbone Collections
├── models          --&gt; Backbone Models
├── templates       --&gt; Mustache Templates
├── tests           --&gt; To store unit tests
├── views           --&gt; Backbone Views
└── main.js         --&gt; Bundle entry point
</pre>
<p>The main.js required by all bundlers. It will be used as the entry point when a bundle is loaded.</p>
<p>Here&#8217;s an example</p>
<pre class="brush: jscript; title: ; notranslate">
define([ &quot;./views/main&quot;], function (MainView) {

    'use strict';

    return function () {

        var mainView = new MainView();
    };

});
</pre>
<p>This file will load a Backbone view object from &#8220;views/main.js&#8221; file.</p>
<h2>Building</h2>
<p>&#8220;Building&#8221; means that we will merge and minify/uglify our source code inside &#8220;myapp/src/&#8221; and output into a new folder &#8220;myapp/dist&#8221;. </p>
<p>We will endup with a single merged file for each bundle, and a single common file for our global dependencies like Backbone.js, RequireJs, jQuery and so on.</p>
<p>For eg. All of our files inside &#8220;myapp/src/scripts/bundles/demo&#8221; will be merged into one &#8220;main.js&#8221; file in the output directory.</p>
<p>As you know, this should be used on production only.</p>
<p>The major difference here, is that since we are using this for multi-page websites, we really don&#8217;t want to merge every thing into one big file, or having all bundles include the common libraries.</p>
<p>So by using the scripts below, we will organize our output code into single files that are loaded on demand.</p>
<p>When we created our directory structure, we created a dir at &#8220;myapp/build&#8221;.<br />
Inside that directory create two new files</p>
<pre class="brush: jscript; title: myaap/build/app.build.js; notranslate">
({
	appDir: '../src/',
	baseUrl: './scripts/',
	dir: '../dist',
	mainConfigFile: '../src/scripts/main.js',
	optimizeCss: 'none',
	paths: {
		requireLib: '../scripts/vendors/requirejs/require'
	},
	modules: [
		// WARNING: Do not remove this entry, it will be required
		// by all your bundles.
        {
            name: 'main',
            include: ['requireLib', 'main', 'app'],
        },


        //
        // Add your bundles here.
        // Make sure you always exclude 'main', 
        // unless you want to have
        // one single big file with every bundle 
        // and dependency. This is
        // not recommended.
        //
        {
            name: 'bundles/demo/main',
            exclude: ['main']
        }
    ]
})
</pre>
<p>In a nutshell, what we are doing here is specifying which bundles should be included, and make sure none of the bundles are merged with the &#8220;main&#8221; common scripts. Resulting in lighter files for the bundles. </p>
<pre class="brush: plain; title: myaap/build/build.sh; notranslate">
r.js -o app.build.js skipDirOptimize=true
rm -rf ../dist/scripts/vendors
rm ../dist/scripts/router.js
rm ../dist/scripts/app.js
rm ../dist/build.txt
</pre>
<p>This is the build bash script. It will run r.js and output the result into &#8220;myapp/dist&#8221; and remove some unused folders and files.</p>
<p>You need to install <a href="https://github.com/jrburke/r.js/">r.js first</a>.</p>
<pre class="brush: bash; light: true; title: ; notranslate">
$ cd build/ 
$ chmod +x build.sh
$ ./build.sh
</pre>
<p>You should start seeing a bunch of files being merged, and minified.<br />
After it&#8217;s completed, you should see a new folder &#8220;myapp/dist&#8221;. It should contain all of your code, but without the vendors directory and other files like &#8220;router.js&#8221;, &#8220;app.js&#8221;.</p>
<p>Instead you should see only a &#8220;main.js&#8221; file. If you open this file it should include all the common libraries, including require.js</p>
<p>So in your new &#8220;myapp/dist/index.html&#8221; file you can change the script to</p>
<pre class="brush: xml; title: ; notranslate">
    &lt;script data-main=&quot;scripts/main&quot; 
        data-root=&quot;/backbone-boilerplate/src/&quot;
        src=&quot;scripts/main.js&quot;&gt;&lt;/script&gt;
</pre>
<p>because &#8220;scripts/vendors/require/require.js&#8221; no longer exists.</p>
<h2>Conclusion</h2>
<p>And there you have it.<br />
A basic boilerplate form multi-page websites using Backbone and Requirejs. </p>
<p>I&#8217;ve created a more completed boilerpate called <a href="https://github.com/hbarroso/backbone-boilerplate">Backbone-Boilerplate</a> (creative name right?) that includes the concepts we are described here and goes a little further by using Unit testing, Template engine and including a Todo demo bundle for your to check it out.</p>
<p>I highly recommend your check this repository out, as it includes a more detail information on how to create bundles.</p>
<p>I also hope you&#8217;ve learned something, and if I missed or you have other suggestions please let me know in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/creating-a-dynamic-modular-multi-page-app-with-backbone-js-and-requirejs/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Music for coding</title>
		<link>http://www.henriquebarroso.com/music-for-coding/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=music-for-coding</link>
		<comments>http://www.henriquebarroso.com/music-for-coding/#comments</comments>
		<pubDate>Tue, 22 Jan 2013 21:10:49 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Offline]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[albums]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[songs]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=234</guid>
		<description><![CDATA[I don&#8217;t know about you, but I can&#8217;t code without music. It&#8217;s just something that I do in auto-pilot, right before writing any line of code I put my headphones on and start my music player. Although I love lots of rock bands and different styles, when it comes to coding I&#8217;m very, very picky. [...]]]></description>
				<content:encoded><![CDATA[<p>I don&#8217;t know about you, but I can&#8217;t code without music. It&#8217;s just something that I do in auto-pilot, right before writing any line of code I put my headphones on and start my music player.</p>
<p>Although I love lots of rock bands and different styles, when it comes to coding I&#8217;m very, very picky.<br />
One of the first requirements is that it can&#8217;t have people singing, or at least keep it to the bare minimum. I just find music with lyrics too distracting at times. I tend to concentrate more and get more productive while listening to hypnotic or haunting songs.<br />
<span id="more-234"></span><br />
So while coding I normally listen to Post-rock, Downtempo, chill-out, progressive house and so on. Funny enough tho, I can&#8217;t listen to any sort of music if I&#8217;m learning something new.</p>
<p>Anyway, I decided to compile a few of my favourite albums while I&#8217;m hacking through the day/night.</p>
<p>Without any further due, here&#8217;s my favourite albums recommendations.</p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/220px-BurialUntrue-150x150.jpeg" alt="220px-BurialUntrue" width="150" height="150" class="alignleft size-thumbnail wp-image-242" /></p>
<h3>Burial &#8211; Untrue</h3>
<p><small>Dubstep, 2-step garage, ambient</small><br />
<a href="http://www.youtube.com/watch?v=nBoYu7nnym4">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/220px-ForLackofaBetterNameAlbum-150x150.jpeg" alt="220px-ForLackofaBetterNameAlbum" width="150" height="150" class="alignleft size-thumbnail wp-image-255" /></p>
<h3>Deadmau5 &#8211; Lack For A Better Name</h3>
<p><small>Progressive House</small><br />
<a href="http://www.youtube.com/watch?v=z8nkEXbHgvg">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/13321726encodingjpgsize200-150x150.jpeg" alt="13321726;encoding=jpg;size=200" width="150" height="150" class="alignleft size-thumbnail wp-image-258" /></p>
<h3>Explosions In The Sky &#8211; First Breath After Coma</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=IzA_Qa2KHR0">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/alb_2072189_big-150x150.jpeg" alt="alb_2072189_big" width="150" height="150" class="alignleft size-thumbnail wp-image-259" /></p>
<h3>Gustavo Santaolalla &#8211; 21 Grams OST</h3>
<p><small>Rock, Ambient</small><br />
<a href="http://www.youtube.com/watch?v=Ry6fO8N_BPE">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/soundtrack__hans_zimmer-inception_a-150x150.jpeg" alt="soundtrack__hans_zimmer-inception_a" width="150" height="150" class="alignleft size-thumbnail wp-image-260" /></p>
<h3>Hans Zimmer &#8211; Inception OST</h3>
<p><small>Rock, Ambient</small><br />
<a href="http://www.youtube.com/watch?v=xKA2fAkxAUk">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/justice-cd-cover-art-150x150.jpeg" alt="justice-cd-cover-art" width="150" height="150" class="alignleft size-thumbnail wp-image-261" /></p>
<h3>Justice &#8211; Justice</h3>
<p><small>Electro-House</small><br />
<a href="http://www.youtube.com/watch?v=y1_SCfLxLFA">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/34923-150x150.jpeg" alt="34923" width="150" height="150" class="alignleft size-thumbnail wp-image-262" /></p>
<h3>M83 &#8211; Saturdays = Youth</h3>
<p><small>Electro-House</small><br />
<a href="http://www.youtube.com/watch?v=5B9iM_Si4Sc">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/Zidane_soundtrack-150x150.jpeg" alt="Zidane_soundtrack" width="150" height="150" class="alignleft size-thumbnail wp-image-263" /></p>
<h3>Mogwai &#8211; Zidane: A 21st Century Portrait</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=7Yd8vBKRntE">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/nine_inch_nails-ghosts_i_iv-150x150.jpeg" alt="nine_inch_nails-ghosts_i_iv" width="150" height="150" class="alignleft size-thumbnail wp-image-264" /></p>
<h3>Nine Inch Nails &#8211; Ghosts I-IV</h3>
<p><small>Ambient industrial, dark ambient</small><br />
<a href="http://www.youtube.com/watch?v=wCUZs-d5r0M">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/4302-150x150.jpeg" alt="4302" width="150" height="150" class="alignleft size-thumbnail wp-image-265" /></p>
<h3>Sigur Rós &#8211; Ágætis Byrjun</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=swPHOzSSMNI">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/this-will-destroy-you-150x150.jpeg" alt="this will destroy you" width="150" height="150" class="alignleft size-thumbnail wp-image-266" /></p>
<h3>This Will Destroy You &#8211; This Will Destroy You</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=0BSHAXpNey0">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/7708035_social_network_200-150x150.jpeg" alt="7708035_social_network_200" width="150" height="150" class="alignleft size-thumbnail wp-image-276" /></p>
<h3>Trent Reznor &#8211; The Social Network OST</h3>
<p><small>Dark ambient, post-industrial, experimental, electronica</small><br />
<a href="http://www.youtube.com/watch?v=9SBNCYkSceU">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/Weekend_in_America_-_Wolfgang_Gartner_-_Front_Cover_Art_200x200-150x150.jpeg" alt="Weekend_in_America_-_Wolfgang_Gartner_-_Front_Cover_Art_200x200" width="150" height="150" class="alignleft size-thumbnail wp-image-268" /></p>
<h3>Wolfgang Gartner &#8211; Weekend In America</h3>
<p><small>Progressive-house</small><br />
<a href="http://www.youtube.com/watch?v=nDSUEESo4v0">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/xx_coexist-150x150.jpeg" alt="xx_coexist" width="150" height="150" class="alignleft size-thumbnail wp-image-270" /></p>
<h3>XX &#8211; Coexist</h3>
<p><small>Indie Pop</small><br />
<a href="http://www.youtube.com/watch?v=_nW5AF0m9Zw">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/000000_504-150x150.jpeg" alt="000000_504" width="150" height="150" class="alignleft size-thumbnail wp-image-271" /></p>
<h3>Aes Dana &#8211; Perimeters</h3>
<p><small>Downtempo, Progressive Trance, Ambient</small><br />
<a href="http://www.youtube.com/watch?v=wCWc6Oz8_m0">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/000000_460-150x150.jpeg" alt="000000_460" width="150" height="150" class="alignleft size-thumbnail wp-image-272" /></p>
<h3>Carbon Based Lifeforms &#8211; Interloper</h3>
<p><small>Downtempo, Ambient, Acid</small><br />
<a href="http://www.youtube.com/watch?v=ywIBTz2cohE">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/205026-150x150.jpeg" alt="205026" width="150" height="150" class="alignleft size-thumbnail wp-image-273" /></p>
<h3>God Is An Austronaut &#8211; Age of the Fifth Sun</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=1CD1tlZEw0A">Listen</a><br />
<br clear="all"/></p>
<p><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/homepage_large.885c5fc2-150x150.jpeg" alt="homepage_large.885c5fc2" width="150" height="150" class="alignleft size-thumbnail wp-image-274" /></p>
<h3>Mono &#8211; Hymn to the Immortal Wind</h3>
<p><small>Post-Rock</small><br />
<a href="http://www.youtube.com/watch?v=vxPCqh8qX-4">Listen</a><br />
<br clear="all"/></p>
<p>I&#8217;ve compiled all of these albums in a <a href="http://grooveshark.com/#!/playlist/Music+For+Coding/82130990">Grooveshark Playlist</a> in case you want to hear it in the background.</p>
<p>Hope you&#8217;ve liked my selection, and let me know what are your favourite albums in the comments below <img src='http://www.henriquebarroso.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/music-for-coding/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>My to-learn list for 2013</title>
		<link>http://www.henriquebarroso.com/my-to-learn-list-for-2013/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-to-learn-list-for-2013</link>
		<comments>http://www.henriquebarroso.com/my-to-learn-list-for-2013/#comments</comments>
		<pubDate>Mon, 21 Jan 2013 14:30:25 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Front-end]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[2013]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[goals]]></category>
		<category><![CDATA[languages]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=212</guid>
		<description><![CDATA[Year 2012 was a good year. I had two main goals, learn Objective-C and bootstrap an App. I succeed at both. At first I wanted to launch a iOS app, but in the end I came to launch a OSX app. You can look at it here. Learning Objective-C and Cocoa had a somehow steep learning [...]]]></description>
				<content:encoded><![CDATA[<p>Year 2012 was a good year.<br />
I had two main goals, learn Objective-C and bootstrap an App. I succeed at both.<br />
At first I wanted to launch a iOS app, but in the end I came to launch a OSX app.<br />
You can look at it <a href="http://www.codebugapp.com/">here</a>.</p>
<p>Learning Objective-C and Cocoa had a somehow steep learning curve, specially Cocoa framework. But hey, I did it. I&#8217;m now able to create Cocoa apps, and I&#8217;m very proud of this achievement.<br />
<span id="more-212"></span><br />
However, I&#8217;m mostly a web developer, and in 2012 some technologies and trends slipped away from me due to my full focus on one language and framework.</p>
<p>In 2013 I&#8217;m hoping to fix this, I want to recover that time and get back on track on Webdev, even if some of it is also front-end related.</p>
<p>So to make it easy, I&#8217;ve compiled a small list of things I want to either learn or become more hardcore at it.</p>
<p>Here&#8217;s the main topics.</p>
<h3>Languages</h3>
<p><a href="https://developer.mozilla.org/en/docs/JavaScript">Javascript</a> - I want to improve my currents skills, use better practices and understand some things better<br />
<a href="http://php.net/">PHP 5.4/5.5</a> - Learn the new features of PHP 5.4 and 5.5<br />
<a href="http://www.python.org/">Python</a> (Due to Udacity courses I&#8217;m need to refresh my skills in Python)</p>
<h3>Frameworks</h3>
<p><a href="http://backbonejs.org/">Backbone.js</a> - Everyone is using this lately, I need to get my hands dirty and create something out of it<br />
<a href="http://angularjs.org/">AgularJS</a> - Lots of people recommend this instead of backbone, I want to try both and see what fits me best<br />
<a href="http://coffeescript.org/">CoffeeScript</a> - Heard good things about it, need to try it out as well.<br />
<a href="http://laravel.com/">Laravel</a> - I saw their documentation and a  few videos and I got immediately interested in using it<br />
<a href="http://jquery.com/">JQuery</a> - I need to go depth in JQuery, like javascript, code better with Jquery.<br />
<a href="http://sass-lang.com/">SASS</a> - The new shiny thing for CSS, it looks awesome as well.<br />
<a href="http://www.nodejs.org/">NodeJS</a> - I have done a few things with nodeJS in early 2012, but I&#8217;m feeling rusty at it. So I may do a small come back here as well.</p>
<h3>Services</h3>
<p><a href="http://www.mongodb.org/">MongoDB</a> - Finally I need to get into NoSQL databases and learn/code something out of it<br />
<a href="http://www.elasticsearch.org/">ElasticSearch</a> - I&#8217;ve already tried SphinxSearch, now it&#8217;s time for ElasticSearch and it&#8217;s lovely JSON queries<br />
<a href="http://www.postgresql.org/">PostgreSQL</a> - I left PSQL in 2002/2003, I need to regain my skills at it and maybe ditch MySQL forever.</p>
<h3>Concepts, practices and online courses</h3>
<p><a href="http://en.wikipedia.org/wiki/Unit_testing">Unit Testing</a>, <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a> and <a href="http://en.wikipedia.org/wiki/Behavior-driven_development">BDD</a> - I seriously need to start doing this, so far I&#8217;ve done just a little of Unit testing, I need more. (Shame on me)<br />
<a href="http://pear.php.net/manual/en/standards.php">PHP Standards</a> - Code by PHP standards and stick to it<br />
<a href="http://hackdesign.org/">Hack Design</a> - This is an amazing course for any developer who wants or needs to cross to design once and while<br />
<a href="http://www.udacity.com/">Udacity</a> - Epic courses here, I&#8217;m committing myself to learn at least 2 or 3 this year</p>
<h4>Books</h4>
<p><a href="http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742">Javascript &#8211; The Good Parts</a> - Already read it by time I&#8217;m writing this. Good book to any JS coder.<br />
<a href="http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X">The Pragmatic Programmer</a> - Great tips on good practices, I need to finish it.<br />
<a href="http://www.amazon.com/Code-Complete-Practical-Handbook-Construction/dp/0735619670/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1358778067&amp;sr=1-1&amp;keywords=Code+complete">Code Complete 2nd Edition</a> - I heard this is also a very good book, I need to purchase it first <img src='http://www.henriquebarroso.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h4>Projects</h4>
<p>Launch an OSS project (yet to be defined)<br />
Launch a new Webapp (yet to be defined)<br />
Improve Codebugapp</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/my-to-learn-list-for-2013/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debugging and profiling in PHP</title>
		<link>http://www.henriquebarroso.com/php-debugging-and-profiling/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-debugging-and-profiling</link>
		<comments>http://www.henriquebarroso.com/php-debugging-and-profiling/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 16:42:58 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Good Practices]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Codebug]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Profiling]]></category>
		<category><![CDATA[Xdebug]]></category>
		<category><![CDATA[XHprof]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=147</guid>
		<description><![CDATA[When I started working as a web developer, PHP was the first language I learned that was 100% web oriented. Back then I believe it was PHP3 or something like that. At the time, PHP was pretty new to the web, PERL was the main denominator. PHP today is hated and loved, and I&#8217;m not [...]]]></description>
				<content:encoded><![CDATA[<p>When I started working as a web developer, <a href="http://www.php.org">PHP</a> was the first language I learned that was 100% web oriented.<br />
Back then I believe it was PHP3 or something like that. At the time, PHP was pretty new to the web, PERL was the main denominator.</p>
<p>PHP today is hated and loved, and I&#8217;m not going into that path here, I&#8217;m very programming language agnostic. My mantra is &#8220;use what&#8217;s best for the job&#8221;. However, back then PHP was getting lot of traction, mostly because it was very easy to work with and to setup/deploy. Nothing, even today, beats the LAMP stack.</p>
<p><span id="more-147"></span></p>
<p>However, with great power, comes great responsibility. And in the beginning PHP was like that cool friend you had when you were a teenager, fun, irresponsible, doing fart jokes and it was easy for us to get along. The thing is, PHP grew, it&#8217;s user base grew as well, and today PHP is no longer that C-glued scripts. PHP is being used on entreprise level, on high-scaled websites, it&#8217;s complexity is also much bigger. Now we have amazing frameworks like <a href="http://symfony.com/">Symfony</a>, <a href="http://laravel.com/">Laravel</a>, <a href="http://ellislab.com/codeigniter">Codeigniter</a>, <a href="http://kohanaframework.org/">Kohana</a>, <a href="http://www.yiiframework.com/">Yii</a>  and other.</p>
<p>These frameworks help you build better and faster websites, but they can be quit complex internaly. So we need tools that help us understand how they work, how we can improve our code optimisation and so on.</p>
<p>In this article I&#8217;m going to show you some techniques I use to debug and profile PHP code.</p>
<h3>Why var_dump(); sucks</h3>
<p>First, var_dump(); it&#8217;s a cool function, it allows you to print out an object/array/variable content. However it&#8217;s being wrongly used as a debugger and to test things out. It&#8217;s amazing the number of developers that rely solely on this function and others like &#8220;print&#8221; or &#8220;echo&#8221; to test their code.</p>
<p>Why it sucks? Because it takes something out of context. You will never know what things got triggered along the way that make that variable hold its content.</p>
<p>Say for example your have a variable called $foo, that keeps returning false, when it should be returning true.<br />
Using var_dump, you don&#8217;t get any solution to your problem, you only know what&#8217;s wrong, not how and why it went wrong. It&#8217;s like you are a detective and you know the victim is dead, but you don&#8217;t know why he&#8217;s dead.</p>
<p>You might say: <i>&#8220;well, I can just put a few prints in the lines above that variable where I think it might be changing it&#8221;</i>. Yes that might be true, but it&#8217;s still a trial and error thing. Catching bugs this way it&#8217;s a pain in the ass. </p>
<p>There&#8217;s a better way.</p>
<h3>Meet Xdebug</h3>
<p>What&#8217;s <a href="http://www.xdebug.org">Xdebug</a>? Xdebug is PHP debugger module, it allows you to step through your code and watch it in real time how your code is being processed by PHP interpret. With a debugger you are Neo from the Matrix, you can stop the time and see exactly how things work. How can you not want to be like that ?</p>
<p>By &#8220;things work&#8221;, I mean, you can literally see what function are being called, how and when  variables change their values and what caused that change. You can even change a variable content in real-time. Beat that var_dump().</p>
<p>You can specify at which lines you want Xdebug to stop the code so in you can inspect, or you can just type &#8220;xdebug_break();&#8221; in your code to emulate a breaking point.</p>
<p>Using Xdebug is even more fun when you realize that you can do it remotely, from your hosting server, as long as you have a local copy of your code files you can set up breakpoints remotely. </p>
<p>It still beats me why PHP developers don&#8217;t use Xdebug.</p>
<p>I love Xdebug so much, that I even built a Xdebug client standalone for the Mac called <a href="http://codebugapp.com">Codebug</a>. I created it because there weren&#8217;t real stable solution unless you wanted to use an IDE like PHPStorm or Netbeans, which in my case I didn&#8217;t. I&#8217;m in love with <a href="http://www.sublimetext.com/">Sublime Text</a>.<br />
But if you use any of these IDEs, they already include a Xdebug frontend. </p>
<p>To install Xdebug it&#8217;s very easy, just follow these instruction <a href="http://xdebug.org/docs/install">here</a>, or if you are using mac OSX with MAMP read it <a href="http://www.codebugapp.com/documentation/#a2">here</a>.</p>
<div id="attachment_151" class="wp-caption alignnone" style="width: 962px"><a href="http://www.henriquebarroso.com/wp-content/uploads/2013/01/09Debugging.png"><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/09Debugging.png" alt="Codebug - Xdebug frontend for mac" width="962" height="741" class="size-full wp-image-151" /></a><p class="wp-caption-text"><a href="http://codebugapp.com">Codebug</a> &#8211; Xdebug frontend for mac</p></div>
<p>If you use PHP as a professional, you need to have Xdebug installed. Trust me, you won&#8217;t go back to var_dump() anytime soon.</p>
<p>Also, you can use Xdebug to learn how some class or function works. It&#8217;s a good learning tool for code you don&#8217;t exactly know how it connects.</p>
<p>But Xdebug isn&#8217;t just about code debugging, it also let&#8217;s your profile your code.<br />
What profiling means is that, it allows you to see what parts of your code are using more memory, calls, and response time. This is a really useful add-on.</p>
<div id="attachment_161" class="wp-caption alignnone" style="width: 929px"><a href="http://www.henriquebarroso.com/wp-content/uploads/2013/01/example1.png"><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/example1.png" alt="Xdebug profiling" width="929" height="387" class="size-full wp-image-161" /></a><p class="wp-caption-text"><a href="http://kcachegrind.sourceforge.net/html/Home.html">KCachegrind</a> &#8211; Xdebug profiling</p></div>
<p>However, I can recommend something better for profiling.</p>
<h3>Say hello to XHProf</h3>
<p><a href="https://github.com/facebook/xhprof">XHProf</a> was developed by Facebook development team. So you can imagine the complexity that is Facebook, and why they build this.</p>
<p>What this module does is to tell you exactly what parts of your code are decreasing your application performance.<br />
Your page is taking 10 seconds to load and you don&#8217;t know why ? Try running it through XHProf.<br />
This is a must-have tool if you care about your application behaviour.</p>
<p>It highlights the most memory/time consuming functions or classes in a red colour, and what was the origin of the function call in yellow, so you a complete path on how to get to that code hog and fix it.</p>
<div id="attachment_165" class="wp-caption alignnone" style="width: 636px"><a href="http://www.henriquebarroso.com/wp-content/uploads/2013/01/image_4fdf0efe8b163.png"><img src="http://www.henriquebarroso.com/wp-content/uploads/2013/01/image_4fdf0efe8b163-636x310.png" alt="Xhprof" width="636" height="310" class="size-single-thumbnail wp-image-165" /></a><p class="wp-caption-text">Xhprof profiling image diagram</p></div>
<p>It&#8217;s very easy to setup and you can turn it on and off whenever you need.<br />
I don&#8217;t know of any other tool for PHP that works this great.</p>
<p>Again, I highly recommend it. It&#8217;s an amazing profiling tool.</p>
<h3>Conclusion</h3>
<p>These tools that I&#8217;ve shown you, are only PHP related, they won&#8217;t work with your javascript code, or you database queries. Some of these techniques I will write some other time.</p>
<p>Web development is getting more complex each day, and we need tools that free us from doing boring tasks and we need tools that, not only helps us, but that actually makes us better developers by approaching problems in a more efficient way.</p>
<p>I hope you learned something new from this, and that this might help you work better with PHP.<br />
If you have more suggestions or tools for PHP let me known on the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/php-debugging-and-profiling/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>My Top 10 Sublime Text Plugins</title>
		<link>http://www.henriquebarroso.com/my-top-10sublime-2-plugins/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-top-10sublime-2-plugins</link>
		<comments>http://www.henriquebarroso.com/my-top-10sublime-2-plugins/#comments</comments>
		<pubDate>Wed, 16 Jan 2013 21:17:25 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Sublime Text2]]></category>
		<category><![CDATA[Top10]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=91</guid>
		<description><![CDATA[I&#8217;ve known Sublime Text for a long time now, I remember testing it&#8217;s first public beta version around 2008/2009. I was impressed by the epic layout. But at the same time I was still too oriented towards IDEs, so I put it aside. Only too pick it up recently. I was blown away how the [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve known <a href="http://www.sublimetext.com/">Sublime Text</a> for a long time now, I remember testing it&#8217;s first public beta version around 2008/2009. I was impressed by the epic layout. But at the same time I was still too oriented towards IDEs, so I put it aside. Only too pick it up recently.</p>
<p>I was blown away how the community it&#8217;s so active and how extensible it is. I came from a VIM background, so I was a little reluctant to see if this would fit my needs. And it did, you can even simulate VIM by uncommenting just a few lines in the configuration.<br />
<span id="more-91"></span><br />
However, this post is not about Sublime Text itself, but the plugins I use and that I recommend if you are a web developer.</p>
<p><!-- 10 --><br />
<a href="http://wbond.net/sublime_packages/package_control"><br />
<h2>10. Package control</h2>
<p></a><br />
This is a must-have plugin. It lets you install, remove and manage your plugins directly from Sublime Text 2. I&#8217;d love to see this plugin installed by default on ST2. I can&#8217;t recommend enough you use it, it&#8217;s the apt-get or nmp packet manager for Sublime.<br />
After it&#8217;s installation all you need to do is to type <strong>shift + cmd + P</strong>, type &#8220;install&#8221; and ENTER.</p>
<p><!-- 9 --><br />
<a href="https://github.com/facelessuser/BracketHighlighter"><br />
<h2>9. Bracket Highlighter</h2>
<p></a><br />
Like the name states, it highlights the brackets, quotes and html tags. It&#8217;s a simple plugin, but helps a lot when working on big code files.</p>
<p><!-- 8 --><br />
<a href="https://github.com/spadgos/sublime-jsdocs"><br />
<h2>8. DocBlockr</h2>
<p></a><br />
One of the features I really missed from IDEs on ST2 was the ability to create PHPDoc style comments. This plugins does it, and not only it works with PHP, but it also supports Javascript, ActionScript, CoffeeScript, Java, Objective C, C and C++.</p>
<p><!-- 7 --><br />
<a href="https://github.com/titoBouzout/SideBarEnhancements"><br />
<h2>7. SideBar Enhancements</h2>
<p></a><br />
This plugin extends the sidebar menu, by adding lots of new and useful features like: Move to trash, open in browser, and even copy the content of a file as data:uri base64.</p>
<p><!-- 6 --><br />
<a href="http://wbond.net/sublime_packages/prefixr"><br />
<h2>6. Prefixr</h2>
<p></a><br />
It allows you to run <a href="http://prefixr.com/">Prefixr</a> on your CSS code. What it does, among other things, it helps get Cross-Browser CSS in place. So you just need to worry writing CSS3 code, and this plugin will do the rest.</p>
<p><!-- 5 --><br />
<a href="https://github.com/sergeche/emmet-sublime"><br />
<h2>5. Emmet</h2>
<p></a><br />
It&#8217;s a plugin based on the <a href="http://docs.emmet.io/">Emmet</a> standard. If you never heard of it and you code in HTML, this will  blow your mind. You can create complete layouts with just one line of code, press TAB and presto. Have a look a the official website. Highly recommend.</p>
<p><!-- 4 --><br />
<a href="https://github.com/kemayo/sublime-text-2-git/wiki"><br />
<h2>4. Git</h2>
<p></a><br />
<a href="http://en.wikipedia.org/wiki/Git_(software)"></a> Git is my favourite file version control system ever, and this plugin is a front-end for it. If you use Git on a daily basis this is a must-have. Very easy to work with, and after using it you rarely will go into the system console ever again to do common tasks.</p>
<p><!-- 3 --><br />
<a href="https://github.com/fbzhong/sublime-jslint"><br />
<h2>3. JSLint</h2>
<p></a><br />
<a href="http://www.jslint.com/">JSLint</a> it&#8217;s a Javascript code quality tool created by Douglas Crockford, an Javascript hardcore developer. This tool helps you know what parts of your code you need to change in order to have a better sane code. Until now, you could only do it online, but with this plugin you can do it directly on ST2. If you are serious about Javascript you need this.</p>
<p><!-- 2 --><br />
<a href="https://github.com/SublimeLinter/SublimeLinter"><br />
<h2>2. Sublime Linter</h2>
<p></a><br />
First off, you need this. This plugin is like a IDE itself, it finds errors in your code as you go. It supports dozens of languages, from PHP to Python, Java, etc..<br />
This plugin is not only recommend but it should be mandatory. </p>
<p><!-- 1 --><br />
<a href="https://github.com/Kronuz/SublimeCodeIntel"><br />
<h2>1. Sublime CodeIntel</h2>
<p></a><br />
This is my favourite plugin for ST2. This plugins brings a little of IDE functionality into ST2. This plugin reads all your code and is able to code-complete, jump into definitions and function call tooltips.<br />
Although sometimes looks a little buggy, it&#8217;s still worth having it around. It&#8217;s a huge time saver, especially when you are dealing with other&#8217;s people code.</p>
<p><!-- Bonus --><br />
<a href="https://github.com/daylerees/colour-schemes"><br />
<h2>0(bonus). Dayle Rees Themes</h2>
<p></a><br />
Even though ST2 comes with a beautiful package of themes, you might grow tired of it, so the Dayle Rees themes are an amazing beautiful eye-candy themes for ST2.</p>
<p>So I hope you find my top 10 ST2 plugins useful. Let me know if you use anything else  that you&#8217;d like to share in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/my-top-10sublime-2-plugins/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>Name Convention &#8211; A better approach</title>
		<link>http://www.henriquebarroso.com/name-convention-a-better-approach/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=name-convention-a-better-approach</link>
		<comments>http://www.henriquebarroso.com/name-convention-a-better-approach/#comments</comments>
		<pubDate>Wed, 07 Nov 2012 22:49:33 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Good Practices]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=70</guid>
		<description><![CDATA[If your read my previous post about Clean Code, this will fit right along. This post is about choosing the right and correctly variables/classes or functions names for your code. Picking up a good name convention in some cases eliminates the need for comments, because your code will explain what&#8217;s going on. So, how do [...]]]></description>
				<content:encoded><![CDATA[<p>If your read my <a href="http://www.henriquebarroso.com/the-secret-art-of-clean-code/">previous post</a> about <strong>Clean Code</strong>, this will fit right along.</p>
<p>This post is about choosing the right and correctly variables/classes or functions names for your code.<br />
Picking up a good name convention in some cases eliminates the need for comments, because your code will explain what&#8217;s going on.<br />
<span id="more-70"></span><br />
So, how do you choose a good variable naming convention ?</p>
<h3>Use self-explanatory names</h3>
<p>Look at the following code</p>
<pre class="brush: php; title: Wrong; notranslate">
foreach ($x as $c) {
	if($c-&gt;engine == 0) {
		...
	}
}
</pre>
<p>Now look at this</p>
<pre class="brush: php; title: Correct; notranslate">
foreach ($cars as $car) {
	if($car-&gt;engine == ENGINE_BROKEN) {
		...
	}
}
</pre>
<p>The problem with the first is that, it lacks context, you may know what $x or $c contain, but a year from now or some other developer has no clue just by looking at that. You you see the &#8220;engine&#8221; there, but is it a boat, a plane, no&#8230;it&#8217;s wrongly used variables names (no pun intended).</p>
<p>In the second one, it&#8217;s obviously more verbose, but if your read it to yourself it&#8217;s almost english-readable. You can easily read it like <em>&#8220;For each car in my cars check if the engine is broken and something about it&#8221;</em> while the first one it&#8217;s pretty much cryptic.</p>
<p>So, avoid using single letters in your classes and code. They should only exists in very small pieces for code/functions.</p>
<h3>Avoid long variables names</h3>
<p>I see this countless times, sometimes developers get carried and create long useless, painful to read variables names.</p>
<p>Bad:</p>
<pre class="brush: php; title: Wrong; notranslate">
$firstNameWithCapitalizedWord = something();

$emailForUserWhoForgotHisPassword = something();
</pre>
<p>Better:</p>
<pre class="brush: php; title: Correct; notranslate">
$firstName = something();

$userEmail = something();
</pre>
<p>The first example is horrific and I see it every now and then, long variable names are very hard to read and sometimes they include gratuitous context. You should never have more than three words as variable name.</p>
<h3>Don&#8217;t use prepended junk</h3>
<p>This is a classic mistake when it comes to variables.<br />
you should never use prepended names for your variables. Here&#8217;s an example:</p>
<pre class="brush: php; title: Wrong; notranslate">
$Foo_firstName = ...

$MyCompany_totalEmployees = ...
</pre>
<p>Imagine this all over the code and it can be quite lame. Some will argue that this helps them identify code they created when working on somebody else&#8217;s code.<br />
I say this doesn&#8217;t help on anything, as developers we have better tools to identify our code from the rest without having to add junk to our code.</p>
<p>Also, this is pretty bad if you are using and IDE, imagine typing $my and hit tab, all the variables will be listed, while if you used $firstName it should be a lot fast for the IDE and you.</p>
<h3>Don&#8217;t be funny</h3>
<p>Sometimes we are in a good mood and we reflect that in our code, but don&#8217;t be the funny variable name guy</p>
<pre class="brush: php; title: Wrong; notranslate">
$OMFG = 12;
$ForeverAlone = true;
</pre>
<p>While this may be funny to read, it&#8217;s not really that funny when a year from now you don&#8217;t have a clue what this does, worse, your co-works have no clue what it represents.</p>
<h3>Don&#8217;t be redundant</h3>
<p>This one is also a classic mistake.</p>
<pre class="brush: php; title: Wrong; notranslate">
$stringName = &quot;Joe Doe&quot;; // It's a name, so obviously it will be a string, not a boolean duh!
$intAge = 28; // Ages are always numeric..no need for int there
$peopleArray = array(); // This one is even more self explanatory 
</pre>
<p>I&#8217;m using PHP here, since it&#8217;s a dynamic language it&#8217;s easier to follow on this trap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/name-convention-a-better-approach/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The &#8220;Secret&#8221; Art of Clean Code</title>
		<link>http://www.henriquebarroso.com/the-secret-art-of-clean-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-secret-art-of-clean-code</link>
		<comments>http://www.henriquebarroso.com/the-secret-art-of-clean-code/#comments</comments>
		<pubDate>Tue, 06 Nov 2012 09:15:00 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Good Practices]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=28</guid>
		<description><![CDATA[It shouldn&#8217;t be a secret, in fact I don&#8217;t want it to be a secret. This so called &#8220;art&#8221; can define the future of your application, the sanity of your team, or worse, the future of your company. Am I exaggerating ? Not really. If you are a programmer with a few years of experience [...]]]></description>
				<content:encoded><![CDATA[<p>It shouldn&#8217;t be a secret, in fact I don&#8217;t want it to be a secret.</p>
<p>This so called &#8220;art&#8221; can define the future of your application, the sanity of your team, or worse, the future of your company.</p>
<p>Am I exaggerating ?</p>
<p>Not really. If you are a programmer with a few years of experience you&#8217;ve probably already seen this countless times, hell, you&#8217;ve probably done this already which is the so called messy, undocumented, untested and hard to read code.<br />
<span id="more-28"></span><br />
Here&#8217;s a fictional story that I know lots of you can relate.</p>
<h3>Meet Foo Inc.</h3>
<p>The Foo Inc. company is about to release this new amazing app.</p>
<p>In the beginning everything was fine and dandy, the software appears to run, so the managers were happy. The developers know they could&#8217;ve do much better job than this but it&#8217;s to late to refactor, that would mean to create everything from scratch. Yes, they didn&#8217;t follow good development methodologies because they thought it was too boring and it wasn&#8217;t really that necessary.</p>
<p>And over time, their code is getting bigger, fattier, ugly and buggier, to the point that when a new change it&#8217;s needed a new bug pops out from some other place. So they quickly patch it, to get it over with it, and fingers are crossed.</p>
<p>So, the next time a new feature it&#8217;s added, they go back to that glue-patched-cryptic code and add more spaghetti code. At this stage some of them think it doesn&#8217;t even matter anymore, they just want to add that functionality to that beast and get the hell out.</p>
<p>Developers get demoralised, and eventually some of them quit. So the company has to replace them. They hire new people. But since this app code is uncommented, patched to the bones and cryptic, the new developers have hard time understanding it, so they talk to the managers and decide that they need to start over, a clean slate.</p>
<p>Now you can see where this is heading. There&#8217;s a new buzz in the company, and every developer wants to be part of this new &#8220;version&#8221;. It&#8217;s a breeze of fresh air, it&#8217;s like starting over. But it&#8217;s getting worse, because now they have two versions to maintain and nobody want&#8217;s to be part of the &#8220;old&#8221; code team.</p>
<p>So this company is spending more money, more resources into something that should be done right from the start if they enforced their developers into using good coding practices.</p>
<p>To some companies, this could be their end, the first version of the software could be so bad that they don&#8217;t have any more money to hire new developers or create a new version from scratch, because they got not clients for the fact that the first version had so many bugs that nobody bought it.</p>
<h3>So&#8230;what&#8217;s clean code ?</h3>
<p>Clean code it&#8217;s when you read it and you know the developer cared.<br />
When it runs all the tests, it&#8217;s well documented, meaningful function, classes and variable names are used, it avoids code duplication. It&#8217;s when software methodologies are in place. In the end, clean code it&#8217;s when you learn how it works by just looking at it.</p>
<p>This is not something you learn from day one, it&#8217;s something your learn over the years. It requires practice and good taste, and this it&#8217;s why it&#8217;s called &#8220;Art&#8221;.</p>
<p>Explain to your team and your company why this is so important, why it&#8217;s important to use good coding practices and extend the deadline if needed in order to make your code better.</p>
<p>I&#8217;ve read this in the &#8220;Clean Code&#8221; book once:</p>
<blockquote><p>Leave the campground cleaner than you found it</p></blockquote>
<p>It really represents the Art Of Clean code mantra.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/the-secret-art-of-clean-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zero</title>
		<link>http://www.henriquebarroso.com/zero/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=zero</link>
		<comments>http://www.henriquebarroso.com/zero/#comments</comments>
		<pubDate>Mon, 05 Nov 2012 21:40:23 +0000</pubDate>
		<dc:creator>Henrique B.</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.henriquebarroso.com/?p=26</guid>
		<description><![CDATA[This is my zero post. The first post out of (hopefully) many to come. This is a clean sheet, a green field or maybe a blank canvas, ready for me to fill it up. It&#8217;s where I will post my ideas, opinions on software development, programming techniques and basically everything I feel it fits the [...]]]></description>
				<content:encoded><![CDATA[<p>This is my zero post.<br />
The first post out of (hopefully) many to come.<br />
This is a clean sheet, a green field or maybe a blank canvas, ready for me to fill it up.</p>
<p>It&#8217;s where I will post my ideas, opinions on software development, programming techniques and basically everything I feel it fits the topic.<br />
<span id="more-26"></span><br />
Some of you will agree, some of you won&#8217;t, other won&#8217;t even know I exist.</p>
<p>In the end it really doesn&#8217;t matter as long as I, somehow, help some folk out there, bring some sort of discussion to the table.</p>
<p>I hope I teach something good and useful for any of you, as I hope to learn from everyone else too.</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.henriquebarroso.com/zero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
