<?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>SAPessi &#187; Technology</title>
	<atom:link href="http://sapessi.com/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://sapessi.com</link>
	<description>Perfection of means and confusion of aims...</description>
	<lastBuildDate>Fri, 02 Mar 2012 09:26:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Maps &#8211; Open vs Closed</title>
		<link>http://sapessi.com/2012/03/maps-open-vs-closed/</link>
		<comments>http://sapessi.com/2012/03/maps-open-vs-closed/#comments</comments>
		<pubDate>Fri, 02 Mar 2012 09:26:33 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[General Babbling]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Comparison]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[Open]]></category>
		<category><![CDATA[OpenStreetMap]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=405</guid>
		<description><![CDATA[Normally I'm a big supporter of openness. However, in this particular care, I find myself thinking that a "closed" system is probably better. I am using the word close losely here as what I mean is not a system unaccessible to developers but rather a system maintained and paid for by a private corporation.
My reasons are the following...<!-- Easy AdSense V2.82 -->
<!-- Post[count: 1] -->
<div class="ezAdsense adsense adsense-leadout" style="text-align:center;margin:12px;"><script type="text/javascript"><!--
google_ad_client = "pub-8456780651289352";
/* 468x60, created 11/24/09 */
google_ad_slot = "7140896000";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<!-- Easy AdSense V2.82 -->

]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright" title="World Map" src="http://www.webresourcesdepot.com/wp-content/uploads/image/old-world-map.jpg" alt="World Map" width="347" height="265" />Yesterday,  Following <a title="Foursquare switches to openstreetmap" href="http://blog.foursquare.com/2012/02/29/foursquare-is-joining-the-openstreetmap-movement-say-hi-to-pretty-new-maps/">Foursquare&#8217;s announcement</a> of their decision to switch to <a href="http://www.openstreetmap.org/">OpenStreetMap</a>,  I had a long discussion on Twitter about the merits of open and &#8220;closed&#8221; map systems.</p>
<p>I am a big fan of Google maps. I like using the website both from my pc and my iPhone.<br />
The only interaction I have had with OpenStreetMap has been through the <a href="http://www.skobbler.us/">Skobbler navigation app for the iPhone</a>. I had even paid to get the offline maps. My experience was a thoroughly disappointing one. Partly because of the maps not being very accurate but mainly because of the frustration with the application. After spending the money to get the offline maps the app kept telling me to connect to the internet to navigate &#8211; which entirely defeats the purpose of paying for the offline maps.</p>
<p>Normally I&#8217;m a big supporter of openness. However, in this particular care, I find myself thinking that a &#8220;closed&#8221; system is probably better. I am using the word close losely here as what I mean is not a system unaccessible to developers but rather a system maintained and paid for by a private corporation.<br />
My reasons are the following:</p>
<ol>
<li>&#8220;Mapping&#8221; is an expensive business &#8211; A private corporation fully invested in this business is likely to spend considerable sums of money making sure its maps are accurate and reliable, <strong>globally</strong>. Globally here is a keyword for me. OpenStreetMap is not likely to get very accurate data in areas which are not easily reachable or don&#8217;t have easy access to the internet (and that&#8217;s where I like to travel and use my maps)</li>
<li>People are lazy &#8211; We see it all the time. Wikipedia (which I love) is updated only by a handful of users  while being consumed by billions &#8211; Creating content on Wikipedia requires relatively little (physical) effort, on the other hand creating content for OpenStreetMaps includes going out, driving and therefore spending money. Granted there will always be a handful of people eager to create and share this information, but is that enough to keep a world atlas up to date?</li>
<li>Being popular online is expensive &#8211; OpenStreetMap to keep growing in popularity will have to raise an ever larger amount of money to keep its hosting facilities up to scratch to deal with the demand. Of course a business has the same issue, but they make money out of it and this money is invested in keeping the facilities up-to-date.</li>
</ol>
<p>I love the idea of OpenStreetMap being an open data source and API rather than a product (like Google maps). I love how customisable it is and how easy it is for developers to integrate. Nevertheless I am not sure it will be able to stay accurate in the long run. Yesterday Skobbler&#8217;s creator claimed that OpenStreetMap is already better than Google maps in Germany. Just out of curiosity I went to google maps, picked a random small town in the middle of Germany then went to have a look at it on OpenStreetMap &#8211; quite a few roads where missing (especially dead end roads) &#8211; Urgh.</p>
<p>What do you think?</p>
<!-- Easy AdSense V2.82 -->
<!-- Post[count: 2] -->
<div class="ezAdsense adsense adsense-leadout" style="text-align:center;margin:12px;"><script type="text/javascript"><!--
google_ad_client = "pub-8456780651289352";
/* 468x60, created 11/24/09 */
google_ad_slot = "7140896000";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<!-- Easy AdSense V2.82 -->

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;submitHeadline=Maps+%26%238211%3B+Open+vs+Closed&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;title=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;title=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;title=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;bm_description=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;T=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;title=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;title=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Maps+%26%238211%3B+Open+vs+Closed+@+http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2012%2F03%2Fmaps-open-vs-closed%2F&amp;t=Maps+%26%238211%3B+Open+vs+Closed" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2012/03/maps-open-vs-closed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interviewing tips</title>
		<link>http://sapessi.com/2010/08/interviewing-tips/</link>
		<comments>http://sapessi.com/2010/08/interviewing-tips/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 19:26:50 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[General Babbling]]></category>
		<category><![CDATA[My Works]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Job]]></category>
		<category><![CDATA[Position]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=385</guid>
		<description><![CDATA[Over the past couple of weeks I&#8217;ve been interviewing candidates for a Java developer position. I can&#8217;t find words to describe my feelings now so I&#8217;ll recycle something a friend of mine, who&#8217;s also hiring, said: It&#8217;s next to impossible to hire anyone useful now. My complaint with most of the applicants is that they [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Over the past couple of weeks I&#8217;ve been interviewing candidates for a Java developer position.<br />
I can&#8217;t find words to describe my feelings now so I&#8217;ll recycle something a friend of mine, who&#8217;s also hiring, said:</p>
<blockquote><p>It&#8217;s next to impossible to hire anyone useful now.</p></blockquote>
<p><img class="alignright size-medium wp-image-387" title="cv" src="http://sapessi.com/wp-content/uploads/2010/08/cv-300x252.jpg" alt="" width="300" height="252" /></p>
<p>My complaint with most of the applicants is that they behave &#8211; there&#8217;s no other way to say this &#8211; machines.</p>
<p>I did what I did because I was told to it. Never really thought about it.</p>
<p>This infuriates me beyond belief.</p>
<p>So here a few tips for your (and my) next interview:</p>
<ol>
<li><strong>Don&#8217;t make up stuff on your CV. </strong>Sounds obvious but you&#8217;ll be surprised by how many people list technologies they have barely used on their CV and when asked about it don&#8217;t have a clue. You have no idea how bad this looks. (The red bullshitter light starts flashing in my head instantly)</li>
<li><strong>Show that you have passion for what you do. </strong>Being a Sun certified Java developer is all well and good but when I ask you what you have been looking into recently, or if you&#8217;ve worked on something on your own make sure to have an answer; or, if you don&#8217;t, make sure you have a good excuse.</li>
<li><strong>If you have 1000 years of experience with something I expect you to have some thoughts about it. </strong>Once again, Sun certified Java developer, if I ask you where do you see java going in the next 5 years have an answer! There must be something you think needs improving in Java or that you&#8217;d do differently. I&#8217;ll go wherever Sun takes me is just not an acceptable answer.</li>
<li><strong>Have an opinion! </strong>For God&#8217;s sake have one. I&#8217;ll even settle for half an opinion. If not about a technology you have used for 10 years at least about the coffee I just bought you during the interview. There&#8217;s no point in talking for an hour with somebody who has nothing to tell me other than &#8220;I&#8217;ll do everything you want, I always did.&#8221;</li>
<li><strong>Know what the company you have applied for does! </strong>This sounds stupid but I have called people after 1 week of their application and after 10 minutes with them over the phone I found out that they have no idea what the company they applied at was doing. That&#8217;s an instant goodbye!</li>
<li><strong>Fill the gaps in your CV, and proof-read it before sending it out for goodness sake. </strong>It&#8217;s fine that you have taken one year off to travel the world. If your CV does not list anything for the whole of 2009 I&#8217;m going to ask you about it. Give me a sincere instant answer and there&#8217;ll be no problem. Give me random excuses and it&#8217;s goodbye. As for proof-reading I had somebody applying who had listed &#8220;quick apprehension&#8221; as a skill. I&#8217;m not into hiring failed super-heroes. (I assume they ment quick comprehension)</li>
<li><strong>Apply for jobs you are genuinely interested in. </strong>You are not likely to get a job if your interviewer notices you don&#8217;t give a toss about what you do and who you do it for, and it shows. So Unless you are applying for a position as a nut-packer make sure you&#8217;re going for a job you&#8217;d actually enjoy doing and are interested in.</li>
</ol>
<p>Needless to say my search continues.</p>
<p>After reviewing more than 60 CVs I have almost completely given up on websites such as <a href="http://monster.co.uk" target="_blank">Monster</a> and <a href="http://cwjobs.co.uk" target="_blank">CWJobs</a> and I&#8217;m going to go entirely through connections now.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;submitHeadline=Interviewing+tips&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;title=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;title=Interviewing+tips" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;title=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;bm_description=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;T=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;title=Interviewing+tips" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;title=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Interviewing+tips+@+http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2010%2F08%2Finterviewing-tips%2F&amp;t=Interviewing+tips" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2010/08/interviewing-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decode a GPolyline in Objective-C</title>
		<link>http://sapessi.com/2010/06/decode-a-gpolyline-in-objective-c/</link>
		<comments>http://sapessi.com/2010/06/decode-a-gpolyline-in-objective-c/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 12:54:03 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[My Works]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Encoded]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GPolyline]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=378</guid>
		<description><![CDATA[The new version of MapKit in iOS 4 supports polylines, finally. MKPolyline to be precise. I have been working with the Google Maps API for a while and now I&#8217;m learning Objective-C and writing an iPhone app ro Route.ly Since the best way to send around the net the data to draw a polyline on [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The new version of MapKit in iOS 4 supports <a href="http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GPolyline" target="_blank">polylines</a>, finally. MKPolyline to be precise.</p>
<p>I have been working with the Google Maps API for a while and now I&#8217;m learning Objective-C and writing an iPhone app ro <a href="http://route.ly" target="_blank">Route.ly</a></p>
<p>Since the best way to send around the net the data to draw a polyline on a map is in <a href="http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html" target="_blank">encoded format</a> I decided to write a small Objective-C function to decode the encoded string. Since I couldn&#8217;t find this anywhere on the net I decided to publish the code here.</p>
<p>You&#8217;ll notice that at the beginning of the function I replace &#8220;\\\\&#8221; with &#8220;\\&#8221;. This is because I use the encoded data both in web pages with javascript and my iPhone app. In javascript &#8220;\\&#8221; would be considered an escape and would therefore break my array of points. This is not the case in Objective-C so I switch back to the normal &#8220;\\&#8221;.</p>
<div class="codesnip-container" >
<div class="objc codesnip" style="font-family:monospace;"><span class="sy0">-</span> <span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> <span class="sy0">*</span><span class="br0">&#41;</span> decodePolyline<span class="sy0">:</span><span class="br0">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> <span class="sy0">*</span><span class="br0">&#41;</span>encodedPoints <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> escapedEncodedPoints <span class="sy0">=</span> <span class="br0">&#91;</span>encodedPoints stringByReplacingOccurrencesOfString<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;<span class="es0">\\</span><span class="es0">\\</span>&quot;</span> withString<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;<span class="es0">\\</span>&quot;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> len <span class="sy0">=</span> <span class="br0">&#91;</span>escapedEncodedPoints length<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> waypoints <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/"><span class="kw5">NSMutableArray</span></a> alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> index <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> lat <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> lng <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span>index &lt; len<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">char</span> b;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> shift <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span> result <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b <span class="sy0">=</span> <span class="br0">&#91;</span>escapedEncodedPoints characterAtIndex<span class="sy0">:</span>index<span class="sy0">++</span><span class="br0">&#93;</span> <span class="sy0">-</span> <span class="nu0">63</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result |<span class="sy0">=</span> <span class="br0">&#40;</span>b <span class="sy0">&amp;</span> 0x1f<span class="br0">&#41;</span> &lt;&lt; shift;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shift <span class="sy0">+=</span> <span class="nu0">5</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">while</span> <span class="br0">&#40;</span>b &gt;<span class="sy0">=</span> 0&#215;20<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> dlat <span class="sy0">=</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>result <span class="sy0">&amp;</span> 1<span class="br0">&#41;</span> ? ~<span class="br0">&#40;</span>result &gt;&gt; 1<span class="br0">&#41;</span> <span class="sy0">:</span> <span class="br0">&#40;</span>result &gt;&gt; 1<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lat <span class="sy0">+=</span> dlat;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shift <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span class="sy0">=</span> <span class="nu0">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b <span class="sy0">=</span> <span class="br0">&#91;</span>escapedEncodedPoints characterAtIndex<span class="sy0">:</span>index<span class="sy0">++</span><span class="br0">&#93;</span> <span class="sy0">-</span> <span class="nu0">63</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result |<span class="sy0">=</span> <span class="br0">&#40;</span>b <span class="sy0">&amp;</span> 0x1f<span class="br0">&#41;</span> &lt;&lt; shift;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shift <span class="sy0">+=</span> <span class="nu0">5</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">while</span> <span class="br0">&#40;</span>b &gt;<span class="sy0">=</span> 0&#215;20<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> dlng <span class="sy0">=</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>result <span class="sy0">&amp;</span> 1<span class="br0">&#41;</span> ? ~<span class="br0">&#40;</span>result &gt;&gt; 1<span class="br0">&#41;</span> <span class="sy0">:</span> <span class="br0">&#40;</span>result &gt;&gt; 1<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lng <span class="sy0">+=</span> dlng;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> finalLat <span class="sy0">=</span> lat <span class="sy0">*</span> 1e<span class="sy0">-</span>5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">float</span> finalLong <span class="sy0">=</span> lng <span class="sy0">*</span> 1e<span class="sy0">-</span>5;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Waypoint <span class="sy0">*</span>newPoint <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span>Waypoint alloc<span class="br0">&#93;</span> init<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newPoint.lat <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%f&quot;</span>, finalLat<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newPoint.lng <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span class="kw5">NSString</span></a> alloc<span class="br0">&#93;</span> initWithFormat<span class="sy0">:</span><span class="co3">@</span><span class="st0">&quot;%f&quot;</span>, finalLong<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>waypoints addObject<span class="sy0">:</span>newPoint<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>newPoint release<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> waypoints;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Waypoints is a simple model class I&#8217;ve written with two NSString properties: lat and lng.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;submitHeadline=Decode+a+GPolyline+in+Objective-C&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;title=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;title=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;title=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;bm_description=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;T=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;title=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;title=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Decode+a+GPolyline+in+Objective-C+@+http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2010%2F06%2Fdecode-a-gpolyline-in-objective-c%2F&amp;t=Decode+a+GPolyline+in+Objective-C" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2010/06/decode-a-gpolyline-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>The problem with software patents</title>
		<link>http://sapessi.com/2010/05/the-problem-with-software-patents/</link>
		<comments>http://sapessi.com/2010/05/the-problem-with-software-patents/#comments</comments>
		<pubDate>Sun, 09 May 2010 00:09:38 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[AVC]]></category>
		<category><![CDATA[Engineering]]></category>
		<category><![CDATA[Fred]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Patent]]></category>
		<category><![CDATA[Patents]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Wilson]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=370</guid>
		<description><![CDATA[Brilliant video posted by Fred Wilson on his blog. If you can spare half an hour definitely watch it! Video: Patent Absurdity &#8211; Dokumentarfilm (28:54) Bookmark It]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Brilliant video posted by <a href="http://avc.com" target="_blank">Fred Wilson on his blog</a>.</p>
<p>If you can spare half an hour definitely watch it!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="270" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="AllowScriptAccess" value="always" /><param name="src" value="http://video.golem.de/player/videoplayer.swf?id=3070&amp;autoPl=false" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="270" src="http://video.golem.de/player/videoplayer.swf?id=3070&amp;autoPl=false" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="width: 480px; text-align: center; font-family: verdana,sans-serif; font-size: 0.8em;"><a href="http://video.golem.de/politik-recht/3070/patent-absurdity-dokumentarfilm.html">Video: Patent Absurdity &#8211; Dokumentarfilm</a> (28:54)</div>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;submitHeadline=The+problem+with+software+patents&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;title=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;title=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;title=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;bm_description=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;T=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;title=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;title=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+The+problem+with+software+patents+@+http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2010%2F05%2Fthe-problem-with-software-patents%2F&amp;t=The+problem+with+software+patents" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2010/05/the-problem-with-software-patents/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Draggable directions with Google Maps APIs</title>
		<link>http://sapessi.com/2010/03/draggable-directions-with-google-maps-apis/</link>
		<comments>http://sapessi.com/2010/03/draggable-directions-with-google-maps-apis/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 11:51:20 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[My Works]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WWW]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Directions]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Maps]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=358</guid>
		<description><![CDATA[I love calculating driving directions on Google Maps and then drag the blue line marking my directions to change the route. Everything is updated automatically on the page and the directions are re-calculated to go through the new point I defined. I&#8217;ve been playing around with the Google Maps APIs recently and imagine my disappointment [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I love calculating driving directions on Google Maps and then drag the blue line marking my directions to change the route. Everything is updated automatically on the page and the directions are re-calculated to go through the new point I defined.</p>
<p>I&#8217;ve been playing around with the <a href="http://code.google.com/apis/maps/" target="_blank">Google Maps APIs</a> recently and imagine my disappointment when I found out that Google does not allow directions calculated through the APIs to be dragged around.</p>
<p>Not put off by this I decided to try and replicate the directions-dragging myself. How hard can it be?<br />
As it turns out. Very, at least if you want to make it look as smooth as Google&#8217;s own solution.</p>
<p>When generating directions Google Maps adds a <a href="http://code.google.com/apis/maps/documentation/reference.html#GPolyline" target="_blank">GPolyline</a> element overlay to your map. You can set the returned line to be editable but this makes an awful lot of vertices appear on it, which makes reading your directions quite hard. Even so, once you dragged one of this vertices around you are not editing the route but just changing the shape of the line.</p>
<p>Mine is not a complete solution and I&#8217;m interested in feedback and ideas on how to improve it.</p>
<p>First off calculate your directions:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">map <span class="sy0">=</span> <span class="kw2">new</span> google.<span class="me1">maps</span>.<span class="me1">Map2</span><span class="br0">&#40;</span>document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&#8216;map_canvas&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw2">var</span> wayPoints <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
wayPoints.<span class="me1">push</span><span class="br0">&#40;</span>startPoint.<span class="me1">getLatLng</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
wayPoints.<span class="me1">push</span><span class="br0">&#40;</span>endPoint.<span class="me1">getLatLng</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="kw2">var</span> myDir <span class="sy0">=</span> <span class="kw2">new</span> google.<span class="me1">maps</span>.<span class="me1">Directions</span><span class="br0">&#40;</span>map<span class="br0">&#41;</span><br />
myDir.<span class="me1">loadFromWaypoints</span><span class="br0">&#40;</span>wayPoints<span class="sy0">,</span> <span class="br0">&#123;</span> travelMode<span class="sy0">:</span> G_TRAVEL_MODE_DRIVING <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>This will calculate your driving directions and plot a GPolyline on your map. The line is easily accessible in the GDirections object once the directions are calculated. To intercept this I have decided to use the <strong>addoverlay</strong> event on the GMap object. This event is triggered every time something is plotted over the map (says on the tin).</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">google.<span class="me1">maps</span>.<span class="me1">Event</span>.<span class="me1">addListener</span><span class="br0">&#40;</span>myDir<span class="sy0">,</span> <span class="st0">&quot;addoverlay&quot;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">var</span> dirLine <span class="sy0">=</span> myDir.<span class="me1">getPolyline</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">// Get the polyline from the directions object</span><br />
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>At this point we can ask the APIs to make the GPolyline editable. This will make the vertices appear on the line and make then draggable. As I said before this only changes the shape of the line and doesn&#8217;t actually affect your directions object. Luckily the GPolyline comes with a nifty event called <strong>lineupdated</strong>.<br />
This is triggered once the user has finished dragging a vertex. By intercepting this we can look through the vertices and know what&#8217;s been changed on the line and where the vertex has been moved to.<br />
In order to do this we must also know the previous position of the vertices (latitude and longitude) to be able to compare the old and the new &#8220;edited&#8221; line.<br />
Another challenge is the fact that the <a href="http://code.google.com/apis/maps/documentation/reference.html#GDirections" target="_blank">GDirections</a> object can accept only so many waypoints (25 if I&#8217;m not wrong). Which means we&#8217;ll have to add only the vertex that has changed to the directions and not all of them.</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="co1">// In the addoverlay event also save the original vertices of the line</span><br />
<span class="kw2">var</span> origLine <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&amp;</span>lt<span class="sy0">;</span> dirLine.<span class="me1">getVertexCount</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
origLine.<span class="me1">push</span><span class="br0">&#40;</span>dirLine.<span class="me1">getVertex</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="co1">// DONE saving vertices</span></p>
<p><span class="co1">// Now intercept the lineupdated event and add the new waypoints</span><br />
google.<span class="me1">maps</span>.<span class="me1">Event</span>.<span class="me1">addListener</span><span class="br0">&#40;</span>dirLine<span class="sy0">,</span> <span class="st0">&quot;lineupdated&quot;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
routePoints <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
<span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw2">var</span> i <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> i <span class="sy0">&amp;</span>lt<span class="sy0">;</span> dirLine.<span class="me1">getVertexCount</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span> i<span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">var</span> savedPoint <span class="sy0">=</span> origLine<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="sy0">;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>savedPoint <span class="sy0">||</span> <span class="br0">&#40;</span>savedPoint.<span class="me1">lat</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">!=</span> dirLine.<span class="me1">getVertex</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="me1">lat</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;&amp;</span>amp<span class="sy0">;</span> savedPoint.<span class="me1">lng</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">!=</span> dirLine.<span class="me1">getVertex</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="me1">lng</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
routePoints.<span class="me1">push</span><span class="br0">&#40;</span>dirLine.<span class="me1">getVertex</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="co1">// Now we remove the previous directions and recalculate the route</span><br />
map.<span class="me1">removeOverlay</span><span class="br0">&#40;</span>dirLine<span class="br0">&#41;</span><br />
calcRoute<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>This works quite well but does not look as smooth as Google&#8217;s solution.<br />
The problem is that while you are dragging a vertex only that bit of the GPolyline moves and the rest stays in its original position. which makes the shape of your directions quite awkward while you are dragging. Unforunately the GPolyline does not come with a &#8220;startdragging&#8221; event, otherwise we could just recalculate the route every few seconds while the vertex is being dragged.</p>
<p>This is not the most elegant of solutions but it does the job.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;submitHeadline=Draggable+directions+with+Google+Maps+APIs&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;title=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;title=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;title=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;bm_description=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;T=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;title=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;title=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Draggable+directions+with+Google+Maps+APIs+@+http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2010%2F03%2Fdraggable-directions-with-google-maps-apis%2F&amp;t=Draggable+directions+with+Google+Maps+APIs" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2010/03/draggable-directions-with-google-maps-apis/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Want to be a programmer in an investment bank?</title>
		<link>http://sapessi.com/2009/11/want-to-be-a-programmer-in-an-investment-bank/</link>
		<comments>http://sapessi.com/2009/11/want-to-be-a-programmer-in-an-investment-bank/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 10:45:20 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=346</guid>
		<description><![CDATA[What do you need to know? Java Enterprise Edition. That&#8217;s the simple answer. If you read between the lines what I&#8217;m really saying is: &#8220;You better make sure you really don&#8217;t give a flying toss about technology and don&#8217;t care about how frustrating what you spend most of your day doing is.&#8221; A few days [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>What do you need to know? Java Enterprise Edition. That&#8217;s the simple answer.<br />
If you read between the lines what I&#8217;m really saying is: &#8220;You better make sure you really don&#8217;t give a flying toss about technology and don&#8217;t care about how frustrating what you spend most of your day doing is.&#8221;</p>
<p>A few days ago I was talking with a friend who&#8217;s in the process of interviewing with a few big financial institutions in London. The most common questions according to him. <a href="http://struts.apache.org/" target="_blank">Struts</a>, <a href="http://java.sun.com/javaee/technologies/javaee5.jsp" target="_blank">JEE</a>.<br />
<a href="http://www.springsource.org/" target="_blank"> Spring</a> was also mentioned by I don&#8217;t have much against Spring. If used properly it really does keep your code tidy and avoids duplication.</p>
<p>You see a bank&#8217;s idea of a high performance reliable system is a monolithic Java application running a million-billion threads at the same time on a huge machine. Maybe that&#8217;s a bit too harsh. Sometimes they do distribute. They just add 15 layers shooting messages at each other in between the 2 they actually need.<br />
Then they wonder why the best talent winds up working for Google, and their budget to deliver 1 application is twice what Facebook spent to build its entire social network.</p>
<p>What I have a problem with is the architects who design these systems. And the clearly-drunken bank managers who hired them.</p>
<p><img class="alignright size-full wp-image-350" title="Dumb and Dumber" src="http://sapessi.com/wp-content/uploads/2009/11/dumb-and-dumber3.jpg" alt="Dumb and Dumber" width="300" height="209" />The most common profile for architects in investment banks (and I met quite a few) is 50-something, stopped following/reading about technology in 1995 and prior to being employed by Mr Mighty WankBank (Thanks <a href="http://www.cityboy.biz/" target="_blank">City Boy</a> for the name) was VP of over-engineering at the Apache Software Foundation (focused on Struts).<br />
First thing in their TODO list is hire some bright spark straight out of university who has a keen interest in over-engineering and never had to deliver anything in less than a geological era.<br />
That&#8217;s when an overpaid team of consultants comes in to &#8220;sort-it-out&#8221;, at which point the bank loses control over its source-code and none of their developers can understand it any more.</p>
<p>Oh, and then there&#8217;s the process, oh the bureaucracy.</p>
<p>Fortunately I also know that in London there are a few sunny spots (techonology-wise) such as Hedge funds who started using Erlang (for example) to distribute their heavy computations over a network.</p>
<p>Now don&#8217;t get me wrong I have nothing against JEE per-se. Some of the libraries are actually very useful and improve a developer&#8217;s quality of life quite a lot. Just think about <a href="http://java.sun.com/javaee/technologies/jta/index.jsp" target="_blank">JTA</a>.<br />
What is wrong is the way they are used by people who never left the nineties.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;submitHeadline=Want+to+be+a+programmer+in+an+investment+bank%3F&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;title=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;title=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;title=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;bm_description=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;T=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;title=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;title=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Want+to+be+a+programmer+in+an+investment+bank%3F+@+http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fwant-to-be-a-programmer-in-an-investment-bank%2F&amp;t=Want+to+be+a+programmer+in+an+investment+bank%3F" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2009/11/want-to-be-a-programmer-in-an-investment-bank/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Server side JavaScript with node.js</title>
		<link>http://sapessi.com/2009/11/server-side-javascript-with-node-js/</link>
		<comments>http://sapessi.com/2009/11/server-side-javascript-with-node-js/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 17:01:12 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[V8]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=337</guid>
		<description><![CDATA[While skimming through my RSS feed I stumbled upon an interesting article on Ajaxian about server side JavaScript programming. I really, really enjoy writing JavaScript code so I decided to read through the article and take a look at the node.js library linked there. Node is a framework to build server-side event-driven JavaScript applications. Developed [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>While skimming through my RSS feed I stumbled upon an interesting <a href="http://ajaxian.com/archives/full-frontal-09-simon-willison-on-server-side-javascript-and-node-js" target="_blank">article on Ajaxian about server side JavaScript programming</a>.</p>
<p>I really, really enjoy writing JavaScript code so I decided to read through the article and take a look at the <a href="http://nodejs.org/" target="_blank">node.js library linked there</a>.</p>
<p><a href="http://nodejs.org" target="_blank"><img class="aligncenter size-full wp-image-339" title="node.js logo" src="http://sapessi.com/wp-content/uploads/2009/11/node_js_logo.jpg" alt="node.js logo" width="293" height="90" /></a></p>
<p>Node is a framework to build server-side event-driven JavaScript applications. Developed in C++ on top of <a href="http://en.wikipedia.org/wiki/V8_%28JavaScript_engine%29" target="_blank">Google&#8217;s V8 JavaScript engine</a> and accompanied by a set of JavaScript libraries Node seems to make building distributed (over a network), fast applications a piece of cake even for inexperienced developers.<br />
Event-driven here really is the keyword because it represent a big change in the way applications are built (and architected in your brain).</p>
<blockquote><p>Node is similar in design to and influenced by systems like Ruby&#8217;s <a href="http://rubyeventmachine.com/">Event Machine</a> or Python&#8217;s <a href="http://twistedmatrix.com/">Twisted</a>.  Node takes the event         model a bit further—it presents the event loop as a language         construct instead of as a library. In other systems there is always         a blocking call to start the event-loop.  Typically one defines         behavior through callbacks at the beginning of a script and at the         end starts a server through a blocking call like
<div class="codesnip-container" >EventMachine<span>::</span><span>run</span><span>()</span></div>
<p>. In Node there is no such         start-the-event-loop call.  Node simply enters the event loop after         executing the input script.</p></blockquote>
<p>The example below (taken from Node&#8217;s website) will make everything clear&#8230; hopefully.</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="kw2">var</span> sys <span class="sy0">=</span> require<span class="br0">&#40;</span><span class="st0">&#8216;sys&#8217;</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp;http <span class="sy0">=</span> require<span class="br0">&#40;</span><span class="st0">&#8216;http&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>http.<span class="me1">createServer</span><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span>req<span class="sy0">,</span> res<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; setTimeout<span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; res.<span class="me1">sendHeader</span><span class="br0">&#40;</span><span class="nu0">200</span><span class="sy0">,</span> <span class="br0">&#123;</span><span class="st0">&#8216;Content-Type&#8217;</span><span class="sy0">:</span> <span class="st0">&#8216;text/plain&#8217;</span><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; res.<span class="me1">sendBody</span><span class="br0">&#40;</span><span class="st0">&#8216;Hello World&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; res.<span class="me1">finish</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><span class="sy0">,</span> 2000<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>.<span class="me1">listen</span><span class="br0">&#40;</span>8000<span class="br0">&#41;</span><span class="sy0">;</span><br />
sys.<span class="me1">puts</span><span class="br0">&#40;</span><span class="st0">&#8216;Server running at http://127.0.0.1:8000/&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>Can you see the beauty?!</p>
<p>I have only one worry. This is an open-source effort. The community behind it on Google groups is just 181 members strong (so far). What if node.js suddenly stops being the cool thing and the community disappears.</p>
<p>As much as I love writing JavaScript and I can really see the value in what they are building I&#8217;ll still wait until there are 100 Google Groups for node.js and a trillion members in each before using it in anything close to a production system.</p>
<p>Having said that I&#8217;m going back to writing silly node.js apps now. Well done to all the developers involved in the project and keep it up!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;submitHeadline=Server+side+JavaScript+with+node.js&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;title=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;title=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;title=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;bm_description=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;T=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;title=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;title=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Server+side+JavaScript+with+node.js+@+http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fserver-side-javascript-with-node-js%2F&amp;t=Server+side+JavaScript+with+node.js" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2009/11/server-side-javascript-with-node-js/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>SVG graphics with JavaScript</title>
		<link>http://sapessi.com/2009/11/svg-graphics-with-javascript/</link>
		<comments>http://sapessi.com/2009/11/svg-graphics-with-javascript/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 13:47:03 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[My Works]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[WWW]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RaphaelJS]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[TweetSentiment]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=327</guid>
		<description><![CDATA[When I started developing TweetSentiment I decided that the interface should have as little text as possible. Most of the information I was interested in could be displayed graphically, with a chart. So I looked at all the options available for chart generation. Backend code to generate a static image (JFreeChart or PHP) Flash object [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When I started developing <a href="http://tweetsentiment.info" target="_blank">TweetSentiment</a> I decided that the interface should have as little text as possible. Most of the information I was interested in could be displayed graphically, with a chart.</p>
<p>So I looked at all the options available for chart generation.</p>
<ol>
<li>Backend code to generate a static image (<a href="http://www.jfree.org/jfreechart/" target="_blank">JFreeChart</a> or PHP)</li>
<li>Flash object to draw a chart retrieving the data from a URL</li>
<li>Draw charts in JavaScript directly on the client&#8217;s browser</li>
</ol>
<p>I&#8217;m not a huge fan of option one. Primarily because TweetSentiment is hosted on a tiny linux box which would not be able to handle the load for the traffic the site gets, also because it&#8217;s a static image &#8211; it&#8217;s just not very funky &#8211; no interaction possible.</p>
<p>Option two would certainly create spectacular looking charts but I have almost no experience with flash and I wasn&#8217;t about to start learning a new language/technology. Plus I&#8217;m not into browser plugins if I can avoid them.</p>
<p>JavaScript is a language I&#8217;m familiar with and I remember seeing some cool-looking charts generated with <a href="http://www.dojotoolkit.org/" target="_blank">Dojo</a>. Unfortunately for TweetSentiment I have used jquery since the most important thing for me there was DOM manipulation (and jquery is just better for that).<br />
I then started shopping around for <a href="http://jquery.com/" target="_blank">jQuery</a> plugins to generate charts. There are a few around but none of them impressed me. They just weren&#8217;t as good looking as I&#8217;d hoped nor they were interactive.</p>
<p>By coincidence I stumbled on <a href="http://raphaeljs.com/" target="_blank">RaphaelJS</a>. A JavaScript library to draw <a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics" target="_blank">Scalable Vector Graphics</a> directly from JavaScript based on jQuery. I tested the samples on the website with a few browsers and I was happy to discover it worked just fine with all of them.</p>
<blockquote>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;"><strong>Scalable Vector Graphics</strong> (<strong>SVG</strong>) is a family of specifications of an <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="XML" href="/wiki/XML">XML</a>-based <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="File format" href="/wiki/File_format">file format</a> for describing two-dimensional <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="Vector graphics" href="/wiki/Vector_graphics">vector graphics</a>, both static and dynamic (i.e. interactive or <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="SVG animation" href="/wiki/SVG_animation">animated</a>).</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">The SVG specification is an <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="Open standard" href="/wiki/Open_standard">open standard</a> that has been under development by the <a style="text-decoration: none; color: #002bb8; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: initial initial; background-repeat: initial initial;" title="World Wide Web Consortium" href="/wiki/World_Wide_Web_Consortium">World Wide Web Consortium</a> (W3C) since 1999.</p>
</blockquote>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">I also discovered that there is a <a href="http://g.raphaeljs.com/" target="_blank">charting library built on top of RaphaelJS</a>, which is exactly what I was looking for. However, being a geek, I decided to go ahead and try to develop something on my own. You know, just for kicks.</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">As I delved deeper into RaphaelJS I found the library to be incredibly powerful. It&#8217;s a shame that the <a href="http://raphaeljs.com/reference.html" target="_blank">documentation provided on the website</a> lets it down a bit.<br />
The most powerful bit is the ability to extend objects and attach new functions to them. Something scarcely mentioned in the available documentation.</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">For example if you need to use curved lines (paths as SVG calls them) you can just defined a default function you can then call from your code simply by adding it to the <strong>el </strong>&#8220;object&#8221; in RaphaelJS</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">Raphael.<span class="me1">el</span>.<span class="me1">curveTo</span> <span class="sy0">=</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> args <span class="sy0">=</span> Array.<span class="me1">prototype</span>.<span class="me1">splice</span>.<span class="me1">call</span><span class="br0">&#40;</span>arguments<span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> arguments.<span class="me1">length</span><span class="br0">&#41;</span><span class="sy0">,</span><br />
&nbsp; d <span class="sy0">=</span> <span class="br0">&#91;</span><span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="st0">&quot;s&quot;</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="st0">&quot;c&quot;</span><span class="br0">&#93;</span><span class="br0">&#91;</span>args.<span class="me1">length</span><span class="br0">&#93;</span> <span class="sy0">||</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">this</span>.<span class="me1">isAbsolute</span> <span class="sy0">&amp;</span>amp<span class="sy0">;&amp;</span>amp<span class="sy0">;</span> <span class="br0">&#40;</span>d <span class="sy0">=</span> d.<span class="me1">toUpperCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">this</span>._last <span class="sy0">=</span> <span class="br0">&#123;</span>x<span class="sy0">:</span> args<span class="br0">&#91;</span>args.<span class="me1">length</span> <span class="sy0">-</span> 2<span class="br0">&#93;</span><span class="sy0">,</span> y<span class="sy0">:</span> args<span class="br0">&#91;</span>args.<span class="me1">length</span> <span class="sy0">-</span> 1<span class="br0">&#93;</span><span class="br0">&#125;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="br0">&#123;</span>path<span class="sy0">:</span> <span class="kw1">this</span>.<span class="me1">attrs</span>.<span class="me1">path</span> <span class="sy0">+</span> d <span class="sy0">+</span> args<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="sy0">;</span></div>
</div>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">Another very useful function I found in one of their samples is the <strong>andClose() </strong>This is used to close a polygon you have started drawing with paths. No matter where you got to it will reconnect to the initial point.</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">Raphael.<span class="me1">el</span>.<span class="me1">andClose</span> <span class="sy0">=</span> <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">attr</span><span class="br0">&#40;</span><span class="br0">&#123;</span>path<span class="sy0">:</span> <span class="kw1">this</span>.<span class="me1">attrs</span>.<span class="me1">path</span> <span class="sy0">+</span> <span class="st0">&quot;z&quot;</span><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="sy0">;</span></div>
</div>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">This can then be used this way using <a href="http://ejohn.org/blog/ultra-chaining-with-jquery/" target="_blank">chaining</a>.</p>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">RaphaelJSElement.<span class="me1">lineTo</span><span class="br0">&#40;</span>x<span class="sy0">,</span> opts.<span class="me1">height</span> <span class="sy0">-</span> bottomgutter<span class="br0">&#41;</span>.<span class="me1">andClose</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p style="margin-top: 0.4em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; line-height: 1.5em;">I&#8217;m still developing the chart library I used in TweetSentiment and I&#8217;m planning to publish it here with some documentation under MIT licence.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;submitHeadline=SVG+graphics+with+JavaScript&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;title=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;title=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;title=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;bm_description=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;T=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;title=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;title=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+SVG+graphics+with+JavaScript+@+http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fsvg-graphics-with-javascript%2F&amp;t=SVG+graphics+with+JavaScript" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2009/11/svg-graphics-with-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Go</title>
		<link>http://sapessi.com/2009/11/google-go/</link>
		<comments>http://sapessi.com/2009/11/google-go/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 15:10:10 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[General Babbling]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Distributed]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[multi-process]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=315</guid>
		<description><![CDATA[I have just stumbled on an article on Slashdot about Google Go. A programming language which was initially developed internally and it&#8217;s now been open-sourced. Over the past few months I have been working with Erlang on multi-process distributed systems. Concurrency in Go is based on the same model Erlang uses: Hoare&#8217;s Communicating Sequential Processes, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I have just stumbled on an <a href="http://developers.slashdot.org/story/09/11/11/0210212/Go-Googles-New-Open-Source-Programming-Language?from=rss" target="_blank">article on Slashdot about Google Go</a>. A programming language which was initially developed internally and it&#8217;s now been open-sourced.</p>
<p>Over the past few months I have been working with Erlang on multi-process distributed systems. Concurrency in <a href="http://golang.org/" target="_blank">Go</a> is based on the same model Erlang uses: Hoare&#8217;s Communicating Sequential Processes, or <a href="http://golang.org/doc/go_lang_faq.html#csp" target="_blank">CSP</a>.</p>
<blockquote><p>Go&#8217;s concurrency primitives derive from a different part of the family tree whose main contribution is the powerful notion of channels as first class objects.</p></blockquote>
<p>The thing I appreciate the most of Erlang is how easy it is to distribute &#8211; even over a network &#8211; and monitor processes. After skimming through Go&#8217;s documentation I couldn&#8217;t help but notice the lack of integrated network-distribution of processes or goroutines, as they are called.</p>
<p><span style="background-color: #ffffff;">This for me means that while Go, exactly like Erlang and Occam, simplifies the approach to multi-threaded programming (at least from a developer&#8217;s point of view), it doesn&#8217;t go all the way and leaves developers to deal with distribution of processes over a network on their own.</span></p>
<p>This is a perfectly acceptable design choice in the name of flexibility, however it creates a whole new bunch of use cases for the developers to deal with, such as sending channels/channels-data over the network).</p>
<p>What I don&#8217;t like of Erlang is its handling of strings, which makes it unsuitable for a number of application that could benefit greatly from its multi-processing capabilities. Very few people would recommend Erlang as a high performance string manipulation language. T<span style="background-color: #ffffff;">o quote Sendmail&#8217;s case study in implementing their Sendmail load balancing &#8220;Client Daemon&#8221; in Erlang:</span></p>
<blockquote>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; display: block; unicode-bidi: embed;">&#8230;But Erlang&#8217;s treatment of strings as lists of bytes is as elegant as it is impractical. The factor-of-eight storage expansion of text, as well as the copying that occurs during message-passing, cripples Erlang for all but the most performance-insensitive text-processing applications.</p>
</blockquote>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; display: block; unicode-bidi: embed;">Go totally wins on this.</p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; display: block; unicode-bidi: embed;">If you now asked me to pick one to use. I&#8217;d still go for Erlang.<br />
<span style="background-color: #ffffff;">Functional languages and CSP are changing the way big companies approach the development of business critical applications. In the last year alone I have seen the number of positions advertised for Erlang developers in the financial sector multiply.<br />
Go, if it continues on this path definitely has a chance of making it there. Open-sourcing the language is the right decision to give it the exposure to real-life scenarios that tend to accelerate the growth and adoption rate. </span></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;submitHeadline=Google+Go&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;title=Google+Go" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;title=Google+Go" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;title=Google+Go" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;bm_description=Google+Go" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;T=Google+Go" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;title=Google+Go" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;title=Google+Go" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Google+Go+@+http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Fgoogle-go%2F&amp;t=Google+Go" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2009/11/google-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TweetSentiment &#8211; Twitter activity VS market activity</title>
		<link>http://sapessi.com/2009/11/tweetsentiment-twitter-activity-vs-market-activity/</link>
		<comments>http://sapessi.com/2009/11/tweetsentiment-twitter-activity-vs-market-activity/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 18:30:47 +0000</pubDate>
		<dc:creator>Stefano Buliani</dc:creator>
				<category><![CDATA[My Works]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Market]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[StockTwits]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://sapessi.com/?p=307</guid>
		<description><![CDATA[Perhaps I&#8217;m bored. Maybe I&#8217;m just too single. Anyway. A couple of days ago I was looking at StockTwits again and saw a considerable amount of activity. There and then I decided that it would have been pretty cool to check whether there was any correlation between the activity about a stock on Twitter and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;source=sapessi&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Perhaps I&#8217;m bored. Maybe I&#8217;m just too single.<br />
Anyway. A couple of days ago I was looking at <a href="http://stocktwits.com/" target="_blank">StockTwits</a> again and saw a considerable amount of activity. There and then I decided that it would have been pretty cool to check whether there was any correlation between the activity about a stock on Twitter and the actual trading volume on the market.</p>
<p>I set off to build a small system to do just that. A couple of <a href="http://groovy.codehaus.org/" target="_blank">groovy scripts</a> to collect the data and save it plus some JavaScript and HTML to display it.</p>
<p>So here I am a couple of days later talking about <a href="http://tweetsentiment.info" target="_blank">TweetSentiment</a>.</p>
<p>Collecting the data I needed was pretty trivial thanks to the fact that StockTwits asks all its members to tweet the symbols they are trading preceded by a dollar sign ($).<br />
My first task was to build a list of securities I was interested in. I decided to go to <a href="http://www.covestor.com" target="_blank">Covestor.com</a> and pick the most traded securities list.  Once that list was ready all I had to do was call the <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method:-search" target="_blank">Twitter Search APIs</a> for each stock and store the results.<br />
Groovy made these tasks incredibly simple.</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;">def output <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aurl+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">URL</span></a><span class="br0">&#40;</span><span class="st0">&quot;http://search.twitter.com/search.atom?q=${&quot;</span>\$<span class="st0">&quot;+curSecurity.symbol}&amp;amp;rpp=100&quot;</span><span class="br0">&#41;</span>.<span class="me1">getText</span><span class="br0">&#40;</span><span class="br0">&#41;</span></p>
<p>def parsedXml <span class="sy0">=</span> <span class="kw1">new</span> XmlParser<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">parseText</span><span class="br0">&#40;</span>output<span class="br0">&#41;</span></p>
<p>parsedXml.<span class="me1">entry</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> curEntry <span class="sy0">-&amp;</span>gt<span class="sy0">;</span><br />
&#8230;</div>
</div>
<p>I&#8217;m not doing much with the tweets. At the moment I just count them and look for &#8220;buy&#8221; and &#8220;sell&#8221;. I&#8217;m looking into smarter ways of analysing the text and look for positive/negative opinions. If you have any suggestion on this please do leave a comment.</p>
<p>Next in my TODO list was getting some market data. For that I&#8217;m using Yahoo finance asking for previous closing price and average volume for each security. Once again, piece of cake with Groovy. Same thing as before just different URL.<br />
Yahoo finance actually has quite a simple interface to let you grab the data. Check out this page on <a href="http://cliffngan.net/a/13" target="_blank">Cliff&#8217;s Notes</a>.</p>
<p>Now I had all the data I needed. Only thing left was to build some sort of interface to look at it. I wanted to display all of the data on a chart to be able to make sense of it as quickly as possible.<br />
My server (i.e. the machine running this blog) with its puny power could have never handled the traffic I get while generating charts. Therefore what I decided to do is to export all the data in text files (JSON format) and do all of the chart generation with JavaScript.</p>
<p>I browsed the web for a bit looking for charting components for <a href="http://jquery.com/" target="_blank">jQuery</a>. Couldn&#8217;t find anything I was happy with. Not functionality-wise but aesthetically. Or maybe I just felt like playing around with JS for some time &#8211; unfortunately as it often happens with JS I spent the best part of the last 2 days working on it.</p>
<p>I decided to use a library called <a href="http://raphaeljs.com/index.html" target="_blank">Raphaël</a>. This library makes working with vector graphics incredibly simple and the results just look amazing. I know that they are in the process of building a <a href="http://g.raphaeljs.com/" target="_blank">charting library on top of it</a> however&#8230; well I have no excuse now other than I wanted to work with JS.</p>
<p>What I did is build a very simple jQuery component called SAPchart. It only draws line charts but it&#8217;s quite simple and I think the results look pretty good.</p>
<p>You can download the <a href="http://sapessi.com/tweetsentiment/js/SAPchart.js" target="_blank">source here</a>. It requires jQuery, <a href="http://raphaeljs.com/index.html" target="_blank">Raphaël</a>, and <a href="http://sapessi.com/tweetsentiment/js/raphael.path.methods.js" target="_blank">raphael path methods</a>.</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="co1">// Constructor. Possible options are:</span><br />
<span class="co1">// showGrid: true</span><br />
<span class="co1">// width: 800</span><br />
<span class="co1">// height: 250</span><br />
<span class="co1">// legendWidth: 200</span><br />
<span class="co1">// showLabels: true</span><br />
<span class="co1">// showDots: true</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">SAPchart</span><span class="br0">&#40;</span><span class="br0">&#123;</span>legendWidth<span class="sy0">:</span> 800<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// Give the library a list of labels for the x axis</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">setLabels</span><span class="br0">&#40;</span>theLabels<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// Add to the chart as many series as you want &#8211; provided the length of the series is</span><br />
<span class="co1">// the same of the labels (quite unsophisticated but serves its purpose)</span><br />
<span class="co1">// array of values, unique id of the series, legend name, additional options)</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">addSeries</span><span class="br0">&#40;</span>theTweets<span class="sy0">,</span> <span class="st0">&quot;tweet&quot;</span><span class="sy0">,</span> <span class="st0">&quot;Twitter Activity&quot;</span><span class="sy0">,</span> <span class="br0">&#123;</span> <span class="st0">&quot;color&quot;</span><span class="sy0">:</span> <span class="br0">&#91;</span>.6<span class="sy0">,</span> 1<span class="sy0">,</span> .75<span class="br0">&#93;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">addSeries</span><span class="br0">&#40;</span>theVolumes<span class="sy0">,</span> <span class="st0">&quot;volume&quot;</span><span class="sy0">,</span> <span class="st0">&quot;Average Daily Volume&quot;</span><span class="sy0">,</span> <span class="br0">&#123;</span> <span class="st0">&quot;color&quot;</span><span class="sy0">:</span> <span class="br0">&#91;</span>.2<span class="sy0">,</span> 1<span class="sy0">,</span> .75<span class="br0">&#93;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="co1">// Draws the chart in your html element</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">draw</span><span class="br0">&#40;</span><span class="br0">&#41;</span></p>
<p><span class="co1">// This will return an HTML table containing the legend of all the series you specified</span><br />
<span class="co1">// the boolean parameter tells me whether you want your legend to be horizontal (default vertical)</span><br />
$<span class="br0">&#40;</span><span class="st0">&quot;#holder&quot;</span><span class="br0">&#41;</span>.<span class="me1">getLegend</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span>.<span class="me1">appendTo</span><span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="st0">&quot;#legend&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>I&#8217;m now wondering whether I should keep working on it and improve it.</p>
<p>Anyway <a href="http://sapessi.com/tweetsentiment/" target="_blank">TweetSentiment is now available here</a>. I&#8217;m planning to keep it running and collecting data for a while. I&#8217;d say you need at least 3/4 months worth of data before you can make any useful observations.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;submitHeadline=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;title=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;title=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;title=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;bm_description=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;T=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;title=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;title=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity+@+http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fsapessi.com%2F2009%2F11%2Ftweetsentiment-twitter-activity-vs-market-activity%2F&amp;t=TweetSentiment+%26%238211%3B+Twitter+activity+VS+market+activity" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://sapessi.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://sapessi.com/2009/11/tweetsentiment-twitter-activity-vs-market-activity/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

