<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9876605</atom:id><lastBuildDate>Wed, 15 May 2013 08:32:39 +0000</lastBuildDate><category>autoconf</category><category>funny</category><category>books</category><category>spelunking</category><category>comics</category><category>latex</category><category>tmux</category><category>scifi</category><category>marriage</category><category>biking</category><category>xkcd</category><category>hiking</category><category>git</category><category>python</category><category>haskell</category><category>sun</category><category>ptimer</category><category>Mac OS X</category><category>windows</category><category>vim</category><category>solaris</category><category>c++</category><category>science</category><category>linux</category><category>tech</category><category>personal</category><category>mysql</category><category>programming</category><category>camping</category><category>music</category><category>ted</category><category>algorithm</category><category>django</category><category>blog</category><category>Mandriva</category><category>regex</category><category>automake</category><category>caving</category><category>adventure</category><category>jobs</category><category>getkey</category><category>osnews</category><category>gnome ubuntu linux</category><category>taekwondo</category><category>fun</category><category>Ubuntu</category><category>PyQt4</category><category>pomodoro</category><category>recursion</category><title>Core Dump</title><description>Segfaults in my brain.</description><link>http://amjith.blogspot.com/</link><managingEditor>noreply@blogger.com (Amjith Ramanujam)</managingEditor><generator>Blogger</generator><openSearch:totalResults>135</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/blogspot/amjith" /><feedburner:info uri="blogspot/amjith" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-306850472253120611</guid><pubDate>Thu, 24 May 2012 07:29:00 +0000</pubDate><atom:updated>2012-05-24T01:40:56.690-06:00</atom:updated><title>Goodbye Utah</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
The time has come to part ways. I'm leaving Utah to move to Portland on May 25th 2012. This July would have marked the 10 year anniversary of living in Utah. I can't believe I spent one third of my life so far in Utah. Some of the best memories in my life were formed here.&lt;br /&gt;
&lt;strong&gt;True Love:&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;
I met my beautiful wife here in Utah. She kicked my ass in TaeKwonDo, I asked her out, and the rest is history. Happily married for &amp;nbsp;four years with a baby on the way.&lt;br /&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;img alt="232323232-fp33-nu3282-384-873-wsnrcg323372-389847nu0mrj" height="480" src="http://getfile7.posterous.com/getfile/files.posterous.com/temp-2012-05-23/qyCwxEIpjciBGmdpmFdyHtzxkGleuojnCzpolJvrgthpagccqIzhkkIJHAfi/232323232-fp33-nu3282-384-873-WSNRCG323372-389847nu0mrj.jpeg.scaled600.jpg" width="360" /&gt; &lt;/div&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-23/fFtuwDHeHDwCIehzcluqsilDyoIywAqwmFIHxdABwjyfroyraFpCclDkkEnE/hisa_520.jpg.scaled1000.jpg"&gt;&lt;img alt="Hisa_520" height="669" src="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-23/fFtuwDHeHDwCIehzcluqsilDyoIywAqwmFIHxdABwjyfroyraFpCclDkkEnE/hisa_520.jpg.scaled1000.jpg" width="1000" /&gt;&lt;/a&gt; &lt;a href="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-23/qoHalBmxxhHbpDiDedbyhagHAxcADnJmahokehpjEhCvBCllGAlflsJJcCws/hisa_459.jpg.scaled1000.jpg"&gt;&lt;img alt="Hisa_459" height="1000" src="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-23/qoHalBmxxhHbpDiDedbyhagHAxcADnJmahokehpjEhCvBCllGAlflsJJcCws/hisa_459.jpg.scaled1000.jpg" width="667" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/goodbye-utah"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;First Job:&lt;/strong&gt;&lt;br /&gt;
My first real programming job was with &lt;a href="http://featurecam.com/"&gt;Delcam&lt;/a&gt; USA. I still have my first paystub from Delcam. Tom my boss at Delcam is still the best boss I've had so far.&lt;br /&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile3.posterous.com/getfile/files.posterous.com/temp-2012-05-23/nkhIveuoJyttuoIrxsqdCmvExaphaDadswebBiHDdwwCswaFkivqAtaHhDiv/IMG_4637.JPG.scaled1000.jpg"&gt;&lt;img alt="Img_4637" height="750" src="http://getfile3.posterous.com/getfile/files.posterous.com/temp-2012-05-23/nkhIveuoJyttuoIrxsqdCmvExaphaDadswebBiHDdwwCswaFkivqAtaHhDiv/IMG_4637.JPG.scaled1000.jpg" width="1000" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;strong&gt;Higher Education:&lt;/strong&gt;&lt;br /&gt;
University of Utah. So many memories, so many sleepless nights at the computer lab. I still get a nostalgia when I walk through the campus.&lt;br /&gt;
&lt;div&gt;
&lt;strong&gt;Parksvan:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
Eight clueless kids from India got together to share accomodation while going to school and ended up sharing the best parts of our life. Although we have all parted ways since our college days, I can't help but feel they are part of my family.&lt;/div&gt;
&lt;div&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile5.posterous.com/getfile/files.posterous.com/temp-2012-05-23/iClArlbcscjBnqCjyctGtmGxogqwCGEanvdArxBmaCDJrAeArdczjaraFAat/100_1141.JPG.scaled1000.jpg"&gt;&lt;img alt="100_1141" height="450" src="http://getfile1.posterous.com/getfile/files.posterous.com/temp-2012-05-23/iClArlbcscjBnqCjyctGtmGxogqwCGEanvdArxBmaCDJrAeArdczjaraFAat/100_1141.JPG.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;a href="http://getfile7.posterous.com/getfile/files.posterous.com/temp-2012-05-23/syeJrhwlrftBkHjIapIasIJfJaijBAhnqkvryGkuhCvxrccltjIykzJvwsFG/100_1167.JPG.scaled1000.jpg"&gt;&lt;img alt="100_1167" height="450" src="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-23/syeJrhwlrftBkHjIapIasIJfJaijBAhnqkvryGkuhCvxrccltjIykzJvwsFG/100_1167.JPG.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/goodbye-utah"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Aikido:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
When I went to my first class, I thought I was going there to give my wife some company. Four years and 6 belts later, it has become a dominating force in my life. I never knew getting thrown around was the way to make new friends. :)&lt;/div&gt;
&lt;div&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile9.posterous.com/getfile/files.posterous.com/temp-2012-05-24/rEzruGkigvHgrfctEEGrslpwFzbsvpvBrcbtnBcJkDtchiBzFqGiisHkaJAo/IMG_8809.JPG.scaled1000.jpg"&gt;&lt;img alt="Img_8809" height="561" src="http://getfile9.posterous.com/getfile/files.posterous.com/temp-2012-05-24/rEzruGkigvHgrfctEEGrslpwFzbsvpvBrcbtnBcJkDtchiBzFqGiisHkaJAo/IMG_8809.JPG.scaled1000.jpg" width="1000" /&gt;&lt;/a&gt; &lt;a href="http://getfile7.posterous.com/getfile/files.posterous.com/temp-2012-05-24/AkwJHhcioDaJsDAbAhtpJFGicsIwxBzxlnFewfHymviACJCCdAwuEuIEGhCm/IMG_8848.JPG.scaled1000.jpg"&gt;&lt;img alt="Img_8848" height="337" src="http://getfile9.posterous.com/getfile/files.posterous.com/temp-2012-05-24/AkwJHhcioDaJsDAbAhtpJFGicsIwxBzxlnFewfHymviACJCCdAwuEuIEGhCm/IMG_8848.JPG.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/goodbye-utah"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Along the way I discovered the wonderful art of Iaido. I call it the art of playing with Japanese swords.&lt;br /&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile0.posterous.com/getfile/files.posterous.com/temp-2012-05-24/wDvHgJgvcdfItuFmjifpiemkABrjikjdrHpomIbGeIupgmeyyfGmBmspkIDI/DSC_4667.jpg.scaled1000.jpg"&gt;&lt;img alt="Dsc_4667" height="902" src="http://getfile6.posterous.com/getfile/files.posterous.com/temp-2012-05-24/wDvHgJgvcdfItuFmjifpiemkABrjikjdrHpomIbGeIupgmeyyfGmBmspkIDI/DSC_4667.jpg.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;a href="http://getfile7.posterous.com/getfile/files.posterous.com/temp-2012-05-24/mehuDsygBsnigpfnyqdtBiDGfhdEyliCCswDJdtHaJdedcHgmsvEkGjIiJhg/DSC_4591.jpg.scaled1000.jpg"&gt;&lt;img alt="Dsc_4591" height="1000" src="http://getfile7.posterous.com/getfile/files.posterous.com/temp-2012-05-24/mehuDsygBsnigpfnyqdtBiDGfhdEyliCCswDJdtHaJdedcHgmsvEkGjIiJhg/DSC_4591.jpg.scaled1000.jpg" width="665" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/goodbye-utah"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Python:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
I couldn't believe there was a &lt;a href="http://www.utahpython.org/"&gt;group&lt;/a&gt; of people who met every month to geek out about their favorite language. My heartfelt thanks to &lt;a href="http://sexysexypenguins.com/"&gt;herlo&lt;/a&gt;,&amp;nbsp;&lt;a href="http://hairysun.com/"&gt;mharrison&lt;/a&gt;,&amp;nbsp;&lt;a href="http://mcquay.me/"&gt;smcquay&lt;/a&gt;, &lt;a href="http://the.softwaretoolsmith.com/"&gt;travis&lt;/a&gt; and &lt;a href="http://eseth.org/"&gt;seth&lt;/a&gt;. You guys welcomed me into the group and helped me shape my future in the world of Python.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Outdoor:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
I took up Mountain Biking, Hiking and Snowboarding and I've loved every minute of it. I will miss the rocky moutains, Uintahs and the snowy hills.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile2.posterous.com/getfile/files.posterous.com/temp-2012-05-24/cBvwwJzIBvpFwqomctteDxzpsuhslIhsHeHHEkBtGaytkhavydAlFhGyvajf/Biking.jpg.scaled1000.jpg"&gt;&lt;img alt="Biking" height="720" src="http://getfile2.posterous.com/getfile/files.posterous.com/temp-2012-05-24/cBvwwJzIBvpFwqomctteDxzpsuhslIhsHeHHEkBtGaytkhavydAlFhGyvajf/Biking.jpg.scaled1000.jpg" width="960" /&gt;&lt;/a&gt; &lt;a href="http://getfile1.posterous.com/getfile/files.posterous.com/temp-2012-05-24/AaexyvvtFEFinGulfaCdvJAAEpqEJvoJeJAlGAzirJgoIDuHccpAIBFElniC/IMG_4597.JPG.scaled1000.jpg"&gt;&lt;img alt="Img_4597" height="750" src="http://getfile1.posterous.com/getfile/files.posterous.com/temp-2012-05-24/AaexyvvtFEFinGulfaCdvJAAEpqEJvoJeJAlGAzirJgoIDuHccpAIBFElniC/IMG_4597.JPG.scaled1000.jpg" width="1000" /&gt;&lt;/a&gt; &lt;a href="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-24/ncjmrJrnpDimgrrjmhHiylkGiEahvkuDrkzJEhAmvFceByqbeApFygoeHsnJ/Hiking.jpg.scaled1000.jpg"&gt;&lt;img alt="Hiking" height="960" src="http://getfile4.posterous.com/getfile/files.posterous.com/temp-2012-05-24/ncjmrJrnpDimgrrjmhHiylkGiEahvkuDrkzJEhAmvFceByqbeApFygoeHsnJ/Hiking.jpg.scaled1000.jpg" width="720" /&gt;&lt;/a&gt; &lt;img alt="Snowboarding" height="604" src="http://getfile5.posterous.com/getfile/files.posterous.com/temp-2012-05-24/zxevmfvImxiBlcspHemozesvGBGtlBohxcAFEetFlldAoJGhaidDszoAikmu/Snowboarding.jpg.scaled1000.jpg" width="453" /&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/goodbye-utah"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Leaving all of this behind makes me sad. Utah made me into what I am today.&lt;/div&gt;
&lt;div&gt;
But now I'm headed to Portland to work for &lt;a href="http://newrelic.com/"&gt;New Relic&lt;/a&gt;. I'm told Oregon is a wonderful place, but I'll always have fond memories of Utah wherever I go.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=2b63MXiqAEE:7ULfF6dRWVY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/2b63MXiqAEE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/2b63MXiqAEE/goodbye-utah_24.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2012/05/goodbye-utah_24.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-8240017388112502858</guid><pubDate>Wed, 16 May 2012 02:28:00 +0000</pubDate><atom:updated>2012-05-15T20:28:10.801-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Python Profiling - Part 1</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
I gave a talk on profiling python code at the 2012 Utah Open Source Conference.&amp;nbsp;Here are the &lt;a href="http://bit.ly/J4lO2L"&gt;slides&lt;/a&gt; and the accompanying &lt;a href="http://bit.ly/IJTm8e"&gt;code&lt;/a&gt;.&lt;br /&gt;
There are three parts to this profiling talk:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Standard Lib Tools - cProfile, Pstats&lt;/li&gt;
&lt;li&gt;Third Party Tools - line_profiler, mem_profiler&lt;/li&gt;
&lt;li&gt;Commercial Tools - New Relic&lt;/li&gt;
&lt;/ul&gt;
This is Part 1 of that talk. It covers:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;cProfile module - usage&lt;/li&gt;
&lt;li&gt;Pstats module - usage&lt;/li&gt;
&lt;li&gt;RunSnakeRun - GUI viewer&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Why Profiling:&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Identify the bottle-necks.&lt;/li&gt;
&lt;li&gt;Optimize intelligently.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: center;"&gt;
In God we trust, everyone else bring data&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;&lt;a href="http://docs.python.org/library/profile.html#module-cProfile"&gt;cProfile:&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
cProfile is a profiling module that is included in the Python's standard library. It instruments the code and reports the time to run each function and the number of times each function is called.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;strong&gt;Basic Usage:&lt;/strong&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
The sample code I'm profiling is finding the lowest common multiplier of two numbers. &lt;a href="https://github.com/amjith/utosc_python_profiling/blob/master/code_samples/lcm.py"&gt;lcm.py&lt;/a&gt;&lt;/div&gt;
&lt;pre&gt;# lcm.py - ver1 
    def lcm(arg1, arg2):
        i = max(arg1, arg2)
        while i &amp;lt; (arg1 * arg2):
            if i % min(arg1,arg2) == 0:
                return i
            i += max(arg1,arg2)
        return(arg1 * arg2)

    lcm(21498497, 3890120)&lt;/pre&gt;
