<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0">

<channel>
	<title>open core</title>
	
	<link>http://blog.rogeriopvl.com</link>
	<description>I like my coffee black, just like my macbook...</description>
	<lastBuildDate>Thu, 01 Oct 2009 00:11:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/rogeriopvl" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Playing with Twitter Stream API and Text-to-Speech</title>
		<link>http://blog.rogeriopvl.com/archives/playing-with-twitter-stream-api-and-text-to-speech</link>
		<comments>http://blog.rogeriopvl.com/archives/playing-with-twitter-stream-api-and-text-to-speech#comments</comments>
		<pubDate>Thu, 01 Oct 2009 00:03:02 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[stream]]></category>
		<category><![CDATA[text-to-speech]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=662</guid>
		<description><![CDATA[There&#8217;s a new Twitter API in town: The Twitter Stream API. But before you get all excited building a new twitter stream client, it&#8217;s important for you to know that this is in alpha version for now.
Since I wanted to test this new API and didn&#8217;t knew how to test it, I decided to do [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a new Twitter API in town: <a href="http://apiwiki.twitter.com/Streaming-API-Documentation">The Twitter Stream API</a>. But before you get all excited building a new twitter stream client, it&#8217;s important for you to know that this is in alpha version for now.</p>
<p>Since I wanted to test this new API and didn&#8217;t knew how to test it, I decided to do something silly. I wandered how it would be like to have someone read me in realtime all the tweets about a given keyword. This is the part where the Mac OS X built-in text-to-speech comes in.</p>
<p>The result was a PHP script that called the OS X <code>"say"</code> command to read the realtime Twitter stream.</p>
<p>The code is very simple:</p>
<pre class="code">
&lt;?php
$username = 'TWITTER_USER';
$password = 'TWITTER_PASSWORD';
$keyword = 'twitter';

$fp = fopen("http://$username:$password@stream.twitter.com/1/statuses/filter.json?track=$keyword", 'r');

while($data = fgets($fp))
{
	$res = json_decode($data, true);

	$user = $res['user']['screen_name'];
	$tweet = $res['text'];

	echo ("$user says: $tweet");
	exec (escapeshellcmd("say $user says: $tweet"));
}

fclose($fp);
?&gt;
</pre>
<p>Note the <code>escapeshellcmd</code> function that saves you from being owned in case someone &#8220;accidently&#8221;  tweets something like <code>";rm -rf ~/"</code>.</p>
<p>You can just run this script in terminal, but first change the username and password to match your twitter account, and keyword to something you want to search.</p>
<p>Now you can annoy everyone at your workplace, with a voice reading out loud all your (not so) interesting tweets.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/playing-with-twitter-stream-api-and-text-to-speech/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macports and PHP 5.3</title>
		<link>http://blog.rogeriopvl.com/archives/macports-and-php-5-3</link>
		<comments>http://blog.rogeriopvl.com/archives/macports-and-php-5-3#comments</comments>
		<pubDate>Thu, 17 Sep 2009 20:37:28 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=655</guid>
		<description><![CDATA[I&#8217;ve currently noticed that after updating to PHP 5.3 on macports, the php-cli (command line executable) was giving me some warnings with no sense because I had all the mentioned libraries installed:

PHP Warning:  Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve currently noticed that after updating to PHP 5.3 on <a href="http://www.macports.org/">macports</a>, the php-cli (command line executable) was giving me some warnings with no sense because I had all the mentioned libraries installed:</p>
<pre class="code">
PHP Warning:  Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './gd.so' - dlopen(./gd.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mbstring.so' - dlopen(./mbstring.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mcrypt.so' - dlopen(./mcrypt.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mysql.so' - dlopen(./mysql.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './mysqli.so' - dlopen(./mysqli.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './pdo_mysql.so' - dlopen(./pdo_mysql.so, 9): image not found in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './zip.so' - dlopen(./zip.so, 9): image not found in Unknown on line 0
</pre>
<p>This seems to be a very common problem after the update. It occurs because most of the configurations in <code>/opt/local/etc/php.ini</code> are now obsolete with PHP 5.3.</p>
<p>So if your update went well, you should have two samples of <code>php.ini</code> in the mentioned folder. One for production and the other for development. To fix this problem just rename you current <code>php.ini</code> file to something else, and then rename one of the samples to <code>php.ini</code>. Restart apache and voilá. PHP cli is back with no warnings and all the installed libraries available.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/macports-and-php-5-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating hashr to work on Firefox 3.5</title>
		<link>http://blog.rogeriopvl.com/archives/updating-hashr-to-work-on-firefox-3-5</link>
		<comments>http://blog.rogeriopvl.com/archives/updating-hashr-to-work-on-firefox-3-5#comments</comments>
		<pubDate>Fri, 24 Jul 2009 21:19:33 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[add-on]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hashr]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=647</guid>
		<description><![CDATA[I got an email today from a hashr user complaining that the add-on was not working on Firefox 3.5. I had noticed it a few days ago, but completely forgot about it.
I&#8217;m currently updating the add-on to 3.5, improving the user interface and maybe add some new feature. But for now if you wish to [...]]]></description>
			<content:encoded><![CDATA[<p>I got an email today from a <a href="http://rogeriopvl.com/hashr">hashr</a> user complaining that the <a href="https://addons.mozilla.org/en-US/firefox/addon/8539">add-on</a> was not working on Firefox 3.5. I had noticed it a few days ago, but completely forgot about it.</p>
<p>I&#8217;m currently updating the add-on to 3.5, improving the user interface and maybe add some new feature. But for now if you wish to use the extension with Firefox 3.5 you can use a little hack that works with no problems.</p>
<p>Just locate your Firefox profile folder, and then open the <code>extensions</code> folder inside it. There will be one folder with the word &#8220;hashr&#8221; in the name. Open it an edit the file <code>install.rdf</code>.</p>
<p>Inside the file locate the following lines: </p>
<pre class="code">
&lt;em:minVersion&gt;1.5&lt;/em:minVersion&gt;
&lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;
</pre>
<p>And change it to: </p>
<pre class="code">
&lt;em:minVersion&gt;1.5&lt;/em:minVersion&gt;
&lt;em:maxVersion&gt;3.5.*&lt;/em:maxVersion&gt;
</pre>
<p>Save the file and restart Firefox. It should now be working perfectly. If not, check the add-ons manager to see if it&#8217;s disabled.</p>
<p><strong>Edit: </strong>Mozilla has finally approved the new version of hashr, so this hack is no longer needed. You can find the addon here: <a href="https://addons.mozilla.org/en-US/firefox/addon/8539">https://addons.mozilla.org/en-US/firefox/addon/8539</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/updating-hashr-to-work-on-firefox-3-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change ls terminal colors in OS X Leopard</title>
		<link>http://blog.rogeriopvl.com/archives/change-ls-terminal-colors-in-os-x-leopard</link>
		<comments>http://blog.rogeriopvl.com/archives/change-ls-terminal-colors-in-os-x-leopard#comments</comments>
		<pubDate>Sun, 12 Jul 2009 22:49:17 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=643</guid>
		<description><![CDATA[If you use the terminal in OS X allot, you have probably noticed that the ls command has no colors. You can activate the colors by adding the following to your ~/.profile:
alias ls='ls -G'
Or you can even choose a better way. Adding the following to your ~/.profile:
export CLICOLOR=1
Now you just need to restart your terminal, [...]]]></description>
			<content:encoded><![CDATA[<p>If you use the terminal in OS X allot, you have probably noticed that the <code>ls</code> command has no colors. You can activate the colors by adding the following to your <code>~/.profile</code>:</p>
<pre class="code">alias ls='ls -G'</pre>
<p>Or you can even choose a better way. Adding the following to your <code>~/.profile</code>:</p>
<pre class="code">export CLICOLOR=1</pre>
<p>Now you just need to restart your terminal, and you have a all nice and shiny <code>ls</code> output.</p>
<p>The problem is&#8230; if you use a dark background, like any other sane person. The dark blue coloring the directories names is simply impossible to read.</p>
<p>To change that color you just need to add another line in your <code>~/.profile</code> file:</p>
<pre class="code">export LSCOLORS=gxfxcxdxbxegedabagacad</pre>
<p>What&#8217;s with the DNA chain? Well, it&#8217;s just some crazy way to configure the <code>ls</code> output color. You can find the corresponding color to every character on the <code>ls</code> man pages. Just to keep it simple, that combo turns the directory names to cyan, so that they become readable on top of dark backgrounds.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/change-ls-terminal-colors-in-os-x-leopard/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apple keyboard</title>
		<link>http://blog.rogeriopvl.com/archives/apple-keyboard</link>
		<comments>http://blog.rogeriopvl.com/archives/apple-keyboard#comments</comments>
		<pubDate>Wed, 10 Jun 2009 20:23:33 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[keyboard]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=630</guid>
		<description><![CDATA[
After of some weeks flirting with the Apple keyboard, today I finally bought it. I&#8217;m writing  this post with it. And I can only say that this is the best keyboard one can have. It&#8217;s very slim and the typing is smooth, actually is pretty much the same as the new macbook keyboard.
I bought [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img src="http://blog.rogeriopvl.com/wp-content/uploads/apple_keyboard.jpg" alt="apple usb keyboard" width="450" /></p>
<p>After of some weeks flirting with the <a href="http://www.apple.com/keyboard">Apple keyboard</a>, today I finally bought it. I&#8217;m writing  this post with it. And I can only say that this is the best keyboard one can have. It&#8217;s very slim and the typing is smooth, actually is pretty much the same as the new macbook keyboard.</p>
<p>I bought it to use at work, mainly because working endless hours in a laptop can injure your back and an external keyboard allows me to vary my posture when sitting in front of the macbook. Another reason, is that in summer time, having my hands resting in a macbook pro, turns out to be a hot and sweaty experience.</p>
<p>I opted for the USB version because I don&#8217;t really like batteries at all, and I wouldn&#8217;t be very tolerant with random bluetooth disconnects. Although the keyboard USB cable is short, Apple was king enough to include an extension for those who need a longer cable.</p>
<p style="text-align: center;"><img src="http://blog.rogeriopvl.com/wp-content/uploads/apple_keyboard_cable.jpg" alt="apple keyboard usb extension" width="450"/></p>
<p>Here&#8217;s the Apple keyboard side by side with my old <a href="http://www.driverheaven.net/reviews/Revoltec%20Lightboard%20XL%202/">Revoltec Lightboard</a>, so you can get an ideia about the size of this thing:</p>
<p style="text-align: center;"><img src="http://blog.rogeriopvl.com/wp-content/uploads/apple_keyboard_vs_revoltec.jpg" alt="The apple keyboard vs revoltec lightboard" width="450"/></p>
<p>Just to end this post, as you can see on the first picture, I bought this keyboard at <a href="http://www.tbstore.pt">TB Store</a> in Colombo. I definitely recommend this store to buy Apple stuff. Great customer service, nice and unusual bags for the shopped products and bonus key chain lanyards.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/apple-keyboard/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avoiding unnecessary risks with your Google account</title>
		<link>http://blog.rogeriopvl.com/archives/avoiding-unnecessary-risks-with-your-google-account</link>
		<comments>http://blog.rogeriopvl.com/archives/avoiding-unnecessary-risks-with-your-google-account#comments</comments>
		<pubDate>Tue, 09 Jun 2009 14:52:14 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[clickjacking]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[gmail]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=608</guid>
		<description><![CDATA[Almost everybody nowadays has a Gmail/Google account. We use it for our email service, to read our feeds, store our bookmarks, edit our documents, and what not. This demands that we constantly log in to these services with our google account user and password. The most &#8220;paranoid&#8221; users, never check the &#8220;keep me logged in&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Almost everybody nowadays has a Gmail/Google account. We use it for our email service, to read our feeds, store our bookmarks, edit our documents, and what not. This demands that we constantly log in to these services with our google account user and password. The most &#8220;paranoid&#8221; users, never check the &#8220;keep me logged in&#8221; checkbox, while the majority just checks it and doesn&#8217;t even bother anymore.</p>
<p>If you &#8220;worship&#8221; your google account, and the idea of losing it sounds catastrophic to you, because all your life is in it. You might just keep on reading this post.</p>
<h2>What&#8217;s the problem?</h2>
<p>The web is mostly an unsafe place, and having your google account logged while browsing &#8220;random&#8221; web sites, might be a russian roulette experience. Because with some recent techniques like <a href="http://en.wikipedia.org/wiki/Clickjacking">clickjacking</a>, an attacker might set up a web page with malicious code that uses your logged in google account session to perform actions on your behalf. And if you don&#8217;t believe this, you can try for your self in the following example.</p>
<p>You can try this using a dummy Gmail account if you feel insecure about it.</p>
<p>Log in to your dummy Gmail account, open a new tab and go to <a href="http://www.sirdarckcat.net/gmailclickjacking.html">this website</a>. Now click the &#8220;send&#8221; button on the page, and go check your dummy Gmail sent messages folder. You will see that you have just sent an email, without even noticing (well you did notice actually if you checked the status bar, but it was too late anyway).</p>
<p>The way to achieve a hack like this is not very complex. Quoting the <a href="http://www.sirdarckcat.net">author</a>:</p>
<blockquote style="font-style: oblique;">
<p>You get a copy of the generated HTML code of the target webpage, then you simply hide everything, except for the button you want to overlay.. you could draw other things using absolute positioning, but this is enough for most scenarios.</p>
<p>You can checkout the &#8220;ghost page&#8221; here: http://www.sirdarckcat.net/dad.html</p>
<p>This attack has it&#8217;s pros and it&#8217;s cons.. the most important pro is that it&#8217;s the best way of doing cross-browser exploits.. since you don&#8217;t depend on the sizes, margins, overflow rules etc.. that different browsers use.</p>
</blockquote>
<h2>Possible solutions?</h2>
<p>The best way to prevent against these attacks, while it may not be the ideal solution, is by simply reducing the time you spend logged in on the browser. Actually, you can even use these services with no logged session on the browser.</p>
<p>The answer is simple: don&#8217;t use these services web interface on your personal computer. For Gmail, use a POP or IMAP client of your choice, for every other, use <a href="http://prism.mozilla.com">Prism</a>. Prism lets you run web applications in a desktop/standalone mode. This way you have all your sessions encapsulated, in a kind of sandbox way. Leaving you free to use the browser in a more relaxed manner.</p>
<p>Why do I say &#8220;on personal computer&#8221; ? Because it&#8217;s in your daily use machine that you are more tempted to save login forms and such, leaving you vulnerable to the type of attacks I described. On other machines you are less tempted to do that, because it&#8217;s not your machine, or it&#8217;s a public computer, and you spend much less time on it.</p>
<p>While I&#8217;ve been talking about Google accounts and Gmail along this post, actually, every other service may be vulnerable to this type of attack, but generally Google services are usually more secured than the rest.</p>
<h2>What can web developers do?</h2>
<p>Not much really. For web developers, the way to prevent that your site gets opened in a <code>iframe</code> is the piece of code known as &#8220;<a href="http://en.wikipedia.org/wiki/Framekiller">the Framekiller</a>&#8220;. This is a javascript code snippet to include in your HTML pages:</p>
<pre class="code">
&lt;script type="text/javascript"&gt;
if (top !== self) top.location.replace(self.location.href);
&lt;/script&gt;
</pre>
<p>This works with the obvious javascript/client side limitations, so it shouldn&#8217;t be regarded as a reliable approach, but it definitely helps.</p>
<h2>More on the subject</h2>
<p>If you wish to know more about other similar techniques, you can check these links below:</p>
<p><a href="http://sirdarckcat.blogspot.com/2008/10/about-css-attacks.html">CSS Attacks</a></p>
<p><a href="http://www.sectheory.com/clickjacking.htm">Clickjacking</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/avoiding-unnecessary-risks-with-your-google-account/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TwitterPHP 0.5 released and lessons learned…</title>
		<link>http://blog.rogeriopvl.com/archives/twitterphp-05-released-and-lessons-learned</link>
		<comments>http://blog.rogeriopvl.com/archives/twitterphp-05-released-and-lessons-learned#comments</comments>
		<pubDate>Sun, 24 May 2009 20:37:54 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitterphp]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=599</guid>
		<description><![CDATA[I&#8217;ve released this Friday a new version of the TwitterPHP library. In this version I&#8217;ve done some code optimization, removed some files and changed to Doxygen for class documentation.
First, all methods were returning a SimpleXML object, which is a mistake in terms of flexibility. I&#8217;ve changed them all to just return a XML string. Now [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released this Friday a new version of the <a href="http://twitterphp.googlecode.com">TwitterPHP library</a>. In this version I&#8217;ve done some code optimization, removed some files and changed to <a href="http://www.doxygen.org">Doxygen</a> for class documentation.</p>
<p>First, all methods were returning a SimpleXML object, which is a mistake in terms of flexibility. I&#8217;ve changed them all to just return a XML string. Now its up to the user (programmer) to choose the way to access/parse the XML.</p>
<p>Second, TwitterPHP is a class, you can instantiate it several times, for let&#8217;s say, accessing multiple accounts. At least you should be able to do that, but since I was reading the Twitter username and password from a configuration file (naive, I know), multiple instances could only use the same account. Now the problem is solved by simply adding the username and password as arguments of the constructor method and removing the configuration file.</p>
<p>Third and last, I switched from <a href="http://www.phpdoc.org/">PHPDocumentor</a> to Doxygen. This was mainly because I found out that Doxygen is much more flexible, I can use it with any other project with any other language. And the resulting documentation is more fast and clean than PHPDocumentor.</p>
<p>So you can take a look at the new version of TwitterPHP <a href="http://twitterphp.googlecode.com">here</a> and the documentation generated by Doxygen <a href="http://rogeriopvl.com/twitterphp/doc">here</a>.</p>
<p>In future releases I&#8217;m planning to add <a href="http://apiwiki.twitter.com/OAuth-FAQ">OAuth</a> support and implement more Twitter API actions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/twitterphp-05-released-and-lessons-learned/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object Oriented Javascript</title>
		<link>http://blog.rogeriopvl.com/archives/object-oriented-javascript</link>
		<comments>http://blog.rogeriopvl.com/archives/object-oriented-javascript#comments</comments>
		<pubDate>Wed, 13 May 2009 23:12:11 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[oo]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=589</guid>
		<description><![CDATA[Recently, I&#8217;ve been playing with Object Oriented Javascript. This language, besides it&#8217;s chaotic nature, can be very powerful when used with some best practices (humm, that&#8217;s funny, I&#8217;d swear I&#8217;ve heard this before).
One of the most interesting things about Javascript OO is the way to define a Class. Actually there is no keyword &#8220;class&#8221; at [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been playing with Object Oriented Javascript. This language, besides it&#8217;s chaotic nature, can be very powerful when used with some best practices (humm, that&#8217;s funny, I&#8217;d swear I&#8217;ve heard <a href="http://php.net">this before</a>).</p>
<p>One of the most interesting things about Javascript OO is the way to define a Class. Actually there is no keyword &#8220;class&#8221; at all. So here&#8217;s an example on how to create a class <code>Book</code> in Javascript:</p>
<pre class="bigcode">
/**this will be the constructor method,
that automatically creates the class**/

function Book (isbn, title, author) {
    this.isbn = isbn;
    this.title = title;
    this.author = author;
}

/** And now the getters **/

Book.prototype.getISBN = function () {
    return this.isbn;
}

Book.prototype.getTitle = function () {
    return this.title;
}

Book.prototype.getAuthor = function () {
    return this.author;
}
</pre>
<p>If your class has attributes that are not passed as constructor arguments, you can declare the attribute just like we did for the methods:</p>
<pre class="code">
Book.prototype.numTimesRead = 5;

//a setter
Book.prototype.setNumTimeRead = function (n) {
    this.numTimesRead = n;
}
</pre>
<p>Now if we wish to instantiate our class, it&#8217;s identical to most OO languages:</p>
<pre class="code">
var mybook = new Book("123", "Dive into Python", "Mark Pilgrim");

//I tried to output this the ugliest way possible :P
document.getElementsByTagName("body").innerHTML = "Title: "+mybook.getTitle();
</pre>
<p>This will (<del><a href="http://en.wikipedia.org/wiki/Pwn">pwn</a> your body element</del>) print the Book title, you can add any other info as you wish.</p>
<p>You may find more on object oriented programming with Javascript at the <a href="https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript">Mozilla&#8217;s Developer site</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/object-oriented-javascript/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Extreme Programming</title>
		<link>http://blog.rogeriopvl.com/archives/extreme-programming</link>
		<comments>http://blog.rogeriopvl.com/archives/extreme-programming#comments</comments>
		<pubDate>Sun, 19 Apr 2009 11:52:00 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[extreme programming]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[xp]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=582</guid>
		<description><![CDATA[Some time ago, I&#8217;ve written a post talking about Agile Software Development methodologies, where I mentioned Extreme Programming (aka XP).
I was thinking about writing a post on Extreme Programming, but I&#8217;ve just found a very good video of a lecture on the subject by Richard Buckland, that explains it the best way possible and with [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I&#8217;ve <a href="http://blog.rogeriopvl.com/archives/agile-software-development-wrong-or-right">written a post</a> talking about Agile Software Development methodologies, where I mentioned Extreme Programming (aka XP).</p>
<p>I was thinking about writing a post on Extreme Programming, but I&#8217;ve just found a very good video of a lecture on the subject by <a href="http://www.cse.unsw.edu.au/~richardb/">Richard Buckland</a>, that explains it the best way possible and with some humor. So here&#8217;s the video:</p>
<p style="text-align: center"><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/XP4o0ArkP4s&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/XP4o0ArkP4s&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>This is a highly recommended video for those that want to learn about Extreme Programming and Unit Tests.</p>
<p><strong>Video Link: </strong> <a href="http://youtube.com/watch?v=XP4o0ArkP4s">http://youtube.com/watch?v=XP4o0ArkP4s</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/extreme-programming/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TinyURL reversing</title>
		<link>http://blog.rogeriopvl.com/archives/tinyurl-reversing</link>
		<comments>http://blog.rogeriopvl.com/archives/tinyurl-reversing#comments</comments>
		<pubDate>Mon, 13 Apr 2009 08:46:53 +0000</pubDate>
		<dc:creator>rogeriopvl</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[foresee]]></category>
		<category><![CDATA[tinyurl]]></category>

		<guid isPermaLink="false">http://blog.rogeriopvl.com/?p=544</guid>
		<description><![CDATA[TinyURL is a online service that shortens long URL&#8217;s so that they can save space in services like Twitter and others.
This is definitely a tool of great convenience, but like almost everything in life, has a drawback. Actually, two drawbacks. First, spammers, phishers and alike are using this service to mask the URL of their [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tinyurl.com">TinyURL</a> is a online service that shortens long URL&#8217;s so that they can save space in services like <a href="http://www.twitter.com">Twitter</a> and others.</p>
<p>This is definitely a tool of great convenience, but like almost everything in life, has a drawback. Actually, two drawbacks. First, spammers, phishers and alike are using this service to mask the URL of their malicious website so that when someone sees the link, feels comfortable about clicking it, and unaware of what&#8217;s coming. And second, it&#8217;s slowly building a &#8220;broken&#8221; web, because if this kind of services disappear, a good portion of links on the web won&#8217;t work anymore. And this can&#8217;t be good.</p>
<p>Against the first drawback, TinyURL has a feature that allows you to send a preview link instead of an instant redirection one, but it&#8217;s hardly used by anyone.</p>
<p>Some time ago, I developed a <a href="http://rogeriopvl.com/foresee">small online tool</a> that unveils every tinyurl that is sent to it. But its usefulness is almost none, since no one will bother to visit another website just to unveil the tinyurl&#8217;s target. So, to simplify that process, I&#8217;m developing a <a href="http://addons.mozilla.org">Firefox Extension</a> that integrates with the tool, so that when you visit a tinyurl, before that url is loaded, is passed trough the reverser and the target is shown on a confirmation popup or just a tooltip.</p>
<p>While the extension is not ready, I leave you here a small example of how to reverse a tinyurl in PHP. It&#8217;s very simple, and straightforward:</p>
<pre class="code">
function reverse_tinyurl($url){
	$url = explode('.com/', $url);
	$url = 'http://preview.tinyurl.com/'.$url[1];
	$prev = file_get_contents($url);
	preg_match('/redirecturl" href="(.*)">/', $prev, $res);
	return $res[1];
}
</pre>
<p>Well, or maybe if you prefer Ruby:</p>
<pre class="code">
require 'rubygems'
require 'net/http'

def reverse_tinyurl(url)
    url_parts = url.split('.com/')
    preview_url = "http://preview.tinyurl.com/#{url_parts[1]}"
    response = Net::HTTP.get_response(URI.parse(preview_url))
    original_url = response.body.scan(/redirecturl" href="(.*)">/)[0][0]
end
</pre>
<p>Or if you are more of a Python guy/girl: </p>
<pre class="code">
from lxml import etree

def reverse_tinyurl(url):
    hash = url[url.find(".com/")+5:]
    preview_url = "http://preview.tinyurl.com/"+hash
    parser = etree.HTMLParser()
    tree = etree.parse(preview_url, parser)
    elem = tree.findall('.//a[@id="redirecturl"]')
    if len(elem) == 1:
        return elem[0].get("href")
    return None
</pre>
<p>This examples should get you started on developing something around this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rogeriopvl.com/archives/tinyurl-reversing/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
