<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>foo, bar n baz</title>
 
 <link href="http://foobarnbaz.com/" />
 <updated>2011-10-06T00:00:00+5:30</updated>
 <id>http://foobarnbaz.com/</id>
 <author>
   <name>Sreejith K</name>
   <email>sreejithemk@gmail.com</email>
 </author>
 
 
 <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/foobarnbaz" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="foobarnbaz" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
   <title>Voldemort: A Jinja2 powered static site generator</title>
   <link href="http://foobarnbaz.com/2011/10/05/voldemort-a-jinja-powered-static-site-generator" />
   <updated>2011-10-05T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/10/05/voldemort-a-jinja-powered-static-site-generator</id>
   <content type="html">&lt;p&gt;&lt;a href="https://github.com/semk/voldemort"&gt;Voldemort&lt;/a&gt; is a blog-aware static site generator inspired by &lt;a href="http://jinja.pocoo.org/2/"&gt;Jinja2&lt;/a&gt;. All these times this blog was generated using &lt;a href="https://github.com/mojombo/jekyll"&gt;Jekyll&lt;/a&gt; and I always wanted to use something Pythonic. &lt;a href="http://ringce.com/hyde"&gt;Hyde&lt;/a&gt; was there, but the awesomeness of Jinja2 forced me to write Voldemort on my own.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Voldemort" src="/images/posts/2011-10-05-voldemort-a-jinja-powered-static-site-generator/voldemort.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Voldemort has its own advantages. You can templatize your HTML pages using Jinja and write posts using &lt;a href="http://daringfireball.net/projects/markdown"&gt;Markdown&lt;/a&gt;. And if you like this website, then you've got one reason to tryout Voldemort. Go for an &lt;a href="http://pypi.python.org/pypi/voldemort/0.6.0"&gt;install&lt;/a&gt; or grab the &lt;a href="https://github.com/semk/voldemort"&gt;sources&lt;/a&gt; if you want to tweak it your own way.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Packaging Python Applications</title>
   <link href="http://foobarnbaz.com/2011/10/02/packaging-python-applications" />
   <updated>2011-10-02T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/10/02/packaging-python-applications</id>
   <content type="html">&lt;p&gt;A few days ago, I came across a situation where I needed to create Debian packages for some Python libraries on which our software was dependant on. All these time we were creating and distributing the application as Eggs built using &lt;a href="http://pypi.python.org/pypi/setuptools"&gt;setuptools&lt;/a&gt; &lt;code&gt;setup.py&lt;/code&gt; script. Later on this became a problem since some other applications which we were using were not Python applications and were packaged as &lt;code&gt;.deb&lt;/code&gt; packages. This situation made us to build &lt;code&gt;.deb&lt;/code&gt; packages for our Python software as well.&lt;/p&gt;
&lt;p&gt;The real challenge here was packaging all the dependencies our Python application has brought in, as most of the dependencies were having only &lt;code&gt;egg&lt;/code&gt; distributions. Luckily there was an extension to setuptools called &lt;a href="https://github.com/astraw/stdeb"&gt;stdeb&lt;/a&gt; which will allow you to generate debian packages using your setup.py script. It'll automatically add the dependencies in the &lt;code&gt;debian/control&lt;/code&gt; file after searching for the dependencies using &lt;code&gt;apt-cache&lt;/code&gt;. stdeb will do something like &lt;code&gt;apt-cache dump | grep &amp;lt;package&amp;gt;&lt;/code&gt; to find whether there is a proper debian package for the dependencies. If they found the correct one in apt-cache, &lt;code&gt;debian/control&lt;/code&gt; file will be updated with that information. But as I said, most of the dependencies were not packaged as &lt;code&gt;.deb&lt;/code&gt;. So we downloaded all the dependencies using the &lt;code&gt;easy_install&lt;/code&gt; command and created &lt;code&gt;.deb&lt;/code&gt; packages for them using &lt;code&gt;stdeb&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I will demonstrate the procedure with the &lt;a href="https://github.com/semk/voldemort"&gt;Voldemort&lt;/a&gt; project from my GitHub Repo. The &lt;code&gt;setup.py&lt;/code&gt; looks like this,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;find_packages&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;ImportError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;ez_setup&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;use_setuptools&lt;/span&gt;
    &lt;span class="n"&gt;use_setuptools&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;find_packages&lt;/span&gt;

&lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;voldemort&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;0.5.0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Voldemort is a simple static site generator&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="s"&gt;                    using Jinja2 and markdown templates.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;author&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Sreejith K / K7Computing Pvt Ltd&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;author_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;sreejithemk@gmail.com&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;http://www.foobarnbaz.com&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;Pygments &amp;gt;= 1.4&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;PyYAML &amp;gt;= 3.10&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;Markdown &amp;gt;= 2.0&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;Jinja2 &amp;gt;= 2.5&amp;#39;&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;setup_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;find_packages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exclude&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;ez_setup&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="n"&gt;test_suite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;tests&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;scripts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;scripts/voldemort&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;include_package_data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;zip_safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;In this case all the dependencies were lacking &lt;code&gt;.deb&lt;/code&gt; packages. So, we need to download them using &lt;code&gt;easy_install&lt;/code&gt;.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;mkdir deps
easy_install -e -b deps/ &lt;span class="s2"&gt;&amp;quot;Pygments&amp;gt;=1.4&amp;quot;&lt;/span&gt;
easy_install -e -b deps/ &lt;span class="s2"&gt;&amp;quot;PyYAML&amp;gt;=3.10&amp;quot;&lt;/span&gt;
easy_install -e -b deps/ &lt;span class="s2"&gt;&amp;quot;Markdown&amp;gt;=2.0&amp;quot;&lt;/span&gt;
easy_install -e -b deps/ &lt;span class="s2"&gt;&amp;quot;Jinja2&amp;gt;=2.5&amp;quot;&lt;/span&gt;
ls deps/
jinja2   markdown pygments pyyaml
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now you need to go to each dependency directory and issue the following command&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;python setup.py --command-packages&lt;span class="o"&gt;=&lt;/span&gt;stdeb.command debianize
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That will create a directory named &lt;code&gt;debian&lt;/code&gt; which contain all the stuffs needed to create a &lt;code&gt;.deb&lt;/code&gt; package. Now it is upto us to edit the control file and add any additional dependency if needed. To generate the debian package, do&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;dpkg-buildpackage -us -uc
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now you can build the main application debs by editing the control file manually since stdeb won't add the dependencies. But you know you have them in your hand :-).&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Developing scalable services with Python</title>
   <link href="http://foobarnbaz.com/2011/08/30/developing-scalable-services-with-python" />
   <updated>2011-08-30T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/08/30/developing-scalable-services-with-python</id>
   <content type="html">&lt;p&gt;Developing multi-threaded applications in python is a "Pain In The Ass". And the &lt;a href="http://wiki.python.org/moin/GlobalInterpreterLock"&gt;GIL&lt;/a&gt; (Global Interpreter Lock) takes away the advantage of utilizing multiple cores in a machine. It doesn't matter how many cores a CPU have, GIL prevents threads from running in multiple cores. So python programs would't get the maximum performance out of the CPU when they use threads in their services.&lt;/p&gt;