Let's run the profiler.&lt;br /&gt;
&lt;pre&gt;$ python -m cProfile lcm.py 
     7780242 function calls in 4.474 seconds
    
    Ordered by: standard name
   
    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
         1    0.000    0.000    4.474    4.474 lcm.py:3()
         1    2.713    2.713    4.474    4.474 lcm.py:3(lcm)
   3890120    0.881    0.000    0.881    0.000 {max}
         1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
   3890119    0.880    0.000    0.880    0.000 {min}&lt;/pre&gt;
&lt;strong&gt;Output Columns:&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; ncalls - number of calls to a function.&lt;/li&gt;
&lt;li&gt; tottime - total time spent in the function without counting calls to sub-functions.&lt;/li&gt;
&lt;li&gt; percall - tottime/ncalls &lt;/li&gt;
&lt;li&gt; cumtime - cumulative time spent in a function and it's sub-functions.&lt;/li&gt;
&lt;li&gt; percall - cumtime/ncalls&lt;/li&gt;
&lt;/ul&gt;
It's clear from the output that the built-in functions max() and min() are called a few thousand times which could be optimized by saving the results in a variable instead of calling it every time.&lt;br /&gt;
&lt;ul&gt;  &lt;/ul&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;&lt;a href="http://docs.python.org/library/profile.html#the-stats-class"&gt;Pstats&lt;/a&gt;:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
Pstats is also included in the standard library that is used to analyze profiles that are saved using the cProfile module.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Usage:&lt;/strong&gt;&lt;br /&gt;
For scripts that are bigger it's not feasible to analyze the output of the cProfile module on the command-line. The solution is to save the profile to a file and use Pstats to analyze it like a database. Example:&amp;nbsp;&amp;nbsp;Let's analyze&amp;nbsp;&lt;a href="https://github.com/amjith/utosc_python_profiling/blob/master/code_samples/url_shortener/shorten.py"&gt;shorten.py&lt;/a&gt;.&lt;br /&gt;
&lt;pre&gt;$ python -m cProfile -o shorten.prof shorten.py   # saves the output to shorten.prof  
$ ls shorten.py shorten.prof&lt;/pre&gt;
Let's analyze the profiler output to list the top 5 frequently called functions.&lt;br /&gt;
&lt;pre&gt;$ python 
&amp;gt;&amp;gt;&amp;gt; import pstats
&amp;gt;&amp;gt;&amp;gt; p  = pstats.Stats('script.prof')   # Load the profiler output
&amp;gt;&amp;gt;&amp;gt; p.sort_stats('calls')              # Sort the results by the ncalls column
&amp;gt;&amp;gt;&amp;gt; p.print_stats(5)                   # Print top 5 items

    95665 function calls (93215 primitive calls) in 2.371 seconds
    
   Ordered by: call count
   List reduced from 1919 to 5 due to restriction &amp;lt;5&amp;gt;
    
       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    10819/10539    0.002    0.000    0.002    0.000 {len}
           9432    0.002    0.000    0.002    0.000 {method 'append' of 'list' objects}
           6061    0.003    0.000    0.003    0.000 {isinstance}
           3092    0.004    0.000    0.005    0.000 /lib/python2.7/sre_parse.py:182(__next)
           2617    0.001    0.000    0.001    0.000 {method 'endswith' of 'str' objects}
&lt;/pre&gt;
&lt;pre&gt;
&lt;/pre&gt;
This is quite tedious or not a lot of fun. Let's introduce a GUI so we can easily drill down.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;&lt;a href="http://www.vrplumber.com/programming/runsnakerun/"&gt;RunSnakeRun&lt;/a&gt;:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
This cleverly named GUI written in wxPython makes life a lot easy.&amp;nbsp;Install it from PyPI using (requires wxPython)&lt;br /&gt;
&lt;pre&gt;$ pip install SquareMap RunSnakeRun&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;$ runsnake shorten.prof     #load the profile using GUI&lt;/pre&gt;
The output is displayed using squaremaps that clearly highlights the bigger pieces of the pie that are worth optimizing.&lt;br /&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile8.posterous.com/getfile/files.posterous.com/temp-2012-05-15/gaJlueuhwimecexomyhcmrizGtCqHAwszdbsrxqIxsfmmlbwGgsdmgeeyqqD/runsnake.png.scaled1000.png"&gt;&lt;img alt="Runsnake" height="317" src="http://getfile2.posterous.com/getfile/files.posterous.com/temp-2012-05-15/gaJlueuhwimecexomyhcmrizGtCqHAwszdbsrxqIxsfmmlbwGgsdmgeeyqqD/runsnake.png.scaled600.png" width="600" /&gt;&lt;/a&gt;&lt;/div&gt;
It also lets you sort by clicking the columns or drill down by double clicking on a piece of the SquareMap.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
That concludes Part 1 of the profiling series. All the tools except RunSnakeRun are available as part of the standard library. It is essential to introspect the code before we start shooting in the dark in the hopes of optimizing the code.&lt;br /&gt;
&lt;br /&gt;
We'll look at line_profilers and mem_profilers in Part 2. Stay tuned.&lt;br /&gt;
&lt;br /&gt;
You are welcome to follow me on &lt;a href="https://twitter.com/#!/amjithr"&gt;twitter(@amjithr)&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=TdG6F8DNC4E:zWfUxlX73Pw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/TdG6F8DNC4E" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/TdG6F8DNC4E/python-profiling-part-1.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2012/05/python-profiling-part-1.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-824341406607321022</guid><pubDate>Wed, 21 Mar 2012 04:56:00 +0000</pubDate><atom:updated>2012-03-20T23:02:17.512-06:00</atom:updated><title>PyCon 2012 Review</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
PyCon 2012 was held at Santa Clara, California.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Tutorial:&lt;/strong&gt;&lt;br /&gt;
&lt;div&gt;
I was there on the Thrusday to attend a tutorial called &lt;a href="http://pyvideo.org/video/613/python-epiphanies" target="_blank"&gt;Python Epiphanies&lt;/a&gt;. The tutorial was educational in understanding some of the inner workings of Python. But I have a hard time trying to figure out how to use the knowledge I gained there.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Opening Ceremony:&lt;/strong&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;strong&gt;We had ROBOTS.&lt;/strong&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile2.posterous.com/getfile/files.posterous.com/amjith/ML1YQ727akZKMZpb5FBgc5S25JrSJpTfard0MbAZxcVA0jcASi6rYaOFJlFe/P1080277.jpg.scaled.1000.jpg"&gt;&lt;img alt="P1080277" height="450" src="http://getfile5.posterous.com/getfile/files.posterous.com/amjith/y3j5kUaOublzxav62l3qLoSuOcf4CJJxAmT1LXGullsP4xnVrmPeCQsijV4A/P1080277.jpg.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;a href="http://getfile8.posterous.com/getfile/files.posterous.com/amjith/2YMaybIHQglVpeJ1UjVkC8lwtyzLVtrPGFO6Sa0A04dVw7Wy2G7XXEMyyC9f/P1080276.jpg.scaled.1000.jpg"&gt;&lt;img alt="P1080276" height="800" src="http://getfile0.posterous.com/getfile/files.posterous.com/amjith/9KB0wrjCDen6dJ77rIVQ6QJL6z9f49Nh0IsNUHzREOw6KHka7merdyFQqUzR/P1080276.jpg.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;a href="http://getfile5.posterous.com/getfile/files.posterous.com/amjith/yGoseNeWUoX4wr3aeFX3mjQOhefZOCCUKIapxnLGtNB5HykviRD1R2zGgYvb/P1080279.jpg.scaled.1000.jpg"&gt;&lt;img alt="P1080279" height="450" src="http://getfile2.posterous.com/getfile/files.posterous.com/amjith/yUzOiSsPTBKrot6TRm93izW70h5CWYuismsDICgrGmzAYwFQeSNEz2gLK0tg/P1080279.jpg.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;div class="p_see_full_gallery"&gt;
&lt;a href="http://amjith.posterous.com/pycon-2012-review"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
And they were dancing.... how cool was that? It was a splendid opening ceremony.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Socializing:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
Thursday evening was bag stuffing. Where we helped out by stuffing the swag bag. I got to work side-by-side some well known figures in the community (&lt;a href="https://twitter.com/#!/jessenoller" target="_blank"&gt;Jesse Noller&lt;/a&gt;, &lt;a href="http://pydanny.github.com/" target="_blank"&gt;Pydanny&lt;/a&gt;). After that I hung out with some &lt;a href="http://www.heroku.com/" target="_blank"&gt;Heroku&lt;/a&gt; folks and learned about their awesome work culture.&lt;/div&gt;
&lt;div&gt;
Later that night, Yannick and &lt;a href="https://twitter.com/#!/bryanveloso" target="_blank"&gt;Bryan&lt;/a&gt; gave a Pycon newbie orientation. I took their advice and gave a Lightning Talk about bpython (about 10mins into the video).&lt;/div&gt;
&lt;div&gt;
&lt;iframe allowfullscreen="" frameborder="0" height="417" src="http://www.youtube.com/embed/N4zdWLuSbV0#t=637s?wmode=transparent" width="500"&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;
I socialized plenty and got a lot of useful contacts from different companies.&amp;nbsp;I got to meet the founders of &lt;a href="http://octopart.com/" target="_blank"&gt;Octopart&lt;/a&gt;, my favorite Electrical Engineering based startups.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
I also met with &lt;a href="http://www.kennethreitz.com/" target="_blank"&gt;Kenneth Reitz&lt;/a&gt;&amp;nbsp;who is famous for his requests library and this awesome talk &lt;a href="http://python-for-humans.heroku.com/" target="_blank"&gt;Python for Humans&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
I was quite thrilled when I first saw Guido at the Lunch hall sitting right next to my table. I was too shy to talk to him, but I managed to get a picture with him (in the frame).&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile0.posterous.com/getfile/files.posterous.com/amjith/7jH6iwvNBdIqJEwWKDKaMuzMKGI35gJRcWkkSWEqkoULM3G2MAqm1DTO3BZf/P1080280.jpg.scaled.1000.jpg"&gt;&lt;img alt="P1080280" height="450" src="http://getfile5.posterous.com/getfile/files.posterous.com/amjith/jcy0wjMjnaUOtxniWf59meL1C8p1iR62Lcx3D8Y302txA51IjgiBEQ7aRC5I/P1080280.jpg.scaled600.jpg" width="600" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Real gutsy! Maybe next year I'll actually shake his hand and get a picture with him.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Keynotes:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;I enjoyed Paul Graham's &lt;a href="http://pyvideo.org/video/626/keynote-paul-graham-ycombinator" target="_blank"&gt;keynote&lt;/a&gt; quite a bit. He talked about daring startup ideas. His keynote is summarized in these &lt;a href="http://paulgraham.com/ambitious.html" target="_blank"&gt;two&lt;/a&gt; &lt;a href="http://paulgraham.com/property.html" target="_blank"&gt;essays&lt;/a&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;David Beazly's &lt;a href="http://pyvideo.org/video/659/keynote-david-beazley" target="_blank"&gt;keynote&lt;/a&gt; was a walk-through (demo) of tinkering with PyPy. It looked hard as balls and I kept hoping a happy ending where he declared victory. But it ended up being one of those art movie endings that leaves the listeners in a confused and inconclusive state.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/956/keynote-guido-van-rossum" target="_blank"&gt;Guido's Keynote&lt;/a&gt; on the other hand was interesting. His talk was sprinkled with unintended hilarity that ensued due to Google's presentation software. He was sporting an awesome T-shirt that read "Python is for girls" and talked about dealing with Python Trolls.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Talks:&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
I knew that all the talks were video taped and posted &lt;a href="http://pyvideo.org/" target="_blank"&gt;online&lt;/a&gt;, so I didn't worry too much about missing some when I had conflicts.&lt;/div&gt;
&lt;div&gt;
The following talks piqued my interest and will make me go exploring a little bit.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/650/permission-or-forgiveness" target="_blank"&gt;Permission or Forgiveness&lt;/a&gt;&amp;nbsp;- Quaint. Applying Grace Murray Hopper's logic to Python programming.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/696/pandas-powerful-data-analysis-tools-for-python" target="_blank"&gt;pandas: Powerful data-analysis tools for Python&lt;/a&gt;&amp;nbsp;- Useful.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/703/web-server-bottlenecks-and-performance-tuning" target="_blank"&gt;Webserver Performance Tuning&lt;/a&gt;&amp;nbsp;- Sounded like a sales pitch for New Relic, but not in a bad way.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/737/37-building-a-robot-that-can-play-angry-birds-on" target="_blank"&gt;Angry Birds playing Robot&lt;/a&gt;&amp;nbsp;- Hilarious and Informative.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://pyvideo.org/video/686/the-pyed-piper-a-modern-python-alternative-to-aw" target="_blank"&gt;Pyed Piper: Modern Alternative to Awk, Sed etc.&lt;/a&gt;&amp;nbsp; - Interesting.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Capoeira:&amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
I went to the open space organized by Pydanny where he brought his Capoeira instructor who taught us some awesome moves. By the end of the class, we are all breathing heavily and energized. Once I tried to do a hand stand and lost my balance, but Aikido training kicked in and I gracefully rolled out of my fall with just a carpet burn on my elbow.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;Open Spaces:&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
I didn't get a chance to go to many of them, but I did attend the open space for &lt;a href="http://saltstack.org/" target="_blank"&gt;SaltStack&lt;/a&gt; and sat with &lt;a href="http://eseth.org/" target="_blank"&gt;Seth House&lt;/a&gt; to try and get Salt running on my Macbook. After a few failed attempts, I decided to give Salt a chance on my linux desktop once I got home.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Babbage Difference Engine: (Not Pycon related)&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;
Sunday afternoon &lt;a href="http://mcquay.me/"&gt;Stephen McQuay&lt;/a&gt; (a fellow Utah Pythonista) and I decided to take up Vijay's offer to go visit the Computer History Museum where they were doing a live demo of the Babbage Difference Engine. OMG! It was awesome to watch the history come alive.&amp;nbsp;&lt;/div&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://getfile1.posterous.com/getfile/files.posterous.com/temp-2012-03-20/kfEnaqptlGcpwicjHpfwtqsJeDcaCtjGegahwCkkIetljfpDamAiAluawnEf/P1080286.JPG.scaled1000.jpg"&gt;&lt;img alt="P1080286" height="750" src="http://getfile1.posterous.com/getfile/files.posterous.com/temp-2012-03-20/kfEnaqptlGcpwicjHpfwtqsJeDcaCtjGegahwCkkIetljfpDamAiAluawnEf/P1080286.JPG.scaled1000.jpg" width="1000" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=1apKxrfmbtI:DBSCB4vh-FA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/1apKxrfmbtI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/1apKxrfmbtI/pycon-2012-review.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/N4zdWLuSbV0/default.jpg" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://amjith.blogspot.com/2012/03/pycon-2012-review.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6870761903910191356</guid><pubDate>Fri, 10 Feb 2012 16:42:00 +0000</pubDate><atom:updated>2012-03-23T16:50:22.127-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">algorithm</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Memoization Decorator</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
Recently I had the opportunity to give a short 10 min presentation on Memoization Decorator at our local UtahPython Users Group meeting.&lt;br /&gt;
&lt;blockquote&gt;
&lt;strong&gt;Memoization:&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Everytime a function is called, save the results in a cache (map).&lt;/li&gt;
&lt;li&gt;Next time the function is called with the exact same args, return the value from the cache instead of running the function.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
The code for memoization decorator for python is here: &lt;a href="http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize"&gt;http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Example:&lt;/strong&gt;&lt;br /&gt;
The typical recursive implementation of fibonacci calculation is pretty inefficient O(2^n).&amp;nbsp; &lt;br /&gt;
&lt;pre class="prettyprint"&gt;def fibonacci(num):
        print 'fibonacci(%d)'%num
        if num in (0,1):
            return num
        return fibonacci(num-1) + fibonacci(num-2)

