<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>open core</title>
	<link href="http://blog.rogeriopvl.com/atom.xml" rel="self"/>
	<link href="http://blog.rogeriopvl.com/"/>
	<updated>2015-01-18T18:18:33+00:00</updated>
	<id>http://blog.rogeriopvl.com/</id>
	<author>
		<name>Rog&#x00E9;rio Vicente</name>
		<email>noreply@rogeriopvl.com</email>
	</author>
	
	<entry>
		<title>Simple XMLHttpRequest with Fetch</title>
		<link href="http://blog.rogeriopvl.com/archives/simple-xmlhttprequests-with-window.fetch"/>
		<updated>2015-01-15T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/simple-xmlhttprequests-with-window.fetch</id>
		<content type="html">&lt;p&gt;This week, the new &lt;a href=&quot;https://fetch.spec.whatwg.org&quot;&gt;Fetch standard&lt;/a&gt; has landed in Chrome Canary (version 42). This is one of the specs I’ve been waiting for. It really simplifies &lt;a href=&quot;https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest&quot;&gt;XMLHttpRequests&lt;/a&gt; with a cleaner interface, and comes with built-in promises.&lt;/p&gt;

&lt;p&gt;So to give you some perspective, here’s how you currently do an XMLHttpRequest:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;XMLHttpRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;responseText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;GET&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;http://someendpoint.com/api/stuff&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;req&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is a very simple example, and as you know, it can get much more verbose if you start handling error cases.&lt;/p&gt;

&lt;p&gt;And now, this is the same request made with &lt;code&gt;window.fetch()&lt;/code&gt; but with bonus error handling:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;http://someendpoint.com/api/stuff&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In my opinion this is much simpler. And it’s also customizable:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fetch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;http://someendpoint.com/api/stuff&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;POST&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;headers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;s1&quot;&gt;&amp;#39;Accept&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;application/json&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;s1&quot;&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;application/json&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;someField&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1234&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;anotherField&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;foobar&amp;#39;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;reponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}).&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Have a look at &lt;a href=&quot;https://fetch.spec.whatwg.org&quot;&gt;the spec&lt;/a&gt;, there are much more features included.&lt;/p&gt;

&lt;h3 id=&quot;what-about-other-browsers-support&quot;&gt;What about other browsers support?&lt;/h3&gt;

&lt;p&gt;Github has released a &lt;a href=&quot;https://github.com/github/fetch&quot;&gt;Fetch polyfill&lt;/a&gt; that works perfectly well with all browsers (IE 9+ included), just make sure you also install &lt;code&gt;es6-promise&lt;/code&gt; polyfill for promise support in older browsers.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Check out Github pull requests</title>
		<link href="http://blog.rogeriopvl.com/archives/check-out-github-pull-requests"/>
		<updated>2014-08-01T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/check-out-github-pull-requests</id>
		<content type="html">&lt;p&gt;This is a quick way to checkout Github pull requests into a local branch so you can test if everything is ok.&lt;/p&gt;

&lt;p&gt;Just create this simple function in your &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt; file:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; checkout-pr&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    git fetch origin refs/pull/&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;/head:PR&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After saving, just reload your shell and the &lt;code&gt;checkout-pr&lt;/code&gt; command should be available.&lt;/p&gt;

&lt;p&gt;To use it just enter a project’s folder and type:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;checkout-pr 13&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will access your project’s origin, fetch the content of the pull request with ID 13 and save it in a local branch called &lt;code&gt;PR13&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now you can checkout the &lt;code&gt;PR13&lt;/code&gt; branch and evaluate the changes made.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Yeoman generator for Ink</title>
		<link href="http://blog.rogeriopvl.com/archives/generator-ink"/>
		<updated>2013-12-17T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/generator-ink</id>
		<content type="html">&lt;p&gt;Probably everybody knows now that SAPO’s &lt;a href=&quot;http://ink.sapo.pt&quot;&gt;Ink framework&lt;/a&gt; is an awesome alternative to Bootstrap. And there’s also this great scaffolding tool called &lt;a href=&quot;http://yeoman.io&quot;&gt;Yeoman&lt;/a&gt;, that if you don’t know, you should really check it out. The same also applies to Ink.&lt;/p&gt;

&lt;p&gt;About two months ago, during my short travel to London to attend the &lt;a href=&quot;http://greatbritishnodeconf.co.uk&quot;&gt;The Great British Node Conf&lt;/a&gt;, I developed a Yeoman generator for Ink, called &lt;a href=&quot;http://rogeriopvl.github.io/generator-ink&quot;&gt;generator-ink&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This generator creates a ready-to-use website layout using Ink. You can even choose from 11 available layouts (more coming soon), and start hacking right away with the basic dependencies already in place.&lt;/p&gt;

&lt;p&gt;To install it , just type on your terminal (make sure you already have Yeoman installed first):&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm install -g generator-ink&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now create a folder for your project and &lt;code&gt;cd&lt;/code&gt; into it:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir my_awesome_project &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;my_awesome_project&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And now to start &lt;code&gt;generator-ink&lt;/code&gt; just run:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;yo ink&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If everything went well, you’ll be greeted with the layout choice menu:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/rogeriopvl/generator-ink/master/screenshots/generator-ink.png&quot; alt=&quot;generator-ink layout choice menu&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now it’s just a matter of choosing the layout that most adjusts to your needs, and hack it.&lt;/p&gt;