&lt;p&gt;In many cases you might need to write services where you need to listen on a port and wait for the client connection to do some task. If multiple clients are connecting to this service simultaneously then you might need to spawn threads to handle the requests. Considering the fact that GIL introduces a performance bottleneck, the best way to solve this situation is to use python's &lt;a href="http://docs.python.org/library/multiprocessing.html"&gt;multiprocessing&lt;/a&gt; capabilities. This library provides almost &lt;code&gt;threading&lt;/code&gt; like class implementations. &lt;/p&gt;
&lt;p&gt;Then a question might arise. How do you share a socket created by the server process to the newly spawned processes? It is possible since all the &lt;code&gt;fork&lt;/code&gt;ed processes will have the parent's file descriptors. &lt;code&gt;multiprocessing&lt;/code&gt; library already has this package named &lt;code&gt;multiprocessing.reduction&lt;/code&gt; that provides a method &lt;code&gt;reduce_handle&lt;/code&gt; which can serialize a socket and you can send this socket to another process using pipes. The child processes can read from the pipe and re-create the socket using &lt;code&gt;rebuild_handle&lt;/code&gt;. The following example will make this idea clear to you.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# Main Process&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;multiprocessing.reduction&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;reduce_handle&lt;/span&gt;
&lt;span class="c"&gt;# serialize the socket&lt;/span&gt;
&lt;span class="n"&gt;serialized_socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reduce_handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client_socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fileno&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c"&gt;# send it to the child/worker process&lt;/span&gt;
&lt;span class="n"&gt;pipe_to_worker&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serialized_socket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Worker Process&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;multiprocessing.reduction&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;rebuild_handle&lt;/span&gt;
&lt;span class="c"&gt;# get the socket from parent&lt;/span&gt;
&lt;span class="n"&gt;serialized_socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pipe_from_parent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;recv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c"&gt;# rebuild the file descriptor&lt;/span&gt;
&lt;span class="n"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rebuild_handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;serialized_socket&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;# create socket from fd&lt;/span&gt;
&lt;span class="n"&gt;client_socket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fromfd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AF_INET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SOCK_STREAM&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;# use the socket as usual. eg: send a message to the client&lt;/span&gt;
&lt;span class="n"&gt;client_socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Baby, I&lt;/span&gt;&lt;span class="se"&gt;\&amp;#39;&lt;/span&gt;&lt;span class="s"&gt;m so fast&lt;/span&gt;&lt;span class="se"&gt;\r\n&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;h3&gt;Preforking&lt;/h3&gt;
&lt;p&gt;Another way to solve this issue is by spawning multiple process from the main server which is listening on a socket/port and letting all the child processes to &lt;code&gt;accept()&lt;/code&gt; connections from the client. Apache uses this style of process scaling known as "Preforking". A simple example using &lt;code&gt;multiprocessing&lt;/code&gt; module which runs an instance of a &lt;code&gt;BaseHTTPServer.HTTPServer&lt;/code&gt; on a pool of worker processes can be written very easily as follows.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Example where a pool of http servers share a single listening socket&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# On Windows this module depends on the ability to pickle a socket&lt;/span&gt;
&lt;span class="c"&gt;# object so that the worker processes can inherit a copy of the server&lt;/span&gt;
&lt;span class="c"&gt;# object.  (We import `multiprocessing.reduction` to enable this pickling.)&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Not sure if we should synchronize access to `socket.accept()` method by&lt;/span&gt;
&lt;span class="c"&gt;# using a process-shared lock -- does not seem to be necessary.&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Copyright (c) 2006-2008, R Oudkerk&lt;/span&gt;
&lt;span class="c"&gt;# All rights reserved.&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;multiprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Process&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;current_process&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;freeze_support&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;BaseHTTPServer&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTTPServer&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;SimpleHTTPServer&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SimpleHTTPRequestHandler&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;platform&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;win32&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;multiprocessing.reduction&lt;/span&gt;    &lt;span class="c"&gt;# make sockets pickable/inheritable&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;note&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;[&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;]&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_process&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RequestHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SimpleHTTPRequestHandler&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c"&gt;# we override log_message() to show which process is handling the request&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;log_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;serve_forever&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;starting server&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;serve_forever&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;KeyboardInterrupt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;runpool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number_of_processes&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c"&gt;# create a single server object -- children will each inherit a copy&lt;/span&gt;
    &lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HTTPServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;RequestHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# create child processes to act as workers&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number_of_processes&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;Process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;serve_forever&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c"&gt;# main process also acts as a worker&lt;/span&gt;
    &lt;span class="n"&gt;serve_forever&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;DIR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__file__&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;..&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;ADDRESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;NUMBER_OF_PROCESSES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;

    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;Serving at http://&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;:&lt;/span&gt;&lt;span class="si"&gt;%d&lt;/span&gt;&lt;span class="s"&gt; using &lt;/span&gt;&lt;span class="si"&gt;%d&lt;/span&gt;&lt;span class="s"&gt; worker processes&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; \
          &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ADDRESS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;ADDRESS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;NUMBER_OF_PROCESSES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;To exit press Ctrl-&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;C&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;Break&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;win32&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DIR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;runpool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ADDRESS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NUMBER_OF_PROCESSES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;freeze_support&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I wrote a simple wrapper for this kind of services which can be scaled. You can find it &lt;a href="http://github.com/semk/utils/prefork_server.py"&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Custom Authentication for Google App Engine apps</title>
   <link href="http://foobarnbaz.com/2011/07/31/custom-authentication-on-gae" />
   <updated>2011-07-31T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/07/31/custom-authentication-on-gae</id>
   <content type="html">&lt;p&gt;&lt;img alt="Google App Engine" src="http://upload.wikimedia.org/wikipedia/en/3/38/Google_App_Engine_Logo.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://code.google.com/appengine"&gt;Google App Engine&lt;/a&gt; is a widely used and most popular &lt;a href="en.wikipedia.org/wiki/Platform_as_a_service"&gt;PaaS&lt;/a&gt; solution provided by Google. App Engine provides the developer with a wide range of apis which can be used to develop web applications using any &lt;a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface"&gt;WSGI&lt;/a&gt; compliant Frameworks (&lt;a href="http://code.google.com/appengine/docs/python/tools/webapp/"&gt;Webapp&lt;/a&gt;, &lt;a href="http://www.tipfy.org"&gt;Tipfy&lt;/a&gt;, &lt;a href="http://www.django.org"&gt;Django&lt;/a&gt;, &lt;a href="http://bottlepy.org"&gt;Bottle&lt;/a&gt;, &lt;a href="http://www.tornadoweb.org"&gt;Tornado&lt;/a&gt; etc.). One of the apis App Engine provides is the &lt;a href="http://code.google.com/appengine/docs/python/users/overview.html"&gt;users api&lt;/a&gt;, which most of the developers confuses for an api which provides user creation, authentication for the application. But this api only authenticates Google Accounts (can be the application developer or any third-party Google Account) using &lt;a href="http://oauth.net/"&gt;OAuth&lt;/a&gt;. You can't really user this api to create or manage users for your application.&lt;/p&gt;