&amp;gt;&amp;gt;&amp;gt; math_funcs.fibonacci(4)   # 9 function calls
    fibonacci(4)
    fibonacci(3)
    fibonacci(2)
    fibonacci(1)
    fibonacci(0)
    fibonacci(1)
    fibonacci(2)
    fibonacci(1)
    fibonacci(0)
    3
&lt;/pre&gt;
But the memoized version makes it ridiculously efficient O(n) with very little effort.&lt;br /&gt;
&lt;pre class="prettyprint"&gt;import memoized
@memoized
def fibonacci(num):
    print 'fibonacci(%d)'%num
    if num in (0,1):
        return num
    return fibonacci(num-1) + fibonacci(num-2)
    
&amp;gt;&amp;gt;&amp;gt; math_funcs.mfibonacci(4)  # 5 function calls
    fibonacci(4)
    fibonacci(3)
    fibonacci(2)
    fibonacci(1)
    fibonacci(0)
    3
&lt;/pre&gt;
&lt;div&gt;
&lt;strong&gt;We just converted an algorithm from Exponential Complexity to Linear Complexity by simply adding the memoization decorator.&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Slides&lt;/strong&gt;:&lt;br /&gt;
&lt;div&gt;
&lt;script src="http://speakerdeck.com/embed/4f3e77bda0d46a001f01268b.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;a href="http://speakerdeck.com/u/amjith/p/memoization-decorator"&gt;http://speakerdeck.com/u/amjith/p/memoization-decorator&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Presentation:&lt;/strong&gt;&lt;br /&gt;
I generated the slides using LaTeX Beamer. But instead of writing raw LaTeX code I used reStructured Text (rst) and used rst2beamer script to generate the .tex file.&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Source:&lt;/strong&gt;&lt;br /&gt;
The rst file and tex files are available in Github.&lt;br /&gt;
&lt;a href="https://github.com/amjith/User-Group-Presentations/tree/master/memoization_decorator"&gt;https://github.com/amjith/User-Group-Presentations/tree/master/memoization_de...&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Update&lt;/u&gt;: &lt;a href="http://news.ycombinator.com/item?id=3576791"&gt;Comment by dasht&lt;/a&gt;&amp;nbsp;via HackerNews pointed out that the terminology Cache is used when you have a fixed size container, whereas the memoization decorator above does not have a restriction on the size. Hence it's technically not a cache.&lt;br /&gt;
&lt;br /&gt;
Follow the comments in HackerNews:&amp;nbsp;&lt;a href="http://news.ycombinator.com/item?id=3576620"&gt;http://news.ycombinator.com/item?id=3576620&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=04fo5jMhBTM:0vT55te0ZFs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/04fo5jMhBTM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/04fo5jMhBTM/memoization-decorator.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2012/02/memoization-decorator.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-2953516280970806173</guid><pubDate>Fri, 10 Feb 2012 06:09:00 +0000</pubDate><atom:updated>2012-02-10T09:48:50.288-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">django</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Productive Meter</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;A few weeks ago I decided that I should suck it up and start learning how to develop for the web. After asking around, my faithful community brethren, I decided to learn Django from its &lt;a href="https://docs.djangoproject.com/en/1.3/intro/tutorial01/"&gt;docs&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;::Django documentation is awesome::&lt;/p&gt;  &lt;p&gt;Around this time I came across this post about &lt;a href="http://www.mattgreer.org/post/2fiveam"&gt;Waking up at 5am to code&lt;/a&gt;. I tried it a few times and it worked wonders. I've been working on a small project that can keep track of my productivity on the computer. The concept is really simple, just log the window that is on top and find a way to display that data in a meaningful way.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Today's 5am session got me to a milestone on my project. I am finally able to visaulize the time I spend using a decent looking graph. Which is a huge milestone for someone who learned how to display html tables 3 weeks ago.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Tools:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;  &lt;li&gt;&lt;a href="https://www.djangoproject.com/"&gt;Django&lt;/a&gt;&amp;nbsp;for backend&lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.sqlite.org/"&gt;Sqlite&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href="http://haystacksearch.org/"&gt;Haystack/Solr&lt;/a&gt; - search backend for Django&lt;/li&gt;  &lt;li&gt;&lt;a href="http://fancybox.net/"&gt;FancyBox&lt;/a&gt; - jquery plugin&lt;/li&gt;  &lt;li&gt;&lt;a href="http://code.google.com/p/flot/"&gt;flot&lt;/a&gt; - jquery plotting lib&lt;/li&gt;  &lt;li&gt;&lt;a href="http://twitter.github.com/bootstrap/"&gt;Bootstrap&lt;/a&gt; - html/css&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;A huge thanks to my irc friends and random geeks who wrote awesome blog posts and SO answers on every problem I encountered.&lt;/p&gt;  &lt;p&gt;I will be open-sourcing the app pretty soon. Stay tuned.&lt;/p&gt;  &lt;p&gt;&lt;div class='p_embed p_image_embed'&gt; &lt;a href="http://getfile8.posterous.com/getfile/files.posterous.com/temp-2012-02-09/duGEaJvxHAffFfposnvqldjhhmCEAvhDBmIvhrlsFqqGhbqJcrvfwCzbudAf/productive_meter_screenshot.png.scaled1000.png"&gt;&lt;img alt="Productive_meter_screenshot" height="313" src="http://getfile6.posterous.com/getfile/files.posterous.com/temp-2012-02-09/duGEaJvxHAffFfposnvqldjhhmCEAvhDBmIvhrlsFqqGhbqJcrvfwCzbudAf/productive_meter_screenshot.png.scaled600.png" width="600" /&gt;&lt;/a&gt; &lt;a href="http://getfile3.posterous.com/getfile/files.posterous.com/temp-2012-02-09/ohgFstdpHDqsdhsFfHIEGamrgAnpFGijwixccArgwerwwlrFtluAbkDIprxi/productive_meter_screenshot1.png.scaled1000.png"&gt;&lt;img alt="Productive_meter_screenshot1" height="446" src="http://getfile3.posterous.com/getfile/files.posterous.com/temp-2012-02-09/ohgFstdpHDqsdhsFfHIEGamrgAnpFGijwixccArgwerwwlrFtluAbkDIprxi/productive_meter_screenshot1.png.scaled1000.png" width="1000" /&gt;&lt;/a&gt; &lt;div class='p_see_full_gallery'&gt;&lt;a href="http://amjith.posterous.com/100506320"&gt;See the full gallery on Posterous&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=3d5-m4H1k_Q:2gs3CUSRDaA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/3d5-m4H1k_Q" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/3d5-m4H1k_Q/productive-meter.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2012/02/productive-meter.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-7335440754230861981</guid><pubDate>Tue, 22 Nov 2011 06:47:00 +0000</pubDate><atom:updated>2011-11-21T23:47:19.231-07:00</atom:updated><title>Too Many Classes Too Little Time</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;I'm taking a couple of the free online classes offered by Standford. One on &lt;a href="http://ai-class.org"&gt;Artifical Intelligence&lt;/a&gt; and one on &lt;a href="http://ml-class.org"&gt;Machine Learning&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;I haven't had so much fun since kindergarten. Actually that's not fair, I didn't enjoy kindergarten this much. I'm listening to the classes during my lunch, after work, during weekends. I'm working on my assignment with so much enthusiasm, I dread the day when this class ends.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Stanford just announced a slew of new &lt;a href="http://www.hci-class.org/"&gt;online&lt;/a&gt; classes offered starting in Jan 2012. I was way too excited when I first read the description on them. Now I'm a little sad, becasue I want to take 8 out of the 11 courses that are being offered and I don't have enough time. :(&lt;/p&gt;  &lt;p&gt;Woe is me.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;ps: If you are not taking any of these classes you are missing out big time. Please do yourself a favor and sign up.&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=pccDqAoLd8Y:qOYtPn4xrYU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/pccDqAoLd8Y" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/pccDqAoLd8Y/im-taking-couple-of-free-online-classes.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/11/im-taking-couple-of-free-online-classes.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-909988614520025137</guid><pubDate>Tue, 18 Oct 2011 05:01:00 +0000</pubDate><atom:updated>2011-10-17T23:09:19.822-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">recursion</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Picking 'k' items from a list of 'n' - Recursion</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
Let me preface this post by saying I suck at recursion. But it never stopped me from trying to master it. Here is my latest (successful) attempt at an algorithm that required recursion.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Background:&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;
You can safely skip this section if you're not interested in the back story behind why I decided to code this up.&lt;br /&gt;
&lt;br /&gt;
I was listening to &lt;a href="http://www.khanacademy.org/"&gt;KhanAcademy&lt;/a&gt; videos on &lt;a href="http://www.khanacademy.org/#probability"&gt;probability&lt;/a&gt;. I was particularly intrigued by the combinatorics &lt;a href="http://www.khanacademy.org/video/getting-exactly-two-heads--combinatorics?playlist=Probability"&gt;video&lt;/a&gt;. The formula to calculate the number of combinations of nCr was simple, but I wanted to print all the possible combinations of nCr.&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br /&gt;
Given 'ABCD' what are the possible outcomes if you pick 3 letters from it to form a combination without repetition (i.e. 'ABC' is the same as 'BAC').&lt;br /&gt;
&lt;br /&gt;
At first I tried to solve this using an iterative method and gave up pretty quickly. It was clearly designed to be a recursive problem. After 4 hours of breaking my head I finally got a working algorithm using recursion. I was pretty adamant about not looking it up online but I seeked some help from IRC (Thanks &lt;a href="http://www.jtolds.com/"&gt;jtolds&lt;/a&gt;).&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Code:&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;def combo(w, l):
    lst = []
    for i in range(len(w)):
        if l == 1:
            lst.append(w[i])
        for c in combo(w[i+1:], l-1):
            lst.append(w[i] + c)
    return lst
