<?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>Chunhao&#039;s Blog &#187; linux</title>
	<atom:link href="http://chunhao.net/blog/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://chunhao.net/blog</link>
	<description>Life happens. Love helps.</description>
	<lastBuildDate>Fri, 28 May 2021 12:36:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.1</generator>
	<item>
		<title>Are Your Fingers Long Enough to Use Vim?</title>
		<link>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/</link>
		<comments>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 12:14:27 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=122</guid>
		<description><![CDATA[Note: I wrote this post just for fun. Please don’t take it seriously. Thank you! Which editor are you using, Vim or Emacs? And why? Next time, when you are arguing with other people about which editor is better and trying to persuade others to use your favorite editor, just forget it. If you believe [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><span style="color: #ff0000;">Note: I wrote this post just for fun. Please don’t take it seriously.</span> <span style="color: #ff0000;"> Thank you!</span> <img src="http://chunhao.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>Which editor are you using, Vim or Emacs? And why?</p>
<p>Next time, when you are arguing with other people about which editor is better and trying to persuade others to use your favorite editor, just forget it. If you believe everything is in destiny, it is not an exception for the editor you choose. The choice is written on your fingers.</p>
<p>Several days ago, I learnt from <a href="http://mike.struct.cn">Mike</a> that the choice between using Vim or Emacs depends on your fingers. As he figured out, people have longer fingers prefer to use Vim, while people have shorter fingers prefer to use Emacs. It is amazing, but reasonable.</p>
<p>Using Vim, the most frequent key you hits might be the &#8220;Esc&#8221;. Vim has three modes: insert mode, command mode and visual mode. Command mode is the bridge of other two modes, and most of navigating and searching is done in command mode. So, when you are using Vim, you must: press &#8220;a&#8221; or &#8220;i&#8221; to start insert mode and input something, then press the &#8220;Esc&#8221; to enter the command mode and do navigation, then enter the insert mode again and then press the &#8220;Esc&#8221; to the command mode. Maybe some times you want to hit &#8220;v&#8221; to enter the visual mode to select something, and after that you must hit the &#8220;Esc&#8221; again back to the command mode. At most time, you are hitting the &#8220;Esc&#8221;. That&#8217;s why they call Vim &#8220;hit Esc to death&#8221;. Of course, you also need Ctrl and Shift in vim, but not so often. For example, when you select contents by line or by block, you will press &#8220;Shift+v&#8221; or &#8220;Ctrl+v&#8221;. When you want to jump to the end of a line, you will press &#8220;$&#8221;(Shift+4). But these cases are much rearer than hitting the &#8220;Esc&#8221;. So, when your fingers are long enough, you will find it very comfortable and easy to hit the &#8220;Esc&#8221;. Maybe that&#8217;s why you like to use Vim.</p>
<p>I have touched Emacs for little times. In Emacs, almost everything except for inputing text are done by &#8220;Ctrl+something&#8221;, &#8220;Shift+something&#8221;, &#8220;Alt+something&#8221;, or even &#8220;Ctrl+Alt/Shift+something&#8221;. That means at most time, one of your finger must hit &#8220;Ctrl&#8221;, &#8220;Shift&#8221; or &#8220;Alt&#8221;. That&#8217;s why they call Emacs &#8220;hit Ctrl to death&#8221;. Some Emacs fans even want to use pedals to help them hit hot keys. I have to twist my fingers to hit those keys. For some complicated combination of keys, I even don&#8217;t know how to hit them comfortably and elegantly. So I gave up Emacs soon to save my hands and fingers. Maybe people who have shorter fingers would fall in love with Emacs because they could hit these hot keys easily without twisting their fingers very much.</p>
<p>Although I prefer Vim, I don&#8217;t mean to comment Emacs and Emacs users. Emacs is also powerful, and even more powerful than Vim (at least in my mind). I admire Emacs users very much because they can learn so many hot keys by heart and use them gently and easily.</p>
<p>If you are still confusing about choosing Vim or Emacs, just check your finger. If your fingers are longer than most of your friends, then just choose Vim without hesitate and you will like the life of hitting the &#8220;Esc&#8221;. If your fingers are shorter than average and you find it&#8217;s uncomfortable to hit the &#8220;Esc&#8221; frequently, then you should definitely choose Emacs.</p>
<p>If you are still arguing with other people about Vim and Emacs, forget it, unless you want to cut some one&#8217;s finger to force them to use Emacs or lengthen some one&#8217;s finger to force them to use Vim.</p>
<p>If you are jeered by Emacs users for you are using such a disharmonious editor that has multiple confusing modes, you could respond them, &#8220;at least I have beautiful long fingers&#8221;. If you are sneered by Vim users for you are using such a complicated editor that requires a pedal to handle the hot keys, you could respond them, &#8220;at least my memory is better than you, since I could remember thousands of hot keys&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/are-your-fingers-long-enough-to-use-vim/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Which email client are you using?</title>
		<link>http://chunhao.net/blog/which-email-client-are-you-using/</link>
		<comments>http://chunhao.net/blog/which-email-client-are-you-using/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 16:59:18 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[email client]]></category>
		<category><![CDATA[evolution]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=110</guid>
		<description><![CDATA[What can you do for killing time? Maybe you could figure out what email clients your contacts are using. It&#8217;s funny. Most people prefer webmail, especially Gmail. Webmail is very easy to use and does not require much configuration. Gmail is the most wonderful webmail. It groups messages by threads and it has a powerful [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>What can you do for killing time? Maybe you could figure out what email clients your contacts are using. It&#8217;s funny.</p>
<p>Most people prefer webmail, especially Gmail. Webmail is very easy to use and does not require much configuration. Gmail is the most wonderful webmail. It groups messages by threads and it has a powerful searching tool. You can easily find out what you want from the mass.</p>
<p>However, one drawback of webmail is that you cannot access your mail off-line. Although Gmail started to support off-line email recently, I still think that keeping the emails in my local storage is safe and reliable. Moreover, an email client is generally much more customizable than webmail. So, I am using <a href="http://www.gnome.org/projects/evolution/">Evolution</a>, which is the most powerful and standard email client in Linux, to receive and send email everyday.</p>
<p>As said in the beginning, I want to figure out what email clients my contacts are using. This work is not hard. There might be some fields in the header of email indicating which client this email is generated. The field could be named &#8220;X-Mailer&#8221;, &#8220;X-mailer&#8221;, or &#8220;User-Agent&#8221;. In Evolution, you can open the menu &#8220;Edit&gt;Preferences&gt;Mail Preferences&gt;Headers&#8221;, and check the &#8220;Mailer&#8221;. Then you could see the Mailer information in your mails. Some mails are composed without the Mailer information. I don&#8217;t know why. We just ignore the mails without Mailer information.</p>
<p>Evolution stores mails in the folder &#8220;~/.evolution/mail/local/Inbox.sbd&#8221;. Under this folder, the files without extension are the mail files, which included all the contents of your mail. So, we can grab Mailer informations from these files.</p>
<p>First, we can use &#8220;grep&#8221; to filter the lines containing &#8220;X-Mailer&#8221;, &#8220;X-mailer&#8221;, and &#8220;User-Agent&#8221;. We can store them into a file.</p>
<blockquote><p>cat mail-box-name | grep X-Mailer &gt; outfile</p>
<p>cat mail-box-name | grep X-mailer &gt;&gt; outfile</p>
<p>cat mail-box-name | grep User-Agent &gt;&gt; outfile</p></blockquote>
<p>&#8220;mail-box-name&#8221; is the name of the mail files. Carefully name the outfile. Don&#8217;t let it overwrite the existing file. My suggestion is that you can copy all the mail files to another place and do these operations there. It&#8217;s safe.</p>
<p>Now we get the outfile containing Mailer information. The next step is removing useless information from this file, such as the header &#8220;X-Mailer&#8221; or the version information. This is the most boring part. Maybe there are some sophisticated methods which could do this work automatically, but I am lazy to think them up. For me, I use Vim and <a href="http://en.wikibooks.org/wiki/Learning_the_vi_editor/Vim/Modes">block-edit</a> the text (ctrl+v, then move cursor), and this work is done without much effort. Now we get the file like this:</p>
<blockquote><p>&#8230;<br />
Moto-EZX<br />
Moto-EZX<br />
Moto-EZX<br />
Mozilla<br />
Mozilla<br />
Mozilla<br />
Mutt<br />
Mutt<br />
&#8230;</p></blockquote>
<p>Then we should count them. Use this command:</p>
<blockquote><p>uniq -c inputfile &gt; outputfile</p></blockquote>
<p>Finally we get the file like this:</p>
<blockquote><p>&#8230;<br />
84 Evolution<br />
182 Foxmail<br />
1956 G2/1.0<br />
&#8230;</p></blockquote>
<p>Maybe we need some refinement for these data. For example, remove the very rare entries (e.g &lt; 10), and remove the entries that are obviously web server, such as &#8220;ASPMail&#8221;, &#8220;PHPMail&#8221;, etc.</p>
<p>After refinement, there we come to the OpenOffice Spreadsheet for analyzing these data. Again, we use Vim and block-editing to separate the count and client name, and paste them into  Spreadsheet individually. Then open &#8220;Insert&gt;Chart&#8221; and generate your favourite chart.</p>
<p>Following is my data, in which the size of sample is 3003 (after refinement):</p>
<p style="text-align: center;"><a href="http://chunhao.net/blog/wp-content/uploads/2009/06/data2.png"><img class="aligncenter size-full wp-image-111" title="email-client-distribution" src="http://chunhao.net/blog/wp-content/uploads/2009/06/data2.png" alt="email-client-distribution" width="528" height="264" /></a></p>
<p style="text-align: left;">From the chart we can see the most popular email client of my contacts is Gmail (G2/1.0). Following are Thunderbird and Foxmail. Then it comes Evolution, Apple Mail, SquirrelMail, Outlook and SFUwebmail.</p>
<p>Which client are you using?</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/which-email-client-are-you-using/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tools for Reading Sources</title>
		<link>http://chunhao.net/blog/tools-for-reading-sources/</link>
		<comments>http://chunhao.net/blog/tools-for-reading-sources/#comments</comments>
		<pubDate>Thu, 21 May 2009 11:39:17 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Doxygen]]></category>
		<category><![CDATA[LXR]]></category>
		<category><![CDATA[LXRng]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[Source Navigator]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=88</guid>
		<description><![CDATA[Hacking is a good method of learning. And the pre-stage of hacking is reading the source code. You might have this experience: facing a large amount of source code (generally dozens of files), you don&#8217;t know how to start, or you even don&#8217;t know how to read them. A good tool is very helpful for [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Hacking is a good method of learning. And the pre-stage of hacking is reading the source code. You might have this experience: facing a large amount of source code (generally dozens of files), you don&#8217;t know how to start, or you even don&#8217;t know how to read them. A good tool is very helpful for reading code. It can facilitate your understanding of the code and help you find out the things you want as soon as possible. I will introduce you some wonderful tools of browsing sources.</p>
<p>For me, the must-have feathers of a source browsing tool should be:</p>
<ol>
<li>Syntax highlighting</li>
<li>Friendly user interface</li>
<li>Identifier and function search</li>
</ol>
<p>If you are a Windows user, you might have heard about Source Insight, which is a non-free software. I haven&#8217;t used it, so I am not going to comment it.</p>
<p>For Linux user, the first tool I want to mention is <a href="http://sourcenav.sourceforge.net/">Source Navigator</a>. It is developed and supported by Red hat. It supports C, C++, Java, Tcl, FORTRAN and COBOL. It&#8217;s very powerful. But if you just want to browse sources, I don&#8217;t recommend you to use it. Since it GUI is developed in Tcl, an ancient programming language, the user interface is not very friendly. I bet you don&#8217;t like it.</p>
<p>Another wonderful software is <a href="http://www.doxygen.org">Doxygen</a>. Although it aims to generate documents various programming languages, including C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, and to some extent D, you can treat it as a source browsing tool. It can generate documents in HTML format. So you can read them via Firefox. If the source code is well commented following JavaDoc&#8217;s style, a beautiful documents describing classes, variables, functions could be generated. If the source code is not commented in JavaDoc&#8217;s style, the documents could also be generated, but it just have source codes, without these detailed description about classes, variables, and functions. Doxygen can also generate class-graphs, call-graphs and other similar graphs in UML style, which will help you understand the source.</p>
<p>The disadvantage of Doxygen is that its search result is somehow coarse-grained. It cannot distinguish variables from functions in search result. And it cannot differentiate definition, declaration and reference. So, if you are dealing with a huge project, you may find it uncomfortable to read source generated by Doxygen.</p>
<p>The ultimate tool, in my view, is <a href="http://sourceforge.net/projects/lxr">LXR</a>, which stand for Linux Corss Referencer. Specially, it may be the best choice for you to read Linux source code. Although, namely, LXR aim for Linux source code, it suitable for other projects written in C/C++, COBOL, Java, Perl. It is a web based tool and you can read the source code via Firefox. It uses a database to management cross references. So the search result is very accurate. And it can differentiate definition, declaration and reference.</p>
<p>LXR is famous for its difficulty on setup and configuration. And its user interface cannot be called &#8220;beautiful&#8221;. Luckily, the next generation, <a href="http://lxr.linux.no/">LXRng</a> (<a href="http://lxr.linux.no/linux">demo</a>) is available now. LXRng has a very beautiful and friendly user interface.  Moreover, setup and configuration for LXRng is much simpler than LXR. However, it seems that LXRng currently only support C language. If you need it for C++, you need a slight hack:</p>
<p>Locate to your LXRng&#8217;s installation directory, then open this file:</p>
<blockquote><p>lib/LXRng/Lang/C.pm</p></blockquote>
<p>Find the following code from this file:</p>
<pre lang="perl">sub pathexp {
    return qr/.[ch]$/;
}</pre>
<p>And change it into:</p>
<pre lang="perl">sub pathexp {
    return qr/.[ch]$|.cpp$/;
}</pre>
<p>Then LXRng should support the C++ files.</p>
<p>Doxygen and LXRng could satisfy most of your requirement. Maybe reading source from Firefox is strange and unfamiliar to you, but I think you will going to like it if you just have a try. If you have no idea about how to use them, just go to their websites, where you can find plenty of documents and toturials.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/tools-for-reading-sources/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Burning Video DVD on Ubuntu</title>
		<link>http://chunhao.net/blog/burning-video-dvd-on-ubuntu/</link>
		<comments>http://chunhao.net/blog/burning-video-dvd-on-ubuntu/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 15:21:04 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[DVD]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=73</guid>
		<description><![CDATA[Burning video DVD is harder than you think. It involves transcoding, subtitles, burning and other complicated things. Each step may not work for you, let alone on Ubuntu! I just created my first video DVD. My experience may help you get less trouble on burning your video DVD on Ubuntu/Linux. Most DVD videos are encoded [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Burning video DVD is harder than you think. It involves transcoding, subtitles, burning and other complicated things. Each step may not work for you, let alone on Ubuntu!</p>
<p>I just created my first video DVD. My experience may help you get less trouble on burning your video DVD on Ubuntu/Linux.</p>
<p>Most DVD videos are encoded in <a href="http://en.wikipedia.org/wiki/MPEG-2">MPEG-2</a> format. So, if your original video is not encoded into MPEG-2, the first thing you need to do is to transcode it into MPEG-2. There are lots of powerful tools to handle it, such as <a href="http://www.ffmpeg.org/">ffmpeg</a> and <a href="http://www.mplayerhq.hu/">mencoder</a>. They are command-line tools. If you are a crazy fan of command line, you definitely should try them. However, the command line arguments will generally be 10 lines! If you cannot handle them(like me), just try some GUI tools.</p>
<p>The first option is <a href="http://fixounet.free.fr/avidemux/">Avidemux</a>. It&#8217;s powerful and easy to use. However, its <a href="http://en.wikipedia.org/wiki/H264">H264</a> support is poor. When I tried to transcode a H264 video into MPEG-2, it crashed every time. Maybe it works fine with other format, but I have no chances to take a try.</p>
<p>Another great transcoding tool is <a href="http://gtk-apps.org/content/show.php/Hyper+Video+Converter?content=88970">Hyper Video Converter</a>. It&#8217;s a front-end of ffmpeg and mencoder. Although it looks a bit &#8220;Shanzhai&#8221;, it&#8217;s more powerful than its appearance, since it&#8217;s the frontend of powerful ffmpeg and mencoder. It&#8217;s quite reliable. I used it to transcode my H264 &#8220;mkv&#8221; file into MPEG-2 &#8220;mpg&#8221; file. I recommend you to use it, if you have no requirement on gaudy appearance. The KDE version is <a href="http://www.kde-apps.org/content/show.php/Hyper+Video+Converter?content=67781">here</a>.</p>
<p>Then it goes to create DVD file structure.  Generally, we need a folder contains VEDIO_TS and AUDIO_TS folders and put some necessary information files in them. This work can be done by <a href="http://dvdauthor.sourceforge.net/">dvdAuthor</a>. It&#8217;s also command line based tool. As introduced in its website, there are several frontend for it. The most famous one is <a href="http://qdvdauthor.sourceforge.net/">QDvdauthor</a>. The newest version for Hardy in <a href="http://www.getdeb.net/app/QDVDAuthor">Getdeb</a> is 1.5.0, which is even lower in repository. 1.5.0 has much bugs in creating subtitles, You should use the newest version, 1.7.0, which is available in Getdeb for Intrepid. I am using Hardy, so I compiled 1.7.0 and created a deb package by myself. Grab it if you need.</p>
<p>Now, we are using QDvdauthor 1.7.0. Just create you your DVD file structure using the MPEG-2 video encoded by  Hyper Video Converter. There are some <a href="http://qdvdauthor.sourceforge.net/guide/e_index.html">tutorials</a> for QDvdauther.  Just take a tour if have problems on how to start.</p>
<p>Once you get the DVD file structure including VIDEO_TS and AUDIO_TS, you can test them via VLC or SMPlayer. Take SMPlayer for example, select &#8220;Open&#8221;-&gt;&#8221;DVD from folder&#8221; to test the video.</p>
<p>If everything works, you can create an ISO image. I recommend you to create ISO image and burn image by your self, using <a href="http://www.cdrkit.org/">genisoimage</a> and K3B. Because there are much things that you can control. The most important thing is that current version of genisoimage has a <a href="https://bugs.launchpad.net/debian/+source/cdrkit/+bug/233942">huge bug</a>. The image created by it is not readable by Windows and standalone DVD machine. This bug is not solved in even the latest version 1.9.0. You have to downgrade you genisoimage into 1.2.0 from <a href="http://packages.debian.org/es/etch/genisoimage">debian repository</a>.</p>
<p>One thing that QDvdauther cannot control is the volume name of the image. This is why I recommend you to create ISO image by yourself. You can use this command:</p>
<blockquote><p>genisoimage -dvd-video -udf -V &#8220;Volume-Name&#8221; -o &#8220;dvd.iso&#8221; &#8220;DVD-folder&#8221;</p></blockquote>
<p>&#8220;dvd.iso&#8221; is the ISO image you are going to create. And &#8220;DVD-folder&#8221; is the folder contains VEDIO_TS and AUDIO_TS folders.</p>
<p>Then, add the Error Correction Codes(ECC) to the image</p>
<blockquote><p>dvdisaster -i &#8220;/tmp/Unnamed/dvd.iso&#8221; -mRS02 -n 350000 -c</p></blockquote>
<p>If this command issues error message, maybe you should remove the option &#8220;-n 350000&#8243; or adjust it.</p>
<p>At the last step, burn this ISO image by whatever software you like.</p>
<p>Enjoy your video DVD created on Ubuntu/Linux!</p>
<p>Following is the deb package of QDvdauthor 1.7.0. It could be installed on Ubuntu 8.04.</p>
<p><a href="http://chunhao.net/blog/wp-content/uploads/2009/04/qdvdauthor-170.deb">qdvdauthor-170_deb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/burning-video-dvd-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to synchronize with SSH</title>
		<link>http://chunhao.net/blog/how-to-synchronize-with-ssh/</link>
		<comments>http://chunhao.net/blog/how-to-synchronize-with-ssh/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 06:08:26 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[synchronize]]></category>

		<guid isPermaLink="false">http://chunhao.net/blog/?p=52</guid>
		<description><![CDATA[I will share my experience in synchronizing files with SSH here. Following are demonstrated by synchronizing Dokuwiki. Of course, you can synchronize everything as you like. The wiki I used in my homepage is Dokuwiki. The most great feature is that it does not require database connection. It&#8217;s very convenience for personal usage. I have [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I will share my experience in synchronizing files with SSH here. Following are demonstrated by synchronizing Dokuwiki. Of course, you can synchronize everything as you like.</p>
<p>The <a href="http://chunhao.net/wiki/">wiki</a> I used in my homepage is <a href="http://www.dokuwiki.org/">Dokuwiki</a>. The most great feature is that it does not require database connection. It&#8217;s very convenience for personal usage.</p>
<p>I have two Dokuwiki maintained. One is located in localhost, another in the webserver. I always edit the pages on localhost, and synchronize them to the webserver at times. Since Dokuwiki is totally PHP based, without database such as MySQL, I only need to synchronize some files.</p>
<p>All the changes on wiki are reflected on the folder &#8220;data&#8221; in your Dokuwiki path. So every time, I only need to synchronize this folder.</p>
<p>The best way to communicate with webserver is SSH. Fortunately, my webserver <a href="https://www.godaddy.com/">Godaddy</a> support SSH access. Another thing need to concern is synchronizer. Here I use <a href="http://www.cis.upenn.edu/~bcpierce/unison/">Unison</a>. The best description of Unison comes from it&#8217;s the author of this software:</p>
<blockquote><p>A file-synchronization tool for Unix and Windows<br />
Unison is a file-synchronization tool for Unix and Windows, written<br />
in OCaml. It allows two replicas of a collection of files and<br />
directories to be stored on different hosts (or different disks<br />
on the same host), modified separately, and then brought up to<br />
date by propagating the changes in each replica to the other.</p>
<p>Unison offers several advantages over various synchronization methods<br />
such as CVS, Coda, rsync, Intellisync, etc. Unison can run on and<br />
synchronize between Windows and many UNIX platforms. Unison requires<br />
no root privileges, system access or kernel changes to function. Unison<br />
can synchronize changes to files and directories in both directions,<br />
on the same machine, or across a network using ssh or a direct<br />
socket connection.</p>
<p>Transfers are optimised using a version of the rsync protocol,<br />
making it ideal for slower links. Unison has a clear and precise<br />
specification, and is resilient to failure due to its careful<br />
handling of the replicas and its private structures.</p></blockquote>
<p>If you are using Ubuntu machine, you can install it from the repository just by one command:</p>
<blockquote><p>sudo apt-get install unison</p></blockquote>
<p>There is also a gtk front-end for this software: unison-gtk, but I think it&#8217;s useless at most time.</p>
<p>Now, another problem comes to front&#8211;in order to synchronize files with SSH, both installations of Unison on client and server are required. However, at most time, you don&#8217;t have the permission to install software such as unison on SSH server. Here, we attack this issue by SSHFS. It allows you to mount a remote folder on your machine via SSH.</p>
<p>Everything is OK. I wrote a small script to handle the synchronization:</p>
<pre lang="bash">#!/bin/sh
sshfs -o workaround=rename username@sshserver:/path/html/wiki wiki-remote/
echo "Synchronising with sshserver"
unison /var/www/dokuwiki/data ./wiki-remote/data 
  -fastcheck yes 
  -ignore 'Path cache' 
  -ignore 'Path locks'</pre>
<p>Modify it to fit your actual environment. Note that the argument of sshfs command &#8220;-o workaround=rename&#8221;, this prevents the &#8220;<a href="http://ubuntuforums.org/showthread.php?t=553103">renaming problem</a>&#8220;.</p>
<p>All things done. Excute this script. Or, you could add an cron job to run this script automatically once per day. Have fun in synchronizing files with SSH!</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/how-to-synchronize-with-ssh/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Upgrading to Hardy</title>
		<link>http://chunhao.net/blog/upgrading-to-hardy/</link>
		<comments>http://chunhao.net/blog/upgrading-to-hardy/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 13:30:08 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/upgrading-to-hardy</guid>
		<description><![CDATA[Upgrading is evil. Although sometimes software need upgrading, in order to fix bugs, or add new supporting, when you find bugs, there are only two things you can do for it. The first is fixing it yourself, while the second is waiting for upgrade. On the other hand, you might find some bugs appears after [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Upgrading is evil.</p>
<p>Although sometimes software need upgrading, in order to fix bugs, or add new supporting, when you find bugs, there are only two things you can do for it. The first is fixing it yourself, while the second is waiting for upgrade. On the other hand, you might find some bugs appears after you upgrading a software, which worked well before. It&#8217;s hard to tell why we are willing to upgrade it. Just for upgrading?</p>
<p>Almost 5 months have passed since <a href="http://www.ubuntu.com/">Ubuntu 8.04</a> &#8220;Hardy Heron&#8221; had released. And even &#8220;Intrepid Ibex&#8221; is coming within one month. I, should like changing, still used &#8220;Gutsy&#8221; in my laptop. There are several reasons why I keep using it. It&#8217;s hard to make all parts of my laptop Dell 1420 work well under Ubuntu 7.10, including the sound card, wireless, and microphone. Thank <a href="http://linux.dell.com/wiki/index.php/Wiki_Main_Page">Dell Ubuntu Wiki</a> a lot to provide patches to fix these issues. About 5 months ago, when &#8220;Hardy&#8221; was just released, the entry &#8220;Known Issues&#8221; in Dell Ubuntu Wiki is empty. I cannot put myself in hell to try the new release. Fortunately, issues have be found and fixed now for &#8220;Hardy&#8221;. I can upgrade my system safely&#8211;at least in image.</p>
<p>Another thing is that I have patched something on the kernel, such as <a href="http://www.virtualbox.org/">VBox</a>. I don&#8217;t want to repatch them after upgrading. And I was afraid that some software may don&#8217;t work after upgrading to &#8220;Hardy&#8221;. I have no time and don&#8217;t want to reinstall and reconfig them. Maybe a small issue can cause the damage of entire system. Then, I have to reinstall everything, and encounter all kinds of problems. A good thing is that I have my /home located in a separate partition. If my system is down, at least I can retain the things under my home folder, which are very very important.</p>
<p>I have one thousand reasons for not upgrading. However, how could you image that the software you are about to install depend on a newer version of &#8220;libglib&#8221; or &#8220;libc6&#8243;? <a href="http://www.pidgin.im/">Pidgin 2.5</a> support off-line messages for MSN, which I desired for a long time. When I tried to install it, it told me that it need a newer version of &#8220;libglib&#8221;. That meant I have to upgrade almost everything. Sounds like hell. Finally, I decided to do upgrade for Ubuntu.</p>
<p>The whole process took me an afternoon. I followed the <a href="http://www.ubuntu.com/getubuntu/upgrading">official guide</a>. It was not very hard. After downloading everything, dialogues popped up one after another. After I handled all of them, upgrading is over. The following thing is following the Dell Ubuntu Wiki to fix issues. At last, everything seems work fine, including microphone.</p>
<p>The last thing is installing Pidgin 2.5, for which, seems, the whole upgrading is processing.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/upgrading-to-hardy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Slax Linux, with Chinese</title>
		<link>http://chunhao.net/blog/slax-linux-with-chinese/</link>
		<comments>http://chunhao.net/blog/slax-linux-with-chinese/#comments</comments>
		<pubDate>Sat, 21 Jun 2008 16:54:48 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[OS]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/slax-linux-with-chinese</guid>
		<description><![CDATA[A few days ago, I decided to installed linux on my 1GB USB Drive. In order for the ability to do some recovering when my system crashes(hope not) and for fun. After considering several distro, I chose slax linux. I think I&#8217;ve been influenced a lot by my friend Jiawei who had used slax linux [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>A few days ago, I decided to installed linux on my 1GB USB Drive. In order for the ability to do some recovering when my system crashes(hope not) and for fun.</p>
<p>After considering several  distro, I chose <a href="http://www.slax.org">slax linux</a>. I think I&#8217;ve been influenced a lot by my friend Jiawei who had used slax linux when his hard drive was down.</p>
<p>After installing slax linux on my USB drive correctly following the <a href="http://www.slax.org/documentation_install_slax.php">official manual</a>, I found it didn&#8217;t support Chinese at all. When I googled that, I found <a href="http://fanx.org.cn">fanx</a>, a localized slax. Since I am the people who like solving problems in a more challenge way, I didn&#8217;t choose that.</p>
<p>For the first thing, I downloaded the modules for i18n of Chinese packages from <a href="http://www.itsdisk.cn/mypane.aspx?Path=zzzz88%2fSlax%2fChinese/">here</a>. The only packages I needed are the files start with 001, 002, 003, 004, 010 and 011. Put them on  <font color="#33cccc">/slax/modules</font> on my USB drive.</p>
<p>After started it(don&#8217;t choose the &#8220;fresh mode&#8221; or &#8220;copy to ram&#8221; mode), modify <font color="#33cccc">/etc/profile.d/lang.sh</font>. Added the following lines:</p>
<blockquote><p>export LC_ALL=zh_CN.UTF-8</p>
<p>export LANG=zh_CN.UTF-8</p></blockquote>
<p>And commented all other lines by add &#8216;#&#8217; at the first of the line. So simple!</p>
<p>You may also want to use your favourite fonts. Then, copy the &#8216;.ttf&#8217; fonts to the folder  <font color="#33cccc">/usr/share/fonts/TTF</font></p>
<p>Every thing is OK now. After short configurations, it can display Chinese characters as well as with Chinese input method available. Let&#8217;s enjoying the beautiful, lightweight and portable linux.</p>
<p>Before writing <a href="http://www.testking.net/testking-70-647.htm">70-647</a> and <a href="http://www.testking.net/testking-640-816.htm">640-816</a>, make sure that basics like <a href="http://www.testking.net/testking-70-271.htm">70-271</a> and <a href="http://www.testking.net/testking-70-293.htm">70-293</a> are cleared well in advance for <a href="http://www.testking.net/testking-PMI-001.htm">PMI-001</a> and eventually <a href="http://www.testking.net/testking-350-018.htm">350-018</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/slax-linux-with-chinese/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Interesting Unix Time</title>
		<link>http://chunhao.net/blog/interesting-unix-time/</link>
		<comments>http://chunhao.net/blog/interesting-unix-time/#comments</comments>
		<pubDate>Thu, 20 Mar 2008 23:00:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[OS]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/interesting-unix-time</guid>
		<description><![CDATA[If you set the preference of you system time, you will find a clock type called &#8220;UNIX time&#8220;. If &#8220;UNIX time&#8221; is selected, what will happen? Cool! This is the time here. Isn&#8217;t it interesting? Well, it may be confusing as hell, and you may ask what&#8217;s the time it is. Let&#8217;s investigate what&#8217;s Unix [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>If you set the preference of you system time, you will find a clock type called &#8220;<strong>UNIX time</strong>&#8220;.</p>
<p><a href="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot16.png" title="screenshot16.png"><img src="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot16.thumbnail.png" alt="screenshot16.png" /></a></p>
<p>If &#8220;UNIX time&#8221; is selected, what will happen?</p>
<p><a href="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot17.png" title="screenshot17.png"><img src="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot17.thumbnail.png" alt="screenshot17.png" /></a></p>
<p>Cool! This is the time here. Isn&#8217;t it interesting?  Well, it may be confusing as hell, and you may ask what&#8217;s the time it is. Let&#8217;s investigate what&#8217;s Unix Time.</p>
<p>Unix time is displayed in seconds elapsed since January 1, 1970. It is stored in a 32-bits integer, <em><strong>time_t</strong>. </em>So, it looks like this.</p>
<p>But there is a small issue there, say, as long as the largest integer a 31-bits(1 bit for sign bit) number can represent is  2^31 that is 2147483648. So large? What time it is? It is exactly 03:14:07am(GMT), January, 19th, 2038. This is the famous<strong> 2038</strong> problem. After this time, the variable will turn into 10000000000000000000000000000000, which is -2147483648 in decimal. Is that tricky? What&#8217;s the time then? May be 8:45:52pm, December, 13rd, 1901. Wow, it&#8217;s really a big problem, almost all the computer will be crashed at that time. Is that true? Of course, but I don&#8217;t think that will be a critical problem, because after 30 years, almost all the computer will be upgraded in to 64-bits or even 128-bits(256-bits?). The problem will be easily fixed then. So, just think it as a tricky, rather a problem.</p>
<p>At last, I want to say, enjoy your Unix time! You know, developers are the primary users of it.</p>
<p>Not all <a href="http://www.testking.net/testking-650-393.htm">650-393</a> students are qualified for <a href="http://www.testking.net/testking-642-446.htm">642-446</a> or <a href="http://www.testking.net/testking-642-503.htm">642-503</a>. They need to write <a href="http://www.testking.net/testking-156-215.htm">156-215</a> as well as <a href="http://www.testking.net/testking-642-436.htm">642-436</a> in order to prepare for <a href="http://www.testking.net/testking-70-284.htm">70-284</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/interesting-unix-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to connect vim with gdb — using clewn</title>
		<link>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/</link>
		<comments>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 05:22:40 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/?p=6</guid>
		<description><![CDATA[First, I will show you the screen shot The screen of vim is divide into two sub windows, the top one can display the code and the bottom one shows the variable you want to watch. Well, this can be changed by you, you can split the window any way you like. You can use [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a title="screenshot3.png" href="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot3.png"><img src="http://chunhao.net/blog/wp-content/uploads/2008/03/screenshot3.thumbnail.png" alt="screenshot3.png" /></a></p>
<p><span class="postbody">First, I will show you the screen shot</span> The screen of vim is divide into two sub windows, the top one can display the code and the bottom one shows the variable you want to watch.  Well, this can be changed by you, you can split the window any way you like.  You can use C-B to make a break, and press R to run your program, and press S to step, and C-J to add the variable you want to watch. <span class="postbody"> You can download clewn here:</span></p>
<blockquote><p><span class="postbody"><a href="http://clewn.sourceforge.net/" target="_blank">http://clewn.sourceforge.net/</a></span></p></blockquote>
<p>How to install:  <span class="postbody">first of all, you should have your gvim installed,</span></p>
<blockquote>
<p align="left">sudo apt-get install vim-gnome</p>
</blockquote>
<p><span class="postbody">as well as gdb</span> And then download the source file of clewn; note here, not vimgdb.  And extract the file, then use your terminal to enter the clewn folder</p>
<blockquote><p>./configure make sudo make install</p></blockquote>
<p>Note here, may be some one will be suffered from the dependency problem during their installing. If your machine tell you that you need readline, then install libreadline5-dev</p>
<blockquote><p>sudo apt-get install libreadline5-dev</p></blockquote>
<p><span class="postbody"> And then, copy some files to ~/.vim you can refer my folder:</span></p>
<blockquote><p>cp /usr/local/share/vim/vimfiles/clewn.vim ~/.vim/plugin/</p>
<p>cp /usr/local/share/vim/vimfiles/doc/clewn.txt ~/.vim/doc/</p>
<p>cp /usr/local/share/vim/vimfiles/macros/clewn_mappings.vim ~/.vim/macros/</p>
<p>cp /usr/local/share/vim/vimfiles/syntax/gdbvar.vim ~/.vim/syntax/</p></blockquote>
<p>Then, every thing is done. You can write a small program to test.</p>
<pre lang="c">#include 

int main(int argc, char *argv[]) {
  int i;
  int s;
  s = 0;
  for (i = 0; i &lt; 10; ++i) {
    s = s + 1;
  }
}</pre>
<p><span class="postbody"> Save it as test.c , for example. And then,</span></p>
<blockquote><p>gcc -g -o test test.c</p></blockquote>
<p>If everything is right during compiling, then</p>
<blockquote><p>clewn -va test.c</p></blockquote>
<p><span class="postbody">Then, gdb is opened on your terminal, and your gvim is opened at the same time</span> Cool down now; input the following on your terminal(gdb):</p>
<blockquote><p>file test</p></blockquote>
<p>Now, you can debug your program on gvim.  <span class="postbody">For example, you can click the line you want to set break point. And then press CTRL+B, then, break point is set.</span> SHIFT+r（that is capital R）It will run and stop at your break point SHIFT+s（that is capital S）It will step And watch your variable, input following on gvim</p>
<blockquote><p>:split</p></blockquote>
<p><span class="postbody">Then the window will be split, and then click the variable you want to watch, and press C+J, then you can see the variable appears in another window.</span> <span class="postbody">To do this, you also can input the following on your terminal(gdb)</span></p>
<blockquote><p>createvar yourvar</p></blockquote>
<p>&#8220;youvar&#8221; represents the variable you want to watch.  Following is the default shortcuts</p>
<p>List of default key mappings:</p>
<blockquote>
<pre><span class="Special">        CTRL-Z</span>  send an interrupt to GDB and the program it is running
        B       info breakpoints
        L       info locals
        A       info args
        S       step
        I       stepi
        <span class="Special">CTRL-N</span>  next: next source line, skipping all function calls
        X       nexti
        F       finish
        R       run
        Q       quit
        C       continue
        W       where
        <span class="Special">CTRL-U</span>  up: go up one frame
        <span class="Special">CTRL-D</span>  down: go down one frame

<span class="PreProc">cursor position:</span><span class="Ignore"> ~</span>
        <span class="Special">CTRL-B</span>  set a breakpoint on the line where the cursor is located
        <span class="Special">CTRL-E</span>  clear all breakpoints on the line where the cursor is located

<span class="PreProc">mouse pointer position:</span><span class="Ignore"> ~</span>
        <span class="Special">CTRL-P</span>  print the value of the variable defined by the mouse pointer
                position
        <span class="Special">CTRL-X</span>  print the value that is referenced by the address whose
                value is that of the variable defined by the mouse pointer
                position
        <span class="Special">CTRL-K</span>  set a breakpoint at assembly address shown by mouse position
        <span class="Special">CTRL-H</span>  clear a breakpoint at assembly address shown by mouse position
        <span class="Special">CTRL-J</span>  add the selected variable at mouse position to the watched
                variables window</pre>
</blockquote>
<p>This is referred the official document, which is available here</p>
<blockquote><p><a href="http://clewn.sourceforge.net/" target="_blank"></a><a href="http://clewn.sourceforge.net/doc.html" target="_blank">http://clewn.sourceforge.net/doc.html</a></p></blockquote>
<p>Hope this will help you somewhat. If you have some new or better idea, please contact me.  chunhao86@gmail.com  Thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/how-to-connect-vim-with-gdb-using-clewn/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>I am using Ubuntu 7.10 currently</title>
		<link>http://chunhao.net/blog/i-am-using-ubuntu-710-currently/</link>
		<comments>http://chunhao.net/blog/i-am-using-ubuntu-710-currently/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 04:39:11 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://chunhao86.cn/blog/?p=5</guid>
		<description><![CDATA[Well, I have used ubuntu 6.06 before, but because my XP crashed some time, and I had to reinstall my XP. It cause my grub been destroyed. Unfortunately, I even didn&#8217;t know how to rewrite grub by live-cd. (which seems to simple today). I gave up ubuntu that time, about one and a half years [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Well, I have used ubuntu 6.06 before, but because my XP crashed some time, and I had to reinstall my XP. It cause my grub been destroyed. Unfortunately, I even didn&#8217;t know how to rewrite grub by live-cd. (which seems to simple today). I gave up ubuntu that time, about one and a half years ago.  Half years ago, I saw ubuntu&#8217;s 3D desktop from google; it&#8217;s something like eye-candy, but really attracted me, and I installed it on my laptop. Since I have some experience about linux before, it wasn&#8217;t not very hard to install it. It took me about couple of days to configure the 3D desktop, due to which, I learned many things about config files and file structures of linux. That&#8217;s a good start, wasn&#8217;t it?  After that, I walked into the world of linux, and found it was really wonderful! During that time, I learned something about vim, latex, and other useful tools on linux. It helps a lot in everyday&#8217;s study and work.  Later, I will share some of my experience about that. Anyway, it &#8216;s just a start.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://chunhao.net/blog/i-am-using-ubuntu-710-currently/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
