<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Life, universe, everything</title>
	<atom:link href="http://atechie.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://atechie.net</link>
	<description>and more ...</description>
	<lastBuildDate>Wed, 09 Sep 2009 12:01:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='atechie.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>poll, ping, pubsub, pubsubhub, pubsubhubbub</title>
		<link>http://atechie.net/2009/09/poll-ping-pubsub-pubsubhub-pubsubhubbub/</link>
		<comments>http://atechie.net/2009/09/poll-ping-pubsub-pubsubhub-pubsubhubbub/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 11:00:40 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[feed optimization]]></category>
		<category><![CDATA[pubsubhubbub]]></category>
		<category><![CDATA[realtime feed]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=358</guid>
		<description><![CDATA[In case you are skeptical, there is a method in the madness above, in the title of the post. In tech circles it is unlikely that you haven&#8217;t heard of pubsubhubbub. In fast few months, it has been one of the top three talked about things. Other two being homomorphic encryption and Google wave[ 1.]. [...]]]></description>
				<content:encoded><![CDATA[<p>In case you are skeptical, there is a method in the madness above, in the title of the post. In tech circles it is unlikely that you haven&#8217;t heard of pubsubhubbub. In fast few months,  it has been one of the top three talked about things. Other two being <a href="http://portal.acm.org/citation.cfm?doid=1536414.1536440"> homomorphic encryption </a> and Google <a href="http://wave.google.com/">wave</a>[ <a name="fnone" href="#fnone0">1.</a>]. Coming back to current post &#8211; terms in the title indicate how you get the contents from other people. Following details become more clear, if you imagine things happening with respect to blogs, even though they are conceptually not restricted to blogs.</p>
<p>Polling refers to the scenario where clients keep asking the server if something new has come up. How often to ask for updates will always be a problem with polling too frequent or too infrequent, but as one reader pointed out  <a href="http://code.google.com/p/pubsubhubbub/wiki/WhyPollingSucks">here</a> that one <em>great</em> , thing with polling is that server doesn&#8217;t have to maintain state.  </p>
<p>Ping refers to the case where when post an article, you(or your software) also updates some popular (central) update services. Some background <a href="http://codex.wordpress.org/Update_Services"> here</a>.</p>
<p>Next is pubsub which stands for publish/subscribe , one of the earliest pitch for it was made <a href="http://www.slideshare.net/kellan/beyond-rest"> here</a> by Evan Henshaw-Plath and Kellan Elliott-McCrea  (72 slides but worth going through). Compelling example they gave against was this &#8211; on a particular date, Friendfeed crawled Flickr 2.9 million times to get the latest photos of 45,754 users, of which 6,721 had visited Flickr in those 24  hrs and could have &#8216;potentially&#8217; uploaded a photo . Note that what they proposed  was not a new technology, as they point out &#8216;revolutionary new 20 year old technology&#8217; .  If you do it for blogs then one of the major problems with xmpp &#8211; presence data overhead, which may be as high as 60-70 % can be reduced a lot. </p>
<p>pubsubhub stands for publish subscribe hub and pubsubhubbub is a protocol , core of which is idea of pubsubhub. Wherein publishers(say bloggers) update the hub which(may be more than one hubs, which talk to each other) resides &#8216;somewhere in cloud&#8217;, as per protocol this can be push or pull as per the protocol but the next link in the chain, hub to client(say readers) it is always push model.  <a href="http://code.google.com/p/pubsubhubbub/">This</a> page is good starting point for pubsubhubbub, overview slides are good. Ever eloquent Anil Dash describes it  <a href="http://dashes.com/anil/2009/07/the-pushbutton-web-realtime-becomes-real.html"> here</a> as pushbutton web.<br />
Two other related reads are <a href="http://webhooks.pbworks.com/">webhooks</a> which is basically http callbacks. Github <a href="http://github.com/guides/post-receive-hooks">uses</a> it, so does paypal for asynchronous notifications of payment in <a href="https://www.paypal.com/ipn">ipn</a>.So do many others. Related concept is  <a href="http://rsscloud.org/">rsscloud </a>which is again pubsub hub. Follow <a href="http://rsscloud.org/walkthrough.html"> this </a>link for details.</p>
<p>You might be wondering what is the point of writing all these here, there are two 1. These things are worth knowing, minimally at least and 2.  This blog is pubsubhubbub enabled now via appspot hub using this wordpress <a href="http://wordpress.org/extend/plugins/pubsubhubbub/"> plugin</a> and feed too is pubsubhubbub enabled via feedburner, link <a href="http://adsenseforfeeds.blogspot.com/2009/07/whats-all-hubbub-about-pubsubhubbub.html"> here</a><br />
&#8211;<br />
[<a name="fnone0" href="#fnone">1</a>]. &#8211;  Good introductory read for fully homomorphic encryption is  <a href="http://www.schneier.com/blog/archives/2009/07/homomorphic_enc.html">this</a> article by Bruce Schneier and <a href="http://www.youtube.com/watch?v=v_UyVmITiYQ"> this </a> talk is more or less only source for Google wave.</p>
<p>-UPDATE &#8211;  <a href="http://grack.com/blog/2009/09/09/pubsubhubbub-to-xmpp-gateway/">This</a> post explains how the requirement of public server for callback can be worked around for desktop clients by using xmpp gateway(for pubsubhubbub).</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/09/poll-ping-pubsub-pubsubhub-pubsubhubbub/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A bit of assembly</title>
		<link>http://atechie.net/2009/08/a-bit-of-assembly/</link>
		<comments>http://atechie.net/2009/08/a-bit-of-assembly/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 17:28:54 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cas]]></category>
		<category><![CDATA[compare and swap]]></category>
		<category><![CDATA[gcd]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=349</guid>
		<description><![CDATA[After reading this article about lock free buffers and seeing the use of CAS(compare and swap), I felt like posting the assembly code to do the same. Use case over there was to write a native method and call it from Java(back in 1.5 , when concurrent data structures in Java were more or less [...]]]></description>
				<content:encoded><![CDATA[<p>After reading <a href="http://www.ddj.com/hpc-high-performance-computing/219500200"> this</a> article about lock free buffers and seeing the use of CAS(compare and swap), I felt like posting the assembly code to do the same. Use case over there was to write a native method and call it from Java(back in 1.5 , when concurrent data structures in Java were more or less non existent). Without further ado , I&#8217;ll unleash the code onto you <img src='http://atechie.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . First is for CAS and second is for computing GCD using Euclid&#8217;s algorithm(this one can be found in many places and tutorials as well).</p>
<p><em>Compile and run instructions</em> <code> gcc file_name.c ; ./a.out </code></p>
<p><strong>Compare and Swap</strong></p>
<pre name="code" class="c">
  #include <stdio.h>
 #include <stdlib.h>
//exchange - newvalue, comperand is old/expected value
/*
 * Function actually does the following thing - if the value at *dest is equal to oldvalue then replace it by newvalue else leave it unchanged : do all these atomically
 *
 * There are two options for return value
 *  1.is initial value of *dest and leave the burden of calling fxn to compare it with oldval
 *  2. do it over here and return 0 or 1, this should be more efficient
 * */

/* later change it into macro  */
int cas(int* dest, int oldvalue, int newvalue){
	printf("(%d,%d,%d)",*dest,oldvalue,newvalue);
	/* int cas(int dest, int oldvalue, int newvalue){ */
	/* int cas(int dest, int newvalue, int oldvalue){ */
	int result= 1;/* 1 shows that cas succeeded and 0 shows that it failed  */
	/* btw need to set cc for flag clobbering !  */
	__asm__ __volatile__(
			"movl %2, %%eax\n\t"
			"movl %3, %%ebx\n\t"
			"movl %0, %%ecx\n\t"
			"LOCK\n\t"
			"CMPXCHG %%ebx, (%%ecx)\n\t"  /* should LOCK be on the same line  */
			"jz DONE\n\t"
			"movl $0, %1\n\t "
			"DONE: \n\t"
			:"=m"(dest),"=g"(result)
			:"g" (oldvalue),"g" (newvalue),"m"(dest)
			:"%eax","%ebx","ecx","cc"
			);
	printf("(%d,%d,%d)",*dest,oldvalue,newvalue);
	return result; 
}


/* TODO
 * write another asm fxn which puts above fxn in a while loop and keep trying unless it succeeds*/

int main(){
	int a= 5,b= 6;
	int* c = (int*) malloc(sizeof(int));
	*c= 6;
	/* int c= 6; */
	printf("%d\n",cas(c,b,b));
	printf("%d\n",cas(c,b,a));
	printf("%d\n",cas(c,a,a));
	printf("%d\n",cas(c,b,b));
	*c= 6;
	/* c= 5; */
	printf("changing value of *c to %d\n",*c);
	printf("%d\n",cas(c,b,b));
	printf("%d\n",cas(c,b,a));
	printf("%d\n",cas(c,a,a));
	printf("%d\n",cas(c,a,b));
	printf("%d\n",cas(c,b,a));
	return 0;
}
</pre>
<p>Formatting notes &#8211; seems like wp syntax highlighter is adding </stdio.h> in the end , ignore that.</p>
<p><strong>GCD</strong></p>
<pre name="code" class="c">
#include <stdio.h>
int gcd( int a, int b ) {
    int result ;
    /* Compute Greatest Common Divisor using Euclid's Algorithm */
    __asm__ __volatile__ ( "movl %1, %%eax;"
                          "movl %2, %%ebx;"
                          "CONTD: cmpl $0, %%ebx;"
                          "je DONE;"
                          "xorl %%edx, %%edx;"
                          "idivl %%ebx;"
                          "movl %%ebx, %%eax;"
                          "movl %%edx, %%ebx;"
                          "jmp CONTD;"
                          "DONE: movl %%eax, %0;" : "=g" (result) : "g" (a), "g" (b)
    );

    return result ;
}

int main() {
    int first, second ;
    printf( "Enter two integers : " ) ;
    scanf( "%d%d", &amp;first, &amp;second );

    printf( "GCD of %d &amp; %d is %d\n", first, second, gcd(first, second) ) ;

    return 0 ;
}

</pre>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/08/a-bit-of-assembly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cricketing World Awaits a New World Order</title>
		<link>http://atechie.net/2009/08/ricketing-world-awaits-a-new-world-order/</link>
		<comments>http://atechie.net/2009/08/ricketing-world-awaits-a-new-world-order/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 18:07:50 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[cricket]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=329</guid>
		<description><![CDATA[After a series spanning  five tests and approximately two months, England  reclaimed ashes. Let&#8217;s talk about the  winning  team first  &#8211; their middle order is &#8216;average&#8217; if you don&#8217;t want to critical . Greame Swann&#8217;s contribution with the bat will count no less than contribution with the ball. Stuart Broad &#8211; best all rounder was [...]]]></description>
				<content:encoded><![CDATA[<p>After a series spanning  five tests and approximately two months, England  reclaimed ashes.</p>
<p>Let&#8217;s talk about the  winning  team first  &#8211; their middle order is &#8216;average&#8217; if you don&#8217;t want to critical . Greame Swann&#8217;s contribution with the bat will count no less than contribution with the ball. Stuart Broad &#8211; best all rounder was non starter for the 5th test. Andrew Strauss was the only consistent batsman and Jimmy Anderson was the only consistent bowler.</p>
<p>Point here is not to berate the achievements of the winning team but to put in perspective the fact that despite all these, Australia lost. you&#8217;ll have to think for few seconds , if asked to name their best bowler.  Right, it was BW Hilfenhaus. Hauritz outperformed everbody&#8217;s expectation but was still not good enough to be selected for two of the five tests.  South Africa never became a world beater without a world class spinner , Australia can&#8217;t hope to remain one without one good enough one at least. Magician left the stage and it doesn&#8217;t look like art anymore, forget magic. Ponting stands tall among lesser mortals and Michael Clarke stands up very often, but that makes them a team with some very good players and not a very good team.<br />
Ashes 2009 will be remembered for Andrew Flintoff&#8217;s last Ashes, Stuart Broad&#8217;s arrival as an all rounder(if he adds some more Ashes folklore to his promising  start), and one of the most telling debut century of all time by Trott but it will also be remembered as the point where ifs and buts about Australia&#8217;s supremacy were finally put to rest, it is over. Don&#8217;t get me wrong they can still unearth Mike Hussey or Stuart Clark but you feel the contribution of  all time greats when they go missing. Sometimes they come to remind you of themselves in IPL but still they can not be replaced. Let&#8217;s feel blessed for having seen Warne, McGrath and Gilchrist playing together and being supported by Waughs, Ponting, Hyden , Martin and Langer.</p>
<p>Going forward, South Africa will always remain a very good team but they need to win semifinals and be more consistent around the globe, Pakistan will remain enigmatically brilliant, Indian young guns will probably find it tough to fill the shoes of extraordinary predecessors. Sri Lanka should continue to show glimpses of art in craft. But, we may have to wait for sometime before having an all out dominant team or before a captain complains of lack of competition, as Steve Waugh did once.</p>
<p>On a related note &#8211; let&#8217;s welcome the coming back of Asif , he has a hell lot of potential, let&#8217;s hope to see some of that and also welcome Andy Flower in the new awatar, right you can&#8217;t keep good men down for long.</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/08/ricketing-world-awaits-a-new-world-order/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ruby one liners to create hash</title>
		<link>http://atechie.net/2009/08/ruby-one-liners-to-create-hash/</link>
		<comments>http://atechie.net/2009/08/ruby-one-liners-to-create-hash/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 15:45:54 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[group_by]]></category>
		<category><![CDATA[inject]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=281</guid>
		<description><![CDATA[Yesterday while going through one of my old programs, I found this written by me sometime back : #begin magic hash=Hash[*CGI.unescape(raw_text).split('&#38;').map{&#124;x&#124; b=x.split("=");b.push(nil) if b.size==1;b}.flatten] #end magic To kill some of suspense let me disclose that raw_text looks like "SUCCESS&#38;mc_gross=10.00&#38;protection_eligibility=Ineligible&#38;payer_id=U7PPJJ4TSJ47E&#38;tax=0.00&#38;payment_date=09%3A45%3A30+Jul+10%2C+2009+PDT&#38;payment_status=Pending" , right it has been cut from paypal payment acknowledgment. Above line if broken in parts [...]]]></description>
				<content:encoded><![CDATA[<p>Yesterday while going through one of my old programs, I found this written  by me sometime back :<br />
<code><br />
#begin magic<br />
hash=Hash[*CGI.unescape(raw_text).split('&amp;').map{|x| b=x.split("=");b.push(nil) if b.size==1;b}.flatten]<br />
#end magic<br />
</code><br />
To kill some of suspense let me disclose that raw_text looks like</p>
<pre name="code" class="ruby">"SUCCESS&amp;mc_gross=10.00&amp;protection_eligibility=Ineligible&amp;payer_id=U7PPJJ4TSJ47E&amp;tax=0.00&amp;payment_date=09%3A45%3A30+Jul+10%2C+2009+PDT&amp;payment_status=Pending"</pre>
<p>, right it has been cut from paypal payment acknowledgment.</p>
<p>Above line if broken in parts reads better :</p>
<pre name="code" class="ruby">  unescaped_array= CGI.unescape(raw_text).split('&amp;')
  unescaped_array= unescaped_array.collect{|x| b=x.split("=");b.push(nil) if b.size==1;b}
  flattened_array= unescaped_array.flatten
  hash= Hash[*flattened_array]</pre>
<p>Let&#8217;s do individual steps in irb:</p>
<pre name="code" class="ruby">irb(main):009:0&gt;unescaped_array= CGI.unescape(raw_text).split('&amp;')    

=&gt; ["SUCCESS", "mc_gross=10.00", "protection_eligibility=Ineligible", "payer_id=U7PPJJ4TSJ47E", "tax=0.00", "payment_date=09:45:30 Jul 10, 2009 PDT", "payment_status=Pending"]                                                                         

irb(main):013:0&gt; unescaped_array= unescaped_array.map{|x| b=x.split("=");b.push(nil) if b.size==1;b}  

=&gt; [["SUCCESS", nil], ["mc_gross", "10.00"],["protection_eligibility", "Ineligible"], ["payer_id", "U7PPJJ4TSJ47E"], ["tax", "0.00"], ["payment_date", "09:45:30 Jul 10, 2009 PDT"], ["payment_status", "Pending"]]                               

irb(main):014:0&gt; flattened_array= unescaped_array.flatten     

=&gt; ["SUCCESS", nil, "mc_gross", "10.00", "protection_eligibility", "Ineligible", "payer_id", "U7PPJJ4TSJ47E", "tax", "0.00", "payment_date", "09:45:30 Jul 10, 2009 PDT", "payment_status", "Pending"]
irb(main):015:0&gt;
hash= Hash[*flattened_array]
=&gt; {"tax"=&gt;"0.00", "payment_status"=&gt;"Pending", "payer_id"=&gt;"U7PPJJ4TSJ47E", "mc_gross"=&gt;"10.00", "SUCCESS"=&gt;nil, "payment_date"=&gt;"09:45:30 Jul 10, 2009 PDT", "protection_eligibility"=&gt;"Ineligible"}</pre>
<p>BTW, * is called splat operator in ruby</p>
<p>Another way to create hash from &#8216;array of pairs &#8216; is to use inject :</p>
<pre name="code" class="ruby">hash= [[1,2],[3,4]].inject({}){|result,element| result[element.first]= result[element.last]; result}</pre>
<p>There is one more way <img src='http://atechie.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Write a loop, that I&#8217;ll leave as an exercise to the readers !!</p>
<p>Here is a bit unrelated use case of creating hash from arrays:</p>
<pre name="code" class="ruby">irb(main):005:0&gt; [1,2,3,4,7,9].group_by{|x| x&lt;5 ? :lesser : :greater}

=&gt; {:lesser=&gt;[1, 2, 3, 4], :greater=&gt;[7, 9]}</pre>
<p>You can do more things, basically result of the block is used as the key for that element in the resulting hash.</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/08/ruby-one-liners-to-create-hash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gmail, mutt and msmtp fix</title>
		<link>http://atechie.net/2009/08/gmail-mutt-and-msmtp-fix/</link>
		<comments>http://atechie.net/2009/08/gmail-mutt-and-msmtp-fix/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 19:33:29 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[msmtp]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[tls]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=308</guid>
		<description><![CDATA[If you use mutt and smtp to access gmail . Here is a (bad) news. Cool guys at Google again changed certificate. Oh, did you ask &#8211; how do it know it ? Simple mutt started complaining about bad certificate when trying to use msmpt, infamous &#8216;msmtp: TLS certificate verification failed: the certificate hasn&#8217;t got [...]]]></description>
				<content:encoded><![CDATA[<p>If you use mutt and smtp to access gmail . Here is a (bad) news. Cool guys at Google again changed certificate. Oh, did you ask &#8211; how do it know it ? Simple mutt started complaining about bad certificate when trying to use msmpt, infamous &#8216;msmtp: TLS certificate verification failed: the certificate hasn&#8217;t got a known issuer.&#8217; greeted me on the screen. </p>
<p>To cross confirm &#8211;<br />
Just run following<br />
<code><br />
$ msmtp --serverinfo --host=smtp.gmail.com --tls=on --port=587        --tls-certcheck=off<br />
</code><br />
In place of old Thwate Server now you get following in issuer segment<br />
<code>Issuer:<br />
        Common Name: Google Internet Authority<br />
        Organization: Google Inc<br />
        Country: US<br />
</code></p>
<p>Fortunately fix is simple, here is what you need to do on debian<br />
<code><br />
# apt-get install  ca-certificates<br />
# dpkg -s ca-certificates|grep Version<br />
Version: 20090814<br />
<code></p>
<p>After this just change following line in you ~/.msmtprc<br />
<code><br />
tls_trust_file <YOUR_PATH>/certs/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem<br />
</code><br />
to<br />
<code><br />
 tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/08/gmail-mutt-and-msmtp-fix/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Git and Awesome Survey</title>
		<link>http://atechie.net/2009/08/git-and-awesome-survey/</link>
		<comments>http://atechie.net/2009/08/git-and-awesome-survey/#comments</comments>
		<pubDate>Sat, 15 Aug 2009 06:00:45 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=304</guid>
		<description><![CDATA[Here are two links for survey by git (version control system) and awesome(window manager) community. If you use either of these, please take out some time to fill in the questionnaire. Think of it as the simplest way to contribute back to the software you use. Here are the links : Git &#8211; http://www.survs.com/survey?id=2PIMZGU0&#038;channel=Q0EKJ3NF54 Awesome [...]]]></description>
				<content:encoded><![CDATA[<p>Here are two links for survey by  git (version control system) and awesome(window manager) community.  If you use either of these, please take out some time to fill in the questionnaire. Think of it as the simplest way to contribute back to the software you use.<br />
Here are the links :</p>
<p>Git &#8211; <a href="http://www.survs.com/survey?id=2PIMZGU0&#038;channel=Q0EKJ3NF54">http://www.survs.com/survey?id=2PIMZGU0&#038;channel=Q0EKJ3NF54</a></p>
<p>Awesome &#8211; <a href="http://www.survs.com/survey?id=8BVEV3FO&#038;channel=BH07CQ040D">http://www.survs.com/survey?id=8BVEV3FO&#038;channel=BH07CQ040D</a></p>
<p>Note -(As found on those pages but at the bottom <img src='http://atechie.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) &#8211;<br />
 &#8220;If you have cookies enabled, you can always submit partially filled survey, and return to your answers at later time, completing it later.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/08/git-and-awesome-survey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Merging hashes in yaml conf files</title>
		<link>http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/</link>
		<comments>http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:12:22 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=282</guid>
		<description><![CDATA[YAML is quite handy for writing configuration files. Primary advantage is that, it reads like text file. This works really well if your config file is flat(no hierarchy) and has no repetitions. If your configurations file has repetitions then it makes sense to separate out those elements and reuse them. What I mean is this [...]]]></description>
				<content:encoded><![CDATA[<p>YAML is  quite handy for writing configuration files. Primary advantage is that, it reads like text file. This works really well if your config file is flat(no hierarchy) and has no repetitions.<br />
If your configurations file has repetitions then it makes sense to separate out those elements and reuse them. What I mean is this &#8211; let&#8217;s say you your config file looks like this :</p>
<p><code> </code></p>
<pre>development:
  input_location: common_input
  output_location: dev_location
  mail:
    smtp_server: your_server
    login: your_login
    password: top_secret
production:
  input_location: common_input
  output_location: dev_location
  mail:
    smtp_server: your_server
    login: your_login
    password: top_secret</pre>
<p>Assuming above code in /tmp/test.yml here is how you can read in python and ruby<br />
<code>$cat readyml.py </code></p>
<pre name="code" class="python">
#!/usr/bin/env python
from pprint import pprint as pp
#in debian need to install python-yaml
from yaml import load,load_all,dump
hash= load(open('/tmp/test.yml'))
pp(hash['development'])</pre>
<p><code><br />
$ cat readyml.rb<br />
</code></p>
<pre name="code" class="ruby">#!/usr/bin/env ruby
require 'pp'
hash= YAML::load(File.open('/tmp/test.yml').read)
pp hash['development']</pre>
<p>here is a handy one liner for ruby version<br />
<code>$ ruby  -rpp -e   'pp YAML::load(File.open("/tmp/a.yml"))["development"]' </code> or you can try the same in irb or python console.</p>
<p>Note that in the above code snippet ,everything is other than output location is same in development and production part.  This  is where yml node identifier comes to rescue. Idea is simple have a set of default values and override them at different place.<br />
You could pull it apart as follows:<br />
<code> </code></p>
<pre>defaults: &amp;defaults
  input_location: common_input
  output_location: dev_location
  mail:
    sender_name: sender
    smtp_server: your_server
    login: your_login
    password: top_secret
development:
  &lt;&lt;: *defaults
production:
  &lt;&lt;: *defaults
  output_location: prod_location</pre>
<p><code><br />
$ ruby  -rpp -e   'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'<br />
"your_login"<br />
$<br />
</code><br />
Great , it works(tm) !.<br />
Arguably we traded some clarity for a bit of magic. Here is a small explanation : &amp; , * and &lt;&lt;:  &amp; which is  anchor tag can be understood as node identifier, * is node reference and &lt;&lt;: stands for hash merge.</p>
<p>For more details see either <a href="http://www.yaml.org/spec/current.html">yaml specs</a> or <a href="http://en.wikipedia.org/wiki/YAML">wikipedia</a><br />
So far so good but there is a catch here, these hash merges are not recursive. What it means is this : let&#8217;s say you want to have different sender name for mail in two environments, you may be tempted to do the following:<br />
<code> </code></p>
<pre>defaults: &amp;defaults
  input_location: common_input
  output_location: dev_location
  mail:
    sender_name: sender
    smtp_server: your_server
    login: your_login
    password: top_secret
development:
  &lt;&lt;: *defaults
  mail:
    sender_name: sender_dev
production:
  &lt;&lt;: *defaults
  output_location: prod_location
  mail:
    sender_name: sender_prod</pre>
<p>Lets check<br />
<code><br />
$ ruby  -rpp -e   'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'<br />
nil<br />
$<br />
</code></p>
<p>Oops, something went wrong, problem as mentioned above is that the hash merge is not recursive and while merging it replaced mail of default by mail of production which has only one key. Solution/work around is to unroll one more level:<br />
<code> </code></p>
<pre>common_settings: &amp;common_settings
input_location: common_input
output_location: dev_location
mail_defaults: &amp;mail_defaults
  sender_name: sender
  smtp_server: your_server
  login: your_login
  password: top_secret

defaults: &amp;defaults
  &lt;&lt;: *common_settings
  mail:
    &lt;&lt;: *mail_defaults
development:
  &lt;&lt;: *defaults
production:
  &lt;&lt;: *defaults
  mail:
    &lt;&lt;: *mail_defaults
    sender_name: sender_prod
</pre>
<p>Lets check again<br />
<code><br />
$ ruby  -rpp -e   'pp YAML::load(File.open("/tmp/a.yml"))["development"]["mail"]["login"]'<br />
"your_login"<br />
$<br />
</code><br />
Did you say you have one more level of nesting, well you can definitely unroll one more level, but then it becomes a mess. So, if you are not trying to write solution to towers of hanoi in a conf file, it is better to restucture conf file than digging into yaml or something else. But that is your call anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Great programmers find simple solutions to complex problems</title>
		<link>http://atechie.net/2009/06/great-programmers-find-simple-solutions-to-complex-problems/</link>
		<comments>http://atechie.net/2009/06/great-programmers-find-simple-solutions-to-complex-problems/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 11:46:53 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[misc]]></category>
		<category><![CDATA[essays]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=266</guid>
		<description><![CDATA[After a long time I could find the source for following quote- Junior programmers create simple solutions to simple problems. Senior programmers create complex solutions to complex problems. Great programmers find simple solutions to complex problems. It is from an essay called Beautiful Software by Charles Connell. Another favorite one of mine is The Zen [...]]]></description>
				<content:encoded><![CDATA[<p>After a long time I could find the source for following quote-</p>
<blockquote><p>Junior programmers create simple solutions to simple problems. Senior programmers create complex solutions to complex problems. Great programmers find simple solutions to complex problems.</p></blockquote>
<p>It is from an essay called <a href="http://www.chc-3.com/pub/beautifulsoftware_v10.htm"> Beautiful Software</a> by Charles Connell.</p>
<p>Another favorite one of mine is <a href="http://www.python.org/dev/peps/pep-0020/">The Zen of Python</a> -</p>
<p>Beautiful is better than ugly.<br />
Explicit is better than implicit.<br />
Simple is better than complex.<br />
Complex is better than complicated.<br />
Flat is better than nested.<br />
Sparse is better than dense.<br />
Readability counts.<br />
Special cases aren&#8217;t special enough to break the rules.<br />
Although practicality beats purity.<br />
Errors should never pass silently.<br />
Unless explicitly silenced.<br />
In the face of ambiguity, refuse the temptation to guess.<br />
There should be one&#8211; and preferably only one &#8211;obvious way to do it.<br />
Although that way may not be obvious at first unless you&#8217;re Dutch.<br />
Now is better than never.<br />
Although never is often better than *right* now.<br />
If the implementation is hard to explain, it&#8217;s a bad idea.<br />
If the implementation is easy to explain, it may be a good idea.<br />
Namespaces are one honking great idea &#8212; let&#8217;s do more of those!<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
and then there is classic <a href="http://www.canonical.org/~kragen/tao-of-programming.html">Tao of Programming </a></p>
<p>&#8212;</p>
<p>credits as on the linked site-</p>
<p>Translated by Geoffrey James</p>
<p>Transcribed by Duke Hillard</p>
<p>Transmitted by Anupam Trivedi, Sajitha Tampi, and Meghshyam Jagannath</p>
<p>Re-html-ized and edited by Kragen Sittler</p>
<p>&#8212;-</p>
<blockquote><p>
Book 1 &#8211; The Silent Void</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;When you have learned to snatch the error code from the trap frame, it<br />
will be time for you to leave.&#8221;</p>
<p>1.1</p>
<p>Something mysterious is formed, born in the silent void. Waiting alone and<br />
unmoving, it is at once still and yet in constant motion. It is the source<br />
of all programs. I do not know its name, so I will call it the Tao of<br />
Programming.</p>
<p>If the Tao is great, then the operating system is great. If the operating<br />
system is great, then the compiler is great. If the compiler is great,<br />
then the application is great. The user is pleased and there exists<br />
harmony in the world.</p>
<p>The Tao of Programming flows far away and returns on the wind of morning.</p>
<p>1.2</p>
<p>The Tao gave birth to machine language. Machine language gave birth to the<br />
assembler.</p>
<p>The assembler gave birth to the compiler. Now there are ten thousand<br />
languages.</p>
<p>Each language has its purpose, however humble. Each language expresses the<br />
Yin and Yang of software. Each language has its place within the Tao.</p>
<p>But do not program in COBOL if you can avoid it.</p>
<p>1.3</p>
<p>In the beginning was the Tao. The Tao gave birth to Space and Time.<br />
Therefore Space and Time are Yin and Yang of programming.</p>
<p>Programmers that do not comprehend the Tao are always running out of time<br />
and space for their programs. Programmers that comprehend the Tao always<br />
have enough time and space to accomplish their goals.</p>
<p>How could it be otherwise?</p>
<p>1.4</p>
<p>The wise programmer is told about Tao and follows it. The average<br />
programmer is told about Tao and searches for it. The foolish programmer<br />
is told about Tao and laughs at it.</p>
<p>If it were not for laughter, there would be no Tao.</p>
<p>The highest sounds are hardest to hear.<br />
Going forward is a way to retreat.<br />
Great talent shows itself late in life.<br />
Even a perfect program still has bugs.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 2 &#8211; The Ancient Masters</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;After three days without programming, life becomes meaningless.&#8221;</p>
<p>2.1</p>
<p>The programmers of old were mysterious and profound. We cannot fathom<br />
their thoughts, so all we do is describe their appearance.</p>
<p>Aware, like a fox crossing the water. Alert, like a general on the<br />
battlefield. Kind, like a hostess greeting her guests. Simple, like<br />
uncarved blocks of wood. Opaque, like black pools in darkened caves.</p>
<p>Who can tell the secrets of their hearts and minds?</p>
<p>The answer exists only in Tao.</p>
<p>2.2</p>
<p>Grand Master Turing once dreamed that he was a machine. When he awoke he<br />
exclaimed:</p>
<p>&#8220;I don&#8217;t know whether I am Turing dreaming that I am a machine, or a<br />
machine dreaming that I am Turing!&#8221;</p>
<p>2.3</p>
<p>A programmer from a very large computer company went to a software<br />
conference and then returned to report to his manager, saying: &#8220;What sort<br />
of programmers work for other companies? They behaved badly and were<br />
unconcerned with appearances. Their hair was long and unkempt and their<br />
clothes were wrinkled and old. They crashed our hospitality suite and they<br />
made rude noises during my presentation.&#8221;</p>
<p>The manager said: &#8220;I should have never sent you to the conference. Those<br />
programmers live beyond the physical world. They consider life absurd, an<br />
accidental coincidence. They come and go without knowing limitations.<br />
Without a care, they live only for their programs. Why should they bother<br />
with social conventions?</p>
<p>&#8220;They are alive within the Tao.&#8221;</p>
<p>2.4</p>
<p>A novice asked the Master: &#8220;Here is a programmer that never designs,<br />
documents or tests his programs. Yet all who know him consider him one of<br />
the best programmers in the world. Why is this?&#8221;</p>
<p>The Master replies: &#8220;That programmer has mastered the Tao. He has gone<br />
beyond the need for design; he does not become angry when the system<br />
crashes, but accepts the universe without concern. He has gone beyond the<br />
need for documentation; he no longer cares if anyone else sees his code.<br />
He has gone beyond the need for testing; each of his programs are perfect<br />
within themselves, serene and elegant, their purpose self-evident. Truly,<br />
he has entered the mystery of Tao.&#8221;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 3 &#8211; Design</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;When the program is being tested, it is too late to make design<br />
changes.&#8221;</p>
<p>3.1</p>
<p>There once was a man who went to a computer trade show. Each day as he<br />
entered, the man told the guard at the door:</p>
<p>&#8220;I am a great thief, renowned for my feats of shoplifting. Be<br />
forewarned, for this trade show shall not escape unplundered.&#8221;</p>
<p>This speech disturbed the guard greatly, because there were millions of<br />
dollars of computer equipment inside, so he watched the man carefully. But<br />
the man merely wandered from booth to booth, humming quietly to himself.</p>
<p>When the man left, the guard took him aside and searched his clothes, but<br />
nothing was to be found.</p>
<p>On the next day of the trade show, the man returned and chided the guard<br />
saying: &#8220;I escaped with a vast booty yesterday, but today will be even<br />
better.&#8221; So the guard watched him ever more closely, but to no avail.</p>
<p>On the final day of the trade show, the guard could restrain his curiosity<br />
no longer. &#8220;Sir Thief,&#8221; he said, &#8220;I am so perplexed, I cannot live in<br />
peace. Please enlighten me. What is it that you are stealing?&#8221;</p>
<p>The man smiled. &#8220;I am stealing ideas,&#8221; he said.</p>
<p>3.2</p>
<p>There once was a master programmer who wrote unstructured programs. A<br />
novice programmer, seeking to imitate him, also began to write<br />
unstructured programs. When the novice asked the master to evaluate his<br />
progress, the master criticized him for writing unstructured programs,<br />
saying, &#8220;What is appropriate for the master is not appropriate for the<br />
novice. You must understand the Tao before transcending structure.&#8221;</p>
<p>3.3</p>
<p>There was once a programmer who was attached to the court of the warlord<br />
of Wu. The warlord asked the programmer: &#8220;Which is easier to design: an<br />
accounting package or an operating system?&#8221;</p>
<p>&#8220;An operating system,&#8221; replied the programmer.</p>
<p>The warlord uttered an exclamation of disbelief. &#8220;Surely an accounting<br />
package is trivial next to the complexity of an operating system,&#8221; he<br />
said.</p>
<p>&#8220;Not so,&#8221; said the programmer, &#8220;when designing an accounting package,<br />
the programmer operates as a mediator between people having different<br />
ideas: how it must operate, how its reports must appear, and how it must<br />
conform to the tax laws. By contrast, an operating system is not limited<br />
by outside appearances. When designing an operating system, the programmer<br />
seeks the simplest harmony between machine and ideas. This is why an<br />
operating system is easier to design.&#8221;</p>
<p>The warlord of Wu nodded and smiled. &#8220;That is all good and well, but<br />
which is easier to debug?&#8221;</p>
<p>The programmer made no reply.</p>
<p>3.4</p>
<p>A manager went to the master programmer and showed him the requirements<br />
document for a new application. The manager asked the master: &#8220;How long<br />
will it take to design this system if I assign five programmers to it?&#8221;</p>
<p>&#8220;It will take one year,&#8221; said the master promptly.</p>
<p>&#8220;But we need this system immediately or even sooner! How long will it<br />
take if I assign ten programmers to it?&#8221;</p>
<p>The master programmer frowned. &#8220;In that case, it will take two years.&#8221;</p>
<p>&#8220;And what if I assign a hundred programmers to it?&#8221;</p>
<p>The master programmer shrugged. &#8220;Then the design will never be<br />
completed,&#8221; he said.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 4 &#8211; Coding</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;A well-written program is its own heaven; a poorly-written program is<br />
its own hell.&#8221;</p>
<p>4.1</p>
<p>A program should be light and agile, its subroutines connected like a<br />
string of pearls. The spirit and intent of the program should be retained<br />
throughout. There should be neither too little or too much, neither<br />
needless loops nor useless variables, neither lack of structure nor<br />
overwhelming rigidity.</p>
<p>A program should follow the `Law of Least Astonishment&#8217;. What is this law?<br />
It is simply that the program should always respond to the user in the way<br />
that astonishes him least.</p>
<p>A program, no matter how complex, should act as a single unit. The program<br />
should be directed by the logic within rather than by outward appearances.</p>
<p>If the program fails in these requirements, it will be in a state of<br />
disorder and confusion. The only way to correct this is to rewrite the<br />
program.</p>
<p>4.2</p>
<p>A novice asked the master: &#8220;I have a program that sometime runs and<br />
sometimes aborts. I have followed the rules of programming, yet I am<br />
totally baffled. What is the reason for this?&#8221;</p>
<p>The master replied: &#8220;You are confused because you do not understand Tao.<br />
Only a fool expects rational behavior from his fellow humans. Why do you<br />
expect it from a machine that humans have constructed? Computers simulate<br />
determinism; only Tao is perfect.</p>
<p>&#8220;The rules of programming are transitory; only Tao is eternal. Therefore<br />
you must contemplate Tao before you receive enlightenment.&#8221;</p>
<p>&#8220;But how will I know when I have received enlightenment?&#8221; asked the<br />
novice.</p>
<p>&#8220;Your program will then run correctly,&#8221; replied the master.</p>
<p>4.3</p>
<p>A master was explaining the nature of Tao of to one of his novices. &#8220;The<br />
Tao is embodied in all software &#8211; regardless of how insignificant,&#8221; said<br />
the master.</p>
<p>&#8220;Is the Tao in a hand-held calculator?&#8221; asked the novice.</p>
<p>&#8220;It is,&#8221; came the reply.</p>
<p>&#8220;Is the Tao in a video game?&#8221; continued the novice.</p>
<p>&#8220;It is even in a video game,&#8221; said the master.</p>
<p>&#8220;And is the Tao in the DOS for a personal computer?&#8221;</p>
<p>The master coughed and shifted his position slightly. &#8220;The lesson is over<br />
for today,&#8221; he said.</p>
<p>4.4</p>
<p>Prince Wang&#8217;s programmer was coding software. His fingers danced upon the<br />
keyboard. The program compiled without an error message, and the program<br />
ran like a gentle wind.</p>
<p>&#8220;Excellent!&#8221; the Prince exclaimed, &#8220;Your technique is faultless!&#8221;</p>
<p>&#8220;Technique?&#8221; said the programmer turning from his terminal, &#8220;What I<br />
follow is Tao &#8211; beyond all techniques! When I first began to program I<br />
would see before me the whole problem in one mass. After three years I no<br />
longer saw this mass. Instead, I used subroutines. But now I see nothing.<br />
My whole being exists in a formless void. My senses are idle. My spirit,<br />
free to work without plan, follows its own instinct. In short, my program<br />
writes itself. True, sometimes there are difficult problems. I see them<br />
coming, I slow down, I watch silently. Then I change a single line of code<br />
and the difficulties vanish like puffs of idle smoke. I then compile the<br />
program. I sit still and let the joy of the work fill my being. I close my<br />
eyes for a moment and then log off.&#8221;</p>
<p>Prince Wang said, &#8220;Would that all of my programmers were as wise!&#8221;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 5 &#8211; Maintenance</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;Though a program be but three lines long, someday it will have to be<br />
maintained.&#8221;</p>
<p>5.1</p>
<p>A well-used door needs no oil on its hinges.<br />
A swift-flowing stream does not grow stagnant.<br />
Neither sound nor thoughts can travel through a vacuum.<br />
Software rots if not used.</p>
<p>These are great mysteries.</p>
<p>5.2</p>
<p>A manager asked a programmer how long it would take him to finish the<br />
program on which he was working. &#8220;It will be finished tomorrow,&#8221; the<br />
programmer promptly replied.</p>
<p>&#8220;I think you are being unrealistic,&#8221; said the manager, &#8220;Truthfully, how<br />
long will it take?&#8221;</p>
<p>The programmer thought for a moment. &#8220;I have some features that I wish to<br />
add. This will take at least two weeks,&#8221; he finally said.</p>
<p>&#8220;Even that is too much to expect,&#8221; insisted the manager, &#8220;I will be<br />
satisfied if you simply tell me when the program is complete.&#8221;</p>
<p>The programmer agreed to this.</p>
<p>Several years later, the manager retired. On the way to his retirement<br />
luncheon, he discovered the programmer asleep at his terminal. He had been<br />
programming all night.</p>
<p>5.3</p>
<p>A novice programmer was once assigned to code a simple financial package.</p>
<p>The novice worked furiously for many days, but when his master reviewed<br />
his program, he discovered that it contained a screen editor, a set of<br />
generalized graphics routines, an artificial intelligence interface, but<br />
not the slightest mention of anything financial.</p>
<p>When the master asked about this, the novice became indignant. &#8220;Don&#8217;t be<br />
so impatient,&#8221; he said, &#8220;I&#8217;ll put in the financial stuff eventually.&#8221;</p>
<p>5.4</p>
<p>Does a good farmer neglect a crop he has planted?<br />
Does a good teacher overlook even the most humble student?<br />
Does a good father allow a single child to starve?<br />
Does a good programmer refuse to maintain his code?</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 6 &#8211; Management</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;Let the programmers be many and the managers few &#8211; then all will be<br />
productive.&#8221;</p>
<p>6.1</p>
<p>When managers hold endless meetings, the programmers write games. When<br />
accountants talk of quarterly profits, the development budget is about to<br />
be cut. When senior scientists talk blue sky, the clouds are about to roll<br />
in.</p>
<p>Truly, this is not the Tao of Programming.</p>
<p>When managers make commitments, game programs are ignored. When<br />
accountants make long-range plans, harmony and order are about to be<br />
restored. When senior scientists address the problems at hand, the<br />
problems will soon be solved.</p>
<p>Truly, this is the Tao of Programming.</p>
<p>6.2</p>
<p>Why are programmers non-productive?<br />
Because their time is wasted in meetings.</p>
<p>Why are programmers rebellious?<br />
Because the management interferes too much.</p>
<p>Why are the programmers resigning one by one?<br />
Because they are burnt out.</p>
<p>Having worked for poor management, they no longer value their jobs.</p>
<p>6.3</p>
<p>A manager was about to be fired, but a programmer who worked for him<br />
invented a new program that became popular and sold well. As a result, the<br />
manager retained his job.</p>
<p>The manager tried to give the programmer a bonus, but the programmer<br />
refused it, saying, &#8220;I wrote the program because I thought it was an<br />
interesting concept, and thus I expect no reward.&#8221;</p>
<p>The manager upon hearing this remarked, &#8220;This programmer, though he holds<br />
a position of small esteem, understands well the proper duty of an<br />
employee. Let us promote him to the exalted position of management<br />
consultant!&#8221;</p>
<p>But when told this, the programmer once more refused, saying, &#8220;I exist so<br />
that I can program. If I were promoted, I would do nothing but waste<br />
everyone&#8217;s time. Can I go now? I have a program that I&#8217;m working on.&#8221;</p>
<p>6.4</p>
<p>A manager went to his programmers and told them: &#8220;As regards to your work<br />
hours: you are going to have to come in at nine in the morning and leave<br />
at five in the afternoon.&#8221; At this, all of them became angry and several<br />
resigned on the spot.</p>
<p>So the manager said: &#8220;All right, in that case you may set your own<br />
working hours, as long as you finish your projects on schedule.&#8221; The<br />
programmers, now satisfied, began to come in at noon and work to the wee<br />
hours of the morning.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 7 &#8211; Corporate Wisdom</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;You can demonstrate a program for a corporate executive, but you can&#8217;t<br />
make him computer literate.&#8221;</p>
<p>7.1</p>
<p>A novice asked the master: &#8220;In the east there is a great tree-structure<br />
that men call `Corporate Headquarters&#8217;. It is bloated out of shape with<br />
vice presidents and accountants. It issues a multitude of memos, each<br />
saying `Go, Hence!&#8217; or `Go, Hither!&#8217; and nobody knows what is meant. Every<br />
year new names are put onto the branches, but all to no avail. How can<br />
such an unnatural entity be?&#8221;</p>
<p>The master replied: &#8220;You perceive this immense structure and are<br />
disturbed that it has no rational purpose. Can you not take amusement from<br />
its endless gyrations? Do you not enjoy the untroubled ease of programming<br />
beneath its sheltering branches? Why are you bothered by its<br />
uselessness?&#8221;</p>
<p>7.2</p>
<p>In the east there is a shark which is larger than all other fish. It<br />
changes into a bird whose wings are like clouds filling the sky. When this<br />
bird moves across the land, it brings a message from Corporate<br />
Headquarters. This message it drops into the midst of the programmers,<br />
like a seagull making its mark upon the beach. Then the bird mounts on the<br />
wind and, with the blue sky at its back, returns home.</p>
<p>The novice programmer stares in wonder at the bird, for he understands it<br />
not. The average programmer dreads the coming of the bird, for he fears<br />
its message. The master programmer continues to work at his terminal, for<br />
he does not know that the bird has come and gone.</p>
<p>7.3</p>
<p>The Magician of the Ivory Tower brought his latest invention for the<br />
master programmer to examine. The magician wheeled a large black box into<br />
the master&#8217;s office while the master waited in silence.</p>
<p>&#8220;This is an integrated, distributed, general-purpose workstation,&#8221; began<br />
the magician, &#8220;ergonomically designed with a proprietary operating<br />
system, sixth generation languages, and multiple state of the art user<br />
interfaces. It took my assistants several hundred man years to construct.<br />
Is it not amazing?&#8221;</p>
<p>The master raised his eyebrows slightly. &#8220;It is indeed amazing,&#8221; he<br />
said.</p>
<p>&#8220;Corporate Headquarters has commanded,&#8221; continued the magician, &#8220;that<br />
everyone use this workstation as a platform for new programs. Do you agree<br />
to this?&#8221;</p>
<p>&#8220;Certainly,&#8221; replied the master, &#8220;I will have it transported to the<br />
data center immediately!&#8221; And the magician returned to his tower, well<br />
pleased.</p>
<p>Several days later, a novice wandered into the office of the master<br />
programmer and said, &#8220;I cannot find the listing for my new program. Do<br />
you know where it might be?&#8221;</p>
<p>&#8220;Yes,&#8221; replied the master, &#8220;the listings are stacked on the platform in<br />
the data center.&#8221;</p>
<p>7.4</p>
<p>The master programmer moves from program to program without fear. No<br />
change in management can harm him. He will not be fired, even if the<br />
project is cancelled. Why is this? He is filled with Tao.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 8 &#8211; Hardware and Software</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;Without the wind, the grass does not move. Without software, hardware is<br />
useless.&#8221;</p>
<p>8.1</p>
<p>A novice asked the master: &#8220;I perceive that one computer company is much<br />
larger than all others. It towers above its competition like a giant among<br />
dwarfs. Any one of its divisions could comprise an entire business. Why is<br />
this so?&#8221;</p>
<p>The master replied, &#8220;Why do you ask such foolish questions? That company<br />
is large because it is large. If it only made hardware, nobody would buy<br />
it. If it only made software, nobody would use it. If it only maintained<br />
systems, people would treat it like a servant. But because it combines all<br />
of these things, people think it one of the gods! By not seeking to<br />
strive, it conquers without effort.&#8221;</p>
<p>8.2</p>
<p>A master programmer passed a novice programmer one day. The master noted<br />
the novice&#8217;s preoccupation with a hand-held computer game. &#8220;Excuse me,&#8221;<br />
he said, &#8220;may I examine it?&#8221;</p>
<p>The novice bolted to attention and handed the device to the master. &#8220;I<br />
see that the device claims to have three levels of play: Easy, Medium, and<br />
Hard,&#8221; said the master. &#8220;Yet every such device has another level of<br />
play, where the device seeks not to conquer the human, nor to be conquered<br />
by the human.&#8221;</p>
<p>&#8220;Pray, great master,&#8221; implored the novice, &#8220;how does one find this<br />
mysterious setting?&#8221;</p>
<p>The master dropped the device to the ground and crushed it underfoot. And<br />
suddenly the novice was enlightened.</p>
<p>8.3</p>
<p>There was once a programmer who worked upon microprocessors. &#8220;Look at how<br />
well off I am here,&#8221; he said to a mainframe programmer who came to visit,<br />
&#8220;I have my own operating system and file storage device. I do not have to<br />
share my resources with anyone. The software is self- consistent and<br />
easy-to-use. Why do you not quit your present job and join me here?&#8221;</p>
<p>The mainframe programmer then began to describe his system to his friend,<br />
saying &#8220;The mainframe sits like an ancient sage meditating in the midst<br />
of the data center. Its disk drives lie end-to-end like a great ocean of<br />
machinery. The software is as multifaceted as a diamond, and as convoluted<br />
as a primeval jungle. The programs, each unique, move through the system<br />
like a swift-flowing river. That is why I am happy where I am.&#8221;</p>
<p>The microcomputer programmer, upon hearing this, fell silent. But the two<br />
programmers remained friends until the end of their days.</p>
<p>8.4</p>
<p>Hardware met Software on the road to Changtse. Software said: &#8220;You are<br />
Yin and I am Yang. If we travel together we will become famous and earn<br />
vast sums of money.&#8221; And so the set forth together, thinking to conquer<br />
the world.</p>
<p>Presently they met Firmware, who was dressed in tattered rags and hobbled<br />
along propped on a thorny stick. Firmware said to them: &#8220;The Tao lies<br />
beyond Yin and Yang. It is silent and still as a pool of water. It does<br />
not seek fame, therefore nobody knows its presence. It does not seek<br />
fortune, for it is complete within itself. It exists beyond space and<br />
time.&#8221;</p>
<p>Software and Hardware, ashamed, returned to their homes.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Book 9 &#8211; Epilogue</p>
<p>Thus spake the master programmer:</p>
<p>&#8220;It is time for you to leave.&#8221;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
</p></blockquote>
<p>If you liked these, you may also like to read <a href="http://www.jwz.org/doc/worse-is-better.html">worse is better</a></p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/06/great-programmers-find-simple-solutions-to-complex-problems/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A bit of shell redirection</title>
		<link>http://atechie.net/2009/05/a-bit-of-shell-redirection/</link>
		<comments>http://atechie.net/2009/05/a-bit-of-shell-redirection/#comments</comments>
		<pubDate>Sat, 09 May 2009 19:07:18 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=16</guid>
		<description><![CDATA[Here is how we normally do shell redirection $ ./pgm.sh args &#62;out.txt 2&#62;err.txt I wanted to modify it a bit and run as follows $ ./pgm.sh args with the requirement that  output and error should go to some filename computed inside pgm.sh based on args. One illustrative case could be when date is part of [...]]]></description>
				<content:encoded><![CDATA[<p>Here is how we normally do shell redirection<br />
<code> $ ./pgm.sh args &gt;out.txt 2&gt;err.txt </code><br />
I wanted to modify it a bit and run as follows<br />
<code> $ ./pgm.sh args </code><br />
with the requirement that  output and error should go to some filename computed inside pgm.sh based on args. One illustrative case could be when date is part of args. So you would like stdout to go to say /your/directory/pgm_out_YYYYMMDD.txt <a href="#rev">1</a></p>
<p>The problem with standard way of redirecting <code> N&gt;file.txt</code> i.e, associating file descriptor N to file.txt , is that it works only for the newly forked process and not for the current  process.<br />
so<br />
<code>$ echo hi 1&gt;out.txt ;  echo hii </code> will send hi to out.txt but will print hii to stdout.<a href="#note2">2</a></p>
<p>This is where <code>exec</code> comes to our rescue. If we add <code> exec 1&gt;somefile.txt </code> then output from rest of the script will go to somefile.txt<br />
<code><br />
$ cat test.sh<br />
#!/usr/bin/env bash<br />
exec 1&gt;out.txt<br />
echo hi<br />
echo hii<br />
</code>$./test.sh will redirect hi as well as hii to out.txt</p>
<p>Similarly to redirect stdout as well as stderr we&#8217;ll do something like this<br />
<code> cat test2.sh<br />
exec 1&gt;out.txt<br />
exec 2&gt;err.txt<br />
echo out text<br />
echo 1&gt;&amp;2 err text<br />
somenoneexitent command<br />
ls -ld /tmp<br />
</code><br />
Now coming back to original point of redirecting to some file from inside the shell, let&#8217;s say program computed the filename in some variable  OUTFILE, we could have just done <code> exec 1&gt;$OUTFILE</code></p>
<p>That solves the current problem. But you may like to go through following example which achieves &#8216;random access&#8217; of file in shell script.  Example is  from <a href="http://tldp.org/LDP/abs/html/io-redirection.html"> here</a><br />
<code>echo 1234567890 &gt; File    # Write string to "File".<br />
exec 3&lt;&gt; File             # Open "File" and assign fd 3 to it.<br />
read -n 4 &lt;&amp;3             # Read only 4 characters.<br />
echo -n . &gt;&amp;3             # Write a decimal point there.<br />
exec 3&gt;&amp;-                 # Close fd 3.<br />
cat File                  # ==&gt; 1234.67890<br />
</code><br />
With comments, this code is self explanatory.<br />
&#8211;<br />
<a name="rev">1 </a>It can also be done by <code> $ ./pgm.sh args &gt;pgm_out`date +%Y%m%d` </code> but idea is to generate this file name based on some logic in program itself.<br />
<a name="note2">2 </a> 1 in 1&gt;out.txt is redundant but it clarifies here that we are redirecting fd 1</p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/05/a-bit-of-shell-redirection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sony VAIO  review</title>
		<link>http://atechie.net/2009/04/sony-vaio-ns25g-review/</link>
		<comments>http://atechie.net/2009/04/sony-vaio-ns25g-review/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 19:06:21 +0000</pubDate>
		<dc:creator>prashant</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[laptop]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sony vaio]]></category>

		<guid isPermaLink="false">http://atechie.net/?p=201</guid>
		<description><![CDATA[A month back I  bought a vaio NS25G and have been planning to write this post since then. This post is  primarily notes to self and review of the same. Let&#8217;s get off the mark quickly - Post has two parts - I. Review of hardware II. Installing debian and things to setup I. Review [...]]]></description>
				<content:encoded><![CDATA[<p>A month back I  bought a vaio <a href="http://www.sony.co.in/microsite/vaio/products/vaio_ns/vgn_ns25/index.html">NS25G</a> and have been planning to write this post since then. This post is  primarily notes to self and review of the same. Let&#8217;s get off the mark quickly -</p>
<p>Post has two parts -</p>
<p><a href="#rev">I. Review  of hardware</a><br />
<a href="#rev">II. Installing debian and things to setup</a></p>
<p><a name="rev"><strong>I. Review  of hardware</strong> </a></p>
<p>Since I am not a VAIO marketing guy,  I&#8217;ll start other way round -</p>
<p><em>Why you may not like to buy this laptop :</em></p>
<ol>
<li>No bluetooth : believe me, in 2009 sony sells laptop without bluetooth. Sure you can use usb stuff but &#8230;</li>
<li>Screen size is 15.4 inches :  if you travel a lot then this laptop may not be very handy and also 2.9kg laptop is not exactly the lightest around.</li>
<li>No HDMI output.</li>
<li>No  separate graphics card and the likes.(and no dedicated video memory</li>
</ol>
<p><em>Now , why you may like to buy it : </em></p>
<ol>
<li>This laptop is a damn good desktop. What I mean is this if your requirement is like me &#8211; mostly writing programs and trying to use it 25 out of 24 hrs, then with a big screen , extremely comfortable keyboard layout with spacious palm rest and good compute power , it makes a very good combination.</li>
<li>It L2 cache is 2MB and processor/memory system bus are 800MHz. I don&#8217;t play games so can&#8217;t say about that but for anything else but a core 2 duo processor with 2GHz freq is good, this is more than enough.</li>
<li> From my usage, I see processor mostly clocks at 1.2GHz, and memory usage ~500MB. That just reinforces previous point.</li>
<li>Battery backup is good, ~2  hrs is what I get.</li>
</ol>
<p>Just one more thing here &#8211; being  Sony,  it will cost you a bit than other laptops with similar configuration,  but that is a call u have to make.</p>
<p><a name="rev"><strong>II.  Configuring linux (to run out of box ! ) : </strong> </a><br />
It came pre installed with Vista( I think home premium or some fancy name like that). <a href="http://dungara.info">Dungara</a> booted once and created another partition of 150 GB.  Debian testing is what I always install and then up(down?)grade to &#8216;unstable&#8217; sid.</p>
<p>Things which worked without any problem:</p>
<ol>
<li> X -  unsurprisingly X server had not problem with starting or resolution.  After one of the upgrades X refused to start though,  but  &#8216;X -configure&#8217; generated a conf file which worked pretty well.</li>
<li> Audio -  Audio output and external mic work fine. kernel version 2.6.29-1-686 #1 SMP and alsa version  1.0.17. This is what you get from<br />
<code> $ lspci  -v |grep Audio 00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Con1.0.17troller (rev 03)</code></li>
<li>Video cam &#8211; just works</li>
<li>Hibernate to disk and back &#8211; no problem</li>
<li>Wireless -  in short  &#8211; just works.<br />
<code> $ lspci |grep -i wireless<br />
03:13:55 04:00.0 Network controller: Atheros Communications Inc. AR928X Wireless Network Adapter (PCI-Express) (rev 01) .</code><br />
I think kernel 2.6..27 onwards it works with the stock kernel source. You dont have to install ndiswrapper or things like t<br />
hat. As a note, please say good buy gnome-network-manager and welcome wicd, it is just a gui layer but behind the scene they have fixed lot of config stuff like wpasupplient and more.</li>
</ol>
<p>What doesn&#8217;t work -</p>
<ol>
<li>Somehow internal mic refuses to work <img src='http://atechie.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />   External mic works fine though.  Latest alsa sources did not compile cleanly on debian, so for the  time being  I bought external Internal mic, will try to dig into it sometime in future though.</li>
</ol>
<p>Few more misc hints for deiban:</p>
<ul>
<li>Package for devnagri font- ttf-indic-fonts</li>
<li>Package for flash player &#8211; flashplugin-nonfree</li>
<li>Entry in sources.list for mplayer and likes &#8211; deb http://www.debian-multimedia.org sid main</li>
<li>Entry in sources.list for e17 &#8211; deb http://debian.alphagemini.org/ unstable main</li>
<li>Entry in sources.list for skype &#8211; http://download.skype.com/linux/repos/debian/ stable non-free</li>
</ul>
<p>oneliner for increasing and decreasing the brightness -<br />
<code><br />
[root]prashant@vaio09:12 PM$ cat bin/incbrightness.sh<br />
#!/usr/bin/env bash<br />
echo $[1+`cat /sys/class/backlight/acpi_video0/brightness `] &gt;/sys/class/backlight/acpi_video0/brightness<br />
</code><br />
you&#8217;ll have to put this in sudo though.<br />
and to decrease change + to &#8211; and &#8230; you get the idea, right !</p>
<p>A bit more, if you use enlightenment(e17) here are few more hints -</p>
<p>[enlightenment key bindidings]</p>
<p>You can use following key code and mapping</p>
<p>mute :<br />
<code>KEY="Keycode-160"   ACTION="exec" PARAMS="/usr/bin/amixer -q set Master toggle"</code><br />
hibernate :<br />
<code>KEY="Keycode-165"   ACTION="exec" PARAMS="sudo /usr/sbin/hibernate-disk"</code><br />
volume decrease :<br />
<code>KEY="Keycode-174"   ACTION="exec" PARAMS="/usr/bin/amixer -q set Master 2-"</code><br />
volume increase:<br />
<code>KEY="Keycode-176"   ACTION="exec" PARAMS="/usr/bin/amixer -q set Master 2+"</code><br />
increase brightness :<br />
<code>KEY="Keycode-212"   ACTION="exec" PARAMS="sudo /root/bin/incbrightness.sh" </code><br />
decrease brightness<br />
<code>KEY="Keycode-101" ACTION="exec" PARAMS="sudo /root/bin/decbrightness.sh"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://atechie.net/2009/04/sony-vaio-ns25g-review/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