&lt;/pre&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;&amp;gt;&amp;gt;&amp;gt; combinations.combo('abcde',3)
    ['abc', 'abd', 'abe', 'acd', 'ace', 'ade', 'bcd', 'bce', 'bde', 'cde']
&lt;/pre&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Thoughts:&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;It helps to think about recursion with the assumption that an answer for step n-1 already exists.&lt;/li&gt;
&lt;li&gt;If you are getting partial answers check the condition surrounding the return statement.&lt;/li&gt;
&lt;li&gt;Recursion is still not clear (or easy).&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
I have confirmed that this works for bigger data sets and am quite happy with this small victory.&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=mU0MvPilRmo:zPfAr6ri5sU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/mU0MvPilRmo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/mU0MvPilRmo/picking-items-from-list-of-recursion.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/10/picking-items-from-list-of-recursion.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-4958320516126485052</guid><pubDate>Fri, 14 Oct 2011 04:50:00 +0000</pubDate><atom:updated>2012-05-04T10:45:35.153-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Python Profiling</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
I did a presentation at our &lt;a href="http://www.utahpython.org/"&gt;local Python User Group&lt;/a&gt; meeting tonight. It was well received, but shorter than I had expected. I should've added a lot more code examples.&lt;br /&gt;
We talked about usage of cProfile, pstats, runsnakerun and timeit.&lt;br /&gt;
Here are the slides from the presentations:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #0000ee;"&gt;&lt;u&gt;&lt;a href="http://speakerdeck.com/u/amjith/p/python-profiling-1"&gt;http://speakerdeck.com/u/amjith/p/python-profiling-1&lt;/a&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #0000ee;"&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;script src="http://speakerdeck.com/embed/4f3e760bdf5d29001f011e12.js"&gt;
&lt;/script&gt;
&lt;br /&gt;
The slides were done using &lt;a href="http://en.wikipedia.org/wiki/Beamer_(LaTeX)"&gt;latex-beamer&lt;/a&gt;, but I wrote the slides in &lt;a href="http://docutils.sourceforge.net/rst.html"&gt;reStructuredText&lt;/a&gt; and used &lt;a href="http://www.agapow.net/programming/python/rst2beamer"&gt;rst2beamer&lt;/a&gt; to create slides.&lt;br /&gt;
The source code for the slides are available on my &lt;a href="http://www.blogger.com/blogger.g?blogID=9876605"&gt;github page&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=kqAU2AYxACc:Gr8P-05krEk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/kqAU2AYxACc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/kqAU2AYxACc/python-profiling.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/10/python-profiling.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-1383062871417921914</guid><pubDate>Wed, 05 Oct 2011 05:44:00 +0000</pubDate><atom:updated>2011-10-10T13:48:34.611-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Programming - A Gateway Drug to Math</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
&lt;div&gt;
I decided to try my hand at the Stanford's&amp;nbsp;&lt;a href="http://www.ai-class.com/"&gt;AI Class&lt;/a&gt;.&amp;nbsp;The pre-requisites mentioned Probability and Linear Algebra. So I started watching Probability videos on&amp;nbsp;&lt;a href="http://www.khanacademy.org/#probability"&gt;KhanAcademy&lt;/a&gt;.&lt;br /&gt;
Sal Khan was teaching how to find the probability of 2 heads when you toss a coin 5 times.&lt;br /&gt;
A classic nCk problem:&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;img alt="" src="http://latex.codecogs.com/gif.latex?\small%20_nC_k%20=%20\frac{n!}{k!(n-k)!}" style="margin: 10px;" title="This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program." /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 13px;"&gt;T&lt;/span&gt;&lt;span style="background-color: white; font-family: Arial, Helvetica, sans-serif; font-size: 13px;"&gt;he probability of getting 2 heads while tossing a coin 5 times is:&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;img alt="" src="http://latex.codecogs.com/gif.latex?P(2)%20=%20\frac{{_5C_2}}{2^5}" style="margin: 10px;" title="This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program." /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;But I wanted to find out the probability of getting at least 2 heads when I toss 5 coins.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Its really simple. All I had to do is P(2) + P(3) + P(4) + P(5).&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;But then computing&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;img alt="" src="http://latex.codecogs.com/gif.latex?_nC_k" style="margin: 10px;" title="This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program." /&gt;&lt;span style="font-size: small;"&gt;by hand (or a calculator) was painfully slow, let alone do it 4 times.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;So I wrote two little functions in Python that will calculate factorial (yes I reinvented the wheel) and&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;img alt="" src="http://latex.codecogs.com/gif.latex?_nC_k" style="margin: 10px;" title="This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program." /&gt;&lt;span style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;strong&gt;Nothing teaches you math faster than trying to write a program to do the math for you.&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Writing a program is the same as teaching the computer how to do a certain task. The only way you can teach someone to do a task is to become a master at doing that task yourself.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Bonus: It also teaches you corner cases like 0! = 1 and&amp;nbsp;&lt;img alt="" src="http://latex.codecogs.com/gif.latex?\small%20_5C_5%20=%201" style="margin: 10px;" title="This is the rendered form of the equation. You can not edit this directly. Right click will give you the option to save the image, and in most browsers you can drag the image onto your desktop or another program." /&gt;&amp;nbsp;that you wouldn't think of otherwise.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=HFwvtZAaes4:2IH-N4Kl9qc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/HFwvtZAaes4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/HFwvtZAaes4/programming-gateway-drug-to-math_04.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/10/programming-gateway-drug-to-math_04.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6883539583294994725</guid><pubDate>Wed, 05 Oct 2011 03:39:00 +0000</pubDate><atom:updated>2011-10-10T13:48:57.903-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Rant about C++ dependency hell</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
When was the last time I vented about C++? The answer for that is always:&lt;br /&gt;
&lt;br /&gt;
"TOO LONG AGO".&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
The initial friction to setup a substantial project using C++ is unfucking bearable.&lt;br /&gt;
&lt;br /&gt;
When we started code revamp at work recently, I decided to be a good citizen and decided to incorporate &lt;a href="http://cpptest.sourceforge.net/"&gt;cpptest&lt;/a&gt;, a unit testing framework.&lt;br /&gt;
&lt;br /&gt;
It made me realize how unreasonably complicated Makefiles can become. After 3 hours of peeling away at the complexity I managed to add cpptest to the build dependency of the project.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Now time to write a few tests and check it out.&amp;nbsp;I'm thinking "We are almost there".&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
FALSE!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Compilation gives me a gazillion error messages that make absolutely no sense. After about 30mins of &lt;a href="http://www.stackoverflow.com/"&gt;StackOverflowing&lt;/a&gt; and Googling, I find out that string and map that I declared in the headers files need to be namespaced. Of course there is no indication (not even a hint) of that in the error messages. So I add 'using namespace std' and get past it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Awesome my first test is compiling successfully. Time to run this baby and declare victory.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Close! But no cigar.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
The executable was unable to load the CppTest library during runtime. Argh!&lt;/div&gt;
&lt;div&gt;
I set my LD_LIBRARY_PATH env variable and now it's running. But I can't ask everyone in my team to do that, so I have to figure out how to statically link that library.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
It's already 6pm and I'm hungry. That'll have to wait for another day.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
TL;DR - C++ and Makefile can burn in a fire of thousand suns.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=wjnFFYhF13A:DPfef-HO9eU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/wjnFFYhF13A" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/wjnFFYhF13A/rant-about-c-dependency-hell.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>2</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/10/rant-about-c-dependency-hell.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-5327317317636155513</guid><pubDate>Mon, 26 Sep 2011 03:02:00 +0000</pubDate><atom:updated>2011-10-10T13:44:54.227-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Rapid Prototyping in Python</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
I was recently assigned to a new project at work. Like any good software engineer I started writing the pseudocode for the modules. We use C++ at work to write our programs.&lt;br /&gt;
I quickly realized it's not easy to translate programming ideas to English statements without a syntactic structure. When I was whining about it to Vijay, he told me to try prototyping it in Python instead of writing pseudocode. Intrigued by this, I decided to write a prototype in Python to test how various modules will come together.&lt;br /&gt;
Surprisingly it took me a mere 2 hours to code up the prototype. I can't emphasize enough, how effortless it was in Python.&lt;br /&gt;
&lt;h2&gt;