&lt;p&gt;Remember when I told you that every application you write for GAE is a WSGI Application? WSGI is just a standard for the web application to talk to the backend HTTP server. That means a WSGI application can't run by itself. It needs an HTTP server to listen on and execute the code you have written. Its the HTTP Server which handles all the server stuffs used for authentication such as setting cookies. Now, GAE has a &lt;a href="code.google.com/appengine/docs/python/runtime.html"&gt;sandbox&lt;/a&gt;, which is a restrictive environment for your application code to run. For example, your application is restricted for file operations and certain modules are restricted from importing. So you can't really set up a cookie from your application code since its not an HTTP Server code. Here is our problem now. How do you do a custom authentication for a Google App Engine application?&lt;/p&gt;
&lt;p&gt;You can achieve this by writing a middleware to your WSGI application. There are many authentication libraries available for this purpose. Popular ones are &lt;a href="http://beaker.groovie.org/"&gt;Beaker&lt;/a&gt;, &lt;a href="https://github.com/dound/gae-sessions"&gt;GAE-Sessions&lt;/a&gt;, &lt;a href="http://gaeutilities.appspot.com/session"&gt;gaeutilities&lt;/a&gt;. But I liked the GAE-Sessions library better than the other ones since its the &lt;a href="https://github.com/dound/gae-sessions/wiki/comparison-with-alternative-libraries"&gt;fastest&lt;/a&gt; of them all. GAE-Sessions use &lt;a href="code.google.com/appengine/docs/memcache/"&gt;memcache&lt;/a&gt;/&lt;a href="code.google.com/appengine/docs/datastore/"&gt;datastore&lt;/a&gt; to store the session information. To use this library, just copy the gaesessions directory to your application directory. The middleware for your application is as simple as shown in the code below&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;gaesessions&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SessionMiddleware&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;webapp_add_wsgi_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SessionMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cookie_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;a random and long string&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Save the above code to a file named &lt;code&gt;appengine_config.py&lt;/code&gt;. You can use &lt;code&gt;gaesessions.get_current_session()&lt;/code&gt; to get a dictionary to store all the session information. You can either use &lt;code&gt;session.set_quick(&amp;lt;session-var&amp;gt;, &amp;lt;value&amp;gt;)&lt;/code&gt; method to use application memcache for storing session info. Otherwise it'll be stored to the datastore. Getting session info is as easy as &lt;code&gt;session.get(&amp;lt;session-var&amp;gt;)&lt;/code&gt; and &lt;code&gt;session.pop_quick(&amp;lt;session-var&amp;gt;)&lt;/code&gt; will remove the information from the session. All the dictionary like indexed operations will be persisted to the database.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;gaesessions&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;get_current_session&lt;/span&gt;
&lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_current_session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c"&gt;# setting user session information&lt;/span&gt;
&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_quick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;authenticated_user_info&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;# getting user session&lt;/span&gt;
&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;# removing session info&lt;/span&gt;
&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop_quick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The default session lifetime is 7 days. You may configure how long a session lasts by calling &lt;code&gt;SessionMiddleware&lt;/code&gt; with a &lt;code&gt;lifetime&lt;/code&gt; parameter, e.g., &lt;code&gt;lifetime=datetime.timedelta(hours=2)&lt;/code&gt;). You can schedule a cron job for cleaning up all the expired session info for your application by creating a handler file like this.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# cleanup_sessions.py&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;gaesessions&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;delete_expired_sessions&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;delete_expired_sessions&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Make sure you have a &lt;code&gt;cron.yaml&lt;/code&gt; with the correct info.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="l-Scalar-Plain"&gt;cron&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt;
&lt;span class="p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;description&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;daily session cleanup&lt;/span&gt;
  &lt;span class="l-Scalar-Plain"&gt;url&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;/cleanup_sessions&lt;/span&gt;
  &lt;span class="l-Scalar-Plain"&gt;schedule&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;every 24 hours&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can find a complete sample application &lt;a href="https://github.com/dound/gae-sessions/blob/master/demo"&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Fix Parallels Desktop on Mac OSX Lion</title>
   <link href="http://foobarnbaz.com/2011/07/27/fix-parallels-desktop-on-lion" />
   <updated>2011-07-27T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/07/27/fix-parallels-desktop-on-lion</id>
   <content type="html">&lt;p&gt;&lt;img alt="Parallels Desktop" src="http://cdn2.digitaltrends.com/wp-content/uploads/2010/09/pdfm-box-278x266.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Most of the &lt;a href="www.parallels.com/products/desktop/"&gt;Parallels Desktop 6&lt;/a&gt; users are experiencing an &lt;a href="http://www.youtube.com/watch?v=g4yhICBqpfk"&gt;issue&lt;/a&gt; not finding the virtual machine windows after upgrading to &lt;a href="www.apple.com/macosx/"&gt;Mac OSX Lion&lt;/a&gt;. This might be caused by the Desktop (inwhich Parallels to run on) being set to &lt;code&gt;None&lt;/code&gt; during upgrade. &lt;a href="http://www.apple.com/macosx/whats-new/mission-control.html"&gt;Mission Control&lt;/a&gt; to blame? But this can be fixed very easily. Follow these steps,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a Dock Icon for Parallels Desktop if not&lt;/li&gt;
&lt;li&gt;Launch Parallels Desktop&lt;/li&gt;
&lt;li&gt;Right click the Parallels Dock Icon and go to &lt;code&gt;Options&lt;/code&gt;. Then set &lt;code&gt;Assign To&lt;/code&gt; to &lt;code&gt;This Desktop&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Done.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;According to Parallels FAQ, there is one more workaround to fix this issue,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Delete all the spaces except the default one&lt;/li&gt;
&lt;li&gt;Reboot and restart Parallels&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I hope this will be helpful for those struggling to get around this issue.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Meet Raspberry Pi, the $25 computer</title>
   <link href="http://foobarnbaz.com/2011/05/07/cheapest-personal-computer-on-a-usb" />
   <updated>2011-05-07T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/05/07/cheapest-personal-computer-on-a-usb</id>
   <content type="html">&lt;p&gt;No one would have thought that they could ever buy a computer for $25. Thanks to the smart game developer from &lt;a href="http://www.frontier.co.uk/"&gt;Frontier Developments&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/David_Braben"&gt;David Braben&lt;/a&gt; who designed &lt;a href="http://www.raspberrypi.org/"&gt;Raspberry Pi&lt;/a&gt;, a $25 dollar computer with the size of a USB Stick, infact it is actually a USB Stick Computer. Have a look,&lt;/p&gt;
