<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Arunrocks &#187; Technical</title> <atom:link href="http://www.arunrocks.com/blog/archives/category/technical/feed/" rel="self" type="application/rss+xml" /><link>http://www.arunrocks.com/blog</link> <description>Representing Anti-monotonistic Tendencies</description> <lastBuildDate>Sun, 15 Aug 2010 06:25:55 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.8.6</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Mars Rover in Python and Haskell</title><link>http://www.arunrocks.com/blog/archives/2010/02/01/mars-rover-in-python-and-haskell/</link> <comments>http://www.arunrocks.com/blog/archives/2010/02/01/mars-rover-in-python-and-haskell/#comments</comments> <pubDate>Mon, 01 Feb 2010 07:02:52 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Python]]></category> <category><![CDATA[Technical]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=234</guid> <description><![CDATA[Last week I tried to do something which I've been planning for quite sometime. Porting a Python program into Haskell.  I first solved the Mars Rover (used by Thoughtworks) in Python and later attempted to solve the same in Haskell.]]></description> <content:encoded><![CDATA[<p>Last week I tried to do something which I&#8217;ve been planning for quite sometime. Porting a Python program into Haskell. In case you didn&#8217;t know, <a
href="http://www.haskell.org/">Haskell</a> is a purely functional programming language that&#8217;s recently become a hot favourite. It has a lot of cutting edge ideas from the academic world esp laziness and strong typing. It has an interesting way to solve the &#8216;multi-CPU problem&#8217;.</p><p>Mars Rover is a famous programming problem used by <a
href="http://www.thoughtworks.com/">Thoughtworks</a> in their recruitments. I first solved the problem in Python and later attempted to solve the same in Haskell. I cannot say that I ported it from Python because the approach I&#8217;ve used is completely different.</p><h3>The Problem</h3><blockquote><p>A squad of robotic rovers are to be landed by NASA on a plateau on Mars.</p><p>This plateau, which is curiously rectangular, must be navigated by the rovers so that their on-board cameras can get a complete view of the surrounding terrain to send back to Earth.</p><p>A rover&#8217;s position and location is represented by a combination of x and y co-ordinates and a letter representing one of the four cardinal compass points. The plateau is divided up into a grid to simplify navigation. An example position might be 0, 0, N, which means the rover is in the bottom left corner and facing North.</p><p>In order to control a rover , NASA sends a simple string of letters. The possible letters are &#8216;L&#8217;, &#8216;R&#8217; and &#8216;M&#8217;. &#8216;L&#8217; and &#8216;R&#8217; makes the rover spin 90 degrees left or right respectively, without moving from its current spot. &#8216;M&#8217; means move forward one grid point, and maintain the same heading.</p><p>Assume that the square directly North from (x, y) is (x, y+1).</p><p>INPUT:</p><p>The first line of input is the upper-right coordinates of the plateau, the lower-left coordinates are assumed to be 0,0.</p><p>The rest of the input is information pertaining to the rovers that have been deployed. Each rover has two lines of input. The first line gives the rover&#8217;s position, and the second line is a series of instructions telling the rover how to explore the plateau.</p><p>The position is made up of two integers and a letter separated by spaces, corresponding to the x and y co-ordinates and the rover&#8217;s orientation.</p><p>Each rover will be finished sequentially, which means that the second rover won&#8217;t start to move until the first one has finished moving.</p><p>OUTPUT</p><p>The output for each rover should be its final co-ordinates and heading.</p><p>INPUT AND OUTPUT</p><p>Test Input:</p><p>5 5<br
/> 1 2 N<br
/> LMLMLMLMM<br
/> 3 3 E<br
/> MMRMMRMRRM<br
/> <br
/> Expected Output:<br
/> <br
/> 1 3 N<br
/> 5 1 E</p></blockquote><h3>The Python solution</h3><p>The Python solution is actually smaller than the problem itself. The readability isn&#8217;t that great, but it is quite extensible. In fact, adding a new instruction like <code>B(ackward)</code> would need just one additional line. You can also extend the four cardinal directions to eight with minimal changes to the code.</p> <script src="http://gist.github.com/291495.js?file=rover.py"></script> <h3>The Haskell solution</h3><p>I am a beginner in Haskell, so apologies for any bad coding practices. You might notice that rather than using Reflection as in the Python code, I have used Type-inference to invoke the correct function for each instruction. Yet again, this scales well while adding new instructions.</p> <script src="http://gist.github.com/291497.js?file=rover.hs"></script> <h3>Key learnings</h3><p>Since some of you might be interested in Haskell, I have tried to summarize my experience in Haskell programming</p><ol><li>There are no loop constructs. So everything must be done using recursion!</li><li>Haskell I/O is very hard. This is because of my little knowledge of Monads. In fact, I solved the logic pretty quickly. It took me a while to figure out the input parsing.</li><li>Type inference catches a lot of errors. This is quite handy but error messages are sometimes confusing</li><li>I could have used Abstract Data Types for directions but it would have made the code lengthier</li></ol><p>In short, programming in Haskell is a mind-bending exercise. Highly recommended!</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2010/02/01/mars-rover-in-python-and-haskell/feed/</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Managing Creative Assets &#8211; 2: Distributed Version Control Systems</title><link>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-2/</link> <comments>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-2/#comments</comments> <pubDate>Mon, 14 Dec 2009 02:31:29 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Python]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[backup]]></category> <category><![CDATA[bazaar]]></category> <category><![CDATA[creativity]]></category> <category><![CDATA[distributed version control]]></category> <category><![CDATA[git]]></category> <category><![CDATA[hg]]></category> <category><![CDATA[lifehacks]]></category> <category><![CDATA[mercurial]]></category> <category><![CDATA[productivity]]></category> <category><![CDATA[version control]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=171</guid> <description><![CDATA[Managing Creative Assets is a multi-part series on how you can manage your creative works such as a novel or even blog post without impairing your creativity. It highlights the importance of using a version control system as an integral part of one&#8217;s creative workflow. Part 1 gives a good introduction to the series which [...]]]></description> <content:encoded><![CDATA[<p><em>Managing Creative Assets is a multi-part series on how you can manage your creative works such as a novel or even blog post without impairing your creativity. It highlights the importance of using a version control system as an integral part of one&#8217;s creative workflow. <a
href="/blog/archives/2009/12/13/managing-creative-assets-1/">Part 1</a> gives a good introduction to the series which is aimed at technology novices</em></p><h2>Who started the Fire?</h2><p>In April 7, 2005, Linus Torvalds wanted to use a version control system to replace the proprietary BitKeeper system for developing Linux Kernel. He absolutely hated CVS (the version control system in vogue then) with a passion. So, he did what he did best, he wrote his own. This resulted in the release of a version control system called git.</p><p>The development of git led to a sudden interest in distributed version control systems (DVCS). Though it was not the first of its kind (earlier open-source DVCS existed like Arch and Monotone), it was the first mainstream DVCS.</p><p>Today, one of the first choices you need to make while selecting a version control system is whether it is centralised or distributed. Let&#8217;s understand this from own unique stand-point i.e. for managing creative assets.</p><h3>Why I do not advice VSS, Subversion or a Central Version Control</h3><p>What is a Centralised Version Control (CVC)? The odds are that most of the version control systems that you might have heard of are Centralised for e.g. VSS (Microsoft Visual Sourcesafe), CVS, RCS, Clearcase or Subversion.</p><p>If you are planning to use a version control for personal use involving no or minimal collaboration with others, I would strongly recommend not to use a centralised version control system. You can skip to the next section, if you don&#8217;t want a detailed set of reasons on why I recommend non-centralised version control.</p><p>The reasons I would cite here are a mix of usability issues and technical limitations. The usability issues are subjective but I am sure many find them genuinely annoying. I am making an assumption that since this is for personal version control management, so your CVC server would probably be installed locally. The problems are:</p><ol><li><p><strong>Everything is stored inside repositories</strong>: Adding your project to a CVC effectively creates a duplicate layout of your project inside the CVC server. For e.g. if you created your subversion repository within <code>C:\svn</code>, all your projects will be kept inside this folder. You will have to maintain another filesystem inside this server using arcane commands.</p><p>In a distributed version control system, you simply manage the project directory inside your normal filesystem. All the version controlled files will still be inside the project directory. This is quite useful since your project directory can be moved to a different location easily and the version history will be completely intact.</p></li><li><p><strong>Server must be always running</strong>: If you have installed VSS or SVN locally, you must always remember to start the server. This can be configured to run as a service, but you will need admin privileges for this. This is not required in a distributed version control.</p></li><li><p><strong>Offline activity cannot be checked-in</strong>: This is an oft-quoted technical limitation. You need your svn server running to make any check-ins or check-outs, making it considerably less useful whenever you are offline. But this is less of an issue in our case, since I assume the svn server is installed locally.</p></li><li><p><strong>Remembering to checkout immediately after you import or check-in</strong>: Ever had the feeling that your files magically disappeared only to realise that you haven&#8217;t checked out? This is an irritating &#8216;feature&#8217; of CVS. The files appear and disappear as you check in and out. Even worse is that they are sometimes read-only and sometimes writeable. This is confusing and irritating from a usability standpoint.</p><p>Apparently, most people leave their relevant files checked out at all times to avoid this confusion. But that would defeat the purpose. In a distributed version control, the files are always present where you expect them to be. This leads to less confusion and a world of improvement in terms of usability.</p></li><li><p><strong>Weird layout</strong>: Ever seen a funny looking directory structure with <code>truck</code>, <code>branches</code> and <code>tags</code> directories? Then you might be looking at a project under SVN. Ever wondered which directory actually contains your code? The right answer is <code>trunk</code>. I am not sure, if this is  the most intuitive structure possible.</p></li><li><p><strong>Distributed Version Control is a superset</strong>: This should have been my first point, almost <a
href="http://bazaar-vcs.org/Workflows" title="Different kinds of workflow on Bazaar">every centralised workflow can be now supported</a> by Distributed Version Control. You can still upload (or &#8220;push&#8221;) stuff from your branches to the project&#8217;s central server.</p></li></ol><p>If you are still not convinced and still prefer centralised version control, check out <a
href="http://www.codinghorror.com/blog/archives/001093.html" title="Setting up svn and TortoiseSVN in Windows">the easiest way to setup subversion in Windows</a> written by Jeff Croft.</p><h3>Distributed Sounds Complex</h3><p>It is a common misconception that Distributed Version Control systems are difficult to use and hard to understand. In many ways, the concepts are simpler than traditional version control systems from a beginner&#8217;s perspective.</p><p>Assume that the files (say documents or images) related to your project are kept under a particular directory. This is called the Project folder. Traditionally, your project folder will be stored in a central server. Hence the name <em>centralised</em> version control.</p><p>Whenever you would need to use a particular file within this folder, you will need to check-out and once you have reached some logical point (say after adding a few paragraphs in your essay or sketching the torso of a toon) you would check-in.</p><p>These check-ins are like check-points. More check-points you add, the more finer undo history you will get. Fewer check-points will mean that there will be a lot of differences from one check-in to another making it less useful.</p><p>As you might have guessed, every time you need to check-in or check-out you will need to connect to the server. Hence, practically, you will need the server (installed on your machine or elsewhere) up and running at all times.</p><p>If someone else would like to work with you on the same project, they will need to connect to your server. If they would like to work on the same files that you are working on (a rare case), they would need to create a branch and work on the branch.</p><p>This collaborative scenario is slightly different when you are working with a DVCS.</p><h4>What About Distributed?</h4><p>In a distributed version control system, your friend would rather clone your entire project than branch it. After creating a clone, his copy will be identical to your repository in every way. It will have the entire version history intact.</p><p>He no longer needs to be connect to your repository, he can work independently. In fact, there is really no need for a server in DVCS. The repository is actually created within the project folder.</p><p>For instance, let&#8217;s take the initial scenario. You would like to add your project folder to version control. In a DVCS, the project folder is slightly modified to add some additional information (meta-data) which is typically hidden from the user. Hence, your project folder remains mostly intact and it doesn&#8217;t have to move into a server.</p><p>In short, the defining feature of DVCS is that there can be more than one &#8220;central&#8221; repository for the same project. In case, your repository gets nuked, the cloned repository with your friend is always available as a perfect clone. To quote:</p><blockquote><p>&#8220;Only wimps use tape backup: <em>real</em> men just upload their important stuff on ftp, and let the rest of the world mirror it ;)&#8221; &#8212; Linus Torvalds (1996-07-20)</p></blockquote><h3>Types of DVCS</h3><p>These are the popular open-source DVCS available:</p><ul><li><strong>Git</strong> &#8211; Very fast DVCS by Linus which runs on UNIX but has a weak port to Windows.</li><li><strong>Mercurial</strong> &#8211; Fast cross-platform DVCS by Matt Mackall of Selenic. Partly written in Python</li><li><strong>Bazaar</strong> &#8211; User friendly cross-platform DVCS by Canonical (of Ubuntu fame). Written in pure Python</li></ul><p>Selecting a DVCS, like most things, is a personal choice. So, you might want to read a more <a
href="http://www.infoq.com/articles/dvcs-guide" title="InfoQ's guide to Distributed Version Control Systems">detailed comparison</a> before making a choice. I would be explaining Mercurial in my <a
href="http://www.arunrocks.com/blog/archives/2009/12/15/managing-creative-assets-3-tortoisehg-tutorial/">next article</a> because it has a nice selection of all the desired features.</p><p><em>Do comment if you found DVCS more interesting or otherwise&#8230;</em></p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-2/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Managing Creative Assets &#8211; 1</title><link>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-1/</link> <comments>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-1/#comments</comments> <pubDate>Sun, 13 Dec 2009 14:24:02 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Python]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[backup]]></category> <category><![CDATA[creativity]]></category> <category><![CDATA[distributed version control]]></category> <category><![CDATA[lifehacks]]></category> <category><![CDATA[productivity]]></category> <category><![CDATA[version control]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=159</guid> <description><![CDATA[Managing Creative Assets is a multi-part series on how you can manage your creative works such as a novel or even blog post without impairing your creativity. It highlights the importance of using a version control system as an integral part of one's creative workflow]]></description> <content:encoded><![CDATA[<p><em>Managing Creative Assets is a multi-part series on how you can manage your creative works such as a novel or even blog post without impairing your creativity. It highlights the importance of using a version control system as an integral part of one&#8217;s creative workflow</em></p><h2>Why Do We Need A Version Control system?</h2><p>Let me start off by saying that this is article is not for the techies. Despite what the title might tell you, this is an article about how to make computers help your creative process. How does a creative process work?</p><p>Most creative people follow the following simplified process <a
href="http://en.wikipedia.org/wiki/Creativity#Graham_Wallas" title="Wallas model">attributed to Graham Wallas</a> while thinking creatively:</p><ul><li><strong>Preparation</strong> (preparatory work on a problem that focuses the individual&#8217;s mind on the problem and explores the problem&#8217;s dimensions),</li><li><strong>Incubation</strong> (where the problem is internalized into the unconscious mind and nothing appears externally to be happening),</li><li><strong>Intimation</strong> (the creative person gets a &#8216;feeling&#8217; that a solution is on its way),</li><li><strong>Illumination</strong> or insight (where the creative idea bursts forth from its preconscious processing into conscious awareness); and</li><li><strong>Verification</strong> (where the idea is consciously verified, elaborated, and then applied).</li></ul><p>Obviously, this is an iterative process. Most writers would have a pile of crumpled paper sheets overflowing their waste baskets. Be prepared to reject a lot of ideas (even good ones) when you are involved in some creative process. Sometimes, against your earlier good judgement you would like to go back and retrieve an idea that you had discarded. You may have to rummage your waste basket for that page and if you are lucky, you might find it among the pile.</p><p>These days most of the creative works; be it a novel, a movie or even a comic is prepared on a computer. However, the process of throwing away drafts into the waste basket and later digging them out, is still the way we humans work. The various ways people achieve this in practise is:</p><ol><li><p><strong>Saving multiple version</strong>: This results in a whole mess of files grouped by their prefixes. Some prefer to suffix them with version numbers like <em>file-v0.5.doc</em>, <em>file-v1.0.doc</em> etc, while others prefer to use descriptive suffixes like <em>file-draft.doc</em>, <em>file-sentforreview.doc</em> etc. As anyone who might have used this system would have experienced, this quickly becomes unwieldy. For example what is the difference between <em>file-v0.5.doc</em> and <em>file-v1.0.doc</em>? How can I revert to the earliest version while correcting many of the typos I found in the latest version?</p></li><li><p><strong>Using Undo and Redo</strong>: This is a very simple system to understand and hence quite popular among artists. If something doesn&#8217;t feel right, keep pressing the Undo button till you are satisfied and then start over. There are many problems with this approach. Firstly, the timeline is linear. You cannot try two different approaches at the same time. Secondly, the Undo history is available only for a single session. Close the application and the undo history is forgotten.</p></li><li><p><strong>Use a version control system</strong>: This approach relies on an version control system that remembers every version you had ever saved (rather checked-in). This system is the focus of this article.</p></li></ol><p>To extend the analogy further, a version control system can give you a bottomless waste basket with the ability to show you what changes you made from one version to another. Version control systems are powerful enough to allow you to branch out into various versions simultaneously, which is often useful when you are collaborating with others.</p><p>In fact, the addition of a version control system makes a profound change to your creative process. You are no longer afraid to make mistakes. You can play around with your creations without the fear of what you had created so far. Most people are afraid to start from scratch, even though, it is often documented that subsequent creations become more refined and hence elegant due to the better understanding of the &#8216;problem&#8217; mentioned in the <strong>Preparation</strong> phase above. But be mindful of drifting in the opposite direction too, as in the case of the <a
href="http://en.wikipedia.org/wiki/Second-system_effect">Second System effect</a>.</p><p>In the <a
href="http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-2/">next part</a>, we will be introduced to two kinds of version control systems &#8211; Centralized and Distributed; and which one is suited for certain scenarios.</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2009/12/13/managing-creative-assets-1/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>PyCon India Talk 2009: Game Programming in Pyglet</title><link>http://www.arunrocks.com/blog/archives/2009/09/27/pycon-india-talk-2009-game-programming-in-pyglet/</link> <comments>http://www.arunrocks.com/blog/archives/2009/09/27/pycon-india-talk-2009-game-programming-in-pyglet/#comments</comments> <pubDate>Sun, 27 Sep 2009 13:07:59 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Gaming]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[featured]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=154</guid> <description><![CDATA[Thanks to everyone who enjoyed and commented on my talk today titled &#8216;Accelerate Your Game Development with Pyglet&#8217;. I am happy to see so much enthusiasm within the python community for game development. This was my first lightning talk (and the first one for the day as well) and though, I slightly overshot the timelimit, [...]]]></description> <content:encoded><![CDATA[<p>Thanks to everyone who enjoyed and commented on my talk today titled &#8216;Accelerate Your Game Development with Pyglet&#8217;. I am happy to see so much enthusiasm within the python community for game development. This was my first lightning talk (and the first one for the day as well) and though, I slightly overshot the timelimit, it was a great experience.</p><p>The talk was about creating a simple casual game using Pyglet called &#8216;FruitCatch&#8217;. The source code is really small and very readable. I also compared Pyglet with Pygame and why I prefer Pyglet (in certain situations:)). The demo showed the working game in the end.</p><p>You can download the <a
href="http://www.arunrocks.com/downloads/pyconindia2009/fruitcatch-0.1.tar.gz">game source code</a> and <a
href="http://www.arunrocks.com/downloads/pyconindia2009/Accelerate%20Your%20GameDevelopment%20with%20Pyglet.pdf">presentation slides (PDF)</a> here. I&#8217;ve shared this with the organisers as well, so it will be put up at the http://in.pycon.org/ site as well</p><p>UPDATE: The video of the <a
href="http://blip.tv/file/2690880">lightning talk</a> is now available and has been added below:</p><p><span
id="more-154"></span></p><p><embed
src="http://blip.tv/play/AYGlulYC" type="application/x-shockwave-flash" width="480" height="390" allowscriptaccess="always" allowfullscreen="true"></embed></p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2009/09/27/pycon-india-talk-2009-game-programming-in-pyglet/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Weekend Gains</title><link>http://www.arunrocks.com/blog/archives/2009/09/14/weekend-gains/</link> <comments>http://www.arunrocks.com/blog/archives/2009/09/14/weekend-gains/#comments</comments> <pubDate>Mon, 14 Sep 2009 12:41:08 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Technical]]></category> <category><![CDATA[ubuntu]]></category> <category><![CDATA[arch linux]]></category> <category><![CDATA[fedora]]></category> <category><![CDATA[free dos]]></category> <category><![CDATA[hard disk]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[multiboot]]></category> <category><![CDATA[puppy linux]]></category> <category><![CDATA[ram]]></category> <category><![CDATA[weekend]]></category> <category><![CDATA[windows]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=152</guid> <description><![CDATA[This weekend I was pretty productive. Among other things, I was able to perform a much needed upgrade for my laptop after my hard disk crashed and to bring it at par to the prevailing standards, as well. I bought a 320 GB hard disk (up from 100 GB) and added a RAM module bringing [...]]]></description> <content:encoded><![CDATA[<p>This weekend I was pretty productive. Among other things, I was able to perform a much needed upgrade for my laptop after my hard disk crashed and to bring it at par to the prevailing standards, as well. I bought a 320 GB hard disk (up from 100 GB) and added a RAM module bringing the total RAM to 2.5 GB (up from 1 GB). So it&#8217;s a Big Deal :D</p><p>While purchasing the hard disk, I was sure that I don&#8217;t need it to fill it up with lots of data (like movies or songs). I would rather use my external hard disk for that. I had planned to use majority of the space for Linuxes (is that the correct plural form?). Why not Windows, you may ask. Especially with the snazzy Windows 7 being already available for Beta?</p><p>Well the reasons are quite simple. Firstly, too many viruses and malware. Especially, if you have removable storage like <a
href="http://blogs.ad.infosys.com/users/arunv_ravindran/tag/thumb%20drive">pendrives</a> or CDs. Next, it&#8217;s not very stable. Though Windows XP is a comparatively stable member of the Windows family, I have had more than my share of screen freezes and blue screens. This causes bad sectors and reduces the life of your hard disk. Next, most of the apps I use are open source anyways &#8211; Firefox, Open Office, GIMP, Inkscape, Emacs, Foxit etc. Then why not run the same in a better OS like Linux? Lastly, distributions like Ubuntu have become really user-friendly. Vidya and many others who use my laptop really don&#8217;t find it difficult or inconvenient to use.</p><p>Well, you must have noticed the plural form of Linux I&#8217;d used. This weekend I installed the following OSes and they are all working fine:</p><ul><li><a
href="http://www.ubuntu.com/">Ubuntu</a> (Jaunty): Perfect for most multimedia and productivity apps</li><li><a
href="http://fedoraproject.org/">Fedora 11</a>: For trying out Java apps and other <a
href="http://en.wikipedia.org/wiki/Enterprise_application_integration">enterprisey</a> stuff</li><li><a
href="http://www.archlinux.org/">Arch Linux</a>: An ideal hacker&#8217;s OS</li><li><a
href="http://www.microsoft.com/windows/windows-xp/default.aspx">Windows XP</a>: For the necessary evils like movie playback</li><li><a
href="http://www.freedos.org/">FreeDOS</a>: This is the good ol&#8217; DOS. For classic DOS games and simple low level programming</li></ul><p>I am planning to add a couple of more varied distributions. I am currently thinking of adding Puppy Linux and Rescue CD. Any suggestions?</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2009/09/14/weekend-gains/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Decoding Google&#8217;s First Tweet in Python</title><link>http://www.arunrocks.com/blog/archives/2009/02/28/decoding-googles-first-tweet-in-python/</link> <comments>http://www.arunrocks.com/blog/archives/2009/02/28/decoding-googles-first-tweet-in-python/#comments</comments> <pubDate>Sat, 28 Feb 2009 09:10:29 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[featured]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=140</guid> <description><![CDATA[Most of you must have read the news that Google finally jumped into the Twitter Bandwagon. In their trademark style, they have chosen to announce this in a cryptic way. Their first tweet was essentially this:I&#8217;m 01100110 01100101 01100101 01101100 01101001 01101110 01100111 00100000 01101100 01110101 01100011 01101011 01111001 00001010I will explain in [...]]]></description> <content:encoded><![CDATA[<p>Most of you must have read the news that <a
href="http://thenextweb.com/2009/02/26/googles-tweet-official-twitter-account/" title="The news about google's tweet">Google finally jumped into the Twitter Bandwagon</a>. In their trademark style, they have chosen to announce this in a cryptic way. Their <a
href="http://twitter.com/google/status/1251523388" title="Link to Google Twitter account">first tweet</a> was essentially this:</p><blockquote><p>I&#8217;m 01100110 01100101 01100101 01101100 01101001 01101110 01100111 00100000 01101100 01110101 01100011 01101011 01111001 00001010</p></blockquote><p>I will explain in this post how to crack this simple code with the help of some Python one-liners (Google&#8217;s favourite language). If you are a Google aspirant (who isn&#8217;t? ;) ), this might help you clear the interview. So pay attention.</p><p>To most people it is immediately obvious that it is a text encoded in binary. Since each binary word is 8 characters long, it is most probably written in the extended 8-bit ASCII code. In fact, it is and you can read this with a simple <a
href="http://www.cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/ascii.htm" title="ASCII chart">ASCII chart</a>.</p><p>But they have made it slightly difficult for you by writing in binary. Since most charts would provide you a lookup from decimal or hexadecimal numbers to ASCII representations only. So how do you convert from binary to decimal? It&#8217;s quite simple:</p><pre><code>decimal = lambda s: sum(int(j) * pow(2,i) for i,j in enumerate(reversed(s)))
</code></pre><p>This line defines a function <code>decimal</code> which works in a manner similar to how we would manually convert binary numbers into decimal. Each position is multiplied by increasing powers of two from the right. Then, these numbers are added together. for e.g. &#8216;1010&#8242; will be 1 * 8 + 0 * 4 + 1 * 2 + 0 * 1 = 10.</p><p>Next, we split the binary part of the tweet string and apply the <code>decimal</code> function on each part</p><pre><code>tweet = "01100110 01100101 01100101 01101100 01101001 01101110 01100111 00100000 01101100 01110101 01100011 01101011 01111001 00001010"
print ''.join(chr(decimal(s)) for s in tweet.split())
</code></pre><p>The result is something that you might have already guessed seeing the first 2 words:</p><blockquote><p>&#8220;I&#8217;m feeling lucky\n&#8221;</p></blockquote><p>Hope you learnt some interesting python constructs. If there are other ways of decoding this in Python, please comment below.</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2009/02/28/decoding-googles-first-tweet-in-python/feed/</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Forget Pages with Autopagerize</title><link>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/</link> <comments>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/#comments</comments> <pubDate>Sun, 16 Nov 2008 18:49:57 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[firefox]]></category> <category><![CDATA[greasemonkey]]></category> <category><![CDATA[productivity]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=136</guid> <description><![CDATA[Reddit had a heated debate about the AJAX paging pattern. The debate sidetracked into the benefits of Paging. Nobody seemed to mention the excellent greasemonkey script Autopagerize which is proof that the concept works brilliantly. I find it one of the most indispensable Greasemonkey scripts available today.The idea is simple. Assume you are reading a [...]]]></description> <content:encoded><![CDATA[<p>Reddit had a heated debate about the <a
href="http://looksgoodworkswell.blogspot.com/2005/06/death-to-paging-rico-livegrid-released.html">AJAX paging pattern</a>. The debate sidetracked into the benefits of Paging. Nobody seemed to mention the excellent greasemonkey script <a
href="http://userscripts.org/scripts/show/8551">Autopagerize</a> which is proof that the concept works brilliantly. I find it one of the most indispensable Greasemonkey scripts available today.</p><p>The idea is simple. Assume you are reading a blog in blogspot.com. When you scroll towards the end of the blog, Autopagerize realizes that you are really interested in reading more blog posts. In other words, soon you would click on &#8216;Older Entries&#8217; links. This would have caused a fresh page to load. How terribly annoying! Instead, Autopagerize will silently load the older posts in the background and seamlessly add them to the end of the page. By the time you finish reading the second page, the third page will be added to the end and so on and so forth. This results in a smooth and breezy browsing experience, which has to be experienced to be believed.</p><h3>Installing Autopagerize</h3><p><a
href="http://userscripts.org/scripts/show/8551">Autopagerize</a> uses greasemonkey plugin and hence works only if you have Firefox installed. The steps are quite simple:</p><ol><li>Install <a
href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a></li><li>Go to <a
href="http://userscripts.org/scripts/show/8551">Autopagerize script</a> page and click on &#8216;Install this Script&#8217; button</li><li>Visit any of the supported sites e.g. <a
href="http://stackoverflow.com/questions/tagged/python">stackoverflow.com</a> or a blog like <a
href="http://userscripts.org/scripts/show/8551">simblog</a></li><li>If the page supports Autopagerize, a green square will appear at the top right of the page. Scroll to the end and it will momentarily turn blue to indicate that the next page is loading in the background.</li></ol><p><img
src="/blog/wp-content/photos/autopager/00-autopagerize.png" alt="Autopagerize in action" /></p><h3>How does Autopagerize work?</h3><p>Autopagerize works on all kinds of sites which have pages. But how does it manage to understand the structure of them all? The answer is the community maintained SITEINFO database which is the result of hundreds of hours of effort.</p><p>Autopagerize is turned on for a particular site if its URL matches the <strong>url</strong> property. Once the page is loaded, it searches for the next link based on the xpath provided by <strong>nextLink</strong> property. The next page&#8217;s content is identified by the <strong>pageElement</strong> property. Anything which is not part of this content is discarded. This content is then appended to the existing page either by appending as a sibling to the existing <strong>pageElement</strong> or if <strong>insertBefore</strong> is defined, it is inserted before the element identified by <strong>insertBefore</strong> property.</p><h3>How to Add any Website to Autopagerize?</h3><p><em>Note: This is not for the faint of heart. It involves opening and working with some code (to the extend of editing some regular expressions).</em></p><p>So you would like extend the Autopagerize experience to more and more sites? Don&#8217;t worry, you have come to the right place. For this section you would need to install the excellent Firebug plugin. Firebug&#8217;s javascript console is the best interactive XPath debugger I am aware of.</p><p><span
id="more-136"></span></p><p>First, ensure that Firebug console is activated for your site. Visit the page you would like to Autopagerize say <a
href="http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions">http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions</a>. Click on the firebug icon and enable the Console by checking the first check box (as shown in the figure). Click on Enable. Now the page gets refreshed and the Console appears.</p><p><img
src="/blog/wp-content/photos/autopager/01-firebug-console.png" alt="Firebug Console" /></p><p>Next, go to the Firefox menu item: Tools -> Greasemonkey -> Manage User Scripts. Select Autopagerize from the list and click on Edit button below.</p><p><img
src="/blog/wp-content/photos/autopager/02-greasemonkey-dialog.png" alt="Greasemonkey Option" /></p><p>Turn on debugging by changing line 26 (could be different for you) to <code>var DEBUG = 1</code>. However I could make debugging work only after adding the following 3 lines further down, say after line 85.</p><pre><code>if(unsafeWindow.console){
   var GM_log = unsafeWindow.console.log;
}
</code></pre><p>Scroll to the line that starts with <code>var SITEINFO = [</code>, which is around line 40. Copy and uncomment the 6 lines of sample code provided by the author as shown in the figure.</p><p><img
src="/blog/wp-content/photos/autopager/03-emacs-screen.png" alt="Editing code in Emacs" /></p><p>Now, give the appropriate XPATH values to the property variables "pageElement" and "nextLink". The "url" variable is a simple regular expression and an example link for the fourth variable (this variable is purely for documentation). Save this file and refresh your page. If the XPATH values are correctly found the Autopagerize green square icon will appear on the page, else there will be some error on your Firebug console like:</p><pre><code>nextLink not found
</code></pre><h3>Debugging Autopagerize or Shit, Nothing Happens!</h3><p>As you might have guessed, the last step I mentioned earlier is not so easy. This is where Firebug can help you. Before you start read some <a
href="http://www.w3schools.com/Xpath/">XPATH tutorials</a> on the net to familiarize yourself with the XPATH syntax.</p><p>One killer feature in Firebug is selecting any element of a page and copying the XPath value of that element. On the Firebug window click on Firebug's Inspect button and mousing over the page to outline that page element (see fig).</p><p><img
src="/blog/wp-content/photos/autopager/04-inspect.png" alt="Firebug Inspect" /></p><p>Click on the page element you are interested in and the details of the element appear on the firebug window. Right clicking on any item in the breadcrumb at the very top, you will see a Copy XPath option (see fig).</p><p><img
src="/blog/wp-content/photos/autopager/05-copy-xpath.png" alt="Copying XPATH" /></p><p>Now go to the console tab of Firebug and test the XPath by using the $x function. Paste the XPath as an argument to this function and you should get an HTMLElement as the result (see fig).</p><p><img
src="/blog/wp-content/photos/autopager/06-firebug.png" alt="Paste to Console" /></p><p>You will need to find variables: "pageElement" and "nextLink" this way. This is not an exact science and involves a lot of trial and error. Here are some tips I found after several hours of testing:</p><ol><li><strong>Escaping</strong> - You will need to add a backslash '\' before each special character like '/' or ". This is not required in the Firebug console, however.</li><li><strong>Single Quotes</strong> - It is best to use single-quotes as the outer-most quotes in the Firebug console</li><li><strong>Firebug gives Absolute Paths</strong> - You will find that Firebug gives XPaths based on the position of a child element, which is likely to break even if the smallest change is made to the page. Try to avoid relying on positions.</li><li><strong>Use attributes</strong> - The best XPaths use the classname property or id property of an element or its parent.</li><li><strong>No Array Results</strong> - The XPath must always return a unique element. If an array of elements are returned, it will not work.</li><li><strong>Watch the Console</strong> - After you enable debugging the console provides useful error messages. This helps in identifying the problem.</li><li><strong>Read Examples</strong> - It is always best to check the huge <a
href="http://wedata.net/databases/AutoPagerize/items.json">SITEINFO database</a> to understand how other users have tackled similar or tricky sites.</li></ol><p>For the site we were using as an example, the following code should work:</p><pre><code>{
  pageElement: "\/\/table[contains(@class,\"ViewArticlePanel\")]",
  url: "^http:\/\/www\\.adobetutorialz\\.com\/articles",
  nextLink: "\/\/div[@class=\"ArticleNavigation\"]\/a[contains(text(),\"Next »\")]",
  exampleUrl: "http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions"
},
</code></pre><p>Hope this gives you enough information on Autopagerize and improves your browsing experience!</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Workaround to Easy Install PIL on Windows</title><link>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/</link> <comments>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/#comments</comments> <pubDate>Sat, 30 Aug 2008 17:43:54 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Python]]></category> <category><![CDATA[django]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=133</guid> <description><![CDATA[This is a quick workaround for people who are using easy_install to install Python Imaging Library on Windows. Many people faced issues while doing this. I found a simple workaround for this.You must have tried the followingC:&#62; easy_install PIL
Searching for PIL
...
Finished processing dependencies for PIL
C:&#62; python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 [...]]]></description> <content:encoded><![CDATA[<p>This is a quick workaround for people who are using <a
href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a> to install Python Imaging Library on Windows. Many people faced issues while doing this. I found a simple workaround for this.</p><p>You must have tried the following</p><pre><code>C:&gt; easy_install PIL
Searching for PIL
...
Finished processing dependencies for PIL
C:&gt; python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import Image
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ImportError: No module named Image
</code></pre><p>Now you will need to go to your site-packages directory (typically at C:\Python\Lib\site-packages) and change one line that starts with <code>./PIL-1.1.6-py2.5-win32.egg</code> to simply <code>./PIL</code> and change the sub-directory named similarly to <code>PIL</code></p><p>Now your imports should work :smile:</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/08/30/workaround-to-easy-install-pil-on-windows/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Learning Pylons Through Tutorials</title><link>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/</link> <comments>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/#comments</comments> <pubDate>Thu, 26 Jun 2008 17:18:50 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[Python]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[featured]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/?p=128</guid> <description><![CDATA[Web Development is now getting dominated by frameworks. After the initial hype of Rails, Python based frameworks are getting more popularity especially after the release of Google App Engine. Nobody seems to be interested in building websites using PHP, even if they are highly experienced in PHP. This could mean two things:There will be more [...]]]></description> <content:encoded><![CDATA[<p>Web Development is now getting dominated by frameworks. After the initial hype of Rails, Python based frameworks are getting more popularity especially after the release of Google App Engine. Nobody seems to be interested in building websites using PHP, even if they are highly experienced in PHP. This could mean two things:</p><ol><li>There will be more demand in Indian IT companies for PHP skills similar to Perl scripting skills these days  :mrgreen:</li><li>There will be soon be a viable competitor to the immensely popular Wordpress blogging platform from the Python/Ruby world</li></ol><p>I have nothing against Wordpress. In fact, it is one of the easiest tools to deploy. But with tools like cPanel, deployment could be no longer a deciding factor for blogging platforms.</p><p>Coming back to the topic of Python Web Frameworks, there is a multitude of options. I have used some of these framworks and found them to be &#8216;pythonic&#8217; in different ways:</p><ul><li><strong>Django</strong> Well documented. Tightly Coupled and &#8216;Batteries Included&#8217;</li><li><strong>Pylons</strong> Extremely flexibility to Plug and Play components. &#8216;Fun to Hack&#8217;</li><li><strong>web.py</strong> Great for beginners. Entire framework &#8216;fits in your head&#8217;</li></ul><p>Pylons looks most appealing to me. So far it looks like the underdog largely overshadowed by Django&#8217;s presence lacking the <a
href="http://www.jacobian.org/writing/2006/jan/27/why-django/">marketing</a> or <a
href="http://www.djangoproject.com/weblog/2006/aug/07/guidointerview/">love</a> it deserves. A few weeks back I would have complained about the lack of Pylons tutorials on the web. A google search brought up several links pointing to the wiki tutorial. As many have pointed out, the wiki tutorial is too long and complicated for beginners. It would easily put off a beginner. It took me quite some time to realise that the best place to start learning Pylons is the <a
href="http://bel-epa.com/pylonsdocs/">Pylons Documentation</a> itself and the best Pylons tutorial is the <a
href="http://bel-epa.com/pylonsdocs/tutorials/flickr_search_tutorial.html">Flickr Search</a>. Going through the documentation is almost feels like reading a book with every concept explained in detail.</p><p>Pylons currently seems to the having an edge over Django for enterprise application due to its well tested interface with SQLAlchemy. Django seems to be having a fairly recent <a
href="http://code.google.com/p/django-sqlalchemy/">branch</a> for SQLAlchemy integration. Pylons typically uses Python eggs and VirtualEnv for deployment which is might seem a little complex to beginners, but once you try it once it is actually quite convenient. Most of the installation can be done from the command-line and it will be nearly an independent sandbox for Pylons development. However it might take sometime to understand other aspects of using python eggs such as uninstallation and creation of new eggs. I haven&#8217;t had much success with making a portable version of my Pylons installation on Windows though :(</p><p>My favourite templating engine is Genshi because it is very designer friendly(which also means it works with the tools a Designer has, not just that it is easy for a Designer to learn). I can easily do all HTML designing directly on my Genshi templates because they are valid HTML or XML documents. Almost all of Genshi&#8217;s logic can be hidden away as attributes which is a great idea. In fact, the templates are even valid XML which makes the creation of valid HTML pages a much more natural experience. Almost all XML tools and even HTML tools like Tidy will work flawlessly on Genshi templates due to these reasons.</p><p>Once you get used to Genshi&#8217;s templates, you might even use them for static web site designing. I am sure it will save you a lot of time whenever those last minute &#8217;sidebar redesigns for every page&#8217; pops up.</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/06/26/learning-pylons-through-tutorials/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Emacs Tip: A Key to open the Current Folder in Windows</title><link>http://www.arunrocks.com/blog/archives/2008/06/10/emacs-tip-a-key-to-open-the-current-folder-in-windows/</link> <comments>http://www.arunrocks.com/blog/archives/2008/06/10/emacs-tip-a-key-to-open-the-current-folder-in-windows/#comments</comments> <pubDate>Tue, 10 Jun 2008 10:22:52 +0000</pubDate> <dc:creator>Arun Bhai</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[emacs]]></category><guid
isPermaLink="false">http://www.arunrocks.com/blog/archives/2008/06/10/emacs-tip-a-key-to-open-the-current-folder-in-windows/</guid> <description><![CDATA[If the over-descriptive title was not enough, this is another one of my tips to use my favorite editor &#8211; Emacs. Some of you really liked my earlier post on Emacs tips on Windows, so here is one more tip to improve your productivity.Most of the time while editing a document, we need to quickly [...]]]></description> <content:encoded><![CDATA[<p>If the over-descriptive title was not enough, this is another one of my tips to use my favorite editor &#8211; Emacs. Some of you really liked my <a
href="http://www.arunrocks.com/blog/archives/2008/02/20/5-indespensible-tips-for-emacs-on-windows/">earlier post on Emacs tips on Windows</a>, so here is one more tip to improve your productivity.</p><p>Most of the time while editing a document, we need to quickly browse the folder of that file. Add the following lines to your <code>.emacs</code> files and so that by just pressing function key F12 you can immediately view its corresponding folder:</p><div> [source:css]
;; explorer
;; &#8212;&#8212;&#8212;-
;;; Windows explorer to open current file &#8211; Arun Ravindran(defun explorer ()
&#8220;Launch the windows explorer in the current directory and selects current file&#8221;
(interactive)
(w32-shell-execute
&#8220;open&#8221;
&#8220;explorer&#8221;
(concat &#8220;/e,/select,&#8221; (convert-standard-filename buffer-file-name))))(global-set-key [f12]         &#8216;explorer)        ; F12 &#8211; Open Explorer for the current file path[/source]</div><p>A nice extra is that the opened explorer will have the current file automatically selected. Press F12 once in a while, it quickly becomes addictive ;)</p> ]]></content:encoded> <wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/06/10/emacs-tip-a-key-to-open-the-current-folder-in-windows/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss><!--
This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching 6/11 queries in 0.006 seconds using disk

Served from: zoe.asmallorange.com @ 2010-09-03 03:25:33 -->