<?xml version="1.0" encoding="ISO-8859-1"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xml:lang="en-US">
	<title>Shuva&#039;s blog</title>
	<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php" />
	<modified>2010-09-08T14:47:38Z</modified>
	<author>
		<name>Shuva Brata Deb</name>
	</author>
	<copyright>Copyright 2010, Shuva Brata Deb</copyright>
	<generator url="http://www.sourceforge.net/projects/sphpblog" version="0.4.8">SPHPBLOG</generator>
	<entry>
		<title>Bought two domains for daughter</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry100706-042447" />
		<content type="text/html" mode="escaped"><![CDATA[Noting that domain names are exhausting, why not buy domain names for your kids as a gift for them when they grow up. My parents did a good job in giving me an unique name, that I found <a href="http://www.shuva.in/" target="_blank" >shuva.in</a> available even after 30 Gregorian years and at 74.9 Internet years. Yes I am 74.9 internet years old as per <a href="http://whatsmyinternetage.com/" target="_blank" >whatsmyinternetage.com</a>.<br /><br />Back to the point, the new domains I got for my 2.5 year old daughter are <a href="http://tishadeb.com/" target="_blank" >tishadeb.com</a> and <a href="http://tishadeb.in" target="_blank" >tishadeb.in</a><br /><br />On a related note, of late I have found that the cheapest web hosting solution exists at <a href="http://nearlyfreespeech.net" target="_blank" >nearlyfreespeech.net</a>. It all about clould hosting and you pay for what you use.<br /><br />Happy internetting.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry100706-042447</id>
		<issued>2010-07-06T00:00:00Z</issued>
		<modified>2010-07-06T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Overdoing password policies</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry100624-233519" />
		<content type="text/html" mode="escaped"><![CDATA[Imagine this:<br /><br />You try to register by creating a user name and password. Its common and expected for the system to force you to choose a unique user name. However how would you react if you get a message that says:<br /><br /><h5>&quot;This password is already taken, please choose a unique password&quot;</h5><br /><br />--- Is this the way to prevent password reuse? Darn!<br /><br />Happy passwording.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry100624-233519</id>
		<issued>2010-06-24T00:00:00Z</issued>
		<modified>2010-06-24T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Cyclomatic complexity</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry091210-145416" />
		<content type="text/html" mode="escaped"><![CDATA[I came across this interesting metric called &quot;Cyclomatic complexity&quot; at work today. It is measurement of how complex a function is in terms of the logical branches it has.<br /><br />The <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity" target="_blank" >formal definition as in Wikipedia</a> is quite mathematical and not in tune with the thinking of the like minded people visiting my blog.<br /><br />A far less and simple definition can be found at <a href="http://www.codeproject.com/KB/architecture/Cyclomatic_Complexity.aspx" target="_blank" >this code project article </a>which says to calculate this metric:<br /><br />•	Start with 1 for a straight path through the routine. <br />•	Add 1 for each of the following keywords or their equivalent: if, while, repeat, for, and, or. <br />•	Add 1 for each case in a switch statement. <br /><br />There is another defintion as seen in Ncover&#039;s site which says <br /><br /><i>The cyclomatic complexity value is the maximum number of test cases needed to get 100% branch coverage, and the minimum number of test cases needed to exercise every path through a method, so it provides a good way to tell how well-tested a method is.</i><br /><br />Happy cyclomatting.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry091210-145416</id>
		<issued>2009-12-10T00:00:00Z</issued>
		<modified>2009-12-10T00:00:00Z</modified>
	</entry>
	<entry>
		<title>So many software development  methods</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry091202-065713" />
		<content type="text/html" mode="escaped"><![CDATA[I never knew that we have so many software development methods that exist until I read some stuff today. If you had asked me yesterday I would have said:<br /><br />1. Waterfall ---- thats what I learnt in my first few months at TCS.<br /><br />2. Spiral --- the diagram when I first saw looked confusing, but thats what I do mostly these days.<br /><br />3. Extreme programming --- I had spent some time with a start up. Definitely productive with so less management interference. You were almost always the boss but of an extremely small team and which is sometimes just you.<br /><br />The others which are interesting to know and are formal methods are:<br /><br />1. Structured Programming Development -- everything is structured, disciplined.<br /><br />2. Cleanroom -- strong focus towards defect prevention. Quality is though design+coding and not testing.<br /><br />3. Iterative development -- I dont know how this is different from the Spiral method.<br /><br />4. Prototyping --- do prototyping, go to user, re-prototype until acceptable. Sounds like RnD project to me.<br /><br />5. Modified Prototype Model --- Like web-page maintenance. Start simple, keep on modifying based on user needs.<br /><br />6. Rapid Application Development --- No time, just do it.<br /><br />7. Joint Analysis Development --- Developers work closely with end-users to develop the software.<br /><br />8. Exploratory model --- Requirements not known initially, but lets start the project and we will see what is needed.<br /><br />That makes eleven Software Development models. Woow!<br /><br />Happy Modelling.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry091202-065713</id>
		<issued>2009-12-02T00:00:00Z</issued>
		<modified>2009-12-02T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Cross platform XML library comparison</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090708-013943" />
		<content type="text/html" mode="escaped"><![CDATA[I fond this nice site comparing various cross-platform XML libraries. They have a very good benchmark data with lots of graphs. Very useful for making project decisions:<br /><br /><a href="http://iweb.dl.sourceforge.net/sourceforge/xmlbench/features.pdf" target="_blank" >Feature comparison</a><br /><br /><a href="http://iweb.dl.sourceforge.net/sourceforge/xmlbench/benchmark.pdf" target="_blank" >Benchmark sheet 1</a><br /><br /><a href="http://iweb.dl.sourceforge.net/sourceforge/xmlbench/benchmark200402.pdf" target="_blank" >Benchmark sheet 2</a><br /><br />Happy XXLing.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090708-013943</id>
		<issued>2009-07-08T00:00:00Z</issued>
		<modified>2009-07-08T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Recession and Alibaba</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090614-022913" />
		<content type="text/html" mode="escaped"><![CDATA[One more effect of recession. Children at school now read &quot;Alibaba and the thirty thieves&quot;.<br /><br />Happy reading.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090614-022913</id>
		<issued>2009-06-14T00:00:00Z</issued>
		<modified>2009-06-14T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Tips for speeding up your Windows XP box</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090419-012507" />
		<content type="text/html" mode="escaped"><![CDATA[If you also want to speed up your Windows XP box, the following link serves as a good article.<br /><br /><a href="http://www.overclock.net/windows/9836-xp-definitive-performance-tweaking-guide.html" target="_blank" >Windows XP Definitive Performance Tweaking guide</a><br /><br /><br /><b>Real life incident:</b><br /><b>Shuva</b>: (@ office, losing patience waiting for his laptop to shut down). I will take this question to my grave.<br /><b>Anadi </b>: What question?<br /><b>Shuva </b>: Why does Windows take a lifetime to shutdown?<br /><b>Anadi </b>: (brief pause, shakes his legs as usual, thinks)<br />...<br />...<br /><b>Anadi </b>: Everybody takes a lifetime to shutdown.<br /><br /><br />Happy Tweaking.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090419-012507</id>
		<issued>2009-04-19T00:00:00Z</issued>
		<modified>2009-04-19T00:00:00Z</modified>
	</entry>
	<entry>
		<title>The Computer Security Radar Page link</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090409-090647" />
		<content type="text/html" mode="escaped"><![CDATA[I liked this live page<br /><br /><a href="http://www.securitywizardry.com/radar.htm" target="_blank" >Computer Network Defence Operational Picture</a><br /><br />Hope you like(bookmark) it too.<br /><br />Happy Scanning.//]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090409-090647</id>
		<issued>2009-04-09T00:00:00Z</issued>
		<modified>2009-04-09T00:00:00Z</modified>
	</entry>
	<entry>
		<title>C++ : A lock with a timeout : Example code</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090409-041844" />
		<content type="text/html" mode="escaped"><![CDATA[When we use a mutex and wait on it, we basically ASSUME that somebody else is going to release the lock. Most of the time this assumption works. But there can be a situation when you dont want to wait forever on the lock. In such cases we want to have a GetLock() function that has a time out.<br /><br />One such lock exists in Boost and they are:<br /><a href="http://www.boost.org/doc/libs/1_32_0/doc/html/timed_mutex.html" target="_blank" >boost::timed_mutex</a> and<br /><a href="http://www.boost.org/doc/libs/1_32_0/doc/html/recursive_timed_mutex.html" target="_blank" >boost::recursive_timed_mutex</a><br /><br />Unfortunately there are too many good resources that explain boost locks with examples. Here is one crude example that I had to write for my own practice.<br /> <br /><pre><br />#include &lt;iostream&gt;<br />#include &lt;boost/thread/thread.hpp&gt;<br />#include &lt;boost/thread/locks.hpp&gt;<br />#include &lt;sys/types.h&gt;<br />#include &lt;linux/unistd.h&gt;<br /><br />_syscall0(pid_t,gettid)<br /><br />boost::timed_mutex m_mutex;<br /><br />void Thread1_CreateObjectAndWait() {<br />    //Get the lock <br />    boost::timed_mutex::scoped_lock guard(m_mutex);<br />    std::cout &lt;&lt; gettid()  &lt;&lt; &quot;: Thread  got the lock&quot; &lt;&lt; std::endl;<br /><br />    boost::system_time timeout = boost::get_system_time() +<br />                             boost::posix_time::milliseconds(10000);<br /><br />    std::cout &lt;&lt; gettid() <br />              &lt;&lt; &quot;: Waiting for thread 2 to unlock or else timeout&quot; <br />              &lt;&lt; std::endl;<br />    bool ret = m_mutex.timed_lock(timeout);<br /><br />    if (ret == true) { <br />        std::cout &lt;&lt; gettid() &lt;&lt; &quot;: Got the lock before timeout&quot; <br />                  &lt;&lt; std::endl;<br />    } else {<br />        std::cout &lt;&lt; gettid() &lt;&lt; &quot;: Got the lock after timeout&quot; <br />                  &lt;&lt; std::endl;<br />    }       <br />    <br />}<br /><br />void Thread2_Unlock() {<br />    std::cout &lt;&lt; gettid() &lt;&lt; &quot; : Unlocking the mutex &quot; &lt;&lt; std::endl;<br />    m_mutex.unlock() ;<br />}<br /><br /><br />int main() {<br /><br />    //Create thread 1, which will lock itself and wait for thread 2 <br />    //to unlock or timeout.<br />    boost::thread thread1(&amp;Thread1_CreateObjectAndWait);<br /><br />    //sleep some time to give time for thread 1 to start.<br />    sleep(2);<br />    <br />    //create thread 2 which will unlock before thread 1 gets a timeout.<br />    boost::thread thread2(&amp;Thread2_Unlock);<br /><br />    //Create thread 3,  which will lock itself and wait for thread 2 <br />    //to unlock or timeout.<br />    boost::thread thread3(&amp;Thread1_CreateObjectAndWait);<br /><br />    thread1.join();<br />    thread2.join();<br />    thread3.join();<br />    return 0;<br />}<br /><br /></pre><br />The above code compiled with g++ with the following command:<br /><br /><pre>g++ example.cpp -I&lt;path to boost include dir&gt;  &lt;path to boost lib dir&gt;/libboost_thread-gcc34-mt.a  -lpthread</pre><br /><br />The o/p should look something like:<br /><pre>28061: Thread  got the lock<br />28061: Waiting for thread 2 to unlock or else timeout<br />28062 : Unlocking the mutex <br />28061: Got the lock before timeout<br />28063: Thread  got the lock<br />28063: Waiting for thread 2 to unlock or else timeout<br />28063: Got the lock after timeout</pre><br /><br /><br />PS: To compile on Windows, replace gettid() with GetCurrentThreadId() and remove the linux specific header file.<br /><br />Happy Boosting.//<br />]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090409-041844</id>
		<issued>2009-04-09T00:00:00Z</issued>
		<modified>2009-04-09T00:00:00Z</modified>
	</entry>
	<entry>
		<title>Bash Arithmetic : Leading 0 (zero) errors : value too great for base</title>
		<link rel="alternate" type="text/html" href="http://blog.shuva.in/index.php?entry=entry090322-073532" />
		<content type="text/html" mode="escaped"><![CDATA[It can be quite frustrating at time when you cannot get a simple thing as doing a arithmetic expression where the number has a leading zero. I am talking of Bash arithmetic.<br /><br />Example: <br /><b>let x=7*5</b> is OK.<br /><br /><br /><b>let x=07*5 </b>is also OK<br /><br />But <br /><b>let x=08*5 </b>gives the following error:<br /><font color=red>bash: let: x=081: value too great for base (error token is "081")</font><br /><br />The reason is that numbers with leading 0 is treated as octal in Bash. So 01, 02, 03 ...07 would not have any problem. 08, 09 are not valid octal numbers and hence treated so.<br /><br />OK, OK. How to get rid of a leading zero. Unfortunately in Bash its not so straight forward. Here are some useful hints:<br /><br />1. Use a loop like this to get rid of leading zeros from the variable x<br /><pre>while [[ $a = 0* ]]<br />do <br />a=${a#0} <br />done</pre><br /><br />2. The second solution is to explicity mention that it is a base 10 number, which can be quite cumbersome.<br /><pre><br />y=081<br />let x=10#$y*7; #Treat 08 as a base 10 digit.</pre><br /><br /><br />Happy Bashing.//<br />]]></content>
		<id>http://blog.shuva.in/index.php?entry=entry090322-073532</id>
		<issued>2009-03-22T00:00:00Z</issued>
		<modified>2009-03-22T00:00:00Z</modified>
	</entry>
</feed>

