<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>/* No Comments */</title>
	<atom:link href="http://panyam.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://panyam.wordpress.com</link>
	<description>About technology, a few hacks and the violin!</description>
	<lastBuildDate>Thu, 06 Oct 2011 09:33:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='panyam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>/* No Comments */</title>
		<link>http://panyam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://panyam.wordpress.com/osd.xml" title="/* No Comments */" />
	<atom:link rel='hub' href='http://panyam.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Cyginstall &#8211; The Stateful Cygwin Installer</title>
		<link>http://panyam.wordpress.com/2011/02/18/stateful-cygwin-installer/</link>
		<comments>http://panyam.wordpress.com/2011/02/18/stateful-cygwin-installer/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 04:51:38 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=111</guid>
		<description><![CDATA[Hands up those who have tried installing cygwin on windows only to have the damn installer not completely downloading sources or you found that by selecting multiple mirrors, the installer would just get stuck on a slow or buggy mirror? Well back up a bit. Hands up those who were *forced* to use windows and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=111&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hands up those who have tried installing cygwin on windows only to have the damn installer not completely downloading sources or you found that by selecting multiple mirrors, the installer would just get stuck on a slow or buggy mirror?</p>
<p>Well back up a bit.</p>
<p>Hands up those who were *forced* to use windows and hence had to install cygwin?</p>
<p>Me and me again!</p>
<p>At work I am on a windoze box while having to ssh into a linux box to do my development (let us not go there).  Luckily cygwin has helped me in the past but only because I managed to complete the installations out of sheer luck.   For some reason (may be limited intelligence) I could not select the fastest or the most reliable mirror and the installations kept bombing out after hours of what seemed like progress.  Seems wierd but I would have thought the cygwin mirror seeing what files it had already downloaded would have helped.  But no such luck (was it some option I missed)?</p>
<p>So I decided to write a downloader myself (you would still have to call the cygwin setup tool to install the sources).  It HAD to be stateful.  You interrupt it at any point and it should continue where it left of.  So out of that came <a title="Stateful Cygwin Installer" href="https://github.com/panyam/cyginstall" target="_blank">cyginstall</a>.</p>
<p>It also has a few other goodies:</p>
<ol>
<li>Multi threaded (defaults to 5)</li>
<li>Web based UI</li>
<li>Easily select or deselect mirrors</li>
<li>Works through proxy with NTLM authentication.</li>
<li>Better reporting of download status and mirror health.</li>
</ol>
<p>So please give it a go and let me know what you think.  I managed to do a whole download but that does not mean there are no bugs so would appreciate it if you could let me know of any and all issues that need fixing.</p>
<p>Also the UI is very drab.  Very basic but drab, so any help or advice there would be gold.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=111&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2011/02/18/stateful-cygwin-installer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://panyam.wordpress.com/2011/01/02/2010-in-review/</link>
		<comments>http://panyam.wordpress.com/2011/01/02/2010-in-review/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 05:53:12 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=108</guid>
		<description><![CDATA[Have to say. Pretty impressed with wordpress&#8217;s &#8220;summary&#8221; feature/email/view etc..  I wonder if me lazily posting this back as a post actually counts as a post?  In which case this is my first for the year &#8211; happy new year all! &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; The stats helper monkeys at WordPress.com mulled over how this blog did in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=108&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Have to say. Pretty impressed with wordpress&#8217;s &#8220;summary&#8221; feature/email/view etc..  I wonder if me lazily posting this back as a post actually counts as a post?  In which case this is my first for the year &#8211; happy new year all!</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy2.gif" alt="Healthy blog!" width="250" height="183" /></p>
<p>The <em>Blog-Health-o-Meter™</em> reads This blog is doing awesome!.</p>
<h2>Crunchy numbers</h2>
<div style="width:288px;float:right;border:1px solid #ddd;background:#fff;margin:0 0 1em 1em;padding:6px;">
<p><img src="http://s0.wp.com/i/annual-recap/abstract-stats-5.png" alt="Featured image" /></p>
<p><em>A helper monkey made this abstract painting, inspired by your stats.</em></p>
</div>
<p>A Boeing 747-400 passenger jet can hold 416 passengers.  This blog was viewed about <strong>4,000</strong> times in 2010.  That&#8217;s about 10 full 747s.</p>
<p>&nbsp;</p>
<p>In 2010, there were <strong>5</strong> new posts, growing the total archive of this blog to 42 posts.</p>
<p>The busiest day of the year was March 31st with <strong>41</strong> views. The most popular post that day was <a style="color:#08c;" href="http://panyam.wordpress.com/2008/03/07/android-hack-parcellable-in-eclipse/">Android Hack &#8211; Parcellable in eclipse</a>.</p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>anddev.org</strong>, <strong>rainbowdevil.jp</strong>, <strong>markmail.org</strong>, <strong>mail-archive.com</strong>, and <strong>mindtherobot.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>gray code generator</strong>, <strong>django app engine</strong>, <strong>google maps captcha</strong>, <strong>django mobile</strong>, and <strong>aidl file</strong>.</p>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p><a style="margin-right:10px;" href="http://panyam.wordpress.com/2008/03/07/android-hack-parcellable-in-eclipse/">Android Hack &#8211; Parcellable in eclipse</a> <span style="color:#999;font-size:8pt;">March 2008</span><br />
18 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p><a style="margin-right:10px;" href="http://panyam.wordpress.com/2010/02/03/djangoappengine-coexistence-part-1/">Django/Appengine Coexistence, Part 1 &#8211; Environment Specific Settings.py</a> <span style="color:#999;font-size:8pt;">February 2010</span><br />
7 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p><a style="margin-right:10px;" href="http://panyam.wordpress.com/2010/03/21/mango-mobile-django-templates/">Mango &#8211; Mobile Django &#8211; Templates</a> <span style="color:#999;font-size:8pt;">March 2010</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p><a style="margin-right:10px;" href="http://panyam.wordpress.com/2009/10/19/gray-code-generator/">Gray Code Generator</a> <span style="color:#999;font-size:8pt;">October 2009</span><br />
2 comments</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p><a style="margin-right:10px;" href="http://panyam.wordpress.com/2007/03/05/carnatic-violin/">Carnatic Violin</a> <span style="color:#999;font-size:8pt;">March 2007</span><br />
17 comments</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/108/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/108/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/108/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=108&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2011/01/02/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy2.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/abstract-stats-5.png" medium="image">
			<media:title type="html">Featured image</media:title>
		</media:content>
	</item>
		<item>
		<title>New Start</title>
		<link>http://panyam.wordpress.com/2010/12/02/new-start/</link>
		<comments>http://panyam.wordpress.com/2010/12/02/new-start/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 22:34:11 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=106</guid>
		<description><![CDATA[Well it has happened on wednesday.  I have now started work with Macquarie bank.  Pretty excited (though a bit scared).  WMS was awesome and despite my initial disbelief I was fortunate to meet some of the smartest and, more importantly, the most passionate people I have ever met. Wish me all luck folks.  Certainly a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=106&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well it has happened on wednesday.  I have now started work with Macquarie bank.  Pretty excited (though a bit scared).  WMS was awesome and despite my initial disbelief I was fortunate to meet some of the smartest and, more importantly, the most passionate people I have ever met.</p>
<p>Wish me all luck folks.  Certainly a bit of a pain to be wearing business-y outfit to work every day but hey its small price!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=106&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2010/12/02/new-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>DocTest++ &#8211; Extracting test cases embedded in Source Files</title>
		<link>http://panyam.wordpress.com/2010/05/31/doctest-extracting-test-cases-embedded-in-source-files/</link>
		<comments>http://panyam.wordpress.com/2010/05/31/doctest-extracting-test-cases-embedded-in-source-files/#comments</comments>
		<pubDate>Mon, 31 May 2010 02:14:02 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Automated]]></category>
		<category><![CDATA[DocTest]]></category>
		<category><![CDATA[Generated]]></category>
		<category><![CDATA[UnitTest]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=100</guid>
		<description><![CDATA[UnitTest++ is brilliant in how it lets you structure and manage your tests cases but it still requires a &#8220;focus-switch&#8221;.  As I am writing a function, I should be writing a test for it, but going to another file (or compilation unit for the technical term) makes me loose focus of where I am and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=100&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>UnitTest++ is brilliant in how it lets you structure and manage your tests cases but it still requires a &#8220;focus-switch&#8221;.  As I am writing a function, I should be writing a test for it, but going to another file (or compilation unit for the technical term) makes me loose focus of where I am and what I was doing.  Clearly I am only mortal and this doesnt apply to the uber coder gods out there.  And this is where python&#8217;s doctest is awesome.  Then and there test insertion (yes they are validated at a different phase but atleast you can see what tests are around).  Not to mention more info on the documentation.  After all tests cases as documentation are a pretty powerful idea.</p>
<p>So it hit me.  Why not doctests for C++.  Lo behold <a title="DocTest++" href="http://github.com/panyam/DocTestPlusPlus">DocTest++</a>.  Wrote this last weekend because out of laziness I was&#8217;nt really adding  test cases to my <a title="Mango Template Project" href="http://github.com/panyam/mango">mango</a> code, as much I should.  Mango certainly does  have a few unit tests (and growing rapidly) and even more certainly has no plans to replace those unit tests.  But why not doctests as well?  So DocTest++ extracts tests embedded with C/C++ code and creates test cases for them.  More at the <a title="DocTest++ Wiki" href="http://wiki.github.com/panyam/DocTestPlusPlus/">project page</a> on git hub for how it works and what it does.</p>
<p>And to go a step further, this is part of the build process in my make file. A target XXX.test.cpp is (automatically) added for file XXX that contains the @test tag.  This gets compiled along with all tests.  More importantly if any of the files change or new @test tags are added, these are picked by the build system.  Wooot!</p>
<p>Any improvements or feedback?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=100&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2010/05/31/doctest-extracting-test-cases-embedded-in-source-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Mango &#8211; Mobile Django &#8211; Templates</title>
		<link>http://panyam.wordpress.com/2010/03/21/mango-mobile-django-templates/</link>
		<comments>http://panyam.wordpress.com/2010/03/21/mango-mobile-django-templates/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:08:10 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mango]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=88</guid>
		<description><![CDATA[I am a strong believer in a future where mobile devices would actually be servers too.  This is not a new idea or anything.  And Il admit I jumped on the bandwagon quite late.  Though jumping is not what I did out of trying to follow the popular opinion.  It all started when I got [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=88&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am a strong believer in a future where mobile devices would actually be servers too.  This is not a new idea or anything.  And Il admit I jumped on the bandwagon quite late.  Though jumping is not what I did out of trying to follow the popular opinion.  It all started when I got the iPhone and it hit me like a truck.  So it wasnt a bandwagon jumping moment as it was a getting-hit-by-a-truck moment.</p>
<p>Anyway, clearly servers on mobile devices instead of server boxes sitting in some rack is exciting.  Imaging you are on the move with a few people on a train and voila you have a webserver you can put up for sharing.  Mind you, this is not that different or even superior to P2P (locally via Bluetooth or globally).  Just another alternative.  So one of the tools I figured Il use quite a bit on my mobile, should it take off as a webserver is a templating engine.  Here is where Mango comes in.  This was actually inspired by Django templates.  And being a big worshipper of Django, I think of Django as a philosophy and not just as a framework.  So first thing was the port of the templating engine.</p>
<p>Where exactly am I porting it to?  First of all the code is opened under an Apache license and is on git.  Secondly I am porting it to android and objective C.  The objective C version is woefully behind, where as the android version has support for a lot of stuff (for, if, include, variables etc) and has a full set of unit tests with it.  Frankly I find android a much much more intuitive platform to develop than XCode (and objective C).  May be it has to do with my familiarity with java.  The objective C version will follow shortly.</p>
<p>So why another templating engine &#8211; Well I had envisaged 2 use cases for it:</p>
<p>1. Consume json or xml data from a backend and apply a template on the data from the client (mobile).</p>
<p>2. Mobile generates the content and applies a template to it before sending off the response to a client&#8217;s request.</p>
<p>Either way a separate templating engine helps.</p>
<p>Please feel free to try it out. Would appreciate any and all feedback and not to mention help with extending it to a large number of tags and filters.</p>
<p>1. Check it out from git at http://github.com/panyam/mango.</p>
<p>2. Start eclipse (must have java and android)</p>
<p>3. Open the mango and the mangotest projects (from mango/android and mango/android/test respectively).</p>
<p>4. Select the mangotest project and Run As Junit &#8211; watch the unit tests.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=88&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2010/03/21/mango-mobile-django-templates/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Django/Appengine Coexistence, Part 1 &#8211; Environment Specific Settings.py</title>
		<link>http://panyam.wordpress.com/2010/02/03/djangoappengine-coexistence-part-1/</link>
		<comments>http://panyam.wordpress.com/2010/02/03/djangoappengine-coexistence-part-1/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 01:39:44 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[django appengine multiple environment specific settings.py]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=80</guid>
		<description><![CDATA[We&#8217;ve heard it all.  Appengine has uber scalability and that too on demand.  And it is based on Django.  Clarification &#8211; the python based SDK is based on django.  And yes it is a great environment to develop in.  No issues.  But the thing that still causes me a bit of concern is the datastore.  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=80&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve heard it all.  Appengine has uber scalability and that too on demand.  And it is based on Django.  Clarification &#8211; the python based SDK is based on django.  And yes it is a great environment to develop in.  No issues.  But the thing that still causes me a bit of concern is the datastore.  Oh it is fantastic, scalable and all that.  But the limits are still limits.  (I havent even mentioned the 1000 limit on blobs and files which is another big issue).  And also my main concern is if I want to commit myself to writing all my code for appengine and then be in a position where porting to django would involve a total rewrite. Ok there are projects like appenginepatch and so on, but to me its trying to mold one paradigm into another.  Why patch a key/value pair based datastore into an sql backend when each has their own strengths and you are better off writing interfaces that do it in specific ways so the same app at run time will choose the right implementation based on the environment rather than all the adapting of one paradigm to another?</p>
<p>So anyway, my M.O is to have a single project with the view and controller logic that is common for django and appengine but to have seperate model classes and APIs targetted to each backend.  The models are accessed via the API classes that do all django/appengine specific magic behind the scenes transparent to the views and the controllers.  I have talked more about this in a <a title="API Centrid Design" href="http://panyam.wordpress.com/2009/08/02/api-based-design-with-django-and-gae/">previous post</a>.  However I did not provide a specific implementation.  This is now  open sourced as part of the <a title="Djapps" href="http://djapps.googlecode.com">Djapps project</a>.  At the moment this is still in its infancy but it is a collection of app to do a lot of common tasks like external authentication, provide model accessors transparently based on appengine or django and so on.  Still evolving and I will talk about this in future posts.</p>
<p>But to get started with all this, the first thing that needs to be worked on is settings.py.  For better or worse, this file is where all your app specific settings go.  So what I do is literally have a common_settings.py that i import from settings.py and have environment specific settings.py.  So I include one depending on what kind of environment I am on.  Environments for me would be &#8220;appengine dev server&#8221;, &#8220;appengine production server&#8221;, &#8220;local django server&#8221;, &#8220;production djanso server&#8221; etc.</p>
<p>So as an example, here is my settings.py.  Very stripped down:</p>
<pre><span style="color:#3366ff;"># -*- coding: utf-8 -*-
import os
import djapps

# import all common settings - we will override them later on
from djapps.default_settings import *

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'xxxxx'

# The root folder of the project
PROJ_ROOT           = os.path.abspath(os.path.split(__file__)[0])

TEMPLATE_DIRS = (
 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
 # Always use forward slashes, even on Windows.
 # Don't forget to use absolute paths, not relative paths.
 PROJ_ROOT + "/templates/"
)

import dev_profiles
# from dev_profiles.profile_dev_gae import *
from dev_profiles.profile_prod_gae import *
# from dev_profiles.profile_dev_nongae import *
# from dev_profiles.profile_prod_nongae import *

if not USING_APPENGINE: ROOT_URLCONF = 'myproject.urls'</span>
</pre>
<p>Now in the above dev_profiles is the folder where all my different environment based settings files are (I call them profiles).   So an example env specific settings py (profile_prod_gae from above) is:</p>
<pre><span style="color:#3366ff;">URL_PATH_PREFIX     = ""</span>
<span style="color:#3366ff;"> </span>
<span style="color:#3366ff;">USING_APPENGINE     = True</span>
<span style="color:#3366ff;">SITE_URL            = "http://myproject.appspot.com"</span>
<span style="color:#3366ff;">SITE_NAME           = "myproject"</span>
<span style="color:#3366ff;">SERVE_STATIC        = False</span>
<span style="color:#3366ff;">USE_TEST_LOGIN      = False</span>
<span style="color:#3366ff;">DEBUG               = True</span>
<span style="color:#3366ff;">TEMPLATE_DEBUG      = DEBUG</span>
<span style="color:#3366ff;">PROJ_STATIC_HOST    = "/static"</span>
<span style="color:#3366ff;">DATABASE_ENGINE     = ''</span>
<span style="color:#3366ff;">DATABASE_NAME       = 'myproject'</span>
<span style="color:#3366ff;">DATABASE_USER       = 'xxx</span>
<span style="color:#3366ff;">DATABASE_PASSWORD   = 'yyy'</span>
<span style="color:#3366ff;">DATABASE_HOST       = ''</span>
<span style="color:#3366ff;">DATABASE_PORT       = ''</span>
<span style="color:#3366ff;">FORMAT_PARAM        = "format"</span>
<span style="color:#3366ff;"> </span>
<span style="color:#3366ff;">EMAIL_HOST          = "localhost"</span>
<span style="color:#3366ff;">EMAIL_PORT          = 25</span>
<span style="color:#3366ff;">EMAIL_HOST_USER     = ""</span>
<span style="color:#3366ff;">EMAIL_HOST_PASSWORD = ""</span>
<span style="color:#3366ff;"> </span>
<span style="color:#3366ff;">MIDDLEWARE_CLASSES  = (</span>
<span style="color:#3366ff;"> 'django.middleware.common.CommonMiddleware',</span>
<span style="color:#3366ff;"> 'djapps.gaeutils.middleware.SessionMiddleware',</span>
<span style="color:#3366ff;"> 'djapps.auth.local.middleware.LocalAuthMiddleware',</span>
<span style="color:#3366ff;"> 'djapps.auth.openid.middleware.OpenIDAuthMiddleware',</span>
<span style="color:#3366ff;"> # 'djapps.auth.external.middleware.MultiSiteAuthMiddleware',</span>
<span style="color:#3366ff;"> 'django.middleware.locale.LocaleMiddleware',</span>
<span style="color:#3366ff;"> 'django.middleware.doc.XViewMiddleware',</span>
<span style="color:#3366ff;">)</span>
<span style="color:#3366ff;"> </span>
<span style="color:#3366ff;">TEMPLATE_CONTEXT_PROCESSORS = (</span>
<span style="color:#3366ff;"> "djapps.utils.context_processors.site_urls",</span>
<span style="color:#3366ff;"> "djapps.utils.context_processors.gae_local_auth",</span>
<span style="color:#3366ff;"> "core.context_processors.openid_user",</span>
<span style="color:#3366ff;"> 'django.core.context_processors.request',</span>
<span style="color:#3366ff;"> "django.core.context_processors.debug",</span>
<span style="color:#3366ff;"> "django.core.context_processors.i18n",</span>
<span style="color:#3366ff;">)</span>
<span style="color:#3366ff;"> </span>
<span style="color:#3366ff;">INSTALLED_APPS = (</span>
<span style="color:#3366ff;"> 'djapps.utils',</span>
<span style="color:#3366ff;"> 'djapps.dynamo',</span>
<span style="color:#3366ff;"> 'djapps.auth.local',</span>
<span style="color:#3366ff;"> 'djapps.auth.external',</span>
<span style="color:#3366ff;"> 'djapps.events',</span>
<span style="color:#3366ff;"> 'profiles',</span>
<span style="color:#3366ff;">)</span></pre>
<p>Thats it.  Nothing escapes customisation this way.  In case y ou are wondering.  The djapps.default_settings.py is just the settings.py that comes when you first create a django project (with startproject).  Atleast it is very close.</p>
<p>Mind you this has served me very very well on past projects and has not required any major rewrites.  One thing that does annoy me is the last line where I have to manually set the settings I have to choose (ie by uncommenting the line).  You can get around this by checking for an environment variable and importing one based on that but again just a personal preference.</p>
<p>Let me know how this goes for you.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=80&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2010/02/03/djangoappengine-coexistence-part-1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy New Year</title>
		<link>http://panyam.wordpress.com/2010/01/01/happy-new-year/</link>
		<comments>http://panyam.wordpress.com/2010/01/01/happy-new-year/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 06:34:49 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=78</guid>
		<description><![CDATA[Well have a great and prosperous 2010 all.  Hope you have a lot of challenges and you overcome them all!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=78&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well have a great and prosperous 2010 all.  Hope you have a lot of challenges and you overcome them all!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=78&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2010/01/01/happy-new-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Gray Code Generator</title>
		<link>http://panyam.wordpress.com/2009/10/19/gray-code-generator/</link>
		<comments>http://panyam.wordpress.com/2009/10/19/gray-code-generator/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 03:47:12 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=73</guid>
		<description><![CDATA[I suppose I could finally talk about it!  I had my Google interview last July.  Was an embarassement (and to myself too).  This was the final question in my interview (with none other than Lars Rassmussen).  The question was the typical one &#8211; &#8220;there is a room from which at any time only one person [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=73&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I suppose I could finally talk about it!  I had my Google interview last July.  Was an embarassement (and to myself too).  This was the final question in my interview (with none other than Lars Rassmussen).  The question was the typical one &#8211; &#8220;there is a room from which at any time only one person can either enter or exit the room &#8211; and not at the same time.  So how would you model all the states the room can be in without repetitions&#8221;.</p>
<p>&#8220;Simple, isnt that just Graycode?&#8221; I blurt out.  At which point I was asked to write an algorithm to actually generate all graycodes for a n-bit string.   And this was where I floundered.  Mind you I had just been through 3 and a half hours and writing an algorithm was the last thing on my mind.  It wasnt that I hadnt known how to do it, I just blanked out then  then and there &#8211; half an hour close to the finish of the interview and I had lost focus.  Stupid stupid me.</p>
<p>Anyway I just got back from a swim and for some reason the demon of the failed interview reared its ugly head and so I figured Id attempt it here (atleast to get some closure, sob sob).  Here goes.</p>
<p>Here are possible gray codes for N = 1, 2, 3 and 4:</p>
<table style="height:24px;" border="0" width="473">
<tbody>
<tr style="text-align:center;">
<td>N = 1</td>
<td>N = 2</td>
<td>N = 3</td>
<td>N = 4</td>
</tr>
<tr style="text-align:center;">
<td>0</td>
<td>00</td>
<td>000</td>
<td>0000</td>
</tr>
<tr style="text-align:center;">
<td>1</td>
<td>01</td>
<td>001</td>
<td>0001</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td>11</td>
<td>011</td>
<td>0011</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td>10</td>
<td>010</td>
<td>0010</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td>110</td>
<td>0110</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td>111</td>
<td>0111</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td>101</td>
<td>0101</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td>100</td>
<td>0100</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1100</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1101</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1111</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1110</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1010</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1011</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1001</td>
</tr>
<tr style="text-align:center;">
<td></td>
<td></td>
<td></td>
<td>1000</td>
</tr>
</tbody>
</table>
<p>Anyway this is only one combination.  Any bit could be changed in generating the sequence.  The pattern here is that the first half and the second half of the code are &#8220;kind of&#8221; the same but with the first bit being 0 and 1 respectively and the rest of the bits being reverse of each other.</p>
<p>ie with N = 2,<br />
first half = 00 and 01<br />
second half = 11 and 10</p>
<p>So a simple algorithm would be (in pseudo-haskell):</p>
<pre>gc 1, reverse = ["1", "0"] if reverse, else ["0", "1"]
gc N, True =
      ["1" + x for x in gc(N - 1, True) ] ++ ["0" + x for x in gc(N - 1, False) ]
gc N, False =
      ["0" + x for x in gc(N - 1, False) ] ++ ["1" + x for x in gc(N - 1, True) ]
</pre>
<p>Problem with the above is the storage required in the recursion to store the graycodes for N &#8211; 1 (and that too twice).  So in python we could avoid this with generators like:</p>
<pre>def graycode(numbits, reverse = False):
    if numbits = 1:
        if reverse:
            yield "1"
            yield "0"
        else:
            yield "0"
            yield "1"
    else:
        if reverse:
            # all the "1"s start first
            gcprev = graycode(numbits - 1, True)
            for code in gcprev:
                yield "1" + code

            gcprev = graycode(numbits - 1, False)
            for code in gcprev:
                yield "0" + code
        else:
            # all the "0" start first
            gcprev = graycode(numbits - 1, False)
            for code in gcprev:
                yield "0" + code

            gcprev = graycode(numbits - 1, True)
            for code in gcprev:
                yield "1" + code
</pre>
<p>and finally an auxilliary function to print out the codes:</p>
<pre>def gcgen(numbits, reverse = False):
    for codes in graycode(numbits, reverse):
        print "Code: ", codes
</pre>
<p>And that was 15 minutes of thinking.  Damn it why didnt it come to me last year?  Could have been the difference between a googler and foogler!!!  Unless ofcourse it didnt really matter and they simply thought I was just a dick@#$D!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=73&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2009/10/19/gray-code-generator/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>API Centric Design with Django and GAE</title>
		<link>http://panyam.wordpress.com/2009/08/02/api-based-design-with-django-and-gae/</link>
		<comments>http://panyam.wordpress.com/2009/08/02/api-based-design-with-django-and-gae/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 09:05:12 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=69</guid>
		<description><![CDATA[I wasnt really sure what to call this post.  My current situation is I write django apps (well so many words within that sentence can be loosely defined).  I guess after playing with django for last two and a half years (and Google AppEngine, GAE, ever since it came out) I am at a very [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=69&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wasnt really sure what to call this post.  My current situation is I write django apps (well so many words within that sentence can be loosely defined).  I guess after playing with django for last two and a half years (and Google AppEngine, GAE, ever since it came out) I am at a very interesting (or frustrating) crossroad.  What platform to choose and stick with &#8211; appengine or django.  Actually I had this conundrum about a year ago and I have essentially postponed this choice by what I call API centric design (ACD).  I am pretty sure ACD is just another fancy acronymn for existing techniques out there but still bear with me.</p>
<p>Django can be quiet easily used with GAE.  And infact that is what I have done.  I use django entirely within GAE.  The real impedence mismatch pops its ugly head thanks to the completely different backend schemes used by GAE and Django (key-value store vs relational DB).  As much as I am not a fan of the GAE, it is a pretty good platform for prototyping.  Well its free and hence, given the state of the competition, the best choice (for now) in the price range.   So how does one use GAE for prototyping an application, leaving it out there to collect feedback (and failing early and failing often) and move the application a platform of choice when the limits are reached and the constraints in GAE are just too much?  A redesign of an app to leverage non-GAE environments is certainly not the way to go.</p>
<p>What I have done is only expose an API from the app point of view.  Hide the back-end specific details behinds its own models.py (django uses models.py to hold the data models for an applications).  Its actually a lot easier than it sounds (if it already sounds easy, then it is even easier).  What is trickier is that one would have to exercise considerable discipline in following this.  Every call in the application should call only the exposed api instead of using the data-backend related calls provided by the platforms (GAE or Django or anything else).  Even leave the implementation and the optimisation to the specific backends.</p>
<p>As an example, let us take the famous &#8220;counter&#8221; example.  A typical way to have counters in traditional RDBMs based platforms is to have a table that stores the rows of name/counter pairs.  For DBMSes that are strong with write&#8217;s this is great.  GAE however recommends a different approach using shards.  Check Brett Slatkin&#8217;s <a title="Build Scalable Web Applications with GAE." href="http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine">video</a> on this.  So how do you choose between these two?</p>
<p>Firstly settings.py needs to have a variable called USING_APPENGINE (or something similar) that will be set to True if the app is running in GAE and False otherwise (ie a native django app running on the test server or on other webservers).</p>
<p>Suppose our counters api is as follows:</p>
<p>def get_counter(counter_name)</p>
<p>def incr_counter(counter_name, byhowmuch = 1)</p>
<p>Now il need 3 files for the api &#8211; counters.py, djcounters.py and gaecounters.py.  Only counters.py will be imported in any other part of the application requireing counters.  djcounters.py will have the get and incr counter implementations for traditional RDBMBs and gaecounters.py will have the same for a GAE specific implementation.</p>
<p>counters.py will be:</p>
<p>from django.conf import settings</p>
<p>if settings.USING_APPENGINE:</p>
<p>from gaecounters.py import *</p>
<p>else:</p>
<p>from djcounters.py import *</p>
<p>Thats it.  In your calling app simply do:</p>
<p>import counters</p>
<p>counters.get_counter(&#8220;xxx&#8221;)</p>
<p>counters.incr_counter(&#8220;xxx&#8221;, 10)</p>
<p>This is only the beginning.  Clearly this extends to other types of backends as well (ie support TokyoCabinet in the future etc).  When writing an application you shouldnt have to worry about the optimisations.  Nothing stipulates that gaecounters.py will have to implement Brett Slatkin&#8217;s stragey when using counters in GAE, but having separate files allows for this optimisation in the future.  Let the api abstract it all away.</p>
<p>Ofcourse it may appear that this will explode the number of functions  required in the API.  Not necessarily (ie functions having to bepeated to do filters or object creations or deletions).  Some of the common patterns are object creation, fetching an object by ID or by certain attrib/column values, deleting records.  There are others, but these are the most common ones.</p>
<p>So I have a base djhelpers and gaehelpers file which define object creations, deletions, searches for ANY kind of object class and each one is optimised (sort of) to that specific implementation.</p>
<p>For instance, in django objects can be created with the method:</p>
<pre>def create_object(obj_class, **kwds):</pre>
<pre>    return obj_class.objects.create(**kwds)</pre>
<p>while the GAE implementation would be:</p>
<pre>def create_object(obj_class, **kwds):</pre>
<pre>    obj = obj_class(**kwds)</pre>
<pre>    db.put(obj)</pre>
<pre>    return obj</pre>
<p>Note these are only basic ones.  Other implementations could go through the kwds list and get the parent and id parameters to set these on the object as required.  Alternatively, you could only save optionally and so on.</p>
<p>So an object creation in another part of the app is simply a matter of doing:</p>
<p>create_object(MyObjectClass, a = 1, b = 2, c = 3)</p>
<p>and the object is created without having to worry about the backend type.</p>
<p>This is again a simple way of hiding the implementation details.  The same could be implemented using metaclasses and properties to define a DBObject class whose metaclass would be the implementation specific class for the above and other object specific methods.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=69&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2009/08/02/api-based-design-with-django-and-gae/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Sydney Django Users Group</title>
		<link>http://panyam.wordpress.com/2009/05/07/sydney-django-users-group/</link>
		<comments>http://panyam.wordpress.com/2009/05/07/sydney-django-users-group/#comments</comments>
		<pubDate>Thu, 07 May 2009 20:20:36 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=67</guid>
		<description><![CDATA[Well we already do have a Sydney Python group.  So I was a bit apprehensive when I created the Sydney Django Users Group.  But my goal was not to compete with SyPy (actually most of our members are FROM SyPy and we regularly visit SyPy discussions &#8211; including one last night by Alex Dong on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=67&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well we already do have a Sydney Python group.  So I was a bit apprehensive when I created the <a title="Sydney Django Users Group" href="http://groups.google.com/group/sydney-django-users-group">Sydney Django Users Group</a>.  But my goal was not to compete with SyPy (actually most of our members are FROM SyPy and we regularly visit SyPy discussions &#8211; including one last night by <a title="Alex Dong" href="http://www.alexdong.com">Alex Dong</a> on scaling web applications).</p>
<p>The main goal was to have a small group focusing purely on django activity in sydney.  So far so good.  Had our first meetup last tuesday.  Modest turn out and interesting talk by Sam Cavenagh and <a title="Shaon Diwakar" href="http://blog.shaon.net/">Shaon Diwakar</a>.  Oh and thanks heaps for Shaon and Sam for actually pushing me to organise the meetup by getting me out of my lazy zone.</p>
<p>And here&#8217;s for lots more activity in the sydney django community.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=67&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2009/05/07/sydney-django-users-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>StartupCampSydney II</title>
		<link>http://panyam.wordpress.com/2009/01/19/startupcampsydney-ii/</link>
		<comments>http://panyam.wordpress.com/2009/01/19/startupcampsydney-ii/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 03:24:00 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=58</guid>
		<description><![CDATA[Wow that was a doozer! Last weekend was the StartupCampSydney.  A weekend where about 6-10 teams (each with 6-8 members) build, launch and pitch a Startup in one weekend.  Yep one weekend. To be honest I never thought it would work and when asked to be part of this one, I was trying to come [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=58&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wow that was a doozer!</p>
<p>Last weekend was the StartupCampSydney.  A weekend where about 6-10 teams (each with 6-8 members) build, launch and pitch a Startup in one weekend.  Yep one weekend. To be honest I never thought it would work and when asked to be part of this one, I was trying to come up with an excuse to back out of it (before my wife who I hoped would have asked me not to go, urged me to participate&#8230;) &#8230;  the urging turned out to be a blessing.. that was one of the most intense, enriching, immersed and enlightening product development excercises Ive been in.</p>
<p>The sheer amount of talent from all backgrounds says it all.. and ofcourse meeting and working with so much talent just makes you do things that you never realised were possible.  Our startup is <a title="ThreeFeeds" href="http://threefeeds.com">ThreeFeeds.com</a> &#8211; a topic/news aggregator. Check it out, we would love your feedback (please forgive us in advance for the bugs).</p>
<p>Check out a full coverage of SCS by <a title="Ross Dawson" href="http://rossdawsonblog.com/weblog/archives/2009/01/startupcamp_syd.html">Ross Dawson</a>.</p>
<p>Cant wait for the next one.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=58&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2009/01/19/startupcampsydney-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>LunarProbe</title>
		<link>http://panyam.wordpress.com/2008/12/02/lunarprobe/</link>
		<comments>http://panyam.wordpress.com/2008/12/02/lunarprobe/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 23:25:20 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=48</guid>
		<description><![CDATA[At work I do games.   Again not the usual kind but the slot ones.  A good thing about where I work unlike others in the industry is that we actually have a bit of belief in technology and try to &#8220;catchup&#8221; with latest technology (usually mainstream &#8211; 5 years).  Now while this may be astonishing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=48&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>At work I do games.   Again not the <span style="text-decoration:underline;">usual</span> kind but the slot ones.  A good thing about where I work unlike others in the industry is that we actually have a bit of belief in technology and try to &#8220;catchup&#8221; with latest technology (usually mainstream &#8211; 5 years).  Now while this may be astonishing to some outside the industry, it is quite advanced within!  Anyhoo I am digressing.</p>
<p>Point was that with all this catching up we do, we recently (about 6months-1year ago) started using Lua to script a big chunk of the games so that only the core is handled by C++ and everything UI related is palmed off to Lua.  Obvious advantage is that extra builds are not required as compileable source code is not changed and configuration is a lot easier and lot less time consuming.  Again nothing new here.</p>
<p>The problem is that the lua scripts we invoke from C++ have no easy way of debugging them.  So our engineers had been toiling with this by using the first-class technique of peppering the code with print statements.  You would thing some methodologies would die eventually but nope.</p>
<p>So I figured why not simply have a debugger that takes advantage of Lua&#8217;s debug api and allow debugging of scripts remotely.  So was born LunarProbe.  My attemt at debugging lua scripts once embedded in a host language.  Even at the beginning I figured that this was a very generic thing and has no specific code for our games.  So I decided to release it on the Apache License.  You can find the code on <a title="LunarProbe" href="http://code.google.com/p/lunarprobe/">google code</a>.</p>
<p>So far it only supports C/C++ but hope to have more languages supported with the appropriate bindings in place.  The idea is simple:</p>
<ol>
<li>The lua_State object (ie the lua stack or the lua context) is god in Lua.  Essentially it is what the interpreter uses to execute scripts and lua statements &#8220;on&#8221;.</li>
<li>A new lua stack can be opened with the <strong>lua_open</strong> command.</li>
<li>Usually following this command, you open all the standard libraries with the <a href="http://www.lua.org/manual/5.1/manual.html#luaL_openlibs"><strong>luaL_openlibs</strong></a>.</li>
</ol>
<p>That is it.  You do usual things like loading lua files on a particular stack.  See the <a title="Lua Manual" href="http://www.lua.org/manual/5.1/">lua manual</a> for more info on this.</p>
<p>So where does the debugging come in?  Well each lua stack can be given a <a title="Debug Hook Function" href="http://www.lua.org/manual/5.1/manual.html#lua_Hook">debug hook function</a> that is called by the interpreter after certain points at runtime. eg after a line has been executed, after a function is invoked, after a function has returned etc.</p>
<p>What LunarProbe does is registers itself as a hook function and deals with each of the above debug events and presents it via tcp (port 9999 by default) to a remote client.  The debug server is in fact api driven.  It accepts commands from the client and returns responses (but not HTTP &#8211; to keep it simple).  This means any UI could be written easily by simply following the debug server protocol.  A reference client is provided (written in python).  The python client is supposed to be like gdb (but no where near it!! GDB &#8211; please accept my apologies for even trying a comparison!!  I know I dont deserve it.)</p>
<p>I wanted to write a GUI or an Eclipse plugin, but we dont use eclipse plugin at work and wx widget toolkits werent installed by default here at work.  So doing either meant having all developers install extra packages which was a huge adminstrative overhead.  At a later stage, I would like to see more coming up.  Any helpers?</p>
<p>Again I digress.  So how would one enable LunarProbe in stacks they are opening?  Simple.</p>
<p>Instead of lua_open and luaL_openlibs, simply do this:</p>
<p>1. Include the lunarprobe header (ensure that lunarprobe/src is in the include path):</p>
<ul>
<li><strong>#include &#8220;lpmain.h&#8221;</strong></li>
</ul>
<p>2. Instead of lua_open and luaL_openlibs simply do:</p>
<p><strong>LUNARPROBE_NS::LuaUtils::NewLuaStack(true, true, &#8220;hello&#8221;)</strong></p>
<p>This does a few things:</p>
<ol>
<li>Creates a lua stack using lua_open</li>
<li>If the first parameter is true, then Opens standard libraries using luaL_openlibs.</li>
<li>and if the second parameter is true, registers LunarProbe by calling LUNARPROBE_NS::LunarProbe::Attach(stack, name), where &#8220;stack&#8221; was opened in step 1.</li>
<li>The fourth parameter (defaulting to &#8220;&#8221;) only gives a name to each of your stacks for debugging purposes.  This is very useful in the debug client to identify which stack your dealing with when the address of a stack may not be very useful or very clear.</li>
</ol>
<p>Alternatively, you can simply call the step 3 instead of NewLuaStack if you do not want to pull out your own versions of lua_open and luaL_openlibs.</p>
<p>That it. This is the embedding/attaching part of the debugger.  Now the client.</p>
<p><span style="text-decoration:underline;"><strong>The Client</strong></span></p>
<p>lunarprobe/client includes a simple client &#8211; client.py.</p>
<p>I wont go into too much detail here as the &#8220;help&#8221; command is mostly self-explanatory.  Just the brief stuff.</p>
<p>Invoke this with:</p>
<ul>
<li><strong>python client run</strong></li>
</ul>
<p>or if you would like to run it from within an interpreter then:</p>
<ul>
<li><strong>import client</strong></li>
<li><strong>client.run()</strong></li>
</ul>
<p>This brings up the LDB prompt: type in &#8220;help&#8221; to show all commands and their usage.</p>
<p>One distinction (actually an inconvinience) is that since multiple stacks can be debugged at the same time, any context (LP calls stacks as <strong>contexts</strong>) specific commands must pass in the address of the context.  This is not hard, just inconvinient.</p>
<p>To get a list of all the contexts simply type in the <strong>contexts</strong> at the prompt and press enter.  This will show all context names and their addresses.  Use these addresses with any context related commands (like step, next, continue etc).</p>
<p>Breakpoints at the moment can be set by filename (and linenumber) or by a function name.  However at this stage member functions are not differentiated from global functions.  So a function name breakpoint will affect ALL functions of the same name.</p>
<p>As mentioned this is very brief.  Apologies for that.  Il add more and more in as I improve this.</p>
<p>Well hopefully this project is useful for all Lua embedders out there.  Please let me know how I can improve this.  Also this project is on google code, so please let me know if you would like to contribute or extend LP.</p>
<p>Best of luck!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=48&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/12/02/lunarprobe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>End of 2008</title>
		<link>http://panyam.wordpress.com/2008/11/30/end-of-2008/</link>
		<comments>http://panyam.wordpress.com/2008/11/30/end-of-2008/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 10:31:34 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Classical Music]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=45</guid>
		<description><![CDATA[And another short one after ages.  Just a summary of what I had been upto. August &#8211; Had my exam for Marketing Management and Stats.  For some reason i find that more I learn in a subject the worse I do in the exams.  I really need to learn to write academically!  (Yes I know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=45&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>And another short one after ages.  Just a summary of what I had been upto.</p>
<p>August &#8211; Had my exam for Marketing Management and Stats.  For some reason i find that more I learn in a subject the worse I do in the exams.  I really need to learn to write academically!  (Yes I know it sounds like a looser and that most likely must be it!)</p>
<p>September &#8211; 3 weeks in India.  Wow Wow Wow!  Entrepreneurship is just springing up.. (ok the financial climate is not so great but that is really an issue of the system rather than the product/environment)&#8230; After &#8220;the&#8221; valley India is the place to be.  Actually not entirely true.  Even though many wouldnt agree with me, Id say china is still leading in that aspect as people are a lot more risk taking than in India but hey Ive never been to china so it is a very very brave and untested statement.</p>
<p>October &#8211; 2 weeks in HongKong for one of my subjects (Private Equity and Venture Capital)..  amazing course.. only sad thing was that I had to go all the way to HK to do a course in entrepreneurship, which was not offered by AGSM in sydney&#8230; what does that really say about the apetite for entrepreneurship in australia?  But loved HK &#8211; the city and the people&#8230; I cant say the same about the food.  See I am a vegetarian and this is something not easily catered.  Also I was a bit dissapointed with the prices.  Not exactly as cheap as I hoped them to be.  Oh well..</p>
<p>November &#8211; Had my exam for the PE and VC subject..  confirms my theory about learning being inversely proportional to my mark&#8230; well havent got my mark yet but not holding my breath for a great mark&#8230; damn <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>December &#8211; Had 2 concerts yesterday for <a title="SMC" href="http://smc.does.it">SMC</a>.  Tiring but lots of fun.  One more in Brisbane on the 13th and one possibly in melbourne during christmas.  Have to see.  Both very challenging and testing.  One at a time.</p>
<p>Ciao till later.  Will be updating on a lot of programming stuff Ive been hacking away on.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=45&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/11/30/end-of-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>HongKong</title>
		<link>http://panyam.wordpress.com/2008/10/16/hongkong/</link>
		<comments>http://panyam.wordpress.com/2008/10/16/hongkong/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 04:05:46 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[agsm]]></category>
		<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[HK]]></category>
		<category><![CDATA[HOng Kong]]></category>
		<category><![CDATA[VC]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=43</guid>
		<description><![CDATA[Well I am in HK now..  Doing an elective on Private Equity and Venture Capital.  My first time here and the place is breath taking&#8230;.  Ok the weakened Ausie dollar has just robbed a bit of my ability to buy but still a great place&#8230;. The course is very insightful&#8230; if you follow VC news [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=43&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well I am in HK now..  Doing an elective on Private Equity and Venture Capital.  My first time here and the place is breath taking&#8230;.  Ok the weakened Ausie dollar has just robbed a bit of my ability to buy but still a great place&#8230;.</p>
<p>The course is very insightful&#8230; if you follow VC news on techcrunch and a whole bunch of blogs from the big guns in the Valley (no i am just a follower not a propogator), this course is very very complementary.  Ofcourse it is quite sad that we (students) in the Australian campus of AGSM have to resort to travelling overseas to undertake a course in anything entrepreneurial.  Seems the Australian focus is on management training more than anything else.  Could that explain the pitiable state of entrepreneurship in Australia?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=43&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/10/16/hongkong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>I am Rich (I Wish)</title>
		<link>http://panyam.wordpress.com/2008/08/11/i-am-rich-i-wish/</link>
		<comments>http://panyam.wordpress.com/2008/08/11/i-am-rich-i-wish/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 02:26:59 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[App Store]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA["i am rich"]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=38</guid>
		<description><![CDATA[Well wanted to write this last week, but wanted to read more about the reactions to Apple yanking out the &#8220;I am rich&#8221; application from its store. Apple&#8217;s reaction to the app is hardly surprising, after all the company does have a reputation for masking its dubious actions of cencorship and spoon feeding its customers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=38&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well wanted to write this last week, but wanted to read more about the reactions to Apple <a href="http://www.tgdaily.com/content/view/38784/140/">yanking out</a> the &#8220;I am rich&#8221; application from its store.</p>
<p>Apple&#8217;s reaction to the app is hardly surprising, after all the company does have a reputation for masking its dubious actions of cencorship and spoon feeding its customers under the blanket motto of &#8220;quality&#8221;.   What was surprising (may be less so given the psyche of the iStuff customers) is the customers reaction.  All I have heard all around are &#8220;kudos Steve, great work.&#8221;</p>
<p>Forget cencorship, are we actually planning to get rid of the words &#8220;Common Sense&#8221; out of our vocabulary and lives for ever?  What ever happened to Buyer Beware?  Let me go through the arguments Ive heard.</p>
<p><strong><span style="text-decoration:underline;">1. It is Apple&#8217;s store and they can do what ever they want. </span></strong></p>
<p>Ok No argument here.  I mean if M$ can do what they want and get away with it, why shouldnt Apple?  If this is all we care about, then stop reading right here.</p>
<p><span style="text-decoration:underline;"><strong>2. You dont find $1000 news papers in a news-stand so why should we have them in the AppStore?</strong></span></p>
<p>Marketing and Economics 101.  A news agent, has to prioritise the shelf space to maximise his/her profits.  A good indication of this is the customer demand for a product, not ethical or moral values.  You dont find $1000 news papers in a news stand simply because the market segment looking for $1000 news papers is not the one being targetted by the news stand.  If you are looking for expensive magazines try <a title="Millionaire!" href="http://www.millionaire.com">this</a>.</p>
<p><span style="text-decoration:underline;"><strong>3. Dilutes the quality of the App Store</strong></span></p>
<p>Welcome to economics again.  Ever heard of supply and demand?  Ever heard of transaction costs? It was not exactly hard to &#8220;find&#8221; the product.  The App store enables you to search by price and (I am assuming) a few other criteria.  So we have 0 transactions costs for the users OR Apple (never mind that Apple made a cool 30% of the app!).  In an open market (which is what this SHOULD be) the best would bubble to the top and crap like this sinks to the bottom (ok I suddenly have a hankering for this app and I dont even have an iPhone!).</p>
<p><span style="text-decoration:underline;"><strong>4. People are being fooled and tricked.</strong></span></p>
<p>How?  Was the price not clear?  Was the product description not clear?  Sure the app is useless.  But was its uselessness ever a secret and mis-communicated?  The <a href="http://www.foxnews.com/story/0,2933,399461,00.html">8 who have actually bought the app</a>, knew exactly what they were getting into (by the way how many of them are actually complaining about it?).</p>
<p><span style="text-decoration:underline;"><strong>5. Mockery of the store</strong></span></p>
<p>Wow another insightful argument for masking the envy at good (well ok going a bit far there) entrepreneurship.  So suddenly we are ok with Louis Vuitton bags (known mainly for their durability?) but an attempt at brand management and positioning (towards deep-pocketed) users is wrong and unethical and evil and dodgy (and a whole lot of other equally _____ adjectives).  Perhaps it is time we (developers) start making apps targeted at user needs (refer to PG&#8217;s &#8220;make something users want&#8221; mantra for this)?</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>All said and done fellas, the marketing hype for the AppStore and Heinrich (the app&#8217;s author) have been phenominal.  Even with a sale to 8 customers, thats a massive revenue of 80,000.  Wow.  Kudos.  This is just capitalism guys.  Get used to it.  The thing with idiots is, if you cant beat them, you just take advantage of them.  And kudos again to Heinrich for doing just that.  Dont try to beat this guy, join him!!</p>
<p>The other reason I am excited about Apple having been foolish in dealing with this App, is that the need for a better market place for the iPhone is becoming more pronounced.  How long can Apple&#8217;s cencorship and treatment of its customers as children help insulate (and incubate?) its customers&#8217; stupidity?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=38&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/08/11/i-am-rich-i-wish/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Google App Engine</title>
		<link>http://panyam.wordpress.com/2008/06/01/google-app-engine/</link>
		<comments>http://panyam.wordpress.com/2008/06/01/google-app-engine/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 02:17:54 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[chess]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=34</guid>
		<description><![CDATA[Well ive been spending the last week and a bit with my first AppEngine project.  I had recieved my account on the day it was released (yes a shameless boast there )&#8230;  Unfortunately due to exams never got around to doing anything with it. So as a simple project I figured Il write (yet another [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=34&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well ive been spending the last week and a bit with my first AppEngine project.  I had recieved my account on the day it was released (yes a shameless boast there <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )&#8230;  Unfortunately due to exams never got around to doing anything with it.</p>
<p>So as a simple project I figured Il write (yet another online) <a title="WizChess" href="http://wizchess.appspot.com">chess game &#8211; WizChess</a>.  Note that there is already a Blitz Chess as part of the appengine <a title="Google AppEngine Samples" href="http://code.google.com/p/google-app-engine-samples/">samples </a>page.  I wanted to write one just to get a feel for the engine and to largely to learn a lot of things myself.  There are a still a few things I have not implemented (eg on a castle, the server updates, but the client does not properly update UI.  en-passante-s are not implemented.  Timed game not hapening yet, chatting between players not yet happening and so on).</p>
<p>It was a very interesting experience.  The documentation was quite nice and full, but still I was not fully satisfied.  For some reason I found django a lot more satisfying as a web-app dev platform.  For the models for the game I had chosen to follow a more django style (relational) rather than harnessing the rich model extensions provided by appengine (mainly the Expando Models).  I had done this as I wasnt sure if I wanted to seal my app purely to the AppEngine platform.  And after finishing the project, I am still not sure that I do.</p>
<p>I had got a whole bunch of puzzle games from <a title="Chess Puzzles" href="http://homepage.ntlworld.com/adam.bozon/ChessPuzzles.htm">here</a>.  Now I had needed a way to update the database with an initial data set.  So my way was to have a url on the webapp (something like /resetdb) that would load the initial board templates (and in the future games that are saved and so on).  However, since this loading would take some time, I had to resort to breaking this up into several parts and calling each of these individually.  eg:  Id nomally have:</p>
<pre>class ResetDB(webapp.RequestHandler):
    def get(self):
        for board in my_boards:
            add_board_to_db(board)
</pre>
<p>Now as the number boards in my data set increased, the time to put them in the data store would naturally increase.  But there seems to a time limit on each request, which would make my request fail.  So I had to resort to writing a client side script that would call ResetDB with parameters (eg, firstboard and lastboard) and then also break em up as more saved games were restored etc.  Absolute Pain!  Its all good for appengine to be smart about things but to impose assumptions severely limits the usefulness of this platform and I hope in the future this is released.</p>
<p>Next thing was the model apis.  The Expando model is awesome, but once again I was not happy about the lockin.  But this was not my main concern.  The querying api is extremely poor.  Django has amazing querying facilities where one can specify pretty much arbitrary query filters (not a and c or a minus x and so on).  AppEngine does not support &#8220;not&#8221;s in its query.  Aaaaaaaaaaaaaaaaah.   Also I couldnt find an easy way of chaining queries.  Eg, to find a game, where either player0 or player1 (my way of saying white or black) was user, I had to do this:</p>
<pre>games_with_user = []
games = models.Game.all()
games_with_user.extend([g for g in games if g['player0'] = current_user])
games_with_user.extend([g for g in games if g['player1'] = current_user])
</pre>
<p>Yuck!  Same thing in Django happens with:</p>
<pre>games_with_user = models.Game.filter(Q(player0 = current_user) or Q(player1 = current_user))
</pre>
<p>(ok I did that syntax from memory so it may not be right, but it is something similar).</p>
<p>Now the final that REALLY annoyed me was lack of Comet (or any reverse ajax) support.  Essentially I poll the server every 5 seconds to get updates on whether the opponent has played.  Would have been great for the server to notify the client instead of having to keep polling and waste requests (I believe there is a limit of 6.5 million requests a day or is that 650K requests?)</p>
<p>But having said all this, the main (only?) advantage of the platform is the fact that we dont have to worry about scalability.  Unfortunately this is a HUGE advantage.  Normally I could write an app, and host it on my own boxes at home (if i want it to be free), but then il soon be hitting limits with 10 users and Il have to find a hoster and also handle scalability issues myself.  So migrating my own code to appengine at THAT point would be quite a nightmare.  By writing and prototyping it on appengine allows me to fail fast.  Looking at the pricing, app engine would charge about $40 per month per app (with reasonable traffic).  If my app ever got to that stage, I could always port it out of appengine (as long as I dont use Expando and stick to django style object modelling &#8211; with which I dont loose any power).</p>
<p>Please let me know if you would like the sources.  I am not sure how to upload files to wordpress here.</p>
<p>Also I would really appreciate it if you could give me feedback on my learning here.  As a python and web-app noob, Id be grateful for pointing any errors in my ways <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=34&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/06/01/google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Parur Style Techniques</title>
		<link>http://panyam.wordpress.com/2008/05/25/parur-style-techniques/</link>
		<comments>http://panyam.wordpress.com/2008/05/25/parur-style-techniques/#comments</comments>
		<pubDate>Sun, 25 May 2008 20:10:57 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Classical Music]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=33</guid>
		<description><![CDATA[Well I love Parur style violin.  Full-stop.  I would kill to master it.  It is extremely demanding and needs a kind of discipline that would make the marines look like amateurs at Paintball! I have had the extreme good fortune of being pointed to a few clips on Youtube by Akella Mallikarjuna Sharma.  Here they [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=33&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well I love Parur style violin.  Full-stop.  I would kill to master it.  It is extremely demanding and needs a kind of discipline that would make the marines look like amateurs at Paintball!</p>
<p>I have had the extreme good fortune of being pointed to a few clips on Youtube by Akella Mallikarjuna Sharma.  Here they are:</p>
<p><a title="Akella Mallikarjuna Sharma" href="http://youtube.com/results?search_query=msakella">http://youtube.com/results?search_query=msakella</a></p>
<p>Hope you benefit from these.  Good luck.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=33&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/05/25/parur-style-techniques/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Inbreeding &#8211; The Valley Style</title>
		<link>http://panyam.wordpress.com/2008/05/07/inbreeding-the-valley-style/</link>
		<comments>http://panyam.wordpress.com/2008/05/07/inbreeding-the-valley-style/#comments</comments>
		<pubDate>Wed, 07 May 2008 04:52:10 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Entrepreneurship]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Startups]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=32</guid>
		<description><![CDATA[So Marc Andreessen joins the Board of Facebook.  (Advance note of jealousy towards Mark Zuckerberg for getting someone of Marc&#8217;s stature.  Kudos). What I find surprising is will there be any input from Marc on FB&#8217;s technical strategy?  I am specifically concerned about Marc&#8217;s Ning using OpenSocial and FB using its own FB API.  Will [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=32&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So Marc Andreessen <a title="Marc Joins Facebook Board" href="http://kara.allthingsd.com/20080506/andreessen-to-facebook-board/" target="_blank">joins</a> the Board of Facebook.  (Advance note of jealousy towards Mark Zuckerberg for getting someone of Marc&#8217;s stature.  Kudos).</p>
<p>What I find surprising is will there be any input from Marc on FB&#8217;s technical strategy?  I am specifically concerned about Marc&#8217;s Ning using OpenSocial and FB using its own FB API.  Will we see a merging of the two?  Surely it would be stupid (a quality I possess in abundance) to think FB would abandon FB API in favour of Ning for better tapping into Ning and its countless social networks hosted within.  However one cannot help see the allure in a wrapper to FB API to be OpenSocial compatible?</p>
<p>Or is this issue too puny and insignificant to deserve a mention?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=32&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/05/07/inbreeding-the-valley-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>The Greatest Entrepreneurs</title>
		<link>http://panyam.wordpress.com/2008/04/30/the-greatest-entrepreneurs/</link>
		<comments>http://panyam.wordpress.com/2008/04/30/the-greatest-entrepreneurs/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 00:59:39 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=31</guid>
		<description><![CDATA[The 80s and 90s, saw a huge influx of Indian migrants to Australia (the trend still continues).  Now there is something different about these migrants.  Now what is odd about this class of migrants is most of them were in their mid 30s to mid 40s, with very comfortable lifestyles back home (by which I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=31&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The 80s and 90s, saw a huge influx of Indian migrants to Australia (the trend still continues).  Now there is something different about these migrants.  Now what is odd about this class of migrants is most of them were in their mid 30s to mid 40s, with very comfortable lifestyles back home (by which I mean respectable jobs/positions resulting from years of hard work).  Why I think this is odd is that you would not expect people/couples with such low risk lifestyles to risk it all and jump ship to sail to the uncertain shores of a foreign land.</p>
<p>It is pretty easy (or comforting atleast) sitting in your parents&#8217; basement coding or being sponsored to spend summers on startup ideas sponsored by THE man <a title="PG" href="http://paulgraham.com" target="_blank">PG</a> himself (an opportunity Id kill for), but leaving all you have with very little promise of great rewards, purely for the sake of your family, is what I consider true entrepreneurship (well children are the ultimate startups anyway).  Costs of failures are very high (hardship for entire family, loosing face, etc).  Rewards are not staggering except that life for one&#8217;s family is slightly better.</p>
<p>I would like to thank two such migrants who risked very comfortable jobs for the sake of their two sons.  Myself and my brother.  Mum was a very respected high-school teacher (she was my math teacher &#8211; which could explain my interest in maths).  Dad was a successful accountant.  Like others they had left it all for us.  The main reason was reverse-discrimination in the society gripped by the plague of the caste system, existing only to empower already corrupt politicians (redundant adjective). Times were hard for the first two years &#8211; time they had spent unemployed, living on government assistance.  But I am glad for those times.  It had instilled in us a passion and respect for hardwork.  Cant complain at all.  No room for becoming spoilt brats.  In fact I wonder if I can ever replicate their own dedication and values on my own kids (one day).  Atleast I know that I dont have to look far in search of role-models!</p>
<p>So thanks mum and dad (hope this combined post suffices for mothers&#8217; and fathers&#8217; days).</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=31&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/04/30/the-greatest-entrepreneurs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>gDay Mate</title>
		<link>http://panyam.wordpress.com/2008/03/31/gday-mate/</link>
		<comments>http://panyam.wordpress.com/2008/03/31/gday-mate/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 23:16:55 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/2008/03/31/gday-mate/</guid>
		<description><![CDATA[Well, no exception. Google dazzles us all with their supreme Mate technology &#8211; short for Machine Assisted Temporal Extraction.  Its the beginning of Future searches!!!  Just put in the keywords and search for items that may appear tomorrow!! I was a bit skeptical to see how it actually works but man its amazing!  Looks like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=30&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, no exception. Google dazzles us all with their supreme Mate technology &#8211; short for Machine Assisted Temporal Extraction.  Its the beginning of Future searches!!!  Just put in the keywords and search for items that may appear tomorrow!!</p>
<p>I was a bit skeptical to see how it actually works but man its amazing!  Looks like I wont have to be working ever again!!</p>
<p>Here&#8217;s the link!!</p>
<p>http://www.google.com.au/intl/en/gday/index.html</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/30/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/30/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=30&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/03/31/gday-mate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Hack &#8211; Parcellable in eclipse</title>
		<link>http://panyam.wordpress.com/2008/03/07/android-hack-parcellable-in-eclipse/</link>
		<comments>http://panyam.wordpress.com/2008/03/07/android-hack-parcellable-in-eclipse/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 13:29:57 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=29</guid>
		<description><![CDATA[Long story short &#8211; I have been playing around with android. wow. Amazing platform. Ok so the sdk is not all that well documented but it is getting better by the day. Ofcourse due to its young age, it is nowhere near the flex sdk in terms of the ease of use, documentation and ide, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=29&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Long story short &#8211; I have been playing around with android.</p>
<p>wow.  Amazing platform.  Ok so the sdk is not all that well documented but it is getting better by the day.  Ofcourse due to its young age, it is nowhere near the flex sdk in terms of the ease of use, documentation and ide, but hey a great start.  And there are tons of samples out there ofcourse.</p>
<p>Anyhoo today is about one of the many problems and a fix I stumbled across &#8211; Including Parcelables in eclipse projects.</p>
<p><b> Background:</b></p>
<p>It is very easy to create <a href="http://code.google.com/android/reference/aidl.html" title="Designing and Using a Remote Interface Using AIDL">remote services </a>in android.  A remote service runs in the corner handling requests by activities (or other processes in general) that need to use them (essentially server like processes).  By following the tutorial above, you will find that &#8220;aidl&#8221; files come in 2 flavours.</p>
<p>1. Include the interface definition of an interface.</p>
<p>2. Contain a single statement &#8220;parcelable xxxx&#8221;, indicating that class xxxx can be marshalled and unmarshalled (into Parcel objects) so instances of xxxx can be communicated between processes.</p>
<p>With step 1, an aidl file YYYYY.aidl automatically gets built into YYYYY.java which contains a lot of stub and other helper functions to take care marshalling and remote method invocation and yada yada yada.  This seems to be an automatic thing with eclipse.</p>
<p>With step 2, the .java already exists, and hence the need to use the &#8220;parcelable&#8221; keyword to indicate that &#8220;there exists a corresponding XXXX.java that is already parcelable so do NOT create a .java file again&#8221;, but eclipse does not understand this.</p>
<p>Worse still, it is intuitive to place the aidl files along with all your other sources.  The fix involves NOT doing this.</p>
<p>Your project will have usually have the following structure:</p>
<p>&lt;project&gt;</p>
<p>&#8212;- .classpath</p>
<p>&#8212;- .project</p>
<p>&#8212;- .settings/</p>
<p>&#8212;- bin/</p>
<p>&#8212;- src/</p>
<p>&#8212;&#8212;&#8211; package1</p>
<p>&#8212;&#8212;&#8212;&#8212;file1.java        &#8212;&gt;    This is parcellable</p>
<p>&#8212;&#8212;&#8212;&#8212;file2.java</p>
<p>&#8212;&#8212;&#8211; package2</p>
<p>&#8212;&#8212;&#8212;&#8212;interface1.java</p>
<p>&#8212;&#8212;&#8212;&#8212;class2.java             &#8212;-&gt;    This is parcellable</p>
<p>and so on</p>
<p>the key is to add another folder at the same level and structure as the &#8220;src&#8221; folder(I called mine aidl).</p>
<p>So the new structure looks like this:</p>
<p>&lt;project&gt;</p>
<p>&#8212;- .classpath</p>
<p>&#8212;- .project</p>
<p>&#8212;- .settings/</p>
<p>&#8212;- bin/</p>
<p>&#8212;- src/</p>
<p>&#8212;&#8212;&#8211; package1</p>
<p>&#8212;&#8212;&#8212;&#8212;file1.java        &#8212;&gt;    This is parcellable<br />
&#8212;&#8212;&#8212;&#8212;file2.java</p>
<p>&#8212;&#8212;&#8211; package2</p>
<p>&#8212;&#8212;&#8212;&#8212;interface1.java</p>
<p>&#8212;&#8212;&#8212;&#8212;class2.java             &#8212;-&gt;    This is parcellable</p>
<p>&#8212;- aidl/</p>
<p>&#8212;&#8212;&#8211; package1</p>
<p>&#8212;&#8212;&#8212;&#8212;file1.aidl        &#8212;&gt;    This is parcellable<br />
&#8212;&#8212;&#8211; package2</p>
<p>&#8212;&#8212;&#8212;&#8212; class1.aidl        &#8212;-&gt; a sample interface definition with no corresponding .java files ANYWHERE</p>
<p>&#8212;&#8212;&#8212;&#8212;class2.aidl             &#8212;-&gt;    This is parcellable<br />
the aidl files that exist in your src folder, have their corresponding aidl files in the aidl folder in the same package structure.</p>
<p>Now good news is since the aidl folder exists in your &lt;project&gt; folder, it will be picked up by eclipse (on a refresh).  However there is still one minor issue.  aidl file class1.aidl will not be automatically compiled to class1.java.  To do this, we need to add the entire aidl folder as a &#8220;source&#8221; folder.  Simple.  do this:</p>
<p>add an entry like so in the .classpath file!! (ah ha)</p>
<p>&lt;classpathentry kind=&#8221;src&#8221; path=&#8221;aidl&#8221;/&gt;</p>
<p>This essentially says, &#8220;i have another folder called &#8216;<span style="text-decoration:underline;">aidl</span>&#8216;  that is a source folder&#8221;..  voila, being a source folder it will get included in auto-builds.</p>
<p>Beauty of this is that for <span style="text-decoration:underline;">class2.aidl</span> and <span style="text-decoration:underline;">file1.aidl</span> (in your aidl folder), no .java file will be created as they already exist, however <span style="text-decoration:underline;">class1.java</span> will be built.</p>
<p>Saves a huge pain in the rear side (i couldnt spell &#8220;posterior&#8221;)!</p>
<p>good luck.  please let me know if ive missed something.</p>
<p>PS &lt;08/03/2008&gt;</p>
<p>Please see Comment # 2 for further clarifications (and speculations too).  Thanks for trickybit (Comment #1) for inspring that!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=29&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/03/07/android-hack-parcellable-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Captcha got my tongue!!</title>
		<link>http://panyam.wordpress.com/2008/02/11/google-captcha-got-my-tongue/</link>
		<comments>http://panyam.wordpress.com/2008/02/11/google-captcha-got-my-tongue/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 19:46:10 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=28</guid>
		<description><![CDATA[AAAAAAAAAAAAAAAAAAAAAARRRRRRRRGGHHHHH Hate captcha in the google maps.  I can understand how it needs to protect itself against spam, but this is ludicrous.  I was playing with the google maps api writing a simple google maps mashup.  This meant editing my js file and reloading the pages a few times.  Somehow google flagged this as a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=28&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>AAAAAAAAAAAAAAAAAAAAAARRRRRRRRGGHHHHH</p>
<p>Hate captcha in the google maps.  I can understand how it needs to protect itself against spam, but this is ludicrous.  I was playing with the google maps api writing a simple google maps mashup.  This meant editing my js file and reloading the pages a few times.  Somehow google flagged this as a sequence of spam requests.  So it shows me the dreaded captcha page.  I enter the damn captcha.  You would think a company like google would be smart enough to let you get on with your work.  Oh no, it brings up the captcha page again.  May be I got the captcha wrong originally so I tried again, no luck.  Now onto my 100th try in a row and still no luck.  Google still thinks my requests (from a FF3 browser) are all spam requests.</p>
<p>Is this the sign that gOoGle is finally going the MS way?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=28&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/02/11/google-captcha-got-my-tongue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>gprobe &#8211; Json Parser</title>
		<link>http://panyam.wordpress.com/2008/02/07/gprobe-json-parser/</link>
		<comments>http://panyam.wordpress.com/2008/02/07/gprobe-json-parser/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 00:03:03 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=27</guid>
		<description><![CDATA[Here is the code for the json parser I had described in an earlier post.  It is still to be fully tested (works for our purpose right now). Essentially data is fed into the parser continuosly (as there are no blocked reads in flex from the socket). Usage is: var parser:GPJsonParser = new GPJsonParser() parser.processBytes(byteArray) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=27&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is the code for the json parser I had described in an earlier post.  It is still to be fully tested (works for our purpose right now).</p>
<p>Essentially data is fed into the parser continuosly (as there are no blocked reads in flex from the socket).</code></p>
<p>Usage is:</p>
<p><code><br />
var parser:GPJsonParser = new GPJsonParser()<br />
parser.processBytes(byteArray)<br />
var nextObj:* = parser.next();<br />
while (nextObj != null)<br />
{<br />
    // do something with nextObj<br />
    nextObj = parser.next();<br />
}<br />
</code></p>
<p>nextObj will only be non-null if there were no syntax errors and if enough bytes were consumed to produced a complete json fragment.</p>
<p><code>package gprobe.utils<br />
{<br />
</code></p>
<blockquote><p><code> import flash.utils.ByteArray;</code>/*<br />
* On-demand parser for parsing json from a stream<br />
*/<br />
public class GPJsonParser<br />
{<br />
private static var STATE_EOF:int                  = -1;<br />
private static var STATE_START:int                = 0;<br />
private static var STATE_READING_IDENTIFIER:int    = 1;<br />
private static var STATE_READING_NUMBER:int       = 2;<br />
private static var STATE_READING_STRING:int       = 3;</p>
<p>private static var OBJ_NULL:int         = 0;<br />
private static var OBJ_BOOL:int         = 1;<br />
private static var OBJ_NUMBER:int       = 2;<br />
private static var OBJ_STRING:int       = 3;<br />
private static var OBJ_LIST:int         = 4;<br />
private static var OBJ_STRUCT:int       = 5;<br />
private static var OBJ_COMA:int         = 6;<br />
private static var OBJ_COLON:int        = 7;<br />
private static var OBJ_OPEN_BRACE:int   = 8;<br />
private static var OBJ_OPEN_SQUARE:int  = 9;<br />
private static var OBJ_CLOSE_BRACE:int  = 10;<br />
private static var OBJ_CLOSE_SQUARE:int = 11;</p>
<p>/*<br />
* Current string delimiter only valid if we are<br />
* currently reading a string<br />
*/<br />
private var currDelim:int;</p>
<p>/*<br />
* Current string - only if we are reading a string<br />
*/<br />
private var currString:String;</p>
<p>/*<br />
* State in reading current string<br />
*/<br />
private var currStringState:int;</p>
<p>/*<br />
* The byte buffer<br />
*/<br />
private var byteBuffers: Array = new Array();</p>
<p>/*<br />
*<br />
*/<br />
private var currBuffer: ByteArray;</p>
<p>/*<br />
* Number of bytes read since start of object<br />
*/<br />
private var bytesRead: int;</p>
<p>/*<br />
* Current parser state<br />
*/<br />
private var currState: int;</p>
<p>/*<br />
* How many unmatched open square brackets have we encountered?<br />
*/<br />
private var squareCount: int = 0;</p>
<p>/*<br />
* How many unmatched open braces have we encountered?<br />
*/<br />
private var braceCount: int = 0;</p>
<p>/*<br />
* Current parent object<br />
*/<br />
private var objStack: Array = null;</p>
<p>private static const CHAR_BSLASH:int = '\/'.charCodeAt(0);<br />
private static const CHAR_DQUOTE:int = '"'.charCodeAt(0);<br />
private static const CHAR_SQUOTE:int = '\''.charCodeAt(0);<br />
private static const CHAR_PLUS:int = '+'.charCodeAt(0);<br />
private static const CHAR_DOT:int = '.'.charCodeAt(0);<br />
private static const CHAR_a:int = 'a'.charCodeAt(0);<br />
private static const CHAR_A:int = 'A'.charCodeAt(0);<br />
private static const CHAR_e:int = 'e'.charCodeAt(0);<br />
private static const CHAR_E:int = 'E'.charCodeAt(0);<br />
private static const CHAR_t:int = 't'.charCodeAt(0);<br />
private static const CHAR_v:int = 'v'.charCodeAt(0);<br />
private static const CHAR_b:int = 'b'.charCodeAt(0);<br />
private static const CHAR_f:int = 'f'.charCodeAt(0);<br />
private static const CHAR_r:int = 'r'.charCodeAt(0);<br />
private static const CHAR_n:int = 'n'.charCodeAt(0);<br />
private static const CHAR_z:int = 'z'.charCodeAt(0);<br />
private static const CHAR_Z:int = 'Z'.charCodeAt(0);<br />
private static const CHAR_0:int = '0'.charCodeAt(0);<br />
private static const CHAR_9:int = '9'.charCodeAt(0);<br />
private static const CHAR_SLASH:int = '\\'.charCodeAt(0);<br />
private static const CHAR_SPACE:int = ' '.charCodeAt(0);<br />
private static const CHAR_MINUS:int = '-'.charCodeAt(0);<br />
private static const CHAR_UND:int = '_'.charCodeAt(0);<br />
private static const CHAR_TAB:int = '\t'.charCodeAt(0);<br />
private static const CHAR_CR:int = '\r'.charCodeAt(0);<br />
private static const CHAR_LF:int = '\n'.charCodeAt(0);<br />
private static const CHAR_COMA:int = ','.charCodeAt(0);<br />
private static const CHAR_COLON:int = ':'.charCodeAt(0);<br />
private static const CHAR_OSQ:int = '['.charCodeAt(0);<br />
private static const CHAR_CSQ:int = ']'.charCodeAt(0);<br />
private static const CHAR_OBRACE:int = '{'.charCodeAt(0);<br />
private static const CHAR_CBRACE:int = '}'.charCodeAt(0);</p>
<p>/*<br />
* Constructor<br />
*/<br />
public function GPJsonParser()<br />
{<br />
reset();<br />
}</p>
<p>/*<br />
* Resets the parser<br />
*/<br />
public function reset(resetBytes:Boolean = true): void<br />
{<br />
objStack        = [];<br />
currState       = STATE_START;<br />
bytesRead       = 0;<br />
currString      = "";<br />
currStringState = 0;<br />
squareCount     = 0;<br />
braceCount      = 0;<br />
if (resetBytes)<br />
{<br />
byteBuffers = new Array();<br />
currBuffer  = null;<br />
}<br />
}</p>
<p>/*<br />
* Process more bytes.<br />
*<br />
* Returns nothing.  Call next() to retrieve the next object<br />
* from the stream (if any).<br />
*/<br />
public function processBytes(data:ByteArray): void<br />
{<br />
byteBuffers.push(data);<br />
}</p>
<p>/*<br />
* Return the next object from the stream.<br />
* null if none (this is not necessarily an error, just means we do<br />
* not have enough bytes given to us to extract the next object).<br />
*/<br />
public function next(): *<br />
{<br />
var currCh:*;<br />
var readChar:Boolean = true;</p>
<p>while ( ! (objStack.length == 1 &amp;&amp; squareCount == 0 &amp;&amp; braceCount == 0))<br />
{<br />
if (currBuffer == null || currBuffer.bytesAvailable == 0)<br />
{<br />
if (byteBuffers.length == 0)<br />
{<br />
return null;<br />
}<br />
currBuffer = byteBuffers.pop();<br />
}<br />
if (readChar)<br />
{<br />
if (currBuffer.bytesAvailable == 0)<br />
return null;<br />
bytesRead++;<br />
currCh = currBuffer.readByte();<br />
}<br />
else<br />
{<br />
readChar = true;<br />
}</p>
<p>if (currState == STATE_READING_STRING)<br />
{<br />
processStringBytes(currCh);<br />
}<br />
else if (currState == STATE_READING_IDENTIFIER)<br />
{<br />
if ((currCh &gt;= CHAR_a &amp;&amp; currCh &lt;= CHAR_z)         ||<br />
(currCh &gt;= CHAR_A &amp;&amp; currCh &lt;= CHAR_Z)     ||<br />
(currCh &gt;= CHAR_0 &amp;&amp; currCh &lt;= CHAR_9)     ||<br />
currCh == CHAR_UND)<br />
{<br />
currString += String.fromCharCode(currCh);<br />
}<br />
else<br />
{<br />
if (currString == "true")<br />
{<br />
shift(OBJ_BOOL, true);<br />
}<br />
else if (currString == "false")<br />
{<br />
shift(OBJ_BOOL, false);<br />
}<br />
else if (currString == "null")<br />
{<br />
shift(OBJ_NULL, null);<br />
}<br />
else<br />
{<br />
shift(OBJ_STRING, currString);<br />
//throw new Error("Invalid identifier: " + currString);<br />
}</p>
<p>currState = STATE_START;<br />
readChar = false;<br />
}<br />
}<br />
else if (currState == STATE_READING_NUMBER)<br />
{<br />
if ( ! processNumberBytes(currCh))<br />
{<br />
readChar = false;<br />
}<br />
}<br />
else if (currState == STATE_START)<br />
{<br />
if (currCh == CHAR_SPACE || currCh == CHAR_TAB ||<br />
currCh == CHAR_CR || currCh == CHAR_LF)<br />
{<br />
// ignore white spaces<br />
}<br />
else if ((currCh &gt;= CHAR_a &amp;&amp; currCh &lt;= CHAR_z)         ||<br />
(currCh &gt;= CHAR_A &amp;&amp; currCh &lt;= CHAR_Z)     ||<br />
currCh == CHAR_UND)<br />
{<br />
currState = STATE_READING_IDENTIFIER;<br />
currString = String.fromCharCode(currCh);<br />
}<br />
else if (currCh == CHAR_MINUS || (currCh &gt;= CHAR_0 &amp;&amp; currCh &lt;= CHAR_9))<br />
{<br />
currState = STATE_READING_NUMBER;<br />
currStringState = 0;<br />
processNumberBytes(currCh);<br />
}<br />
else if (currCh == CHAR_SQUOTE || currCh == CHAR_DQUOTE)<br />
{<br />
currDelim = currCh;<br />
currString = "";<br />
currState = STATE_READING_STRING;<br />
}<br />
else if (currCh == CHAR_COMA)<br />
{<br />
shift(OBJ_COMA);<br />
}<br />
else if (currCh == CHAR_COLON)<br />
{<br />
shift(OBJ_COLON);<br />
}<br />
else if (currCh == CHAR_OSQ)<br />
{<br />
squareCount++;<br />
shift(OBJ_OPEN_SQUARE);<br />
}<br />
else if (currCh == CHAR_OBRACE)<br />
{<br />
braceCount++;<br />
// shift(OBJ_STRUCT, new Object());<br />
shift(OBJ_OPEN_BRACE);<br />
}<br />
else if (currCh == CHAR_CSQ)<br />
{<br />
squareCount--;<br />
shift(OBJ_CLOSE_SQUARE);<br />
}<br />
else if (currCh == CHAR_CBRACE)<br />
{<br />
braceCount--;<br />
shift(OBJ_CLOSE_BRACE);<br />
}<br />
}<br />
}</p>
<p>if (objStack.length == 1)<br />
{<br />
var obj:Object = objStack.pop();<br />
reset(false);<br />
return obj['value'];<br />
}</p>
<p>return null;<br />
}</p>
<p>/*<br />
* Shifts a token onto the stack and immediately reduces it (the<br />
* stack)<br />
*/<br />
private function shift(tok:int, value: * = null): void<br />
{<br />
if (tok == OBJ_CLOSE_SQUARE || tok == OBJ_CLOSE_BRACE)<br />
{<br />
reduce(tok);<br />
}<br />
else<br />
{<br />
objStack.push({'type': tok, 'value': value});<br />
}<br />
}</p>
<p>/*<br />
* Reduces the parse stackby utilising the next token.<br />
* Reduction can happen more than once.<br />
*/<br />
private function reduce(topType:int): void<br />
{<br />
var t1: *;<br />
var t2: *;</p>
<p>if (topType == OBJ_CLOSE_SQUARE)<br />
{<br />
// we are building a list<br />
var newArray: Array = new Array();<br />
while (objStack.length &gt; 0 &amp;&amp;<br />
objStack[objStack.length - 1]['type'] != OBJ_OPEN_SQUARE)<br />
{<br />
t1 = objStack.pop();<br />
if (t1['type'] == OBJ_COMA)<br />
t1 = objStack.pop();<br />
newArray.push(t1['value']);<br />
}<br />
if (objStack.length == 0 || objStack[objStack.length - 1]['type'] != OBJ_OPEN_SQUARE)<br />
{<br />
throw new Error("Could not find '['");<br />
}<br />
objStack.pop();<br />
newArray.reverse();<br />
objStack.push({'type': OBJ_LIST, 'value': newArray});<br />
}<br />
else<br />
{<br />
// we are building a map<br />
var newObj: Object = new Object();<br />
while (objStack.length &gt; 0 &amp;&amp;<br />
objStack[objStack.length - 1]['type'] != OBJ_OPEN_BRACE)<br />
{<br />
t1 = objStack.pop();<br />
if (t1['type'] == OBJ_COMA)<br />
{<br />
t1 = objStack.pop();<br />
}</p>
<p>t2 = objStack.pop();<br />
if (t2['type'] != OBJ_COLON)<br />
{<br />
throw new Error("':' expected but not found");<br />
}<br />
t2 = objStack.pop();</p>
<p>newObj[t2['value']] = t1['value'];<br />
}<br />
if (objStack.length == 0 || objStack[objStack.length - 1]['type'] != OBJ_OPEN_BRACE)<br />
{<br />
throw new Error("Could not find '{'");<br />
}<br />
objStack.pop();<br />
objStack.push({'type': OBJ_STRUCT, 'value': newObj});<br />
}<br />
}</p>
<p>private function processNumberBytes(currCh: *): Boolean<br />
{<br />
var NUM_START:int               = 0;<br />
var NUM_READING_INT:int         = 1;<br />
var NUM_READING_DOT:int         = 2;<br />
var NUM_READING_FRAC:int        = 3;<br />
var NUM_READING_EXP:int         = 4;<br />
var NUM_READING_EXP_DIGITS:int  = 5;</p>
<p>if (currStringState == NUM_START)<br />
{<br />
currString         = "";<br />
currStringState = NUM_READING_INT;<br />
if (currCh == CHAR_MINUS)<br />
{<br />
currString     = '-';<br />
return true;<br />
}<br />
}</p>
<p>if (currStringState == NUM_READING_INT)<br />
{<br />
if (currCh &gt;= CHAR_0 &amp;&amp; currCh &lt;= CHAR_9)<br />
{<br />
currString += String.fromCharCode(currCh);<br />
return true;<br />
}<br />
else<br />
{<br />
currStringState = NUM_READING_DOT;<br />
}<br />
}</p>
<p>if (currStringState == NUM_READING_DOT)<br />
{<br />
if (currCh == CHAR_DOT)<br />
{<br />
currString += '.';<br />
return true;<br />
}<br />
else if (currCh == CHAR_e || currCh == CHAR_E)<br />
{<br />
currString += 'e';<br />
currStringState = NUM_READING_EXP;<br />
return true;<br />
}</p>
<p>currStringState = NUM_READING_FRAC;<br />
}</p>
<p>if (currStringState == NUM_READING_FRAC)<br />
{<br />
if (currCh &gt;= CHAR_0 &amp;&amp; currCh &lt;= CHAR_9)<br />
{<br />
currString += String.fromCharCode(currCh);<br />
return true;<br />
}<br />
else if (currCh == CHAR_e || currCh == CHAR_E)<br />
{<br />
currString += 'e';<br />
currStringState = NUM_READING_EXP;<br />
return true;<br />
}<br />
}</p>
<p>if (currStringState == NUM_READING_EXP)<br />
{<br />
currStringState = NUM_READING_EXP_DIGITS;<br />
if (currCh == CHAR_PLUS)<br />
{<br />
currString += '+';<br />
return true;<br />
}<br />
else if (currCh == CHAR_MINUS)<br />
{<br />
currString += '-';<br />
return true;<br />
}<br />
}</p>
<p>if (currStringState == NUM_READING_EXP_DIGITS)<br />
{<br />
if (currCh &gt;= CHAR_0 &amp;&amp; currCh &lt;= CHAR_9)<br />
{<br />
currString += String.fromCharCode(currCh);<br />
return true;<br />
}<br />
}</p>
<p>currState = STATE_START;<br />
shift(OBJ_NUMBER, Number(currString));</p>
<p>// invalid char, must be end of numeric<br />
// value so let the caller take care of the<br />
// rest by not consuming the character<br />
return false;<br />
}<br />
private function processStringBytes(currCh: *): void<br />
{<br />
var STR_NORMAL:int = 0;<br />
var STR_SLASH:int  = 1;</p>
<p>if (currStringState == STR_SLASH)<br />
{<br />
currStringState = STR_NORMAL<br />
if (currCh == CHAR_SLASH)<br />
{<br />
currString += '\\';<br />
}<br />
else if (currCh == CHAR_t)<br />
{<br />
currString += '\t';<br />
}<br />
else if (currCh == CHAR_n)<br />
{<br />
currString += '\n';<br />
}<br />
else if (currCh == CHAR_r)<br />
{<br />
currString += '\r';<br />
}<br />
else if (currCh == CHAR_b)<br />
{<br />
currString += '\b';<br />
}<br />
else if (currCh == CHAR_f)<br />
{<br />
currString += '\f';<br />
}<br />
else if (currCh == CHAR_BSLASH)<br />
{<br />
currString += '\/';<br />
}<br />
else if (currCh == CHAR_DQUOTE)<br />
{<br />
currString += '"';<br />
}<br />
else if (currCh == CHAR_SQUOTE)<br />
{<br />
currString += '\'';<br />
}<br />
else<br />
{<br />
currString += ("\\" + currCh);<br />
}<br />
}<br />
else if (currCh == currDelim)<br />
{<br />
currState = STATE_START;<br />
shift(OBJ_STRING, currString);<br />
}<br />
else<br />
{<br />
currString += String.fromCharCode(currCh);<br />
}<br />
}<br />
}</p></blockquote>
<p>}<br />
Essentially, since data is read asynchronously, it needs to be "fed" data as it is recieved by calling</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=27&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/02/07/gprobe-json-parser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>gprobe &#8211; Part 1 &#8211; Message Formats</title>
		<link>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/</link>
		<comments>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 14:27:04 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=24</guid>
		<description><![CDATA[Message transport (between the gprobe, the game server I had written for my work in my spare time and the front end client) was using json or  Action Message Format, AMF.  Reason for the duality, was that for quick testing, I could login into the server with simple telnet and send (textual) commands and recieve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=24&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Message transport (between the gprobe, the game server I had written for my work in my spare time and the front end client) was using json or  Action Message Format, AMF.  Reason for the duality, was that for quick testing, I could login into the server with simple telnet and send (textual) commands and recieve data in json format &#8211; Simple.  However, I could not find a built in JSON parser for Flex and writing one (again, as I had already written one in C++ for the server side) &#8211; didnt just seem too appealing.  Luckily, Flex is capable of serializing and deserializing objects in binary format over a stream &#8211; yep &#8211; the <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">Action Message Format or AMF</a>.  Adding the AMF serializer to the server was fairly simple (did take few hints on the integer encoding from <a href="http://pyamf.org" target="_blank">pyamf</a> &#8211; thanks guys).</p>
<p>Now the problem was that I could not find a way of debugging the decoding (on the flex side) of the AMF stream I had generated from my server.  Why do I need debugging you ask?  Well, I was having random errors in the AMF stream (no doubt due to my encoding) while encoding strings.  Due to time-constraints I had decided to switch to JSON.  This meant I had to write a json parser for flex (as I could not find one at the time).  Not too bad as it gave me a lot of insight into what was being sent and so on.  One day when I earn more free time at work I may decided to debug my AMF encoder.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=24&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Happy 3rd of January</title>
		<link>http://panyam.wordpress.com/2008/01/02/happy-3rd-of-january/</link>
		<comments>http://panyam.wordpress.com/2008/01/02/happy-3rd-of-january/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 22:57:43 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/2008/01/02/happy-3rd-of-january/</guid>
		<description><![CDATA[Happy new year and a happy 3rd of January to all.  No, nothing significant about that date except that it happens to be the date of my first blog (hopefully of hundreds, cough cough) this  year. Been a great vacation.  Drove down to Melbourne to visit the parents.  Boy that was relaxing and tiring at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=25&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Happy new year and a happy 3rd of January to all.  No, nothing significant about that date except that it happens to be the date of my first blog (hopefully of hundreds, cough cough) this  year.</p>
<p>Been a great vacation.  Drove down to Melbourne to visit the parents.  Boy that was relaxing and tiring at the same time.  Cant believe time just dissapeared before I knew it!</p>
<p>Any hoo a happy 2008 to all.  Hope 2007 was a great year for all of you and hope 2008 is much better!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&amp;blog=841257&amp;post=25&amp;subd=panyam&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/01/02/happy-3rd-of-january/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
	</channel>
</rss>