&lt;p&gt;&lt;img alt="Raspberry Pi" src="http://www.geek.com/wp-content/uploads/2011/05/rasperry_pi_pcb-580x435.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;This tiny device comes with an HDMI port in one end and a USB port on the other. You can plug it into a HDMI socket and then connect a keyboard via the USB port turns it into a fully functioning machine running a flavour of Linux. And the Hardware Specs are not that bad at all. It boasts a 700MHz ARM11 processor coupled with 128MB of RAM and runs OpenGL ES 2.0 allowing for decent graphics performance with 1080p. Yes 1080p. You can also add an SD card to the SD card slot for your storage needs. Did I already mention that you can also mount a 12MP camera into this?&lt;/p&gt;
&lt;p&gt;It looks like the stock OS it ships with is Ubuntu. That means you can browse, run office apps or do whatever you want to do with a computer. Braben argues that the new ICT syllabus in schools have changed a lot and no one is teaching programming and the internals of computer systems. They are now teaching other &lt;em&gt;useful&lt;/em&gt; skills like writing documents in a word processor, how to create presentations etc. This could be his effort to bring back the good stuff back to schools by making an affordable computer for students.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Scratch - A Magic Tool for Tux Paint</title>
   <link href="http://foobarnbaz.com/2011/04/11/a-magic-tool-for-tuxpaint" />
   <updated>2011-04-11T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/04/11/a-magic-tool-for-tuxpaint</id>
   <content type="html">&lt;p&gt;&lt;a href="http://tuxpaint.org/"&gt;Tux Paint&lt;/a&gt; is a drawing software for children that provides a kids-like user interface. Tuxpaint does have some nice tools integrated in it which helps the kids to create their drawing &lt;a href="http://tuxpaint.org/gallery/"&gt;masterpieces&lt;/a&gt; using a computer. Simply speaking its the GIMP for kids of 3-12 years.&lt;/p&gt;
&lt;p&gt;But what I was excited about Tux Paint is the availability of &lt;a href="http://www.tuxpaint.org/presentations/tuxpaint-magic-api.pdf"&gt;Magic Tool Plug-in API&lt;/a&gt; using which you can create Magic Tools that creates some sort of graphical effect on the canvas. Tux Paint already provides some Magic Tools by default like blur, bricks etc. Tux paint is fully written in C and uses &lt;a href="http://libsdl.org"&gt;SDL&lt;/a&gt; for graphics programming. There are basically two kinds of tools we can create using the API. One that affects the whole canvas and one that updates a specific region of the canvas (eg. place where you drag the cursor).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Scratch effect on Bricks" src="/images/posts/2011-04-11-a-magic-tool-for-tux-paint/scratch_on_bricks.png" /&gt;&lt;/p&gt;
&lt;p&gt;To test how this API works, I actually developed a &lt;a href="https://github.com/semk/tp-scratch"&gt;Scratch Magic Tool&lt;/a&gt; which when you apply, creates a &lt;em&gt;scratched&lt;/em&gt; effect on the image (as shown above). It also produces a nice sound effect while applying the effect. Still this tool has a lot of logical bugs so that sometimes it doesn't even look like a scratch when applied over certain colors :-). Other than that, you can use this code for a reference to create your own Magic Tools. If you need documentation this presentation &lt;a href="http://www.tuxpaint.org/presentations/tuxpaint-magic-api.pdf"&gt;slide&lt;/a&gt; is more than enough. Once you have downloaded the Tux Paint source code go through &lt;code&gt;src/tp_magic_api.h&lt;/code&gt; to see the all API definitions and usage.&lt;/p&gt;
&lt;p&gt;Back in the college days, we had this subject on &lt;em&gt;Computer Graphics&lt;/em&gt; where you need to study some popular &lt;a href="http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm"&gt;line-drawing&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Midpoint_circle_algorithm"&gt;circle-drawing&lt;/a&gt; algorithms. But there were no lab sessions for those subjects. Everyone where literally by-hearting those algorithms at that time. I would suggest all the CS faculty to conduct a lab session on Computer Graphics and ask students to implement those algorithms as a Magic Tool in Tux Paint using the Magic Tool API. It will be useful for them to see those algorithms in action. You may use my plugin or other plugins available in Tux Paint's &lt;code&gt;magic/src/&lt;/code&gt;  directory as a reference for your development. Please do give a feedback here in the comment section when you implement some of these algorithms as a Magic Tool.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;NOTE:&lt;/em&gt; For compilation and installation of Tux Paint from sources, follow the instructions from &lt;a href="https://github.com/semk/tp-scratch"&gt;tp-scratch repository&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>I have an'droid</title>
   <link href="http://foobarnbaz.com/2011/02/21/i-have-an-droid" />
   <updated>2011-02-21T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/02/21/i-have-an-droid</id>
   <content type="html">&lt;p&gt;Finally my wish came true. Now I'm a proud owner of an Android phone. Its LG Optimus One, better known as LG P500. Good that it comes with Froyo and LG promises an update to Gingerbread. Here you can find the phone &lt;a href="http://www.gsmarena.com/lg_optimus_one_p500-3516.php"&gt;specs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img alt="LG Optimus One" src="http://www.gadgetvenue.com/wp-content/uploads/2010/09/LG-optimus-one-300x300.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;This one is a good choice for anyone looking for a budget Android phone (10.8K when I bought) whose battery lasts a complete day with internet on. Thanks to &lt;a href="http://binarykarma.org"&gt;Shuveb&lt;/a&gt; for providing a review of the phone and atlast making me buy it :-P&lt;/p&gt;