&lt;p&gt;Need more site pages? No problem, there’s a sub-generator for that. Imagine we need to create an article page. Piece of cake! Just type:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;yo ink:page article-page article.html&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You just need to know the name of the layout (you can check all available layouts &lt;a href=&quot;http://rogeriopvl.github.io/generator-ink&quot;&gt;here&lt;/a&gt;), give it a name, and BAM! It’s there!&lt;/p&gt;

&lt;p&gt;You can also contribute with your own layouts! Just make a &lt;a href=&quot;http://github.com/rogeriopvl/generator-ink&quot;&gt;pull request on Github&lt;/a&gt; and I’ll be glad to accept it!&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Playing RTMP streaming on Mac with VLC and rtmpdump</title>
		<link href="http://blog.rogeriopvl.com/archives/playing-rtmp-streaming-on-mac-with-vlc-and-rtmpdump"/>
		<updated>2013-02-21T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/playing-rtmp-streaming-on-mac-with-vlc-and-rtmpdump</id>
		<content type="html">&lt;p&gt;VLC is a great piece of software, but currently lacks RTMP support. The good news is that there might be some &lt;a href=&quot;http://forum.videolan.org/viewtopic.php?f=7&amp;amp;t=97803&quot;&gt;RTMP support planned for the 2.1 release&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Meanwhile, to fix this, here’s a simple workaround using &lt;a href=&quot;http://rtmpdump.mplayerhq.hu&quot;&gt;rtmpdump&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First make sure you have rtmpdump installed. If not, you can install it using the &lt;a href=&quot;http://mxcl.github.com/homebrew&quot;&gt;Homebrew&lt;/a&gt; package manager:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;brew install rtmpdump&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now make sure you have installed &lt;a href=&quot;http://www.videolan.org/vlc/download-macosx.htm[0]: http://forum.videolan.org/viewtopic.php?f=7&amp;amp;t=97803&quot;&gt;VLC&lt;/a&gt; and use the following command to play the RTMP streaming:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rtmpdump -r rtmp://foobar/live/stream --quiet &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; /Applications/VLC.app/Contents/MacOS/VLC -&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will open VLC with a file named &lt;code&gt;fd://0&lt;/code&gt; on the playlist. Just click it and the streaming should be working.&lt;/p&gt;

&lt;p&gt;You can create a &lt;code&gt;vlc&lt;/code&gt; alias to make the command a lot simpler. Just add this in your &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt; or &lt;code&gt;.profile&lt;/code&gt; (choose with one applies) and restart the terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;vlc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/Applications/VLC.app/Contents/MacOS/VLC&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you don’t like to mess around with long terminal commands, here’s a bash function that makes it simpler:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;k&quot;&gt;function&lt;/span&gt; rtmp_open&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        rtmpdump -r &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; --quiet &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt; /Applications/VLC.app/Contents/MacOS/VLC fd://0 --playlist-autostart
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Just copy paste this into your &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt; or &lt;code&gt;.profile&lt;/code&gt; (choose which one applies), and restart the terminal.&lt;/p&gt;

&lt;p&gt;I had to use &lt;code&gt;fd://0&lt;/code&gt; instead of &lt;code&gt;-&lt;/code&gt; to refer to &lt;code&gt;stdin&lt;/code&gt; due to a &lt;a href=&quot;https://trac.videolan.org/vlc/ticket/7272&quot;&gt;bug in VLC&lt;/a&gt; that ignores the &lt;code&gt;--playlist-autostart&lt;/code&gt; when using &lt;code&gt;-&lt;/code&gt; as input.&lt;/p&gt;

&lt;p&gt;Now to run this handy function just type the name and the URL of the RTMP stream you want to play:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rtmp_open rtmp://foobar/live/stream&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And that’s it. Enjoy :)&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Raspberry Pi fun</title>
		<link href="http://blog.rogeriopvl.com/archives/raspberry-pi-fun"/>
		<updated>2012-08-09T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/raspberry-pi-fun</id>
		<content type="html">&lt;p&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/2012/08/rbpi_logo.png&quot; alt=&quot;Raspberry Pi logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I got my &lt;a href=&quot;http://raspberrypi.org&quot;&gt;Raspberry Pi&lt;/a&gt; three days ago, and I’ve been so busy “playing” with it, that I’m only writing this post now.&lt;/p&gt;

&lt;p&gt;If you’re living under a rock, let me tell you that the Raspberry Pi is an awesome credit-card sized computer that costs $35. But the Raspberry Pi website puts it better:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yep, that’s right: kids. And guess what? All the grown ups are loving it :)&lt;/p&gt;

&lt;p&gt;It’s mind-blowing the tons of cool things you can do with this little computer. The first thing I did with it was to install &lt;a href=&quot;http://raspbian.org&quot;&gt;Raspbian&lt;/a&gt; Wheezy image on the SD card (Debian for the RPi, available in the &lt;a href=&quot;http://raspberrypi.org/downloads&quot;&gt;Downloads section of the RPi website&lt;/a&gt;) and put a &lt;a href=&quot;http://nodejs.org&quot;&gt;Node&lt;/a&gt; server running on it. The performance is pretty acceptable.&lt;/p&gt;

&lt;p&gt;And there’s also the community around the RPi. All kinds of people from experienced programmers to beginners are showing off everyday new things that can be done. It’s a nice way to learn about the lower level stuff that goes on in your computer, and you can use it to control other stuff too, like robots, leds etc.&lt;/p&gt;

&lt;p&gt;I’ll be writing here some of my experiences with the RPi as I get to know it better.&lt;/p&gt;

&lt;p&gt;Meanwhile, here’s a photo of the unboxing:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/2012/08/raspberrypi_unbox.jpg&quot; alt=&quot;Raspberry Pi unboxing&quot; title=&quot;Raspberry Pi unboxing&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And a photo of the RPi running headless and being configured through SSH:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/2012/08/raspberrypi_running.jpg&quot; alt=&quot;Raspberry Pi up and running&quot; title=&quot;Raspberry Pi up and running&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I bought it from &lt;a href=&quot;http://inmotion.pt&quot;&gt;InMotion&lt;/a&gt;, a portuguese online store. So if you are in Portugal, I highly recommend buying your Rpi from this store. It costs about 42€ and the service is very fast (ordered on a thursday and had it on monday).&lt;/p&gt;

&lt;p&gt;So go get one, and feed your inner geek :)&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Nodo v0.2.0 released</title>
		<link href="http://blog.rogeriopvl.com/archives/nodo-v0.2.0-released"/>
		<updated>2012-05-29T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/nodo-v0.2.0-released</id>
		<content type="html">&lt;p&gt;A new version of &lt;a href=&quot;http://rogeriopvl.github.com/nodo&quot;&gt;Nodo&lt;/a&gt; is out. Version v0.2.0 has the following features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New actions &lt;code&gt;star&lt;/code&gt; and &lt;code&gt;unstar&lt;/code&gt; that makes possible to mark ou unmark a task as important.&lt;/li&gt;
  &lt;li&gt;UI improvements and some bug fixes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This new version is now available on NPM. To upgrade use:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;npm udpate -g nodo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Please report any issues you find on the &lt;a href=&quot;http://github.com/rogeriopvl/nodo/issues&quot;&gt;github issues page&lt;/a&gt;.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Nodo, the simple command line task manager</title>
		<link href="http://blog.rogeriopvl.com/archives/nodo:-the-simple-command-line-task-manager"/>
		<updated>2012-05-18T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/nodo:-the-simple-command-line-task-manager</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;http://rogeriopvl.github.com/nodo&quot;&gt;Nodo&lt;/a&gt; is a command line task manager, and I love it! Why? Mainly because I developed it, second, it does exactly what I needed from a TODO app: it’s simple, easy and of course, it’s on the command line.&lt;/p&gt;

