<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-20309183</id><updated>2012-01-20T21:42:56.360+05:30</updated><category term='C++'/><category term='rsh linux password less access'/><category term='DSDT. Power Management'/><category term='Twine'/><category term='select linux solaris'/><category term='interview'/><category term='Twitter'/><category term='postgres'/><category term='boot'/><category term='entry point'/><category term='Linux'/><category term='ACPI'/><category term='Bug Fix'/><category term='semantic web'/><category term='hang'/><category term='coding'/><category term='Natural Language'/><category term='Ruby on Rails'/><category term='pragma'/><category term='SuSE'/><category term='BIOS'/><category term='programs'/><category term='Templates'/><title type='text'>puretechie</title><subtitle type='html'>Our technical scratch pad</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>82</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-20309183.post-4829155218230223071</id><published>2011-10-21T23:31:00.000+05:30</published><updated>2011-10-21T23:31:09.675+05:30</updated><title type='text'>Mail thru javascript</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;you can automate sending bulk emails. In case you dont want to send BCCs or even CCs, (some rare cases, i agree)..&lt;br /&gt;&lt;br /&gt;if your content is all text or html, (the example given is for text), and the mail-ids you need to send individual mails are one per line in a google spreadsheet (customisable to add other data),&lt;br /&gt;you can open the spreadsheet, go to tools-&amp;gt;ScriptEditor&lt;br /&gt;and start typing your javascript! heres an example that sends each mail to one individual at a time, in clear text&lt;br /&gt;&lt;br /&gt;//This thing just adds a convenient menu/submenu in your spreadsheet window!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function onOpen() {&lt;br /&gt;&amp;nbsp; var subMenus = [];&lt;br /&gt;&amp;nbsp; subMenus.push({name: "Email File to selected Range", functionName: "mysendmail"});&lt;br /&gt;&amp;nbsp; SpreadsheetApp.getActiveSpreadsheet().addMenu("Email", subMenus);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function mysendmail() {&lt;br /&gt;&amp;nbsp; var numAddrs=SpreadsheetApp.getActiveRange().getValues().length;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; for (var i=0; i&lt;numaddrs;i++){&lt; p=""&gt;&lt;/numaddrs;i++){&lt;&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; var toAddr=SpreadsheetApp.getActiveRange().getValues()[i].toString();&lt;br /&gt;&amp;nbsp; &amp;nbsp; //Browser.msgBox("what is in toAddr is: " + SpreadsheetApp.getActiveRange().getValues()[i].toString());&lt;br /&gt;&lt;br /&gt;// this is the line that sends the mail&lt;br /&gt;&amp;nbsp; &amp;nbsp; GmailApp.sendEmail(toAddr, "sendmail", "testing");&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if you want to attach a file, you need to use MailApp's sendEmail interface that accepts the attachment.&lt;br /&gt;&lt;br /&gt;MailApp.sendEmail(recipients, emailSubject, emailMessage, {attachments: fileName});&lt;br /&gt;&lt;br /&gt;check the documentation for other cool scripting interfaces with google apps.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4829155218230223071?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4829155218230223071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4829155218230223071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4829155218230223071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4829155218230223071'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2011/10/mail-thru-javascript.html' title='Mail thru javascript'/><author><name>Girish</name><uri>http://www.blogger.com/profile/15321268371583634243</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_LNRxIF_pv1Y/SYXg40tbkrI/AAAAAAAACsc/LQoEMwdFeA8/S220/SEAGULL42.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4022514587712751179</id><published>2011-02-28T21:01:00.003+05:30</published><updated>2011-02-28T21:03:31.367+05:30</updated><title type='text'>RSS feed for gmail ...</title><content type='html'>I like this feature, where gmail is now accessible over rss feed. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;try this in firefox ( is rss feed support there in chrome by now? )&lt;/div&gt;&lt;div&gt;https://USERNAME:PASSWORD@gmail.google.com/gmail/feed/atom&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Though this feature is nice , i wonder if there are any uses of this feature in-spite of PoP3 or SMTP clients&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4022514587712751179?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4022514587712751179/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4022514587712751179' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4022514587712751179'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4022514587712751179'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2011/02/rss-feed-for-gmail.html' title='RSS feed for gmail ...'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3274276521273578839</id><published>2010-08-21T00:44:00.000+05:30</published><updated>2010-08-21T00:44:25.907+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='BIOS'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>linux system info</title><content type='html'>if you ever want to get low level h/w info from your linux installation and your proc file system is cryptic, use 'biosdecode' and/or 'dmidecode'&lt;br /&gt;&lt;br /&gt;biosdecode is known to be inadequate. some recent versions of enterprise linux dont ship  biosdecode by default. use dmidecode instead. however, it is known to be inaccurate or un-reliable. But, it gives a quick and easy peek into the system and if you need reliable data, you must anyway look into the proc fs.&lt;br /&gt;&lt;br /&gt;'dmidecode -t' prints all available sub-system level info.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3274276521273578839?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3274276521273578839/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3274276521273578839' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3274276521273578839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3274276521273578839'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2010/08/linux-system-info.html' title='linux system info'/><author><name>Girish</name><uri>http://www.blogger.com/profile/15321268371583634243</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_LNRxIF_pv1Y/SYXg40tbkrI/AAAAAAAACsc/LQoEMwdFeA8/S220/SEAGULL42.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-1497375381718632406</id><published>2009-12-07T11:28:00.002+05:30</published><updated>2009-12-07T11:34:07.317+05:30</updated><title type='text'>New features in Java 7: Switch on Strings</title><content type='html'>At last there is  this feature is in Java 7&lt;br /&gt;&lt;br /&gt;&lt;pre class="sh_java sh_sourceCode"&gt;&lt;span class="sh_usertype"&gt;String&lt;/span&gt;&lt;span class="sh_normal"&gt; &lt;/span&gt;s &lt;span class="sh_symbol"&gt;= "something something something"&lt;/span&gt;&lt;span class="sh_symbol"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="sh_keyword"&gt;switch&lt;/span&gt;&lt;span class="sh_symbol"&gt;(&lt;/span&gt;s&lt;span class="sh_symbol"&gt;)&lt;/span&gt; &lt;span class="sh_cbracket"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class="sh_keyword"&gt;case&lt;/span&gt; &lt;span class="sh_string"&gt;"Jayanagar"&lt;/span&gt;&lt;span class="sh_symbol"&gt;:&lt;/span&gt;&lt;br /&gt;   goToOxford(&lt;span class="sh_symbol"&gt;&lt;/span&gt;s&lt;span class="sh_symbol"&gt;);&lt;/span&gt;&lt;br /&gt;   break;&lt;br /&gt;&lt;br /&gt; &lt;span class="sh_keyword"&gt;case&lt;/span&gt; &lt;span class="sh_string"&gt;"Rajajinagar"&lt;/span&gt;&lt;span class="sh_symbol"&gt;:&lt;/span&gt;&lt;br /&gt; &lt;span class="sh_keyword"&gt;case&lt;/span&gt; &lt;span class="sh_string"&gt;"Navrang"&lt;/span&gt;&lt;span class="sh_symbol"&gt;:&lt;/span&gt;&lt;br /&gt;   &lt;span class="sh_function"&gt;haveDosainAjanta&lt;/span&gt;&lt;span class="sh_symbol"&gt;(&lt;/span&gt;s&lt;span class="sh_symbol"&gt;);&lt;/span&gt;&lt;br /&gt;   &lt;span class="sh_keyword"&gt;break&lt;/span&gt;&lt;span class="sh_symbol"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="sh_keyword"&gt;default&lt;/span&gt;&lt;span class="sh_symbol"&gt;:&lt;/span&gt;&lt;br /&gt;   &lt;span class="sh_function"&gt;goToBrahminsCoffeebar(&lt;/span&gt;&lt;span class="sh_symbol"&gt;&lt;/span&gt;s&lt;span class="sh_symbol"&gt;);&lt;/span&gt;&lt;br /&gt;   &lt;span class="sh_keyword"&gt;break&lt;/span&gt;&lt;span class="sh_symbol"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="sh_cbracket"&gt;}&lt;/span&gt;&lt;br /&gt;More on ... &lt;a href="http://java.sun.com/features/jdk/7/"&gt;http://java.sun.com/features/jdk/7/&lt;/a&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-1497375381718632406?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/1497375381718632406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=1497375381718632406' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1497375381718632406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1497375381718632406'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2009/12/new-features-in-java-7-switch-on.html' title='New features in Java 7: Switch on Strings'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4527159219696681123</id><published>2009-09-18T13:01:00.010+05:30</published><updated>2009-09-18T16:26:50.681+05:30</updated><title type='text'>Getting customized mobile updates from twitter and other RSS services</title><content type='html'>This post marks the 4th year of this blog.&lt;br /&gt;Hope is to actively engage in writing this blog.&lt;br /&gt;&lt;br /&gt;Presented below is an orchestrate of  seemingly disparate technologies to enable your favorite updates on your cellphone.&lt;br /&gt;Note: Your cellphone need not have Wifi or GPRS options. This works on basic SMS incoming facility.&lt;br /&gt;&lt;br /&gt;Now some of my favorite online items which i need to keep track are:&lt;br /&gt;1) Twitter updates from selected friends.&lt;br /&gt;2) Posts from selected blogs which i want to keep myself updated.&lt;br /&gt;3) Instant updates from Google alerts.&lt;br /&gt;&lt;br /&gt;Here is one way we can have all the elements integrated:&lt;br /&gt;&lt;br /&gt;1) Collect RSS feeds of all the items listed above.&lt;br /&gt;2) Using yahoo pipes you can do the following:&lt;br /&gt;         2a) Using Fetch Feed , aggregate all the feeds.&lt;br /&gt;         2b) Use a sort by published date to get the feeds in order. &lt;a href="http://pipes.yahoo.com/pipes/pipe.info?_id=cab822b22b54c23a1951c83d933cce02"&gt;Click here for a preview&lt;/a&gt;&lt;br /&gt;    2c)  This service gives out a common aggregated RSS feed for the selected set.&lt;br /&gt;    2d) Also one can use alternatives like RSSmix to achieve a common RSS feed.&lt;br /&gt;3) To get the updates on the cellphone, use &lt;a href="http://www.labnol.org/internet/google-sms-subscribe-rss-via-sms/4726/"&gt;Google SMS Channel&lt;/a&gt; . By configuring our cellphone for the alerts in Google SMS Channel , we can get the desired updates on our cellphone.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4527159219696681123?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4527159219696681123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4527159219696681123' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4527159219696681123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4527159219696681123'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2009/09/getting-customized-mobile-updates-from.html' title='Getting customized mobile updates from twitter and other RSS services'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-2111108571718472490</id><published>2009-07-06T13:21:00.005+05:30</published><updated>2009-07-14T00:45:59.889+05:30</updated><title type='text'>Java URL Bloomer</title><content type='html'>I came across an interesting problem in java&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class URLBloomer {&lt;br /&gt;           public static void main(String[] args) throws MalformedURLException, URISyntaxException {&lt;br /&gt;          String[] urls= {&lt;br /&gt;                                     "http://meshlabsinc.com",&lt;br /&gt;                                     "http://meshserver.org"&lt;br /&gt;                                  };&lt;br /&gt;        Set&lt;url&gt; testing=new HashSet&lt;url&gt;();&lt;br /&gt;        for (String url : urls) {&lt;br /&gt;                                 testing.add(new URL(url));&lt;br /&gt;       }&lt;br /&gt;       System.out.println(testing.size());&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Output : 1&lt;br /&gt;&lt;br /&gt;Reason .... meshlabsinc.com and meshserver.org point to the same IP&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Lesson learnt is to use URI instead of URL class.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class URLBloomer {&lt;br /&gt;                     public static void main(String[] args) throws MalformedURLException, URISyntaxException {&lt;br /&gt;                    String[] urls= {&lt;br /&gt;                                               "http://meshlabsinc.com",&lt;br /&gt;                                               "http://meshserver.org"&lt;br /&gt;                                             };&lt;br /&gt;                   Set&lt;uri&gt; testing=new HashSet&lt;uri&gt;();&lt;br /&gt;                   for (String url : urls) {&lt;br /&gt;                                           testing.add(new URI(url));&lt;br /&gt;                   }&lt;br /&gt;                  System.out.println(testing.size());&lt;br /&gt;          }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;Output : 2&lt;br /&gt;&lt;input id="gwProxy" type="hidden"&gt;&lt;!--Session data--&gt;&lt;input onclick="jsCall();" id="jsProxy" type="hidden"&gt;&lt;div id="refHTML"&gt;&lt;/div&gt;&lt;/uri&gt;&lt;/uri&gt;&lt;/url&gt;&lt;/url&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-2111108571718472490?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/2111108571718472490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=2111108571718472490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2111108571718472490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2111108571718472490'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2009/07/java-url-bloomer.html' title='Java URL Bloomer'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-872279014522460143</id><published>2009-02-24T20:28:00.001+05:30</published><updated>2009-02-24T20:30:58.595+05:30</updated><title type='text'>Getting the create table command for an already existing table in mysql</title><content type='html'>mysql&gt;SHOW CREATE TABLE &lt;table_name&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; create table x (i integer);&lt;br /&gt;Query OK, 0 rows affected (0.27 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; show create table x;&lt;br /&gt;+-------+--------------------------------------------------------------------------------------+&lt;br /&gt;| Table | Create Table                                                                         |&lt;br /&gt;+-------+--------------------------------------------------------------------------------------+&lt;br /&gt;| x     | CREATE TABLE `x` (&lt;br /&gt;  `i` int(11) default NULL&lt;br /&gt;) ENGINE=MyISAM DEFAULT CHARSET=latin1 |&lt;br /&gt;+-------+--------------------------------------------------------------------------------------+&lt;br /&gt;1 row in set (0.06 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-872279014522460143?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/872279014522460143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=872279014522460143' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/872279014522460143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/872279014522460143'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2009/02/getting-create-table-command-for.html' title='Getting the create table command for an already existing table in mysql'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-322356436542610490</id><published>2008-10-13T21:19:00.004+05:30</published><updated>2008-10-13T21:26:34.447+05:30</updated><title type='text'>Java code to send message to your gtalk friends</title><content type='html'>Have used a library called &lt;a href="http://www.igniterealtime.org/projects/smack/index.jsp"&gt;Smack &lt;/a&gt;(http://www.igniterealtime.org/projects/smack/index.jsp)&lt;br /&gt;&lt;br /&gt;import java.util.Collection;&lt;br /&gt;&lt;br /&gt;import org.jivesoftware.smack.*;&lt;br /&gt;&lt;br /&gt;public class GtalkClient {&lt;br /&gt;&lt;br /&gt; public static void main(String[] args) throws XMPPException {&lt;br /&gt;  ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");&lt;br /&gt;  XMPPConnection connection = new XMPPConnection(config);&lt;br /&gt;  connection.connect();&lt;br /&gt;  connection.login("&lt; username &gt;","&lt; password &gt;");&lt;br /&gt;  &lt;br /&gt;//  Below is the code to get the users&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;//  Roster roster = connection.getRoster();&lt;br /&gt;//  Collection&lt;RosterEntry&gt; rosterEntries = roster.getEntries();&lt;br /&gt;//   &lt;br /&gt;//  System.out.println("\n\n" + rosterEntries.size() + " friend(s):");&lt;br /&gt;//  for(RosterEntry rosterEntry:rosterEntries)&lt;br /&gt;//  {&lt;br /&gt;//   System.out.println(rosterEntry.getUser());&lt;br /&gt;//  }&lt;br /&gt;  &lt;br /&gt;//   Here is a code to send message to a friend&lt;br /&gt;  &lt;br /&gt;  MessageListener messageListener = null;&lt;br /&gt;  Chat chat = connection.getChatManager().createChat("shantanu.gg@gmail.com",messageListener);&lt;br /&gt;  chat.sendMessage("Hello this is a ping from a java program");&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-322356436542610490?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/322356436542610490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=322356436542610490' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/322356436542610490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/322356436542610490'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/10/java-code-to-send-message-to-your-gtalk.html' title='Java code to send message to your gtalk friends'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-1458405420304406899</id><published>2008-09-30T15:58:00.002+05:30</published><updated>2008-09-30T16:05:27.401+05:30</updated><title type='text'>Sending email using GMAIL using Java Mail Api</title><content type='html'>Note: Search for changeme and replace with appropriate terms.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.mail.*;&lt;br /&gt;import javax.mail.internet.*;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;public class MailSender {&lt;br /&gt; final String senderEmailID  = "changeme @ changeme .com";&lt;br /&gt; final String senderPassword  = "changeme";&lt;br /&gt; final String emailSMTPserver = "smtp.gmail.com";&lt;br /&gt; final String emailServerPort = "465";&lt;br /&gt; String receiverEmailID   = null;&lt;br /&gt; String emailSubject    = null;&lt;br /&gt; String emailBody    = null;&lt;br /&gt;&lt;br /&gt; public MailSender(String receiverEmailID, String emailSubject, String emailBody) {&lt;br /&gt;  this.receiverEmailID=receiverEmailID;&lt;br /&gt;  this.emailSubject=emailSubject;&lt;br /&gt;  this.emailBody=emailBody;&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;  Properties props = new Properties();&lt;br /&gt;  props.put("mail.smtp.user",senderEmailID);&lt;br /&gt;  props.put("mail.smtp.host", emailSMTPserver);&lt;br /&gt;  props.put("mail.smtp.port", emailServerPort);&lt;br /&gt;  props.put("mail.smtp.starttls.enable", "true");&lt;br /&gt;  props.put("mail.smtp.auth", "true");&lt;br /&gt;  // props.put("mail.smtp.debug", "true");&lt;br /&gt;  props.put("mail.smtp.socketFactory.port", emailServerPort);&lt;br /&gt;  props.put("mail.smtp.socketFactory.class",&lt;br /&gt;    "javax.net.ssl.SSLSocketFactory");&lt;br /&gt;  props.put("mail.smtp.socketFactory.fallback", "false");&lt;br /&gt;&lt;br /&gt;  SecurityManager security = System.getSecurityManager();&lt;br /&gt;&lt;br /&gt;  try {&lt;br /&gt;   Authenticator auth = new SMTPAuthenticator();&lt;br /&gt;   Session session = Session.getInstance(props, auth);&lt;br /&gt;   // session.setDebug(true);&lt;br /&gt;&lt;br /&gt;   MimeMessage msg = new MimeMessage(session);&lt;br /&gt;   msg.setText(emailBody);&lt;br /&gt;   msg.setSubject(emailSubject);&lt;br /&gt;   msg.setFrom(new InternetAddress(senderEmailID));&lt;br /&gt;   msg.addRecipient(Message.RecipientType.TO,&lt;br /&gt;     new InternetAddress(receiverEmailID));&lt;br /&gt;   Transport.send(msg);&lt;br /&gt;  } catch (Exception mex) {&lt;br /&gt;   mex.printStackTrace();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt; }&lt;br /&gt; private class SMTPAuthenticator extends javax.mail.Authenticator {&lt;br /&gt;  public PasswordAuthentication getPasswordAuthentication() {&lt;br /&gt;   return new PasswordAuthentication(senderEmailID, senderPassword);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; /**&lt;br /&gt;  * @param args&lt;br /&gt;  */&lt;br /&gt; public static void main(String[] args) {&lt;br /&gt;  // TODO Auto-generated method stub&lt;br /&gt;  MailSender mailSender=new MailSender("changeme @ changeme .com","Test Mail from Puretechie","Here goes the body");&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-1458405420304406899?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/1458405420304406899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=1458405420304406899' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1458405420304406899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1458405420304406899'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/09/sending-email-using-gmail-using-java.html' title='Sending email using GMAIL using Java Mail Api'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-550756614871837311</id><published>2008-09-27T22:14:00.005+05:30</published><updated>2008-09-28T00:00:05.527+05:30</updated><title type='text'>Power Vs (LVM Vs VxVm). Score 2-0. Power Wins :(</title><content type='html'>we had an unplanned/unscheduled power outage recently and as a result of that, some servers went down, some storage controllers went down, some switches were up and some local disks went bad.&lt;br /&gt;&lt;br /&gt;chaos, you may think.&lt;br /&gt;it was actually much more challenging than that. and every such situation in office gives a good learning experience. once the storage controllers, switches and power to serves were restored, we had this problem.&lt;br /&gt;&lt;br /&gt;there is one each imaging server for HP-UX, Solaris and AIX environments respectively(NOT imaging as in picture/photos imaging, this is a hard disk imaging environment). we can also call it as network based installation technologies for each h/w architecture type. All these servers store the disk images in a centralised archive server(which was, in our case, the same as the imaging server for hp-ux). the storage came from a MSA with one LUN of 2 TB presented to this host.&lt;br /&gt;&lt;br /&gt;the server wudnt boot up after the power outage from the local disk (which was mirrored). the kernel wud just dump core and reboot infinitely. I and my colleagues were not great hp-ux kernel debuggers, so we took the alternate steps:&lt;br /&gt;&lt;br /&gt;1. Boot from mirrored disk (although we know that a mirrored disk doesnt give data redundancy cos if data on one disk is corrupted, it wud almost simultaneously corrupt data on the other disk) - FAILED. Problem cud be hardware (memory, cpu ... although leds were all green) or OS related.&lt;br /&gt;2. since the server (rp*) had 3 slots for scsi disks, we attached a disk from another server on which hp-ux (version immaterial at this point) was installed and booted the failed server from this disk. System Booted: h/w is OK. what could be so wrong with the OS that it dumps so bad??? and a power outage caused this?!?&lt;br /&gt;3. we dint know the OS environment on the disk that had gone bad(version, file system type, partition information).&lt;br /&gt;&lt;br /&gt;core options we had were&lt;br /&gt;hp-ux 11.23 or 11.31&lt;br /&gt;with&lt;br /&gt;LVM or VxVm.&lt;br /&gt;&lt;br /&gt;thats a combo of four.&lt;br /&gt;&lt;br /&gt;and if u screw up with the metadata(fs data), u r totally lost. not just the 2TB data, configs and other data from the local disk(which had no backup ;) ) wud simply be wiped out. so, the strategy was to recover the local disk data(somehow) and then to recover the data on MSA.&lt;br /&gt;&lt;br /&gt;a quick look at docs said LVM and VxVm totally co-exist and are "aware" of each other. good news, also bad. good news, cos they are aware of each other and hence wud _probably_ not tamper with the meta-data wen u try to access them. bad news, cos they co-exist, and hence our number of combinations to be tried out is still 4.&lt;br /&gt;&lt;br /&gt;with fingers crossed, and since the third disk which had currently booted the server had 11.31 with lvm, i thought i will try the lvm method.&lt;br /&gt;&lt;br /&gt;run sam, go to disks and filesystems menu, locate ur disk. note down the hardware path.&lt;br /&gt;go back to volume groups menu, and say "import volume group".&lt;br /&gt;u get a msg quickly saying that LVM data is not found on disk. phew.&lt;br /&gt;this could mean disk corruption OR that it is a vxvm disk.&lt;br /&gt;&lt;br /&gt;try the command line tools that sam just used with the force options vgscan, vgimport and u get same error.&lt;br /&gt;OK. so its a vxvm disk.(trying to be optimistic)&lt;br /&gt;&lt;br /&gt;apparently, vxvm software is installed as part of every hp-ux installation(may be only internally for us, cos vxvm is a licensed tool) but not activated unless you use it for root dg(disk group). vxvm and lvm have different terminologies.&lt;br /&gt;&lt;br /&gt;LVM             /                                 VxVm&lt;br /&gt;Physical Volume   /    VxVM Disk&lt;br /&gt;Logical Volume    /            Volume&lt;br /&gt;Volume Group    /         Disk Group&lt;br /&gt;Physical Extent   /           Subdisk&lt;br /&gt;LVM metadata    /   Private Region&lt;br /&gt;Unused Physical   /       Free Space&lt;br /&gt;Extent&lt;br /&gt;&lt;br /&gt;LVM, as u see, is what we are mostly exposed to(due to linux and traditinal unix fs). so u know the terminologies and the equivalents. now, u need to know how to use the software itself (vxvm).&lt;br /&gt;its quite easy. just run vxinstall. and use all default options. vxvm has a web based client for a front-end. the tool is called "vea" (Veritas Enterprise Administrator). vea just showed the physical disks. nothing else. all other entities(DGs, volumes) were empty. right-click on  ur disk and say "recover disk" (with crossed fingers, ofcourse). and voila, the disk groups were imported. it was, a vxvm disk. root, swap and stand volumes were shows as detected, but corrupted. okay. so you run a fsck on the disk, correct all vxfs errors. and mount the root volume. ur config data and other data is there.&lt;br /&gt;&lt;br /&gt;now for the data on the MSA. right click on msa disk and said "recover disk", just like earlier. and bam! i got a disk group that showed as 2TB free space!!! where is all the data!&lt;br /&gt;&lt;br /&gt;here is where some concepts learnt in college helps. u most certainly know that u have only screwed up the meta-data and not yet the actual fs data. cos a disk was only initialised to be of some type(vxvm disk) and not formatted.&lt;br /&gt;&lt;br /&gt;u go back to ur root disk and search for /mount-point/etc/fstab (damn, why dint i look into it before!!!) and it said, very promptly, that the disk was of LVM type (device names of vxvm disks are /dev/vx/dg-name/volumes, where as lvm will have it as /dev/vg-name/lvol-names). who wud think that the msa will be configured for lvm type and the root disk will be of vxvm type??? confirm it by running "strings /mount-point/etc/lvmtab" , the disk was sitting pretty there with the vg data.&lt;br /&gt;&lt;br /&gt;ok, now, deactivate the disk using vea and delete all vxvm data. go back to sam and say "import volume group". as expected, lvm data was lost, so sam says, do u want to create a new volume group instead??? (hell, no!)&lt;br /&gt;&lt;br /&gt;since i had access to the root disk, navigate to /mount-point/etc/lvmconfig/ and search for &lt;vg-name&gt;.conf file that will have the vg data.&lt;br /&gt;using that, vgcfgrestore and vgimport commands, we cud restore the vg config. but the superblock was also corrupted(fsck said so). so had to dump the superblock from 8192 and successive(forgot the block count) blocks. fsck again and mount the lvol. phew, the data was all there!&lt;br /&gt;&lt;br /&gt;now for the anti-climax:&lt;br /&gt;even though we cud recover all data, we cudnt boot off the local disk that was dumping core. vxvm used to hang during boot-up right after initialising the disks. we had to re-setup the imaging server(we also tried using the "last_install" kernel and that wudnt boot either). a similar thing happened on an x86 VM (running on ESX 3.5)recently, which was also a critical server for us. even though fsck gave no errors and we cud access all data when mounted as an external disk on another VM, we could not boot from that disk. and thats when i give up and create the setup once again from scratch :( using the data recovered externally. and to top it all, what has power outage got to do with this???&lt;br /&gt;&lt;br /&gt;PS: most of this might not be clear due to the language and the sequence in which i have put it. leave ur quetions as comments.&lt;/vg-name&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-550756614871837311?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/550756614871837311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=550756614871837311' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/550756614871837311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/550756614871837311'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/09/power-vs-lvm-vs-vxvm-score-2-0-power.html' title='Power Vs (LVM Vs VxVm). Score 2-0. Power Wins :('/><author><name>Girish</name><uri>http://www.blogger.com/profile/15321268371583634243</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_LNRxIF_pv1Y/SYXg40tbkrI/AAAAAAAACsc/LQoEMwdFeA8/S220/SEAGULL42.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-6462667181252484984</id><published>2008-09-22T12:18:00.002+05:30</published><updated>2008-09-22T12:59:16.286+05:30</updated><title type='text'>Common bad practice in database calculations</title><content type='html'>create table x ( i int, j varchar(10))&lt;br /&gt;insert into x values (1,'a')&lt;br /&gt;insert into `x`(`i`,`j`) values ( '2',NULL)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;select count(*) from x&lt;br /&gt;2&lt;br /&gt;Select count(j) from x&lt;br /&gt;1&lt;br /&gt;&lt;br /&gt;Note the difference when the count(col_name) is used.&lt;br /&gt;&lt;br /&gt;count(col_name) is used under the impression that it is faster than count(*) , however quite the opposite is true.&lt;br /&gt;&lt;br /&gt;MYISAM table MySQL has cached number of rows in the table. Thats the reason why MYISM  is able to instantly answer COUNT(*) query, but not COUNT(col_name). &lt;br /&gt;&lt;br /&gt;Why ? Because say if col_name column is not defined as NOT NULL there can be some NULL values in it and so MySQL have to perform table scan to find out. This is also why result is different for the second query.&lt;br /&gt;&lt;br /&gt;Using count(*) instead of count(col_name) falls in the best practice category.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-6462667181252484984?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/6462667181252484984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=6462667181252484984' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6462667181252484984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6462667181252484984'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/09/common-bad-practice-in-database.html' title='Common bad practice in database calculations'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-8178448063864805712</id><published>2008-09-03T10:44:00.000+05:30</published><updated>2008-09-03T10:45:49.290+05:30</updated><title type='text'>Try</title><content type='html'>Google Chrome&lt;br /&gt;http://www.google.com/chrome&lt;br /&gt;&lt;br /&gt;feels different.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-8178448063864805712?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/8178448063864805712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=8178448063864805712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8178448063864805712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8178448063864805712'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/09/try.html' title='Try'/><author><name>Girish</name><uri>http://www.blogger.com/profile/15321268371583634243</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://2.bp.blogspot.com/_LNRxIF_pv1Y/SYXg40tbkrI/AAAAAAAACsc/LQoEMwdFeA8/S220/SEAGULL42.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-5910828497634830842</id><published>2008-07-10T15:17:00.004+05:30</published><updated>2008-07-10T15:24:02.238+05:30</updated><title type='text'>Hard disks and Elevators</title><content type='html'>&lt;div align="justify"&gt;Now, that's a weird title. What follows may sound absurd to some people. But having studied computer science, it makes sense to me. &lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;Many of us work in high rise buildings and more often than not, we take elevators to get to our places of work. My office building has 6 elevators, and 2 control switches - each switch, when pressed, sends request to 3 elevators and one of them eventually services the request. &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;Recalling from the operating systems course in engineering, the disk request scheduling algorithm heavily borrows from the algorithm used by elevators to service requests. Most of us computer literate people should know that the disk request scheduling algorithm tries to minimize the number of seeks and the distance per seek. The elevator behaves somewhat similarly. For any request, among many elevators receiving the request, the one closest to the origin-place of request services it. Also, if an elevator is already moving in the direction of the origin-place of the request, it handles the request instead of an idle elevator at the same level. &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;Now, if there was only one elevator in question, then its guaranteed that it would handle requests optimally. But with many elevators and more than one control switch to summon the elevators, the usage could become non-optimal, depending on how people use them. Some of the common things that people do that results in non-optimal usage are: &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;1) Summoning more than one elevator (activating more than one control switch) for one request&lt;/div&gt;&lt;div align="justify"&gt;2) Summoning a elevator(s) which are farther away from the origin-place of the request &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;Think of the elevators in your building as disks, all of them having the same data in them. The amount of distance the elevators need to travel before servicing a request as the seek of a disk. Since there is more than one elevator to choose from, we could choose one (and only one, not more than one! Refer point 1 above) which is closest to the place from which the request is being made. &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;Advantages: &lt;/div&gt;&lt;div align="justify"&gt;1) Avoids non-optimal usage - saves power! (GO GREEN!)&lt;/div&gt;&lt;div align="justify"&gt;2) Provides quicker service! &lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;Disadvantages: &lt;/div&gt;&lt;div align="justify"&gt;1) You could lose 5 seconds in looking at positions of all elevators before making a decision to summon a particular elevator - This could be offset by point 2 in advantages. Also, is 5 seconds too much, considering the slightly more weighed advantages?&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;br&gt;There are many places like these where we can apply knowledge of computer science, in our daily lives. Its surprising that most of us do not. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-5910828497634830842?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/5910828497634830842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=5910828497634830842' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5910828497634830842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5910828497634830842'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/07/hard-disks-and-elevators.html' title='Hard disks and Elevators'/><author><name>Srinivasa S</name><uri>https://profiles.google.com/105381729827549201767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-PD41JO_3KRE/AAAAAAAAAAI/AAAAAAAALOU/Xq-oqiUgbEo/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-2241358386477017086</id><published>2008-06-21T02:26:00.004+05:30</published><updated>2008-06-21T02:51:57.509+05:30</updated><title type='text'>Ways to manage RSS feeds</title><content type='html'>RSS feeds aim to manage the information load.&lt;br /&gt;&lt;br /&gt;I for example blog at these places :&lt;br /&gt;&lt;br /&gt;a) http://dinchari.blogspot.com/ --- my Personal blog &lt;br /&gt;b) http://puretechie.blogspot.com/ --- were a group of like minded tech enthusiasts post about topics of their interest. &lt;br /&gt;&lt;br /&gt;Ideally I would like my friends to have be updated with my thoughts on either blogs. Currently they have to refer to the individual rss feeds separately. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To ease matters, I have used Yahoo Pipes to create a combined RSS feed for the consumers as a single combined RSS feed.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pipes.yahoo.com/pipes/pipe.run?_id=yH0_vQk_3RGAydbXiHrL0A&amp;_render=rss"&gt;Click here for the new combined RSS link&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now this essentially is simple.&lt;br /&gt;&lt;br /&gt;We can develop on this use case extensively.&lt;br /&gt;&lt;br /&gt;Initially,&lt;br /&gt;a) Now in the tech blog: there are many other authors. With the above URL , the consumers will also get the updates from these other authors. There needs to be filtering mechanism based on Author.&lt;br /&gt;&lt;br /&gt;Adding more complexity,&lt;br /&gt;b) Suppose you like all my articles about the puzzles and are not interested in any other topics. This is where the whole thing gets tricky. Using filtering its possible, but I have to explore the capabilities of customizing to individual consumers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-2241358386477017086?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/2241358386477017086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=2241358386477017086' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2241358386477017086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2241358386477017086'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/06/ways-to-manage-rss-feeds.html' title='Ways to manage RSS feeds'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-2183526360308706912</id><published>2008-05-27T07:14:00.002+05:30</published><updated>2008-05-27T07:17:50.668+05:30</updated><title type='text'>Processing RSS feeds --the Python way</title><content type='html'>[shantanu@myjunkyard rss]$ cat a1.py&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;import feedparser&lt;br /&gt;import sys&lt;br /&gt;d = feedparser.parse(sys.argv[1])&lt;br /&gt;for i in d['entries']:&lt;br /&gt;        for j in i['links']:&lt;br /&gt;                print i['title'] + "######" + j['href']&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;[shantanu@myjunkyard rss]$ cat rssFeed.list&lt;br /&gt;http://puretechie.blogspot.com/atom.xml&lt;br /&gt;&lt;br /&gt;[shantanu@myjunkyard rss]$ for i in `cat rssFeed.list `; do ./a1.py $i; done&lt;br /&gt;&lt;br /&gt;See it Yourself :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-2183526360308706912?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/2183526360308706912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=2183526360308706912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2183526360308706912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2183526360308706912'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/05/processing-rss-feeds-python-way.html' title='Processing RSS feeds --the Python way'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3818366385144163304</id><published>2008-05-15T02:13:00.003+05:30</published><updated>2008-05-15T02:59:56.882+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ruby on Rails'/><title type='text'>Ruby on Rails --- it time</title><content type='html'>After many futile attempts RoR finally is happening this year.  Though I tried my best to use Java for the project(as usual , cox thats a comfort zone) , somehow winds changed direction.&lt;br /&gt;&lt;br /&gt;For statistics &lt;a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html"&gt;The TIOBE Programming Community index&lt;/a&gt; which gives an indication of the popularity of programming languages, ranks Ruby 10th in popularity with 2.66% of programmers.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My initial thoughts&lt;br /&gt;&lt;br /&gt;1) There is a need to think in  a language, understand its philosophy. An interesting story to share from RoR for dummies book about the name Ruby on Rails. Since the year 2000, teams of Java programmers have been using a framework named Struts. But the word strut means something in the construction industry. (A strut is a horizontal brace, and a sturdy one at that.) Well, a rail is also a kind of horizontal brace.&lt;br /&gt;And like Ruby, the word Rail begins with the letter R. Thus the name Ruby on Rails.&lt;br /&gt;&lt;br /&gt;2) Understanding MVC is ingrained &lt;br /&gt;http://wiki.rubyonrails.org/rails/pages/UnderstandingRailsMVC&lt;br /&gt;&lt;br /&gt;Best part of the language is that it forces MVC , similar to Java forcing OO.&lt;br /&gt;&lt;br /&gt;These are still baby steps , but has been exciting.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3818366385144163304?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3818366385144163304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3818366385144163304' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3818366385144163304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3818366385144163304'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/05/ruby-on-rails-it-time.html' title='Ruby on Rails --- it time'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-5792528600628932160</id><published>2008-05-13T01:06:00.004+05:30</published><updated>2008-05-13T01:23:08.455+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='semantic web'/><category scheme='http://www.blogger.com/atom/ns#' term='Natural Language'/><category scheme='http://www.blogger.com/atom/ns#' term='Twine'/><category scheme='http://www.blogger.com/atom/ns#' term='Twitter'/><title type='text'>Powerset is released today</title><content type='html'>&lt;a href="http://www.powerset.com"&gt;Powerset&lt;/a&gt; is a first of its kind .... a context sensitive natural language based search engine.&lt;br /&gt;Currently powered by Wikipedia, this is a potentially disruptive technology.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Simple queries like&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Where is PESIT?&lt;br /&gt;or &lt;br /&gt;vice chancellor of Visvesvaraya Technological University&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Interesting results!!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-5792528600628932160?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/5792528600628932160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=5792528600628932160' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5792528600628932160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5792528600628932160'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/05/powerset-is-released-today.html' title='Powerset is released today'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3353406731659403048</id><published>2008-04-11T17:06:00.002+05:30</published><updated>2008-04-11T17:35:23.806+05:30</updated><title type='text'>Punishment for 3 days.</title><content type='html'>For 3 days I was not able to access my system with my ID. &lt;br /&gt;&lt;br /&gt;I kinda circumvented the problem by allowing remote root ssh to my machine(which is criminal). &lt;br /&gt;&lt;br /&gt;The problem was this:&lt;br /&gt;root@shantanu&gt;ssh sg202516@shantanu&lt;br /&gt;Password:&lt;br /&gt;Last login: Fri Apr 11 17:19:51 2008 from shantanu&lt;br /&gt;NO LOGINS: System going down in 30 seconds&lt;br /&gt;Connection to shantanu closed.&lt;br /&gt;root@shantanu&gt;&lt;br /&gt;&lt;br /&gt;Untill today I was ok with it, but  I could not access my screen sessions remotely. &lt;br /&gt;&lt;br /&gt;So finally decided to debug it. &lt;br /&gt;&lt;br /&gt;The issue was the presence of a file called /etc/nologin&lt;br /&gt;&lt;br /&gt;root@shantanu&gt;cat /etc/nologin&lt;br /&gt;NO LOGINS: System going down in 30 seconds&lt;br /&gt;&lt;br /&gt;Removing the file solves the crap. &lt;br /&gt;&lt;br /&gt;With a feeling of achievement I told my neighbor about this.&lt;br /&gt;&lt;br /&gt;The reply came back "Check the date of the creation of the file. It should be Apr 8th. You had not locked the system!!!"&lt;br /&gt;&lt;br /&gt;Related Old link:http://dinchari.blogspot.com/2006/07/assholes-learn-this-way_27.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3353406731659403048?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3353406731659403048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3353406731659403048' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3353406731659403048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3353406731659403048'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2008/04/punishment-for-3-days.html' title='Punishment for 3 days.'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-8929485213805274382</id><published>2007-11-19T12:32:00.000+05:30</published><updated>2007-11-19T12:36:37.643+05:30</updated><title type='text'>Simple But intriguing</title><content type='html'>1) How does one create a file starting with hyphen(-)?&lt;br /&gt;2) How does one remove a file starting with hyphen(-)?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My Solution&lt;br /&gt;===========&lt;br /&gt;1)&lt;br /&gt;bash-2.05$touch a&lt;br /&gt;bash-2.05$tar cvf -c.tar a&lt;br /&gt;2)bash-2.05$ rm ./-c.tar&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-8929485213805274382?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/8929485213805274382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=8929485213805274382' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8929485213805274382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8929485213805274382'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/11/simple-but-intriguing.html' title='Simple But intriguing'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3578471130727671998</id><published>2007-10-27T04:39:00.000+05:30</published><updated>2007-10-27T04:51:15.918+05:30</updated><title type='text'>How can a host determine what address mask is in use on a remote host without logging in?</title><content type='html'>Interestingly, icmp is so powerful , that it can get us this information.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://faqs.org/rfcs/rfc792.html"&gt;RFC 792&lt;/a&gt;  does not mention about the Address Mask( or type 17/18). However &lt;a href="http://www.faqs.org/rfcs/rfc950.html"&gt;RFC 950&lt;/a&gt; has the inherent rationale(Section 2.3) for embedding this option in icmp.&lt;br /&gt;&lt;br /&gt;Using &lt;a href="http://nemesis.sourceforge.net/"&gt;nemesis &lt;/a&gt;the solution can be seen in action outright.&lt;br /&gt;&lt;br /&gt;&lt;snip&gt;&lt;br /&gt;&lt;br /&gt;@SOURCE_MACHINE&gt;/usr/local/bin/nemesis icmp -qM -i 17 -m 0  -S 129.158.224.205 -D 129.158.224.182 -H 0:3:ba:4e:40:44 -M 00:03:ba:5b:8f:5d&lt;br /&gt;&lt;br /&gt;ICMP Packet Injected&lt;br /&gt;&lt;br /&gt;@SOURCE_MACHINE&gt;snoop   icmp&lt;br /&gt;Using device /dev/eri (promiscuous mode)&lt;br /&gt;    SOURCE_MACHINE -&gt; DESTINATION_MACHINE      ICMP Address mask request&lt;br /&gt;    DESTINATION_MACHINE -&gt; SOURCE_MACHINE     ICMP Address mask reply (Mask = &lt;span style="font-weight:bold;"&gt;0xffffff00&lt;/span&gt;)&lt;br /&gt;^C@SOURCE_MACHINE&gt;&lt;br /&gt;&lt;/snip&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3578471130727671998?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3578471130727671998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3578471130727671998' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3578471130727671998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3578471130727671998'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/10/how-can-host-determine-what-address.html' title='How can a host determine what address mask is in use on a remote host without logging in?'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-873768322092241847</id><published>2007-10-18T19:05:00.000+05:30</published><updated>2007-10-18T20:00:39.066+05:30</updated><title type='text'>My failed experiment to detect nodes in Promiscious mode.</title><content type='html'>Basic Prerequisites: &lt;a href="http://en.wikipedia.org/wiki/Promiscuous_mode"&gt;Promiscuous mode&lt;/a&gt;,ARP, &lt;a href="http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol"&gt;ICMP&lt;/a&gt; and &lt;a href="http://www.security-freak.net/packet-injection/packet-injection.html"&gt;Packet Injection&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Problem:&lt;br /&gt;========&lt;br /&gt;The decision to accept/drop the network packets is controlled by the Network Interface Card(NIC). NIC filters out the desired packets which system is entitled to recieve. However by setting the NIC to promiscuous mode the sniffing application receives packets regardless of the system being the intended destination. Sniffing is a difficult problem to acertain as it does not interfere with the network traffic, leaving no digital traces to track.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My Approach in theory&lt;br /&gt;=====================&lt;br /&gt;A  “dynamic” protocol like Address Resolution Protocol (ARP) can be leveraged to detect the sniffing host. This protocol works alongside the Internet Protocol(IP) in Layer 3. On account of this ARP's operation occurs automatically in the background, without concern to the application user. &lt;br /&gt;&lt;br /&gt;ARP works by sending an address request and collecting the response to create its mapping of addresses. The hardware addresses are only needed for hosts on the local network. At the lowest level, the Ethernet driver needs the hardware address of the remote system to which it will send a packet. When it does not have that address, it “broadcasts” a request for the missing address. This request, called an “ARP request”, contains the IP address of the host in question and is sent to all systems on the local network. A system may respond with a reply, called an “ARP reply”, which contains the host IP address and hardware address. The response received is used to build a table of IP addresses and hardware addresses.&lt;br /&gt;&lt;br /&gt;Another feature of the protocol is called “gratuitous ARP”. This occurs when a host broadcasts an ARP request for its own hardware address. A Solaris system does this at boot time. It is used to detect if another system is using its IP address, indicating a misconfigured system. The other use of gratuitous ARP is to send updated&lt;br /&gt;hardware address information. Systems that receive requests like this will automatically update the hardware address information for that host.&lt;br /&gt;&lt;br /&gt;ARP by default uses BROADCAST method to get the destination MAC address. The idea here is to craft an ARP packet with the destination address being a non-BROADCAST address with a specific target IP address. If the NIC is in non-promiscuous mode, the packet is ignored and after the specified TTL no response is got back. However if the node with the corresponding IP address is in promiscuous mode, a prompt response is given by the sniffing host as the packet is percolated to the higher layers.&lt;br /&gt;&lt;br /&gt;Using a handcrafted packet like ICMP with appropriate fields can induce the same effect. &lt;br /&gt;&lt;br /&gt;References&lt;br /&gt;----------&lt;br /&gt;-Defeating Sniffers and Intrusion Detection Systems&lt;br /&gt;http://www.phrack.com/issues.html?issue=54&amp;id=10#article&lt;br /&gt;&lt;br /&gt;-Plummer, Dave. An Ethernet Address Resolution Protocol, RFC 826, Network&lt;br /&gt;Information Center, SRI International, Menlo Park, CA., November 1982.&lt;br /&gt;&lt;br /&gt;- Interetworking with TCP/IP VolumeII Design,Implementation and Internals. Douglas E. Comer/David L. Stevens&lt;br /&gt;&lt;br /&gt;-Solaris Operating Environment Network Settings for Security , By Alex Noordergraaf and KeithWatson&lt;br /&gt;http://www.sun.com/blueprints/1299/network.pdf&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The Reality ( Getting the hands dirty )&lt;br /&gt;=======================================&lt;br /&gt;Destination Machine&lt;br /&gt;===================&lt;br /&gt;@SOURCE-MACHINE&gt;ping DESTINATION-MACHINE&lt;br /&gt;DESTINATION-MACHINE is alive&lt;br /&gt;@ SOURCE-MACHINE&gt;arp -a | grep DESTINATION-MACHINE&lt;br /&gt;eri0   DESTINATION-MACHINE              255.255.255.255       00:03:ba:5b:8f:5d&lt;br /&gt;@SOURCE-MACHINE&gt;ping -s !$&lt;br /&gt;ping -s DESTINATION-MACHINE&lt;br /&gt;PING DESTINATION-MACHINE: 56 data bytes&lt;br /&gt;64 bytes from DESTINATION-MACHINE (129.158.224.182): icmp_seq=0. time=1.26 ms&lt;br /&gt;64 bytes from DESTINATION-MACHINE (129.158.224.182): icmp_seq=1. time=0.920 ms&lt;br /&gt;^C&lt;br /&gt;----DESTINATION-MACHINE PING Statistics----&lt;br /&gt;2 packets transmitted, 2 packets received, 0% packet loss&lt;br /&gt;round-trip (ms)  min/avg/max/stddev = 0.920/1.09/1.26/0.24&lt;br /&gt;@SOURCE-MACHINE&gt;&lt;br /&gt;&lt;br /&gt;Source Machine&lt;br /&gt;===================&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;@SOURCE-MACHINE&gt;hostname&lt;br /&gt;SOURCE-MACHINE  &lt;br /&gt;@SOURCE-MACHINE&gt;ifconfig -a&lt;br /&gt;lo0: flags=2001000849&lt;UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL&gt; mtu 8232 index 1&lt;br /&gt;        inet 127.0.0.1 netmask ff000000&lt;br /&gt;eri0: flags=1000843&lt;UP,BROADCAST,RUNNING,MULTICAST,IPv4&gt; mtu 1500 index 2&lt;br /&gt;        inet 129.158.224.205 netmask ffffff00 broadcast 129.158.224.255&lt;br /&gt;        ether 0:3:ba:4e:40:44&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;Packet Injection&lt;br /&gt;=================&lt;br /&gt;&lt;br /&gt;@SOURCE-MACHINE&gt;/usr/local/bin/nemesis icmp -S 129.158.224.205 -D 129.158.224.182 -H 0:3:ba:4e:40:44 -M 00:03:ba:5b:8f:5d&lt;br /&gt;&lt;br /&gt;ICMP Packet Injected&lt;br /&gt;@SOURCE-MACHINE&gt;&lt;br /&gt;&lt;br /&gt;@SOURCE-MACHINE&gt;snoop icmp&lt;br /&gt;&lt;br /&gt;    SOURCE-MACHINE -&gt; DESTINATION-MACHINE      ICMP Echo request (ID: 15815 Sequence number: 46167)&lt;br /&gt;     DESTINATION-MACHINE -&gt; SOURCE-MACHINE     ICMP Echo reply (ID: 15815 Sequence number: 46167)&lt;br /&gt;&lt;br /&gt;Now sending a wrong MAC address to Destination  ( last letter changed from d to e )&lt;br /&gt;&lt;br /&gt;@SOURCE-MACHINE&gt;/usr/local/bin/nemesis icmp -S 129.158.224.205 -D 129.158.224.182 -H 0:3:ba:4e:40:44 -M 00:03:ba:5b:8f:5e&lt;br /&gt;&lt;br /&gt;ICMP Packet Injected&lt;br /&gt;&lt;br /&gt;@SOURCE-MACHINE&gt;snoop icmp&lt;br /&gt;Using device /dev/eri (promiscuous mode)&lt;br /&gt;    SOURCE-MACHINE -&gt; DESTINATION-MACHINE      ICMP Echo request (ID: 12112 Sequence number: 10553)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Interesting thing to note was that the Packet was seen in the snoop output on DESTINATION-MACHINE but was not replied.&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;There goes the failed experiment. Reality turns out to be different than the assumed theory.  Digging further as to how snoop manages to get a snapshot of the packet and   not process the packet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-873768322092241847?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/873768322092241847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=873768322092241847' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/873768322092241847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/873768322092241847'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/10/my-failed-experiment-to-detect-nodes-in.html' title='My failed experiment to detect nodes in Promiscious mode.'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-8406572281453074088</id><published>2007-10-04T09:02:00.000+05:30</published><updated>2007-10-04T09:15:40.244+05:30</updated><title type='text'>Getting the Kth smallest element in two Sorted Lists</title><content type='html'>Problem&lt;br /&gt;--------&lt;br /&gt;Let A and B be two sorted arrays. The intent is to find the kth smallest number in the union of the two lists. &lt;br /&gt;&lt;br /&gt;Sounds Simple, but the catch is to get it done with a better time complexity than O(size(A) + size(B)). &lt;br /&gt;&lt;br /&gt;I now have the solution which works with O(log(size(A) + size(B)), but i gave a crappy solution to my friend who gave me this puzzle. I used the intuitive, 2 pointer solution. Dont fall for it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-8406572281453074088?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/8406572281453074088/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=8406572281453074088' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8406572281453074088'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8406572281453074088'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/10/getting-kth-smallest-element-in-two.html' title='Getting the Kth smallest element in two Sorted Lists'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-6184015397995735423</id><published>2007-10-02T13:15:00.000+05:30</published><updated>2007-10-02T13:19:02.799+05:30</updated><title type='text'>Implementing a queue with 2 Stacks</title><content type='html'>Interesting, but intuitive question.&lt;br /&gt;&lt;br /&gt;My Solution:-&lt;br /&gt;&lt;br /&gt;//QueueWith2Stacks.java&lt;br /&gt;&lt;br /&gt;import java.util.Stack;&lt;br /&gt;&lt;br /&gt;public class QueueWith2Stacks {&lt;br /&gt; &lt;br /&gt; Stack&lt;  Object&gt; insertStack=new Stack&lt;   Object&gt;();&lt;br /&gt; Stack&lt;  Object&gt; popStack=new Stack&lt; Object&gt;();&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; void enqueue(Object element){&lt;br /&gt;  insertStack.push(element);&lt;br /&gt; }&lt;br /&gt; Object dequeue(){&lt;br /&gt;  if(popStack.empty()&amp;&amp; insertStack.empty())&lt;br /&gt;   return(null);  &lt;br /&gt;  if(popStack.empty())//This is the only interesting part about it.&lt;br /&gt;   while(!insertStack.empty())&lt;br /&gt;    popStack.push(insertStack.pop());   &lt;br /&gt;  return(popStack.pop());  &lt;br /&gt; }&lt;br /&gt; void display(){&lt;br /&gt;  System.out.println(popStack.toString()+insertStack.toString());&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-6184015397995735423?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/6184015397995735423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=6184015397995735423' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6184015397995735423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6184015397995735423'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/10/implementing-queue-with-2-stacks.html' title='Implementing a queue with 2 Stacks'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-2042174223132516119</id><published>2007-08-12T21:16:00.000+05:30</published><updated>2007-08-12T21:58:32.717+05:30</updated><title type='text'>Configuring SSO</title><content type='html'>After analyzing &lt;a href="http://www.josso.org/"&gt;JOSSO &lt;/a&gt;and &lt;a href="http://www.ja-sig.org/products/cas/"&gt;CAS&lt;/a&gt;  as candidates for SSO , the JOSSO implementation seems very promising. &lt;br /&gt;What is &lt;a href="http://en.wikipedia.org/wiki/Single_sign-on"&gt; SSO&lt;/a&gt; ? &lt;br /&gt;&lt;br /&gt;Josso&lt;br /&gt;-----&lt;br /&gt;&lt;br /&gt;Positives&lt;br /&gt;--------------------&lt;br /&gt;1) Just works. Can easily embed my application to the SSO framework.&lt;br /&gt;2) Out-of-the box seem less integration with custom made tomcat. Inbuilt SSL configurations. &lt;br /&gt;3) To-Do steps &lt;br /&gt;   i) Download &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=116854"&gt;Josso tomcat&lt;/a&gt;&lt;br /&gt;   ii) Refer to http://www.josso.org/tomcat55-howto.html&lt;br /&gt;   iii) JAVA_OPTS=-Djava.security.auth.login.config=..\conf\jaas.conf (Spent a romantic night for this. Had to write it )&lt;br /&gt;  iv) For getting the login data from the DB refer to &lt;a href="http://www.josso.org/developer-howto.html"&gt;this &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Negatives &lt;br /&gt;--------------------&lt;br /&gt;1) Pathetic Docs&lt;br /&gt;2) In-active community.&lt;br /&gt;&lt;br /&gt;CAS&lt;br /&gt;---&lt;br /&gt;I could not get CAS working on my system. I know it works, but somehow the jigsaw is not complete. The community is very active and vibrant.Updated wiki . Let me know if  anyone gets it working.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-2042174223132516119?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/2042174223132516119/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=2042174223132516119' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2042174223132516119'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2042174223132516119'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/08/configuring-sso.html' title='Configuring SSO'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4904341807613765561</id><published>2007-08-09T19:21:00.000+05:30</published><updated>2007-08-09T20:26:35.712+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><category scheme='http://www.blogger.com/atom/ns#' term='Bug Fix'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>"C" the Bug - Part I</title><content type='html'>1. Find the bug.&lt;br /&gt;&lt;br /&gt;All necessary Headers included like stdio.h, stdlib.h, string.h etc.&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; char *str = NULL;&lt;br /&gt; int i = 1;&lt;br /&gt; str = (char*)malloc(sizeof(char)*2);&lt;br /&gt; if(!str) {&lt;br /&gt;   printf("Malloc Failed\n");&lt;br /&gt;   exit(1);&lt;br /&gt; }&lt;br /&gt; strcpy(str, "Hi");&lt;br /&gt; printf("%c\n", str[i*i+i/i]);&lt;br /&gt; str = (char *)realloc(str, sizeof(char)*20);&lt;br /&gt; if(!str) {&lt;br /&gt;   printf("Realloc Failed\n");&lt;br /&gt;   exit(1);&lt;br /&gt; }&lt;br /&gt; strcpy(str, "Hello World\n");&lt;br /&gt; i = 2;&lt;br /&gt; printf("%c\n", str[i*i+i/i]);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2. In a doubly linked list, the nodes are paired and these pairs have to be reversed.&lt;br /&gt;&lt;br /&gt;For Ex: If the linked is as below,&lt;br /&gt;1--2--3--4--5--6&lt;br /&gt;Output should be:&lt;br /&gt;5--6--3--4--1--2&lt;br /&gt;&lt;br /&gt;Struct is as below:&lt;br /&gt;typedef struct node {&lt;br /&gt; int data;&lt;br /&gt; struct node *next;&lt;br /&gt; struct node *prev;&lt;br /&gt;} NODE;&lt;br /&gt;&lt;br /&gt;Handle all the conditions. This question was asked in Microsoft Interview.&lt;br /&gt;Deadline is on 18th Aug 2007.&lt;br /&gt;Send it to me at arvind.bhushan@gmail.com or post in the comment. &lt;br /&gt;&lt;br /&gt;Challenging the Code&lt;br /&gt;--------------------&lt;br /&gt;* You need to have trust in me.&lt;br /&gt;* Specify in your mail or comments as "Challenge".&lt;br /&gt;* Rs.50/person.&lt;br /&gt;* Max. challenge amount = Rs.(No. of Persons challenging * 50). Conditions Apply.&lt;br /&gt;* If your code breaks under any conditions, you will lose the amount.&lt;br /&gt;* If your code works smooth, you will win the Total Challenged amount.&lt;br /&gt;#Note#&lt;br /&gt;The challenge amount increases if anyone supports me. Specify in your mail or comments as "Support". For those supporting me will definitely get a share if someone loses the challenge.&lt;br /&gt;&lt;br /&gt;If not interested in challenge or support, you can also mail or post comment as "Fun".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4904341807613765561?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4904341807613765561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4904341807613765561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4904341807613765561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4904341807613765561'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/08/c-bug-part-i.html' title='&quot;C&quot; the Bug - Part I'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-5492084662912840615</id><published>2007-08-03T10:05:00.000+05:30</published><updated>2007-08-03T10:23:54.746+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Templates'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Curiously Recurring Template Pattern (CRTP)</title><content type='html'>The funny named phrase is used to describe the use of a derived class type as a template parameter for its own base class! In simplest form, this is what I'm talking about:&lt;br /&gt;&lt;br /&gt;template &lt;&amp;nbsp;typename T&amp;nbsp;&gt;&lt;br /&gt;class  Base{ };&lt;br /&gt;&lt;br /&gt;class Derived : public Base&lt;&amp;nbsp;Derived&amp;nbsp;&gt; { };&lt;br /&gt;&lt;br /&gt;Let me give a very simple example of where this might be useful. Suppose you want to keep track of how many objects of a particular class are alive at any point in time:&lt;br /&gt;&lt;br /&gt;Simple approach is:&lt;br /&gt;1) Keep a private static "count" member in the class&lt;br /&gt;2) Increment the count in every constructor&lt;br /&gt;3) Decrement the count in the destructor&lt;br /&gt;4) Provide a public interface to query the value of the count&lt;br /&gt;&lt;br /&gt;This approach is fine. However you have to do this for every class that you want to count the objects of. CRTP can pitch in and provide an elegant solution that is highly reusable.&lt;br /&gt;&lt;br /&gt;template &lt;&amp;nbsp;typename CountedType&amp;nbsp;&gt;&lt;br /&gt;class ObjectCounter&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;private:  &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static int counter; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;protected:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectCounter()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;++( ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;::counter );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ObjectCounter( const ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;&amp; obj )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;++( ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;::counter );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;~ObjectCounter()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;--( ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;::counter );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;public:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;static int live()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;::counter;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;template &lt;&amp;nbsp;typename CountedType&amp;nbsp;&gt;&lt;br /&gt;int ObjectCounter&lt;&amp;nbsp;CountedType&amp;nbsp;&gt;::counter = 0;&lt;br /&gt;&lt;br /&gt;Any class that wants to do object counting will inherit from the above class as follows:&lt;br /&gt;&lt;br /&gt;class TestClass : public ObjectCounter&lt;&amp;nbsp;TestClass&amp;nbsp;&gt;{ };&lt;br /&gt;&lt;br /&gt;TestClass::live() will give the number of objects alive at that point in time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-5492084662912840615?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/5492084662912840615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=5492084662912840615' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5492084662912840615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5492084662912840615'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/08/curiously-recurring-template-pattern.html' title='Curiously Recurring Template Pattern (CRTP)'/><author><name>Srinivasa S</name><uri>https://profiles.google.com/105381729827549201767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-PD41JO_3KRE/AAAAAAAAAAI/AAAAAAAALOU/Xq-oqiUgbEo/s512-c/photo.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-5880354725559468236</id><published>2007-07-13T17:30:00.000+05:30</published><updated>2007-07-13T19:06:24.820+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='hang'/><category scheme='http://www.blogger.com/atom/ns#' term='ACPI'/><category scheme='http://www.blogger.com/atom/ns#' term='SuSE'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='DSDT. Power Management'/><category scheme='http://www.blogger.com/atom/ns#' term='boot'/><title type='text'>American Way v/s Russian Way</title><content type='html'>The joke is that America [NASA] spent millions of dollars on developing a pen that would write in outer space, while the Russian Cosmonauts simply used pencils.&lt;br /&gt;&lt;br /&gt;The below mail conversation would tell why I mentioned the above joke. &lt;br /&gt;[American Way]&lt;br /&gt;&lt;br /&gt;Hi KKK,&lt;br /&gt;&lt;br /&gt;After several installations of SuSE Linux Enterprise Server-10 Service Pack-1 on the new test machine, still the system hangs.&lt;br /&gt;I analyzed the error and found that it is a problem with the &lt;a href="http://www.acpi.info/DOWNLOADS/ACPIspec30a.pdf"&gt;ACPI &lt;/a&gt;[Advanced Configuration and Power Interface].&lt;br /&gt;&lt;br /&gt;Below is my analysis and a pointer to resolving it.&lt;br /&gt;&lt;br /&gt;Error found in /var/log/messages [ command is dmesg ]&lt;br /&gt;------------------------------------------------------&lt;br /&gt;ACPI: DSDT (v001 INTEL  DQ965GF  0x000016f2 MSFT 0x01000013) @ 0x0000000000000000&lt;br /&gt;&lt;br /&gt;The above message says there is a bug in DSDT.&lt;br /&gt;&lt;br /&gt;what is DSDT ?&lt;br /&gt;Differentiated System Description Table (DSDT)&lt;br /&gt;An OEM must supply a DSDT to an ACPI-compatible OS. The DSDT contains the Differentiated Definition Block,&lt;br /&gt;which supplies the implementation and configuration information about the base system.&lt;br /&gt;The OS always inserts the DSDT information into the ACPI Namespace at system boot time and never removes it.&lt;br /&gt;&lt;br /&gt;Basically, what this boils down to is that the DSDT describes the configuration of your system.&lt;br /&gt;It has definitions of all of the devices that ACPI supports, and describes their capabilities.&lt;br /&gt;&lt;br /&gt;The above problem can be resolved as follows :&lt;br /&gt;&lt;br /&gt;#cat /proc/acpi/dsdt &gt; /home/yourname/dsdt.dat&lt;br /&gt;#cd /usr/bin&lt;br /&gt;#./iasl -d /home/yourname/dsdt.dat&lt;br /&gt;&lt;br /&gt;This will create a file called dsdt.dsl, which contains the disassembled DSDT.&lt;br /&gt;Copy this file from /usr/sbin to /home/yourname as we are going to work on it.&lt;br /&gt;&lt;br /&gt;Recompile the DSDT.&lt;br /&gt;# cd /usr/bin&lt;br /&gt;# ./iasl -tc /home/yourname/dsdt.dsl&lt;br /&gt;&lt;br /&gt;While compilation 1 error appears as below:&lt;br /&gt;XXXTSTMC1:/usr/bin # ./iasl -tc /home/XXX/dsdt.dsl&lt;br /&gt;&lt;br /&gt;Intel ACPI Component Architecture&lt;br /&gt;ASL Optimizing Compiler version 20060127 [Jun 16 2006]&lt;br /&gt;Copyright (C) 2000 - 2006 Intel Corporation&lt;br /&gt;Supports ACPI Specification Revision 3.0a&lt;br /&gt;&lt;br /&gt;/home/XXX/dsdt.dsl    90:                 Store (0x01, \_SB.TCOI.IGFX.SCIS)&lt;br /&gt;Error    1061 -                                        Object does not exist ^  (\_SB.TCOI.IGFX.SCIS)&lt;br /&gt;&lt;br /&gt;ASL Input:  /home/XXX/dsdt.dsl - 5195 lines, 178611 bytes, 1658 keywords&lt;br /&gt;Compilation complete. 1 Errors, 0 Warnings, 0 Remarks, 566 Optimizations&lt;br /&gt;which can be fixed by removing the line 90 in the file. [ not sure about the fix, but works fine].&lt;br /&gt;&lt;br /&gt;We get 2 files namely, dsdt.hex and dsdt.aml&lt;br /&gt;&lt;br /&gt;There are 2 methods to incorporate the files built above into the kernel which is best described&lt;br /&gt;at this &lt;a href="http://forums.gentoo.org/viewtopic.php?t=122145"&gt; Discussion Forum &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Basically, we have to recompile the kernel every time we install it, which is not usually recommended.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;-XXX&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Reply to this mail : [Russian Way]&lt;br /&gt;&lt;br /&gt;My 2 cents here:&lt;br /&gt;&lt;br /&gt;What if we pass "acpi=off" to the kernel command line? :)&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;-YYY&lt;br /&gt;&lt;br /&gt;Passing commands to &lt;a href="http://en.opensuse.org/SDB:Inserting_Boot_Options_Permanently"&gt; Kernel &lt;/a&gt; on Linux.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-5880354725559468236?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/5880354725559468236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=5880354725559468236' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5880354725559468236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5880354725559468236'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/07/american-way-vs-russian-way.html' title='American Way v/s Russian Way'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-421030875363815712</id><published>2007-06-30T20:15:00.001+05:30</published><updated>2007-06-30T20:19:19.096+05:30</updated><title type='text'>mozilla &amp; stumble</title><content type='html'>First of all, sorry for a lengthy inactive period&lt;br /&gt;&lt;br /&gt;Second, I dono if somebody else has already reported this...&lt;br /&gt;&lt;br /&gt;I tried installing Stumble on my yet unupdated Mozilla 1.5.0.1.2&lt;br /&gt;&lt;br /&gt;It kept saying "Software installation is currently disabled. Click "edit options" on the right, enable it and then try again"&lt;br /&gt;&lt;br /&gt;And it gave me a small edit options box...Clickin on it produced the "Contents" tab in Mozilla's preferences box. That didn't help too much. So googled it up and found the following :&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Enabling software installs&lt;/h3&gt; &lt;p&gt;Some users may have disabled the software installation option based on security issues which have since been resolved &lt;a href="http://www.mozilla.org/security/announce/mfsa2005-42.html" class="external autonumber" title="http://www.mozilla.org/security/announce/mfsa2005-42.html" rel="nofollow"&gt;[1]&lt;/a&gt;. To re-enable: &lt;/p&gt;&lt;p&gt;&lt;b&gt;Firefox 1.5&lt;/b&gt;: If you previously disabled this option and then updated to Firefox 1.5, the disabled setting will be carried over. Since the option to enable software installation no longer exists in the interface, you will need to: &lt;/p&gt; &lt;ol&gt;&lt;li&gt; Type &lt;b&gt;about:config&lt;/b&gt; in the Location Bar and hit enter.  &lt;/li&gt;&lt;li&gt; Type &lt;b&gt;xpi&lt;/b&gt;  in the Filter box and find &lt;b&gt;xpinstall.enabled&lt;/b&gt; in the list.  &lt;/li&gt;&lt;li&gt; Make sure its value is set to "true" (double-click will toggle)&lt;/li&gt;&lt;/ol&gt;http://kb.mozillazine.org/Unable_to_install_themes_or_extensions_(Firefox)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You mite find some other raw config options in "about:config" ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-421030875363815712?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/421030875363815712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=421030875363815712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/421030875363815712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/421030875363815712'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/mozilla-stumble.html' title='mozilla &amp; stumble'/><author><name>Murali</name><uri>http://www.blogger.com/profile/05655502176891047744</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4379768799739650722</id><published>2007-06-28T22:21:00.000+05:30</published><updated>2007-06-28T22:22:13.702+05:30</updated><title type='text'>From PVR Cinemas.com</title><content type='html'>when i clicked on online booking, i get this&lt;br /&gt;&lt;br /&gt;"Please wait....&lt;br /&gt;&lt;br /&gt;PVRDB.Database.1 error '80020009'&lt;br /&gt;&lt;br /&gt;Transaction (Process ID 67) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.&lt;br /&gt;&lt;br /&gt;/pvr/include/login_redirect.asp, line 48 "&lt;br /&gt;&lt;br /&gt;Thank you!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4379768799739650722?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4379768799739650722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4379768799739650722' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4379768799739650722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4379768799739650722'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/from-pvr-cinemascom.html' title='From PVR Cinemas.com'/><author><name>Girish</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://photos1.blogger.com/img/262/5574/640/my1.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-761795426302280645</id><published>2007-06-24T19:36:00.000+05:30</published><updated>2007-06-24T20:18:06.985+05:30</updated><title type='text'>Patching a Hardware Bug</title><content type='html'>What do you do when you find a bug in a software ? Simple ! Find a solution and release a patch. But what if a hardware has bug ? Again, find a solution and release the patch ! Surprised ?? Just read through this &lt;a href="http://www.technologyreview.com/Infotech/18513/"&gt;article&lt;/a&gt; posted on MIT Tech Review.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-761795426302280645?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/761795426302280645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=761795426302280645' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/761795426302280645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/761795426302280645'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/patching-hardware-bug.html' title='Patching a Hardware Bug'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-7453761074709463961</id><published>2007-06-24T13:00:00.000+05:30</published><updated>2007-06-24T13:16:07.821+05:30</updated><title type='text'>Operating Systems...</title><content type='html'>well, we have read many definitions of operating systems based on its role.&lt;br /&gt;one, as a "facilitator" for applications development.&lt;br /&gt;two, as a "manager" of hardware, core routines(processes/daemons,and hence software), imposing security/protection of itself and the hardware it manages.&lt;br /&gt;&lt;br /&gt;here is one definition where the OS is defined based on its objective. Its from the Project Oberon notes...&lt;br /&gt;&lt;br /&gt;"The fundamental objective of an operating system is to present the computer to the user and to the programmer at a certain level of abstraction."&lt;br /&gt;&lt;br /&gt;phew!!! this one defines the complexity, role and the objective of an OS. This definition also gives the implementer freedom to design his OS the way he wants to, based on wat level of abstraction he wants to give his "user and programmer". Nice place to start building one!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-7453761074709463961?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/7453761074709463961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=7453761074709463961' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7453761074709463961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7453761074709463961'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/operating-systems.html' title='Operating Systems...'/><author><name>Girish</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://photos1.blogger.com/img/262/5574/640/my1.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4316079823635171399</id><published>2007-06-11T08:44:00.000+05:30</published><updated>2007-06-11T08:59:28.877+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='select linux solaris'/><title type='text'>Is this implementation of select() syscall in Linux correct?</title><content type='html'>Here is the code&lt;br /&gt;linuxMachine:/tmp # uname -a&lt;br /&gt;Linux linuxMachine 2.4.21-309.PTF.97199.1-smp #1 SMP Mon Jul 24 12:20:00 UTC 2006 i686 unknown&lt;br /&gt;linuxMachine:/tmp # cat testSelectCall.c&lt;br /&gt;#include "stdio.h"&lt;br /&gt;#include "sys/time.h"&lt;br /&gt;#include "sys/types.h"&lt;br /&gt;#include "unistd.h"&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;main(void) {&lt;br /&gt;    fd_set rfds;&lt;br /&gt;    struct timeval tv;&lt;br /&gt;    int retval;&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;    FD_ZERO(&amp;rfds);&lt;br /&gt;    FD_SET(0, &amp;rfds);&lt;br /&gt;    &lt;br /&gt;    tv.tv_sec = 5;&lt;br /&gt;    tv.tv_usec = 0;&lt;br /&gt;&lt;br /&gt;    retval = select(1, &amp;rfds, NULL, NULL, &amp;tv);&lt;br /&gt;    /* Here is the tricky part! */&lt;br /&gt;&lt;br /&gt;    printf("tv.tv_sec=%i\n",tv.tv_sec);&lt;br /&gt;    printf("tv.tv_usec=%i\n",tv.tv_usec);&lt;br /&gt;    if (retval)&lt;br /&gt;        printf("Data is available now.\n");&lt;br /&gt;    else&lt;br /&gt;        printf("No data within five seconds.\n");&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;linuxMachine:/tmp # !gcc&lt;br /&gt;gcc testSelectCall.c&lt;br /&gt;linuxMachine:/tmp # !time&lt;br /&gt;time ./a.out&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;tv.tv_sec=0&lt;br /&gt;tv.tv_usec=0&lt;/span&gt;&lt;br /&gt;No data within five seconds.&lt;br /&gt;&lt;br /&gt;real    0m5.000s&lt;br /&gt;user    0m0.000s&lt;br /&gt;sys     0m0.000s&lt;br /&gt;linuxMachine:/tmp #&lt;br /&gt;&lt;br /&gt;On a solaris box&lt;br /&gt;&lt;br /&gt;solarisBox&gt;uname -a&lt;br /&gt;SunOS solarisBox 5.10 Generic_118835-02 sun4u sparc SUNW,Sun-Blade-100&lt;br /&gt;solarisBox&gt;gcc testSelectCall.c&lt;br /&gt;solarisBox&gt;!time&lt;br /&gt;time ./a.out&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;tv.tv_sec=5&lt;br /&gt;tv.tv_usec=0&lt;/span&gt;&lt;br /&gt;No data within five seconds.&lt;br /&gt;&lt;br /&gt;real    0m5.025s&lt;br /&gt;user    0m0.003s&lt;br /&gt;sys     0m0.010s&lt;br /&gt;solarisBox&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Man Page has the following description&lt;br /&gt; man 2 select&lt;br /&gt;&lt;snip&gt;&lt;br /&gt; Some code calls select with all three sets empty, n zero, and a  non-null&lt;br /&gt;       timeout as a fairly portable way to sleep with subsecond precision.&lt;br /&gt;&lt;br /&gt;       On  Linux,  the function select modifies timeout to reflect the amount of&lt;br /&gt;       time not slept; most other implementations do not do this.   This  causes&lt;br /&gt;       problems  both  when  Linux  code  which reads timeout is ported to other&lt;br /&gt;       operating systems, and when code is ported to Linux that reuses a  struct&lt;br /&gt;       timeval  for  multiple selects in a loop without reinitializing it.  Con�&lt;br /&gt;       sider timeout to be undefined after select returns.&lt;br /&gt;&lt;/snip&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4316079823635171399?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4316079823635171399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4316079823635171399' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4316079823635171399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4316079823635171399'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/is-this-implementation-of-select.html' title='Is this implementation of select() syscall in Linux correct?'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3965284775536327928</id><published>2007-06-04T22:39:00.000+05:30</published><updated>2007-06-04T23:04:57.293+05:30</updated><title type='text'>Microsoft announces surface</title><content type='html'>I am sure, many are aware of it. In case you haven't then check this out&lt;br /&gt;&lt;br /&gt;http://www.microsoft.com/surface/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3965284775536327928?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3965284775536327928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3965284775536327928' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3965284775536327928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3965284775536327928'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/06/microsoft-announces-surface.html' title='Microsoft announces surface'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-6901323748182579933</id><published>2007-05-30T21:52:00.001+05:30</published><updated>2007-05-30T22:03:17.817+05:30</updated><title type='text'>Play it on TV</title><content type='html'>I was thinking about how to watch movies stored on my computer on TV screen, without much investments. &lt;br /&gt;The major problem is that most movies are stored on computer in different formats and players are freely available to install and run. If you want them to play, need to have a DVD/CD player with right set of decoders or use converters to DVD format, not a cost &amp; time saving one's.&lt;br /&gt;Found this &lt;a href="http://www.cinemanow.com/pclaptop1.aspx?grpID=1001"&gt;cool stuff &lt;/a&gt;on the net about how to play movies on your computer on TV.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-6901323748182579933?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/6901323748182579933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=6901323748182579933' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6901323748182579933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6901323748182579933'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/05/play-it-on-tv.html' title='Play it on TV'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-1214211165818759730</id><published>2007-05-30T02:04:00.000+05:30</published><updated>2007-05-30T02:22:43.745+05:30</updated><title type='text'>Getting shell script variable values</title><content type='html'>Here is the problem&lt;br /&gt;&lt;br /&gt;bash-2.05# cat test1.sh&lt;br /&gt;ATM_PIN="123"&lt;br /&gt;echo "Environment variables" &gt; out.log&lt;br /&gt;env &gt;&gt; out.log&lt;br /&gt;echo $ATM_PIN&lt;br /&gt;&lt;br /&gt;bash-2.05# sh test1.sh&lt;br /&gt;123&lt;br /&gt;&lt;br /&gt;bash-2.05# cat out.log |grep -i atm&lt;br /&gt;bash-2.05#&lt;br /&gt;&lt;br /&gt;While debugging a shell script, if the values of the variables are required in an intermittent state of the shell script execution use the -a option.&lt;br /&gt;&lt;br /&gt;bash-2.05# sh -a test1.sh&lt;br /&gt;123&lt;br /&gt;bash-2.05# cat out.log |grep -i atm&lt;br /&gt;ATM_PIN=123&lt;br /&gt;bash-2.05#&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-1214211165818759730?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/1214211165818759730/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=1214211165818759730' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1214211165818759730'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/1214211165818759730'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/05/getting-shell-script-variable-values.html' title='Getting shell script variable values'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-3175785228023708763</id><published>2007-05-17T13:43:00.000+05:30</published><updated>2007-05-17T15:01:15.047+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='rsh linux password less access'/><title type='text'>Configuring rsh service on Linux</title><content type='html'>By default the rsh service is not enabled (obviously).&lt;br /&gt;&lt;br /&gt;So here are the steps&lt;br /&gt;&lt;br /&gt;1. Check if the rpms are installed. (else use the cd's to install)&lt;br /&gt;redhat# rpm -qa|grep rsh&lt;br /&gt;rsh-server-0.17-25.4&lt;br /&gt;rsh-0.17-25.4&lt;br /&gt;redhat#&lt;br /&gt;2. In  /etc/xinetd.d/rsh set disable = no&lt;br /&gt;3. Edit the following files&lt;br /&gt;&lt;br /&gt;redhat# cat /etc/hosts.allow&lt;br /&gt;#&lt;br /&gt;# hosts.allow   This file describes the names of the hosts which are&lt;br /&gt;#               allowed to use the local INET services, as decided&lt;br /&gt;#               by the '/usr/sbin/tcpd' server.&lt;br /&gt;#&lt;br /&gt;ALL : localhost/hostA&lt;br /&gt;redhat# cat /etc/hosts.equiv&lt;br /&gt;localhost&lt;br /&gt;redhat# cat .rhosts&lt;br /&gt;+  user1&lt;br /&gt;&lt;br /&gt;4. /etc/init.d/xinetd restart&lt;br /&gt;5. Test the above&lt;br /&gt;redhat# rsh localhost&lt;br /&gt;redhat# &lt;br /&gt;//password less login to remote machine&lt;br /&gt;&lt;br /&gt;Disclaimer: more secure services like ssh are recommended than services like rsh.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-3175785228023708763?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/3175785228023708763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=3175785228023708763' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3175785228023708763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/3175785228023708763'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/05/configuring-rsh-service-on-linux.html' title='Configuring rsh service on Linux'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-7405325509338464397</id><published>2007-04-29T17:17:00.000+05:30</published><updated>2007-04-29T17:18:14.824+05:30</updated><title type='text'>Having a private snmp number for ones organization ..... No fee invovled</title><content type='html'>http://pen.iana.org/pen/PenApplication.page&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-7405325509338464397?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/7405325509338464397/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=7405325509338464397' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7405325509338464397'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7405325509338464397'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/04/having-private-snmp-number-for-ones.html' title='Having a private snmp number for ones organization ..... No fee invovled'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-5649961287295645689</id><published>2007-03-30T21:48:00.001+05:30</published><updated>2007-03-30T21:58:11.190+05:30</updated><title type='text'>How does one sort the files based on size in Unix ???</title><content type='html'>Again elementary but not used much&lt;br /&gt;&lt;br /&gt;ls does not give an option to sort the files based on file sizes. (some os have -S option not sure which)&lt;br /&gt;&lt;br /&gt;Here is a way to do it in a very generic way&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;bash-2.05# ls -hl /tmp/a.out /tmp/test.c |sort -k 4 -n&lt;br /&gt;-rw-r--r--   1 root     other          0 Mar 30 21:41 /tmp/a.out&lt;br /&gt;-rw-r--r--   1 root     other        108 Mar 29 11:49 /tmp/test.c&lt;br /&gt;&lt;br /&gt;sort -k &lt;position&gt; does the trick. So position can be any column in the output.&lt;br /&gt;For more details &lt;span style="font-weight: bold;"&gt;man sort &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/position&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-5649961287295645689?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/5649961287295645689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=5649961287295645689' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5649961287295645689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/5649961287295645689'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/how-does-one-sort-files-based-on-size.html' title='How does one sort the files based on size in Unix ???'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-242993147783179417</id><published>2007-03-28T01:20:00.000+05:30</published><updated>2007-03-28T02:04:42.998+05:30</updated><title type='text'>Debugging tomcat applications using IDE's</title><content type='html'>Problem:&lt;br /&gt;You have deployed your war file into tomcat. You have the source code, but you cannot innitate a DEBUG from the IDE(Eclipse or Netbeans). How does one debug?&lt;br /&gt;&lt;br /&gt;Solution:&lt;br /&gt;Run tomcat in DEBUG mode&lt;br /&gt;&lt;br /&gt;WINDOWS&lt;br /&gt;    EDIT %CATALINA_HOME%/bin/catalina.bat&lt;br /&gt;    set JAVA_OPTS=-Xdebug   -Xrunjdwp:server=y,transport=dt_socket,address=3091,suspend=n&lt;br /&gt;&lt;br /&gt;UNIX&lt;br /&gt;&lt;br /&gt;  EDIT $CATALINA_HOME/bin/catalina.sh&lt;br /&gt;  JAVA_OPTS=-Xdebug   -Xrunjdwp:server=y,transport=dt_socket,address=3091,suspend=n&lt;br /&gt;&lt;br /&gt;Restarting  tomcat will render it in debug mode listening on port 3091.&lt;br /&gt;&lt;br /&gt;Now in your favourite IDE have the REMOTE  DEBUGGING listening on port 3091.&lt;br /&gt;Then the course is normal, place breakpoints in your code and trace for possible bugs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-242993147783179417?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/242993147783179417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=242993147783179417' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/242993147783179417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/242993147783179417'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/debugging-tomcat-applications-using.html' title='Debugging tomcat applications using IDE&apos;s'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-706228933234618424</id><published>2007-03-16T00:00:00.000+05:30</published><updated>2007-03-16T00:12:40.047+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='pragma'/><category scheme='http://www.blogger.com/atom/ns#' term='programs'/><category scheme='http://www.blogger.com/atom/ns#' term='entry point'/><category scheme='http://www.blogger.com/atom/ns#' term='interview'/><title type='text'>Did You Know ???</title><content type='html'>This might sound like an interview question, but very interesting one's, sorry there are 2 questions ;-)&lt;br /&gt;&lt;br /&gt;1. Whats the output of the following?&lt;br /&gt;&lt;br /&gt;struct a {&lt;br /&gt;  char b;&lt;br /&gt;  int a;&lt;br /&gt;};&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; printf("Size of struct a is %d\n", sizeof(struct a));&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Ans: Assuming int = 4 bytes, size will be 8 bytes.&lt;br /&gt;&lt;br /&gt;Ok, now the real question, how do you make "sizeof(struct a)" to print 5 bytes,&lt;br /&gt;which is the actual size of structure.&lt;br /&gt;&lt;br /&gt;Solution ;-),just add a line to direct the compiler using pragma.&lt;br /&gt;&lt;br /&gt;#pragma pack 1&lt;br /&gt;struct a {&lt;br /&gt;  char b;&lt;br /&gt;  int a;&lt;br /&gt;};&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; printf("Size of struct a is %d\n", sizeof(struct a));&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now, check out the output, it says 5 bytes !!! &lt;br /&gt;&lt;br /&gt;2. Run a program without a main() function in it ??&lt;br /&gt;Please, don't google for it, just look below ;-)&lt;br /&gt;&lt;br /&gt;By the way, I tried this only on HP-UX,&lt;br /&gt;so please try out on different OS, post it in comments.&lt;br /&gt;Basically, you need to do "man cc", to check out the&lt;br /&gt;compilation option.&lt;br /&gt;&lt;br /&gt;#vi t.c&lt;br /&gt;&lt;br /&gt;int f1()&lt;br /&gt;{&lt;br /&gt; printf ("Hello world\n");&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;# cc t.c -o t -ef1&lt;br /&gt;Warnings: Are meant to be ignored by programmers ;-)&lt;br /&gt;# chmod +x t&lt;br /&gt;# ./t&lt;br /&gt;&lt;br /&gt;Aila, it's running !!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-706228933234618424?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/706228933234618424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=706228933234618424' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/706228933234618424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/706228933234618424'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/did-you-know.html' title='Did You Know ???'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-552765310124575303</id><published>2007-03-14T11:09:00.000+05:30</published><updated>2007-03-14T11:45:43.471+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='postgres'/><title type='text'>Partitioning in postgres</title><content type='html'>Partioning is useful to drop group of data in a table in bulk.  In most cases year old data is purged on a regular basis by an application. Partitions are a useful design design to manage the data.&lt;br /&gt;&lt;br /&gt;create table master (i int);&lt;br /&gt;&lt;br /&gt;create table slave1 ( CHECK ( i &gt; 0 AND i &lt;&gt; 10 AND i &lt;&gt; 20 AND i &lt; postgres="#"&gt; 0 AND i &lt;&gt; 10 AND i &lt;&gt; 20 AND i &lt; 30) ) inherits (master);&lt;br /&gt;&lt;br /&gt;postgres=# insert into master values(5);&lt;br /&gt;INSERT 0 1&lt;br /&gt;postgres=# insert into master values(15);&lt;br /&gt;INSERT 0 1&lt;br /&gt;postgres=# insert into master values(25);&lt;br /&gt;INSERT 0 1&lt;br /&gt;postgres=# select * from master;&lt;br /&gt;i&lt;br /&gt;----&lt;br /&gt;15&lt;br /&gt;25&lt;br /&gt;5&lt;br /&gt;(3 rows)&lt;br /&gt;postgres=# select * from slave1;&lt;br /&gt;i&lt;br /&gt;---&lt;br /&gt;5&lt;br /&gt;(1 row)&lt;br /&gt;postgres=# select * from slave2;&lt;br /&gt;i&lt;br /&gt;---&lt;br /&gt;15&lt;br /&gt;(1 rows)&lt;br /&gt;postgres=# select * from slave3;&lt;br /&gt;i&lt;br /&gt;---&lt;br /&gt;25&lt;br /&gt;(1 rows)&lt;br /&gt;&lt;br /&gt;Note: Copy command of postres does not copy the rules associated with the table. So to make sure the rules are reflected, create partitions as a trigger.&lt;br /&gt;&lt;br /&gt;Also here is an interesting thing&lt;br /&gt;&lt;br /&gt;postgres=# update master set i=15 where i=5;&lt;br /&gt;ERROR:  new row for relation "slave1" violates check constraint "slave1_i_check"&lt;br /&gt;&lt;br /&gt;This says it all&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-552765310124575303?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/552765310124575303/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=552765310124575303' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/552765310124575303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/552765310124575303'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/partitioning-in-postgres.html' title='Partitioning in postgres'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-4662275935798039518</id><published>2007-03-03T21:38:00.000+05:30</published><updated>2007-03-03T22:04:49.389+05:30</updated><title type='text'>Effective JDBC</title><content type='html'>&lt;span style="font-size:85%;"&gt;JDBC supports &lt;b&gt;&lt;i&gt;connection pooling&lt;/i&gt;&lt;/b&gt;, which essentially involves keeping open a cache of database connection objects and making them available for immediate use for any application that requests a connection. Instead of performing expensive network roundtrips to the database server, a connection attempt results in the re-assignment of a connection from the local cache to the application. When the application disconnects, the physical tie to the database server is not severed, but instead, the connection is placed back into the cache for immediate re-use, substantially improving data access performance.&lt;br /&gt;&lt;br /&gt;To get more of it checkout these links&lt;br /&gt;&lt;/span&gt;http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html&lt;br /&gt;http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html&lt;br /&gt;&lt;br /&gt;From my limited research, I understand tomcat  implements  connection pool by default.&lt;br /&gt;Here is the link taking at length about it http://www.javapractices.com/Topic75.cjp&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Also during the research came up with this nice article by the Martin Fowler talking about the design decisions of allowing certain business logic in the database rather than handling them exclusively in the application software (esp things like orderby, filtering tools (WHERE,LIKE etc))&lt;br /&gt;Here's the link&lt;br /&gt;http://www.martinfowler.com/articles/dblogic.html&lt;br /&gt;&lt;br /&gt;This was typically the point made by the oracle database legend &lt;a href="http://asktom.oracle.com"&gt;Tom Kyte&lt;/a&gt; in the article &lt;a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:499097979114"&gt;JDBC : SQL vs PL/SQL, Which performs better&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Simple anology(not entrirely a perfect analogy) ,&lt;br /&gt;when we know we need to grep for say automountd process to just know the pid of the process&lt;br /&gt;instead of ps -aef|grep auto&lt;br /&gt;a simple ps -a -o comm,pid|grep auto&lt;br /&gt;will be more effective.&lt;br /&gt;&lt;br /&gt;This design problem is tackled at across various layers. A simple typical case is the OS, where we typically end up getting huge data( say in truss or ps output), there after prunning the processed(cpu) data using grep,awk like  utilities. A tool which stops from generating the unwanted data from being generated always scores over the basic tools we use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-4662275935798039518?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/4662275935798039518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=4662275935798039518' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4662275935798039518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/4662275935798039518'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/effective-jdbc.html' title='Effective JDBC'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-7800233235557061583</id><published>2007-03-02T23:37:00.000+05:30</published><updated>2007-03-03T00:09:25.305+05:30</updated><title type='text'>How to know the current process state</title><content type='html'>This one feature though trivial will be thoughly learnt on a need basis.&lt;br /&gt;&lt;br /&gt;When we need to find out what is the current state of a process is (aka Running(R), Sleeping(S), Stopped(T),Zombie(Z) etc), we can use the ps command effectively.&lt;br /&gt;&lt;br /&gt;Here is the basic setup&lt;br /&gt;test@shantanu&gt;more simple1.c&lt;br /&gt;#include&lt;stdio.h&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;        int i=0;&lt;br /&gt;        printf("Waiting for a console output\n");&lt;br /&gt;        scanf("%d",&amp;i);&lt;br /&gt;        return(0);&lt;br /&gt;}&lt;br /&gt;test@shantanu&gt;gcc simple1.c -o simple1&lt;br /&gt;test@shantanu&gt;./simple1&lt;br /&gt;Waiting for a console output&lt;br /&gt;........///No input is yet given&lt;br /&gt;&lt;br /&gt;In another terminal run&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;test@shantanu&gt;ps -a -o comm  -o s|grep simple1&lt;/span&gt;&lt;br /&gt;./simple1                                                                        S&lt;br /&gt;&lt;br /&gt;So the process is currently sleeping for my input.&lt;br /&gt;All the state changes hereafter can be observed independently.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-7800233235557061583?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/7800233235557061583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=7800233235557061583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7800233235557061583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/7800233235557061583'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/03/how-to-know-current-process-state.html' title='How to know the current process state'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-6963409231225043524</id><published>2007-02-27T23:43:00.000+05:30</published><updated>2007-02-28T00:28:31.384+05:30</updated><title type='text'>core file generation</title><content type='html'>Got to know this interesting bit today&lt;br /&gt;&lt;br /&gt;By default in solaris core dump occurs when an application misbehaves(say segmentation fault).&lt;br /&gt;But in linux the default core dumping is disabled.&lt;br /&gt;&lt;br /&gt;Using ulimit command one can turn on this feature.&lt;br /&gt;&lt;br /&gt;Just enable the application to core dump by&lt;br /&gt;$&gt;ulimit -c unlimited&lt;br /&gt;&lt;br /&gt;For more on this refer to &lt;br /&gt;http://www.novell.com/coolsolutions/feature/16257.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-6963409231225043524?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/6963409231225043524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=6963409231225043524' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6963409231225043524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/6963409231225043524'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/02/core-file-generation.html' title='core file generation'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-2549652080465231471</id><published>2007-02-23T02:00:00.000+05:30</published><updated>2007-02-23T02:16:05.219+05:30</updated><title type='text'>Amazon turks now in Indian rupees</title><content type='html'>Amazon turk now renders Indian rupee transaction. Check it out&lt;br /&gt;http://www.mturk.com/mturk/welcome&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-2549652080465231471?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/2549652080465231471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=2549652080465231471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2549652080465231471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/2549652080465231471'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/02/amazon-turks-now-in-indian-rupees.html' title='Amazon turks now in Indian rupees'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-8906097735629234193</id><published>2007-02-10T01:50:00.000+05:30</published><updated>2007-02-10T03:12:28.752+05:30</updated><title type='text'>Sun Tech days in Hyderabad</title><content type='html'>Sun tech days from Feb 21st to 23rd. Though most of the technical community is aware of this event , please check&lt;a href="http://www.sercononline.com/suntechdays07/ms/home.htm"&gt; this link&lt;/a&gt;  to get the details.   The list of talks,hands on labs, codecamps are&lt;a href="http://www.sercononline.com/suntechdays07/ms/agenda.htm"&gt; here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-8906097735629234193?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/8906097735629234193/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=8906097735629234193' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8906097735629234193'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/8906097735629234193'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/02/sun-tech-days-in-hyderabad.html' title='Sun Tech days in Hyderabad'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-117070114890322471</id><published>2007-02-06T00:11:00.000+05:30</published><updated>2007-02-10T03:13:57.864+05:30</updated><title type='text'>Continuations in  java</title><content type='html'>&lt;a href="http://en.wikipedia.org/wiki/Continuation"&gt;Continuation &lt;/a&gt;is an object that represents the execution state of a program at a certain point. We can use continuation to restart the execution from the point stored in it.&lt;br /&gt;One area that has seen practical use of continuations is in web programming&lt;br /&gt;&lt;br /&gt;Check out an enumeration &lt;a href="http://blogs.sun.com/sundararajan/date/20070119"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-117070114890322471?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/117070114890322471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=117070114890322471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/117070114890322471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/117070114890322471'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2007/02/continuations-in-java.html' title='Continuations in  java'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-116704299395646117</id><published>2006-12-25T16:06:00.000+05:30</published><updated>2006-12-25T16:06:34.050+05:30</updated><title type='text'>Krugle - Code Search for Developers</title><content type='html'>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;p&gt;This is a nice site for code stealing&lt;/p&gt;&lt;p&gt;Read more at &lt;a href="http://www.krugle.com/"&gt;www.krugle.com/&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-116704299395646117?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/116704299395646117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=116704299395646117' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116704299395646117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116704299395646117'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/12/krugle-code-search-for-developers.html' title='Krugle - Code Search for Developers'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-116673200816123355</id><published>2006-12-22T01:33:00.000+05:30</published><updated>2006-12-22T01:43:28.176+05:30</updated><title type='text'>Crystal clear Bangalore on google map</title><content type='html'>&lt;a href="http://maps.google.com/?ie=UTF8&amp;z=5&amp;ll=19.973349,81.254883&amp;spn=28.925361,41.132812&amp;om=1"&gt;Check this out &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now the map is much more detailed and expressive than the satellite based imagery.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-116673200816123355?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/116673200816123355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=116673200816123355' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116673200816123355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116673200816123355'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/12/crystal-clear-bangalore-on-google-map.html' title='Crystal clear Bangalore on google map'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-116120566324839682</id><published>2006-10-19T02:25:00.000+05:30</published><updated>2006-10-19T02:37:43.266+05:30</updated><title type='text'>How to list only directories in Unix</title><content type='html'>Well this may seem a very simple problem, but its not. So it deserves a thread for sure&lt;br /&gt;&lt;br /&gt;Traditional method&lt;br /&gt;&lt;br /&gt;ls -l|grep ^d&lt;br /&gt;&lt;br /&gt;But u get the other unwanted details, incase u are automating &lt;br /&gt;&lt;br /&gt;Slightly Sophisticated&lt;br /&gt;&lt;br /&gt;find . -type d&lt;br /&gt;&lt;br /&gt;But on execution u will dicern that find is recursive, so "just the" folders of the current directory are not displayed&lt;br /&gt;&lt;br /&gt;If its getting slightly complicated try this simpler solution.&lt;br /&gt;&lt;br /&gt;ls -l|grep ^d|awk '{print $9}'&lt;br /&gt;&lt;br /&gt;Pretty neat.&lt;br /&gt;This command works almost fine. But just in case the folder has a "space", the command fails to get the exact name of the folder.&lt;br /&gt;&lt;br /&gt;Here is a solution which "WORKS" and is very simple&lt;br /&gt;&lt;br /&gt;ls -p |grep /&lt;br /&gt;&lt;br /&gt;Just an indicator of the power of the raw tools invented ages ago. KISS(Keep it Simple S......)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-116120566324839682?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/116120566324839682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=116120566324839682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116120566324839682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116120566324839682'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/10/how-to-list-only-directories-in-unix.html' title='How to list only directories in Unix'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-116076035486546450</id><published>2006-10-13T22:54:00.000+05:30</published><updated>2006-10-13T22:57:13.930+05:30</updated><title type='text'>Must Read....</title><content type='html'>&lt;a href="http://www-inst.eecs.berkeley.edu/%7Emaratb/readings/NoSilverBullet.html"&gt;No Silver Bullet&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If u write  code...read it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-116076035486546450?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/116076035486546450/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=116076035486546450' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116076035486546450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116076035486546450'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/10/must-read.html' title='Must Read....'/><author><name>Kiran</name><uri>http://www.blogger.com/profile/04208772606613963340</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-fctQDy_F6ms/Tmurq520wPI/AAAAAAAAArU/DZ44UbvOThY/s1600/6123529531_0bb5f9a448.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-116022706329562208</id><published>2006-10-07T18:38:00.000+05:30</published><updated>2006-10-07T18:47:43.306+05:30</updated><title type='text'>Google does it again</title><content type='html'>Check this &lt;a href="http://www.google.com/codesearch"&gt;out&lt;/a&gt;. Its out and open for people to use. &lt;br /&gt;&lt;br /&gt;Now here are the interesting issues with it.&lt;br /&gt;1) Be prepared for spams. Just try &lt;a href="http://www.google.com/codesearch?q=%40"&gt;this&lt;/a&gt;, you will know.&lt;br /&gt;2) Emotions the poor &lt;a href="http://www.google.com/codesearch?as_q=suck&amp;btnG=Search+Code&amp;as_lang=&amp;as_license_restrict=i&amp;as_license=&amp;as_package=&amp;as_filename=&amp;as_case="&gt;developers &lt;/a&gt;go through :-X . Just pick your slang, google does the rest.I just hope openSolaris is clean!!!!!!!!!!!!!!&lt;br /&gt;3) Some programmers put the default password in sourcecode and Most lazy users never change the default password.This makes it easy to get the default password which can be exploited. &lt;a href="http://www.google.com/codesearch?q=%22default+password+is%22"&gt;Try this&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Actually this is not a great innovation in itself.  &lt;a href="http://www.krugle.com/"&gt;Krugle&lt;/a&gt;, &lt;a href="http://www.koders.com/"&gt;Koders&lt;/a&gt;, and &lt;a href="http://www.codase.com./"&gt;Codease&lt;/a&gt; are into this. But a gaint entering will have its own advatages.&lt;br /&gt;&lt;br /&gt;"Good programmers write good code. Great programmers find it on Google!"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-116022706329562208?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/116022706329562208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=116022706329562208' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116022706329562208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/116022706329562208'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/10/google-does-it-again.html' title='Google does it again'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115946571767557517</id><published>2006-09-28T23:17:00.000+05:30</published><updated>2006-09-28T23:18:37.700+05:30</updated><title type='text'>Good one!</title><content type='html'>&lt;a href="http://steve-yegge.blogspot.com/2006/09/good-agile-bad-agile_27.html"&gt;http://steve-yegge.blogspot.com/2006/09/good-agile-bad-agile_27.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115946571767557517?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115946571767557517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115946571767557517' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115946571767557517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115946571767557517'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/09/good-one.html' title='Good one!'/><author><name>Kiran</name><uri>http://www.blogger.com/profile/04208772606613963340</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-fctQDy_F6ms/Tmurq520wPI/AAAAAAAAArU/DZ44UbvOThY/s1600/6123529531_0bb5f9a448.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115921229931177923</id><published>2006-09-26T00:40:00.001+05:30</published><updated>2006-09-26T00:54:59.313+05:30</updated><title type='text'>PHP sucks big time</title><content type='html'>I was trying to integrate Apache--PHP--mysql for a HR project  at &lt;a href="http://janaagraha.org/"&gt;janagraha&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The problem is that the php documentation is very old...or I should say it works for lower versions of php and apache.&lt;br /&gt;&lt;br /&gt;So here is a small TO-DO on how to go about integrating&lt;br /&gt;1) Download Apache &lt;a href="http://apache.oc1.mirrors.redwire.net/httpd/binaries/win32/apache_2.2.3-win32-x86-no_ssl.msi"&gt;here&lt;/a&gt;. Apply your user friendly GUI knowledge of windows and get it installed. &lt;br /&gt;2)Download php &lt;a href="http://snaps.php.net/win32/php5.2-win32-200609251830.zip"&gt;here&lt;/a&gt;.&lt;br /&gt;3)Unzip in &lt;span style="font-style:italic;"&gt;d:\php5&lt;/span&gt;. &lt;br /&gt;4)Rename php.ini-recommended to php.ini&lt;br /&gt;5)Add these lines to the top of httpd.conf&lt;br /&gt;# PHP 5 Support&lt;br /&gt;&lt;span style="font-style:italic;"&gt;LoadModule php5_module "d:/php5/php5apache2_2_filter.dll"&lt;br /&gt;LoadFile "d:/php5/php5ts.dll"&lt;br /&gt;AddOutputFilter PHP php&lt;br /&gt;PHPIniDir "d:/php5"&lt;span style="font-weight:bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;***Please note the locations used.&lt;br /&gt;6) Finally process is over. Create a test.php.&lt;br /&gt;Having say &lt;br /&gt;&lt;? echo "Integration sucks"; ?&gt;&lt;br /&gt;copy to htdocs folder of apache.&lt;br /&gt;&lt;br /&gt;7)RESTART APACHE. (hopefully no errors). &lt;br /&gt;Run http://localhost/test.php&lt;br /&gt;&lt;br /&gt;Worth a try though&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115921229931177923?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115921229931177923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115921229931177923' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115921229931177923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115921229931177923'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/09/php-sucks-big-time_26.html' title='PHP sucks big time'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115757696352124651</id><published>2006-09-07T02:33:00.000+05:30</published><updated>2006-09-07T02:39:23.533+05:30</updated><title type='text'>Google Releases Tesseract as Open Source</title><content type='html'>Google recently released Tesseract as open source. Originally developed at the HP Labs from 1985-1995, it has been vouched as one of the most accurate &lt;a href="http://en.wikipedia.org/wiki/Optical_character_recognition"&gt;Optical Character Recognition&lt;/a&gt; (OCR) programs available. You can download Tesseract &lt;a href="http://sourceforge.net/projects/tesseract-ocr"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Checkout one possible use of this technology &lt;a href="http://www.newspaperarchive.com/LandingItems/GLP/LP8.aspx?search=vivekananda&amp;img=P9SpTvomPU+KID/6NLMW2pVLTGFFlix4W50nEoESjznjcEt17V09ww==&amp;site=google&amp;fileType=jpg"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Leaving the rest to imagination....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115757696352124651?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115757696352124651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115757696352124651' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115757696352124651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115757696352124651'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/09/google-releases-tesseract-as-open.html' title='Google Releases Tesseract as Open Source'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115678917939845836</id><published>2006-08-28T23:30:00.002+05:30</published><updated>2006-08-28T23:49:39.413+05:30</updated><title type='text'>Does machine have JAVA</title><content type='html'>My friend can up with a curious problem.&lt;br /&gt;&lt;br /&gt;To run an applet a prerequiste is to actually check whether JRE(or JVM) is actually present on the machine. Although applet inherits the intelligence to actually point the   browser to the web location.&lt;br /&gt;&lt;br /&gt;However if the application has to be in total control then how??????&lt;br /&gt;&lt;br /&gt;In short for Non-IE browsers then navigator.mimeTypes gets the registry values for the installed runtimes.&lt;br /&gt;But alas IE does not implement mimetypes. So an activeX document to implement the same.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is a small snippet of the code written in javascript.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if(navigator.mimeTypes) {&lt;br /&gt;//For non-IE browsers&lt;br /&gt;for (i=0; i &lt; navigator.mimeTypes.length; i++) {&lt;br /&gt;if( (navigator.mimeTypes[ i].type != null)&lt;br /&gt;&amp;&amp; (navigator.mimeTypes[ i].type.indexOf(&lt;br /&gt;"application/x-java-applet;jpi-version=1.5") != -1) ) {&lt;br /&gt;pluginDetected = true;&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} else if (is_ie5up) {&lt;br /&gt;var javaVersion;&lt;br /&gt;var shell;&lt;br /&gt;try {&lt;br /&gt;// Create WSH(WindowsScriptHost) shell, available on Windows only&lt;br /&gt;shell = new ActiveXObject("WScript.Shell");&lt;br /&gt;&lt;br /&gt;if (shell != null) {&lt;br /&gt;// Read JRE version from Window Registry&lt;br /&gt;try {&lt;br /&gt;javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");&lt;br /&gt;} catch(e) {&lt;br /&gt;// handle exceptions raised by 'shell.regRead(...)' here&lt;br /&gt;// so that the outer try-catch block would receive only&lt;br /&gt;// exceptions raised by 'shell = new ActiveXObject(...)'&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} catch(e) {&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115678917939845836?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115678917939845836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115678917939845836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115678917939845836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115678917939845836'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/does-machine-have-java_29.html' title='Does machine have JAVA'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115678913938227860</id><published>2006-08-28T23:30:00.000+05:30</published><updated>2006-08-28T23:48:59.646+05:30</updated><title type='text'></title><content type='html'>My friend can up with a curious problem.&lt;br /&gt;&lt;br /&gt;To run an applet a prerequiste is to actually check whether JRE(or JVM) is actually present on the machine. Although applet inherits the intelligence to actually point the   browser to the web location.&lt;br /&gt;&lt;br /&gt;However if the application has to be in total control then how??????&lt;br /&gt;&lt;br /&gt;In short for Non-IE browsers then navigator.mimeTypes gets the registry values for the installed runtimes.&lt;br /&gt;But alas IE does not implement mimetypes. So an activeX document to implement the same.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here is a small snippet of the code written in javascript.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if(navigator.mimeTypes) {&lt;br /&gt;//For non-IE browsers&lt;br /&gt;for (i=0; i &lt; navigator.mimeTypes.length; i++) {&lt;br /&gt;if( (navigator.mimeTypes[ i].type != null)&lt;br /&gt;&amp;&amp; (navigator.mimeTypes[ i].type.indexOf(&lt;br /&gt;"application/x-java-applet;jpi-version=1.5") != -1) ) {&lt;br /&gt;pluginDetected = true;&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} else if (is_ie5up) {&lt;br /&gt;var javaVersion;&lt;br /&gt;var shell;&lt;br /&gt;try {&lt;br /&gt;// Create WSH(WindowsScriptHost) shell, available on Windows only&lt;br /&gt;shell = new ActiveXObject("WScript.Shell");&lt;br /&gt;&lt;br /&gt;if (shell != null) {&lt;br /&gt;// Read JRE version from Window Registry&lt;br /&gt;try {&lt;br /&gt;javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");&lt;br /&gt;} catch(e) {&lt;br /&gt;// handle exceptions raised by 'shell.regRead(...)' here&lt;br /&gt;// so that the outer try-catch block would receive only&lt;br /&gt;// exceptions raised by 'shell = new ActiveXObject(...)'&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;} catch(e) {&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115678913938227860?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115678913938227860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115678913938227860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115678913938227860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115678913938227860'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/my-friend-can-up-with-curious-problem.html' title=''/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115623375955235868</id><published>2006-08-22T13:24:00.000+05:30</published><updated>2006-08-22T13:32:39.563+05:30</updated><title type='text'>Extract Windows Product Key !</title><content type='html'>Just came across this while searching something on "Google", looked very interesting.&lt;br /&gt;Everyone will be wondering how to get this product key if not mentioned it on the CD label.&lt;br /&gt;But I haven't tried this yet, cause am not a windows programmer ;)&lt;br /&gt;Let me know the results about this!&lt;br /&gt;&lt;br /&gt;&lt;p&gt;BSTR GetProductKey()&lt;br /&gt;/*&lt;br /&gt; Window Product Key Extract&lt;/p&gt; &lt;p&gt;*/&lt;br /&gt;{&lt;br /&gt; CString strResult;             //Return a Window Product Key&lt;br /&gt; &lt;br /&gt; HKEY hRegistryKey;           //Registry Handler&lt;br /&gt; BYTE   *DigitalProductID;   //Digital Product Key Value&lt;br /&gt; DWORD DataLength;         //Digital Product Key Length &lt;/p&gt; &lt;p&gt; BYTE ProductKeyExtract [15]; //Extract Key &lt;/p&gt; &lt;p&gt;char sCDKey  [256];   //Temp, adding a Window Product Key&lt;br /&gt;&lt;br /&gt; long ByteCounter;    //Counter&lt;br /&gt; long ByteConvert;    //Convert&lt;/p&gt; &lt;p&gt; int  nCur;      //XOR calculate &lt;/p&gt;&lt;p&gt;&lt;br /&gt; char *KeyChars[] = {&lt;br /&gt;       "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y",&lt;br /&gt;       "2","3","4","6","7","8","9",NULL&lt;br /&gt;      }; &lt;/p&gt;&lt;p&gt; // HKLM\\SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion 열기 &lt;br /&gt; if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NT_CURRENT,&lt;br /&gt;  REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &amp;hRegistryKey) == ERROR_SUCCESS)&lt;br /&gt; {&lt;br /&gt; &lt;br /&gt;  DataLength = 164; &lt;/p&gt;&lt;p&gt;  //Allocate Memory&lt;br /&gt;  DigitalProductID = (BYTE *)malloc(DataLength);    &lt;/p&gt;&lt;p&gt;  //Memory Initializationd&lt;br /&gt;  memset(DigitalProductID, 0, DataLength); &lt;/p&gt;&lt;p&gt; //Digital Product Key Open&lt;/p&gt; &lt;p&gt;  if(RegQueryValueEx(hRegistryKey, "DigitalProductId",&lt;br /&gt;   NULL, NULL, DigitalProductID, &amp;DataLength) == ERROR_SUCCESS)&lt;br /&gt;  {  &lt;br /&gt;   //reading a value start position 52, by 66&lt;br /&gt;   for(ByteCounter=52; ByteCounter&lt;=66; ByteCounter++)&lt;br /&gt;   {&lt;br /&gt;    ProductKeyExtract[ByteCounter - 52] = DigitalProductID[ByteCounter];&lt;br /&gt;   }&lt;/p&gt; &lt;p&gt;   //Last Indexer&lt;br /&gt;   ProductKeyExtract[sizeof(ProductKeyExtract)] = NULL;&lt;br /&gt;  }&lt;br /&gt; } &lt;/p&gt;&lt;p&gt; //Start Converting job, Next Step &lt;/p&gt;&lt;p&gt; memset(sCDKey, 0, sizeof(sCDKey)); &lt;/p&gt;&lt;p&gt; for(ByteCounter=24; ByteCounter&gt;=0; ByteCounter--)&lt;br /&gt; {&lt;br /&gt;  nCur = 0; &lt;/p&gt;&lt;p&gt;  for(ByteConvert=14; ByteConvert&gt;=0; ByteConvert--)&lt;br /&gt;  {&lt;br /&gt;   &lt;/p&gt; &lt;p&gt;   nCur = (nCur * 256) ^ ProductKeyExtract[ByteConvert];  //XOR계산&lt;br /&gt;   ProductKeyExtract[ByteConvert] = nCur / 24;&lt;br /&gt;   nCur = nCur % 24;&lt;br /&gt;  }  &lt;br /&gt; &lt;br /&gt;  strrev(sCDKey);&lt;br /&gt;  strcat(sCDKey, KeyChars[nCur]);&lt;br /&gt;  strrev(sCDKey);&lt;/p&gt; &lt;p&gt;  //Insert "-" &lt;/p&gt; &lt;p&gt;  if(!(ByteCounter % 5) &amp;&amp;amp; (ByteCounter))&lt;br /&gt;  {&lt;br /&gt;   strrev(sCDKey);&lt;br /&gt;  &lt;br /&gt;   strcat(sCDKey, "-");&lt;br /&gt;  &lt;br /&gt;   strrev(sCDKey);&lt;br /&gt;  }&lt;br /&gt; }&lt;/p&gt; &lt;p&gt; //Insert Product Key into Return value &lt;/p&gt;&lt;p&gt; strResult.Format("%s", sCDKey); &lt;/p&gt;&lt;p&gt; //Close Registry&lt;br /&gt; RegCloseKey(hRegistryKey); &lt;/p&gt;&lt;p&gt; //Relese Memory&lt;br /&gt; if(DigitalProductID) free(DigitalProductID); &lt;/p&gt;&lt;p&gt; return strResult.AllocSysString();&lt;br /&gt;} &lt;/p&gt;Note: Please mention the results in the comments section.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115623375955235868?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115623375955235868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115623375955235868' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115623375955235868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115623375955235868'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/extract-windows-product-key.html' title='Extract Windows Product Key !'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115583687907516141</id><published>2006-08-17T23:14:00.000+05:30</published><updated>2006-08-17T23:17:59.076+05:30</updated><title type='text'>Richard Stallman @IISc</title><content type='html'>&lt;span style="font-weight:bold;"&gt;Title: Free Software: current status and challenges&lt;br /&gt;&lt;br /&gt;Time: 19 Aug (Sat) 11am&lt;br /&gt;Place: Faculty Hall&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Speaker: Richard Stallman,&lt;br /&gt;Founder of GNU project and FSF (Free Software Foundation)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Abstract:&lt;br /&gt;Richard Stallman will give a talk on free software and current status on&lt;br /&gt;aspects such as GPLv3, DRM (digital rights mgmt), DMCA, etc.&lt;br /&gt;&lt;br /&gt;Bio:&lt;br /&gt;Richard Stallman is the founder of the GNU Project, launched in 1984 to&lt;br /&gt;develop the free software operating system GNU. The name ``GNU'' is a&lt;br /&gt;recursive acronym for ``GNU's Not Unix''.&lt;br /&gt;&lt;br /&gt;Stallman graduated from Harvard in 1974 with a BA in physics. During his&lt;br /&gt;college years, he also worked as a staff hacker at the MIT Artificial&lt;br /&gt;Intelligence Lab, learning operating system development by doing it. He&lt;br /&gt;wrote the first extensible Emacs text editor there in 1975. He also&lt;br /&gt;developed the AI technique of dependency-directed backtracking, also&lt;br /&gt;known as truth maintenance. In January 1984 he resigned from MIT to&lt;br /&gt;start the GNU project.&lt;br /&gt;&lt;br /&gt;Stallman received the Grace Hopper award for 1991 from the Association&lt;br /&gt;for Computing Machinery, for his development of the first Emacs editor.&lt;br /&gt;In 1990 he was awarded a Macarthur foundation fellowship, and in 1996 an&lt;br /&gt;honorary doctorate from the Royal Institute of Technology in Sweden. In&lt;br /&gt;1998 he received the Electronic Frontier Foundation's pioneer award&lt;br /&gt;along with Linus Torvalds. In 1999 he received the Yuri Rubinski award.&lt;br /&gt;In 2001 he received a second honorary doctorate, from the University of&lt;br /&gt;Glasgow, and shared the Takeda award for social/economic betterment with&lt;br /&gt;Torvalds and Ken Sakamura. In 2002 he was elected to the US National&lt;br /&gt;Academy of Engineering, and in 2003 to the American Academy of Arts and&lt;br /&gt;Sciences. In 2003 he was named an honorary professor of the Universidad&lt;br /&gt;Nacional de Ingenieria in Peru, and received an honorary doctorate from&lt;br /&gt;the Free University of Brussels. In 2004 he received an honorary&lt;br /&gt;doctorate from the Universidad Nacional de Salta, in Argentina.&lt;br /&gt;&lt;br /&gt;About GNU:&lt;br /&gt;&lt;br /&gt;GNU is free software: everyone is free to copy it and redistribute it,&lt;br /&gt;as well as to make changes either large or small. Non-free software&lt;br /&gt;keeps users divided and helpless, forbidden to share it and unable to&lt;br /&gt;change it. A free operating system is essential for people to be able to&lt;br /&gt;use computers in freedom.&lt;br /&gt;&lt;br /&gt;Today, Linux-based variants of the GNU system, based on the kernel Linux&lt;br /&gt;developed by Linus Torvalds, are in widespread use. There are estimated&lt;br /&gt;to be some 20 million users of GNU/Linux systems today.&lt;br /&gt;&lt;br /&gt;Richard Stallman is the principal author of the GNU Compiler Collection,&lt;br /&gt;a portable optimizing compiler which was designed to support diverse&lt;br /&gt;architectures and multiple languages. The compiler now supports over 30&lt;br /&gt;different architectures and 7 programming languages.&lt;br /&gt;&lt;br /&gt;Stallman also wrote the GNU symbolic debugger (gdb), GNU Emacs, and&lt;br /&gt;various other programs for the GNU operating system.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115583687907516141?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115583687907516141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115583687907516141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115583687907516141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115583687907516141'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/richard-stallman-iisc.html' title='Richard Stallman @IISc'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115496506777455249</id><published>2006-08-07T21:05:00.000+05:30</published><updated>2006-08-07T21:07:47.786+05:30</updated><title type='text'>Is this methods fool proof?</title><content type='html'>Does this method make a valid check for even numbers?&lt;br /&gt;&lt;br /&gt;public static boolean isEven(int i) {&lt;br /&gt;    return i % 2 == 1;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115496506777455249?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115496506777455249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115496506777455249' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115496506777455249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115496506777455249'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/is-this-methods-fool-proof.html' title='Is this methods fool proof?'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115462542216702697</id><published>2006-08-03T21:56:00.000+05:30</published><updated>2006-08-03T22:47:02.323+05:30</updated><title type='text'>http://localhost/Wiki/</title><content type='html'>Imagine finding yourself in the middle of nowhere wanting to browse wiki :))&lt;br /&gt;&lt;br /&gt;Wikipedia offers whole of their content as a huge xml dump file, which you can download and host wikipedia on your local machine. There are filters such as &lt;a href="http://wikifilter.sourceforge.net/"&gt;WikiFilter&lt;/a&gt;  available which can read this XML dump and render html dynamically. It also provides indexing and search features, So virtually you won't find any diffrerence when you are browsing the local version, except that you wont be seeing the images on the wiki page. (actually you can get a dump of even the image links, just that you got to have a 100 GB hard disk! ).&lt;br /&gt;&lt;br /&gt;The whole xml dump file is just about 1.4 gb (compressed ver) and came to about 6.4 gb after decompressing.You can also get a sql dump which you can host using mysql which will obviously take less hard disk space, but I couldn't get anything which renders dynamic html out of it and can also provide search capabilities.&lt;br /&gt;&lt;br /&gt;Aha...Its  information about anything under the sun literally at your fingertips. All for free . Screw internet. Screw Encarta. Happy Wiki'ing !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115462542216702697?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115462542216702697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115462542216702697' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115462542216702697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115462542216702697'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/httplocalhostwiki.html' title='http://localhost/Wiki/'/><author><name>Kiran</name><uri>http://www.blogger.com/profile/04208772606613963340</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-fctQDy_F6ms/Tmurq520wPI/AAAAAAAAArU/DZ44UbvOThY/s1600/6123529531_0bb5f9a448.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115446364757712956</id><published>2006-08-02T01:33:00.000+05:30</published><updated>2006-08-02T01:50:47.650+05:30</updated><title type='text'>Nice Article on troublshooting</title><content type='html'>&lt;a href="http://www.jemshad.com/index.php/option/content/task/view/id/41"&gt;Check this out&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I liked the following points discussed&lt;br /&gt;&lt;br /&gt;1)Use of &lt;span style="font-style:italic;"&gt;strings&lt;/span&gt; for printing the strings of printable characters in files.&lt;br /&gt;&lt;br /&gt;2)Apt examples of gdb,strace &amp; ldd&lt;br /&gt;&lt;br /&gt;Also this very useful tip. I ran into this , for finding out what is used of "OR-ing" in javascript.&lt;br /&gt;&lt;span style="font-style:italic;"&gt;&lt;br /&gt;"Google normally removes common words like 'and', 'or', 'when' etc from the search patten. To forcefully include them in the search, use a '+' just before the word. ( +word_to_be_included)"&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115446364757712956?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115446364757712956/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115446364757712956' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115446364757712956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115446364757712956'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/08/nice-article-on-troublshooting.html' title='Nice Article on troublshooting'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115428658395360772</id><published>2006-07-31T00:24:00.000+05:30</published><updated>2006-07-31T00:39:43.963+05:30</updated><title type='text'>IBM is legacy, Infosys is the future</title><content type='html'>These are the exact words of euphemism used by our FM P Chidambaram. &lt;br /&gt;I think its time for Indian companies and Indians to be globally competetive. I would love to see a day when a fresh college grad rejects a MNC's offer for an Indian company for a more financially as well as technically satisfying career. I know the day is not quite far, its in the air- can sense it . &lt;br /&gt;Well &lt;a href="http://www.geocities.com/softwarehero/infosys.html"&gt;Infosys&lt;/a&gt;  has all it takes to kick butt out of IBM. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Happy birthday Infy( btw its Arnold's Birthday today as well, 1 more astrological reason to be gr8)&lt;br /&gt;&lt;br /&gt;And congratulations to all the Infy mates, u are in for a treat. Enjoy madi&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115428658395360772?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115428658395360772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115428658395360772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115428658395360772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115428658395360772'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/07/ibm-is-legacy-infosys-is-future.html' title='IBM is legacy, Infosys is the future'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115385567005120687</id><published>2006-07-26T00:55:00.000+05:30</published><updated>2006-07-26T00:57:50.070+05:30</updated><title type='text'>YouOS  Online OS!!!!!!!!</title><content type='html'>Are we seeing the beginning of the end of Microsoft days, finally? It may be too soon to say but YouOS looks pretty functional to me. “YouOS strives to bring the web and traditional operating systems together to form a shared virtual computer.” It is a wonderful concept. There are gotchas today, not to mention crumbling under digg/slash effect, but first, what in the hell is &lt;a href="https://www.youos.com/"&gt;YouOS&lt;/a&gt;?&lt;br /&gt;&lt;br /&gt;    &lt;a href="https://www.youos.com/"&gt;YouOS &lt;/a&gt;is a web operating system that lets you run diverse applications within a web browser. Small applications like sticky notes or clocks. Large applications like word processing, mp3 players, and instant messaging. Even better, it’s very easy to tweak an existing application or write your own.&lt;br /&gt;&lt;br /&gt;The idea is very captivating. Imagine a giant computer which everyone across the internet can share and work on. You can share your desktop, work equally well from any computer. “Your desktop, applications, and data travel with you from cafe to cafe, session to session. And tedious things like data backups and archiving? We’ll take care of them for you.” And yet you control your data.&lt;br /&gt;&lt;br /&gt;Rapid application development and management is central to YouOS. You can also clone an existing application to start yours. Here is a subset of the sample apps developed by the YouOS team:&lt;br /&gt;* RichTextWarrior - a rich text editor.&lt;br /&gt;* Wshell - a shell program, like in Linux. Try running “ps” or “ls” or javascript.&lt;br /&gt;* FlickRSS - want to have new pictures every time you log on? Use this.&lt;br /&gt;* Mersenne Prime Search - help search for special prime numbers.&lt;br /&gt;* goohoo - a not-so elegant way to search yahoo and google at the same time.&lt;br /&gt;* Penguin - an animated gif for your desktop&lt;br /&gt;* ChatWarrior - a chat room application&lt;br /&gt;&lt;br /&gt;YouOS exposes its functionality through open RESTful server APIs. That means you can easily write applications which consumes them or builds upon them. You can easily provide a customized version of YouOS for mobile for example or a desktop client which uses YouOS API’s to provide services.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In short - wonderful concept and nice implementation (in Python). I wish this project success. It is very likely that it will soon be gobbled by the likes or Microsoft, Yahoo or Google.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115385567005120687?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115385567005120687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115385567005120687' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115385567005120687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115385567005120687'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/07/youos-online-os.html' title='YouOS  Online OS!!!!!!!!'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115220687840993676</id><published>2006-07-06T22:51:00.000+05:30</published><updated>2006-07-06T22:57:58.420+05:30</updated><title type='text'>Wiki --How can we create ONE</title><content type='html'>Just finished with my &lt;a href="http://en.wikipedia.org/wiki/Wiki"&gt;wiki &lt;/a&gt;creation. My machine is the server for the internal wiki which can be put to use.&lt;br /&gt;&lt;br /&gt;It turned out to be much simpler than I expected.&lt;br /&gt;&lt;br /&gt;Just go to http://www.jspwiki.org/wiki/JSPWikiDownload .....download&lt;br /&gt;&lt;br /&gt;Tomcat is required as a container for the above generated war file.&lt;br /&gt;&lt;br /&gt;Just place the JSP WIKI war file in the tomcat HOME directory. Tomcat does everything all by itself.&lt;br /&gt;&lt;br /&gt;Thats it WIKI is up&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115220687840993676?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115220687840993676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115220687840993676' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115220687840993676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115220687840993676'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/07/wiki-how-can-we-create-one.html' title='Wiki --How can we create ONE'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-115089298759219926</id><published>2006-06-21T17:44:00.000+05:30</published><updated>2006-06-21T18:04:41.553+05:30</updated><title type='text'>Microchip@500GHz  speed</title><content type='html'>Check this &lt;a href="http://gizmodo.com/gadgets/peripherals/ibm-georgia-tech-to-announce-worlds-fastest-microchip-500ghz-181966.php"&gt;news&lt;/a&gt; out.&lt;br /&gt;&lt;br /&gt;This is truly out of the world.... If IBM achieves it then boy it will be the company everyone will be after. If I may recall correctly Intel is struggling to  get a 5 GHz processor out.&lt;br /&gt;&lt;br /&gt;When I purchased my PC way back in 2002, I was proud to say that my intel processor is the fastest with 1.7Gig. Well &lt;a href="http://www.webopedia.com/TERM/M/Moores_Law.html"&gt;Moore's law&lt;/a&gt; set in thereafter. But hey this is voilation of the law to the core.&lt;br /&gt;&lt;br /&gt;I wholeheartdly doubt such high speeds being pragmatic.Nevertheless in case it clicks, then the entire world will be changed. &lt;br /&gt;&lt;br /&gt;This processor at 451 degrees below zero is certailnly SUPER COOL!!!!!!!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-115089298759219926?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/115089298759219926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=115089298759219926' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115089298759219926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/115089298759219926'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/06/microchip500ghz-speed.html' title='Microchip@500GHz  speed'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114768292834513447</id><published>2006-05-15T14:16:00.000+05:30</published><updated>2006-05-15T14:18:48.360+05:30</updated><title type='text'>Recursive Fun</title><content type='html'>I was browsing through orkut and found community on Recursive Programming, and saw below piece of code .. Its cool ..&lt;br /&gt;&lt;br /&gt;&lt;tt&gt; node* Reverse(node* ptr)&lt;br /&gt;{&lt;br /&gt; if(ptr-&gt;next == NULL)&lt;br /&gt; {&lt;br /&gt;  Head = ptr;&lt;br /&gt;  return ptr;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; Reverse(ptr-&gt;next)-&gt;next = ptr;&lt;br /&gt;&lt;br /&gt; return ptr;&lt;br /&gt;}&lt;/tt&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Did anyone get it :-) ....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114768292834513447?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114768292834513447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114768292834513447' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114768292834513447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114768292834513447'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/05/recursive-fun.html' title='Recursive Fun'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114634626057041659</id><published>2006-04-30T02:56:00.000+05:30</published><updated>2006-04-30T04:07:34.020+05:30</updated><title type='text'>Pick Up Javascript code for bookmark</title><content type='html'>Bookmark this site &lt;a href="#" onclick="if(navigator.userAgent.indexOf('MSIE')&lt;0){window.sidebar.addPanel('Stay updated','http://puretechie.blogspot.com','');}else{window.external.AddFavorite('http://puretechie.blogspot.com', 'Stay updated');}"&gt;here&lt;/a&gt;&lt;br /&gt;Tested on Firefox and IE. Please comment if you face any run-time or javascript errors with your favourite browser.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114634626057041659?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114634626057041659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114634626057041659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114634626057041659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114634626057041659'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/04/pick-up-javascript-code-for-bookmark.html' title='Pick Up Javascript code for bookmark'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114496384774405267</id><published>2006-04-14T02:13:00.000+05:30</published><updated>2006-04-14T03:00:47.800+05:30</updated><title type='text'>Online  tutorial to learn Web Services in Java</title><content type='html'>http://java.sun.com/webservices/docs/1.5/tutorial/doc/index.html&lt;br /&gt;&lt;br /&gt;The above is a guide to developing Web applications with the Java Web Services Developer Pack (Java WSDP).&lt;br /&gt;&lt;br /&gt;Sun's Application Server needs to be used in here to implement the examples.&lt;br /&gt;&lt;br /&gt;The tutorials covers various things like&lt;br /&gt;-The Java API for XML Processing (JAXP)&lt;br /&gt;-The Java API for XML-based RPC (JAX-RPC)&lt;br /&gt;-SOAP with Attachments API for Java (SAAJ)&lt;br /&gt;-The Java API for XML Registries (JAXR)&lt;br /&gt;&lt;br /&gt;Best part of this is -- all examples are available for download . Hardly any work is needed to get the simple examples working.&lt;br /&gt;&lt;br /&gt;Worst part is --various jargons are in place like SAX(Simple API for XML)&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;, DCOM(Document Object Model) . These are XML processing models.&lt;br /&gt;&lt;br /&gt;This &lt;a href="http://www-128.ibm.com/developerworks/xml/library/x-tipsaxp.html"&gt;link&lt;/a&gt;  is a good starting point to parse XML documents using a SAX parser in Java.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114496384774405267?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114496384774405267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114496384774405267' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114496384774405267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114496384774405267'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/04/online-tutorial-to-learn-web-services.html' title='Online  tutorial to learn Web Services in Java'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114435876349394254</id><published>2006-04-07T02:51:00.000+05:30</published><updated>2006-04-07T02:56:03.506+05:30</updated><title type='text'>Pick up code for sending mail in Java</title><content type='html'>////Use Java 1.3 and above&lt;br /&gt;&lt;br /&gt;import javax.mail.*;&lt;br /&gt;import javax.mail.internet.*;&lt;br /&gt;&lt;br /&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;  * A simple email sender class.&lt;br /&gt;  */&lt;br /&gt;public class SimpleSender&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;  public static void main(String args[])&lt;br /&gt;  {&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;*************Change the smtpServer name ***************************&lt;br /&gt;      String smtpServer="mySMTP";//Use the respective smtpServer name&lt;br /&gt;      String to="shantanu.gg@gmail.com";&lt;br /&gt;      String from="shantanu.gg@gmail.com";&lt;br /&gt;      String subject="Please work";&lt;br /&gt;      String body="Consider urself lucky";&lt;br /&gt;&lt;br /&gt;      send(smtpServer, to, from, subject, body);&lt;br /&gt;    }&lt;br /&gt;    catch (Exception ex)&lt;br /&gt;    {&lt;br /&gt;      System.out.println("Usage:"&lt;br /&gt;       +" smtpServer toAddress fromAddress subjectText bodyText");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    System.exit(0);&lt;br /&gt;  }&lt;br /&gt;  public static void send(String smtpServer, String to, String from&lt;br /&gt;           , String subject, String body)&lt;br /&gt;          {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;              Properties props = System.getProperties();&lt;br /&gt;&lt;br /&gt;              // -- Attaching to default Session, or we could start a new one --&lt;br /&gt;&lt;br /&gt;              props.put("mail.smtp.host", smtpServer);&lt;br /&gt;              Session session = Session.getDefaultInstance(props, null);&lt;br /&gt;&lt;br /&gt;              // -- Create a new message --&lt;br /&gt;              Message msg = new MimeMessage(session);&lt;br /&gt;&lt;br /&gt;              // -- Set the FROM and TO fields --&lt;br /&gt;              msg.setFrom(new InternetAddress(from));&lt;br /&gt;              msg.setRecipients(Message.RecipientType.TO,&lt;br /&gt;                InternetAddress.parse(to, false));&lt;br /&gt;&lt;br /&gt;              // -- We could include CC recipients too --&lt;br /&gt;              // if (cc != null)&lt;br /&gt;              // msg.setRecipients(Message.RecipientType.CC&lt;br /&gt;              // ,InternetAddress.parse(cc, false));&lt;br /&gt;&lt;br /&gt;              // -- Set the subject and body text --&lt;br /&gt;              msg.setSubject(subject);&lt;br /&gt;              msg.setText(body);&lt;br /&gt;&lt;br /&gt;              // -- Set some other header information --&lt;br /&gt;              msg.setHeader("X-Mailer", "MyMail");&lt;br /&gt;              msg.setSentDate(new Date());&lt;br /&gt;&lt;br /&gt;              // -- Send the message --&lt;br /&gt;              Transport.send(msg);&lt;br /&gt;&lt;br /&gt;              System.out.println("Message sent OK.");&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;              ex.printStackTrace();&lt;br /&gt;            }&lt;br /&gt;          }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114435876349394254?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114435876349394254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114435876349394254' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114435876349394254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114435876349394254'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/04/pick-up-code-for-sending-mail-in-java.html' title='Pick up code for sending mail in Java'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114245322269931068</id><published>2006-03-16T01:26:00.000+05:30</published><updated>2006-03-16T01:37:02.723+05:30</updated><title type='text'>Just got Geekie</title><content type='html'>There is a hairline difference between techie/geekie  and posts like this will transcend into the geeky category.&lt;br /&gt;Here  is a small,lazy-- time saving tip for the readers who just can get the article on their systems as and when they are created.&lt;br /&gt;&lt;br /&gt;Here is the RSS feed link for this blog&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 51, 153);"&gt;http://puretechie.blogspot.com/atom.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use this  feed with your favourite RSS reader and be the first to view the articles....(Now u know what geeky really means ). I use Mozilla thunderbird --real good  for such geeky things.&lt;br /&gt;&lt;br /&gt;Stay Updated................&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114245322269931068?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114245322269931068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114245322269931068' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114245322269931068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114245322269931068'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/03/just-got-geekie.html' title='Just got Geekie'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114105057151282245</id><published>2006-02-27T19:37:00.000+05:30</published><updated>2006-03-15T01:54:43.186+05:30</updated><title type='text'>New features in Java 1.5</title><content type='html'>&lt;span class="bodySubtitle"&gt;The &lt;span style="font-weight: bold;"&gt;For-Each&lt;/span&gt; loop&lt;/span&gt;&lt;br /&gt;A task that is done often is to iterate through a collection, and do something with each element. For example, this shows all the elements in a list  :&lt;br /&gt;&lt;br /&gt;&lt;pre class="code"&gt;public void Show(List l) {&lt;br /&gt;   for (int i = 0; i &lt; l.size(); i++) {&lt;br /&gt;  System.out.println (l.get(i));&lt;br /&gt;   }&lt;br /&gt;}&lt;/pre&gt; &lt;pre class="code"&gt;&lt;br /&gt;This code seems right; however it could be very inefficient.&lt;br /&gt;The in-efficiency can be attributed to the sequential manner - the&lt;br /&gt;above progresses,resulting in an algorithm of order &lt;span style="font-weight: bold;"&gt;O(n^2)&lt;/span&gt;&lt;br /&gt;whereas an algorithm &lt;span style="font-weight: bold;"&gt;O(n)&lt;/span&gt; is easily obtained.&lt;br /&gt;&lt;br /&gt;O(n) can be got with the use of iterators (similar to c++)&lt;br /&gt;&lt;br /&gt;public static void ShowFast(List l) {&lt;br /&gt;   for (Iterator it = l.iterator(); it.hasNext();) {&lt;br /&gt;        System.out.println (it.next());&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;When you ask for an iterator of the collection using the method&lt;br /&gt;iterator(), a reference to the beginning of the list is retrieved.&lt;br /&gt;Then, the hasNext() method returns whether there are still more&lt;br /&gt;elements to come, and it.next() does two things: it advances the&lt;br /&gt;reference to the next element in the collection and retrieves the&lt;br /&gt;current element. This gives the LinkedList the opportunity to iterate&lt;br /&gt;through the list in O(n). For the moment, all that can be done in&lt;br /&gt;earlier versions of Java. Even if the above code works, it's not nice&lt;br /&gt;and quite error prone. For example, if in the hurry you call again to&lt;br /&gt;it.next() in the for block in order to retrieve again the element,&lt;br /&gt;you'll get half the list in one place and half in another. Of course&lt;br /&gt;that this can be solved storing the value of it.next() in a local&lt;br /&gt;variable, but Java 1.5 brings a nicer and safer way to do the same: the&lt;br /&gt;for-each loop.&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="code"&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;public static void ShowFastAndNice(List l) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;     for (Object o : l) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;          System.out.println (o);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;     }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can read the for sentence as "for each Object o in l"&lt;br /&gt;&lt;br /&gt;With New features--- have to come their share of new problems.&lt;br /&gt;Not everything is rosy here .....&lt;br /&gt;&lt;br /&gt;The following bombs&lt;br /&gt;Object o;&lt;br /&gt; for (o : l) {&lt;br /&gt;       System.out.println (o);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Sun documents this as "these kinds of practices are not very clear and robust,&lt;br /&gt;so the compiler is making you to write better code, even if it might require&lt;br /&gt;an additional flag."(not verbatim but on similar lines).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114105057151282245?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114105057151282245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114105057151282245' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114105057151282245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114105057151282245'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/02/new-features-in-java-15.html' title='New features in Java 1.5'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-114077441928105570</id><published>2006-02-24T15:14:00.000+05:30</published><updated>2006-02-24T15:16:59.280+05:30</updated><title type='text'>A bit off track , nevertheless useful</title><content type='html'>Spent a hell lot of time getting this&lt;br /&gt;&lt;br /&gt;How do you find the OS your DB is running on ???????&lt;br /&gt;&lt;br /&gt;As Simple as&lt;br /&gt;&lt;br /&gt;select dbms_utility.port_string from dual;&lt;br /&gt;&lt;br /&gt;Now I am posting it so that I myself dont forget it .....&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-114077441928105570?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/114077441928105570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=114077441928105570' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114077441928105570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/114077441928105570'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/02/bit-off-track-nevertheless-useful.html' title='A bit off track , nevertheless useful'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113989376713849621</id><published>2006-02-14T10:37:00.000+05:30</published><updated>2006-02-14T10:39:27.150+05:30</updated><title type='text'>How does it work</title><content type='html'>int main()&lt;br /&gt;{&lt;br /&gt;return(mycmp("a"));&lt;br /&gt;}&lt;br /&gt;int mycmp(char * a1,char *a2)&lt;br /&gt;{&lt;br /&gt;printf("mycmp called");&lt;br /&gt;return(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$&gt;cc mystring.c&lt;br /&gt;$&gt;./a.out&lt;br /&gt;mycmp called&lt;br /&gt;$&gt;&lt;br /&gt;&lt;br /&gt;How is mycmp called when the parameters are different.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113989376713849621?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113989376713849621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113989376713849621' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113989376713849621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113989376713849621'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/02/how-does-it-work.html' title='How does it work'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113816213475003021</id><published>2006-01-25T09:35:00.000+05:30</published><updated>2006-01-25T09:38:54.766+05:30</updated><title type='text'>Fore-warned is fore-armed</title><content type='html'>&lt;div style="text-align: justify;"&gt;Many of the networking or related applications have to marshal/unmarshal packets to/from structures. And its not uncommon to have more than one field within a byte of a packet. So, what's the best way to construct a packet before sending it over the wire? Say, a SCSI CDB (command descriptor block - similar to an SNMP packet) has to be sent to a device target. Lets simplify the whole thing and say that just 1 byte consisting of 8 1-bit flags is to be sent over the wire. What's the best way to represent such a byte? The first solution that comes to anyone's mind would be bitfields. So, let's go ahead with that.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;typedef struct CDB_Byte {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char a:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char b:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char c:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char d:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char e:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char f:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char g:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&amp;nbsp;&amp;nbsp;unsigned char h:1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;} CDB_Byte;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now I want to set only the LSB(least significant bit) and the one next to it. Okay, that's simple.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CDB_Byte byte;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;byte.h = 1;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;byte.g = 1;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;But, I have a question. Is this the correct way to do it? The answer is NO. Let me illustrate why this is'nt the correct way with a simple example.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;unsigned char c = 0x01;    // LSB set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CDB_Byte byte;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;std::memcpy(&amp;byte, &amp;c, 1);    //copy the bits&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;// to change the value of 'c' to 0x03&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;byte.g = 1;    // set the bit next to the LSB&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;std::memcpy(&amp;c, &amp;amp;amp;byte, 1);     // copy the bits back&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;std::cout &lt;&lt; (unsigned)c;  &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Will this print '3'? The answer is '&lt;span style="font-style: italic;"&gt;depends&lt;/span&gt;'. The language standard does not say anything about the allocation of bitfields. The compilers are free to implement them as they deem fit. On linux, the gcc compiler allocates the bitfields starting from the LSB. This can be verified - the above piece of code prints '65'.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;hgfedcba&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;However on HP-UX, the aCC compiler allocates bitfields starting from the MSB. The above piece of code prints '3' (as one might have expected in the first place).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;abcdefgh&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Moral of the story is this:&lt;/span&gt; Never use bitfields to construct structures containing sub-byte fields. Always use a void * chunk of memory, extract a byte, and use masks and bitwise operators to set/extract sub-byte fields. At least, if you expect your application to be portable, don't use bitfields! I would say that bitfields should never be used anyway, 'cos there's no guarantee that the same application will run on the same platform if the compiler vendor rolls out a newer version.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Fore-warned is fore-armed!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113816213475003021?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113816213475003021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113816213475003021' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113816213475003021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113816213475003021'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/fore-warned-is-fore-armed.html' title='Fore-warned is fore-armed'/><author><name>Srinivasa S</name><uri>https://profiles.google.com/105381729827549201767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-PD41JO_3KRE/AAAAAAAAAAI/AAAAAAAALOU/Xq-oqiUgbEo/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113803851504278852</id><published>2006-01-23T22:15:00.000+05:30</published><updated>2006-01-23T23:18:35.256+05:30</updated><title type='text'>System Calls</title><content type='html'>What is a System call? Why do we need system call? These are the few question raise in mind.&lt;br /&gt;Firstly, System Call is a&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;interface&lt;/span&gt; between the application and the underlying hardware [managed by kernel, Operating System]. Secondly, ensures&lt;span style="font-style: italic;"&gt; &lt;span style="color: rgb(153, 0, 0);"&gt;security and stability&lt;/span&gt;&lt;/span&gt; by not allowing direct access to the hardware. The hardware access[system resources] is maintained by the kernel.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Flow of Execution&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;I will be explaining about how the system call flows.&lt;br /&gt;Consider a printf() call in simple C program, the printf() is an API which inturn call the write system call. System Call are those which are executed in &lt;span style="color: rgb(153, 0, 0);"&gt;Kernel Mode&lt;/span&gt;[or System Mode] in &lt;span style="color: rgb(153, 0, 0);"&gt;Process context&lt;/span&gt;. What I meant was, the system call is only visible to kernel, and it is executed on behalf of the process which calls it, because as I told System Call uses system resources and hardware access, which is managed by Kernel[security issue].&lt;br /&gt;&lt;br /&gt;printf() ---&gt; printf() in the C library ---&gt;write() in C library ---&gt;write()  system call in kernel.&lt;br /&gt;&lt;br /&gt;The printf() in library and write() in the library indicates the conversion of the printf() in application to make an appropriate call to write() in Kernel. Its usually called "stub". Remember the RPC [Remote Procedure Call] stubs, which is used to convert function call and its arguments to some protocol. The library routine is responsible for invoking the system call.&lt;br /&gt;&lt;br /&gt;There is a trap instruction [&lt;span style="color: rgb(153, 0, 0); font-style: italic;"&gt;int 80h&lt;/span&gt; - in x86 arch] that is executed which transfers control from user mode to kernel mode to excute the sytem call. The system call is identified in the kernel by the syscall number that is passed by library routine through a register[&lt;span style="color: rgb(153, 0, 0); font-style: italic;"&gt;EAX&lt;/span&gt; - in x86 arch]. Further on I will explaining w.r.t &lt;span style="font-weight: bold;"&gt;x86 arch&lt;/span&gt; and w.r.t &lt;span style="font-weight: bold;"&gt;Linux OS&lt;/span&gt;. Once the trap instruction is executed, it generates an interrupt which is handled by syscall_handler(). The interrupts are dealt in kernel mode itself. This handler checks for the sytem call number in the syscall_table, which contain a detailed list of all the system calls present the kernel. There is a numerous other checks that needs to be handled[security issues, takes lot of time to explain].&lt;br /&gt;&lt;br /&gt;If the system call is present in the list w.r.t to the syscall number passed in&lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt; EAX&lt;/span&gt;, the system call is invoked with the arguments passed to it. Now, one more question arises, how is the arguments to system call is passed? The answer is through other registers &lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;EBX,ECX,EDX, ESI,EDI&lt;/span&gt; contain the first 5 arguments passed. If the arguments is more than 5, then a pointer to memory location where it is present in the user mode is passed through register.&lt;br /&gt;&lt;br /&gt;In Linux, the return value of each system call is &lt;span style="font-style: italic; color: rgb(153, 0, 0);"&gt;long int&lt;/span&gt; so has to be compatible with the 64-bit arch. The return value is stored in EAX register and switched to user mode.&lt;br /&gt;&lt;br /&gt;Adding a &lt;a href="http://fossil.wpi.edu/docs/howto_add_systemcall.html"&gt;System Call in Linux&lt;/a&gt;. Reusability[of already existing system call] is highly recommended hence think twice before adding a system call.&lt;br /&gt;&lt;br /&gt;For any more details or doubts, scratch a comment to this article.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113803851504278852?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113803851504278852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113803851504278852' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113803851504278852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113803851504278852'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/system-calls.html' title='System Calls'/><author><name>Arvind</name><uri>http://www.blogger.com/profile/16847584348017715735</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='21' src='http://lh5.google.co.uk/arvind.bhushan/RtE6eS--7uI/AAAAAAAAAnM/o_dKPq4B4bo/Ary3.jpg?imgmax=912'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113779497311763536</id><published>2006-01-21T03:23:00.000+05:30</published><updated>2006-01-21T03:40:40.740+05:30</updated><title type='text'>Floating Point Anamoly</title><content type='html'>Source:YPK "Test Your C Skills" Ch-4 "Floating Point Issues" 1st question&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;float a=0.7;&lt;br /&gt;if(a &lt;0.7) a="="b" href="http://docs.sun.com/source/806-3568/ncg_goldberg.html"&gt;IEEE &lt;/a&gt;&lt;br /&gt;and&lt;br /&gt;&lt;a href="http://www.lahey.com/float.htm"&gt;Why this anamoly&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;One good practice is&lt;br /&gt;&lt;br /&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;span class="GramE"&gt;use&lt;/span&gt; something like&lt;o:p style="font-style: italic;"&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;span style="font-style: italic;"&gt;#include &lt;&lt;/span&gt;&lt;span style="font-style: italic;" class="SpellE"&gt;math.h&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&gt;&lt;/span&gt;&lt;o:p style="font-style: italic;"&gt;&lt;/o:p&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt;if(&lt;/span&gt;&lt;span style="font-style: italic;" class="SpellE"&gt;fabs&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(a - b) &lt;= epsilon * &lt;/span&gt;&lt;span style="font-style: italic;" class="SpellE"&gt;fabs&lt;/span&gt;&lt;span style="font-style: italic;"&gt;(a))&lt;/span&gt;&lt;br /&gt;&lt;o:p style="font-style: italic;"&gt;&lt;/o:p&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt;for&lt;/span&gt;&lt;span style="font-style: italic;"&gt; some suitably-chosen degree of closeness epsilon (as long as  &lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt;a&lt;/span&gt;&lt;span style="font-style: italic;"&gt; is nonzero!).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113779497311763536?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113779497311763536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113779497311763536' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113779497311763536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113779497311763536'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/floating-point-anamoly.html' title='Floating Point Anamoly'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113779020751260754</id><published>2006-01-21T02:04:00.000+05:30</published><updated>2006-01-21T02:20:07.523+05:30</updated><title type='text'>Is  a[i] = i++;  valid?</title><content type='html'>This is a very basic question, but many intersting concepts emerge out of it.&lt;br /&gt;&lt;br /&gt;Answer is "Behaviour is Undefined".A compiler may do anything it likes when faced with undefined       behavior (and, within limits, with implementation-defined and       unspecified behavior), including doing what you expect.&lt;span style="font-family: monospace;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;         Briefly: implementation-defined means that an implementation         must choose some behavior and document it. &lt;tt&gt; &lt;/tt&gt;Unspecified means         that an implementation should choose some behavior, but need not         document it. &lt;tt&gt; &lt;/tt&gt;Undefined means that absolutely anything might         happen. &lt;tt&gt; &lt;/tt&gt;In no case does the Standard impose requirements; in         the first two cases it occasionally suggests (and may require a         choice from among) a small set of likely behaviors.&lt;br /&gt;&lt;br /&gt;The concept of sequence point can be used to base a discussion on&lt;br /&gt;A sequence point is a point in time (at the end of the&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;evaluation&lt;/span&gt; of a full expression, or at the ||, &amp;&amp;amp;, ?:, or comma&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;operators&lt;/span&gt;, or just before a function call) at which the dust&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;has&lt;/span&gt; settled and all side effects are guaranteed to be complete.&lt;span style=""&gt;&lt;/span&gt;The ANSI/ISO C Standard states that&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=""&gt;  &lt;br /&gt;            &lt;/span&gt;"&lt;span style="font-style: italic;"&gt;Between the previous and next sequence point an &lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt;object&lt;/span&gt;&lt;span style="font-style: italic;"&gt; shall have its stored value modified at &lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt;most&lt;/span&gt;&lt;span style="font-style: italic;"&gt; once by the evaluation of an expression. Furthermore, the prior value shall be accessed&lt;/span&gt;&lt;span style="font-style: italic;" class="GramE"&gt; only&lt;/span&gt;&lt;span style="font-style: italic;"&gt; to determine the value to be stored.&lt;/span&gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=""&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;The second sentence can be difficult to understand.&lt;span style=""&gt;  &lt;/span&gt;It says&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;that&lt;/span&gt; if an object is written to within a full expression, any&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;and&lt;/span&gt; all accesses to it within the same expression must be for&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;the&lt;/span&gt; purposes of computing the value to be written.&lt;span style=""&gt;  &lt;/span&gt;This rule&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;effectively&lt;/span&gt; constrains legal expressions to those in which the&lt;span style=""&gt; &lt;/span&gt;&lt;span class="GramE"&gt;accesses&lt;/span&gt; demonstrably precede the modification(as above).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113779020751260754?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113779020751260754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113779020751260754' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113779020751260754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113779020751260754'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/is-ai-i-valid.html' title='Is  a[i] = i++;  valid?'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113715562058198363</id><published>2006-01-13T17:58:00.000+05:30</published><updated>2006-01-13T18:03:40.590+05:30</updated><title type='text'>C++: Strange name lookup</title><content type='html'>&lt;span style="font-family: verdana;"&gt;This is something I never knew and read about it recently in "&lt;/span&gt;&lt;span style="font-style: italic; font-family: verdana;"&gt;Exceptional C++&lt;/span&gt;&lt;span style="font-family: verdana;"&gt;". Let me start with a code example...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;namespace A {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;class S { };&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;void foo(S&amp; parm)  { }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;namespace B {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;void foo(A::S&amp; parm) { }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;void bar(A::S&amp; parm) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foo(parm);  // Which "foo" does this call?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;Try this out and to your surprise you'll find that this gives a "&lt;/span&gt;&lt;span style="font-weight: bold; font-family: verdana;"&gt;call to foo is ambiguous&lt;/span&gt;&lt;span style="font-family: verdana;"&gt;" error. But why?? The only foo visible at the place of call is in namespace B. Why should this result in an error? Okay, now try this out - comment out the "foo" definition in namespace B&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;namespace A {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;class S { };&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;void foo(S&amp; parm)  { }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; namespace B {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;// void foo(A::S&amp; parm) { }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;void bar(A::S&amp; parm) {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foo(parm);  // Which "foo" does this call?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: verdana;"&gt;This compiles without errors!&lt;/span&gt;&lt;span style="font-family: verdana;"&gt; Surprised again? When you run the program, it'd have called A::foo. What happened here? Does this not appear to be a namespace violation. Apparently not! This strange behavior is explained by "&lt;/span&gt;&lt;span style="font-weight: bold; font-style: italic; font-family: verdana;"&gt;Koenig lookup&lt;/span&gt;&lt;span style="font-family: verdana;"&gt;" also known as "&lt;span style="font-weight: bold; font-style: italic;"&gt;Argument dependent lookup&lt;/span&gt;".&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: georgia;"&gt;&lt;span style="font-family: verdana;"&gt;If you supply a function argument of class type (here parm, of type A::S), then to find the function name the compiler considers matching names in the namespace (here A) containing the argument's type.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: georgia;"&gt;&lt;span style="font-family: verdana;"&gt;But still, is'nt this a namespace violation?? &lt;/span&gt;&lt;span style="font-weight: bold; font-family: verdana;"&gt;NO&lt;/span&gt;&lt;span style="font-family: verdana;"&gt;. Just consider this piece of code...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;std::string str("Hello"); &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;std::cout &lt;&lt; str; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;This works fine right? How? This works because of Koenig lookup. The function in question here is "operator &lt;&lt;" which is found in "namespace std". But we have'nt used any "using" declaration to bring that function into the current scope. Since std::string is going as an argument into that function, the compiler will automatically look into the std namespace and will find that function. Without this kind of lookup, the same function call would have to be written as...&lt;br /&gt;&lt;br /&gt;&lt;/span&gt; &lt;span style="font-family: courier new;"&gt;std::operator &lt;&lt;( std::cout, str) ;  // ugly! ain't it?? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana;"&gt;This is the great value that Koenig lookup gets us and we tend to use it every now and then without realising it. Interesting - is'nt it??&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113715562058198363?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113715562058198363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113715562058198363' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113715562058198363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113715562058198363'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/c-strange-name-lookup.html' title='C++: Strange name lookup'/><author><name>Srinivasa S</name><uri>https://profiles.google.com/105381729827549201767</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-PD41JO_3KRE/AAAAAAAAAAI/AAAAAAAALOU/Xq-oqiUgbEo/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113678472722289121</id><published>2006-01-09T09:53:00.001+05:30</published><updated>2006-01-09T11:05:24.146+05:30</updated><title type='text'>cURL -- A tool limited by imagination</title><content type='html'>&lt;title&gt;&lt;/title&gt;  &lt;p class="MsoNormal" style="margin-bottom: 12pt;"&gt;A stock ticker is a piece of code which keeps you updated with the latest(as and when) stock quotations of various companies at the stock exchange. Technically to build this one needs the following tools --&lt;/p&gt;   &lt;ol start="1" type="1"&gt; &lt;li class="MsoNormal" style=""&gt;XML&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;RSS&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;cURL&lt;/li&gt;&lt;li class="MsoNormal" style=""&gt;sed,awk,grep and simple shell      scripting knowledge.&lt;/li&gt; &lt;/ol&gt;   &lt;p class="MsoNormal"&gt;1. &lt;a href="http://www.w3schools.com/xml/default.asp"&gt;XML&lt;/a&gt;&lt;br /&gt;Need to know just this concepts &lt;a href="http://www.w3schools.com/xml/xml_elements.asp"&gt;elements&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2. &lt;a href="http://en.wikipedia.org/wiki/Rss"&gt;RSS&lt;/a&gt; (Really Simple Syndicate) -- it is really simple.&lt;br /&gt;As I understand this, there is a link like "http://www.xanadb.com/ticker/YHOO" which provides RSS feed for stocks(YHOO- for yahoo, MSFT-microsoft).&lt;br /&gt;Now observe the xml format carefully. All rss feeds essentially have these 3 elements&lt;br /&gt;title,descrption,link.&lt;br /&gt;An RSS reader is one which makes sense of this rss feed.&lt;br /&gt;&lt;br /&gt;So to build the stock ticker here is the design&lt;br /&gt;a) Get the contents of "http://www.xanadb.com/ticker/YHOO" in a variable.&lt;br /&gt;b) Just find the “title” tag. Trash the rest.&lt;br /&gt;c) Find the number and thats it.&lt;br /&gt;&lt;br /&gt;3. &lt;a href="http://curl.haxx.se/docs/httpscripting.html"&gt;cURL&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now to achieve step (a) mentioned above we have to use a tool which gets us the contents of the page in a variable or a file.&lt;br /&gt;&lt;br /&gt;cURL is shipped freely with most of the Linux installations.&lt;br /&gt;&lt;br /&gt;Catch hold of one and execute this&lt;br /&gt;&lt;br /&gt;curl "http://www.xanadb.com/ticker/YHOO"&lt;br /&gt;&lt;br /&gt;Now go through the manual in case you are using proxies, SSL protected site, etc etc etc.&lt;br /&gt;&lt;br /&gt;Now the power is all yours. Just think all the stuff possible with this tool and have i told you this. Its a MIT product.&lt;br /&gt;&lt;br /&gt;4. sed,grep and other scripting techniques&lt;br /&gt;&lt;br /&gt;Here after its  child's play and the scripting skills.&lt;br /&gt;&lt;br /&gt;curl "http://www.xanadb.com/ticker/YHOO"  | grep title | sed s/title//g&lt;br /&gt;&lt;br /&gt;I havent tried the above on a machine , but hope you got an idea as to how the attempt is being made to get the stock quote.&lt;/p&gt;   &lt;h3&gt;Conclusion&lt;/h3&gt;   &lt;p class="MsoNormal"&gt;No matter how hard web designers may try to force you to surf their sites interactively, there will always be free tools to help automate the process, thus enriching our overall Net experience.&lt;br /&gt;A deliberate attempt has been made only to answer the "How" part of the tools and not the "What" part of them, as they are available in the links suggested.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-size:13;"&gt;Next in Line&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;PODCAST -- what the hell is this&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113678472722289121?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113678472722289121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113678472722289121' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113678472722289121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113678472722289121'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/curl-tool-limited-by-imagination_09.html' title='cURL -- A tool limited by imagination'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113678461586199049</id><published>2006-01-09T09:53:00.000+05:30</published><updated>2006-01-09T11:14:39.263+05:30</updated><title type='text'>cant use html tags</title><content type='html'>After writing the article , I just realized that some html tags (like title, link etc in the exact syntax) cant be used in the article. So I could not use the tags correctly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113678461586199049?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113678461586199049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113678461586199049' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113678461586199049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113678461586199049'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2006/01/cant-use-html-tags.html' title='cant use html tags'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-20309183.post-113587869576086930</id><published>2005-12-29T22:09:00.001+05:30</published><updated>2005-12-29T23:21:35.763+05:30</updated><title type='text'>Knowledge POOLING</title><content type='html'>This blog is entirely dedicated to beat the technical thirst in us.&lt;br /&gt;Hope we all appreciate the need for it and also contribute effectively towards it.&lt;br /&gt;&lt;br /&gt;There only&lt;b&gt;   etiquette &lt;/b&gt;to be followed is&lt;br /&gt;&lt;br /&gt;                                                                       "&lt;span style="font-style: italic; font-weight: bold;font-size:180%;" &gt;&lt;span style="color: rgb(102, 0, 0);"&gt;Be Techie&lt;/span&gt;&lt;/span&gt;"&lt;br /&gt;&lt;br /&gt;Oh by the way Arvind came up with this fundu idea again.&lt;br /&gt;Post all the new techie stuf you learn, so that the whole group can leverage your techno abilities. Active discussion on various topics will help us better ourselves than anybody else.&lt;br /&gt;Knowledge only increases by sharing---what say.&lt;br /&gt;&lt;br /&gt;Just to inspire&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;A man is but what he knows. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;- &lt;/span&gt;Francis Bacon&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/20309183-113587869576086930?l=puretechie.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://puretechie.blogspot.com/feeds/113587869576086930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=20309183&amp;postID=113587869576086930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113587869576086930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/20309183/posts/default/113587869576086930'/><link rel='alternate' type='text/html' href='http://puretechie.blogspot.com/2005/12/knowledge-pooling.html' title='Knowledge POOLING'/><author><name>Shantanu</name><uri>http://www.blogger.com/profile/00088855664889365698</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://1.bp.blogspot.com/_JA3lb64jYDE/SrM3DnsB7GI/AAAAAAAACu0/PNoVBld7NkI/S220/Shantanu-small.JPG'/></author><thr:total>0</thr:total></entry></feed>