What makes Python an ideal choice for prototyping:&lt;/h2&gt;
&lt;strong&gt;Dynamically typed language:&lt;/strong&gt;&lt;br /&gt;
Python doesn't require you to declare the datatype of a variable. This lets you write a function that is generic enough to handle any kind of data. For eg:&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;&lt;span class="kw"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;max_val&lt;/span&gt;(a,b):&amp;nbsp;
&lt;span class="kw"&gt;    return&lt;/span&gt; a &lt;span class="kw"&gt;if&lt;/span&gt; a &amp;gt;b &lt;span class="kw"&gt;else&lt;/span&gt; b&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
This function can take integers, floats, strings, a combination of any of those, or lists, dictionaries, tuples, whatever.&lt;br /&gt;
A list in Python need not be homogenous. This is a perfectly good list:&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;[&lt;span class="i"&gt;1&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;abc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, [&lt;span class="i"&gt;1&lt;/span&gt;,&lt;span class="i"&gt;2&lt;/span&gt;,&lt;span class="i"&gt;3&lt;/span&gt;]]
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
This lets you pack data in unique ways on the fly which can later be translated to a class or a struct in a statically typed language like C++.&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;newDataType&lt;/span&gt;&amp;nbsp;
{&amp;nbsp;
&lt;span class="pt"&gt;    int&lt;/span&gt; i;&amp;nbsp;
    String str;&amp;nbsp;
    Vector vInts;&amp;nbsp;
};
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;Rich Set to Data-Structures:&lt;/strong&gt;&lt;br /&gt;
Built-in support for lists, dictionaries, sets, etc reduces the time involved in hunting for a library that provides you those basic data-structures.&lt;br /&gt;
&lt;strong&gt;Expressive and Succinct:&lt;/strong&gt;&lt;br /&gt;
The algorithms that operate on the data-structures are intuitive and simple to use. The final code is more readable than a pseudocode.&lt;br /&gt;
For example: Lets check if a list has an element&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;&amp;gt;&amp;gt;&amp;gt; lst = [&lt;span class="i"&gt;1&lt;/span&gt;,&lt;span class="i"&gt;2&lt;/span&gt;,&lt;span class="i"&gt;3&lt;/span&gt;]    &lt;span class="c"&gt;# Create a list&lt;/span&gt;&amp;nbsp;
&amp;gt;&amp;gt;&amp;gt; res = &lt;span class="i"&gt;2&lt;/span&gt; &lt;span class="kw"&gt;in&lt;/span&gt; lst   &lt;span class="c"&gt;# Check if 2 is in 'lst'&lt;/span&gt; &lt;span class="pc"&gt;True&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
If we have to do it in C++.&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;list lst;&amp;nbsp;
lst.push_back(&lt;span class="i"&gt;3&lt;/span&gt;);&amp;nbsp;
lst.push_back(&lt;span class="i"&gt;1&lt;/span&gt;);&amp;nbsp;
lst.push_back(&lt;span class="i"&gt;7&lt;/span&gt;);&amp;nbsp;
list::iterator result = find(lst.begin(), lst.end(), &lt;span class="i"&gt;7&lt;/span&gt;); &amp;nbsp;
&lt;span class="pt"&gt;bool&lt;/span&gt; res = (result != lst.end())
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Python Interpreter and Help System:&lt;/strong&gt;&lt;br /&gt;
This is a huge plus. The presence of interpreter not only aids you in testing snippets of code, but it acts as an help system. Lets say we want to look up the functions that operate on a List.&lt;br /&gt;
&lt;div class="CodeRay"&gt;
&lt;div class="code"&gt;
&lt;pre class="prettyprint"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;span class="pd"&gt;dir&lt;/span&gt;([])&amp;nbsp;
[&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__add__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__class__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__contains__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__delattr__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__delitem__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__delslice__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__doc__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__eq__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__format__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__ge__&lt;/span&gt;&lt;/span&gt;&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;
,  &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__getattribute__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__getitem__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__getslice__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__gt__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__hash__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__iadd__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__imul__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__init__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__iter__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__le__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;
&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__len__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__lt__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__mul__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__ne__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__new__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__reduce__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__reduce_ex__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__repr__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__reversed__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__rmul__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__setattr__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;
&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__setitem__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__setslice__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;&lt;span class="s"&gt;&lt;span class="k"&gt;'_&lt;/span&gt;&lt;/span&gt;&lt;span class="s"&gt;&lt;span class="k"&gt;_sizeof__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__str__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;__subclasshook__&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;append&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;extend&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;insert&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;pop&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;remove&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;,&amp;nbsp;
&lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;reverse&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;sort&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt;] &amp;nbsp;
&amp;gt;&amp;gt;&amp;gt; help([].sort)&amp;nbsp;
Help on built-&lt;span class="kw"&gt;in&lt;/span&gt; function sort: &amp;nbsp;
    sort(...)&amp;nbsp;
      L.sort(cmp=&lt;span class="pc"&gt;None&lt;/span&gt;, key=&lt;span class="pc"&gt;None&lt;/span&gt;, reverse=&lt;span class="pc"&gt;False&lt;/span&gt;)&amp;nbsp;
      -- stable sort *IN PLACE*; &lt;span class="pd"&gt;cmp&lt;/span&gt;(x, y) -&amp;gt; -&lt;span class="i"&gt;1&lt;/span&gt;, &lt;span class="i"&gt;0&lt;/span&gt;, &lt;span class="i"&gt;1&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt; Advantages of prototyping instead of pseudocode: &lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The type definition of the datastructures emerge as we code. &lt;/li&gt;
&lt;li&gt;The edge cases start to emerge when you prototype. &lt;/li&gt;
&lt;li&gt;A set of required supporting routines. &lt;/li&gt;
&lt;li&gt;A better estimation of the time required to complete a task. &lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=zwMbTgdLFiM:uMNyymAMaZ8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/zwMbTgdLFiM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/zwMbTgdLFiM/rapid-prototyping-in-python.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/09/rapid-prototyping-in-python.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-9209047651312864547</guid><pubDate>Thu, 04 Aug 2011 05:20:00 +0000</pubDate><atom:updated>2012-02-13T08:15:10.532-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tmux</category><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Scripting Tmux Layouts</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="posterous_autopost"&gt;
&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 14px; line-height: 21px;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;a href="http://tmux.sourceforge.net/" style="color: #c55800; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;Tmux&lt;/a&gt; is an awesome replacement for Screen. I have a couple of standard terminal layouts for programming. One of them is shown below.&lt;/div&gt;
&lt;div style="margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 15px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://vim.org/" style="color: #c55800; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;Vim&lt;/a&gt; editor on the left.&lt;/li&gt;
&lt;li&gt;Top right pane has the &lt;a href="http://bpython-interpreter.org/" style="color: #c55800; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: underline;"&gt;bpython&lt;/a&gt; interpreter.&lt;/li&gt;
&lt;li&gt;Bottom right pane has the bash prompt.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="p_embed p_image_embed"&gt;
&lt;a href="http://posterous.com/getfile/files.posterous.com/temp-2011-08-03/ucgsvidqdagbhdmwJJsxkwBekFpBvGyBqijpupiChuavtsftveikrmbnHrEi/python_dev.png.scaled1000.png"&gt;&lt;img alt="Python_dev" height="516" src="http://posterous.com/getfile/files.posterous.com/temp-2011-08-03/ucgsvidqdagbhdmwJJsxkwBekFpBvGyBqijpupiChuavtsftveikrmbnHrEi/python_dev.png.scaled1000.png" width="1000" /&gt;&lt;/a&gt; &lt;/div&gt;
&lt;div class="CodeRay"&gt;
I have a small tmux script in my ~/.tmux/pdev file that has the following lines &lt;/div&gt;

&lt;br /&gt;
&lt;pre class="prettyprint"&gt;selectp -t 0              # Select pane 0
splitw -h -p 50 'bpython' # Split pane 0 vertically by 50%
selectp -t 1              # Select pane 1
splitw -v -p 25           # Split pane 1 horizontally by 25%
selectp -t 0              # Select pane 0&lt;/pre&gt;

In my &lt;a href="https://github.com/amjith/_dotties/blob/master/tmux.conf"&gt;tmux.conf&lt;/a&gt; file I have bound &amp;lt;prefix&amp;gt;+P to sourcing this file. So now anytime I want to launch my python dev layout, I hit &amp;lt;prefix&amp;gt;+&amp;lt;shift&amp;gt;+p. &lt;br /&gt;

&lt;pre class="prettyprint"&gt;bind P source-file ~/.tmux/pdev&lt;/pre&gt;