&lt;p&gt;I spend most of the time on the command line (I’m even writing this post on it with &lt;a href=&quot;http://vim.org&quot;&gt;Vim&lt;/a&gt;) so it comes natural the fact that I needed to find a task management application that has a &lt;a href=&quot;http://en.wikipedia.org/wiki/Command-line_interface&quot;&gt;CLI&lt;/a&gt;, avoiding the constant switch from keyboard to mouse and vice-versa. But still, I used &lt;a href=&quot;http://wunderlist.com&quot;&gt;Wunderlist&lt;/a&gt;, an awesome mac/windows/iphone/android TODO app, that was lacking such interface.&lt;/p&gt;

&lt;h4 id=&quot;but-there-are-already-command-line-task-managers&quot;&gt;But there are already command line task managers!&lt;/h4&gt;

&lt;p&gt;Yes it’s true. I’m not going to mention them all, but let’s just say that none of them met my criteria. Some where too simple, some were just too complex (like TODO.txt) with tons of commands and options. Also, none of them supported my current Wunderlist database.&lt;/p&gt;

&lt;p&gt;So I developed one task manager that suited my needs.&lt;/p&gt;

&lt;h4 id=&quot;in-nodejs-but-i-thought-that-nodejs-was-only-good-at-x&quot;&gt;In Node.js? But I thought that Node.js was only good at X&lt;/h4&gt;

&lt;p&gt;Well, it turns out that Node is actually pretty good at allot of stuff. Including command line apps. But I have to agree that it’s not the best choice because there are no advantages in having non-blocking IO in this kind of app. But since I’ve been learning allot of Node lately, I really wanted to put in practice all my newly aquired skills. Also, &lt;a href=&quot;http://npm.com&quot;&gt;NPM&lt;/a&gt; is a great package manager, and it’s ridiculously easy to publish new packages with it, not mentioning that it’s very interesting the fact that it’s entirely written in &lt;a href=&quot;http://couchdb.com&quot;&gt;CouchDB&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;ok-so-how-does-nodo-work&quot;&gt;Ok, so how does Nodo work?&lt;/h4&gt;

&lt;p&gt;It’s pretty simple. It has an NPM package, so you can install it with the &lt;code&gt;npm&lt;/code&gt; command, just like this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm install -g nodo&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;A few seconds later, Nodo will be installed on your machine.&lt;/p&gt;

&lt;p&gt;After install, Nodo comes with a default list called “inbox”. This list is where you should put all the tasks that you are not sure in which list to put them. So, to add a task to the inbox list just type the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nodo add inbox go shopping&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Later, you decide to organize your tasks, so let’s create a list called “home” to contain all the home related tasks:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nodo add list home&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And now, you can move your shopping task to this new list. Assuming that the shopping task has id 3:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nodo move &lt;span class=&quot;m&quot;&gt;3&lt;/span&gt; home&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After you go shopping you can mark this task as done:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nodo &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; 3&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This is just the Nodo basics. For the full usage instructions I recommend watching the screencast below, or visiting the &lt;a href=&quot;http://rogeriopvl.github.com/nodo&quot;&gt;Nodo page on Github&lt;/a&gt;.&lt;/p&gt;

&lt;div id=&quot;video_embed&quot; style=&quot;text-align: center;&quot;&gt;
    &lt;iframe src=&quot;http://player.vimeo.com/video/42330826?title=0&amp;amp;byline=0&amp;amp;portrait=0&quot; width=&quot;600&quot; height=&quot;337&quot; frameborder=&quot;0&quot;&gt; &lt;/iframe&gt;
&lt;/div&gt;

&lt;p&gt;Currently Nodo does not support adding/editing task notes, or setting a task as important, but these are all just features that are coming in the near future. Feel free to suggest features and/or fixes.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>On using mac instead of linux ...</title>
		<link href="http://blog.rogeriopvl.com/archives/on-using-mac-instead-of-linux"/>
		<updated>2012-04-20T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/on-using-mac-instead-of-linux</id>
		<content type="html">&lt;p&gt;This is a very common and constant discussion at my workplace. And don’t get me wrong, I love linux. But &lt;a href=&quot;http://en.wikipedia.org/wiki/Jamie_Zawinski&quot;&gt;Jamie Zawinski&lt;/a&gt;  says it in way that is very similar to what I feel about it:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I use a Mac instead of Linux on the desktop for a reason: because I think that the design and consistency that Apple’s UI brings is extremely valuable. I don’t buy computers based on how fast they are, I buy them based on how easy it is to get things done with them, and Apple is the hands-down winner on this pretty much across the board. (Oh, also because I want my audio card to work, but that’s neither here nor there.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This quote is taken from a post in his blog where he talks about why he prefers to use Safari instead of Firefox on his mac, and you can read it entirely &lt;a href=&quot;http://www.jwz.org/blog/2012/04/why-i-use-safari-instead-of-firefox/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Having fun developing useless apps</title>
		<link href="http://blog.rogeriopvl.com/archives/having-fun-developing-useless-apps"/>
		<updated>2012-03-13T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/having-fun-developing-useless-apps</id>
		<content type="html">&lt;p&gt;I always thought that the first time I got on the &lt;a href=&quot;http://news.ycombinator.com&quot;&gt;Hacker News&lt;/a&gt; and &lt;a href=&quot;http://reddit.com/r/programming&quot;&gt;Proggit&lt;/a&gt; front-pages would be with some awesome and complex project. I was wrong.&lt;/p&gt;

&lt;h3 id=&quot;part-i---like-a-boss&quot;&gt;Part I - Like A Boss&lt;/h3&gt;

&lt;p&gt;On 25th November, while browsing the web, I found a funny project developed by &lt;a href=&quot;http://zachholman.com&quot;&gt;Zach Holman&lt;/a&gt; called &lt;a href=&quot;http://fuckyeah.herokuapp.com&quot;&gt;Fuck Yeah&lt;/a&gt;. This was a simple API developed in &lt;a href=&quot;http://nodejs.org&quot;&gt;Node.js&lt;/a&gt; that received a piece of text, searched Google Images for that piece of text, and added that text along with a “Fuck Yeah!” to the first image found.&lt;/p&gt;

&lt;p&gt;I found the project to be pretty cool, and since I got a little rusty with nodejs, I decided to fork the code and make a new version of the API, this time called &lt;a href=&quot;http://likeaboss.herokuapp.com&quot;&gt;Like a Boss&lt;/a&gt;. You can pretty much guess what it does. You can check out the code at &lt;a href=&quot;http://github.com/rogeriopvl/likeaboss&quot;&gt;Github&lt;/a&gt; by the way.&lt;/p&gt;

&lt;p&gt;Since I had some spare time, I decided to go further and build a website that presented the generated images in a more good looking way. And &lt;a href=&quot;http://likeaboss.herokuapp.com&quot;&gt;here’s the result&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/hacklikeaboss.jpg&quot; alt=&quot;Hack Like A Boss&quot; title=&quot;Hack Like A Boss&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I decided to post the “Like a Boss” website to Hacker News. It got upvoted somehow, and BAM! Hacker News front-page. In 2 hours the website had about 2000 pageviews. This was cool, but not without some problems showing up that had to be solved in order to keep the code from crashing the server. Still, &lt;a href=&quot;http://heroku.com&quot;&gt;Heroku&lt;/a&gt;, the cloud application platform I used to host my nodejs app, handled all the traffic pretty well with only one web worker (included with the free plan).&lt;/p&gt;

&lt;p&gt;After about 3 hours, the Hacker News post dropped from the front-page, and traffic almost vanished.&lt;/p&gt;

&lt;h3 id=&quot;part-ii---http-cats-api&quot;&gt;Part II - HTTP Cats API&lt;/h3&gt;

&lt;p&gt;On December 14th, again, while browsing the web, someone posted on Hacker News an awesome &lt;a href=&quot;http://www.flickr.com/photos/girliemac/sets/72157628409467125/&quot;&gt;Flickr set of cat pictures&lt;/a&gt; authored by &lt;a href=&quot;http://twitter.com/girlie_mac&quot;&gt;Tomomi Imura&lt;/a&gt; with each cat posing accordingly to a HTTP Status Code. These pictures ended up being a &lt;a href=&quot;http://girliemac.com/blog/2011/12/18/the-day-i-seized-the-interweb-http-status-cats/&quot;&gt;huge success&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I instantly thought about how awesome would be to have those cat images show up when an error occured on a web-server. I fired up &lt;code&gt;vim&lt;/code&gt; and hacked some nodejs code to serve those images through a simple API. After some minutes, the &lt;a href=&quot;http://httpcats.herokuapp.com&quot;&gt;HTTP Cats API&lt;/a&gt; was born. I pushed it to Heroku, and it was rocking. I sent the link to a couple of friends, we all laughed for a while and I thought that was it.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/httpcats_404.jpg&quot; alt=&quot;HTTP Cat 404 Not Found&quot; title=&quot;404 Not Found&quot; /&gt;&lt;/p&gt;

&lt;p&gt;After a while, I posted the API link to Hacker News and Proggit. The Hacker News post never got voted, the Proggit one got allot of upvotes, and soon I was on Proggit front-page. An avalanche of traffic ensued.&lt;/p&gt;

&lt;p&gt;The post got duplicated on Hacker News, and this time it got allot of upvotes (probably a user with more influence). This was when all hell broke loose. Not only it got on the first-page it was also ranked in 2nd place.&lt;/p&gt;

&lt;p&gt;The results where: on the first day I got 19.412 unique visitors. The second day, 21.764 unique visitors. The two days together summed up 255.034 pageviews. These values are amazing for a simple app that serves cat images. Actually, while I write this post, which is 2 months later, it still has around 100 unique visitors a day. And I’m not even counting direct API calls, just the index page visits.&lt;/p&gt;

&lt;h3 id=&quot;so-what&quot;&gt;So what?&lt;/h3&gt;

&lt;p&gt;Yeah, I know these web applications are pretty much useless, but I had allot of fun hacking them and watching the traffic hit the sites. And of course, it doesn’t really matter the fact that they are useless, as long as you have fun, learn and make other people smile, that’s what really matters.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Nginx and the HTTP OPTIONS method</title>
		<link href="http://blog.rogeriopvl.com/archives/nginx-and-the-http-options-method"/>
		<updated>2012-01-27T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/nginx-and-the-http-options-method</id>
		<content type="html">&lt;p&gt;The current version of &lt;a href=&quot;http://nginx.com&quot;&gt;Nginx&lt;/a&gt; (1.0.x) doesn’t seem to support HTTP &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html&quot;&gt;OPTIONS&lt;/a&gt; requests. It returns &lt;code&gt;405 &quot;Method Not Allowed&quot;&lt;/code&gt; whenever this request is sent.&lt;/p&gt;

&lt;p&gt;Here’s an example using &lt;a href=&quot;http://curl.haxx.se&quot;&gt;curl&lt;/a&gt; from the terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; curl -X OPTIONS busydudes.com

&lt;span class=&quot;go&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;405 Not Allowed&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;body bgcolor=&amp;quot;white&amp;quot;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;center&amp;gt;&amp;lt;h1&amp;gt;405 Not Allowed&amp;lt;/h1&amp;gt;&amp;lt;/center&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;hr&amp;gt;&amp;lt;center&amp;gt;nginx/1.0.11&amp;lt;/center&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;HTTP OPTIONS requests are essential if you’re doing &lt;a href=&quot;https://developer.mozilla.org/En/HTTP_access_control&quot;&gt;cross-site HTTP requests&lt;/a&gt; and need to obtain the server authorization for the URI where the request originated from.&lt;/p&gt;

&lt;p&gt;To solve this problem I found two solutions.&lt;/p&gt;

&lt;h4 id=&quot;solution-1-not-recommended&quot;&gt;Solution 1 (not recommended)&lt;/h4&gt;

&lt;p&gt;If you’re using another web server behind Nginx and want the request to be handled by that web server, you can trick Nginx into believing that the HTTP status 405 is actually a 200 OK status, so it will just delegate the request to your webserver using the &lt;code&gt;proxy_pass&lt;/code&gt; directive. Just keep in mind that this is an ugly fix. Edit your &lt;code&gt;nginx.conf&lt;/code&gt; file and add the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;error_page&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;405&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;@405&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;@405&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;root&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;http://localhost:8080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4 id=&quot;solution-2&quot;&gt;Solution 2&lt;/h4&gt;

&lt;p&gt;If you’re just using Nginx as your main server, or just want to obtain the authorization response for the origin domain, then this is definitely the best solution. Edit your &lt;code&gt;nginx.conf&lt;/code&gt; file and add the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-nginx&quot; data-lang=&quot;nginx&quot;&gt;&lt;span class=&quot;k&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kn&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$request_method&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;OPTIONS&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access-Control-Allow-Origin&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;http://example.com&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access-Control-Allow-Methods&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;GET,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;OPTIONS&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access-Control-Allow-Headers&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;Authorization&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Access-Control-Allow-Credentials&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Content-Length&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;add_header&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Content-Type&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;text/plain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kn&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should edit the &lt;code&gt;http://example.com&lt;/code&gt; to match the origin URI you want to allow. If you want to allow any origin just use the &lt;code&gt;*&lt;/code&gt; wildcard.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Fixing libdlna formula in Homebrew</title>
		<link href="http://blog.rogeriopvl.com/archives/fixing-libdlna-formula-in-homebrew"/>
		<updated>2011-12-06T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/fixing-libdlna-formula-in-homebrew</id>
		<content type="html">&lt;div class=&quot;update&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; This fix has now been added to the Homebrew package.&lt;/div&gt;
&lt;p&gt;Recently I got an &lt;a href=&quot;/img/xbox_xmas.jpg&quot; rel=&quot;shadowbox&quot;&gt;XBox 360 for xmas&lt;/a&gt;, and started looking for ways to stream the music in my Macbook Air to it. I found some interesting commercial software to do it, but stumbled upon an open-source linux tool called &lt;a href=&quot;http://ushare.geexbox.org&quot;&gt;uShare&lt;/a&gt; that was also available through the &lt;a href=&quot;http://mxcl.github.com/homebrew&quot;&gt;Homebrew&lt;/a&gt; package manager.&lt;/p&gt;

&lt;p&gt;Doing a &lt;code&gt;brew install ushare&lt;/code&gt; immediately stopped due to a &lt;code&gt;make install&lt;/code&gt; error of the &lt;code&gt;libdlna&lt;/code&gt; package, a dependency of uShare, that is required for compatibility with Playstation 3. Here’s the error I got:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;profiles.c: In function &amp;#39;av_profile_get_codecs&amp;#39;:&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;profiles.c:208: error: &amp;#39;CODEC_TYPE_AUDIO&amp;#39; undeclared (first use in this function)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;profiles.c:208: error: (Each undeclared identifier is reported only once&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;profiles.c:208: error: for each function it appears in.)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;profiles.c:214: error: &amp;#39;CODEC_TYPE_VIDEO&amp;#39; undeclared (first use in this function)&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;make[1]: *** [profiles.o] Error 1&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;make[1]: *** Waiting for unfinished jobs....&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;make: *** [install] Error 2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This error happens for newer versions of the &lt;code&gt;libavformat&lt;/code&gt; that no longer have the symbols &lt;code&gt;CODEC_TYPE_AUDIO&lt;/code&gt; and &lt;code&gt;CODEC_TYPE_VIDEO&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So, in order to fix the formula you need to apply this patch to the source code of &lt;code&gt;libdlna&lt;/code&gt;. You can find the content of this patch in a &lt;a href=&quot;https://gist.github.com/1434147&quot;&gt;github gist&lt;/a&gt;. But to successfully install the Homebrew formula you have to edit the formula file and include this patch in the &lt;code&gt;patches&lt;/code&gt; method:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew edit libdnla&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then find the patches method (on line 10) and change the code inside to the following:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;patches&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# fixes ffmpeg locations&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;https://gist.github.com/raw/356431/fbddfeee80d9224f6c67886b119fbd813f3c0ffa/libdlna.patch&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# fixes missing symbols for newer versions of libavformat&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;https://gist.github.com/raw/1434147/293ec631536bc34a6e2dd49bb0f30c86f02b1107/libdlna023_fix_symbols.patch&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Basically, instead of returning just the patch that was already in the formula as a string, I’m now returning an array with that patch, and my patch.&lt;/p&gt;

&lt;p&gt;Now just save the file and:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew install libdlna&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And then resume the &lt;code&gt;ushare&lt;/code&gt; formula install:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew install ushare&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That’s it. It should now install without a hassle.&lt;/p&gt;

&lt;p&gt;I submitted this change to the Homebrew project with a &lt;a href=&quot;https://github.com/mxcl/homebrew/pull/8981&quot;&gt;pull request&lt;/a&gt;, so anytime soon you won’t be needing this workaround :)&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Hacker News Stack</title>
		<link href="http://blog.rogeriopvl.com/archives/hacker-news-stack"/>
		<updated>2011-05-15T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/hacker-news-stack</id>
		<content type="html">&lt;p style=&quot;text-align:center;&quot;&gt;&lt;img src=&quot;/img/hn128.png&quot; alt=&quot;Hacker News Stack logo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://chrome.google.com/webstore/detail/jcdfcpjmfpbnimkdackbcmdgdpoeklio&quot; title=&quot;Hacker News Stack at Chrome Webstore&quot;&gt;Hacker News Stack&lt;/a&gt; is a Chrome extension that improves the readability of the items in the &lt;a href=&quot;http://news.ycombinator.com&quot; title=&quot;Hacker News website&quot;&gt;Hacker News&lt;/a&gt; website, removing the items that were clicked (read).&lt;/p&gt;

&lt;p&gt;This extension is a page action, that acts on the website. As the user clicks on an item link, the item ID is parsed and stored in the &lt;a href=&quot;http://diveintohtml5.org/storage.html&quot; title=&quot;HTML5 Storage&quot;&gt;HTML5 storage database&lt;/a&gt; (&lt;code&gt;localStorage&lt;/code&gt;). Automatically this item will be moved to the bottom of the website (marked as read).&lt;/p&gt;

&lt;p&gt;This was a frustrating extension to build because of the fact that the HTML source in the Hacker News website &lt;a href=&quot;view-source:http://news.ycombinator.com/&quot; title=&quot;View page source (link for Chrome only)&quot;&gt;is a total mess&lt;/a&gt;. Parsing it turned out to be an unreliable task, not only because the site layout is done with tables, but also because of the lack of semantics in the markup.&lt;/p&gt;

&lt;p&gt;Anyway, it seems to be working fine (with some minor bugs being taken care off). I’m currently using it and it’s making a big difference making me focus only on the news that I didn’t clicked yet.&lt;/p&gt;

&lt;p style=&quot;text-align:center;&quot;&gt;&lt;a style=&quot;border-bottom:0;&quot; href=&quot;/img/hnstack1.png&quot; rel=&quot;shadowbox[hnstack]&quot;&gt;&lt;img style=&quot;display:inline;&quot; src=&quot;/img/hnstack1_small.png&quot; alt=&quot;Hacker News Stack screenshot 1&quot; /&gt;&lt;/a&gt;
&lt;a style=&quot;border-bottom:0;&quot; href=&quot;/img/hnstack2.png&quot; rel=&quot;shadowbox[hnstack]&quot;&gt;&lt;img style=&quot;display:inline;&quot; src=&quot;/img/hnstack2_small.png&quot; alt=&quot;Hacker News Stack screenshot 2&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can install it from the &lt;a href=&quot;https://chrome.google.com/webstore/detail/jcdfcpjmfpbnimkdackbcmdgdpoeklio&quot; title=&quot;Hacker News Stack at Chrome Webstore&quot;&gt;Chrome Webstore&lt;/a&gt; or check out the source code at &lt;a href=&quot;https://github.com/rogeriopvl/hnstack&quot; title=&quot;Hacker News Stack at Github&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>hashr 1.0 for Firefox</title>
		<link href="http://blog.rogeriopvl.com/archives/hashr-1.0-for-firefox"/>
		<updated>2011-04-11T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/hashr-1.0-for-firefox</id>
		<content type="html">&lt;p&gt;The hashr Firefox extension has reached version 1.0 with the launch of Firefox 4.&lt;/p&gt;

&lt;p&gt;This new version brings some UI improvements. Some users were complaining about the interface being clunky, it turns out that this was specially true in Firefox for Windows and Linux. I was only testing it on the Mac version, where it looked allot better. So I gave it a slightly better UI and made it consistent between all operating systems where Firefox runs.&lt;/p&gt;

&lt;p&gt;There’s also a new toolbar button that is added by default on installation. It does the same thing as the addon-bar (aka &lt;a href=&quot;http://support.mozilla.com/en-US/kb/what-happened-status-bar&quot;&gt;old status-bar&lt;/a&gt;), it shows/hides the hashr toolbar. It makes hashr more visible to new users after instalation, but it can be removed if you only wish to use the addon-bar button.&lt;/p&gt;

&lt;p&gt;A new version of the website is being (slowly) developed, and also a new version of the &lt;a href=&quot;https://chrome.google.com/webstore/detail/dladaomdbdobknaihmoieedebgcdgbkb&quot;&gt;Google Chrome extension&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This new version is already available on the &lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/hashr/&quot;&gt;Mozilla Addons&lt;/a&gt; website.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Codebits 2010 Project - Chatstorm</title>
		<link href="http://blog.rogeriopvl.com/archives/codebits-2010-project-chatstorm"/>
		<updated>2010-11-16T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/codebits-2010-project-chatstorm</id>
		<content type="html">&lt;p&gt;Still recovering from &lt;a href=&quot;http://codebits.eu&quot; title=&quot;Codebits website&quot;&gt;Codebits 2010&lt;/a&gt;. Congratulations to &lt;a href=&quot;http://sapo.pt&quot; title=&quot;Sapo web portal&quot;&gt;Sapo&lt;/a&gt; for putting up another awesome edition of this event. Three exausting days of coding, talks, and all kinds of crazy events (yes I’m looking at you &lt;a href=&quot;http://videos.sapo.pt/AmiZBtwvUoUDsc30irCP&quot; title=&quot;Nuclear Tacos Video at Codebits 2010&quot;&gt;Nuclear Tacos&lt;/a&gt;)!&lt;/p&gt;

&lt;p&gt;Just like last year, this year, along with my teammates, I had a mission. To create a project and get it ready by the end of the 48 hour hackathon (actually we spent the first 24 hours attending some talks, playing some video-games and trying to &lt;a rel=&quot;shadowbox&quot; href=&quot;http://farm2.static.flickr.com/1415/5179956615_448e5e1555_b.jpg&quot;&gt;decide what to do&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Once more this mission was accomplished. The project is called “Chatstorm”.&lt;/p&gt;

&lt;p&gt;Chatstorm is an online brainstorming web application that uses a real-time chat to share ideas and automatically fetch and suggest web-content related with those ideas. Technically speaking it was developed in &lt;a href=&quot;http://nodejs.org&quot; title=&quot;Node.js website&quot;&gt;Node.js&lt;/a&gt; (Server-side Javascript) and &lt;a href=&quot;http://socket.io&quot; title=&quot;Socket.io website&quot;&gt;WebSockets&lt;/a&gt; (Client-side). It was allot of fun to work with these new technologies and to watch the final result.&lt;/p&gt;

&lt;p&gt;Unfortunately, Chatstorm won’t be available online for now due to it’s very immature state regarding security, but I’ll leave you some screenshots:&lt;/p&gt;

&lt;p&gt;{.post-image} &lt;img src=&quot;http://farm2.static.flickr.com/1265/5180366162_dc81694d1d_b.jpg&quot; alt=&quot;Chatstorm screenshot 1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;{.post-image} &lt;img src=&quot;http://farm2.static.flickr.com/1327/5180366456_3eb5d590cb_b.jpg&quot; alt=&quot;Chatstorm screenshot 2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;{.post-image} &lt;img src=&quot;http://farm5.static.flickr.com/4127/5179766421_f23aca9151_b.jpg&quot; alt=&quot;Chatstorm screenshot 3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Currently Chatstorm uses &lt;a href=&quot;http://fotos.sapo.pt&quot; title=&quot;Sapo Fotos website&quot;&gt;Sapo Fotos&lt;/a&gt;, &lt;a href=&quot;http://videos.sapo.pt&quot; title=&quot;Sapo Vídeos website&quot;&gt;Sapo Vídeos&lt;/a&gt; and &lt;a href=&quot;http://twitter.com&quot; title=&quot;Twitter website&quot;&gt;Twitter&lt;/a&gt; as sources of information suggestion. But more sources can be easily added just like plugins.&lt;/p&gt;

&lt;p&gt;In the end, we didn’t managed to get into the top 10 projects, but we got much more positive feedback than last year. Still it was worth it. Mission accomplished and now back to real life, counting the days to Codebits 2011.&lt;/p&gt;

&lt;p&gt;Check my Codebits 2010 photos at Flickr: &lt;a href=&quot;http://www.flickr.com/photos/rogeriopvl/sets/72157625396464122/&quot; title=&quot;Codebits 2010 Flickr Gallery&quot;&gt;Gallery&lt;/a&gt; or &lt;a href=&quot;http://www.flickr.com/photos/rogeriopvl/sets/72157625396464122/show&quot; title=&quot;Codebits 2010 Flickr Slideshow&quot;&gt;Slideshow&lt;/a&gt;.&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>PHP mcrypt in Snow Leopard with Homebrew</title>
		<link href="http://blog.rogeriopvl.com/archives/php-mcrypt-in-snow-leopard-with-homebrew"/>
		<updated>2010-08-16T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/php-mcrypt-in-snow-leopard-with-homebrew</id>
		<content type="html">&lt;div class=&quot;update&quot;&gt;
    &lt;strong&gt;Update:&lt;/strong&gt; This also works on OS X Lion as it is. But just for the sake of correctness you can replace every occurrence of &lt;code&gt;10.6&lt;/code&gt; to &lt;code&gt;10.7&lt;/code&gt; in &lt;code&gt;MACOSX_DEPLOYMENT_TARGET&lt;/code&gt;.
&lt;/div&gt;

&lt;p&gt;If you are using &lt;a href=&quot;http://mxcl.github.com/homebrew/&quot;&gt;Homebrew&lt;/a&gt; as your OSX package manager, chances are that you are using the default PHP that comes with Snow Leopard. This PHP installation does not have the &lt;code&gt;mcrypt&lt;/code&gt; extension, so if you are trying to use something like PHPMyAdmin, you’ll get an error message saying that &lt;code&gt;mcrypt&lt;/code&gt; is not enabled in &lt;code&gt;php.ini&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I googled the answer and found little info about it. I found &lt;a href=&quot;http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/&quot;&gt;this post&lt;/a&gt; that it’s pretty complete but it compiles &lt;code&gt;mcrypt&lt;/code&gt; manually, which is not Homebrew way of doing it. So the purpose of this post is to gather the info for those who are using Homebrew and the default PHP.&lt;/p&gt;

&lt;p&gt;First you have to install &lt;code&gt;mcrypt&lt;/code&gt; with Homebrew, but the current Formula for &lt;code&gt;mcrypt&lt;/code&gt; is not suitable for those on Snow Leopard, so let’s change it. Open the Formula in your favorite code editor:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo vim /usr/local/Library/Formula/mcrypt.rb&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Note that you only need the &lt;code&gt;sudo&lt;/code&gt; if you did not &lt;code&gt;chown&lt;/code&gt; your &lt;code&gt;/usr/local&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Now lets change the &lt;code&gt;install&lt;/code&gt; method to this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;install&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=&amp;#39;-O3 -fno-common -arch i386 -arch x86_64&amp;#39; LDFLAGS=&amp;#39;-O3 -arch i386 -arch x86_64&amp;#39; CXXFLAGS=&amp;#39;-O3 -fno-common -arch i386 -arch x86_64&amp;#39; ./configure --disable-dependency-tracking --prefix=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prefix&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; --mandir=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;man&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;make -j6&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;system&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;make install&amp;quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Save and run it:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; brew install mcrypt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Just wait some seconds and you’re done with this step. After this you might want to undo the changes in the Formula file to avoid git conflicts when updating Homebrew.&lt;/p&gt;

&lt;p&gt;Second, you have to download the PHP 5.3 source to compile the &lt;code&gt;mcrypt&lt;/code&gt; PHP extension and install it. You can download the source from &lt;a href=&quot;http://us.php.net/get/php-5.3.0.tar.gz/from/a/mirror&quot;&gt;this link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Extract the tarball to a directory of your choice, it can be &lt;code&gt;~/Desktop&lt;/code&gt; and then:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/Desktop/php-5.3.0/ext/mcrypt&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And type:&lt;/p&gt;

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

&lt;p&gt;Again wait some seconds and when its complete type:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;MACOSX_DEPLOYMENT_TARGET&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;10.6 &lt;span class=&quot;nv&quot;&gt;CFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;-O3 -fno-common -arch i386 -arch x86_64&amp;#39;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;LDFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;-O3 -arch i386 -arch x86_64&amp;#39;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;CXXFLAGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;-O3 -fno-common -arch i386 -arch x86_64&amp;#39;&lt;/span&gt; ./configure --with-php-config&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/Developer/SDKs/MacOSX10.6.sdk/usr/bin/php-config&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; make -j6&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;sudo make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Allot will happen and hopefully you won’t see any errors.&lt;/p&gt;

&lt;p&gt;Now finally you just need to edit the &lt;code&gt;/etc/php.ini&lt;/code&gt; file to enable the extension you just compiled and installed. If you don’t have a &lt;code&gt;/etc/php.ini&lt;/code&gt; file you need to copy the default config file:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo cp /etc/php.ini.default /etc/php.ini&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;And let’s edit it:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; sudo vim /etc/php.ini&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Find the &lt;code&gt;enable_dl&lt;/code&gt; setting and remove the &lt;code&gt;;&lt;/code&gt; in front of the line (if any) and change it to &lt;code&gt;On&lt;/code&gt;. It should look like this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;enable_dl = On&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now find the &lt;code&gt;Dynamic Extensions&lt;/code&gt; section of the file and add this line at the end of that section:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;extension=mcrypt.so&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Restart the Apache server and you’re done. Happy coding!&lt;/p&gt;

</content>
	</entry>
	
	<entry>
		<title>Test Driven Development with PHP</title>
		<link href="http://blog.rogeriopvl.com/archives/test-driven-development-with-php"/>
		<updated>2010-07-18T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/test-driven-development-with-php</id>
		<content type="html">&lt;p&gt;This week I had the oportunity to give an introduction talk about Test Driven Development with PHP at &lt;a href=&quot;http://www.dri.pt&quot;&gt;DRI&lt;/a&gt; Code Sessions. I’m no TDD expert, but I’ve been using this methodology on some of my personal projects, and this was a great way to consolidate what I’ve been learning and also share and discuss it with other programmers.&lt;/p&gt;

&lt;p&gt;The slides are very concise, as they had the sole purpose of guiding my speech. But I believe that they give, along with the code examples, a good notion of what TDD is about.&lt;/p&gt;

&lt;p&gt;You can find the &lt;a href=&quot;http://github.com/rogeriopvl/dri_codesessions_tdd&quot;&gt;code examples&lt;/a&gt; on Github and also the slides in PDF and ODP formats.&lt;/p&gt;

&lt;script src=&quot;http://speakerdeck.com/embed/4f4d3b4fb3a003002202e4f2.js&quot;&gt; &lt;/script&gt;

</content>
	</entry>
	
	<entry>
		<title>Moved from Wordpress to Jekyll</title>
		<link href="http://blog.rogeriopvl.com/archives/moved-from-wordpress-to-jekyll"/>
		<updated>2010-06-27T00:00:00+01:00</updated>
		<id>http://blog.rogeriopvl.com/archives/moved-from-wordpress-to-jekyll</id>
		<content type="html">&lt;p&gt;I’ve been wanting to leave the &lt;a href=&quot;http://wordpress.com&quot; title=&quot;Wordpress website&quot;&gt;Wordpress&lt;/a&gt; platform for a while now, and last week I finally managed to start rebuilding this blog with &lt;a href=&quot;http://jekyllrb.com&quot; title=&quot;Jekyll website&quot;&gt;Jekyll&lt;/a&gt; - a blog-aware, static site generator in Ruby.&lt;/p&gt;

&lt;p&gt;Don’t get me wrong, I still think that Wordpress is a great blogging/CMS platform. But for me and the purpose of this blog, it has become a little overkill.&lt;/p&gt;

&lt;p&gt;Jekyll is my ideal way to maintain a blog. I get to use my favorite daily work tools (&lt;a href=&quot;http://git-scm.com&quot; title=&quot;Git website&quot;&gt;Git&lt;/a&gt; and &lt;a href=&quot;http://macromates.com&quot; title=&quot;Textmate website&quot;&gt;Textmate&lt;/a&gt;) and in terms of performance, static files are just great, no need to spend precious VPS resources. Oh, did I mention that this blog is now running on a VPS? That’s right, &lt;a href=&quot;http://prgmr.com&quot; title=&quot;Prgmr website&quot;&gt;prgmr.com&lt;/a&gt; powered. I’m gradually moving all content in the Dreamhost account to the VPS.&lt;/p&gt;

&lt;p&gt;Regarding the migration, it went almost perfect except for the feed. Feed subscribers may notice some weird behavior, like sudden unread posts showing up that aren’t new at all and stuff like that. Things will get stable with new posts.&lt;/p&gt;

&lt;p&gt;The blog design has also changed from a modified &lt;a href=&quot;http://wordpress.org/extend/themes/simplicitybright&quot; title=&quot;Simplicity Bright theme&quot;&gt;Wordpress template&lt;/a&gt; to something built from scratch. This new design keeps things simple and readable, just the way I like. So no fancy stuff, just plain focus on content. And it’s still being improved along with the markup, so there will be some changes in the next few days.&lt;/p&gt;

&lt;div class=&quot;update&quot;&gt;
  &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; I’m now using the &lt;a href=&quot;http://code.google.com/apis/webfonts/&quot; title=&quot;Google Webfonts API&quot;&gt;Google Webfonts API&lt;/a&gt; to serve the some beautiful fonts. The header title font is &lt;a href=&quot;http://code.google.com/webfonts/family?family=Lobster&quot; title=&quot;Lobster font&quot;&gt;Lobster&lt;/a&gt;, the body font is &lt;a href=&quot;http://code.google.com/webfonts/family?family=Droid+Sans&quot; title=&quot;Droid Sans font&quot;&gt;Droid Sans&lt;/a&gt; and the code font is &lt;a href=&quot;http://code.google.com/webfonts/family?family=Droid+Sans+Mono&quot; title=&quot;Droid Sans Mono font&quot;&gt;Droid Sans Mono&lt;/a&gt;. If your browser does not support Webfonts the CSS will fallback to Georgia, the original font of this blog.&lt;/p&gt;
&lt;/div&gt;

</content>
	</entry>
	
	<entry>
		<title>Using Things with Dropbox</title>
		<link href="http://blog.rogeriopvl.com/archives/using-things-with-dropbox"/>
		<updated>2010-03-28T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/using-things-with-dropbox</id>
		<content type="html">&lt;p&gt;&lt;a href=&quot;http://culturedcode.com/things/&quot;&gt;Things&lt;/a&gt; is probably one of the best task management applications for Mac that I&#39;ve come across. And the only that I didn&#39;t completely forgot after 2-3 days. The iPhone/iPod app is just the cherry on top of the cake. You can sync with your Mac app and all.&lt;/p&gt;
&lt;p&gt;The one feature Things is missing (besides being Mac only), is sync between different computers. I constantly use 2 Macs (personal and work) so this was a major turn off. But that&#39;s where &lt;a href=&quot;https://www.dropbox.com/home&quot;&gt;Dropbox&lt;/a&gt; kicks in and saves the day.&lt;/p&gt;
&lt;p&gt;Although not very explicit, Things has the option to select the location of your tasks database. So it&#39;s pretty much obvious: save the database in a Dropbox folder, configure all your Things apps to use the new database location and you&#39;re done.&lt;/p&gt;
&lt;p&gt;This is where you&#39;re Things database is stored:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;go&quot;&gt;~/Library/Application Support/Cultured Code/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Just copy the &lt;code&gt;Things/&lt;/code&gt; folder that lives in the path above to your Dropbox and then open the Things app pressing simultaneously the option key (alt). A popup will show up asking you to choose the library (database) location:&lt;/p&gt;
&lt;p style=&quot;text-align: center;&quot;&gt;&lt;a rel=&quot;shadowbox&quot; href=&quot;http://blog.rogeriopvl.com/img/2010/03/ChooseALibraryDialog.jpg&quot;&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/2010/03/ChooseALibraryDialog-300x117.jpg&quot; alt=&quot;Things - Choose A Library Dialog&quot; title=&quot;Things - Choose A Library Dialog&quot; width=&quot;300&quot; height=&quot;117&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now choose the Things folder in your Dropbox and that&#39;s it. Repeat this step for every application that you use on a different Mac, and you&#39;re ready to kick some serious ass at &lt;a href=&quot;http://en.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;Getting Things Done&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can find this info about selecting Things library/database on the &lt;a href=&quot;http://culturedcode.com/things/wiki/index.php/Syncing_Things_on_multiple_Macs_%28FAQ%29&quot;&gt;Cultured Code wiki&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;update&quot;&gt;
&lt;strong&gt;Update:&lt;/strong&gt; One thing I forgot to mention is that this approach I described does not work with multiple Things applications running at the same time in different computers. Because Things only reloads the &lt;code&gt;database.xml&lt;/code&gt; file on startup, if you don&#39;t close the application, it won&#39;t be aware of the new changes made to the database, and will eventually save the current state over the changes you&#39;ve made in other instances of the application.
&lt;/div&gt;
</content>
	</entry>
	
	<entry>
		<title>hashr for Google Chrome</title>
		<link href="http://blog.rogeriopvl.com/archives/hashr-for-google-chrome"/>
		<updated>2010-01-19T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/hashr-for-google-chrome</id>
		<content type="html">&lt;p&gt;Yesterday I&#39;ve released &lt;a href=&quot;http://rogeriopvl.com/hashr&quot;&gt;hashr&lt;/a&gt; extension for &lt;a href=&quot;http://chrome.google.com&quot;&gt;Google Chrome&lt;/a&gt;. This is the first version, and it was just to try out the extensions platform for Google&#39;s browser.&lt;/p&gt;
&lt;p&gt;So basically this extension does the same as the &lt;a href=&quot;https://addons.mozilla.org/en-US//addon/8539/&quot;&gt;Firefox addon&lt;/a&gt;, and the &lt;a href=&quot;http://rogeriopvl.com/hashr&quot;&gt;website&lt;/a&gt;, but in Chrome. Here&#39;s a screenshot of it in action:&lt;/p&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;&lt;a rel=&quot;shadowbox&quot; href=&quot;http://blog.rogeriopvl.com/img/2010/01/screen1.png&quot;&gt;&lt;img src=&quot;http://blog.rogeriopvl.com/img/2010/01/screen1-300x176.png&quot; alt=&quot;hashr chrome extension&quot; title=&quot;hashr for chrome&quot; width=&quot;300&quot; height=&quot;176&quot; class=&quot;aligncenter size-medium wp-image-736&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can find more screenshots, info and install it at the &lt;a href=&quot;https://chrome.google.com/extensions/detail/dladaomdbdobknaihmoieedebgcdgbkb&quot;&gt;Extension Gallery page&lt;/a&gt;. Or you can just check out the source at &lt;a href=&quot;http://github.com/rogeriopvl/hashr&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Tinyscrobbler</title>
		<link href="http://blog.rogeriopvl.com/archives/tinyscrobbler"/>
		<updated>2010-01-17T00:00:00+00:00</updated>
		<id>http://blog.rogeriopvl.com/archives/tinyscrobbler</id>
		<content type="html">&lt;p&gt;On my spare time I&#39;ve been learning the &lt;a href=&quot;http://www.ruby-lang.org&quot;&gt;Ruby&lt;/a&gt; language. And &lt;a href=&quot;http://github.com/rogeriopvl/tinyscrobbler&quot;&gt;Tinyscrobbler&lt;/a&gt; is the first result.&lt;/p&gt;
&lt;p&gt;Tinyscrobbler is a lightweight &lt;a href=&quot;http://last.fm&quot;&gt;Last.fm&lt;/a&gt; scrobbler library. It can be used to implement the track scrobbling feature in a ruby player app.&lt;/p&gt;
&lt;p&gt;You can find the source (GitHub) &lt;a href=&quot;http://github.com/rogeriopvl/tinyscrobbler&quot;&gt;here&lt;/a&gt; and install the ruby gem from &lt;a href=&quot;http://gemcutter.org/gems/tinyscrobbler&quot;&gt;Gemcutter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you opt to install from Gemcutter, you need to add it to your gem sources. Just type the following in your terminal (depending on your system you might need to execute these commands with &lt;code&gt;sudo&lt;/code&gt;):&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; gem sources -a http://gemcutter.org&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This will add gemcutter to your gem sources. Finally to install the gem just type:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$&lt;/span&gt; gem install tinyscrobbler&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Tinyscrobbler contains a helper class to read the audio files metadata, but for now it only supports &lt;code&gt;.mp3&lt;/code&gt; files. I&#39;ll be working on extending the support to other file formats like &lt;code&gt;.ogg&lt;/code&gt;, &lt;code&gt;.mp4a&lt;/code&gt; and &lt;code&gt;.wma&lt;/code&gt;.&lt;/p&gt;
</content>
	</entry>
	
</feed>