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

<channel>
	<title>Praveen Kumar &#187; Computers</title>
	<atom:link href="http://praveen.kumar.in/category/computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://praveen.kumar.in</link>
	<description>Random thoughts collection bucket</description>
	<lastBuildDate>Sat, 01 May 2010 04:15:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Introduction to Test-Driven Development in C++ using Boost Test Library</title>
		<link>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/</link>
		<comments>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/#comments</comments>
		<pubDate>Sat, 01 May 2010 04:12:40 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=609</guid>
		<description><![CDATA[<p>I have been following Test-Driven Development for a few years now. Even though TDD is widespread, often I come across a few friends who aren&#8217;t very familiar with TDD approach. It took a while for me to really appreciate TDD since I was introduced to it. When I demonstrated TDD in action, I got a [...]]]></description>
			<content:encoded><![CDATA[<p>I have been following <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test-Driven Development</a> for a few years now. Even though TDD is widespread, often I come across a few friends who aren&#8217;t very familiar with TDD approach. It took a while for me to really appreciate TDD since I was introduced to it. When I demonstrated TDD in action, I got a few of my friends interested.</p>
<p>We have our <a href="http://unittest.red-bean.com/">own test framework</a> that we use in our project which was primarily developed by <a href="http://malvasiabianca.org/">David Carlton</a>. It works very well for our needs. However, for my personal projects, I wanted to try something that is more widely used in the industry. I started using <a href="http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page">CppUnit</a> for a while until I found <a href="http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/index.html">Boost Test Library</a> coming a long way. Now, I use Boost Test Library for all my personal projects. It is very easy to setup tests and I really like it.</p>
<p>I also wanted to write a quick introduction to Boost Test Library. So, I thought that I will put down a screencast that will solve two purposes of demonstrating Boost Test Library and serve as an introduction to TDD. This is not an extensive demo or an introduction. I have chosen a really simple problem that is often asked in preliminary rounds of technical interviews. But, it is a good place to start. I don&#8217;t guarantee that the solution is efficient. But, it is correct to my knowledge. Please feel free to suggest issues or improvements.</p>
<p>Please note that a HD version of this video is available when viewed on <a href="http://www.vimeo.com/">Vimeo&#8217;s site</a>.</p>
<div align="center">
<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11370903&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11370903&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object>
<p><a href="http://vimeo.com/11370903">Introduction to Test Driven Development in C++ using Boost Test Library</a> from <a href="http://vimeo.com/user3715271">Praveen Kumar</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</div>
<p><span id="more-609"></span></p>
<p><strong>Problem:</strong><br />
Implement a function &#8216;<code>int atoi(const std::string &#038;val)</code>&#8216; that converts the given string in decimal notation to its integer value. Return 0 if the input is not a valid integer.</p>
<p><strong>Source code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;string&gt;</span>
&nbsp;
<span style="color: #339900;">#define BOOST_TEST_MODULE atoi</span>
<span style="color: #339900;">#define BOOST_TEST_DYN_LINK</span>
&nbsp;
<span style="color: #339900;">#include &lt;boost/test/unit_test.hpp&gt;</span>
&nbsp;
<span style="color: #0000ff;">namespace</span> impl <span style="color: #008000;">&#123;</span>
&nbsp;
<span style="color: #0000ff;">int</span> <span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span> <span style="color: #000040;">&amp;</span>val<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    <span style="color: #0000ff;">int</span> result <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">int</span> multiplier <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
    <span style="color: #0000ff;">bool</span> negative <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
&nbsp;
    <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #008080;">::</span><span style="color: #007788;">const_reverse_iterator</span> i <span style="color: #000080;">=</span> val.<span style="color: #007788;">rbegin</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
         i <span style="color: #000080;">&lt;</span> val.<span style="color: #007788;">rend</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #000040;">++</span>i<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
        <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000080;">&lt;=</span> <span style="color: #FF0000;">'9'</span> <span style="color: #000040;">&amp;&amp;</span> <span style="color: #000040;">*</span>i<span style="color: #000080;">&gt;=</span> <span style="color: #FF0000;">'0'</span> <span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
            result <span style="color: #000040;">+</span><span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000040;">-</span> <span style="color: #FF0000;">'0'</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">*</span> multiplier<span style="color: #008080;">;</span>
            multiplier <span style="color: #000040;">*</span><span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span><span style="color: #008080;">;</span>
        <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
            <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">*</span>i <span style="color: #000080;">==</span> <span style="color: #FF0000;">'-'</span> <span style="color: #000040;">&amp;&amp;</span> i <span style="color: #000080;">==</span> val.<span style="color: #007788;">rend</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
                negative <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
                <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0000ff;">return</span> negative <span style="color: #008080;">?</span> <span style="color: #000040;">-</span>result <span style="color: #008080;">:</span> result<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#125;</span> <span style="color: #666666;">// namespace impl</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>unit_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;6&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">6</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>tenth_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;45&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">45</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>large_number<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;123456789&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">123456789</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>negative_number<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;-876&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #000040;">-</span><span style="color: #0000dd;">876</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>sign_in_wrong_position<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;72-56&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
BOOST_AUTO_TEST_CASE<span style="color: #008000;">&#40;</span>invalid<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
    BOOST_CHECK_EQUAL<span style="color: #008000;">&#40;</span>impl<span style="color: #008080;">::</span><span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;abcd&quot;</span><span style="color: #008000;">&#41;</span>, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>Compilation and execution:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;"># g++ -g -lboost_unit_test_framework -o atoi atoi.cpp &amp;&amp; ./atoi --log_level=test_suite --report_level=short</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/04/30/introduction-to-test-driven-development-in-c-using-boost-test-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple GNU Emacs keyboard macro demonstration</title>
		<link>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/</link>
		<comments>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 21:15:36 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=603</guid>
		<description><![CDATA[<p>My obsession for GNU Emacs has grown over years to an extent where I managed to get a significant amount of users to adopt Emacs. In the past 10 years, I have learned a lot of nice tricks that I can do on Emacs to improve my productivity. So, I have decided to create a [...]]]></description>
			<content:encoded><![CDATA[<p>My obsession for <a href="http://www.gnu.org/software/emacs/">GNU Emacs</a> has grown over years to an extent where I managed to get a significant amount of users to adopt Emacs. In the past 10 years, I have learned a lot of nice tricks that I can do on Emacs to improve my productivity. So, I have decided to create a series of screencasts demonstrating some of those.</p>
<p>I will start with a very simple one, <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html">macros</a>. Quoting from Emacs documentation, &#8220;A keyboard macro is a command defined by an Emacs user to stand for another sequence of keys. For example, if you discover that you are about to type <code>C-n M-d C-d</code> forty times, you can speed your work by defining a keyboard macro to do <code>C-n M-d C-d</code>, and then executing it 39 more times.&#8221;</p>
<p>In this demo, I have taken a real world example where you have to add C++ class member variables and accessors. There are other efficient ways to do such tasks in GNU Emacs. I personally use <a href="http://code.google.com/p/yasnippet/">yasnippets</a> to do these things. However, this approach is shown just to demonstrate keyboard macros. To supplement this video, please take a look at the keyboard macro documentation that is available within Emacs.</p>
<div align="center">
<object width="640" height="505"><param name="movie" value="http://www.youtube.com/v/L6qSWqKz3eQ&#038;hl=en_US&#038;fs=1&#038;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/L6qSWqKz3eQ&#038;hl=en_US&#038;fs=1&#038;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="505"></embed></object>
</div>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/04/03/simple-gnu-emacs-keyboard-macro-demonstration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting untruncated command line options passed to a Solaris process</title>
		<link>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/</link>
		<comments>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 00:41:23 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=591</guid>
		<description><![CDATA[<p>If you have ever wanted to get the command line options that were passed to a running Solaris process, you might have noticed that the output of command line arguments from ps is truncated to 80 characters. Looking into /usr/include/sys/procfs.h will reveal the reason why! This is because of the restriction in struct psinfo. Here [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever wanted to get the command line options that were passed to a running Solaris process, you might have noticed that the output of command line arguments from <code>ps</code> is truncated to 80 characters. Looking into <code>/usr/include/sys/procfs.h</code> will reveal the reason why! This is because of the restriction in <code>struct psinfo</code>. Here are the relevant fields from the definition of <code>struct psinfo</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define	PRFNSZ		16	/* Maximum size of execed filename */</span>
<span style="color: #339933;">#define	PRARGSZ		80	/* number of chars of arguments */</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> psinfo <span style="color: #009900;">&#123;</span>
         <span style="color: #808080; font-style: italic;">/* Fields omitted */</span>
         <span style="color: #993333;">char</span> pr_fname<span style="color: #009900;">&#91;</span>PRFNSZ<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>    <span style="color: #808080; font-style: italic;">/* name of exec'ed file */</span>
         <span style="color: #993333;">char</span> pr_psargs<span style="color: #009900;">&#91;</span>PRARGSZ<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #808080; font-style: italic;">/* initial characters of arg list */</span>
         <span style="color: #808080; font-style: italic;">/* Fields omitted */</span>
<span style="color: #009900;">&#125;</span> psinfo_t<span style="color: #339933;">;</span></pre></div></div>

<p>So, due to the 80 characters restriction in <code>psinfo::pr_psargs</code>, the kernel will not be keeping track of arguments beyond the limit. Now, the only way to get the information is from the process&#8217; memory of <code>argv</code>. In order to do this, you should have access to read the processes&#8217; memory. This is the trick employed by both <code>pargs</code> and BSD version of <code>ps</code> with <code>-ww</code> switch.</p>
<p>To get the full length command line arguments passed to a process, you can do one of the following.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ /usr/ucb/ps eww &lt;pid&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pargs -l &lt;pid&gt;</pre></div></div>

<p>One catch here is that, if the process has modified the <code>argv</code> since it was started, the output reported by both <code>ps</code> and <code>pargs</code> will show the modified data and not the initial arguments that were passed in. However, modifying <code>argv</code> within a program is not a standard practice and hence the chance of encountering such a scenario is remote.</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/02/24/getting-untruncated-command-line-options-passed-to-a-solaris-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dumping core file from set-UID, set-GID &#8216;ed processes in Solaris</title>
		<link>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/</link>
		<comments>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 23:52:44 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=586</guid>
		<description><![CDATA[<p>I had a previous post on how to turn on core files for set-UID, set-GID processes under Linux. Recently we ran into the same problem on Solaris. To turn on core files for set-id processes, use coreadm.</p>

$ pfexec coreadm -e global-setid

<p>Please keep in mind that these core files can have information that non-privileged user isn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I had a <a href="http://praveen.kumar.in/2008/06/05/dumping-core-file-from-set-uid-set-gid-ed-processes-in-linux/">previous post</a> on how to turn on core files for set-UID, set-GID processes under Linux. Recently we ran into the same problem on Solaris. To turn on core files for set-id processes, use <code>coreadm</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pfexec coreadm -e global-setid</pre></div></div>

<p>Please keep in mind that these core files can have information that non-privileged user isn&#8217;t supposed to know. Quoting from Solaris man page:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">     A process that is or ever has been setuid  or  setgid  since
     its  last  exec(2)  presents  security issues that relate to
     dumping  core.  Similarly,  a  process  that  initially  had
     superuser  privileges  and  lost  those  privileges  through
     setuid(2) also presents security issues that are related  to
     dumping core. A process of either type can contain sensitive
     information in  its  address  space  to  which  the  current
     nonprivileged  owner  of the process should not have access.
     If setid core files are enabled, they are created  mode  600
     and owned by the superuser.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/02/23/dumping-core-file-from-set-uid-set-gid-ed-processes-in-solaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling virtual consoles in OpenSolaris</title>
		<link>http://praveen.kumar.in/2010/02/19/enabling-virtual-consoles-in-opensolaris/</link>
		<comments>http://praveen.kumar.in/2010/02/19/enabling-virtual-consoles-in-opensolaris/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 04:23:58 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=574</guid>
		<description><![CDATA[<p>OpenSolaris was lacking virtual console for a while. This support was made available since build snv_124. However, due to various bugs, it is turned off by default. To enable virtual consoles, do the following.</p>

$ pfexec svcadm enable vtdaemon
$ pfexec svcadm enable console-login:vt2
$ pfexec svcadm enable console-login:vt3
$ pfexec svcadm enable console-login:vt4
$ pfexec svcadm enable console-login:vt5
$ pfexec [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.opensolaris.org/">OpenSolaris</a> was lacking virtual console for a while. This support was made available since build snv_124. However, due to various bugs, it is turned off by default. To enable virtual consoles, do the following.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pfexec svcadm enable vtdaemon
$ pfexec svcadm enable console-login:vt2
$ pfexec svcadm enable console-login:vt3
$ pfexec svcadm enable console-login:vt4
$ pfexec svcadm enable console-login:vt5
$ pfexec svcadm enable console-login:vt6</pre></div></div>

<p>To enable hot keys for switching virtual consoles, do the following.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pfexec svccfg -s vtdaemon setprop options/hotkeys=true
$ pfexec svcadm refresh vtdaemon
$ pfexec svcadm restart vtdaemon</pre></div></div>

<p>Console security is enabled by default. What it means is that if you leave a virtual console and move to another one, the previous virtual console will be locked and you will have to provide the password to unlock it. If you don&#8217;t like that, turn the security off.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pfexec svccfg -s vtdaemon setprop options/secure=false
$ pfexec svcadm refresh vtdaemon
$ pfexec svcadm restart vtdaemon</pre></div></div>

<p>If you have already logged into an X session while doing this, logout and wait for Xorg to restart. After that, you should be able to switch between the virtual consoles by pressing the hotkey <code>Alt + Ctrl + F#</code>, where # => 1 to 7. Console 1 is the primary console, 2-6 are virtual consoles and 7 is the Xorg.</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2010/02/19/enabling-virtual-consoles-in-opensolaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random links for week 50</title>
		<link>http://praveen.kumar.in/2009/12/12/random-links-for-week-50/</link>
		<comments>http://praveen.kumar.in/2009/12/12/random-links-for-week-50/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 18:18:55 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Health & Fitness]]></category>
		<category><![CDATA[fitness]]></category>
		<category><![CDATA[gnu]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=549</guid>
		<description><![CDATA[
We were troubleshooting an interesting problem with GCC/gdb that caused gdb to report an argument passed by reference as if it was passed by value. In the process, I was digging up some DWARF information. Ever wondered what exactly gcc is adding to support the debuggers when you use &#8216;-g&#8217; switch? Michael J. Eager has [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>We were troubleshooting an interesting problem with <a href="http://gcc.gnu.org/">GCC</a>/<a href="http://www.gnu.org/software/gdb/">gdb</a> that caused gdb to report an argument passed by reference as if it was passed by value. In the process, I was digging up some <a href="http://en.wikipedia.org/wiki/DWARF">DWARF</a> information. Ever wondered what exactly gcc is adding to support the debuggers when you use &#8216;-g&#8217; switch? Michael J. Eager has an excellent &#8220;<a href="http://dwarfstd.org/Debugging%20using%20DWARF.pdf">Introduction to DWARF Debugging Format</a>&#8221; article.
</li>
<li>I Found that <a href="http://docs.sun.com/app/docs/doc/819-3683">Sun Studio dbx</a> can handle binaries created by GCC with DWARF-2 debugging information very well. Sun Wiki has a page describing the <a href="http://wikis.sun.com/display/SunStudio/Dwarf+Differences+between+Sun+Studio+and+GCC+compilers">DWARF differences</a> between Sun Studio and GCC compilers.</li>
<li>Last week, the launch of Russian missile, Bulava caused quite a stir in Norway. Russian strategic nuclear forces <a href="http://russianforces.org/blog/2009/12/no_luck_for_bulava.shtml">blog claims</a> that the test was a failure. However, I see some comments that suggests that the spiral motion was a feature instead of a bug. Here is the <a href="http://www.youtube.com/watch?v=lYvM68AtlbA">video</a> of one of those UFO (later identified as Bulava) sightings.
</li>
<li>To include a little more variety in my exercise routines, I am planning to include some <a href="http://en.wikipedia.org/wiki/Plyometrics">Plyometrics</a>. Currently, I am improving my weighted <a href="http://en.wikipedia.org/wiki/Squat_%28exercise%29">squats</a> by going for high intensity squats. Squats is one of the exercise that I hate. However, in terms of fitness routines, I find doing something that I hate pays off very well.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2009/12/12/random-links-for-week-50/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random links for week 46</title>
		<link>http://praveen.kumar.in/2009/11/14/random-links-for-week-46/</link>
		<comments>http://praveen.kumar.in/2009/11/14/random-links-for-week-46/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 03:40:19 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Health & Fitness]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[fitness]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=544</guid>
		<description><![CDATA[
Editing big chunks of text in Firefox text area is a pain. I am using &#8220;It&#8217;s all Text&#8221; Firefox add-on to edit text from a text area in external editors like Emacs, Vim, etc. I have configured my add-on to use emacsclient. I use this heavily when I have to edit text in TWiki, Bugzilla, [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>Editing big chunks of text in Firefox text area is a pain. I am using <a href="https://addons.mozilla.org/en-US/firefox/addon/4125">&#8220;It&#8217;s all Text&#8221;</a> Firefox add-on to edit text from a text area in external editors like Emacs, Vim, etc. I have configured my add-on to use <a href="http://www.emacswiki.org/emacs/EmacsClient">emacsclient</a>. I use this heavily when I have to edit text in TWiki, Bugzilla, Wordpress, etc. This post is written in Emacs using this add-on.</li>
<li>Speaking of TWiki, I discovered last week that there is an Emacs major mode for editing TWiki markup. It is <a href="http://www.neilvandyke.org/erin-twiki-emacs/">erin.el</a>, named after Erin Gray. It has some WYSIWYG capabilities and a markup sampler. I will start using it to see how useful it would be.</li>
<li>I started using <a href="http://orgmode.org/worg/org-contrib/babel/org-babel.php">Org-babel</a>, that lets you to execute source code in various languages within Org-mode documents. It is really cool! It can also do cool syntax highlighting in the exported files.
</li>
<li>I store my daily weight measurements as an Org table in Emacs. I was using <a href="http://www.gnuplot.info/">Gnuplot</a> to plot these values to track progress. Last week, I learned about <a href="http://www.r-project.org/">R project</a> and started experimenting a bit with it as well. Data visualization really helps.
</li>
<li>From next week, I am adding <a href="http://en.wikipedia.org/wiki/High-intensity_interval_training">HIIT cardio</a> sessions to my exercise routine. I am going to have my HIIT sessions on non-lifting days, which seems to be the most recommended strategy. I don&#8217;t love cardio as much as lifting weights. But, I am eagerly looking for experimenting with HIIT.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2009/11/14/random-links-for-week-46/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix mouse cursor jumping to top left corner of screen on OpenSolaris</title>
		<link>http://praveen.kumar.in/2009/09/12/fix-mouse-cursor-jumping-to-top-left-corner-of-screen-on-opensolaris/</link>
		<comments>http://praveen.kumar.in/2009/09/12/fix-mouse-cursor-jumping-to-top-left-corner-of-screen-on-opensolaris/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 19:12:03 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=494</guid>
		<description><![CDATA[
Update 2009-11-07: This issue is fixed in OpenSolaris build snv_126.</p>

<p>OpenSolaris dev repository update snv_116 introduced an XOrg bug that caused the mouse cursor to jump to the top left corner of the screen very frequently. Apparently, there is some floating point math issue is involved using MMX/SSE2 instructions. I was living with the workaround posted [...]]]></description>
			<content:encoded><![CDATA[<div align='center'>
<blockquote><strong>Update 2009-11-07:</strong> This issue is fixed in OpenSolaris build snv_126.</p></blockquote>
</div>
<p><a href="http://opensolaris.org/os/">OpenSolaris</a> <a href="http://pkg.opensolaris.org/dev/en/index.shtml">dev repository</a> update snv_116 introduced an <a href="http://www.x.org/wiki/">XOrg</a> <a href="http://defect.opensolaris.org/bz/show_bug.cgi?id=9862">bug</a> that caused the mouse cursor to jump to the top left corner of the screen very frequently. Apparently, there is some floating point math issue is involved using MMX/SSE2 instructions. I was living with the workaround posted on <a href="http://defect.opensolaris.org/bz/show_bug.cgi?id=9862">bugzilla</a>. I was hoping that the bug would soon be fixed in the subsequent updates. Yesterday, I updated to build <a href="http://mail.opensolaris.org/pipermail/opensolaris-announce/2009-September/001256.html">snv_122</a> and found that the issue still exists. Hence, I am posting about the workaround to fix this issue.</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">$ pfexec bash
# cp -p /usr/X11/bin/i386/Xorg /usr/X11/bin/i386/Xorg.orig 
# echo 'xf86SigioReadInput+9?w 770f 9090 9090' | mdb -w /usr/X11/bin/i386/Xorg</pre></div></div>

<p>This bug is currently tracked in <a href="http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6849925">bugster</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2009/09/12/fix-mouse-cursor-jumping-to-top-left-corner-of-screen-on-opensolaris/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Per-user Mercurial Installation</title>
		<link>http://praveen.kumar.in/2009/09/05/per-user-mercurial-installation/</link>
		<comments>http://praveen.kumar.in/2009/09/05/per-user-mercurial-installation/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 11:58:48 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://praveen.kumar.in/?p=496</guid>
		<description><![CDATA[<p>Recently, I had to install Mercurial on one of our Solaris 10 development machines without root access. The installation procedure was a little bit tricky. So, I thought it would be helpful to share the experience. </p>
<p>First, I downloaded Mercurial source and extracted it. This is a standard procedure for installing any package from source.</p>

$ [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I had to install <a href="http://mercurial.selenic.com/wiki/">Mercurial</a> on one of our Solaris 10 development machines without root access. The installation procedure was a little bit tricky. So, I thought it would be helpful to share the experience. </p>
<p>First, I downloaded Mercurial source and extracted it. This is a standard procedure for installing any package from source.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ wget http://mercurial.selenic.com/release/mercurial-1.3.tar.gz
$ tar -zxvf mercurial-1.3.tar.gz
$ cd mercurial-1.3</pre></div></div>

<p>The installation mechanism is directly controlled by the <code>Makefile</code>. Per-user installation can be selected by choosing <code>Makefile</code> target <code>install-home</code>, <code>install-home-bin</code> or <code>install-home-doc</code>. The target <code>install-home</code> is a collection of <code>install-home-bin</code> and <code>install-home-doc</code> targets. The target <code>install-home-bin</code> builds/installs Mercurial binaries and the target <code>install-home-doc</code> builds/installs Mercurial documentation. To build the documentation, we would need <a href="http://www.methods.co.nz/asciidoc/">ASCIIDOC</a> and <a href="https://fedorahosted.org/xmlto/">XMLTO</a>. So, I decided to skip building the documentation. The target that I chose was <code>install-home-bin</code>. The installation prefix can be controlled by the environment variable <code>HOME</code>.</p>
<p>The build process uses C compiler to compile Mercurial extensions written in C and linker to create the shared libraries. We need to specify the desired compiler and linker through <code>CC</code> and <code>LD</code> environment variables respectively. When using GCC, we need to specify <code>CFLAGS</code> to build relocatable objects. If the Python library is located in a non-standard location, we have to specify <code>LDFLAGS</code> appropriately as well. Here is how my compilation line looked like.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ make install-home-bin HOME=/home/praveen/chaos.SunOS CC=gcc CFLAGS=&quot;-fPIC&quot; \
    LDSHARED=&quot;gcc -shared&quot; LDFLAGS=&quot;-L/opt/csw/lib -Wl,-R/opt/csw/lib&quot;</pre></div></div>

<p><span id="more-496"></span></p>
<p>Once installed, I had to configure my <code>PATH</code> and <code>PYTHONPATH</code> with the location of installation. To make this persistent, I had to add it to <code>~/.bashrc</code> file.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ export PYTHONPATH=${HOME}/chaos.SunOS/lib/python
$ export PATH=${HOME}/chaos.SunOS/bin:$PATH</pre></div></div>

<p>Now I verified that Mercurial  worked fine by running the following.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ hg debuginstall
Checking encoding (ascii)...
Checking extensions...
Checking templates...
Checking patch...
Checking commit editor...
Checking username...
 No username found, using 'praveen@HOSTCENSORED' instead
 (specify a username in your .hgrc file)
No problems detected</pre></div></div>

<p>Happy distributed version controlling!</p>
<p>[ad#page-footer-adsense-728x90]</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2009/09/05/per-user-mercurial-installation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GNOME Metacity dual screen issue in OpenSolaris 2009.06</title>
		<link>http://praveen.kumar.in/2009/06/03/gnome-metacity-dual-screen-issue-in-opensolaris-2009-06/</link>
		<comments>http://praveen.kumar.in/2009/06/03/gnome-metacity-dual-screen-issue-in-opensolaris-2009-06/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 17:51:34 +0000</pubDate>
		<dc:creator>Praveen Kumar</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://praveen.kumar.net.in/journal/?p=478</guid>
		<description><![CDATA[<p>With the latest OpenSolaris 2009.06, maximizing windows managed by Metacity (GNOME) will maximize the windows across both screens. This is due to an issue that Metacity was trying to use a wrong Xinerama type. This issue is fixed in the mercurial repository. However, the fix was not on time to make it into the final [...]]]></description>
			<content:encoded><![CDATA[<p>With the latest OpenSolaris 2009.06, maximizing windows managed by Metacity (GNOME) will maximize the windows across both screens. This is due to an issue that <a href="http://defect.opensolaris.org/bz/show_bug.cgi?id=8748">Metacity was trying to use a wrong Xinerama type</a>. This issue is fixed in the mercurial repository. However, the fix was not on time to make it into the final release of OpenSolaris 2009.06. But, there is a quick workaround for this issue. Here is the set of instructions.</p>
<p><strong>Step 1.</strong> Backup your current metacity.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ pfexec cp /usr/bin/metacity /usr/bin/metacity.orig</pre></div></div>

<p><strong>Step 2.</strong> Download the fixed Metacity binary from developer&#8217;s site and replace the original binary.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ wget http://www.gnome.org/~erwannc/bugs/8748/metacity -O /tmp/metacity
$ pfexec cp /tmp/metacity /usr/bin/metacity</pre></div></div>

<p><del datetime="2009-08-04T06:16:03+00:00"><strong>Note:</strong> Don&#8217;t do this in one step using <code>wget -O /usr/bin/metacity</code>. This broke my system.</del></p>
<p><strong>Step 3. (Optional)</strong> By now, your new Metacity should have already started working. If not, replace the current instance by hand.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ metacity --replace</pre></div></div>

<p>Happy dual-screening on your OpenSolaris 2009.06!</p>
]]></content:encoded>
			<wfw:commentRss>http://praveen.kumar.in/2009/06/03/gnome-metacity-dual-screen-issue-in-opensolaris-2009-06/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