&lt;p&gt;Eventhough a Pythonista like me hates Java, the Android platform was tempting me to look at Java with some interest. So I bought &lt;em&gt;Android Application Development by O'Reilly&lt;/em&gt; and setup a Development Environment on my laptop using Eclipse. This was so easy that I could run the &lt;em&gt;Hello World&lt;/em&gt; program without even writing a piece of Java code. Once you create a Project, it auto-generates files needed for the application to show on the foreground and other resource files and build scripts. By default, they'll create an activity source file with an &lt;em&gt;Activity&lt;/em&gt; name you've given. This is pretty much the &lt;em&gt;Hello World&lt;/em&gt; program we wanted.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="n"&gt;com&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;semk&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;helloworld&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.app.Activity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;android.os.Bundle&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HelloWorldActivity&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Activity&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="cm"&gt;/** Called when the activity is first created. */&lt;/span&gt;
    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bundle&lt;/span&gt; &lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;super&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;savedInstanceState&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;setContentView&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;R&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;main&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Google has done a great job in developing an easy-to-use and feature-abundant SDK for Android. The Android emulator which comes with the SDK is an engineering masterpiece. It helps the developer to run and test their applications locally before running them on the actual devices.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Android Emulator" src="/images/posts/2011-02-21-i-have-an-droid/emulator.png" /&gt;&lt;/p&gt;
&lt;p&gt;I'm hoping to develop some useful applications for Android while I finish reading the book. So keep an eye on my &lt;a href="http://github.com/semk"&gt;Git Repo&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>HyperGAE - Use Hypertable for App Engine Datastore</title>
   <link href="http://foobarnbaz.com/2011/01/08/hypergae-use-hypertable-for-appengine-datastore" />
   <updated>2011-01-08T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/01/08/hypergae-use-hypertable-for-appengine-datastore</id>
   <content type="html">&lt;p&gt;After few days of hacking on the &lt;a href="http://code.google.com/appengine/docs/python/overview.html"&gt;Google App Engine SDK&lt;/a&gt; and &lt;a href="http://code.google.com/apis/protocolbuffers/docs/pythontutorial.html"&gt;ProtocolBuffers&lt;/a&gt;, finally I succeeded in creating a datastore driver for GAE that talks to &lt;a href="http://hypertable.org"&gt;Hypertable&lt;/a&gt; and stores the data there &lt;em&gt;fully protocol buffer encoded&lt;/em&gt;. If you want to checkout this implementation head to &lt;a href="https://github.com/semk/hypergae"&gt;HyperGAE&lt;/a&gt; repository and see &lt;a href="https://github.com/semk/hypergae/tree/master/google/appengine/datastore"&gt;files&lt;/a&gt; &lt;code&gt;datastore_hypertable_ht.py&lt;/code&gt; and &lt;code&gt;datastore_hypertable_thrift.py&lt;/code&gt;. HyperGAE basically uses two methods to connect to hypertable. Using the thrift api and using the boost-python library &lt;a href="http://code.google.com/p/python-hypertable/"&gt;ht&lt;/a&gt;. The mentioned drivers provides these api connections to hypertable.&lt;/p&gt;
&lt;p&gt;To run App Engine sdk with hypertable support, do&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;python dev_appserver.py demos/guestbook/ --use_hypertable
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The above command assumes hypertable &lt;a href="http://www.hypertable.com/download/0.9.3.4.html"&gt;0.9.3.4&lt;/a&gt; installed and running on your machine. It uses the thrift connection by default. I need to add support for configuring hypertable options though &lt;code&gt;dev_appserver.py&lt;/code&gt; script. Suggestions and patches are always welcome.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;UPDATE:&lt;/em&gt; The drivers api has been modified to accommodate the new Hypertable and Thrift api changes. You must install Hypertable version &lt;a href="http://www.hypertable.com/download/"&gt;0.9.4.3&lt;/a&gt; for HyperGAE to work. More updates to follow.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Building Custom Firmware for PS3</title>
   <link href="http://foobarnbaz.com/2011/01/05/building-custom-firmware-for-ps3" />
   <updated>2011-01-05T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2011/01/05/building-custom-firmware-for-ps3</id>
   <content type="html">&lt;p&gt;The 27th &lt;a href="http://events.ccc.de/congress/2010/wiki/Welcome"&gt;Chaos Communication Congress&lt;/a&gt; revealed the &lt;a href="http://www.engadget.com/2010/12/29/hackers-obtain-ps3-private-cryptography-key-due-to-epic-programm/"&gt;&lt;em&gt;Epic Programming Fail&lt;/em&gt;&lt;/a&gt; on the PlayStation 3 security. Finally it turned  out that Sony's ECDSA algorithm for signing apps use a random number generator which always returns the same number (No, I'm not kidding). The &lt;a href="http://fail0verflow.com"&gt;fail0verflow&lt;/a&gt; team, who found out this fail, used the following famous &lt;a href="http://xkcd.com"&gt;xkcd&lt;/a&gt; comic to describe Sony's ECDSA algorithm.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Random Number" src="http://imgs.xkcd.com/comics/random_number.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;fail0verflow&lt;/em&gt; demonstrated their work on &lt;a href="http://marcansoft.com/blog/2010/10/asbestos-running-linux-as-gameos/"&gt;AsbestOS&lt;/a&gt;, which is a bootloader for ps3 using which you can boot &lt;em&gt;Linux&lt;/em&gt; on it. Currently this needs some wiring and soldering works but they have promised to release an easy to use tool sometime next month.&lt;/p&gt;
