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

<channel>
	<title>Saulo Silva&#039;s Blog</title>
	<atom:link href="http://saulosilva.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://saulosilva.com</link>
	<description>On technology, programming, et cetera.</description>
	<lastBuildDate>Thu, 22 Jul 2010 14:14:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Oracle rebrands Java, breaks Eclipse</title>
		<link>http://saulosilva.com/2010/07/oracle-rebrands-java-breaks-eclipse/</link>
		<comments>http://saulosilva.com/2010/07/oracle-rebrands-java-breaks-eclipse/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 14:02:54 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://saulosilva.com/?p=838</guid>
		<description><![CDATA[The last release of  Java—version 1.6.0 update 21—was rebranded as being made by “Oracle” instead of “Sun Microsystems, Inc”. The problem is that Eclipse uses that value to decide on whether to pass a specific argument to the Virtual Machine or not. This change affects versions 3.3 (released in 2007) to 3.6 (released in 2010), causing [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-848 alignleft" title="Eclipse and Oracle" src="http://saulosilva.com/wp-content/uploads/2010/07/eclipse_oracle.png" alt="" width="144" height="99" />The last release of  Java—version 1.6.0 update 21—was rebranded as being made by “Oracle” instead of “Sun Microsystems, Inc”.</p>
<p>The problem is that <a href="https://bugs.eclipse.org/bugs/attachment.cgi?id=174008&amp;action=diff">Eclipse uses that value</a> to decide on whether to pass a specific argument to the Virtual Machine or not.</p>
<p>This change affects versions 3.3 (released in 2007) to 3.6 (released in 2010), causing the IDE to hang consistently, without any error messages.</p>
<p>The guys at Eclipse.org have posted <a href="http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Oracle.2FSun_VM_1.6.0_21_on_Windows">three workarounds</a> for this issue. (Since I’m using Helios, I opted for no. 3.)</p>
<p>Here is the bug  on the <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6969236">Oracle</a> and on the <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514">Eclipse</a> side.</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2010/07/oracle-rebrands-java-breaks-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object-oriented programming with JavaScript</title>
		<link>http://saulosilva.com/2010/04/object-oriented-programming-with-javascript/</link>
		<comments>http://saulosilva.com/2010/04/object-oriented-programming-with-javascript/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 01:09:26 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[object-oriented]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=654</guid>
		<description><![CDATA[I will try to show with this short article how the concepts of classes and inheritance can be achieved in JavaScript. Only the very basics will be covered here. If you are unfamiliar with object-oriented programming, I highly recommend reading this Wikipedia article before you proceed. Classes in my JavaScript? JavaScript does not have a built-in language [...]]]></description>
			<content:encoded><![CDATA[<p>I will try to show with this short article how the concepts of classes and inheritance can be achieved in JavaScript. Only the very basics will be covered here.</p>
<p style="padding-left: 30px;">If you are unfamiliar with object-oriented programming, I highly recommend reading <a title="Object-oriented programming: Fundamental concepts and features" href="http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_concepts_and_features">this Wikipedia article</a> before you proceed.</p>
<h3>Classes in my JavaScript?</h3>
<p>JavaScript does not have a built-in language construct for the definition of a class per se, but there are a few ways of achieving almost the same concept of an &#8220;object blueprint&#8221;. One of them is via a <code>function</code>, to which attributes and  methods can be attached dynamically. Let&#8217;s look at a practical example—let&#8217;s implement a simple <em>Animal</em> class:</p>
<pre class="brush: jscript;">
// Animal class
function Animal(name) {
	// Attributes
	this.name = name;

	// Methods
	this.getName = function() {
		return this.name;
	}

	this.setName = function(name) {
		this.name = name;
		return this;
	}

	this.speak = function() {};
	this.toString = function() {};
}
</pre>
<p>So this class has a <em>name</em> which is encapsulated by a getter and a setter. It also has two undefined methods. Nothing extraordinary here.</p>
<h3>Inheritance</h3>
<p>Let&#8217;s implement a class <em>Cat</em> that extends <em>Animal</em>. This can be done by assigning an instance of <em>Animal</em> to  <code>Cat.prototype</code>:</p>
<pre class="brush: jscript; highlight: [2];">
// Cat class
Cat.prototype = new Animal(); // A Cat is an Animal
function Cat(name, favouriteFood) {
	// This is how we invoke the constructor of the parent class.
	// Not very nice; we will see a way around this.
	Animal.prototype.constructor.call(this, name);

	// Attributes
	this.favouriteFood = favouriteFood;

	// Methods
	this.speak = function() {
		return 'Meow';
	}

	this.toString = function() {
		return this.getName() + ' is a cat';
	}

	this.getFavouriteFood = function() {
		return this.favouriteFood;
	}
}
</pre>
<p>Instantiating objects and passing messages is straight forward to those who are familiar with C++/Java:</p>
<pre class="brush: jscript;">
loup = new Cat(&quot;Loup&quot;, &quot;tuna&quot;);

document.write(
	loup + ' who loves ' + loup.getFavouriteFood() + '.' +
	loup.getName() + ' says &quot;' + loup.speak()+ '&quot;.'
);
</pre>
<p>And the output is:</p>
<blockquote><p>Loup is a cat who loves tuna. Loup says &#8220;Meow&#8221;.</p></blockquote>
<p>Notice the overriding of the methods <code>speak()</code> and <code>toString()</code> in the <em>Cat</em> class.</p>
<h3>But wait! There&#8217;s more!</h3>
<p>We can make the invocation of parent constructors a bit more elegant like this:</p>
<pre class="brush: jscript; highlight: [3,7];">
// Cat class, version 2
Cat.prototype = new Animal(); // A Cat is an Animal
Cat.prototype.parent = Animal.prototype;
function Cat(name, favouriteFood) {
	// This is how we invoke the constructor of the parent class.
	// See how this is much better?
	this.parent.constructor.call(this, name);
	…
</pre>
<p>But now for every inheritance we would need to copy and paste lines 2 and 3. We can reduce code repetition by creating a method as follows:</p>
<pre class="brush: jscript;">
Function.prototype.inheritFrom = function(parentClass) {
	this.prototype = new parentClass();
	this.prototype.parent = parentClass.prototype;
}
</pre>
<p>Since our classes are actually JavaScript <code>function</code>s, we can add any method or attribute to <em>Function</em> and it will be available to any of our classes. Lines 2 and 3 above are almost exactly as we had before: &#8220;Cat&#8221; was replaced by &#8220;this&#8221; and &#8220;Animal&#8221; was replaced by the reference &#8220;parentClass&#8221;.</p>
<p>Here is how we would use it:</p>
<pre class="brush: jscript; highlight: [2];">
// Cat class, version 3
Cat.inheritFrom(Animal); // A Cat is an Animal
function Cat(name, favouriteFood) {
…
</pre>
<h3>That&#8217;s it!</h3>
<p>The final version of the code can be tested <a href="/wp-content/uploads/2010/04/oop-with-javascript.html">here</a>.</p>
<p>If you don&#8217;t want to reinvent the wheel, there are a couple of powerful and robust frameworks out there that will achieve the same functionality and much more. <a href="http://www.prototypejs.org/">Prototype</a> is one of them.</p>
<p>So there you go, this should get you started with <acronym title="Object-oriented programming">OOP</acronym> in JavaScript!</p>
<p><em>If you find any mistakes or if you have any suggestions, please leave a comment.</em></p>
<p><small><span style="color: #888888;">References: <a href="http://www.crockford.com/javascript/inheritance.html#sugar"><em>Classical Inheritance in JavaScript</em> by Douglas Crockford</a> and <a href="http://phrogz.net/JS/Classes/OOPinJS2.html"><em>OOP in JS, Part 2 : Inheritance</em> by Gavin Kistner</a>.</span></small></p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2010/04/object-oriented-programming-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to load a properties file from a servlet</title>
		<link>http://saulosilva.com/2009/06/how-to-load-a-properties-files-from-a-servlet/</link>
		<comments>http://saulosilva.com/2009/06/how-to-load-a-properties-files-from-a-servlet/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 14:48:30 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[How-Tos]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=433</guid>
		<description><![CDATA[I wanted to read a properties file from a servlet without using a hard-coded, absolute path. I tried to search on the web for a portable solution, but I couldn&#8217;t find anything. Here is the trick: use ServletContext.getRealPath(String). For instance, a file called &#8220;config.properties&#8221; located in &#8220;WEB-INF&#8221;, can be loaded like this: public void init(ServletConfig [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-462" title="config.properties" src="http://saulosilva.com/wp-content/uploads/2009/07/config.properties.png" alt="config.properties" /></p>
<p>I wanted to read a properties file from a servlet without using a hard-coded, absolute path. I tried to <a href="http://www.google.ca/search?q=load+properties+file+from+servlet">search on the web</a> for a portable solution, but I couldn&#8217;t find anything.</p>
<p>Here is the trick: use <code><a href="http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)">ServletContext.getRealPath(String)</a></code>. For instance, a file called &#8220;config.properties&#8221; located in &#8220;WEB-INF&#8221;, can be loaded like this:</p>
<pre class="brush: java;">
public void init(ServletConfig config) throws ServletException {
	String pathToPropertiesFile =
		config.getServletContext().getRealPath(&quot;&quot;)
		+ &quot;/WEB-INF/config.properties&quot;;
	Properties properties = new Properties();
	properties.load(new FileInputStream(pathToPropertiesFile));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2009/06/how-to-load-a-properties-files-from-a-servlet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aspect-oriented programming with AspectJ</title>
		<link>http://saulosilva.com/2009/03/aspect-oriented-programming-with-aspectj/</link>
		<comments>http://saulosilva.com/2009/03/aspect-oriented-programming-with-aspectj/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 03:35:47 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[aspectj]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=276</guid>
		<description><![CDATA[In one of the courses I took this session I was introduced to aspect-oriented programming. For those who are not familiar with it, an aspect can be used to implement a concern that is crosscutting among different components. There are a few such concerns that are commonly affected by crosscutting, namely: authentication, persistence, logging and [...]]]></description>
			<content:encoded><![CDATA[<p>In one of the courses I took this session I was introduced to aspect-oriented programming. For those who are not familiar with it, an aspect can be used to implement a concern that is crosscutting among different components.</p>
<p>There are a few such concerns that are commonly affected by crosscutting, namely: authentication, persistence, logging and contract checking.</p>
<p>It is argued that with object-oriented programming, even after proper refactoring, it is not always possible to map a requirement to a single component. When a requirement is implemented by more than one component, scattering occurs. <acronym title="Aspect-oriented programming">AOP</acronym> allows you to localize the scattered requirement into an aspect.</p>
<p>AspectJ is an extension to the Java language that adds support to <acronym title="Aspect-oriented programming">AOP</acronym>. An aspect in AspectJ is composed of <em>pointcuts</em> and <em>advices</em>. A pointcut defines the condition that needs to be met in order for the logic in an advice to be executed. A pointcut could be, for instance, the execution of a method in a particular class.</p>
<h3>How AspectJ can be useful</h3>
<p>Let&#8217;s look at an example. Say we want to log when <a title="A horse drinking water." href="http://www.flickr.com/photos/architekt2/185791912/">horses drink water</a> and when <a title="A cow eating grass." href="http://www.flickr.com/photos/dizzo/2168240431/">cows eat grass</a>. Assume we have a class <code>Logger</code> with a static method <code>log()</code>. Here&#8217;s what the implementation could look like:</p>
<pre class="brush: java;">public class Horse {
	private int consumedWaterInLitres;

	public void drink() {
		consumedWaterInLitres++;
		Logger.log(&quot;A horse is drinking water.&quot;);
	}
}

public class Cow {
	private int consumedGrassInGrams;

	public void eat() {
		consumedGrassInGrams++;
		Logger.log(&quot;A cow is eating grass.&quot;);
	}
}</pre>
<p>The argument is that the concern of logging is now crosscut among the Horse and Cow components. In addition, it can be said that <code>Horse.drink()</code> and <code>Cow.eat()</code> are responsible for more core logic (eating and drinking) than they should have been. Let&#8217;s try to fix this problem with an aspect:</p>
<pre class="brush: java;">public aspect Logging {
	pointcut logHorseDrinking() : call(public void Horse.drink());
	pointcut logCowEating() : call(public void Cow.eat());

	void after() : logHorseDrinking() {
		Logger.log(&quot;A horse is drinking water.&quot;);
	}

	void after() : logCowEating() {
		Logger.log(&quot;A cow is eating grass.&quot;);
	}
}</pre>
<p>Here we defined two pointcuts that capture calls to <code>Horse.drink()</code> and to <code>Cow.eat()</code>. We&#8217;ve attached these pointcuts to two advices that will run after these methods are executed. With the Logging aspect in place, we can now remove all calls to <code>Logger.log()</code> from <code>Horse</code> and <code>Cow</code>. Isn&#8217;t that great?</p>
<h3>How AspectJ can be dangerous</h3>
<p><img class="size-full wp-image-330 alignright" title="Dog Class Diagram" src="http://saulosilva.com/wp-content/uploads/2009/03/dog_class_diagram.png" alt="Dog before DogAspect" width="86" height="46" /></p>
<p>Aspects can also add state, behaviour and inheritance to a component. Privileged aspects have access to all features in a system—including private ones. Does that raise a red flag? Let&#8217;s look at the class <code>Dog</code> below.</p>
<pre class="brush: java;">public class Dog {
}</pre>
<p>It has no features—no attributes nor methods—and doesn&#8217;t extend from any class, right? Wrong:</p>
<pre class="brush: java;">public aspect DogAspect {
	declare parents: Dog extends Animal;
	private String Dog.ownersName = &quot;Bobert&quot;;

	public String Dog.getOwnwersName() {
		return ownersName;
	}
}</pre>
<p><img class="size-full wp-image-353 alignright" title="Class Dog after DogAspect" src="http://saulosilva.com/wp-content/uploads/2009/03/dog_after_dogaspect.png" alt="Dog after DogAspect" width="146" height="136" /></p>
<p>The aspect above has completely changed the class <code>Dog</code>. It has made it an <code>Animal</code>, it has added an attribute <em>ownersName</em> and a getter for it. The worst part is that <code>Dog</code> is completely oblivious to the aspect—it will never know about it. In fact, unless you as a developer look at all aspects on the system, you will never know about it either.</p>
<p>That is not completely true because some <acronym title="Integrated development environment">IDE</acronym>s will provide a visual clue whenever a class is affected by an aspect. The <a href="http://www.eclipse.org/ajdt/">AspectJ Developement Tools</a> add-on for <a href="http://eclipse.org/">Eclipse</a> (a great <acronym title="Integrated development environment">IDE</acronym> by the way) is supposed to show a marker on the editor margin whenever a component is being advised by an aspect. I have the latest version installed (ADJT 1.6.4) but for some reason the marker is not showing up, unfortunately.</p>
<p>There are also other issues one might encounter when using AspectJ. It is not an easy task to document the impact aspects have on a system—<acronym title="Unified Modeling Language">UML</acronym> has no support for aspects at this moment, and how are you going to show that on a sequence diagram? Also, the debugging and tracing of execution of a class that is being advised by an aspect can get pretty tricky.</p>
<h3>In conclusion</h3>
<p>I believe that the application of <acronym title="Aspect-oriented programming">AOP</acronym> could indeed improve the quality of a system through the localization of crosscutting concerns. However, its Java implementation—AspectJ—provides a level of control that is too risky to be used in industrial medium- to large-scale projects. Its supporting technologies and documenting tools have not yet reached the desired maturity level.</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2009/03/aspect-oriented-programming-with-aspectj/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Should we use foreign-key constraints when persisting Domain Models?</title>
		<link>http://saulosilva.com/2009/02/domain-model-persistence-and-foreign-key-constraints/</link>
		<comments>http://saulosilva.com/2009/02/domain-model-persistence-and-foreign-key-constraints/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 19:53:25 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=253</guid>
		<description><![CDATA[Since last summer I&#8217;ve been working with three other Software Engineering undergraduates on a web enterprise application that will eventually replace a legacy ERP system. We used patterns from Martin Fowler&#8217;s Patterns of Enterprise Application Architecture (a great book, by the way), and the well-known three-layered architecture. One day we had a discussion related to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://saulosilva.com/wp-content/uploads/2009/02/mediawiki-database-schema.png"><img class="size-thumbnail wp-image-264 alignleft" title="The Mediawiki database schema" src="http://saulosilva.com/wp-content/uploads/2009/02/mediawiki-database-schema-150x150.png" alt="Mediawiki Database Schema" width="150" height="150" /></a></p>
<p>Since last summer I&#8217;ve been working with three other Software Engineering undergraduates on a web enterprise application that will eventually replace a legacy <acronym title="Enterprise Resource Planning">ERP</acronym> system. We used patterns from Martin Fowler&#8217;s <a href="http://martinfowler.com/books.html"><em>Patterns of Enterprise Application Architecture</em></a> (a great book, by the way), and the well-known three-layered architecture.</p>
<p>One day we had a discussion related to the persistence of <a title="The Domain Model software design pattern." href="http://martinfowler.com/eaaCatalog/domainModel.html">Domain Model</a>s and whether we should enforce foreign-key constraints at the database level. My first reaction was that the very use of a relational database implied the enforcement of such constraints, but some of my colleagues argued that the database should be seen as nothing but a persistence mechanism and therefore we should avoid placing any business logic in it. We ended up by not using foreign-key constraints.</p>
<p>Would you have done otherwise? I would like to hear what other software engineers/developers have to say about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2009/02/domain-model-persistence-and-foreign-key-constraints/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mighty Putty</title>
		<link>http://saulosilva.com/2009/01/mighty-putty/</link>
		<comments>http://saulosilva.com/2009/01/mighty-putty/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 16:29:31 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Humour]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=234</guid>
		<description><![CDATA[Hey guys, sorry for the lack of updates. My last semester has been a little bit hectic, but in three months I&#8217;ll be a (Junior) Software Engineer! :) Here&#8217;s a little video I just stumbled upon on reddit. It&#8217;s pure gold.]]></description>
			<content:encoded><![CDATA[<p>Hey guys, sorry for the lack of updates. My last semester has been a little bit hectic, but in three months I&#8217;ll be a (Junior) Software Engineer! :)</p>
<p>Here&#8217;s a little video I just stumbled upon on reddit. It&#8217;s pure gold.</p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/r_4a4O7kXQo&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/r_4a4O7kXQo&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2009/01/mighty-putty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Barack Obama 2008</title>
		<link>http://saulosilva.com/2008/10/i-support-barack-obama/</link>
		<comments>http://saulosilva.com/2008/10/i-support-barack-obama/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 14:52:38 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[United States]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=214</guid>
		<description><![CDATA[I support Barack Obama. That is all. Edit: Obama is the new elect-president! Congratulations!]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-215" title="Barack Obama 2008" src="http://saulosilva.com/wp-content/uploads/2008/10/obamafaceicon.jpg" alt="" width="96" height="96" />I support Barack Obama. That is all.<br />
<strong>Edit:</strong> Obama is the new elect-president! Congratulations!<br />
<br clear="all" /></p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2008/10/i-support-barack-obama/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Chrome, a new web browser</title>
		<link>http://saulosilva.com/2008/09/google-chrome-a-new-web-browser/</link>
		<comments>http://saulosilva.com/2008/09/google-chrome-a-new-web-browser/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 23:11:46 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[web browser]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=170</guid>
		<description><![CDATA[Google confirmed tomorrow&#8217;s launch of Google Chrome beta, a new open source web browser that borrows the rendering engine from Apple&#8217;s WebKit and components from Mozilla Firefox. An important design aspect behind Google Chrome is that each tab will be assigned an entire process instead of a thread within a process. This means that if [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-179 alignleft" title="Google Chrome logo" src="http://saulosilva.com/wp-content/uploads/2008/09/google_chrome_logo.jpg" alt="" width="130" height="150" /><a href="http://googleblog.blogspot.com/2008/09/fresh-take-on-browser.html">Google confirmed</a> tomorrow&#8217;s launch of Google Chrome beta, a new open source web browser that borrows the rendering engine from Apple&#8217;s WebKit and components from Mozilla Firefox.</p>
<p>An important design aspect behind Google Chrome is that each tab will be assigned an entire process instead of a thread within a process. This means that if a particular website causes the page to hang, only its tab will have to be closed. In addition, a task manager will allow the user to see which page, plug-in or web application is consuming system resources, a feature available in all modern <acronym title="Operating System">OS</acronym>s.</p>
<p>Google has published a <a href="http://www.google.com/googlebooks/chrome/">comic</a> that explains in 38 pages their web browser project.</p>
<p>How will this affect the battle for market share between existing web browsers? Will Google Chrome be adopted by Firefox or <acronym title="Internet Explorer">IE</acronym> users?</p>
<p><a href="http://saulosilva.com/wp-content/uploads/2008/09/google_chrome_comic_page_38.png"><img class="size-thumbnail wp-image-177 alignnone" title="Google Chrome Comic page 38" src="http://saulosilva.com/wp-content/uploads/2008/09/google_chrome_comic_page_38-150x150.png" alt="Google Chrome Comic page 38" width="150" height="150" /></a> <a href="http://saulosilva.com/wp-content/uploads/2008/09/google_chrome_screenshot.jpg"><img class="size-thumbnail wp-image-186 alignnone" title="A screenshot of Google Chrome" src="http://saulosilva.com/wp-content/uploads/2008/09/google_chrome_screenshot-150x150.jpg" alt="A screenshot Google Chrome" width="150" height="150" /></a></p>
<p><strong>Update 1</strong>: added a screenshot (found at <a href="http://www.techcrunch.com/2008/09/01/first-public-screen-captures-of-google-chrome/">TechCrunch</a>).<br />
<strong>Update 2:</strong> <a title="Google Chrome" href="http://www.google.com/chrome/">The Google Chrome webpage is up</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2008/09/google-chrome-a-new-web-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goodbye PensCMS, hello WordPress!</title>
		<link>http://saulosilva.com/2008/08/goodbye-penscms-hello-wordpress/</link>
		<comments>http://saulosilva.com/2008/08/goodbye-penscms-hello-wordpress/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 15:54:20 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[Site updates]]></category>

		<guid isPermaLink="false">http://pensador.org/?p=119</guid>
		<description><![CDATA[After realizing that I would never match the power of hundreds of developers behind WordPress&#8217; success, I decided to ditch my own custom, ad hoc content management system. PensCMS had been around for eight years, and I had just successfully solved the spam problem with reCAPTCHA (I know, I should have thought about that before!). [...]]]></description>
			<content:encoded><![CDATA[<p>After realizing that I would never match the power of hundreds of developers behind WordPress&#8217; success, I decided to ditch my own custom, <em>ad hoc</em> content management system. PensCMS had been around for eight years, and I had just successfully solved the spam problem with <a href="http://recaptcha.net/">reCAPTCHA</a> (I know, I should have thought about that before!). The other thing that really bothered me with my own blogging software is that in order to add images to a post, I had to manually resize, upload via FTP and paste the code for them, which was a painful process to say the least.</p>
<p>I prefer to always include at least an image with my posts, so this was a big issue for me.  As I thought about a solution, I had a sudden spark of humbleness: maybe it&#8217;s OK to use other people&#8217;s work instead of doing it all myself from the ground up.</p>
<p><img class="size-full wp-image-135 alignleft" title="WordPress" src="http://saulosilva.com/wp-content/uploads/2008/08/wp-20-square-button-trans.gif" alt="WordPress" /></p>
<p>After some research, I narrowed down to two options: <a href="http://wordpress.org">WordPress</a> and <a href="http://blogger.com">Blogger</a>. The reason why I chose the former is that I wanted to transfer all my posts and comments from my old blog. The easiest way of doing so (although a bit long and tedious) was to manually add them to the database. The other option was to convert all posts and comments to XML—which I did—but I was unable to import into Blogger. Besides, there is no way of creating the <a href="/about/">about</a> and <a href="/quotes/">quotes</a> pages on the Google-maintained blogging system.</p>
<p>I spent the whole day yesterday moving posts and comments, customizing the <a href="http://ifelse.co.uk/simpla">Simpla</a> theme and installing plug-ins. I left behind some posts that were either too old or too silly—I did keep the ones that were chronologically interesting such as the post on how <a href="http://pensador.org/2003/10/17/mozilla-firebird-a-great-ie-alternative/">Firebird (now &#8220;Firefox&#8221;) was good alternative to IE</a>.</p>
<p>I am happy with the results and I will try to write more often now that I don&#8217;t have to open Paint.NET and FileZilla in order to post an article!</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2008/08/goodbye-penscms-hello-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Applying the Chinese Remainder Theorem</title>
		<link>http://saulosilva.com/2007/10/applying-the-chinese-remainder-theorem/</link>
		<comments>http://saulosilva.com/2007/10/applying-the-chinese-remainder-theorem/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 13:17:59 +0000</pubDate>
		<dc:creator>Saulo</dc:creator>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[mathematics]]></category>

		<guid isPermaLink="false">http://pensador.org/wordpress/?p=1</guid>
		<description><![CDATA[In public-key Cryptography, especially with the RSA algorithm, the Chinese Remainder Theorem is often used. Say you have a system of simultaneous congruences as follows x a1 mod m1 x a3 mod m2 x ak mod mk , where m1, m2, &#8230;, mk are coprime, i.e. gcd(m1, m2, &#8230;, mk) = 1. How can we [...]]]></description>
			<content:encoded><![CDATA[<p>In public-key Cryptography, especially with the <a href="http://en.wikipedia.org/wiki/RSA">RSA algorithm</a>, the Chinese Remainder Theorem is often used. Say you have a system of simultaneous congruences as follows</p>
<p>x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" /> a<sub>1</sub> mod m<sub>1</sub><br />
x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" /> a<sub>3</sub> mod m<sub>2</sub><br />
<img class="size-full wp-image-106 noborder alignnone" title="Vertical Ellipsis" src="http://saulosilva.com/wp-content/uploads/2008/08/vertical_ellipsis.png" alt="" width="5" height="20" /><br />
x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" /> a<sub>k</sub> mod m<sub>k</sub> ,</p>
<p>where m<sub>1</sub>, m<sub>2</sub>, &#8230;, m<sub>k</sub> are coprime, i.e. <acronym title="Greatest common divisor">gcd</acronym>(m<sub>1</sub>, m<sub>2</sub>, &#8230;, m<sub>k</sub>) = 1.   How can we solve for x? The solution is quite straight forward, but could involve a   fair amount of calculations. I find that breaking down the method into smaller steps   makes it easier to find and fix mistakes. By the Chinese   Remainder Theorem, the solution to that system of equations is</p>
<p style="text-align: center;">x =   (a<sub>1</sub>M<sub>1</sub>y<sub>1</sub> + a<sub>2</sub>M<sub>2</sub>y<sub>2</sub> + &#8230; + a<sub>k</sub>M<sub>k</sub>y<sub>k</sub>) mod M ,</p>
<p>where M<sub>i</sub> is the product of all   m&#8217;s except for m<sub>i</sub></p>
<p style="text-align: center;"><img class="size-full wp-image-107 noborder alignnone" title="How to compute M sub i" src="http://saulosilva.com/wp-content/uploads/2008/08/mi.png" alt="" width="77" height="54" />,</p>
<p>y<sub>i</sub> is the multiplicative inverse of M<sub>i</sub> modulo m<sub>i</sub></p>
<p style="text-align: center;">y<sub>i</sub> <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> M<sub>i</sub><sup>-1</sup> mod m<sub>i</sub> ,</p>
<p style="text-align: center;">and M = m<sub>1</sub> * m<sub>2</sub> * &#8230; * m<sub>k</sub> .</p>
<p>Let us try a numeric example. Here is a system of simultaneous congruences:</p>
<p style="text-align: center;">x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 12 mod 25<br />
x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 9 mod 26<br />
x <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 23 mod 27</p>
<p>We start by calculating M<sub>1</sub> and y<sub>1</sub>:</p>
<p style="text-align: center;">M<sub>1</sub> = m<sub>2</sub> * m<sub>3</sub> = 26 * 27 = 702</p>
<p style="text-align: center;">y<sub>1</sub> = M<sub>1</sub><sup>-1</sup> mod m<sub>1</sub> = 702<sup>-1</sup> mod 25 .</p>
<p>We apply the <a href="http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm">Extended Euclidean Algorithm</a> to find the multiplicative inverse of 702 relative to 25:</p>
<p>702 = 28 * 25 + 2  → 2 = 702 – 28 * 25<br />
25   = 12 * 2 + 1      → 1 = 25 – 12 * <span style="text-decoration: underline;">2</span><br />
= 25 – 12 * (702 – 28 * 25)<br />
= 337 * 25 – 12 * 702</p>
<p>Then y<sub>1</sub> = 702<sup>-1</sup> mod 25 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> -12 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 13.</p>
<p>The same calculations can be carried on to find M<sub>2</sub> = 675, y<sub>2</sub> = 25, M<sub>3</sub> = 650 and y<sub>3</sub> = 14. Now it is just a matter of plugging in the values into the equation:</p>
<p>x = (a<sub>1</sub>M<sub>1</sub>y<sub>1</sub> + a<sub>2</sub>M<sub>2</sub>y<sub>2</sub> + a<sub>3</sub>M<sub>3</sub>y<sub>3</sub>) mod  M<br />
= (12*702*13 + 9*675*25 + 23*650*14) mod 17550 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 470687 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 14387</p>
<p>To verify our answer we can plug that number back into the system:</p>
<p style="text-align: center;">470687 mod 25 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 12<br />
470687 mod 26 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 9<br />
470687 mod 27 <img class="alignnone size-full wp-image-103 noborder" title="Congruence" src="http://saulosilva.com/wp-content/uploads/2008/08/congruence.png" alt="" width="11" height="13" /> 23</p>
]]></content:encoded>
			<wfw:commentRss>http://saulosilva.com/2007/10/applying-the-chinese-remainder-theorem/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