&lt;/div&gt;
&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=T9NNyPjjoNo:xe-Hwee1Ckc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/T9NNyPjjoNo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/T9NNyPjjoNo/scripting-tmux-layouts.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>5</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/08/scripting-tmux-layouts.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-8404980168717029102</guid><pubDate>Tue, 07 Jun 2011 00:28:00 +0000</pubDate><atom:updated>2011-06-06T18:28:06.360-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tech</category><category domain="http://www.blogger.com/atom/ns#">jobs</category><title>How to Find Local Tech Jobs</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;Looking for tech jobs can be daunting.&amp;nbsp;Networking is touted as the magic bullet for job seekers. But where do you start?&lt;/p&gt;  &lt;p&gt;Here are some robust ways to build your network.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Users Group:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;User groups are typically monthly meetings for geeks who get together to talk about their favorite programming language or operating system. Usually they are accompanied with a mailing list which is used to announce the meetings, ask questions and &lt;span style="color: #008000;"&gt;&lt;strong&gt;post job openings&lt;/strong&gt;&lt;/span&gt;. So sign up to the mailing list and start attending the meetups. They are full of really nice people who are willing to help.&amp;nbsp;&lt;/p&gt;  &lt;ul&gt;  &lt;li&gt;&lt;a href="http://groups.google.com/group/utahpython/"&gt;Utah Python&lt;/a&gt; - Utah Python Users Group&lt;/li&gt;  &lt;li&gt;&lt;a href="http://utruby.org/"&gt;URUG&lt;/a&gt; - Utah Ruby Users Group&lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.sllug.org/"&gt;SLLUG&lt;/a&gt; - Salt Lake Linux Users Group   &lt;ul&gt;  &lt;li&gt;&lt;a href="http://www.sllug.org/cgi-bin/mailman/listinfo/sllug-jobs-announce"&gt;SLLUG-JOBS&lt;/a&gt; - Mailing list to announce job postings&lt;/li&gt;  &lt;/ul&gt;  &lt;/li&gt;  &lt;li&gt;&lt;a href="http://www.plug.org/"&gt;PLUG&lt;/a&gt;&amp;nbsp;- Provo Linux Users Group&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Local Conferences:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Most cities have some tech conferences that are a great source for networking. I found out about a lot of the user group by going to one of the following conference.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://utos.org/"&gt;UTOSC&lt;/a&gt; - Utah Open Source Conference.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://project-day.utos.org/projects-2011/"&gt;HackUTOS&lt;/a&gt; &amp;nbsp;- Utah Open Source Project Day - Geeks, snacks and open source.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.launchup.org/"&gt;LaunchUp&lt;/a&gt; - A local entreneurship clinic. A great way to learn about the local start-up scene. You can meet new CEOs and fresh companies looking to hire tech talent. A must for job-seekers.&lt;/p&gt;  &lt;p&gt;I hope this helps someone.&lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=3dt-L-ZGkiQ:gt2DuNuRfwQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/3dt-L-ZGkiQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/3dt-L-ZGkiQ/how-to-find-local-tech-jobs.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/06/how-to-find-local-tech-jobs.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-3800140188960511149</guid><pubDate>Thu, 05 May 2011 05:50:00 +0000</pubDate><atom:updated>2011-05-05T08:04:16.467-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Contributing to Open Source</title><description>&lt;div class="posterous_autopost"&gt;&lt;p&gt;Last week I successfully submitted my &lt;a href="https://bitbucket.org/bobf/bpython/changeset/bc4a8a7a0e65"&gt;first patch&lt;/a&gt; to an open source project and it was accepted. &lt;/p&gt;  &lt;p&gt;I like the &lt;a href="http://www.bpython-interpreter.org/"&gt;bpython&lt;/a&gt; interpreter for all my python needs. It is quite handy for a python newbie like me. A few weeks ago I was in the middle of building an elaborate datastructure to learn list comprehension in python, when bpython crashed and took all the history with it. I &lt;a href="https://twitter.com/#!/_ikanobori/status/60822979994583040"&gt;whined&lt;/a&gt; about it on twitter and one of the developers of the project prompted me to submit a bug report. I was quite impressed by the fact that a core developer of bpython replied to my bitching on twitter.&lt;/p&gt;  &lt;p&gt;After I filed the bug report, I decided to get the source code and poke around. I finally implemented a feature that will save the history after each command instead of waiting till the end of a session. &lt;/p&gt;  &lt;p&gt;The following factors were the main impetus that led me to contribute to the project. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Project Hosting: &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The project was hosted on &lt;a href="http://bitbucket.org/"&gt;bit bucket&lt;/a&gt; which is a &lt;a href="http://github.com/"&gt;Github&lt;/a&gt; equivalent for &lt;a href="http://mercurial.selenic.com/"&gt;mercurial&lt;/a&gt;. This makes it so easy to fork a project and issue pull requests, compared to the traditional source forge model of submitting patches in a mailing list. The social coding sites like Github and BitBucket have reduced much of the initial friction in starting an open source project.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Project Size:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This one has a huge impact when I decide to dive into the code. Traditional C projects tend to have a ton of files that are too big and daunting for a beginner. The bpython project was written in python and had a total of 13 .py files. This makes it dead simple to make a quick change and run the project without compiling it. Again the choice of language has a lot to do with this. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;IRC:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The welcoming nature of the community around a project does a lot to encourage a new comer. The IRC channels are a great way to interact with the developers compared to a passive form of communication such as emails. I jumped on #bpython irc channel and started asking questions when I ran into an issue with bpython source code. People on that channel are really helpful and prompt in answering questions.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Persistence:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;My first pull request was scrutinized by the core developers and some suggestions for improvements were given. During that process I learned a lot about code review and how to check for corner cases. Finally after I made all those improvements the pull request was accepted and merged with the main repo. So having a beginners mind (no ego) is an absolute must when getting started on any project. Don't be discouraged if your first attempt is unsuccessful. &lt;/p&gt;  &lt;p&gt;Now I'm proud to say my name is listed in the &lt;a href="https://bitbucket.org/bobf/bpython/src/fd740b9b73ad/AUTHORS"&gt;AUTHORS&lt;/a&gt; file of bpython project.&lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=s_XJhvQJUX4:lGYBUY40jPs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/s_XJhvQJUX4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/s_XJhvQJUX4/contributing-to-open-source.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>4</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/05/contributing-to-open-source.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-2240467666826394000</guid><pubDate>Tue, 26 Apr 2011 06:38:00 +0000</pubDate><atom:updated>2011-04-26T00:38:39.240-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">tmux</category><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Synchronize Panes in Tmux</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-size: small;"&gt;Tmux is an alternative for screen. For anyone who doesn't know screen, it is a terminal multiplexer which means, it allow multiple windows in terminal. It can split your window into multiple panes (vertical/horizontal), detach a session which can be attached at a later time. Detach/Attach is very useful for running a job in a remote server without having to keep the ssh open the whole time.&amp;nbsp;&lt;/span&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;Tmux can be configured by &amp;nbsp;~/&lt;a href="https://github.com/amjith/_dotties/blob/master/.tmux.conf"&gt;.tmux.conf&lt;/a&gt; file.&lt;/div&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;&lt;span style="font-size: medium;"&gt;My prefix key is Ctrl-q.&lt;/span&gt;&lt;/div&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;&lt;strong&gt;Synchronizing panes:&lt;/strong&gt;&lt;/div&gt;  &lt;div style="font-size: small;"&gt;If you want to send your keystrokes to all the panes in your tmux window:&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;&amp;lt;prefix&amp;gt; :setw synchronize-panes&lt;/div&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;In my case I do:&lt;/div&gt;  &lt;p /&gt;  &lt;div style="font-size: small;"&gt;&lt;span style="font-size: medium;"&gt;Ctrl-q:setw synchronize-panes&lt;/span&gt;&lt;/div&gt;  &lt;div style="font-size: small;"&gt;&lt;div class='p_embed p_video_embed'&gt; &lt;a href="http://amjith.posterous.com/synchronize-panes-in-tmux"&gt;&lt;img alt="" src="http://posterous.com/getfile/video.posterous.com/temp-2011-04-25/cucuFgGczimmmxzuwAhIydAIhuBalccuqxrkzmDEwtCrrHvGphgycrEfnbDs/frame_0000.png" /&gt;&lt;/a&gt; &lt;div class='p_embed_description'&gt; &lt;strong&gt;tmux.avi&lt;/strong&gt; &lt;a href="http://amjith.posterous.com/synchronize-panes-in-tmux"&gt;Watch on Posterous&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="font-size: small;"&gt;This is immensely useful if you want to execute the same set of commands on multiple servers.&lt;/div&gt;  &lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=IxQSAc3CQnI:7bEx_KW9eT4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/IxQSAc3CQnI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/IxQSAc3CQnI/synchronize-panes-in-tmux.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>2</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/04/synchronize-panes-in-tmux.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6282632803023201212</guid><pubDate>Tue, 01 Mar 2011 05:49:00 +0000</pubDate><atom:updated>2011-02-28T22:49:37.017-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">gnome ubuntu linux</category><title>Why do I hate Gnome?</title><description>&lt;div class='posterous_autopost'&gt;I&amp;#39;ve been using Ubuntu Linux on my netbook for the past couple of days and I&amp;#39;m quite pleased with the whole experience, except for the initial &lt;a href="http://amjith.posterous.com/ubuntu-and-i-have-some-trust-issues-tag-ubunt" target="_blank"&gt;issues&lt;/a&gt; (I just won&amp;#39;t trust the auto-update).&lt;p /&gt;&lt;div&gt;Ubuntu uses the Gnome desktop environment by default with a little bit of tweaking. Gnome UI designers have a sense of aesthetic cognizance to their designs. I&amp;#39;ve always appreciated the crisp icons and the polished dialogs. I&amp;#39;ve been known to throw around the word stunning, quite generously, while describing Gnome. &lt;/div&gt; &lt;p /&gt;&lt;div&gt;All these initial infatuations almost made me forget the reasons why I abandoned Gnome a few years ago. I  hate the absence of a central control center to tweak the default behavior of Gnome. There is however a severely handicapped version called gconf-editor which is like a terrible cousin of Windows Registry. So now if you want sloppy focus on gnome that doesn&amp;#39;t raise your window when you click on it, you just have to do the following simple steps:&lt;p /&gt; &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Open gconf-editor&lt;/li&gt;&lt;li&gt;apps&lt;/li&gt;&lt;li&gt;metacity&lt;/li&gt;&lt;li&gt;general&lt;/li&gt;&lt;li&gt;raise on click (uncheck)&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Quite intuitive wouldn&amp;#39;t you agree? &lt;/div&gt;&lt;p /&gt;&lt;div&gt;Oh you want to enable compositing, so your gnome-do can have some slick skins, here&amp;#39;s how you achieve that: &lt;/div&gt; &lt;p /&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Open gconf-editor&lt;/li&gt;&lt;li&gt;apps&lt;/li&gt;&lt;li&gt;metacity&lt;/li&gt;&lt;li&gt;general&lt;/li&gt;&lt;li&gt;compositing_manager (check)&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;Why? Why would you think this is more intuitive than having a simple GUI driven control center? I&amp;#39;m told this was a conscious choice by Gnome developers because giving choices tend to confuse their users.&lt;/div&gt; &lt;p /&gt;&lt;blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"&gt; If you think your users are idiots, only idiots will use it.&lt;/blockquote&gt;&lt;p /&gt;&lt;div&gt;No wonder &lt;a href="http://www.desktoplinux.com/news/NS8745257437.html"&gt;Linus was pissed&lt;/a&gt; at Gnome and started recommending KDE.&lt;/div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=8lXiT-CA06A:dM-E1an3oy8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/8lXiT-CA06A" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/8lXiT-CA06A/why-do-i-hate-gnome.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/02/why-do-i-hate-gnome.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6786577870867202493</guid><pubDate>Mon, 21 Feb 2011 07:31:00 +0000</pubDate><atom:updated>2011-02-21T00:31:03.597-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">Mandriva</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Ubuntu and I have some trust issues</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;I've been exclusively using Meego on my netbook and I was moderately happy with what it provided. So I did what any self-respecting hacker would do - I tried to make it better. Well, we all know how &lt;strong&gt;that&lt;/strong&gt; usually ends. I managed to uninstall every single kernel in the system and rendered the system unbootable. Taking this as an opportunity I decided to try a grown-up OS. Enter Ubuntu into the picture.&lt;/p&gt;  &lt;p /&gt;  &lt;div&gt;I've heard nothing but great things about Ubuntu and I fuckin' hated it. Why? Because it was stealing all the limelight from the ever superior Mandriva (my favorite distro). So I got the installation process going which was smooth but surprisingly it didn't give me the option to keep my old partition, it was an all or nothing approach (grown up OS my ass). I had all my "stuff" backed up, so I decided to repartition my disk. It even detected my Broadcom wireless card and offered to install a proprietary driver for it. Wireless was working and the visual candy was stunning. I've never seen such a beautiful font set on my computer before. All the visual components looked hand crafted and the notifications were done with style. It was just a gorgeous piece of artwork. Visually stunning (if you didn't get that part already).&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;I was quite pleased with the decision to go with Ubuntu and was having some fleeting thoughts about replacing Mandriva on my desktop. Around 15 minutes in my playful prodding and poking, I was prompted by Ubuntu to notify that Software Updates were available. After it successfully installed the updates and rebooted the computer (some Kernel updates were involved), I couldn't connect to the internet anymore. The network icon wouldn't show up on my system tray anymore. After some googling oI managed to find the "Additional Drivers" program which installed the Broadcom Drivers once again. But this time it would show me the available networks but wouldn't connect to any of them. The system update had successfully screwed over the authentication routine for connecting to WPA2 networks. I tried to plug in my network cable to the ethernet port only to find out the system hadn't recognized the existence of an ethernet port. Are you kidding me? Have you heard of a little thing called hot-plugging? I've been spoiled by Mandriva that can automatically choose between the wireless card and the network cable on the fly, depending on which was available. Now I had to muck around the network interface files to even get my ethernet card detected. How hard is it to develop a Central Control Center that can manage your hardware? After getting that to work, I tried at least 10 different methods described on various forums to get the wireless chipset to work again without any success. I gave up after 10 hours of tweaking and started trying other OSes. Here is a list:&lt;/div&gt;  &lt;div&gt;  &lt;ul&gt;  &lt;li&gt;Fedora looked nice but wouldn't connect to internet. Same problem as Ubuntu, but this time, it wouldn't offer to download proprietary drivers.&amp;nbsp;&lt;/li&gt;  &lt;li&gt;Mandriva image hangs up in the middle of booting (I'm personally&amp;nbsp;embarrassed by this). Btw, Mandriva has to be the ugliest of all the OSes. Seriously man, you gotta up the ante a little bit if you want to stay in this game.&lt;/li&gt;  &lt;li&gt;Mint OS same as Ubuntu, only it looked even more gorgeous. I might try this out in the future.&amp;nbsp;&lt;/li&gt;  &lt;/ul&gt;  &lt;/div&gt;  &lt;div&gt;I should've tried Arch Linux but I was too tired at this point. So I did what any self-respecting hacker would do..... I re-installed Ubuntu and rejected the offer to auto-update my system. Now I have wireless internet and a usable desktop that looks pretty.&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;Ubuntu had so much potential. I will always remember today as the day I almost replaced my desktop Mandriva with Ubuntu. Maybe next time.&lt;/div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=FBPFWz5B_Ro:glHw6G3hqkI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/FBPFWz5B_Ro" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/FBPFWz5B_Ro/ubuntu-and-i-have-some-trust-issues.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>4</thr:total><feedburner:origLink>http://amjith.blogspot.com/2011/02/ubuntu-and-i-have-some-trust-issues.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6109790476551752023</guid><pubDate>Sun, 19 Dec 2010 17:17:00 +0000</pubDate><atom:updated>2010-12-19T10:17:02.964-07:00</atom:updated><title>LaTeX on Mac OS X</title><description>&lt;div class='posterous_autopost'&gt;I used LaTeX when I was in school to create reports, presentation (using &lt;a href="http://en.wikipedia.org/wiki/Beamer_(LaTeX)"&gt;beamer&lt;/a&gt;) and even sometimes class notes and assignments. Recently when I was looking for a presentation program in Linux I was crestfallen by the lack of polish in OpenOffice Impress. So I created my &lt;a href="http://amjith.posterous.com/hands-on-into-git"&gt;presentation&lt;/a&gt; for the Salt Lake Linux User Group in LaTeX and it looked professional (nothing surprising there).&lt;p /&gt;&lt;div&gt;But that was created on my tiny Netbook running Meego. I wanted to make some edits to it with my wife&amp;#39;s MacBook, so I started looking around for LaTeX on Mac. I found &lt;a href="http://www.tug.org/mactex/"&gt;MacTex&lt;/a&gt; which completely took me by surprise, because the download size of the MacTex package was 1.6GB and the installed size on the computer was well over 3GB. It took me a good one hour to download, install and configure that thing her laptop. Seeing the 1.6GB zip file getting downloaded made me realize how much work has gone into LaTeX which I&amp;#39;ve been taking for granted all these years. &lt;/div&gt; &lt;p /&gt;&lt;div&gt;I bow before thee LaTeX. &lt;/div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=YMg5xSxdYXM:8QOxvOSpawo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/YMg5xSxdYXM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/YMg5xSxdYXM/latex-on-mac-os-x.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/12/latex-on-mac-os-x.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-891502708559771396</guid><pubDate>Thu, 09 Dec 2010 06:33:00 +0000</pubDate><atom:updated>2010-12-08T23:33:20.473-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">linux</category><category domain="http://www.blogger.com/atom/ns#">git</category><title>Hands on Intro - Git</title><description>&lt;div class='posterous_autopost'&gt;&lt;p&gt;Today I presented in the Salt Lake Linux User Group meeting. The topic was "Hands on Intro - Git". It went well and I actually enjoyed it quite a bit. I choked twice once while trying to explain how to git apply patches that you receive via email, but then recovered from it with some help from the audience. But the second time I choked while trying to explain how to pull from multiple remote repositories, I couldn't recover from that. I do that so rarely it never occurred to me. Oh well, the first time is the hardest.&lt;/p&gt;  &lt;p /&gt;  &lt;div&gt;Off to prepare for the talk tomorrow at the Utah Python Group. I'm presenting "Hands on Into - PyQt4".&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;Here are the slides from that talk. LaTeX Source:&amp;nbsp;&lt;a href="https://github.com/amjith/git_present"&gt;https://github.com/amjith/git_present&lt;/a&gt;&amp;nbsp;&lt;/div&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;       &lt;div style='padding: 5px 5px 10px 5px; margin-top: 5px; border: 1px solid #ddd; background-color: #fff;line-height: 16px;'&gt;       &lt;div style="float: left; margin-right: 5px; overflow: visible;"&gt;&lt;a href='http://posterous.com/getfile/files.posterous.com/amjith/q1XFctzWfhYySo8Gua1Lw7ba96PGkNrEBfjkY58dSFkTqM7gcrQXN6udAASv/git_present.pdf' style='color: #bc7134;'&gt;&lt;img src='http://posterous.com/images/filetypes/pdf.png' style='border: none;'/&gt;&lt;/a&gt;&lt;/div&gt;       &lt;div style="font-size: 10px; color: #424037;line-height: 16px;"&gt;Download now or &lt;a href='http://amjith.posterous.com/hands-on-into-git' style='color: #bc7134;'&gt;preview on posterous&lt;/a&gt;&lt;/div&gt;       &lt;b&gt;&lt;a href='http://posterous.com/getfile/files.posterous.com/amjith/q1XFctzWfhYySo8Gua1Lw7ba96PGkNrEBfjkY58dSFkTqM7gcrQXN6udAASv/git_present.pdf' style='color: #bc7134;'&gt;git_present.pdf&lt;/a&gt;&lt;/b&gt; &lt;span style="font-size: 10px; color: #424037;"&gt;(135 KB)&lt;/span&gt;       &lt;br style="clear: both;"/&gt;&lt;/div&gt;      &lt;/p&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=xZE8VbySHIs:hdU_cXvvKcc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/xZE8VbySHIs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/xZE8VbySHIs/hands-on-intro-git.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/12/hands-on-intro-git.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-5291450965400697362</guid><pubDate>Sat, 13 Nov 2010 05:10:00 +0000</pubDate><atom:updated>2010-11-12T22:55:53.483-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">ptimer</category><title>pTimer listed in Softpedia</title><description>&lt;div class='posterous_autopost'&gt;&lt;div&gt;One of my hobby projects is now included in the &lt;a href="http://mac.softpedia.com/get/Business/pTimer.shtml"&gt;Softpedia&lt;/a&gt; Mac OS database. I don't know if that means anything but it is fun to see that 9 people have downloaded that utility so far.&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;A while ago I wrote a little PyQt4 application called &lt;a href="http://code.google.com/p/ptimer/"&gt;pTimer&lt;/a&gt;&amp;nbsp;to try out the famous Pomodoro Technique for productivity.&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;The &lt;a href="http://amjith.blogspot.com/2010/09/pomodoro-timer-written-in-python-and.html"&gt;original&lt;/a&gt; reason why I wrote that timer was to get myself acclimatized to Qt programming using Python. But since I liked it so much I decided to publish the code and host it on Google Code hosting.&amp;nbsp;&lt;/div&gt;  &lt;p /&gt;  &lt;div&gt;Yesterday I got an email from Softpedia about including that utility in their website. Pleasantly surprised.&lt;/div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=AqtYUcTo36w:IRxZga4QLW4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/AqtYUcTo36w" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/AqtYUcTo36w/ptimer-listed-in-softpedia.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/11/ptimer-listed-in-softpedia.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-7744882400461682528</guid><pubDate>Sat, 06 Nov 2010 00:46:00 +0000</pubDate><atom:updated>2010-11-06T14:02:52.970-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mysql</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Moving MySQL databases to a new location</title><description>Default MySQL uses /var/lib/mysql folder to store the database files. If you'd like to change that default location to something else, you can modify the mysql config file called my.cnf located in /etc/my.cnf.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So edit /etc/my.cnf (you'll need root privileges). Lets say you want to change the default location to /home/mysql.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;WAS:&lt;/b&gt;&lt;/div&gt;&lt;pre class="prettyprint"&gt;[mysqld]&lt;br /&gt;user = mysql&lt;br /&gt;datadir = /var/lib/mysql&lt;br /&gt;&lt;span class="Apple-style-span"   style=" white-space: normal;  font-family:Georgia, serif;font-size:16px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/pre&gt;&lt;b&gt;IS:&lt;/b&gt;&lt;pre class="prettyprint"&gt;[mysqld]&lt;br /&gt;user = mysql&lt;br /&gt;datadir = /home/mysql&lt;br /&gt;&lt;/pre&gt;Create the folder /home/mysql and copy the folders that are inside /var/lib/mysql to /home/mysql.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="prettyprint"&gt;cp -r /var/lib/mysql /home/mysql&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The last and important step is to change the ownership of /home/mysql and its contents to the username mysql.&lt;/div&gt;&lt;pre class="prettyprint"&gt;chown -R mysql:mysql /home/mysql&lt;/pre&gt;&lt;div&gt;Now restart the mysqld service. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;pre class="prettyprint"&gt;service mysqld restart&lt;/pre&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;It should be ready to go and you can remove the folders from the old location /var/lib/mysql/* after you've checked to make sure everything is working properly. &lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=wScmCKY0km0:56x7V-GmaHs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/wScmCKY0km0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/wScmCKY0km0/moving-mysql-databases-to-new-location.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><thr:total>0</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/11/moving-mysql-databases-to-new-location.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-2266570949598460206</guid><pubDate>Wed, 29 Sep 2010 03:46:00 +0000</pubDate><atom:updated>2010-09-29T19:51:09.030-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PyQt4</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">ptimer</category><title>Making Standalone Application for Mac OS X from PyQt app using py2app</title><description>&lt;div style="text-align: left;"&gt;In a previous &lt;a href="http://amjith.blogspot.com/2010/09/pomodoro-timer-written-in-python-and.html"&gt;blog post&lt;/a&gt; I talked about a software I wrote in Python called &lt;a href="http://code.google.com/p/ptimer/"&gt;ptimer&lt;/a&gt;. I decided to bundle that software into a Mac OS X application that can be used without installing any dependencies. &lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;Download Link - &lt;a href="http://ptimer.googlecode.com/files/ptimer.dmg"&gt;ptimer.dmg&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;py2app is a setuptool that can convert python scripts into a standalone Mac OS X App bundle. First install py2app using easy_install. Type the following in a Terminal.&lt;/div&gt;&lt;pre class="prettyprint"&gt;$ sudo easy_install -U py2app&lt;br /&gt;&lt;/pre&gt;Next step is to create a setup.py that defines our package.&lt;/div&gt;&lt;pre class="prettyprint"&gt;from setuptools import setup&lt;br /&gt;&lt;br /&gt;APP = ['ptimer.py']&lt;br /&gt;DATA_FILES = []&lt;br /&gt;OPTIONS = {'argv_emulation': True,&lt;br /&gt; 'iconfile': 'bell.icns',&lt;br /&gt; 'includes': ['sip', 'PyQt4']}&lt;br /&gt;&lt;br /&gt;setup(&lt;br /&gt;app=APP,&lt;br /&gt;data_files=DATA_FILES,&lt;br /&gt;options={'py2app': OPTIONS},&lt;br /&gt;setup_requires=['py2app'],&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You'll notice that we included both sip and PyQt4 as dependencies, they will be bundled with the application. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The icon file for this application comes from 'bell.icns'. If your icon file is in the form of an image you can convert it to icns using the &lt;a href="http://www.img2icnsapp.com/"&gt;img2icns&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now let us create our app:&lt;/div&gt;&lt;pre class="prettyprint"&gt;$ python setup.py py2app&lt;br /&gt;&lt;/pre&gt;&lt;div&gt;This will create two folders in the current directory called 'build' and 'dist'. Inside the dist folder you'll see the Mac OS X app bundle called ptimer.app. That is the app bundle for distribution.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you double click on the ptimer.app in finder, you'll get the following error message: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_Klq-3NKFe2s/TKLEMqG1h0I/AAAAAAAABBk/89l95hhBcKQ/s1600/py2app_error.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Klq-3NKFe2s/TKLEMqG1h0I/AAAAAAAABBk/89l95hhBcKQ/s400/py2app_error.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5522191814850086722" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 202px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Lets fix that error. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Using Terminal navigate inside your app bundle and open the __boot__.py file inside the dist/ptimer.app/Contents/Resources folder.&lt;/div&gt;&lt;pre class="prettyprint"&gt;$ cd dist/ptimer.app/Contents/Resources&lt;br /&gt;$ open __boot__.py&lt;br /&gt;&lt;/pre&gt;Towards the end of the file there is a function def _run(*scripts):&lt;br /&gt;Add this line after the import statement:&lt;pre class="prettyprint lang-python"&gt;    sys.path = [os.path.join(os.environ['RESOURCEPATH'], 'lib', 'python2.6', 'lib-dynload')] + sys.path&lt;br /&gt;&lt;/pre&gt;You might have to change python2.6 to the appropriate folder name inside the dist/ptimer.app/Contents/Resources/lib folder. Double-click to make sure it is working. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Not it is time to create the .dmg file which is an apple disk image that is usually used to distribute software for Mac OS X.&lt;/div&gt;&lt;pre class="prettyprint"&gt;$ hdiutil create ptimer.dmg -srcfolder dist/ptimer.app&lt;/pre&gt;&lt;div&gt;This will create the ptimer.dmg file that is ready for distribution. Release it in the wild for everyone to enjoy.&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=d8AoAB5gpR8:gqLPp_Dbto4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/d8AoAB5gpR8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/d8AoAB5gpR8/making-standalone-application-for-mac.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_Klq-3NKFe2s/TKLEMqG1h0I/AAAAAAAABBk/89l95hhBcKQ/s72-c/py2app_error.png" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/09/making-standalone-application-for-mac.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-6485125094842474099</guid><pubDate>Mon, 27 Sep 2010 01:48:00 +0000</pubDate><atom:updated>2010-09-30T14:35:38.571-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">PyQt4</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">Mac OS X</category><title>Developing PyQt4 Applications in Mac OS X</title><description>&lt;div style="text-align: left;"&gt;PyQt4 is Python binding for the Qt library. Qt is developed by Nokia and PyQt bindings are provided by Riverbank.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;PyQt4 is available only for 32-bit Intel architecture for Mac OS X. So we have to keep that in mind while we install the various dependencies for PyQt4.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The dependencies for PyQt4 are Qt4 and SIP. &lt;/div&gt;&lt;div&gt;Use the following command for configuring SIP and PyQt4 in 32-bit mode: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class="prettyprint"&gt;python configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin --use-arch=i386&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;This link is a walk through of the installation process: &lt;a href="http://blog.oak-tree.us/index.php/2010/05/27/pyqt-snow-leopard"&gt;http://blog.oak-tree.us/index.php/2010/05/27/pyqt-snow-leopard&lt;/a&gt;.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Now that we have installed PyQt4 we are ready to start writing scripts in Python using PyQt4. &lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets check if PyQt4 is working. Type the following the Python interpreter:&lt;/div&gt;&lt;div&gt;&lt;pre class="prettyprint"&gt;&gt;&gt;&gt; import PyQt4&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;If there are no errors, then we are good.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;Since PyQt4 is installed as a 32-bit library, we have to run the Python scripts in the 32-bit mode as well.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class="prettyprint"&gt;$arch -i386 python2.6 pyqt_test.py&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Lets try it out:&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Copy the code to a file and name it pyqt_test.py&lt;/div&gt;&lt;pre class="prettyprint lang-py"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;import sys&lt;br /&gt;from PyQt4 import QtCore, QtGui&lt;br /&gt;&lt;br /&gt;class Ui_Dialog(object):&lt;br /&gt;   def setupUi(self, Dialog):&lt;br /&gt;       Dialog.setObjectName("Dialog")&lt;br /&gt;       Dialog.resize(400, 300)&lt;br /&gt;       self.pushButton = QtGui.QPushButton(Dialog)&lt;br /&gt;       self.pushButton.setGeometry(QtCore.QRect(80, 80, 271, 151))&lt;br /&gt;       self.pushButton.setObjectName("pushButton")&lt;br /&gt;       self.retranslateUi(Dialog)&lt;br /&gt;       QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL("clicked()"), Dialog.close)&lt;br /&gt;       QtCore.QMetaObject.connectSlotsByName(Dialog)&lt;br /&gt;   def retranslateUi(self, Dialog):&lt;br /&gt;       Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))&lt;br /&gt;       self.pushButton.setText(QtGui.QApplication.translate("Dialog", "Close", None, QtGui.QApplication.UnicodeUTF8))&lt;br /&gt;&lt;br /&gt;class DialogTest(QtGui.QMainWindow):&lt;br /&gt;   def __init__(self, parent=None):&lt;br /&gt;       QtGui.QWidget.__init__(self, parent)&lt;br /&gt;       self.ui =  Ui_Dialog()&lt;br /&gt;       self.ui.setupUi(self)&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;   app = QtGui.QApplication(sys.argv)&lt;br /&gt;   myapp = DialogTest()&lt;br /&gt;   myapp.show()&lt;br /&gt;   sys.exit(app.exec_())&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now try running the script:&lt;div&gt;&lt;pre class="prettyprint"&gt;$arch -i386 python2.6 pyqt_test.py&lt;/pre&gt;&lt;/div&gt;It should pop-up a dialog box with a big close button. Congratulations you are now ready to develop PyQt4 applications on your Mac OS X.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_Klq-3NKFe2s/TKAfiZxO1ZI/AAAAAAAABBI/_1aThOEKe8U/s1600/pythondialog.png"&gt;&lt;img src="http://2.bp.blogspot.com/_Klq-3NKFe2s/TKAfiZxO1ZI/AAAAAAAABBI/_1aThOEKe8U/s400/pythondialog.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5521447819049620882" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 322px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;If you use the following without the&lt;span class="Apple-style-span" style=" white-space: pre; font-family:monospace;"&gt; arch -i386&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" white-space: pre; font-family:monospace;"&gt;$python2.6 pyqt_test.py&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You will get the following error message:&lt;/div&gt;&lt;pre class="prettyprint"&gt;Traceback (most recent call last):&lt;br /&gt;File "pyqt_test.py", line 4, in &lt;module&gt;&lt;br /&gt;from PyQt4 import QtCore, QtGui&lt;br /&gt;ImportError: dlopen(/Library/Python/2.6/site-packages/PyQt4/QtCore.so, 2): no suitable image found. Did find:&lt;br /&gt;/Library/Python/2.6/site-packages/PyQt4/QtCore.so: mach-o, but wrong architecture&lt;br /&gt;&lt;/module&gt;&lt;/pre&gt;Happy Hacking!&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=rucAChU3_R0:y_sDl_0UWA4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/rucAChU3_R0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/rucAChU3_R0/developing-pyqt4-applications-in-mac-os.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_Klq-3NKFe2s/TKAfiZxO1ZI/AAAAAAAABBI/_1aThOEKe8U/s72-c/pythondialog.png" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/09/developing-pyqt4-applications-in-mac-os.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-9155439615221009783</guid><pubDate>Wed, 22 Sep 2010 03:57:00 +0000</pubDate><atom:updated>2010-09-28T22:02:11.977-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">pomodoro</category><category domain="http://www.blogger.com/atom/ns#">PyQt4</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">programming</category><category domain="http://www.blogger.com/atom/ns#">ptimer</category><title>Pomodoro Timer written in Python and Qt4</title><description>&lt;div style="text-align: left;"&gt;I recently came across the &lt;a href="http://www.pomodorotechnique.com/index.html"&gt;Pomodoro Technique&lt;/a&gt; which is a method for improving concentration and getting things done without distractions. Since my attention span rivals the lifetime of a &lt;a href="http://en.wikipedia.org/wiki/Muon"&gt;Muon&lt;/a&gt;, I jumped on the opportunity to try it out.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Pomodoro in 5 simple steps (from the website):&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Choose a task to be accomplished&lt;/li&gt;&lt;li&gt;Set the Pomodoro to 25 minutes (the Pomodoro is a timer)&lt;/li&gt;&lt;li&gt;Work on the task until the Pomodoro rings, then put a check on your sheet of paper&lt;/li&gt;&lt;li&gt;Take a short break (5 minutes is OK)&lt;/li&gt;&lt;li&gt;Every 4 Pomodoros take a longer break&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;div&gt;Since I wasn't planning on bringing my kitchen timer to work, I started to look for a software timer that can fit my needs. &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To my surprise I couldn't find a good timer that can notify me every 25 mins, followed by 5 mins and repeat the cycle. I took it as my calling to implement the perfect Pomodoro Timer and use this opportunity to learn Python and Qt.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Rest of this post is about the timer. I decided to call it '&lt;a href="http://code.google.com/p/ptimer"&gt;ptimer&lt;/a&gt;', partly because the name 'pytimer' was already taken. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Download Link: &lt;a href="http://ptimer.googlecode.com/files/ptimer-src-latest.zip"&gt;http://ptimer.googlecode.com/files/ptimer-src-latest.zip&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In order to run this timer you need to have &lt;a href="http://www.python.org/download/"&gt;python 2.6&lt;/a&gt; or above and &lt;a href="http:///www.riverbankcomputing.co.uk/software/pyqt/download"&gt;PyQt4&lt;/a&gt; installed on your system. I plan to bundle this into a single executable in the future. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;How to Use: &lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Download and unzip the &lt;a href="http://ptimer.googlecode.com/"&gt;ptimer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Launch ptimer.py&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Windows: Double click on ptimer.py&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Linux/Mac OS X: Type './ptimer.py' from Terminal&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Set the appropriate alarm times in the settings box and press Ok.&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://3.bp.blogspot.com/_Klq-3NKFe2s/TJmbys9Z1MI/AAAAAAAABAY/LSpn4y1ms-Y/s400/ptimer_settings.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5519614113683723458" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 204px; height: 167px; " /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;The ptimer will reside in the system tray.&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://1.bp.blogspot.com/_Klq-3NKFe2s/TJmcNK8xitI/AAAAAAAABAg/3Dh7bV15EWs/s400/ptimer_systray.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5519614568410745554" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 168px; height: 25px; " /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;When the timer expires it will flash a small display.&lt;a href="http://4.bp.blogspot.com/_Klq-3NKFe2s/TJmdUMg83aI/AAAAAAAABBA/mll0wsxQ1-E/s1600/ptimer_timer_display.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Klq-3NKFe2s/TJmdUMg83aI/AAAAAAAABBA/mll0wsxQ1-E/s400/ptimer_timer_display.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5519615788601630114" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 128px; height: 79px; " /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Left click to start the second alarm timer. &lt;/li&gt;&lt;li&gt;Repeat as necessary.&lt;/li&gt;&lt;li&gt;Right click on the timer display or the systray icon to control the behavior of the timer display.&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_Klq-3NKFe2s/TJmcxR77yWI/AAAAAAAABA4/COj7mFXbEcs/s1600/ptimer_timer_context.png"&gt;&lt;img src="http://4.bp.blogspot.com/_Klq-3NKFe2s/TJmcxR77yWI/AAAAAAAABA4/COj7mFXbEcs/s400/ptimer_timer_context.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5519615188761561442" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 287px; height: 176px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I plan to go over the details of the code in some of the future posts.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Until then, enjoy the ptimer!&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=0ZHhVPsJZxs:1ppCRYDtozE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/0ZHhVPsJZxs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/0ZHhVPsJZxs/pomodoro-timer-written-in-python-and.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_Klq-3NKFe2s/TJmbys9Z1MI/AAAAAAAABAY/LSpn4y1ms-Y/s72-c/ptimer_settings.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://amjith.blogspot.com/2010/09/pomodoro-timer-written-in-python-and.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9876605.post-586927743969797890</guid><pubDate>Tue, 04 Aug 2009 15:55:00 +0000</pubDate><atom:updated>2010-09-26T23:58:38.420-06:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">hiking</category><category domain="http://www.blogger.com/atom/ns#">spelunking</category><category domain="http://www.blogger.com/atom/ns#">caving</category><title>Intro to Caving in Timpanogos</title><description>Caving (or Spelunking) is the sport of exploring caves. Yosh and I recently had the opportunity to go on our first spelunking adventure. It was offered at the &lt;a href="http://www.nps.gov/tica/planyourvisit/ictour.htm"&gt;Timponogos caves&lt;/a&gt; in Utah for a group of five. It wasn't quite as dangerous and difficult as it sounds, but it was definitely more than just walking inside a cave. We donned our hard-hats with head lamps before entering the dark hole in the mountain. We were accompanied by a Ranger who knew what he was doing.&lt;div&gt;&lt;br /&gt;&lt;div&gt;We had already taken the regular tour of the cave which in retrospect was dull in comparison to the spelunking experience. The path we took had a pretty low ceiling at many spots, sometimes so low we had to crawl in all fours. At one point we had to descend down the cave through a rock-climbing rope which was exciting. The cave walls were adorned with gorgeous calcite formations. At the end of our path there was a hidden lake (more like a pond really) which had a crystal clear surface. We all turned off our head lamps at this point and experienced the total darkness for about a couple of minutes. This is the kind of darkness that our eyes never get used to. No matter how long you stay in that darkness, it is impossible to detect anything. Experiencing the absence of even a single photon was quite unnerving. It was a lot of fun and definitely worth trying. We are both planning to pursue more spelunking in the future, lets see how deep it takes us. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Picture Time:&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;a href="http://picasaweb.google.com/lh/photo/-8s2Z4YlPx6GJY4xtEi0bQ?feat=embedwebsite"&gt;&lt;img src="http://lh4.ggpht.com/_a7uv83IYef0/SoGU9_sntkI/AAAAAAAAEvQ/iK_AdI0mXho/s600/IMG_2798.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;All ready to go in&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;a href="http://picasaweb.google.com/lh/photo/hrsD8lMTCa2z4iqAo8JnUA?feat=embedwebsite"&gt;&lt;img src="http://lh6.ggpht.com/_a7uv83IYef0/SoGU9tTqm8I/AAAAAAAAEvM/YPusKokcjv8/s600/IMG_2797.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;Posing with the ranger&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;a href="http://picasaweb.google.com/lh/photo/b8gISQdKpyNmwDam5iF-Eg?feat=embedwebsite"&gt;&lt;img src="http://lh4.ggpht.com/_a7uv83IYef0/SoGU9YodkKI/AAAAAAAAEvE/GykJS_14Rys/s600/IMG_2794.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;The whole group&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/blogspot/amjith?a=7VoR6PV7fiE:TUh10ExgqIo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/blogspot/amjith?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/blogspot/amjith/~4/7VoR6PV7fiE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/blogspot/amjith/~3/7VoR6PV7fiE/intro-to-caving-in-timpanogos.html</link><author>noreply@blogger.com (Amjith Ramanujam)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_a7uv83IYef0/SoGU9_sntkI/AAAAAAAAEvQ/iK_AdI0mXho/s72-c/IMG_2798.JPG" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://amjith.blogspot.com/2009/08/intro-to-caving-in-timpanogos.html</feedburner:origLink></item></channel></rss>