&lt;p&gt;But &lt;a href="https://github.com/kakaroto"&gt;kakaroto&lt;/a&gt;(the hacker behind aMsn and PL3 payload for &lt;em&gt;psgroove&lt;/em&gt;) wasn't patient enough. He went on to develop some tools to create &lt;em&gt;custom firmware&lt;/em&gt; for ps3. You can find the custom firmware generator code from &lt;a href="https://github.com/kakaroto/ps3utils"&gt;here&lt;/a&gt;. Currently it works on Linux and Mac. For those who doesn't know how to use these tools, the following steps would help.&lt;/p&gt;
&lt;p&gt;First of all checkout the tools developed by &lt;em&gt;fail0verflow&lt;/em&gt; team and build it. You might need to install &lt;code&gt;build-essential&lt;/code&gt; and &lt;code&gt;zlib1g-dev&lt;/code&gt; packages if you are using Ubuntu (use &lt;code&gt;sudo apt-get install&lt;/code&gt;).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;mkdir ~/src
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/src
git clone git://git.fail0verflow.com/ps3tools.git
&lt;span class="nb"&gt;cd &lt;/span&gt;ps3tools
make
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now checkout the firmware generator code from kakaroto's GitHub repository and use the official firmware update (PS3UPDAT.PUP) to create the CFW.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;mkdir ~/.ps3
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/.ps3
git clone https://github.com/kakaroto/ps3keys.git .
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/src
git clone https://github.com/kakaroto/ps3utils.git
&lt;span class="nb"&gt;cd &lt;/span&gt;ps3utils
make
./create_cfw.sh PS3UPDAT.PUP CFW.PUP
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can rename this CFW.PUP to PS3UPDAT.PUP and copy it to PS3-&amp;gt;UPDATE directory of your pendrive and update the ps3 from the XMB. Still, this CFW does nothing but shows the &lt;em&gt;Install Application&lt;/em&gt; option on XMB. You still have to wait until the homebrews are signed and repackaged with the retail &lt;code&gt;.pkg&lt;/code&gt; format to install on this firmware.&lt;/p&gt;
&lt;h4&gt;Links&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="http://events.ccc.de/congress/2010/Fahrplan/attachments/1780_27c3_console_hacking_2010.pdf"&gt;fail0verflow's presentation on Console Hacking&lt;/a&gt; - 27th Chaos Communication Congress&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="http://www.bbc.co.uk/news/technology-12116051"&gt;fail0verflow and Geohot Interview with BBC&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</content>
 </entry>
 
 <entry>
   <title>Reads for the New Year</title>
   <link href="http://foobarnbaz.com/2010/12/31/reads-for-the-new-year" />
   <updated>2010-12-31T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/12/31/reads-for-the-new-year</id>
   <content type="html">&lt;p&gt;Now I have two new good books to read for this New Year. The classic &lt;a href="http://mitpress.mit.edu/sicp/full-text/book/book.html"&gt;Structure and Interpretation of Computer Programs/SICP&lt;/a&gt; and &lt;a href="http://www.amazon.com/Mock-Mockingbird-Other-Logic-Puzzles/dp/0394534913"&gt;To Mock a Mockingbird&lt;/a&gt; (&lt;a href="http://en.wikipedia.org/wiki/Raymond_Smullyan"&gt;Raymond Smullyan&lt;/a&gt;), a humorous introduction to &lt;a href="http://en.wikipedia.org/wiki/Combinatory_logic"&gt;combinatory logic&lt;/a&gt; with the help of &lt;a href="http://www.codinghorror.com/blog/2007/09/classic-computer-science-puzzles.html"&gt;interesting puzzles&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;SICP was used as the textbook of MIT's old introductory programming class &lt;a href="http://sicp.ai.mit.edu/Spring-2007/"&gt;6.001&lt;/a&gt;. Later this class has been replaced by &lt;a href="http://mit.edu/6.01/mercurial/spring10/www/index.html"&gt;6.01&lt;/a&gt;, which uses Python. It is also known as the wizard book beacause it features the image of a wizard on its cover page.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Books" src="/images/posts/2010-12-31-reads-for-the-new-year/books.png" /&gt;&lt;/p&gt;
&lt;p&gt;To Mock a Mockingbird contains numerous logical puzzles and by solving them, you will eventually learn some theories and concepts in combinatorics and &lt;a href="http://en.wikipedia.org/wiki/Lambda_calculus"&gt;lambda calulus&lt;/a&gt;, the base of &lt;a href="http://en.wikipedia.org/wiki/Lisp_programming_language"&gt;Lisp&lt;/a&gt; programming.&lt;/p&gt;
&lt;p&gt;Well. Afterall, its time to say good bye to 2010 and welcome 2011.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Learn web development with Flask</title>
   <link href="http://foobarnbaz.com/2010/12/25/learn-web-development-with-flask" />
   <updated>2010-12-25T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/12/25/learn-web-development-with-flask</id>
   <content type="html">&lt;p&gt;I've seen many people jumping into web development with feature-complete frameworks like &lt;a href="http://www.djangoproject.com/"&gt;Django&lt;/a&gt; and &lt;a href="http://rubyonrails.org/"&gt;Rails&lt;/a&gt;. But most of them will find it difficult to assimilate the web development concepts because of cluttered documentation (incase of Rails) or complexity (incase of Django). One might need to look at a simpler microframework to learn from scratch. And yes, &lt;a href="http://flask.pocoo.org/"&gt;Flask&lt;/a&gt; is the one you'd want to have a look at.&lt;/p&gt;
&lt;p&gt;Flask is a microframework for Python based on &lt;a href="http://www.pocoo.org/projects/werkzeug/"&gt;Werkzeug&lt;/a&gt;, and &lt;a href="http://www.pocoo.org/projects/jinja2/"&gt;Jinja 2&lt;/a&gt;. It is developed by the same guys at &lt;a href="http://www.pocoo.org/"&gt;Pocoo&lt;/a&gt; who gave us &lt;a href="http://www.pocoo.org/projects/sphinx/"&gt;Sphinx&lt;/a&gt; and &lt;a href="http://www.pocoo.org/projects/pygments/"&gt;Pygments&lt;/a&gt; (a Python based syntax highlighter which beautifies the codes shown in this website). If you are new to the world of web development, with Flask you'd find it easier to understand the basics concepts like &lt;em&gt;sessions&lt;/em&gt;, &lt;em&gt;cookie&lt;/em&gt;, &lt;em&gt;templates&lt;/em&gt; etc.&lt;/p&gt;
&lt;p&gt;Flask provides a more developer friendly routing mechanism. You can define the routes to handlers with the help of a simple python decorator. That means no pain-in-the-ass for defining routes and writing handlers separately. Let's have a look at a sample &lt;em&gt;Hello World&lt;/em&gt; application in Flask. I don't think you might need an explanation to this code :-)&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# Hello World in Flask&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Hello World!&amp;quot;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If you want to look at some really cool applications using Flask, never hesitate to checkout the code from &lt;a href="https://github.com/mitsuhiko/flask/tree/master/examples"&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Factory/Service mode on PlayStation 3</title>
   <link href="http://foobarnbaz.com/2010/12/12/factory-service-mode-om-playstation-3" />
   <updated>2010-12-12T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/12/12/factory-service-mode-om-playstation-3</id>
   <content type="html">&lt;p&gt;Here is a happy news for those who updated to firmware &lt;code&gt;&amp;gt;3.41&lt;/code&gt; and didn't get a chance to enjoy the homwbrews for PS3. Yes, atlast we'll be able to downgrade the PS3 firmware to any version &lt;code&gt;&amp;lt;3.50&lt;/code&gt;. The actual PSJailbreak team were the first team to release the downgrade. But many thanks to &lt;a href="https://github.com/zAxis"&gt;zAxis&lt;/a&gt; who created &lt;a href="https://github.com/zAxis/PSGrade"&gt;PSGrade&lt;/a&gt;, an opensouce version of PSDowngrade. Using this we can put the PS3 into Factory/Service mode (Downgrade) using popular development boards like Teensy and AT90USBKEY.&lt;/p&gt;
&lt;p&gt;We should also be thankful to &lt;a href="https://github.com/kakaroto"&gt;KaKaRaTo&lt;/a&gt; who reversed the PS3Yes Key and made it available for PSGrade. Here is PS3Yes key which he reversed from its hex.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;0×04, 0x4E, 0×61, 0x1B, 0xA6, 0xA6, 0xE3, 0x9A, 0×98, 0xCF, 0×35, 0×81, 0x2C, 0×80, 0×68, 0xC7, 0xFC, 0x5F, 0x7A, 0xE8&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You'll need to specify this key in PSGrade sources (key.c as shown below) for the service mode hack to work. But now zAxis has updated the code with this key. So all you have to do is download the souces and compile the hex for your board.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;uint8_t&lt;/span&gt; &lt;span class="n"&gt;jig_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="mh"&gt;0x04&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x4E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x1B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xA6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xA6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xE3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x9A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x98&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xCF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="mh"&gt;0x35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x81&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x2C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x68&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xC7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xFC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x5F&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x7A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0xE8&lt;/span&gt; 
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;As I was already there in firmware 3.50, I had a chance to test PSGrade. I compiled the sources for my Teensy 2.0 board and wrote the hex files to it. Using the same PSJailbreak methods I booted the PS3 with the Teensy board in the usb port and rebooted after the hack got executed (Teensy LED will glow). It booted into the service mode quickly and I got a screen as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Service Mode" src="http://www.ps3hax.net/wp-content/uploads/2010/12/SERVICE.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;For exiting from the service mode you need to copy a special file (Lv2diag.self) to a usb storage drive and boot the PS3. Otherwise your PS3 will still be on service mode.&lt;/p&gt;
&lt;p&gt;If you wish to downgrade the firmware (which I haven't performed yet) follow these downgrade steps from &lt;a href="http://psgroove.com/content.php?501-PS3Yes-Release-Free-PSGRADE-Downgrade-Hex-Works-on-All-AT90usb162-Boards"&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Cricinfo api (unofficial) for Python</title>
   <link href="http://foobarnbaz.com/2010/11/30/cricinfo-api-for-python" />
   <updated>2010-11-30T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/11/30/cricinfo-api-for-python</id>
   <content type="html">&lt;p&gt;Recently I started developing a Python &lt;a href="https://github.com/semk/cricinfo"&gt;library&lt;/a&gt; for accessing live information from &lt;a href="http://espncricinfo.com"&gt;ESPN Cricinfo&lt;/a&gt; like live scores, innings details and player profiles. Currently, it only fetches live match information using a simple Python iterator.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# instantiate&lt;/span&gt;
&lt;span class="n"&gt;matches&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CricInfo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c"&gt;# iterate though matches&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;matches&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c"&gt;# match title&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;
    &lt;span class="c"&gt;# a short desciption for the match&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt;
    &lt;span class="c"&gt;# url to live scorecard&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;guid&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I wish to add features for every match like full scorecard, innings details etc in a similar manner. A plan for getting player profile is also in my mind. I'd like to make this as human-readable as possible. For example, innings information can be fetched by an iteration over the Match object. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# getting innings info&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;innings&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;innings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;innings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current_batsmen&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;innings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;overs&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="n"&gt;innings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wickets&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I'll update about the changes being done for the api. So keep reading my blog. I need your suggestions to make it a useful one. &lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Ubuntu Maverick Meerkat</title>
   <link href="http://foobarnbaz.com/2010/11/07/ubuntu-maverick-meerkat" />
   <updated>2010-11-07T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/11/07/ubuntu-maverick-meerkat</id>
   <content type="html">&lt;p&gt;I installed the new &lt;a href="http://www.ubuntu.com/desktop"&gt;Ubuntu 10.10 Maverick Meerkat&lt;/a&gt; on my Laptop and on my Desktop at home. Now both systems doesn't have Windows in it. My family is now very comfortable with Ubuntu and they use the Ubuntu machine for working with &lt;a href="http://www.openoffice.org"&gt;OpenOffice&lt;/a&gt;, watching movies, playing &lt;a href="http://2dboy.com/games.php"&gt;games&lt;/a&gt; and for using Internet.&lt;/p&gt;
&lt;p&gt;BTW, I really like the new Ubuntu font which gives Ubuntu a brandish look. I mean like Mac :-)&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Borg Pattern</title>
   <link href="http://foobarnbaz.com/2010/10/06/borg-pattern" />
   <updated>2010-10-06T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/10/06/borg-pattern</id>
   <content type="html">&lt;p&gt;Singleton Design Patterns create all sorts of problems as you have exactly one instance for the singleton class throughout the program.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# Singleton implementation using new-style classes&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__new__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;_the_instance&amp;#39;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__dict__&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_the_instance&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__new__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_the_instance&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;bar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10049912&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10049912&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Usually programmers use Singleton Patterns as a global entry point to database connections. This is a bad programming habit. This will also break tests as most unittests use dummy implementations of real objects that emulate real objects. Suppose you have protected your class to instantiate only once using this pattern, then it would become impossible for him to stub/mock this class for tests. In short, Singleton patterns are not recommended for test driven development.&lt;/p&gt;
&lt;p&gt;What we really care about class objects are its identity/state and behaviour, not the number of instances; unless you really need that kind of implementation. This is where Borg pattern comes as useful. Borg pattern share the same state across all its class instances. Its fairly easy to implement a Borg pattern in python. Just initialize the class &lt;code&gt;__dict__&lt;/code&gt; with a class attribute in its &lt;code&gt;__init__&lt;/code&gt;.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# Borg Pattern&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Borg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;__shared_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__dict__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__shared_state&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Subclass this &lt;em&gt;Borg&lt;/em&gt; class and you can have a shared-state class implementation and all the instances will have the same state. For more information about different patterns in python, checkout this &lt;a href="http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.html"&gt;link&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>A commandline mapper</title>
   <link href="http://foobarnbaz.com/2010/10/02/commandline-mapper" />
   <updated>2010-10-02T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/10/02/commandline-mapper</id>
   <content type="html">&lt;p&gt;Python provides a builtin &lt;code&gt;map&lt;/code&gt; function which applies a method over a list of entities. This function comes handy in a lot of situations as in&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="c"&gt;# find the square of all integers in a list&lt;/span&gt;
&lt;span class="c"&gt;# Eg: &lt;/span&gt;
&lt;span class="c"&gt;#   input: [1, 2, 3, 4]&lt;/span&gt;
&lt;span class="c"&gt;#   return: [1, 4, 9, 16]&lt;/span&gt;
&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;list_of_integers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Similar functionality can be achieved in linux commandline using a combination of unix pipe &lt;code&gt;|&lt;/code&gt; and &lt;code&gt;xargs&lt;/code&gt; command. For my previous blog post I needed to resize the image sizes so that it fits correcly in the post. This is how I mapped the &lt;code&gt;convert&lt;/code&gt; utility over a list of image files in a directory.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;find . -name &lt;span class="s2"&gt;&amp;quot;*.jpg&amp;quot;&lt;/span&gt; -print0 | xargs -0 -I img convert -resize 600x450 img img
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;-print0&lt;/code&gt; option for find list files without the EOF marker so that it can be used efficiently in &lt;code&gt;xargs&lt;/code&gt;. The -0 option indicates this. You can use a replace string similar to &lt;code&gt;img&lt;/code&gt; used here, to replace initial arguments of the command from standard input. See &lt;code&gt;man xargs&lt;/code&gt; for more information about this utility.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Hacking PlayStation 3 with Teensy 2.0</title>
   <link href="http://foobarnbaz.com/2010/10/02/hacking-playstation3-with-teensy" />
   <updated>2010-10-02T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/10/02/hacking-playstation3-with-teensy</id>
   <content type="html">&lt;p&gt;I've always been a proud and loyal owner of a &lt;a href="http://en.wikipedia.org/wiki/PlayStation_3"&gt;Playstation 3&lt;/a&gt; and still I consider it as the most powerful game console of this generation. But things were super-cool back on the days when &lt;a href="http://en.wikipedia.org/wiki/PlayStation_3"&gt;Playstation 3&lt;/a&gt; supported &lt;a href="http://en.wikipedia.org/wiki/OtherOS"&gt;OtherOS&lt;/a&gt; by which you could boot and use Linux on your console. This was the very feature (other than GameOS which is why someone should buy a PS3 :-)) every PS3 owner was proud of when comparing his console to its counterparts. This feature was removed by Sony after &lt;a href="http://en.wikipedia.org/wiki/George_Hotz"&gt;Geohot's&lt;/a&gt; attempts to hack &lt;a href="http://en.wikipedia.org/wiki/PlayStation_3"&gt;Playstation 3&lt;/a&gt; using Linux. Although he was partially succeeded in doing so, soon he disappeared from the PlayStation hacking scene and asked other hackers to continue his work. The PS3 users gained nothing from this untill the mighty &lt;a href="http://psjailbreak.com"&gt;PSJailbreak&lt;/a&gt; was announced.&lt;/p&gt;
&lt;p&gt;I must say, Sony guys have made &lt;a href="http://en.wikipedia.org/wiki/PlayStation_3"&gt;Playstation 3&lt;/a&gt; almost unhackable as it took more than 4 years for the console hackers to find an exploit to allow homebrews on it. This exploit which was found in firmware 3.41, allows users to backup &lt;em&gt;Legitimate&lt;/em&gt; Copies of PlayStation Games to internal/external harddisk. This is achieved by installing an application called Backup Manager. The team to announce this hack was &lt;a href="http://psjailbreak.com"&gt;PSJailbreak&lt;/a&gt;, who used a USB dongle to boot from which took advantage of the exploit found in 3.41. Later open source implementations of &lt;a href="http://psjailbreak.com"&gt;PSJailbreak&lt;/a&gt; like &lt;a href="http://github.com/psgroove/psgroove"&gt;psgroove&lt;/a&gt;, psfreedom etc. came which used popular development boards like &lt;a href="http://www.pjrc.com/store/teensypp.html"&gt;Teensy ++&lt;/a&gt; and &lt;a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3879"&gt;Atmel AT90USBKEY&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I was really excited to see this progress and I liked the idea of backing up games. If you buy Original Games for $50, atleast there should be one way to make backups so that you can play games even if yor media is damaged. So I logged on to &lt;a href="http://pjrc.com"&gt;pjrc&lt;/a&gt; and ordered one &lt;a href="http://www.pjrc.com/teensy/"&gt;Teensy 2.0 USB Development Board&lt;/a&gt; which used &lt;a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=4317"&gt;Atmel ATMEGA32U4 AVR&lt;/a&gt;. It took almost 3 weeks to ship to India from US. I checked out &lt;a href="http://github.com/psgroove/psgroove"&gt;psgroove&lt;/a&gt; code from GitHub and used the Teensy Loader utility to flash the compiled hex code to the board.&lt;/p&gt;
&lt;p&gt;For this jailbreak to work, you need to hard power your PS3 after connecting the usb board. Turn on the console and immediately press eject button for the exploit to work. If everything goes proper, the orange led in Teensy board will light up. Tada! The PlayStation is Jailbroken. Take a look at the snaps I took during Jailbreaking my console.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Flashed Teensy" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/teensy_loaded.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Exploited" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/exploited.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Installing" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/installing.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Backup Manager" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/backup_manager.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Backup Manager Page" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/bm_screen.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Backing up Uncharted" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/backing_up.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="FTP Server" src="/images/posts/2010-10-02-hacking-playstation3-with-teensy/ftp_server.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;The latest firmware update from Sony patches this exploit and even they are banning consoles using Backup Manager when they connect to &lt;a href="http://en.wikipedia.org/wiki/PlayStation_Network"&gt;PSN&lt;/a&gt;. As I love &lt;a href="http://en.wikipedia.org/wiki/PlayStation_Network"&gt;PSN&lt;/a&gt; and playing &lt;a href="http://en.wikipedia.org/wiki/Uncharted_2:_Among_Thieves"&gt;Uncharted 2&lt;/a&gt; online, soon I have to update my firmware to 3.50. Even legitimate users are irritated by this move by Sony. If iPhone Jailbreak is legal, this is also legal. Right ?&lt;/p&gt;
&lt;p&gt;Had Sony not removed &lt;a href="http://en.wikipedia.org/wiki/OtherOS"&gt;OtherOS&lt;/a&gt;, none of this would have happened OR atleast it would have taken more time for the hackers to hack the console. "Sony, never do stupid things like this anymore. Please bring back &lt;a href="http://en.wikipedia.org/wiki/OtherOS"&gt;OtherOS&lt;/a&gt;." &lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>GitHub powered blogging</title>
   <link href="http://foobarnbaz.com/2010/09/23/github-powered-blogging" />
   <updated>2010-09-23T00:00:00+5:30</updated>
   <id>http://foobarnbaz.com/2010/09/23/github-powered-blogging</id>
   <content type="html">&lt;p&gt;I have learned a big lesson from losing all the blog archives from my previous blog &lt;a href="http://semk.in"&gt;semk.in&lt;/a&gt;, that never ever host a blog without any backups. I didn't pay any attention to domain/hosting expiration date since I was busy working at that time. But finally everything was deleted in a matter of seconds. I never blamed the hosting provider for this. They kept mailing me all the day. Recently I came to know about using &lt;a href="http://github.om"&gt;Github&lt;/a&gt; + &lt;a href="http://github.com/mojombo/jekyll"&gt;Jekyll&lt;/a&gt; for blogging from &lt;a href="http://pages.github.com/"&gt;Github Pages&lt;/a&gt; which I think is the best way to maintain the website code. Thats why this new site got spawned up. &lt;/p&gt;
&lt;p&gt;This website layout is a fork of &lt;a href="http://tatey.com"&gt;Tate Johnson's site&lt;/a&gt; with some minor modifications. Stay tuned for interesting stuffs ...&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Sreejith K&lt;/p&gt;</content>
 </entry>
 
 
</feed>

