<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-21954772</id><updated>2012-01-22T14:27:31.521+08:00</updated><category term='VTOL'/><category term='scilab'/><category term='Visual Studio'/><category term='fonts'/><category term='regexp'/><category term='Windows'/><category term='open source'/><category term='sed'/><category term='Git'/><category term='scipy'/><category term='study'/><category term='GIMP'/><category term='SVM'/><category term='GPG'/><category term='QnA'/><category term='corner detection'/><category term='vim'/><category term='Inkscape'/><category term='Mutt'/><category term='SCIM'/><category term='helicopter'/><category term='opencv'/><category term='plot'/><category term='stereo vision'/><category term='soundconverter'/><category term='SURF'/><category term='webcam'/><category term='OpenOffice'/><category term='XML'/><category term='ffmpeg'/><category term='screensaver'/><category term='UAV'/><category term='bash'/><category term='Maximum Likelihood Estimation'/><category term='Word'/><category term='vlc'/><category term='smbfs'/><category term='Firefox'/><category term='ImageMagick'/><category term='DiveIntoPython'/><category term='desktop'/><category term='fbgs'/><category term='signal processing'/><category term='wmii'/><category term='coding'/><category term='GPS'/><category term='keymaps'/><category term='Boost'/><category term='fft'/><category term='matplotlib'/><category term='gnuplot'/><category term='pyx'/><category term='podcast'/><category term='list'/><category term='network setting'/><category term='pycam'/><category term='SP'/><category term='Machine Learning'/><category term='fbi'/><category term='pylab'/><category term='BibTeX'/><category term='pidgin'/><category term='rhythmbox'/><category term='tty'/><category term='pattern recognition'/><category term='GNU'/><category term='mplayer'/><category term='Chromium'/><category term='pyode'/><category term='console'/><category term='data processing'/><category term='opengl'/><category term='framebuffer'/><category term='python'/><category term='GTK+'/><category term='browser'/><category term='quod libet'/><category term='SWAN'/><category term='image'/><category term='csv'/><category term='okular'/><category term='The Python Challenge'/><category term='Tkinter'/><category term='ps2pdf'/><category term='EMD'/><category term='GSL'/><category term='linux'/><category term='driver'/><category term='shell script'/><category term='CLI'/><category term='tk'/><category term='emacs'/><category term='H-LING'/><category term='tool'/><category term='Ethernet'/><category term='usb'/><category term='Debian'/><category term='octave'/><category term='C/C++'/><category term='mount'/><category term='SIFT'/><category term='RC'/><category term='lisp'/><category term='Java'/><category term='viewer'/><category term='rubik&apos;s cube'/><category term='eps'/><category term='Draganflyer X6'/><category term='HMM'/><category term='gcc'/><category term='pygame'/><category term='Ubuntu'/><category term='image processing'/><category term='LaTeX'/><title type='text'>人 teh 飛, 天 teh 看</title><subtitle type='html'>The title is in Taiwanese. It means "human beings are flying, and God is watching."&lt;br&gt;

Something about my own studies, programming notes, and also English writing exercise.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default?start-index=101&amp;max-results=100'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>189</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21954772.post-8773601210806319392</id><published>2012-01-08T11:30:00.000+08:00</published><updated>2012-01-08T11:39:49.970+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='Chromium'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='Firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='browser'/><title type='text'>Cannot set Chromium as your default browser?</title><content type='html'>I was using &lt;a href="http://freemind.sourceforge.net/wiki/index.php/Main_Page"&gt;FreeMind&lt;/a&gt; to manage information of my work, and there were several links embedded in the mind map. When I was trying to open the links, they were opened in Firefox instead of Chromium that has been my default browser. I tried to set Chromium as the default browser in the Preferences tab but it said ``Chromium cannot determine or set the default browser.''&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-IdFmieVm7fw/TwkL8gNOh-I/AAAAAAAAAo8/HXGRTAzBCwg/s1600/chromium_cannot_set_default.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-IdFmieVm7fw/TwkL8gNOh-I/AAAAAAAAAo8/HXGRTAzBCwg/s1600/chromium_cannot_set_default.png" /&gt;&lt;/a&gt;&lt;/div&gt;The solution was found on &lt;a href="http://ubuntuforums.org/"&gt;Ubuntu Forums&lt;/a&gt;. In &lt;a href="http://ubuntuforums.org/showthread.php?t=1607996"&gt;the thread&lt;/a&gt;, &lt;a href="http://ubuntuforums.org/showpost.php?p=10039958&amp;amp;postcount=4"&gt;user cavalier911 provided a method&lt;/a&gt; using&amp;nbsp;update-alternatives to set the default browser. The command is as follows.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ sudo update-alternatives --config x-www-browser&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Pretty easy and works like a charm.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8773601210806319392?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8773601210806319392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8773601210806319392' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8773601210806319392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8773601210806319392'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2012/01/cannot-set-chromium-as-your-default.html' title='Cannot set Chromium as your default browser?'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-IdFmieVm7fw/TwkL8gNOh-I/AAAAAAAAAo8/HXGRTAzBCwg/s72-c/chromium_cannot_set_default.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4879849687247439709</id><published>2012-01-02T11:41:00.000+08:00</published><updated>2012-01-02T11:49:28.239+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ffmpeg'/><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>Screencast of particular window in Ubuntu using ffmpeg</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushBash.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;When you want to record the screen output, there have been some software good to use [1]. However, I found none of them can properly record the zone in which a C++ program produced video stream combining webcam input and OpenGL objects.&lt;br /&gt;&lt;br /&gt;After some trials, I found an useful solution [2] and made some modifications. It is a shell script that uses ffmpeg to record the video content of target window.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:bash"&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;echo -e "Usage: bash $0 outputfile\nClick on the window to be recorded."&lt;br /&gt;&lt;br /&gt;size=$(xwininfo -frame | awk '/geometry/ {print $2}')&lt;br /&gt;offset=$(echo $size | awk -F + '{print $2","$3}')&lt;br /&gt;&lt;br /&gt;ffmpeg -f alsa -ac 2 -ab 192k -i pulse -f x11grab -s $size -r 30 -i :0.0+$offset -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 $1&lt;br /&gt;&lt;/pre&gt;---&lt;br /&gt;[1] Such as &lt;a href="http://recordmydesktop.sourceforge.net/about.php"&gt;recordMyDesktop&lt;/a&gt; and &lt;a href="http://xvidcap.sourceforge.net/"&gt;xvidcap&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://ubuntuguide.org/wiki/Screencasts#Run_FFMPEG_with_x11grab"&gt;Run FFMPEG with x11grab&lt;/a&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4879849687247439709?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4879849687247439709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4879849687247439709' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4879849687247439709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4879849687247439709'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2012/01/screencast-in-ubuntu-using-ffmpeg.html' title='Screencast of particular window in Ubuntu using ffmpeg'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8458562405845177682</id><published>2011-11-08T15:39:00.005+08:00</published><updated>2011-11-08T15:43:14.979+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 06</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 06 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main library used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;zipfile&lt;/span&gt; module.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;Level 06 really made me frustrated but brought me fun and totally new knowledge about ``zipfile'' module.&lt;br /&gt;&lt;br /&gt;I read and studied the hints given on the forum. To me, this challenge was little complicated. There were several time when I thought I've found the solution but quickly realized that I was wrong. Level 06 was ``multiple layers puzzle'', at least I think so.&lt;br /&gt;&lt;br /&gt;The original version of my code is as the follows. I decided to use &lt;a href="http://docs.python.org/library/stdtypes.html#mapping-types-dict"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;dict&lt;/span&gt;&lt;/a&gt; because the puzzle has to be solved by searching successive keys as a chain.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [1, 4, 5]"&gt;import zipfile&lt;br /&gt;&lt;br /&gt;next_nothing = '90052'&lt;br /&gt;zf = zipfile.ZipFile('channel.zip')&lt;br /&gt;d = {}&lt;br /&gt;&lt;br /&gt;# scan through the *.zip and collect the comments&lt;br /&gt;for info in zf.infolist(): &lt;br /&gt;    filename = info.filename&lt;br /&gt;    filename_s = filename.split('.')[0]&lt;br /&gt;&lt;br /&gt;    msg = zf.read(filename).decode()&lt;br /&gt;    next_nothing = msg.split( )[-1]&lt;br /&gt;&lt;br /&gt;    comment = info.comment.decode()&lt;br /&gt;&lt;br /&gt;    d.update( {filename_s:[next_nothing, comment]} )&lt;br /&gt;&lt;br /&gt;# search in the dict d&lt;br /&gt;key1 = '90052'&lt;br /&gt;for i in range( len(d) - 1 ):&lt;br /&gt;    key2 = d.get(key1)[0]&lt;br /&gt;    value = d.get(key1)[1]&lt;br /&gt;    key1 = key2&lt;br /&gt;    print(value, end='')&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;---&lt;br /&gt;Ref: &lt;a href="http://www.doughellmann.com/PyMOTW/zipfile/"&gt;zipfile – Read and write ZIP archive files&lt;/a&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8458562405845177682?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8458562405845177682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8458562405845177682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8458562405845177682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8458562405845177682'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/11/py-python-challenge-level-06.html' title='[Py] The Python Challenge -- Level 06'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8979988219902773553</id><published>2011-10-31T00:23:00.001+08:00</published><updated>2011-10-31T00:23:38.766+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 05</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 05 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main library used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pickle&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Actually I didn't know pickle before. I just noticed the ``banner.p'' file shown in the source. When I viewed the banner.p file, I noticed the strange characters could be transferred to meaningful or readable messages.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pickle&lt;/span&gt; module was found by paste few characters in the banner.p file into Google for searching. There was a thread mentioned about the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pickle&lt;/span&gt; module, so I decided to start with it and got right result.&lt;br /&gt;&lt;br /&gt;The original version of my code is as the follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [3]"&gt;import pickle&lt;br /&gt;&lt;br /&gt;tmp_list = pickle.load( open('banner.p', 'rb') )&lt;br /&gt;&lt;br /&gt;for row in range( len(tmp_list) ):&lt;br /&gt;    for elem in range( len(tmp_list[row]) ):&lt;br /&gt;        for repeat in range(tmp_list[row][elem][1]):&lt;br /&gt;            print(tmp_list[row][elem][0], end="")&lt;br /&gt;    print()&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8979988219902773553?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8979988219902773553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8979988219902773553' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8979988219902773553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8979988219902773553'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/py-python-challenge-level-05.html' title='[Py] The Python Challenge -- Level 05'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4181717516800345823</id><published>2011-10-30T22:58:00.003+08:00</published><updated>2011-10-30T23:02:09.983+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 04</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 04 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main library used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;urllib.parse&lt;/span&gt; to parse the url and the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;urllib.request&lt;/span&gt; for retrieving the web page source.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;I had been totally lost at the beginning. The page showed only the message ``follow the chain'' and the url said ``linkedlist'' so I thought that must be something relevant to linked list in Python.&lt;br /&gt;&lt;br /&gt;I searched on the web and found no useful clue. I felt a little bit frustrated.&lt;br /&gt;&lt;br /&gt;After investigating the web page of Level 04, I noticed the url ended with php instead conventional html. Actually I didn't know what was the difference between the php and html pages, but I guessed there must be some clues.&amp;nbsp; When the curser moved to the picture of the web page, the url changed to something ended with ``nothing=12345'', and the link led to another page showed ``and the next nothing is 44827.'' I replaced ``12345'' with ``44827'' and got another page with new digits.&lt;br /&gt;&lt;br /&gt;So, I assumed the digits had something to do with the linked list. I was wrong.&lt;br /&gt;&lt;br /&gt;It took me two days to tackle the puzzle but got no useful advances. Then I decided to get some hints from &lt;a href="http://www.pythonchallenge.com/forums/index.php"&gt;the forum&lt;/a&gt; of The Python Challenge. The hint that led me out is &lt;a href="http://www.pythonchallenge.com/forums/viewtopic.php?p=42#p42"&gt;the one given by thesamet&lt;/a&gt;:&lt;br /&gt;&lt;blockquote class="tr_bq"&gt;if your hands are getting tired, maybe &lt;i&gt;get someone else to do it for you&lt;/i&gt;...&lt;/blockquote&gt;Yes. But who can do it for me? Finally I got that: do the dirty work by the script automatically for you. It is a shame not to think about such a basic principle. To do dirty or boring works by writing small script should be a institute of a hacker or of one who wants to be a hacker.&lt;br /&gt;&lt;br /&gt;With the enlightened idea, I began to write the code and finally got the solution. :-)&lt;br /&gt;&lt;br /&gt;The original version of the my code (in Python 3) is as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [8]"&gt;from urllib.parse import urlparse&lt;br /&gt;from urllib.request import urlopen&lt;br /&gt;&lt;br /&gt;nothing = '12345'&lt;br /&gt;&lt;br /&gt;while nothing.isdigit():&lt;br /&gt;    # get modified url&lt;br /&gt;    obj = urlparse('http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=' + nothing) &lt;br /&gt;    # get the web page source&lt;br /&gt;    src = urlopen(obj.geturl()).read()&lt;br /&gt;    # extract the part of digits, and convert it from bytes to str&lt;br /&gt;    nothing = src.split( )[-1].decode()&lt;br /&gt;    print(src)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;---&lt;br /&gt;Notes: There are two &lt;a href="http://docs.python.org/release/3.1.3/library/stdtypes.html#typesseq"&gt;sequence types&lt;/a&gt; named &lt;a href="http://docs.python.org/release/3.1.3/reference/lexical_analysis.html#strings"&gt;bytes&lt;/a&gt; and str. To convert one to another, use &lt;a href="http://docs.python.org/release/3.1.3/library/stdtypes.html#str.encode"&gt;encode&lt;/a&gt; and &lt;a href="http://docs.python.org/release/3.1.3/library/stdtypes.html#bytes.decode"&gt;decode&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4181717516800345823?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4181717516800345823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4181717516800345823' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4181717516800345823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4181717516800345823'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/py-python-challenge-level-04.html' title='[Py] The Python Challenge -- Level 04'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8809503642559190078</id><published>2011-10-27T14:37:00.001+08:00</published><updated>2011-10-27T14:47:22.748+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 03</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 03 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main library used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;urllib.request&lt;/span&gt; for retrieving the web page source and the &lt;a href="http://docs.python.org/release/3.1.3/library/re.html"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;re&lt;/span&gt;&lt;/a&gt; for &lt;a href="http://en.wikipedia.org/wiki/Regular_expression"&gt;regular expression&lt;/a&gt; operations.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;At the beginning, I had been totally lost. There was no obvious thing for me to process with Python. So I did quick search on Google and tried not to view any possible solution. I glanced about the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;re&lt;/span&gt; library,&amp;nbsp; and thought about the Level 02 challenge in which the data to be processed was given in the web page source. Yes, in Level 03, the raw material is embedded in the page source again.&lt;br /&gt;&lt;br /&gt;When writing the code, I happened to noticed that there was a hint on the tab of web page... Orz&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-uLXJzikrpy8/Tqj70uk_GOI/AAAAAAAAAnk/5XrMfWrwlAo/s1600/TPC_L03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="298" src="http://3.bp.blogspot.com/-uLXJzikrpy8/Tqj70uk_GOI/AAAAAAAAAnk/5XrMfWrwlAo/s400/TPC_L03.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I started with &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;re.research()&lt;/span&gt; function. It took me some time to figure out what were the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;groups&lt;/span&gt; and the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;group&lt;/span&gt; which were returned by &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;re.search()&lt;/span&gt;. I used them to get the string ``&lt;i style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;IQNlQSL&lt;/i&gt;'' but it was not the right answer for the link. Then I tried to modified the link with only the lowercase ``&lt;i style="font-family: Times,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;l&lt;/i&gt;'', and the web page responded a message read ``yes. but there are more.'' Since then I supposed that I have to find all the matched clips in the text.&lt;br /&gt;&lt;br /&gt;The successful tool I used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;re.findall()&lt;/span&gt;. And the original version of the my code (in Python 3) is as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [9]"&gt;import urllib.request&lt;br /&gt;import re&lt;br /&gt;&lt;br /&gt;source = urllib.request.urlopen("http://www.pythonchallenge.com/pc/def/equality.html") &lt;br /&gt;&lt;br /&gt;src_str = str(source.read()).replace('\\n','').split('&amp;lt;!--')&lt;br /&gt;target_str = src_str[-1]&lt;br /&gt;&lt;br /&gt;m = re.findall('([^A-Z][A-Z]{3})([a-z])([A-Z]{3}[^A-Z])', target_str)&lt;br /&gt;&lt;br /&gt;for c in m:&lt;br /&gt;    print(c[1], end="")&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8809503642559190078?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8809503642559190078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8809503642559190078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8809503642559190078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8809503642559190078'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/py-python-challenge-level-03.html' title='[Py] The Python Challenge -- Level 03'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-uLXJzikrpy8/Tqj70uk_GOI/AAAAAAAAAnk/5XrMfWrwlAo/s72-c/TPC_L03.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-774101052163932410</id><published>2011-10-27T11:21:00.000+08:00</published><updated>2011-10-27T14:47:33.268+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 02</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 02 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The main library used is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;urllib.request&lt;/span&gt;. In Python 2.x, it is just &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;urllib&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When dealing with the challenge, I viewed the page source directly from Firefox and read the further hint: find rare characters in the mess below. With the hint, I copied the messy paragraph and tried to paste it in Vim for further text processing, but my Vim hung when I did the pasting. I had no idea about the hanging but didn't want to figure out the possible problem on the side of Vim. Instead, I decided to capture the messy paragraph within the code. It would be a better approach, I thought.&lt;br /&gt;&lt;br /&gt;After getting the messy paragraph, I assumed that there were some readable letters embedded in the paragraph of big mess. Therefore I tried &lt;b&gt;to pick out ascii characters from the messy paragraph&lt;/b&gt;. It worked. :-)&lt;br /&gt;&lt;br /&gt;The original version of the my code (in Python 3) is as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [4,6,7]"&gt;import urllib.request&lt;br /&gt;import string&lt;br /&gt;&lt;br /&gt;source = urllib.request.urlopen("http://www.pythonchallenge.com/pc/def/ocr.html") &lt;br /&gt;&lt;br /&gt;src_str = str(source.read()).replace('\\n','').split('&amp;lt;!--')&lt;br /&gt;target_str = src_str[-1]&lt;br /&gt;&lt;br /&gt;for c in target_str:&lt;br /&gt;    if c in string.ascii_letters:&lt;br /&gt;        print(c, end="")&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-774101052163932410?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/774101052163932410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=774101052163932410' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/774101052163932410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/774101052163932410'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/py-python-challenge-level-02.html' title='[Py] The Python Challenge -- Level 02'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-92824078092744494</id><published>2011-10-26T16:44:00.000+08:00</published><updated>2011-10-27T14:47:54.602+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='The Python Challenge'/><title type='text'>[Py] The Python Challenge -- Level 01</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Here is a note of my solution to solve Level 01 of &lt;a href="http://www.pythonchallenge.com/"&gt;The Python Challenge&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Used functions: ord() and chr().&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The ord() and chr() are handy to convert between the ASCII characters and the corresponding digits.&lt;br /&gt;&lt;br /&gt;The original version of the my code (in Python 3) is as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py"&gt;#str_in = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj." &lt;br /&gt;str_in = "map"&lt;br /&gt;&lt;br /&gt;ch = ''&lt;br /&gt;for tmp in str_in:&lt;br /&gt;    if ord(tmp) &amp;gt;= ord('a'):&lt;br /&gt;        if ord(tmp) &amp;lt;= ord('x'):&lt;br /&gt;            ch = ch + ( chr( ord(tmp) + 2) )&lt;br /&gt;        if ord(tmp) &amp;gt;= ord('y'):&lt;br /&gt;            ch = ch + ( chr( ord(tmp) + 2 - 26) )&lt;br /&gt;    else:&lt;br /&gt;        ch = ch + tmp &lt;br /&gt;&lt;br /&gt;print(ch)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-92824078092744494?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/92824078092744494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=92824078092744494' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/92824078092744494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/92824078092744494'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/py-python-challenge-level-01.html' title='[Py] The Python Challenge -- Level 01'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-389856635398698611</id><published>2011-10-20T14:42:00.000+08:00</published><updated>2011-10-20T14:42:01.282+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>pss: searching your source code in command line</title><content type='html'>When I was working on my Ubuntu with Vim to write or to view source code, I had no simple way to find certain functions scattering in the files by their name or key words.&lt;br /&gt;&lt;br /&gt;Now I have one useful tool which is named &lt;a href="http://eli.thegreenplace.net/2011/10/14/announcing-pss-a-tool-for-searching-inside-source-code/"&gt;pss&lt;/a&gt; written by &lt;a href="http://eli.thegreenplace.net/"&gt;Eli Bendersky&lt;/a&gt;. The tool is written in Python and that is attractive to me, because I can read the source code and maybe learn something from it. :-)&lt;br /&gt;&lt;br /&gt;Download: https://bitbucket.org/eliben/pss/downloads&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-389856635398698611?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/389856635398698611/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=389856635398698611' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/389856635398698611'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/389856635398698611'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/pss-searching-your-source-code-in.html' title='pss: searching your source code in command line'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8085587350305435619</id><published>2011-10-20T09:55:00.001+08:00</published><updated>2011-10-20T14:21:59.916+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='okular'/><title type='text'>Okular: Annotations are stored in local directory</title><content type='html'>This is just a quick note.&lt;br /&gt;&lt;br /&gt;When using &lt;a href="http://okular.kde.org/"&gt;Okular&lt;/a&gt; to view the PDF files, you can add various annotations in the documents. These annotations, however, are not embedded in the PDF files. Instead, they are stored in your local directory. In my Ubuntu PC, the path is&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;~/.kde/share/apps/okular/docdata&lt;/div&gt;&lt;br /&gt;The annotations are stored in individual XML files for the corresponding annotated PDF files. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8085587350305435619?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8085587350305435619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8085587350305435619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8085587350305435619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8085587350305435619'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/10/okular-annotations-are-stored-in-local.html' title='Okular: Annotations are stored in local directory'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8028271816256909612</id><published>2011-09-15T16:31:00.001+08:00</published><updated>2011-09-15T16:32:58.937+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Boost'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><category scheme='http://www.blogger.com/atom/ns#' term='C/C++'/><title type='text'>Using Boost accumulators to calculate the variance</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;a href="http://www.boost.org/"&gt;Boost&lt;/a&gt; seems a promising set of C++ library, but I found it's not easy for me to figure out its usage. After serveral trials, I finally got the variance calculated.&lt;br /&gt;&lt;br /&gt;Here is the testing code I used (in VS2005):&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:cpp"&gt;#include &amp;lt;boost/accumulators/accumulators.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;boost/accumulators/statistics/stats.hpp&amp;gt;&lt;br /&gt;#include &amp;lt;boost/accumulators/statistics/variance.hpp&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(){&lt;br /&gt;    using namespace boost::accumulators;&lt;br /&gt;    accumulator_set&amp;lt; double, stats&amp;lt;tag::variance&amp;gt; &amp;gt; acc_variance;&lt;br /&gt;&lt;br /&gt;    for (int i = 0; i &amp;lt; 10; i++){&lt;br /&gt;        std::cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; ", ";&lt;br /&gt;        acc_variance(i);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    std::cout &amp;lt;&amp;lt; std::endl &amp;lt;&amp;lt; "Variance = " &lt;br /&gt;        &amp;lt;&amp;lt; variance(acc_variance) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;The output is:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;0, 1, 2, 3, 4, 5, 6, 7, 8, 9,&lt;br /&gt;Variance = 8.25&lt;/div&gt;&lt;br /&gt;When I tried to varify the result, I use MS Excel but got unexpected result. The variances given by Boost and Excel are different!&lt;br /&gt;&lt;br /&gt;Did I make any mistakes? Oh, I didn't realise the variance calculated by Boost function was the &lt;b&gt;population variance&lt;/b&gt;, and the VAR function of Excel gave the &lt;b&gt;sample variance&lt;/b&gt;. To have population variance in Excel, you need &lt;b&gt;VARP&lt;/b&gt;, not VAR.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref: &lt;a href="http://boost.2283326.n4.nabble.com/Variance-calcs-in-the-stats-library-and-in-Excel-td2594553.html"&gt;Variance calcs in the stats library and in Excel&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8028271816256909612?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8028271816256909612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8028271816256909612' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8028271816256909612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8028271816256909612'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/09/using-boost-accumulators-to-calculate.html' title='Using Boost accumulators to calculate the variance'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2775700530139603685</id><published>2011-09-15T11:32:00.000+08:00</published><updated>2011-09-15T15:54:15.993+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Git'/><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Visual Studio'/><title type='text'>Using Git as a working logger</title><content type='html'>I am working on a project, which is a experimental program coded and maintained by myself.&lt;br /&gt;&lt;br /&gt;It is redundant and seems stupid to copy the whole working folder whenever I want to change the code to another version. Especially when the folder contains not only source code but some other documents or videos of testing results.&lt;br /&gt;&lt;br /&gt;``I need a version control tool.'' The idea came to my mind.&lt;br /&gt;&lt;br /&gt;``But I've never used or been familiar with any.'' The truth is cruel.&lt;br /&gt;&lt;br /&gt;Then I thought of &lt;a href="http://git-scm.com/"&gt;Git&lt;/a&gt;, a term which I might saw several times when surfing webpages.&lt;br /&gt;&lt;br /&gt;Because the project I am working on is written and compiled with &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2005"&gt;Visual Studio 2005&lt;/a&gt;, I started to search how to use Git with VS2005 and found &lt;a href="http://code.google.com/p/gitextensions/"&gt;Git Extensions&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just download the &lt;a href="http://code.google.com/p/gitextensions/downloads/detail?name=GitExtensions224SetupComplete.msi"&gt;GitExtensions224SetupComplete.msi&lt;/a&gt; and install it, there will be an item added on the main menu of VS2005 as shown in Fig. 1.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-meMqia-J4x0/TnFp8xaYr_I/AAAAAAAAAmE/9T2j2DCob7U/s1600/vs2005_gitextensions.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="312" src="http://1.bp.blogspot.com/-meMqia-J4x0/TnFp8xaYr_I/AAAAAAAAAmE/9T2j2DCob7U/s400/vs2005_gitextensions.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 1. Git Extensions on the main menu with its drop-down.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;I played around with Git to get basic understandings. Although Git is designed for version control for group cooperation, I found it also suitable for personal usage. Now I use it as a working logger, and I can go back to certain status which has been recorded by Git.&lt;br /&gt;&lt;br /&gt;Here I will show some screenshots of my own working program with Git. Fig. 2 shows the steps to commit the changes. After the committing, you can view the committed status with the details (see Fig. 3 and Fig. 4).&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-4r8YESO0eF4/TnFvvk64TiI/AAAAAAAAAmY/C7jMNCbAJSo/s1600/vs2005_git_commit.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="271" src="http://3.bp.blogspot.com/-4r8YESO0eF4/TnFvvk64TiI/AAAAAAAAAmY/C7jMNCbAJSo/s400/vs2005_git_commit.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 2. Steps of Commit the changes.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-7doxdTRWEDg/TnFub8JB10I/AAAAAAAAAmM/DRX8ggAk5fo/s1600/vs2005_git_diff.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="296" src="http://2.bp.blogspot.com/-7doxdTRWEDg/TnFub8JB10I/AAAAAAAAAmM/DRX8ggAk5fo/s400/vs2005_git_diff.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 3. View the committed status.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-RlmxrTdY0Yc/TnFul9Y2d_I/AAAAAAAAAmQ/ym8PIGcHZGQ/s1600/vs2005_git_diff_detail.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="310" src="http://3.bp.blogspot.com/-RlmxrTdY0Yc/TnFul9Y2d_I/AAAAAAAAAmQ/ym8PIGcHZGQ/s400/vs2005_git_diff_detail.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 4. The details of committed content.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;All the records are in the .git folder resides in the working directory. The .gitignore file is used to tell Git which file is not necessary to track.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-C2DVhWzyAkk/TnFxTHFpweI/AAAAAAAAAmc/QrXKC2pl1OE/s1600/vs2005_git_pwd.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="327" src="http://2.bp.blogspot.com/-C2DVhWzyAkk/TnFxTHFpweI/AAAAAAAAAmc/QrXKC2pl1OE/s400/vs2005_git_pwd.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 5. The .git folder and .gitignore file in the working directory.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2775700530139603685?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2775700530139603685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2775700530139603685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2775700530139603685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2775700530139603685'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/09/using-git-as-working-logger.html' title='Using Git as a working logger'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-meMqia-J4x0/TnFp8xaYr_I/AAAAAAAAAmE/9T2j2DCob7U/s72-c/vs2005_gitextensions.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4253535429306029674</id><published>2011-08-31T15:03:00.001+08:00</published><updated>2011-08-31T15:04:03.992+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='vlc'/><title type='text'>VLC outputs black screen while the audio works fine</title><content type='html'>My &lt;a href="http://www.videolan.org/vlc/"&gt;VLC &lt;/a&gt;video player gives strange behaviour these days. When playing video, there is only sound with black screen. I once though the video files were broken, but they can be viewed by using &lt;a href="http://www.apple.com/quicktime/download/"&gt;QuickTime&lt;/a&gt;. So, the problem must be in VLC.&lt;br /&gt;&lt;br /&gt;I searched on the Web and didn't find exact issue I encountered. Then I found &lt;a href="http://www.techanswerguy.com/2008/04/black-screenno-video-in-vlc.html"&gt;this post&lt;/a&gt;, but the solution didn't work for me and didn't make sense to me. However, the post remind me about preference settings, and I thought of there was a post I glanced mentioned about video card. Oh! I've changed my video card several weeks ago. It might be the cause! I looked into the ``Video Settings'' of preference menu, and unchecked the item named ``Accelerated video output (Overlay)''. It works! :-)&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-qbWol74wrW0/Tl3conxclaI/AAAAAAAAAlE/-l6siQbrDok/s1600/vlc_video_settings_overlay.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/-qbWol74wrW0/Tl3conxclaI/AAAAAAAAAlE/-l6siQbrDok/s320/vlc_video_settings_overlay.jpg" width="318" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4253535429306029674?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4253535429306029674/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4253535429306029674' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4253535429306029674'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4253535429306029674'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/08/vlc-outputs-black-screen-while-audio.html' title='VLC outputs black screen while the audio works fine'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-qbWol74wrW0/Tl3conxclaI/AAAAAAAAAlE/-l6siQbrDok/s72-c/vlc_video_settings_overlay.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3418681173623972691</id><published>2011-07-25T23:48:00.002+08:00</published><updated>2011-07-26T23:00:20.386+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='corner detection'/><category scheme='http://www.blogger.com/atom/ns#' term='study'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Example code of FAST corner detection</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Edward Rosten developed the &lt;a href="http://www.edwardrosten.com/work/fast.html"&gt;FAST corner detection algorithm&lt;/a&gt; and gives several versions of source code. Python code is one of them. I downloaded the Python source code but found there was no example to illustrate the basic usage. Fortunately, the Matlab code has one example m-file. Based on the m-file, I tried to write a Python version and it works.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;There are fast9, fast10, fast11, fast12, and faster modules. I have not had time to dive into the differences between them, but just took simple tests. The ``faster'' module caused the program keep running for several minutes and took most of my laptop's resource, so I terminated it without final output. Other modules gave the following results. As I mentioned, I haven't had any idea about the algorithms as well as the meanings of these results. Just for your reference.&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-ySqaSm-M8Nc/Ti2OSGAItPI/AAAAAAAAAis/QhjqO3x8538/s1600/lab_corners_fast9.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://3.bp.blogspot.com/-ySqaSm-M8Nc/Ti2OSGAItPI/AAAAAAAAAis/QhjqO3x8538/s400/lab_corners_fast9.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Corners detected by fast9.py&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-7hWB9ocvd9Y/Ti2OUlRtskI/AAAAAAAAAiw/YDPPaWYcflw/s1600/lab_corners_fast10.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://1.bp.blogspot.com/-7hWB9ocvd9Y/Ti2OUlRtskI/AAAAAAAAAiw/YDPPaWYcflw/s400/lab_corners_fast10.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Corners detected by fast10.py&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-UCi3irQkQjI/Ti2OWjBp7zI/AAAAAAAAAi0/u1OdIa25tLw/s1600/lab_corners_fast11.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://1.bp.blogspot.com/-UCi3irQkQjI/Ti2OWjBp7zI/AAAAAAAAAi0/u1OdIa25tLw/s400/lab_corners_fast11.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Corners detected by fas11.py&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-66ww7QENJK8/Ti2OY7WwBzI/AAAAAAAAAi4/jxKF_P3Culc/s1600/lab_corners_fast12.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-66ww7QENJK8/Ti2OY7WwBzI/AAAAAAAAAi4/jxKF_P3Culc/s400/lab_corners_fast12.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Corners detected by fast12.py&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;The example code used to get the above results is listed as the follows:&lt;br /&gt;(Example usage: &lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;python example.py 9&lt;/span&gt;) &lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; highlight: [13]"&gt;import Image, ImageDraw&lt;br /&gt;import numpy&lt;br /&gt;import sys &lt;br /&gt;import fast9, fast10, fast11, fast12&lt;br /&gt;&lt;br /&gt;im = Image.open('lab.pgm')&lt;br /&gt;pix = numpy.array(im)&lt;br /&gt;draw = ImageDraw.Draw(im)&lt;br /&gt;&lt;br /&gt;method = 'fast' + str(sys.argv[1])&lt;br /&gt;filetosave = 'lab_corners_' + method + '.png'&lt;br /&gt;&lt;br /&gt;(corners, scores) = eval(method).detect(pix, 30, 1)&lt;br /&gt;&lt;br /&gt;#draw.point(corners, fill='white') # points are too small for the illustration&lt;br /&gt;r = 5 &lt;br /&gt;for (x,y) in corners:&lt;br /&gt;    draw.ellipse((x, y, x+r, y+r), fill='white', outline='black')&lt;br /&gt;&lt;br /&gt;im.save(filetosave)&lt;br /&gt;im.show()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3418681173623972691?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3418681173623972691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3418681173623972691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3418681173623972691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3418681173623972691'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/07/py-example-code-of-fast-corner.html' title='[Py] Example code of FAST corner detection'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-ySqaSm-M8Nc/Ti2OSGAItPI/AAAAAAAAAis/QhjqO3x8538/s72-c/lab_corners_fast9.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3648673274796888392</id><published>2011-05-31T09:01:00.003+08:00</published><updated>2011-05-31T09:04:20.301+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='ImageMagick'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>Tile Figures with Montage (ImageMagick)</title><content type='html'>Suppose you have several figures for articles ,papers, blogs, or anything else. You want to combine these figures into a bigger frame, and they have gaps between each other. How? I had used &lt;a href="http://inkscape.org/"&gt;Inkscape&lt;/a&gt; to import the figures, arrange them, and export the final result. No, don't do that again. It is not necessary to launch your image editors with GUI to accomplish this kind of work. I found the most convenient&amp;nbsp; way is to use some commands offered by the magic &lt;a href="http://www.imagemagick.org/script/index.php"&gt;ImageMagick&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Good examples have been given in ``&lt;a href="http://www.imagemagick.org/Usage/montage/#geometry_size"&gt;ImageMagick v6 Examples -- Montage, Arrays of Images&lt;/a&gt;,'' and the following is my own test with some notes.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;Now I have four pictures:&lt;br /&gt;&lt;br /&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-BxrDUfAUqEY/TPY50GW-mzI/AAAAAAAAAZo/HR9fXjVxlG4/s1600/002_namie.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/-BxrDUfAUqEY/TPY50GW-mzI/AAAAAAAAAZo/HR9fXjVxlG4/s200/002_namie.jpg" width="200" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;002_namie.jpg&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-blcjFA8nxtM/TS1FMEzNgKI/AAAAAAAAAa0/4LsQ8L3Hvqk/s1600/008_janine.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://2.bp.blogspot.com/-blcjFA8nxtM/TS1FMEzNgKI/AAAAAAAAAa0/4LsQ8L3Hvqk/s200/008_janine.jpg" width="200" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;008_janine.jpg&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-j3LPA2iIY4E/TUmDULgpEDI/AAAAAAAAAcY/T1FUVZg8Tbo/s1600/009_color.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="150" src="http://3.bp.blogspot.com/-j3LPA2iIY4E/TUmDULgpEDI/AAAAAAAAAcY/T1FUVZg8Tbo/s200/009_color.png" width="200" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;009_color.png&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-NzmOqXnw2r4/TWU_23yYhvI/AAAAAAAAAc0/ew0vCZbvt88/s1600/010_color.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="200" src="http://4.bp.blogspot.com/-NzmOqXnw2r4/TWU_23yYhvI/AAAAAAAAAc0/ew0vCZbvt88/s200/010_color.png" width="133" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;010_color.png&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;Command:&lt;br /&gt;&lt;div style="background-color: orange; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ montage *_* -geometry 120x120 tile01.png&lt;/div&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-8vrzys7St34/TeQ6AydIorI/AAAAAAAAAec/z2vdoyfMtDM/s1600/tile01.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-8vrzys7St34/TeQ6AydIorI/AAAAAAAAAec/z2vdoyfMtDM/s1600/tile01.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Command:&lt;br /&gt;&lt;div style="background-color: orange; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ montage *_* -geometry 120x120+5+5 tile02.png&lt;/div&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-cUztLBFuc1g/TeQ7m3slaeI/AAAAAAAAAeg/pDKNF6qJygk/s1600/tile02.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-cUztLBFuc1g/TeQ7m3slaeI/AAAAAAAAAeg/pDKNF6qJygk/s1600/tile02.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Command:&lt;br /&gt;&lt;div style="background-color: orange; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;montage *_* -tile 1x4 -geometry 120x120 tile03.png&lt;/div&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-UFuuF_cIrag/TeQ80Z5f3II/AAAAAAAAAek/aztnmGEId0E/s1600/tile03.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-UFuuF_cIrag/TeQ80Z5f3II/AAAAAAAAAek/aztnmGEId0E/s1600/tile03.png" /&gt;&lt;/a&gt;&lt;/div&gt;Command:&lt;br /&gt;&lt;div style="background-color: orange; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;montage *_* -tile 4x1 -geometry 120x120 tile04.png&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-T2-4WRSnbtg/TeQ8_18oFiI/AAAAAAAAAeo/PcTPKnZxR7w/s1600/tile04.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-T2-4WRSnbtg/TeQ8_18oFiI/AAAAAAAAAeo/PcTPKnZxR7w/s1600/tile04.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="background-color: #6aa84f;"&gt;Note:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;The ``*_*'' is the regexp shorthand of the original files to be combined.&lt;/li&gt;&lt;li&gt;The final term of the command is the file name of output. &lt;/li&gt;&lt;li&gt;The 120x120 option resizes the output&lt;/li&gt;&lt;li&gt;The +5+5 option add gaps between each picture in x then y directions.&lt;/li&gt;&lt;li&gt;If only one value is given (+5, for example), then only the x gap is set.&lt;/li&gt;&lt;li&gt;Montage arrange the output in array automatically, but you can change it by the -tile option.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3648673274796888392?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3648673274796888392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3648673274796888392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3648673274796888392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3648673274796888392'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/05/tile-figures-with-montage-imagemagick.html' title='Tile Figures with Montage (ImageMagick)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-BxrDUfAUqEY/TPY50GW-mzI/AAAAAAAAAZo/HR9fXjVxlG4/s72-c/002_namie.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5841601522961576485</id><published>2011-05-22T15:09:00.000+08:00</published><updated>2011-05-22T15:09:33.768+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='open source'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='C/C++'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><title type='text'>Tetris in Command Line</title><content type='html'>Ha ha! That's really funny. I never think about even &lt;a href="http://www.gnu.org/software/sed/manual/sed.html"&gt;sed&lt;/a&gt; can &lt;a href="http://sed.sourceforge.net/#gamez"&gt;be used to write games&lt;/a&gt; such as Tetris!&lt;br /&gt;&lt;br /&gt;I just wondered how to play Tetris in command line. Googled it and found several results with source code. There are three of them I've played:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.nathandumont.com/node/167"&gt;Tetris for the command line with Python Curses&lt;/a&gt; (in Python)&lt;/li&gt;&lt;li&gt;&lt;a href="http://commandliners.com/2009/03/play-tetris-at-the-command-line/"&gt; Play Tetris at the command line&lt;/a&gt; (in sed)&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.miketaylor.org.uk/tech/tt/"&gt;tt: Tetris for Terminals&lt;/a&gt; (in C)&lt;/li&gt;&lt;/ol&gt;To compile tt, you may need to install ncurses, or you will get the following errors:&lt;br /&gt;&lt;blockquote style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;utils.c:32:20: error: curses.h: No such file or directory&lt;br /&gt;utils.c:33:18: error: term.h: No such file or directory&lt;/blockquote&gt;&lt;br /&gt;In Ubuntu, just install the ncurses-dev.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5841601522961576485?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5841601522961576485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5841601522961576485' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5841601522961576485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5841601522961576485'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/05/tetris-in-command-line.html' title='Tetris in Command Line'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7878463498078909289</id><published>2011-05-05T12:13:00.001+08:00</published><updated>2011-05-05T12:15:47.827+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='open source'/><title type='text'>[talk] Thanks to You</title><content type='html'>I attended a class about how to write English emails yesterday. At the end of the class, the lecturer asked us to write an email for exercise. Below is what I wrote. A personal thank to you who have contributed to the open source community.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Dear Mr. and Ms. Hackers,&lt;br /&gt;&lt;br /&gt;I am writing to thank you for your great and amazing works&lt;br /&gt;to the open source community.&lt;br /&gt;&lt;br /&gt;With so many brilliant tools you've created and kindly released,&lt;br /&gt;many end-users, including me, are allowed to do more useful&lt;br /&gt;things with free [of] charge and, more important[ly], with the freedom&lt;br /&gt;to choose software.&lt;br /&gt;&lt;br /&gt;Furthermore, I've learnt about many interesting and useful skills from&lt;br /&gt;the source code released by you.&lt;br /&gt;That's great and I hope I could be capable of contributing back to the&lt;br /&gt;community in the future.&lt;br /&gt;Thank you all for your great works.&lt;br /&gt;&lt;br /&gt;Sincerely yours,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;THK&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7878463498078909289?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7878463498078909289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7878463498078909289' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7878463498078909289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7878463498078909289'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/05/talk-thanks-to-you.html' title='[talk] Thanks to You'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-112409524138649230</id><published>2011-04-28T13:51:00.000+08:00</published><updated>2011-04-28T13:51:04.665+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='BibTeX'/><category scheme='http://www.blogger.com/atom/ns#' term='Word'/><category scheme='http://www.blogger.com/atom/ns#' term='LaTeX'/><title type='text'>Great tool for LaTeX users working with MS Word -- Bibtex4Word</title><content type='html'>I was writing conference papers which have only templates in MS Word, and was wondering how to cite the references and to produce the bibliography in Word as easy as that in LaTeX. Then I found &lt;a href="http://www.ee.ic.ac.uk/hp/staff/dmb/perl/index.html"&gt;Bibtex4Word&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Most MS Word users might type the bibliography list manually, and it is really a tedious work. Inconsistent formatting style might be a main problem of manually typing the bibliography. The format should be done automatically, and should be changed easily to other styles. Just all the natural things in LaTeX.&lt;br /&gt;&lt;br /&gt;Bibtex4Word can do the work pretty nice. I have installed and tested with it. Other programs needed are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://jabref.sourceforge.net/"&gt;JabRef&lt;/a&gt;: to produce and to manage the bib file of your references&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.miktex.org/"&gt;MikeTeX&lt;/a&gt;: to provide &lt;a href="http://en.wikipedia.org/wiki/BibTeX"&gt;BibTeX &lt;/a&gt;for Bibtex4Word so that it can output formatted bibliography list&lt;/li&gt;&lt;/ul&gt;No need to worry about the formatting is really great. :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-112409524138649230?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/112409524138649230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=112409524138649230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/112409524138649230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/112409524138649230'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/04/great-tool-for-latex-users-working-with.html' title='Great tool for LaTeX users working with MS Word -- Bibtex4Word'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4830171282513970540</id><published>2011-04-20T10:34:00.000+08:00</published><updated>2011-04-20T10:34:52.737+08:00</updated><title type='text'>[talk] Talk to myself...</title><content type='html'>&lt;ul&gt;&lt;li&gt;Work hard when you are at work.&lt;/li&gt;&lt;li&gt;Don't promise too much, but once promised, don't think too much. Just do it.&lt;/li&gt;&lt;li&gt;No matter what is in front of you, calm down.&lt;/li&gt;&lt;li&gt;The only way to solve the problem is to solve it.&lt;/li&gt;&lt;li&gt;A problem is not only a problem, it's also a challenge, and could be a chance, an opportunity.&lt;/li&gt;&lt;li&gt;Knowledge, skill, and working hard.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4830171282513970540?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4830171282513970540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4830171282513970540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4830171282513970540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4830171282513970540'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/04/talk-talk-to-myself.html' title='[talk] Talk to myself...'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2968092921324203768</id><published>2011-03-08T13:41:00.001+08:00</published><updated>2011-03-08T13:41:47.499+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='opencv'/><title type='text'>[Py] Use ``import cv'' in Ubuntu</title><content type='html'>At the beginning of my OpenCV learning with Python, I noticed one thing which confused me but I didn't give it further attentions. Some examples import the OpenCV modules by using ``import cv'' and some use ``import opencv.'' The first one has never worked to me, so I've adopted ``import opencv'' until today.&lt;br /&gt;&lt;br /&gt;The problems were not only about the import approach. Although I found I can import opencv.cv module, which looked similar to the so-called cv module, there had been other problems about the function names. I noticed that many functions given by the opencv.cv module have the ``cv'' prefix, while the same functions given directly by the cv module don't. For example, opencv.cv offers open.cv.cvSomeFunction() while in cv it is cv.SomeFunction(). Based on the observation, I suspected that my installation of OpenCV an/or Python bindings are not totally right.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So another solution searching journey begun, and I think I've got the right answers.&lt;br /&gt;&lt;br /&gt;First, according to [1], I went to &lt;a href="http://opencv.willowgarage.com/wiki/InstallGuide%20%3A%20Debian"&gt;one of the OpenCV document pages&lt;/a&gt;, and it read:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;You can not use the python-opencv package because he provide old python support. On Ubuntu, python bindings won't work.&lt;/blockquote&gt;&lt;br /&gt;Gosh, I had used the python-opencv package for weeks without knowing such a fundamental problem!&lt;br /&gt;&lt;br /&gt;After reading the document page carefully, I install the OpenCV2.2 with&lt;a href="http://www.samontab.com/web/2010/04/installing-opencv-2-1-in-ubuntu/"&gt; the guidance given by Montabone&lt;/a&gt;. Make sure to have python-dev so that you can compile and have the most import thing -- cv.so.&lt;br /&gt;&lt;br /&gt;Note that the cv.so will be in the site-packages directory which is not in the Python's searching path. You need to cp the cv.so to the dist-packages directory, that is:&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ sudo cp /usr/local/lib/python2.6/site-packages/cv.so /usr/local/lib/python2.6/dist-packages/cv.so&lt;/div&gt;&lt;br /&gt;So far, I can use ``import cv'' in Python. That's great, but I've started to worry about my previous trials about the image processing with webcam... Orz&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;[1] &lt;a href="http://ubuntuforums.org/showthread.php?t=1500834"&gt;http://ubuntuforums.org/showthread.php?t=1500834&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2968092921324203768?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2968092921324203768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2968092921324203768' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2968092921324203768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2968092921324203768'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/03/py-use-import-cv-in-ubuntu.html' title='[Py] Use ``import cv&apos;&apos; in Ubuntu'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8286671321973172950</id><published>2011-03-03T20:57:00.011+08:00</published><updated>2011-03-04T10:38:19.256+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='opencv'/><title type='text'>Trials of pycam example code (2)</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushBash.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;I've downloaded pycam and &lt;a href="http://hiankun.blogspot.com/2011/01/trials-of-pycam-example-code.html"&gt;tested some of the sample codes&lt;/a&gt;. There were some errors when I tried to run the examples, such as DrawAHat.py and eyeLocator.py [1]. The error messages were as follows.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;swig/python detected a memory leak of type 'int64 *', no destructor found.&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;  File "DrawAHat.py", line 50, in &amp;lt;module&amp;gt;&lt;br /&gt;    VideoCapturePlayer(processFunction=drawHatOnFaces).main()&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/pycam/VideoCapturePlayer.py", line 160, in main&lt;br /&gt;    self.get_and_flip()&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/pycam/VideoCapturePlayer.py", line 126, in get_and_flip&lt;br /&gt;    res = self.processFunction(self.snapshot)&lt;br /&gt;  File "DrawAHat.py", line 36, in drawHatOnFaces&lt;br /&gt;    faces = pygameFaceDetect.getFaces(surf)&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/pycam/pygameFaceDetect.py", line 51, in getFaces&lt;br /&gt;    return faceDetect.detectObject(img)&lt;br /&gt;  File "/usr/local/lib/python2.6/dist-packages/pycam/objectDetect.py", line 130, in detectObject&lt;br /&gt;    t = cvGetTickCount() - t&lt;br /&gt;TypeError: unsupported operand type(s) for -: 'SwigPyObject' and 'SwigPyObject'&lt;br /&gt;swig/python detected a memory leak of type 'int64 *', no destructor found.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This afternoon, I jumped into these examples again and tried to figure out what the messages meant. But I know nothing about the swig/python lines. Then, I found out that I should step into objectDetect.py which is in charge of the detection of objects. The error messages said that the problems caused by something about types, and I found the cvGetTickCount() were used to get ticks for estimating fps, which is not crucial and can be isolated!&lt;br /&gt;&lt;br /&gt;So I commented out the lines related to cvGetTickCount(), reinstalled the pycam library, and retried the DrawAHat.py example. It worked!&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py; first-line: 112; highlight: [127, 130, 131]"&gt;def detectObject(self,img):&lt;br /&gt;        """ &lt;br /&gt;        This should be pure opencv and reasonably quick.&lt;br /&gt;        It carrys out the actual detection, and returns a list of objects found&lt;br /&gt;        """&lt;br /&gt;        # Could this go into init?&lt;br /&gt;        gray = cvCreateImage( cvSize(img.width,img.height), 8, 1 ) &lt;br /&gt;        small_img = cvCreateImage( cvSize( cvRound (img.width/self.image_scale),&lt;br /&gt;                                           cvRound (img.height/self.image_scale)), 8, 1 ) &lt;br /&gt;        cvCvtColor( img, gray, CV_BGR2GRAY )&lt;br /&gt;        cvResize( gray, small_img, CV_INTER_LINEAR )&lt;br /&gt;        cvEqualizeHist( small_img, small_img )&lt;br /&gt;        cvClearMemStorage( self.storage )&lt;br /&gt;&lt;br /&gt;        if( self.cascade ):&lt;br /&gt;            #t = cvGetTickCount()&lt;br /&gt;            objects = cvHaarDetectObjects( small_img, self.cascade, self.storage,&lt;br /&gt;                                         self.haar_scale, self.min_neighbors, self.haar_flags, self.min_size )&lt;br /&gt;            #t = cvGetTickCount() - t&lt;br /&gt;            #logging.debug( "%i objects found, detection time = %gms" % (objects.total,t/(cvGetTickFrequency()*1000.)) )&lt;br /&gt;            return objects&lt;br /&gt;        else:&lt;br /&gt;            logging.error("no cascade")&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here are two funny trials. &lt;a href="http://www.openclipart.org/detail/95377"&gt;Spider-Man&lt;/a&gt; and &lt;a href="http://www.openclipart.org/detail/70477"&gt;Guy Fawkes&lt;/a&gt;:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh3.googleusercontent.com/-MJq9Ov_n1Aw/TW-jiRkGIlI/AAAAAAAAAdA/W5Dxbwd4CfQ/s1600/mask_spiderman.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="255" src="https://lh3.googleusercontent.com/-MJq9Ov_n1Aw/TW-jiRkGIlI/AAAAAAAAAdA/W5Dxbwd4CfQ/s320/mask_spiderman.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh6.googleusercontent.com/-MYq0H3eLDIk/TW-jmg-8AkI/AAAAAAAAAdE/WuDWzBwnNRE/s1600/mask_guyfawkes.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="255" src="https://lh6.googleusercontent.com/-MYq0H3eLDIk/TW-jmg-8AkI/AAAAAAAAAdE/WuDWzBwnNRE/s320/mask_guyfawkes.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;[1] These examples are located in ``pycam-read-only/pycam/examples/opencv''&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8286671321973172950?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8286671321973172950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8286671321973172950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8286671321973172950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8286671321973172950'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/03/trials-of-pycam-example-code-2.html' title='Trials of pycam example code (2)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh3.googleusercontent.com/-MJq9Ov_n1Aw/TW-jiRkGIlI/AAAAAAAAAdA/W5Dxbwd4CfQ/s72-c/mask_spiderman.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7907798695457327021</id><published>2011-02-28T18:33:00.001+08:00</published><updated>2011-03-04T10:38:58.084+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Use cProfile to check the run time performance of a program</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;When I was trying to figure out the usage about get_fps of &lt;a href="http://www.pygame.org/docs/ref/time.html#pygame.time.Clock"&gt;pygame.time.Clock&lt;/a&gt;, I read about the thread:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/2530478/help-getting-frame-rate-fps-up-in-python-pygame"&gt;Help getting frame rate (fps) up in Python + Pygame&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;And I noticed that they were talking about ``cProfile,'' so I went to the document about it:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://docs.python.org/library/profile.html"&gt;The Python Profilers&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;During the test, I encountered the following import error:&lt;br /&gt;&lt;blockquote&gt;ImportError: No module named pstats&lt;/blockquote&gt;To solve this problem, install the module named python-proflier [1], not the python-stats which I mistaken for the missing module.&lt;br /&gt;&lt;br /&gt;Note that it seems not straightforward to run cProfile in &lt;a href="http://ipython.scipy.org/moin/"&gt;IPython&lt;/a&gt; [2]. I have tried cProfile in IPython but got no expected results, so I turned to run cProfile in command line. The following example shows the command line usage of run foo.py with cProfile, and save the output into foo.profile which can be used later:&lt;br /&gt;&lt;blockquote&gt;$ python -m cProfile -o foo.profile foo.py&lt;/blockquote&gt;Then run in IPython:&lt;br /&gt;&lt;pre class="brush:py"&gt;import pstats&lt;br /&gt;p = pstats.Stats('foo.profile') # read the profile just have been saved&lt;br /&gt;p.sort_stats('cumulative').print_stats(10) # sort by cumulative time, and then print the first 10 results&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;The output:&lt;br /&gt;&lt;blockquote&gt;Mon Feb 28 17:57:59 2011&amp;nbsp;&amp;nbsp;&amp;nbsp; foo.profile&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 57277 function calls (56161 primitive calls) in 3.940 CPU seconds&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; Ordered by: cumulative time&lt;br /&gt;&amp;nbsp;&amp;nbsp; List reduced from 969 to 10 due to restriction &amp;lt;10&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; ncalls&amp;nbsp; tottime&amp;nbsp; percall&amp;nbsp; cumtime&amp;nbsp; percall filename:lineno(function)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942 &lt;string&gt;:1(&lt;module&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942 {execfile}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.013&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.013&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.942 cam_pygame.py:1(&lt;module&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.003&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.972&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.124 cam_pygame.py:11(get_image)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.000&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.783&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.116 /usr/lib/pymodules/python2.6/opencv/highgui.py:116(cvQueryFrame)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.783&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.116&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.783&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.116 {_highgui.cvQueryFrame}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.255&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.255&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.011 {pygame.display.flip}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.067&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.067&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.154&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.154 {pygame.display.set_mode}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.145&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.006&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.145&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.006 {method 'blit' of 'pygame.Surface' objects}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.018&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.100&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.100 /usr/lib/python2.6/dist-packages/pygame/__init__.py:25(&lt;module&gt;)&lt;/module&gt;&lt;/module&gt;&lt;/module&gt;&lt;/string&gt;&lt;/blockquote&gt;---&lt;br /&gt;Ref:&lt;br /&gt;[1] &lt;a href="http://www.saltycrane.com/blog/2010/01/importerror-no-module-named-pstats-error-ubuntu/"&gt;"ImportError: No module named pstats" error on Ubuntu&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://yuji.wordpress.com/2011/02/17/cprofile-example-and-ipython-magic-shortcut-prun/"&gt;cProfile Example and iPython Magic Shortcut %prun&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7907798695457327021?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7907798695457327021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7907798695457327021' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7907798695457327021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7907798695457327021'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/py-use-cprofile-to-check-run-time.html' title='[Py] Use cProfile to check the run time performance of a program'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7026874194240809910</id><published>2011-02-28T17:12:00.004+08:00</published><updated>2011-03-04T10:40:14.412+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='webcam'/><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Using get_fps function of pygame</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;There are modules of &lt;a href="http://www.pygame.org/news.html"&gt;pygame&lt;/a&gt; which provide time related functions. One of them is the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;get_fps&lt;/span&gt; which can be used to know the fps of executing program.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;To use the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;get_fps&lt;/span&gt; function, we have to create a Clock object:&lt;br /&gt;&lt;blockquote&gt;clock = &lt;a href="http://www.pygame.org/docs/ref/time.html#pygame.time.Clock"&gt;pygame.time.Clock&lt;/a&gt;()&lt;/blockquote&gt;Then, use the tick method and get_fps:&lt;br /&gt;&lt;blockquote&gt;clock.tick()&lt;br /&gt;print "fps:", clock.get_fps()&lt;/blockquote&gt;Here is the testing code, which is almost the same with the one used in &lt;a href="http://hiankun.blogspot.com/2011/02/py-pythonopencvpygame-for-capturing.html"&gt;my old post&lt;/a&gt;:&lt;br /&gt;&lt;pre class="brush:py; highlight: [20, 28, 29]"&gt;import pygame&lt;br /&gt;import Image&lt;br /&gt;import ImageOps&lt;br /&gt;from pygame.locals import *&lt;br /&gt;import sys &lt;br /&gt;&lt;br /&gt;import opencv&lt;br /&gt;from opencv import highgui&lt;br /&gt;&lt;br /&gt;camera = highgui.cvCreateCameraCapture(0)&lt;br /&gt;def get_image():&lt;br /&gt;        im = highgui.cvQueryFrame(camera)&lt;br /&gt;        return ImageOps.mirror(opencv.adaptors.Ipl2PIL(im))&lt;br /&gt;&lt;br /&gt;pygame.init()&lt;br /&gt;window = pygame.display.set_mode((640,480))&lt;br /&gt;pygame.display.set_caption("WebCam Demo")&lt;br /&gt;screen = pygame.display.get_surface()&lt;br /&gt;&lt;br /&gt;clock = pygame.time.Clock()&lt;br /&gt;&lt;br /&gt;while True:&lt;br /&gt;        events = pygame.event.get()&lt;br /&gt;        for event in events:&lt;br /&gt;                if event.type == QUIT or event.type == KEYDOWN:&lt;br /&gt;                        highgui.cvReleaseCapture(camera)&lt;br /&gt;                        sys.exit(0)&lt;br /&gt;        clock.tick()&lt;br /&gt;        print "fps:", clock.get_fps()&lt;br /&gt;&lt;br /&gt;        im = get_image()&lt;br /&gt;        pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)&lt;br /&gt;&lt;br /&gt;        screen.blit(pg_img, (0,0))&lt;br /&gt;        pygame.display.flip()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Note that the print slow down the program significantly, so what we get is actually NOT the original fps but a slower one.&lt;br /&gt;&lt;br /&gt;What I have shown in this post may be not a good implementation of getting real-time fps information. It is just a trial to utilize the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;get_fps&lt;/span&gt; function. If you know any better approach, please show me related information. Thank you.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref: &lt;a href="http://www.pygame.org/docs/ref/time.html"&gt;Pygame module for monitoring time&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7026874194240809910?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7026874194240809910/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7026874194240809910' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7026874194240809910'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7026874194240809910'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/py-using-getfps-function-of-pygame.html' title='[Py] Using get_fps function of pygame'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8398443195574909994</id><published>2011-02-28T13:54:00.002+08:00</published><updated>2011-02-28T13:57:31.693+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Using rst files -- the easy way</title><content type='html'>When viewing documents of &lt;a href="http://luispedro.org/software/mahotas"&gt;mahatos&lt;/a&gt;, there are text files with rst as their extensions. They reminded me about the &lt;a href="http://docutils.sourceforge.net/rst.html"&gt;reStructureText&lt;/a&gt; which I met but got confused and gave it up. This time I tried to figure out how to use it and how to convert it into other formats, for example, the HTML. The following steps and links are my quick notes, just for you who also want to try the rst files very quickly on Ubuntu.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Assume that you have Python on your system already.&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ sudo apt-get install python-docutils&lt;/span&gt; (this is the module that gives the utilities of the conversion between rst and other formats)&lt;/li&gt;&lt;li&gt;Download &lt;a href="http://docutils.sf.net/docutils-snapshot.tgz"&gt;the source package&lt;/a&gt; of Docutils&lt;/li&gt;&lt;li&gt;Untar the downloaded package and go to the &lt;b&gt;tools&lt;/b&gt; directory, find the &lt;b&gt;rst2html.py&lt;/b&gt;, and copy it to a folder contained the &lt;a href="http://docutils.sourceforge.net/docs/user/rst/cheatsheet.txt"&gt;cheatsheet.txt&lt;/a&gt; (Please download it. It is a text file formatted in rst file, and we will use it for the following test.)&lt;/li&gt;&lt;li&gt;Go to the folder contained the cheatsheet.txt file&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ python rst2html.py cheatsheet.txt &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cheatsheet&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.html&lt;/span&gt;&lt;/li&gt;&lt;li&gt;You now have the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cheatsheet&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.txt&lt;/span&gt; converted to &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cheatsheet&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.html&lt;/span&gt;, and you can view the &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cheatsheet&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;.html&lt;/span&gt; in your browser&lt;/li&gt;&lt;/ol&gt;To be brief, use the the tools given by the source package to convert the rst text files into other formats.&lt;br /&gt;&lt;br /&gt;Before jump into installing the Dcoutils on your system, you may want to try and see the rendered result online: &lt;a href="http://www.tele3.cz/jbar/rest/rest.html"&gt;reST to HTML conversion&lt;/a&gt;. Just copy the content of  &lt;a href="http://docutils.sourceforge.net/docs/user/rst/cheatsheet.txt"&gt;cheatsheet.txt&lt;/a&gt; and paste it into the online converter, and click the Render button to view the result. That's pretty cool. :-)&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8398443195574909994?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8398443195574909994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8398443195574909994' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8398443195574909994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8398443195574909994'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/using-rst-files-easy-way.html' title='Using rst files -- the easy way'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5794594669869320416</id><published>2011-02-28T11:32:00.001+08:00</published><updated>2011-03-04T10:41:11.377+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='SURF'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] SURF tests with mahotas.surf</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;I &lt;a href="http://hiankun.blogspot.com/2011/02/installing-mahotas-image-processing-in.html"&gt;installed mahotas&lt;/a&gt; in my Python for the purpose of trying the &lt;a href="http://www.vision.ee.ethz.ch/%7Esurf/"&gt;SURF&lt;/a&gt;. There is &lt;a href="http://packages.python.org/mahotas/surf.html"&gt;a simple example&lt;/a&gt; on the mahotas document page, but some minor modifications are needed. Here is the modified example code:&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py"&gt;import numpy as np&lt;br /&gt;import pylab&lt;br /&gt;import mahotas.surf&lt;br /&gt;&lt;br /&gt;f = mahotas.imread('lena.png')&lt;br /&gt;spoints = mahotas.surf.surf(f)&lt;br /&gt;&lt;br /&gt;f2 = mahotas.surf.show_surf(f, spoints[:20])&lt;br /&gt;pylab.imshow(f2)&lt;br /&gt;pylab.show()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Note that only grayscale images can be directly used as the input. Here only the first 20 interesting points have been plotted.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="https://lh4.googleusercontent.com/-NTfSDjN0zps/TWqALu0rmoI/AAAAAAAAAc8/5Zp80WXH0mc/s1600/lena_surf_test.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="160" src="https://lh4.googleusercontent.com/-NTfSDjN0zps/TWqALu0rmoI/AAAAAAAAAc8/5Zp80WXH0mc/s320/lena_surf_test.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5794594669869320416?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5794594669869320416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5794594669869320416' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5794594669869320416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5794594669869320416'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/py-surf-tests-with-mahotassurf.html' title='[Py] SURF tests with mahotas.surf'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh4.googleusercontent.com/-NTfSDjN0zps/TWqALu0rmoI/AAAAAAAAAc8/5Zp80WXH0mc/s72-c/lena_surf_test.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8293446562757125824</id><published>2011-02-27T22:04:00.003+08:00</published><updated>2011-03-04T10:42:03.609+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SIFT'/><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='SURF'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Installing Mahotas (image processing in Python)</title><content type='html'>I've just learned about &lt;a href="http://www.cs.ubc.ca/%7Elowe/keypoints/"&gt;SIFT&lt;/a&gt; and &lt;a href="http://www.vision.ee.ethz.ch/%7Esurf/"&gt;SURF&lt;/a&gt;, and am trying to find some example to learn more.&lt;br /&gt;&lt;br /&gt;For SIFT, it is a patented methodology and seems not possible to be used as the open sourced libraries. For SURF, which has been claimed more robust and faster then SIFT, there is OpenSURF written in C++.&lt;br /&gt;&lt;br /&gt;Based on &lt;a href="http://en.wikipedia.org/wiki/SURF#Implementations"&gt;the information given on Wikipedia&lt;/a&gt;, I went for &lt;a href="http://luispedro.org/software/mahotas"&gt;mahotas&lt;/a&gt;, which is for image processing in Python, and that's what I need.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;I followed the installing instruction on the webpage of mahotas, which utilizes the &lt;a href="http://packages.python.org/distribute/easy_install.html"&gt;easy_install&lt;/a&gt; approach. I have used easy_install once on Windows XP, but have had no experience on Ubuntu. According to the instruction of &lt;a href="http://pypi.python.org/pypi/setuptools#downloads"&gt;setuptools&lt;/a&gt;, I downloaded the setuptools-0.6c11-py2.6.egg and run it with:&lt;br /&gt;&lt;blockquote&gt;$ sudo bash setuptools-0.6c11-py2.6.egg&lt;/blockquote&gt;&lt;br /&gt;The result showed a bunch of errors. I checked the first error message and found it said:&lt;br /&gt;&lt;blockquote&gt;error: Python.h: No such file or directory&lt;/blockquote&gt;It ws because my system had no python-dev, so just installed it and everything went smoothly.&lt;br /&gt;&lt;br /&gt;Finally, use easy_install for installing mahotas:&lt;br /&gt;&lt;blockquote&gt;$ sudo easy_install mahotas&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8293446562757125824?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8293446562757125824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8293446562757125824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8293446562757125824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8293446562757125824'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/installing-mahotas-image-processing-in.html' title='Installing Mahotas (image processing in Python)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5711808329055512911</id><published>2011-02-26T23:05:00.003+08:00</published><updated>2011-03-04T10:43:06.364+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='opencv'/><title type='text'>[Py] Python+OpenCV+pygame for capturing webcam frames on Ubuntu (10.04)</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;Several weeks ago, I tried to find some sample code which can get the frames of the webcam on Ubuntu. Some examples were written in C/C++, some were in Python, and them are all based on OpenCV. I tested them and got some failed. Unfortunately, I have neither enough experience nor enough time to figure out where the problems are, so I started to search some more examples again.&lt;br /&gt;&lt;br /&gt;The first light came from &lt;a href="http://www.jperla.com/blog/"&gt;Joseph Perla's blog&lt;/a&gt;. He gave &lt;a href="http://www.jperla.com/blog/post/capturing-frames-from-a-webcam-on-linux"&gt;an example&lt;/a&gt; which worked fine on my Ubuntu 10.04. I post the example with minor modifications (using ImageOps.mirror to flip the image horizontally) as the follows.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py"&gt;import pygame&lt;br /&gt;import Image&lt;br /&gt;import ImageOps&lt;br /&gt;from pygame.locals import *&lt;br /&gt;import sys &lt;br /&gt;&lt;br /&gt;import opencv&lt;br /&gt;from opencv import highgui&lt;br /&gt;&lt;br /&gt;camera = highgui.cvCreateCameraCapture(0)&lt;br /&gt;def get_image():&lt;br /&gt;        im = highgui.cvQueryFrame(camera)&lt;br /&gt;        return ImageOps.mirror(opencv.adaptors.Ipl2PIL(im))&lt;br /&gt;&lt;br /&gt;pygame.init()&lt;br /&gt;window = pygame.display.set_mode((640,480))&lt;br /&gt;pygame.display.set_caption("WebCam Demo")&lt;br /&gt;screen = pygame.display.get_surface()&lt;br /&gt;&lt;br /&gt;while True:&lt;br /&gt;        events = pygame.event.get()&lt;br /&gt;        for event in events:&lt;br /&gt;                if event.type == QUIT or event.type == KEYDOWN:&lt;br /&gt;                        highgui.cvReleaseCapture(camera) # I add this, but don't know whether it is necessary&lt;br /&gt;                        sys.exit(0)&lt;br /&gt;        im = get_image()&lt;br /&gt;        pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)&lt;br /&gt;&lt;br /&gt;        screen.blit(pg_img, (0,0))&lt;br /&gt;        pygame.display.flip()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;The example remind me about &lt;a href="http://www.pygame.org/news.html"&gt;pygame&lt;/a&gt;, which I found but had not given further attention to. I don't know the role of pygame in webcam applications so far, but I do know it works with OpenCV on my system. I would keep on studying more about it.&lt;br /&gt;&lt;br /&gt;In addition to Joseph's example code, I also found &lt;a href="http://code.google.com/p/pycam/"&gt;pycam&lt;/a&gt;, again. This time it is found &lt;a href="http://www.pygame.org/project-pycam-1111-.html"&gt;on the pygame webpage&lt;/a&gt;. I've tested pycam's examples roughly &lt;a href="http://hiankun.blogspot.com/2011/01/trials-of-pycam-example-code.html"&gt;in my previous post&lt;/a&gt; when I didn't notice that it utilizes pygame modules.&lt;br /&gt;&lt;br /&gt;My summary is: to capture and to show the webcam's image in real-time on Ubuntu, use Python, OpenCV, and pygame.&lt;br /&gt;&lt;br /&gt;For me, the next step will be learning how to apply OpenCV functions to do some image processing on the webcam's image.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5711808329055512911?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5711808329055512911/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5711808329055512911' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5711808329055512911'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5711808329055512911'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/py-pythonopencvpygame-for-capturing.html' title='[Py] Python+OpenCV+pygame for capturing webcam frames on Ubuntu (10.04)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8255452858345964169</id><published>2011-02-25T15:54:00.004+08:00</published><updated>2011-03-04T10:44:26.225+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stereo vision'/><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><title type='text'>Stereo vision -- source code testing</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushBash.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;br /&gt;&lt;a href="http://www.cs.cmu.edu/%7Eclz/CLZhomepage.html"&gt;C. Zitnick&lt;/a&gt; and &lt;a href="http://www.ri.cmu.edu/person.html?person_id=136"&gt;T. Kanade&lt;/a&gt; proposed &lt;a href="http://www.cs.cmu.edu/%7Eclz/stereo.html"&gt;an algorithm&lt;/a&gt; [1] to compute the depth (or disparity) maps for stereo version. The source code was released for non-commercial usage, and there is &lt;a href="http://disparity.wikidot.com/"&gt;a modified version&lt;/a&gt; by&amp;nbsp;K. Sokolova and B. Shilo. I suggest you go for the modified version which gives some practical and straightforward descriptions and examples. Also, the modified version offers a complete set to be compiled and executed. However, the source code needs some more minor modifications to be compiled using g++ in Ubuntu 10.04.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In run-zks.cpp:&lt;br /&gt;&lt;pre class="brush:bash"&gt;10c10&lt;br /&gt;&amp;lt; #include &lt;string&gt;&lt;br /&gt;---&lt;br /&gt;&amp;gt; #include &lt;cstring&gt;&lt;br /&gt;11a12,13&lt;br /&gt;&amp;gt; #include &lt;cstdlib&gt;&lt;br /&gt;&amp;gt; #include &lt;climits&gt;&lt;br /&gt;270,271d271&lt;br /&gt;&lt;/climits&gt;&lt;/cstdlib&gt;&lt;/cstring&gt;&lt;/string&gt;&lt;/pre&gt;&lt;br /&gt;In EasyBMO.cpp&lt;br /&gt;&lt;pre class="brush:bash"&gt;20a21&lt;br /&gt;&amp;gt; #include &lt;cstring&gt;&lt;br /&gt;&lt;/cstring&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;I combined the output images into the following gif animation (in loop).&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-J0DmL-rGy_o/TWfArCA9-KI/AAAAAAAAAc4/Nxqntx9SFhg/s1600/coal.dis.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-J0DmL-rGy_o/TWfArCA9-KI/AAAAAAAAAc4/Nxqntx9SFhg/s1600/coal.dis.gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;[1]&amp;nbsp;Charles Zitnick and Takeo Kanade, "A Cooperative Algorithm for Stereo Matching and Occlusion Detection," tech. report CMU-RI-TR-99-35, Robotics Institute, Carnegie Mellon University, October, 1999&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8255452858345964169?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8255452858345964169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8255452858345964169' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8255452858345964169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8255452858345964169'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/stereo-vision-source-code-testing.html' title='Stereo vision -- source code testing'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-J0DmL-rGy_o/TWfArCA9-KI/AAAAAAAAAc4/Nxqntx9SFhg/s72-c/coal.dis.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2776031390118839670</id><published>2011-02-18T16:53:00.000+08:00</published><updated>2011-02-18T16:53:41.226+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='GNU'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Bring good stuffs of Linux into Windows</title><content type='html'>&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;I love to work with Linux (Ubuntu), especially with its useful commands and tools when I need to write programs or analyse some kind of data. Sometimes, however, I have to cooperate with my colleagues, who are working with Windows and Visual Studio. Maybe I can do the coding works in Ubuntu, but I am not so good to solve all the problems related to hardware and drivers. We are always using cameras to capture images and process the streams in real-time. There are problems for me to run all the programs written by my colleagues in Ubuntu, and unfortunately I have no enough time as well as knowledge to tackle all the problems. Therefore, I have to go back to Windows for some program developments.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;But, the command line environment in Windows is not so convenient as in Ubuntu. Lacking the useful commands and tools might be the most inconvenient.&amp;nbsp;&lt;a href="http://www.cygwin.com/"&gt;Cygwin&lt;/a&gt;&amp;nbsp;is one way to run Linux commands in Windows, but it can only work within the Path in which the Cygwin is installed. Luckily, we have&amp;nbsp;&lt;a href="http://gnuwin32.sourceforge.net/"&gt;GunWin&lt;/a&gt;&amp;nbsp;which provides many of the useful tools for Windows. Just click the ``Setup'' links on&lt;a href="http://gnuwin32.sourceforge.net/packages.html"&gt;&amp;nbsp;the page of &amp;nbsp;packages&lt;/a&gt;, then you will get the tools installed and you can use them directly in the Windows cmd shell.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;For further introduction, please go for the following link:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://www.askstudent.com/tips/how-to-use-unixlinux-commands-at-the-windows-command-prompt/"&gt;How to use Unix/Linux commands at the Windows command prompt&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2776031390118839670?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2776031390118839670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2776031390118839670' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2776031390118839670'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2776031390118839670'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/bring-good-stuffs-of-linux-into-windows.html' title='Bring good stuffs of Linux into Windows'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4728657841083802137</id><published>2011-02-18T16:17:00.001+08:00</published><updated>2011-03-04T10:45:17.989+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='open source'/><category scheme='http://www.blogger.com/atom/ns#' term='Chromium'/><category scheme='http://www.blogger.com/atom/ns#' term='Firefox'/><title type='text'>Moved from Firefox to Chromium</title><content type='html'>I have moved from &lt;a href="http://www.mozilla.com/en-US/firefox/"&gt;Firefox&lt;/a&gt; to &lt;a href="http://en.wikipedia.org/wiki/Chromium_%28web_browser%29"&gt;Chromium&lt;/a&gt; for several weeks. Firefox is excellent in many aspects, especially its abundant and wonderful &lt;a href="https://addons.mozilla.org/en-US/firefox/?browse=featured"&gt;add-ons&lt;/a&gt;. However, in my own experience, it is not really fast. After some trials and findings, I decided to use Chromium as my default browser.&lt;br /&gt;&lt;br /&gt;I would like to share some experiences here. Some are the excellent features of Chromium, and of course some are not so good.&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;1. Synchronization&lt;/span&gt;&lt;br /&gt;When using Chromium, you don't need to synchronize the bookmarks or plugins of your browsers which might be installed in your laptops and PCs. You can set the synchronization in ``Preferences --&amp;gt; Personal Stuff --&amp;gt; Sync.''&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-hPKXNUfQlaA/TV4NvZ7JiCI/AAAAAAAAAck/stJPYTKi7YI/s1600/chromium_preferences.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/-hPKXNUfQlaA/TV4NvZ7JiCI/AAAAAAAAAck/stJPYTKi7YI/s320/chromium_preferences.png" width="297" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;You can click ``Customize...'' button to change the settings. It is extremely convenient because the&amp;nbsp;synchronization&amp;nbsp;syncs not only the bookmarks but also your extensions, themes, and almost everything else. So when you change some settings in the browser in one of your PC, you don't need to rework on other browsers installed in your other machines.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-c5dqMjP6tsI/TV4Nwnexx1I/AAAAAAAAAco/E-K5nOevif8/s1600/chromium_sync.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="279" src="http://4.bp.blogspot.com/-c5dqMjP6tsI/TV4Nwnexx1I/AAAAAAAAAco/E-K5nOevif8/s320/chromium_sync.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;2. Change the Colors&lt;/span&gt;&lt;br /&gt;I like to view webpages in black background with white fonts, just like that in command line consoles. If you are like me, the &lt;a href="https://chrome.google.com/webstore/detail/jbmkekhehjedonbhoikhhkmlapalklgn"&gt;Change Colors&lt;/a&gt; extension might be handy for you. There are three levels to apply or to remove the color settings: this page, this domain, and all pages. The following pictures are my blog before and after the colors changed.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-74bqiwUMVcI/TV4RkN6eAiI/AAAAAAAAAcs/joJ39q7jNog/s1600/chromium_site.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="208" src="http://2.bp.blogspot.com/-74bqiwUMVcI/TV4RkN6eAiI/AAAAAAAAAcs/joJ39q7jNog/s320/chromium_site.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-A1QDlEd6Wjk/TV4Roemj1mI/AAAAAAAAAcw/CwId6ecQZM4/s1600/chromium_site_change_color.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="208" src="http://4.bp.blogspot.com/-A1QDlEd6Wjk/TV4Roemj1mI/AAAAAAAAAcw/CwId6ecQZM4/s320/chromium_site_change_color.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;The first problem I've encountered is about images. Some images on webpages become invisible after applying the color change. The colorful logo of Google is one of them, and the equations on Wikipedia (which have transparent background) is another one. Another problem is for some widgets with bright background. Because the text has been set as bright color, but we can not change the widgets' colors as well, this will cause the text difficult to view.&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;3. StumbleUpon Toolbar&lt;/span&gt;&lt;br /&gt;As far as I know, there are two methods to use StumbleUpon in Chromium:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.indiandevs.com/technoworld/2008/09/09/stumbleupon-toolbar-for-chrome-use-stumbleupon-without-it/"&gt;StumbleUpon Toolbar for Chrome – How to Use StumbleUpon on Google Chrome&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.stumbleupon.com/sublog/su_chrome_extension/"&gt;StumbleUpon Extension for Chrome Now Officially Available!&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The first one is older but less buggy. Although, the second one is an official extension, it cause some problems when showing the results of ``Google images.'' With the official toolbar enabled, I can search images with Google, but always get blank pages when I click the links of searching results. I don't know whether it is a bug of the StumbleUpon official extension. It is just my quick conclusion based on my tests.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;4. YouTube Downloaders&lt;/span&gt;&lt;br /&gt;In Firefox, I am used to &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1-click-youtube-video-download/"&gt;1-Click YouTube Video Download&lt;/a&gt;. In Chromium, I think &lt;a href="https://chrome.google.com/webstore/detail/ickpmedlifakmdjakgmiecbdokepellh"&gt;YouTube Downloader&lt;/a&gt;&amp;nbsp;is doing good works. (At the moment of writing this article, I found the link of YouTube Downloader failed, and the extension can not be found on &lt;a href="https://chrome.google.com/webstore"&gt;Chromium webpage&lt;/a&gt;. Hope it is just temporary.)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;5. Navigate as in Vim&lt;/span&gt;&lt;br /&gt;Maybe this is just important for &lt;a href="http://www.vim.org/"&gt;Vim&lt;/a&gt; users. I found &lt;a href="https://chrome.google.com/webstore/detail/godjoomfiimiddapohpmfklhgmbfffjj"&gt;Vrome&lt;/a&gt; for Chromium, but its searching function is slow and strange. Sometimes the searching seems get stuck. I am still prefer &lt;a href="http://vimperator.org/vimperator"&gt;Vimperator&lt;/a&gt; so far, which is for Firefox. Maybe I have not known very well about Vrome, so I can't utilize its capabilities properly.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Summery&lt;/span&gt;&lt;br /&gt;There are useful extensions for Chromium. Most of them are capable of doing works well but may be not so good as their counterparts of Firefox. Chromium has good integration with Google, and Firefox has powerful add-ons.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4728657841083802137?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4728657841083802137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4728657841083802137' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4728657841083802137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4728657841083802137'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/moved-from-firefox-to-chromium.html' title='Moved from Firefox to Chromium'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-hPKXNUfQlaA/TV4NvZ7JiCI/AAAAAAAAAck/stJPYTKi7YI/s72-c/chromium_preferences.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-9112775528480908476</id><published>2011-02-17T08:52:00.000+08:00</published><updated>2011-02-17T08:52:02.623+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>codepad -- an interesting web service for code sharing</title><content type='html'>Check the&amp;nbsp;&lt;a href="http://codepad.org/"&gt;codepad&lt;/a&gt;&amp;nbsp;out. I had no idea about &lt;a href="http://en.wikipedia.org/wiki/Pastebin"&gt;pastebin&lt;/a&gt; until meet the codepad website. It's really useful when you want to share some code and output with someone via email, MSN, or other internet media.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here is my simple trial on the codepad:&amp;nbsp;&lt;a href="http://codepad.org/Oja9hsaI"&gt;http://codepad.org/Oja9hsaI&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-9112775528480908476?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/9112775528480908476/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=9112775528480908476' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/9112775528480908476'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/9112775528480908476'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/codepad-interesting-web-service-for.html' title='codepad -- an interesting web service for code sharing'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3871986655790994140</id><published>2011-02-05T18:05:00.000+08:00</published><updated>2011-02-05T18:05:52.644+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='desktop'/><title type='text'>VirtuaWin -- Virtual desktop manager for Windows</title><content type='html'>If you are used to working with virtual desktops or workspaces in Linux, you might feel uncomfortable when working under the Windows environment. Fortunately, &lt;a href="http://virtuawin.sourceforge.net/"&gt;VirtuaWin&lt;/a&gt; offers an wonderful solution. I have used VirtuaWin in my office PC for at least couples of month. Today I have to do some works in Windows in my laptop, recalled VirtuaWin, and I think this time, I should introduce this good applications to you who read this post. In addition to its excellent functions, VirtuaWin is&amp;nbsp;licensed&amp;nbsp;under GNU.&lt;br /&gt;&lt;br /&gt;After downloading VirtuaWin and installing it, you can check the content of Setup by right clicking on the icon of VirtauWin, which should reside in the bottom right toolbar of the desktop.&lt;br /&gt;&lt;br /&gt;Basic usage by default:&lt;br /&gt;Alt+Ctrl+Left/Right/Up/Down: to navigate around the virtual desktops&lt;br /&gt;Alt+Win+Left/Right/Up/Down: to move the working window to the next virtual desktop&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Note: Its name is VirtuaWin, not VirtualWin.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3871986655790994140?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3871986655790994140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3871986655790994140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3871986655790994140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3871986655790994140'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/02/virtuawin-virtual-desktop-manager-for.html' title='VirtuaWin -- Virtual desktop manager for Windows'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2163947680894830942</id><published>2011-01-26T15:56:00.001+08:00</published><updated>2011-03-03T22:31:58.023+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pycam'/><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='image processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='opencv'/><title type='text'>Trials of pycam example code</title><content type='html'>I am trying to learn something about computer version, and Python is my first choice of the coding tool. After several hours of searching, I found &lt;a href="http://code.google.com/p/pycam/"&gt;pycam&lt;/a&gt;. There are several sample codes given by the pycam. What I have downloaded was the ``pycam-read-only'' folder in which are three subdirectories:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;c-vs-py&lt;/li&gt;&lt;li&gt;openeyes&lt;/li&gt;&lt;li&gt;pycam&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;To install the pycam, just find the ``setup.py'' in the subdirectory named ``pycam'' and run ``sudo python setup.py install.'' Furthermore, what you need to install might include the follows:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;python-opencv&lt;/li&gt;&lt;li&gt;python-pygame&lt;/li&gt;&lt;li&gt;libcv-dev&lt;/li&gt;&lt;li&gt;libcvaux-dev&lt;/li&gt;&lt;li&gt;libhighgui-dev&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The lib*-dev are (my guess) for the cpp codes, which need to include the cv.h and highgui.h.&lt;br /&gt;&lt;br /&gt;So far, my testing results are:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;pycam-read-only/pycam/examples/: Okay, but the fps are low&lt;/li&gt;&lt;li&gt;pycam-read-only/pycam/examples/opencv: Failed. There were errors I don't know how to resolve yet. Only the ``cam-histo.py'' can be executed, after remove the ``cv.CV_VERSION'' at line 88. (the CV_VERSION seems not in my OpenCV.)&lt;/li&gt;&lt;li&gt;pycam-read-only/pycam/pycam/: Failed&lt;/li&gt;&lt;li&gt;pycam-read-only/c-vs-py/c_examples: Okay&lt;/li&gt;&lt;li&gt;pycam-read-only/c-vs-py/py_examples: Some codes showed errors. They are harris_opencv.py,&amp;nbsp;objectDetect.py, and people_only.py.&lt;/li&gt;&lt;/ol&gt;---&lt;br /&gt;EDIT: New results are given in the new post:&lt;br /&gt;&lt;a href="http://hiankun.blogspot.com/2011/03/trials-of-pycam-example-code-2.html"&gt;Trials of pycam example code (2)&lt;/a&gt;&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2163947680894830942?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2163947680894830942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2163947680894830942' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2163947680894830942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2163947680894830942'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/01/trials-of-pycam-example-code.html' title='Trials of pycam example code'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3210604653492271411</id><published>2011-01-25T11:46:00.014+08:00</published><updated>2011-01-26T09:42:28.475+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pattern recognition'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='opencv'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Face detection-- code patch and tests with some drawings</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushBash.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;My colleague introduced me &lt;a href="http://opencv.jp/"&gt;an OpenCV site in Japanese&lt;/a&gt; in which many sample codes are available. Most of the sample codes are written in C++, and some are converted to Python also. I copied one &lt;a href="http://opencv.jp/sample/object_detection.html#face_detection"&gt;sample code&lt;/a&gt;, which is used for face detection.&lt;br /&gt;&lt;br /&gt;After testing, I found the sample code has two lines which have to be modified to run properly. The first one seems to be a typo. &lt;s&gt;The variable named as ``storage1'' should be ``storage'' according to other lines of code.&lt;/s&gt;&amp;nbsp;The 25th line with variable ``starage1'' should be deleted. Another modification is to change assign the path of Haar-cascade xml files [*] explicitly. The original code gives the xml file without the complete path, and the program cannot find the so-called ``haarcascade_frontalface_default.xml.''&lt;br /&gt;&lt;br /&gt;The patch file:&lt;br /&gt;&lt;pre class="brush:bash"&gt;@@ -22,9 +22,8 @@&lt;br /&gt;                 sys.exit(-1)&lt;br /&gt;         src_gray = cvCreateImage(cvSize(src_img.width, src_img.height), IPL_DEPTH_8U, 1)&lt;br /&gt; &lt;br /&gt;-        storage1 = cvCreateMemStorage(0)&lt;br /&gt;         ## (2)ブーストされた分類器のカスケードを読み込む&lt;br /&gt;-        cascade_name = "haarcascade_frontalface_default.xml"&lt;br /&gt;+        cascade_name = "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml"&lt;br /&gt;         cascade = cvLoadHaarClassifierCascade(cascade_name, cvSize(1,1))&lt;br /&gt; &lt;br /&gt;         ## (3)メモリを確保し，読み込んだ画像のグレースケール化，ヒストグラムの均一化を行う&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Here I tested the sample code with some of my drawings, which can be viewed on &lt;a href="http://angatou.blogspot.com/"&gt;my another blog&lt;/a&gt;. The results are interesting (at least for me).&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v3Y2M03I/AAAAAAAAAbs/qK2Zi3cIZEk/s1600/face_detect_001.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v3Y2M03I/AAAAAAAAAbs/qK2Zi3cIZEk/s320/face_detect_001.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_a9TRcneUCJM/TT5v5tPChvI/AAAAAAAAAbw/7twHjoEPZv0/s1600/face_detect_002.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/_a9TRcneUCJM/TT5v5tPChvI/AAAAAAAAAbw/7twHjoEPZv0/s320/face_detect_002.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_a9TRcneUCJM/TT5v7XpCTCI/AAAAAAAAAb0/BUS1Fx-PzRI/s1600/face_detect_003.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_a9TRcneUCJM/TT5v7XpCTCI/AAAAAAAAAb0/BUS1Fx-PzRI/s320/face_detect_003.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v8ngNm-I/AAAAAAAAAb4/taGqtBQ5uBs/s1600/face_detect_004.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v8ngNm-I/AAAAAAAAAb4/taGqtBQ5uBs/s320/face_detect_004.jpg" width="256" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v-pYwbsI/AAAAAAAAAb8/MEHiC4AdDNs/s1600/face_detect_005.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v-pYwbsI/AAAAAAAAAb8/MEHiC4AdDNs/s320/face_detect_005.jpg" width="240" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_a9TRcneUCJM/TT5wAdnj9AI/AAAAAAAAAcA/AKw0M2cNMEo/s1600/face_detect_006.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://3.bp.blogspot.com/_a9TRcneUCJM/TT5wAdnj9AI/AAAAAAAAAcA/AKw0M2cNMEo/s320/face_detect_006.jpg" width="240" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_a9TRcneUCJM/TT5wC6Kdo-I/AAAAAAAAAcE/5KTwm6ERMWU/s1600/face_detect_007.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/_a9TRcneUCJM/TT5wC6Kdo-I/AAAAAAAAAcE/5KTwm6ERMWU/s320/face_detect_007.jpg" width="211" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5wEk0BZkI/AAAAAAAAAcI/gN_Ax3J7pVU/s1600/face_detect_008.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TT5wEk0BZkI/AAAAAAAAAcI/gN_Ax3J7pVU/s320/face_detect_008.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;[*] I have just begun to learn things about computer vision, so I might use some terms wrong.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3210604653492271411?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3210604653492271411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3210604653492271411' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3210604653492271411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3210604653492271411'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/01/face-detection-code-patch-and-tests.html' title='Face detection-- code patch and tests with some drawings'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_a9TRcneUCJM/TT5v3Y2M03I/AAAAAAAAAbs/qK2Zi3cIZEk/s72-c/face_detect_001.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4601939931874376273</id><published>2011-01-13T14:00:00.040+08:00</published><updated>2011-01-26T09:40:56.136+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='signal processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Spline function test</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;To interpolate data points, Scipy has several modules for this work. For what I am interested in, there are two functions seem to meet my requirement:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.UnivariateSpline.html"&gt;scipy.interpolate.UnivariateSpline&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.InterpolatedUnivariateSpline.html"&gt;scipy.interpolate.InterpolatedUnivariateSpline&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;According to the explanations given by the above links, to use UnivariateSpline with s=1 is equivalent to use InterpolatedUnivariateSpline.&lt;br /&gt;&lt;br /&gt;Here is the results of a simple test:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/TS6U1lrH13I/AAAAAAAAAa8/x_OIwa88jss/s1600/spline_test.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TS6U1lrH13I/AAAAAAAAAa8/x_OIwa88jss/s400/spline_test.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Code:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:py"&gt;from numpy import linspace,exp&lt;br /&gt;from numpy.random import randn&lt;br /&gt;from scipy.interpolate import UnivariateSpline, InterpolatedUnivariateSpline&lt;br /&gt;from pylab import plot, legend, show&lt;br /&gt;&lt;br /&gt;x = linspace(-3, 3, 100)&lt;br /&gt;y = exp(-x**2) + randn(100)/10&lt;br /&gt;&lt;br /&gt;s0 = UnivariateSpline(x, y, s=0)&lt;br /&gt;s1 = UnivariateSpline(x, y, s=1)&lt;br /&gt;s2 = InterpolatedUnivariateSpline(x, y)&lt;br /&gt;&lt;br /&gt;xs = linspace(-3, 3, 1000)&lt;br /&gt;ys0 = s0(xs)&lt;br /&gt;ys1 = s1(xs)&lt;br /&gt;ys2 = s2(xs)&lt;br /&gt;&lt;br /&gt;plot(xs,ys0,'g--',label='UnivariateSpline s=0',linewidth=4)&lt;br /&gt;plot(xs,ys1,'b',label='UnivariateSpline s=1')&lt;br /&gt;plot(xs,ys2,'k',label='InterpolatedUnivariateSpline')&lt;br /&gt;plot(x,y,'ro',label='original signal')&lt;br /&gt;legend()&lt;br /&gt;show()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.config.bloggerMode = true;     SyntaxHighlighter.all()&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4601939931874376273?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4601939931874376273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4601939931874376273' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4601939931874376273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4601939931874376273'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/01/py-spline-function-test.html' title='[Py] Spline function test'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_a9TRcneUCJM/TS6U1lrH13I/AAAAAAAAAa8/x_OIwa88jss/s72-c/spline_test.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8402792756634407941</id><published>2011-01-05T15:39:00.004+08:00</published><updated>2011-01-26T09:41:56.752+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='signal processing'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Producing sinusoidal signals</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushPython.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;br /&gt;Sometimes I need a signal of different frequencies for testing, so I wrote a simple Python code to produce compound sinusoidal signal by adding several cosine waves of different frequencies, amplitudes, and phases.&lt;br /&gt;&lt;br /&gt;The code is listed as the follows. (&lt;a href="https://docs.google.com/leaf?id=0B5Qdmp5TIyJVYmRmMDY0NWQtZWNjMi00N2IzLWJkNzAtM2M4MzM1NTBmZDJi&amp;amp;sort=name&amp;amp;layout=list&amp;amp;num=50"&gt;download&lt;/a&gt;)&lt;br /&gt;&lt;pre class="brush:py"&gt;from scipy import *&lt;br /&gt;from pylab import *&lt;br /&gt;&lt;br /&gt;data_size = 10 # number of sinusoidal waves&lt;br /&gt;&lt;br /&gt;A = rand(data_size)&lt;br /&gt;theta = rand(data_size)&lt;br /&gt;f = [i for i in range(1,data_size+1)]&lt;br /&gt;t = linspace(0,10,1024)&lt;br /&gt;&lt;br /&gt;y = [0.0 for i in range(len(t))]&lt;br /&gt;&lt;br /&gt;for i in range(data_size):&lt;br /&gt;        y += A[i]*cos(2*pi*f[i]*t + theta[i])&lt;br /&gt;&lt;br /&gt;plot(t,y)&lt;br /&gt;show()&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8402792756634407941?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8402792756634407941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8402792756634407941' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8402792756634407941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8402792756634407941'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/01/producing-sinusoidal-signals.html' title='Producing sinusoidal signals'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6549105328018489328</id><published>2011-01-05T15:21:00.005+08:00</published><updated>2011-01-26T09:41:31.054+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='signal processing'/><category scheme='http://www.blogger.com/atom/ns#' term='EMD'/><category scheme='http://www.blogger.com/atom/ns#' term='C/C++'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Trials of EMD C code</title><content type='html'>&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;&lt;link href="https://sites.google.com/site/hiankun/home/syntaxhighlighter/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;I found a simple module of &lt;a href="http://en.wikipedia.org/wiki/Hilbert%E2%80%93Huang_transform#The_empirical_mode_decomposition_.28EMD.29"&gt;EMD&lt;/a&gt; in C on google code: &lt;a href="http://code.google.com/p/realtime-emd/"&gt;realtime-emd&lt;/a&gt;. The source code, however, has no main function to invoke the modules. So I wrote one as the follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:cpp"&gt;#include &amp;lt;stdio&gt;&lt;br /&gt;#include "EmpiricalModeDecomposition.h"&lt;br /&gt;&lt;br /&gt;void imfs_output(emdData* emd){&lt;br /&gt;        int i, j;&lt;br /&gt;&lt;br /&gt;        for(j = 0; j &lt; emd-&gt;size; j++){&lt;br /&gt;                for(i = 0; i &lt; emd-&gt;order; i++) {&lt;br /&gt;                        printf("%f ", emd-&gt;imfs[i][j]);&lt;br /&gt;                }   &lt;br /&gt;                printf("\n");&lt;br /&gt;        }   &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(void){&lt;br /&gt;        FILE *inputfile = fopen("sinusoid.txt","r");&lt;br /&gt;        int i=0;&lt;br /&gt;        float signal[1024]={0.0};&lt;br /&gt;        emdData data;&lt;br /&gt;&lt;br /&gt;        while (fscanf(inputfile, "%f", &amp;signal[i]) != EOF){&lt;br /&gt;                //printf("%d %f\n",i,signal[i]);&lt;br /&gt;                i++;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        emdCreate(&amp;data,i,5,10,0); // problems here&lt;br /&gt;        emdDecompose(&amp;data,signal);&lt;br /&gt;        imfs_output(&amp;data);&lt;br /&gt;        emdClear(&amp;data);&lt;br /&gt;&lt;br /&gt;        fclose(inputfile);&lt;br /&gt;        return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;script type="text/javascript"&gt;     SyntaxHighlighter.all()&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;The main problem is the arguments of the function emdCreate. I am not sure how to set proper parameters to obtain correct results, so please take this clip of code as just a reference.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can download the &lt;a href="https://docs.google.com/leaf?id=0B5Qdmp5TIyJVZDZiMDFkMGYtYjUwMS00OTEzLTkwNjgtOTY2NWQxYmY1MjQ5&amp;amp;sort=name&amp;amp;layout=list&amp;amp;num=50"&gt;main.c&lt;/a&gt; and &lt;a href="https://docs.google.com/leaf?id=0B5Qdmp5TIyJVYmRmMDY0NWQtZWNjMi00N2IzLWJkNzAtM2M4MzM1NTBmZDJi&amp;amp;sort=name&amp;amp;layout=list&amp;amp;num=50"&gt;sinusoid.txt&lt;/a&gt; for testing.&amp;nbsp;The input file sinusoid.txt was generate by adding several sinusoidal signals.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6549105328018489328?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6549105328018489328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6549105328018489328' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6549105328018489328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6549105328018489328'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2011/01/trials-of-emd-c-code.html' title='Trials of EMD C code'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-1212374171842768564</id><published>2010-12-30T16:43:00.000+08:00</published><updated>2010-12-30T16:43:41.559+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='pyode'/><category scheme='http://www.blogger.com/atom/ns#' term='opengl'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>[QnA] GL/gl.h and GL/glu.h in Ubuntu 10.04</title><content type='html'>I have installed &lt;a href="http://pyode.sourceforge.net/"&gt;PyODE&lt;/a&gt; and tried some examples&amp;nbsp;&lt;a href="http://hiankun.blogspot.com/2010/05/py-pyode-installation-and-test.html"&gt;once&lt;/a&gt; when my system was Ubuntu 8.04. Today I think about the PyODE examples and want to study them again. Because my system is Ubuntu 10.04 now, I have to rebuild some necessary environment.&lt;br /&gt;&lt;br /&gt;The most tedious step is to install the &lt;a href="http://cgkit.sourceforge.net/introduction.html"&gt;cgkit&lt;/a&gt;. It has to be installed from the source. During the installation, some more packages or libraries are necessary. Two of them are GL/gl.h and GL/glu.h. Out of my expectation, they have to be installed from different packages.&lt;br /&gt;&lt;br /&gt;To have GL/gl.h:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$ sudo apt-get install mesa-common-dev&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;To have GL/glu.h:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;$&amp;nbsp;sudo apt-get install libglu1-mesa-dev&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-1212374171842768564?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/1212374171842768564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=1212374171842768564' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1212374171842768564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1212374171842768564'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/12/qna-glglh-and-glgluh-in-ubuntu-1004.html' title='[QnA] GL/gl.h and GL/glu.h in Ubuntu 10.04'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-207171749671475556</id><published>2010-12-22T15:57:00.005+08:00</published><updated>2010-12-31T23:48:25.974+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scipy'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='data processing'/><title type='text'>[DP] Window functions trial</title><content type='html'>I am studying the windowed-sinc filters and found &lt;a href="http://www.scipy.org/"&gt;SciPy&lt;/a&gt; has had a set of window functions to play around.&lt;br /&gt;&lt;br /&gt;Below is my code to generate the plot of several window functions. Note that only 12 of them have been shown. There are four of them need more than one argument and I don't have time to figure out their parameters to get corresponding results.&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from scipy import signal&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;from pylab import *&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;data_point = 500&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;windows =\&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;['boxcar'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'triang'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'parzen'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'bohman'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'blackman'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'blackmanharris'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'nuttall'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'flattop'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'bartlett'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'hann'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'barthann'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;, 'hamming'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#, 'kaiser'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#, 'gaussian'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#, 'general_gaussian'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;#, 'slepian'&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;t = [i for i in range(data_point)]&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;steps = 3&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;for i in range(0,len(windows),steps):&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for j in range(i,i+steps):&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;w = eval('signal.'+windows[j])(data_point)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;subplot(2,2,1+i/steps)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;plot(t, w)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;axis([0,data_point,-0.2,1.2])&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;legend((windows[i:i+steps]),loc='upper left')&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;show()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;The result:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_a9TRcneUCJM/TRGt_YQvaCI/AAAAAAAAAaU/MnR_lfQd83o/s1600/signal_windows.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="314" src="http://4.bp.blogspot.com/_a9TRcneUCJM/TRGt_YQvaCI/AAAAAAAAAaU/MnR_lfQd83o/s640/signal_windows.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Basically, the window functions return an array which has the size as you assigned. An easy example is as the following:&lt;br /&gt;&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; from scipy import signal&lt;br /&gt;&amp;gt;&amp;gt;&amp;gt; signal.blackman(50)&lt;br /&gt;array([ -1.38777878e-17, &amp;nbsp; 1.48858213e-03, &amp;nbsp; 6.05806481e-03,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.40095693e-02, &amp;nbsp; 2.58120534e-02, &amp;nbsp; 4.20553960e-02,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6.33894512e-02, &amp;nbsp; 9.04534244e-02, &amp;nbsp; 1.23800653e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.63824257e-01, &amp;nbsp; 2.10689158e-01, &amp;nbsp; 2.64275593e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.24138580e-01, &amp;nbsp; 3.89486780e-01, &amp;nbsp; 4.59182958e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5.31766851e-01, &amp;nbsp; 6.05499812e-01, &amp;nbsp; 6.78429126e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7.48468603e-01, &amp;nbsp; 8.13490971e-01, &amp;nbsp; 8.71426720e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.20363618e-01, &amp;nbsp; 9.58640963e-01, &amp;nbsp; 9.84932919e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.98315897e-01, &amp;nbsp; 9.98315897e-01, &amp;nbsp; 9.84932919e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.58640963e-01, &amp;nbsp; 9.20363618e-01, &amp;nbsp; 8.71426720e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8.13490971e-01, &amp;nbsp; 7.48468603e-01, &amp;nbsp; 6.78429126e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6.05499812e-01, &amp;nbsp; 5.31766851e-01, &amp;nbsp; 4.59182958e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.89486780e-01, &amp;nbsp; 3.24138580e-01, &amp;nbsp; 2.64275593e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.10689158e-01, &amp;nbsp; 1.63824257e-01, &amp;nbsp; 1.23800653e-01,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9.04534244e-02, &amp;nbsp; 6.33894512e-02, &amp;nbsp; 4.20553960e-02,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.58120534e-02, &amp;nbsp; 1.40095693e-02, &amp;nbsp; 6.05806481e-03,&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1.48858213e-03, &amp;nbsp;-1.38777878e-17])&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;You can find the source code containing these window functions in the SciPy folder. Mine is located in&amp;nbsp;/usr/lib/python2.6/dist-packages/scipy/signal/signaltools.py&lt;/li&gt;&lt;li&gt;Documents can be found at&amp;nbsp;&lt;a href="http://docs.scipy.org/doc/scipy/reference/signal.html"&gt;http://docs.scipy.org/doc/scipy/reference/signal.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt;There is a good book about the signal processing for engineers by Steven W. Smith:&lt;a href="http://www.dspguide.com/"&gt;&amp;nbsp;The Scientist and Engineer's Guide to Digital Signal Processing&lt;/a&gt;. The windowed-sinc filters are introduced in &lt;a href="http://www.dspguide.com/ch16/1.htm"&gt;Chapter 16&lt;/a&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-207171749671475556?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/207171749671475556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=207171749671475556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/207171749671475556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/207171749671475556'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/12/dp-window-functions-trial.html' title='[DP] Window functions trial'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_a9TRcneUCJM/TRGt_YQvaCI/AAAAAAAAAaU/MnR_lfQd83o/s72-c/signal_windows.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5110463590069776654</id><published>2010-12-22T09:55:00.003+08:00</published><updated>2010-12-22T10:01:30.292+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Machine Learning'/><category scheme='http://www.blogger.com/atom/ns#' term='Maximum Likelihood Estimation'/><title type='text'>[ML] Pretty good tutorial for MLE</title><content type='html'>What is Maximum Likelihood Estimation (MLE) exactly? This question has bothered me for a long time. When I was reading papers relevant to ICA, the term MLE appeared again. This time, fortunately, I found a really good tutorial in Wikipedia:&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://statgen.iop.kcl.ac.uk/bgim/mle/sslike_1.html"&gt;Maximum Likelihood Estimation, by S. Purcell.&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The first three parts introduce the most fundamental ideas about MLE, and I suggest you, who want to figure out what is MLE, to read these three parts.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In the next three parts, however, some terms and examples seem come from the biology or genetic aspect. If you get confused with the technical words used in ``twin data'', the ``&lt;a href="http://en.wikipedia.org/wiki/Twin_study"&gt;twin study&lt;/a&gt;'' item given by Wikipedia might help you.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So far, I've had more clear idea about the difference between the probability and the likelihood estimation, which can be&amp;nbsp;summarized&amp;nbsp;as:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Probability&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Knowing parameters: Prediction of outcome&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Likelihood&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Observation of data: Estimation of parameters&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;There still are some concepts I have not quite known yet, such as the ideas presented in the section of ``&lt;a href="http://statgen.iop.kcl.ac.uk/bgim/mle/sslike_5.html"&gt;Likelihood ratio test&lt;/a&gt;.''&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5110463590069776654?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5110463590069776654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5110463590069776654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5110463590069776654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5110463590069776654'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/12/ml-pretty-good-tutorial-for-mle.html' title='[ML] Pretty good tutorial for MLE'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5293012208924043249</id><published>2010-12-15T11:14:00.003+08:00</published><updated>2010-12-15T11:20:57.082+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Inkscape'/><category scheme='http://www.blogger.com/atom/ns#' term='LaTeX'/><title type='text'>[SW] Installation of the LaTeX formula extension in Inkscape 4.07</title><content type='html'>First, the ``Effects'' item has been renamed as ``Extensions'' in Inkscape 4.07.&lt;br /&gt;&lt;br /&gt;Then what you need are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;pdflatex: To have it, you have to install texlive-latex-base package (I am not sure about this).&lt;/li&gt;&lt;li&gt;pdf2svg&lt;/li&gt;&lt;li&gt;textext: You can download suitable version at&amp;nbsp;&lt;a href="http://pav.iki.fi/software/textext/index.html"&gt;http://pav.iki.fi/software/textext/index.html&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;To install the textext package, just copy the textext.py and textext.inx files to the folder:&lt;br /&gt;~/.config/inkscape/extensions/&lt;br /&gt;&lt;br /&gt;Finally, restart your Inkscape and try it. Note the LaTeX formula might appear in some place beyond your working window, so make sure to zoom out your working area and look around for your formula.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5293012208924043249?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5293012208924043249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5293012208924043249' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5293012208924043249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5293012208924043249'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/12/sw-installation-of-latex-formula.html' title='[SW] Installation of the LaTeX formula extension in Inkscape 4.07'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5103533519544338220</id><published>2010-12-13T09:00:00.000+08:00</published><updated>2010-12-13T09:00:21.369+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ethernet'/><category scheme='http://www.blogger.com/atom/ns#' term='network setting'/><title type='text'>[QnA] eth0 disappeared...</title><content type='html'>I have no idea why this could happened, yet. My Toshiba laptop lost its eth0 again, and this time I was very sure that the driver had been installed properly.&lt;br /&gt;&lt;br /&gt;Again, I found the following posts which solved my problem:&lt;br /&gt;&lt;a href="http://ubuntuforums.org/showthread.php?t=1459907"&gt;http://ubuntuforums.org/showthread.php?t=1459907&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just edit ``/etc/NetworkManager/nm-system-settings.conf'' and let ``managed=true'':&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5103533519544338220?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5103533519544338220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5103533519544338220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5103533519544338220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5103533519544338220'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/12/qna-eth0-disappeared.html' title='[QnA] eth0 disappeared...'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2735186119520291187</id><published>2010-11-04T10:34:00.005+08:00</published><updated>2010-11-04T10:44:59.633+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>Floating calculation in bash (with formatted output)</title><content type='html'>What I wanted was to get a list of incremental floating numbers, like:&lt;br /&gt;0.0 0.2 0.4 0.6 ... 2.0&lt;br /&gt;&lt;br /&gt;It is possible to accomplish this mission in bash, with the help of &lt;a href="http://linux.about.com/od/commands/l/blcmdl1_bc.htm"&gt;bc&lt;/a&gt;. My own script is listed below:&lt;br /&gt;&lt;blockquote&gt;#!/bin/bash&lt;br /&gt;for i in {0..20..2}&lt;br /&gt;    do&lt;br /&gt;        #f=$(printf %3.1f `echo "scale=1; $i/10" | bc`) # old version&lt;br /&gt;        printf -v f %3.1f `echo "scale=1; $i/10" | bc`  # new version&lt;br /&gt;        echo $f&lt;br /&gt;    done&lt;/blockquote&gt;&lt;br /&gt;The bc command was used because bash cannot handle floating calculation directly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2735186119520291187?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2735186119520291187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2735186119520291187' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2735186119520291187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2735186119520291187'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/11/floating-calculation-in-bash-with.html' title='Floating calculation in bash (with formatted output)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8895916040903324233</id><published>2010-10-24T21:44:00.004+08:00</published><updated>2010-10-24T22:17:51.300+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ethernet'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='driver'/><title type='text'>[QnA] Activate the ethernet card of Toshiba L600 laptop (for Ubuntu 10.04)</title><content type='html'>I've bought a laptop (Toshiba Satellite L600) several days ago. Everything seems alright when I inserted the Live CD of Ubuntu 10.04 to play example audio and video files. So I installed Ubuntu 10.04 in my new laptop. After the installation, I tried to connect to the Internet for system upgrade and found the pppoeconf complained with ``no Ethernet card'' messages.&lt;br /&gt;&lt;br /&gt;From the searched results and based on my own incomplete test, here are the steps to activate the Ethernet card of the Toshiba Satellite L600:&lt;br /&gt;&lt;br /&gt;Step 1: Check the type of card.&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family: courier new;"&gt;$ lspci | grep Ethernet&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;04:00.0 Ethernet controller: Atheros Communications AR8152 v1.1 Fast Ethernet (rev c1)&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Step 2: Use the keyword of the card to search the driver. What I found is &lt;a href="http://partner.atheros.com/Drivers.aspx"&gt;AR81Family-linux-v1.0.1.13.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Step 3: Untar the downloaded files and install the driver.&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family: courier new;"&gt;$ make&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo make install&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ cd src/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo cp atl1e.ko /lib/modules/2.6.32-21-generic/kernel/drivers/net/atlx/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo depmod -a&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Step 4: Reboot the system then go for pppoeconf to set up the DSL connection.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8895916040903324233?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8895916040903324233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8895916040903324233' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8895916040903324233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8895916040903324233'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/10/qna-activate-ethernet-card-of-toshiba.html' title='[QnA] Activate the ethernet card of Toshiba L600 laptop (for Ubuntu 10.04)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2415889810107089086</id><published>2010-10-14T15:21:00.001+08:00</published><updated>2010-10-14T15:36:04.808+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='list'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Assign values of one list to another</title><content type='html'>It is easy to ``copy'' lists in Python, but it is also easy to get things wrong, especially when you ignore something important like what I did.&lt;br /&gt;&lt;br /&gt;Consider the following situation:&lt;br /&gt;&lt;blockquote style="font-family: courier new;"&gt;&gt;&gt;&gt; A = [1,2,3]&lt;br /&gt;&gt;&gt;&gt; B = A&lt;br /&gt;&gt;&gt;&gt; B[0]=-1&lt;br /&gt;&gt;&gt;&gt; A&lt;br /&gt;[-1, 2, 3]&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;What I want is to create a new list B which contains identical elements of the original list A. This doesn't work, however. As you can see in the above test, any modifications made on list B will affect list A. The reason is that when we type ``B=A'', the list B is just another name of list A. They are identical and of course are pointed to the same address. See the following tests:&lt;br /&gt;&lt;br /&gt;&lt;blockquote style="font-family: courier new;"&gt;&gt;&gt;&gt; B is A&lt;br /&gt;True&lt;br /&gt;&gt;&gt;&gt; B.index, A.index&lt;br /&gt;(&lt;built-in&gt;, &lt;built-in&gt;)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So, if we need an independent list B which has a set of values' copy in list A, use ``list slicing'':&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; B = A&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;[:]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; B is A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&gt;&gt;&gt; B.index, A.index&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;(&lt;built-in&gt;, &lt;built-in&gt;)&lt;/span&gt;&lt;/blockquote&gt;---&lt;br /&gt;Ref: &lt;a href="http://effbot.org/zone/python-list.htm"&gt;An Introduction to Python Lists&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2415889810107089086?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2415889810107089086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2415889810107089086' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2415889810107089086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2415889810107089086'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/10/py-assign-values-of-one-list-to-another.html' title='[Py] Assign values of one list to another'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7273301757082338445</id><published>2010-10-14T10:24:00.005+08:00</published><updated>2010-10-14T15:38:58.359+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='list'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Be careful when create multi-dimensional lists</title><content type='html'>I wrote &lt;a href="http://hiankun.blogspot.com/2010/05/py-multi-dimensional-list.html"&gt;a note&lt;/a&gt; about the creation of multi-dimensional lists in Python, when I had not yet encountered another problem which have emerged recently. The problem is about appending items to the multi-dimensional lists.&lt;br /&gt;&lt;br /&gt;Consider the following example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;A = [[]]*3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[], [], []]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; for i in range(3):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j in range(3):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A[i].append(i+j)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;... &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[0, 1, 2, 1, 2, 3, 2, 3, 4], [0, 1, 2, 1, 2, 3, 2, 3, 4], [0, 1, 2, 1, 2, 3, 2, 3, 4]]&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;But what I really want is something like&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;A = [[0, 1, 2], [1, 2, 3], [2, 3, 4]]&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;My guess is that the creation approach doesn't create a list which contains three independent rows, but just create three rows which actually point to the same address or something like that.&lt;br /&gt;&lt;br /&gt;The solution (perhaps not the best one) is to create the rows in the form of list comprehension:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; &lt;span style="color: rgb(102, 0, 204);"&gt;A = [[] for rows in range(3)]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[], [], []]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; for i in range(3):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for j in range(3):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A[i].append(i+j)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;... &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; A&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[0, 1, 2], [1, 2, 3], [2, 3, 4]]&lt;/span&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7273301757082338445?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7273301757082338445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7273301757082338445' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7273301757082338445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7273301757082338445'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/10/py-be-careful-when-create-multi.html' title='[Py] Be careful when create multi-dimensional lists'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2403889786777094697</id><published>2010-10-01T08:51:00.003+08:00</published><updated>2010-10-01T09:05:17.239+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>[QnA] Change the permission of viminfo to enable the command histroy of Vim</title><content type='html'>After upgrading from Ubuntu 8.04 to 10.04, I found the command history of Vim was missing. The reason is simple: in Ubuntu 10.04, the ~/.viminfo file has a 600 permission so only the root can access it.&lt;br /&gt;&lt;br /&gt;To get the command history of vim back, you may change the permission from 600 to 666. I don't know whether this change has any side effects, however. At least for only one user using one computer, this is a quick trick. :-)&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="https://bugs.launchpad.net/ubuntu/+source/vim/+bug/189238"&gt;command history is missing from vim&lt;/a&gt;&lt;/li&gt;&lt;li&gt;(You could use `:help viminfo' in Vim to know more about the viminfo file)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2403889786777094697?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2403889786777094697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2403889786777094697' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2403889786777094697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2403889786777094697'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/10/qna-change-permission-of-viminfo-to.html' title='[QnA] Change the permission of viminfo to enable the command histroy of Vim'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8957433975246059284</id><published>2010-09-30T08:37:00.002+08:00</published><updated>2010-09-30T08:59:49.332+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='framebuffer'/><category scheme='http://www.blogger.com/atom/ns#' term='fbi'/><category scheme='http://www.blogger.com/atom/ns#' term='tty'/><category scheme='http://www.blogger.com/atom/ns#' term='fbgs'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='console'/><title type='text'>[QnA] Problems when using fbi/fbgs in virtual consoles of Ubuntu 10.04 (Lucid Lynx)</title><content type='html'>I upgraded all my computers (2 PCs and 1 laptop) from Ubuntu 8.04 to 10.04 these days. Most things are fine (and even great!), but there is one thing, the &lt;a href="https://help.ubuntu.com/community/Grub2"&gt;GRUB 2&lt;/a&gt;,t has brought me some troubles. I could not use &lt;a href="http://linux.bytesex.org/fbida/"&gt;fbi and fbgs&lt;/a&gt; in the consoles. Of course I ran into Google several times but got no lucks, until yesterday when I found the following thread and links:&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.linuxquestions.org/questions/linux-desktop-74/tty-1-6-not-functional-in-ubuntu-10-04-lts-813179/"&gt;TTY 1-6 not functional in Ubuntu 10.04 LTS&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://crunchbanglinux.org/forums/topic/8883/how-to-fix-tty16-ctrlaltfx-terminals-if-they-are-not-working/"&gt;How to fix tty1-6 (Ctrl+Alt+Fx terminals) if they are not working&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;The second link gives a complete guide.&lt;br /&gt;&lt;br /&gt;FYI: To check the resolution given by &lt;a href="http://tldp.org/HOWTO/Framebuffer-HOWTO/"&gt;framebuffer&lt;/a&gt; of your computer, use ``sudo hwinfo --framebuffer'' command in the console.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8957433975246059284?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8957433975246059284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8957433975246059284' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8957433975246059284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8957433975246059284'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/09/qna-problems-when-using-fbifbgs-in.html' title='[QnA] Problems when using fbi/fbgs in virtual consoles of Ubuntu 10.04 (Lucid Lynx)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-1717146515741554515</id><published>2010-09-19T08:55:00.004+08:00</published><updated>2010-09-19T09:38:47.012+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GIMP'/><title type='text'>[SW] Use GIMP to save layers of animated GIF</title><content type='html'>It is easy to use &lt;a href="http://www.gimp.org/"&gt;GIMP&lt;/a&gt; to create animation in &lt;a href="http://en.wikipedia.org/wiki/Graphics_Interchange_Format"&gt;GIF&lt;/a&gt; format (just use Google and you can find many examples). However, to extract individual layers of an animated GIF  is another story, and I can't find a straightforward approach in GIMP.&lt;br /&gt;&lt;br /&gt;Fortunately, the solution has been exist. There is &lt;a href="http://registry.gimp.org/node/15617#comment-2911"&gt;a script by &lt;/a&gt;&lt;span class="submitted"&gt;&lt;a href="http://registry.gimp.org/node/15617#comment-2911"&gt;saulgoode&lt;/a&gt;*. After downloading the script, save it into your .gimp/script directory, then run GIMP. You will find the added function in ``File --&gt; Save all layers...''. Note there is no option for you to choose the saving directory, and all the saved layers (the default format is PNG) will be in the working path of GIMP.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;*Here is &lt;a href="http://www.youtube.com/watch?v=nz4UdyeMpzA"&gt;a tutorial video&lt;/a&gt; to show the usage of the script, but I don't know whether the video uploader is the one who write the script.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-1717146515741554515?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/1717146515741554515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=1717146515741554515' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1717146515741554515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1717146515741554515'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/09/sw-use-gimp-to-se.html' title='[SW] Use GIMP to save layers of animated GIF'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-1417580746699019682</id><published>2010-09-06T22:04:00.003+08:00</published><updated>2010-09-06T22:23:30.534+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='rubik&apos;s cube'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Rubik's cube game</title><content type='html'>Although I am not good at solving &lt;a href="http://en.wikipedia.org/wiki/Rubik%27s_Cube"&gt;Rubik's Cube&lt;/a&gt;, I am a fan of it. Of course, I am always wondering whether there are programs which can show a 3D Rubik's Cube in my computer so that I can play the cube interactively. And the answer is YES!&lt;br /&gt;&lt;br /&gt;On &lt;a href="http://www.pygame.org/news.html"&gt;Pygame site&lt;/a&gt;, there is a wonderful program called &lt;a href="http://www.pygame.org/project-Rubik%27s+Cube+Game-932-.html"&gt;Rubik's Cube Game&lt;/a&gt; meets all my needs. Actually, I've downloaded and tested it several months ago, but until today I finally get clear steps to make the program run properly. My modifications are as follows.&lt;br /&gt;&lt;ol style="font-family: courier new;"&gt;&lt;li&gt;rename Images/*.PNG to Images/*.png&lt;/li&gt;&lt;li&gt;apt-get install python-opengl&lt;/li&gt;&lt;li&gt;download &lt;a href="http://code.google.com/p/gameobjects/"&gt;gameobjects&lt;/a&gt; and install it&lt;/li&gt;&lt;li&gt;remove *.pyc&lt;/li&gt;&lt;li&gt;rename *.pyw to *.py&lt;/li&gt;&lt;li&gt;run ``python Rubik's Cube.py''&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-1417580746699019682?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/1417580746699019682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=1417580746699019682' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1417580746699019682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1417580746699019682'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/09/py-rubiks-cube-game.html' title='[Py] Rubik&apos;s cube game'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2739902692713372973</id><published>2010-09-02T09:10:00.007+08:00</published><updated>2010-09-02T09:33:12.227+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='sed'/><title type='text'>Converting filenames from UPPERCASE to lowercase</title><content type='html'>I searched and found the following thread:&lt;br /&gt;&lt;a href="http://blog.mc-thias.org/?title=rename-files-from-upper-case-filename-to&amp;amp;more=1&amp;amp;c=1&amp;amp;tb=1&amp;amp;pb=1"&gt;http://blog.mc-thias.org/?title=rename-files-from-upper-case-filename-to&amp;amp;more=1&amp;amp;c=1&amp;amp;tb=1&amp;amp;pb=1&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Based on the post given by Jadu Saikia, I got the bash script of my own version as follows:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;ls * | sed -e p -e 's/.*/\L&amp;amp;/g' |xargs -n 2 mv&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;One new thing I've learned in this example is the ``\L''  part, which can be found in &lt;a href="http://sed.sourceforge.net/sedfaq4.html#s4.16"&gt;sed's FAQ&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2739902692713372973?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2739902692713372973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2739902692713372973' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2739902692713372973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2739902692713372973'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/09/converting-filenames-from-uppercase-to.html' title='Converting filenames from UPPERCASE to lowercase'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6272496439514916715</id><published>2010-08-04T14:43:00.009+08:00</published><updated>2010-08-04T15:41:28.558+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pygame'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Install pygame-1.9.1 in Ubuntu (with running a game: Cave Copter)</title><content type='html'>I went to &lt;a href="http://www.pygame.org/news.html"&gt;pygame&lt;/a&gt;'s website to see whether there are some very simple examples for me to begin with. After several trials, I found the pygame version of Ubuntu 8.04 was 1.7 and it was too old to run some games, so I decided to install pygame from the source.&lt;br /&gt;&lt;br /&gt;Things were almost easy. Just download and extract the source files and run the setup.py. Some error messages showed up:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;sh: sdl-config: not found&lt;br /&gt;sh: smpeg-config: not found&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It means you need to install the following libraries.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ sudo apt-get install libsdl-dev libsmpeg-dev&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Ran the setup.py again and I got other warning messages as follows.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;FONT : not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;IMAGE : not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;MIXER : not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;PNG : not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;JPEG : not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;PORTMIDI: not found&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;PORTTIME: not found&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What I installed were:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;libjpeg-dev libpng12-dev libportmidi-dev libsdl-ttf2.0-dev libsdl-image1.2-dev libsdl-mixer1.2-dev&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally, ran&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ sudo python setup.py&lt;/span&gt;&lt;br /&gt;and got new version pygame work!&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;After installing pygame-1.9.1, I tried to test the game, &lt;a href="http://www.pygame.org/project-Cave+Copter-1405-.html"&gt;Cave Copter&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Cave Copter is a game using pygame. To make it run properly in Ubuntu, there still some minor works to do.&lt;br /&gt;&lt;br /&gt;First, we need to change all the double backslashes in the original CaveCopter.py to single slash. Second, we have to change the *.PNG to *.png so that these png files can be recognized.&lt;br /&gt;&lt;br /&gt;Hope I will have time to play with and to learn something from the source code...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6272496439514916715?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6272496439514916715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6272496439514916715' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6272496439514916715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6272496439514916715'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/08/py-install-pygame-191-in-ubuntu-with.html' title='[Py] Install pygame-1.9.1 in Ubuntu (with running a game: Cave Copter)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3886717959095047013</id><published>2010-07-01T13:53:00.003+08:00</published><updated>2010-07-01T14:23:34.634+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] pty module testing note</title><content type='html'>The &lt;a href="http://docs.python.org/library/pty.html#module-pty"&gt;pty module&lt;/a&gt; can be used for pseudo terminals, about which I actually know very little.&lt;br /&gt;&lt;br /&gt;Here are some simple tests I have conducted in my own Ubuntu PC, and I write down it just as a reminding note.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Open pseudo terminal pairs&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At the beginning, check the content of /dev/pts:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ ls /dev/pts&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;0  1  ptmx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Open another terminal for IPython and then test with pty module as the following:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [1]: import pty&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [2]: pty.openpty()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;Out[2]: (3, 4)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now check /dev/pts again:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ ls /dev/pts&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;0  1  2  ptmx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Go back to IPython:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [3]: pty.openpty()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;Out[3]: (5, 6)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The content of /dev/pts becomes:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ ls /dev/pts&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;0  1  2  3 ptmx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Exit IPython, then check the /dev/pts:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ ls /dev/pts&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;0  1  ptmx&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Read and Write test&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To read from the pseudo terminal, it seems necessary to write something first.&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [1]: import pty&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [2]: pty.openpty()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;Out[2]: (3, 4)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [3]: pty._writen(3,"test")&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;In [4]: pty._read(3)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;Out[4]: 'test'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/2174071/how-to-use-dev-ptmx-for-create-a-virtual-serial-port"&gt;how to use /dev/ptmx for create a virtual serial port?&lt;/a&gt;&lt;br /&gt;&lt;a href="http://pydoc.org/2.1/pty.html"&gt;Python: module pty&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3886717959095047013?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3886717959095047013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3886717959095047013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3886717959095047013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3886717959095047013'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/07/py-pty-module-testing-note.html' title='[Py] pty module testing note'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3823434085389946012</id><published>2010-06-23T00:11:00.006+08:00</published><updated>2010-06-29T22:04:04.227+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[Py] Work with multiple versions of Python</title><content type='html'>In Ubuntu 8.04, the default version of Python is 2.5, and I want to try Python 2.6 without messing up Python 2.5. I followed &lt;a href="http://www.lysium.de/blog/index.php?/archives/229-Installing-Python-2.6-on-Ubuntu-8.04.html"&gt;Andreas Bernauer's article&lt;/a&gt; but still had problems.&lt;br /&gt;&lt;br /&gt;During the installation process, I found another useful article which gives also clear guidance:&lt;br /&gt;&lt;a href="http://achinghead.com/archive/83/installing-multiple-versions-python/"&gt;Installing multiple versions of Python on Ubuntu from Source&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After installing Python 2.6 successfully, I linked python command to Python 2.6, but got some problems. All the third-part packages (installed in the `site-packages' folder) cannot be seen by Python 2.6. I tried to link the folders but got no luck. Then I noticed the ``&lt;a href="http://pypi.python.org/pypi/setuptools/"&gt;setuptools&lt;/a&gt;''  which claims:&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;Download, build, install, upgrade, and uninstall Python packages -- easily!&lt;/blockquote&gt;Then followed the steps which also given in &lt;a href="http://achinghead.com/archive/83/installing-multiple-versions-python/"&gt;Installing multiple versions of Python on Ubuntu from Source&lt;/a&gt;. Finally, set link to easy_install, for example:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ sudo ln -s /opt/python2.6/bin/easy_install-2.6 /usr/bin/easy_install2.6&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;---&lt;br /&gt;I installed numpy and matplotlib with easy_install:&lt;br /&gt;&lt;blockquote&gt;$ sudo easy_install2.6 numpy&lt;br /&gt;$ sudo easy_install2.6 matplotlib&lt;br /&gt;&lt;/blockquote&gt;The installation of matplotlib got an error message as below:&lt;br /&gt;&lt;blockquote&gt;error: Setup script exited with error: command 'gcc' failed with exit status 1&lt;/blockquote&gt;I followed the method proposed &lt;a href="http://lists.initd.org/pipermail/psycopg/2007-August/005607.html"&gt;here&lt;/a&gt;, and installed ``libpq-dev'' but it didn't work. Then I found &lt;a href="http://old.nabble.com/Error-building-from-source---Ubuntu-td23599549.html"&gt;the solution&lt;/a&gt; which is as follows:&lt;br /&gt;&lt;blockquote&gt;&lt;span&gt;$ sudo apt-get build-dep matplotlib&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;So far, one thing is still bothering me. I have no idea how to let &lt;a href="http://ipython.scipy.org/moin/"&gt;IPython&lt;/a&gt; work with Python 2.6.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3823434085389946012?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3823434085389946012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3823434085389946012' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3823434085389946012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3823434085389946012'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-work-with-multiple-versions-of.html' title='[Py] Work with multiple versions of Python'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6652090567287371871</id><published>2010-06-16T01:05:00.003+08:00</published><updated>2010-06-16T01:24:36.779+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tkinter'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Use lambda expression for callback functions of widgets</title><content type='html'>Let's see a quotation about &lt;a href="http://effbot.org/zone/tkinter-callbacks.htm"&gt;Tkinter callbacks&lt;/a&gt;:&lt;br /&gt;&lt;blockquote style="font-style: italic;"&gt;A common beginner’s mistake is to call the callback function when constructing the widget.  That is, instead of giving just the function’s name (e.g. “callback”), the programmer adds parentheses and argument values to the function&lt;/blockquote&gt;That's true. I just solved one problem of this kind in my code.&lt;br /&gt;&lt;br /&gt;In short, we cannot use callbacks of widgets in the form of&lt;br /&gt;Widget(text="some text",   command=callback(argv)).pack()&lt;br /&gt;&lt;br /&gt;The reason has been stated clearly in the first link of this post. To call the callbacks which have arguments, we need to utilize &lt;a href="http://docs.python.org/reference/expressions.html#lambda"&gt;the lambda expression&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I have tried with 3 test programs. They are listed as follows.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;1. from Tkinter import *&lt;br /&gt;2.&lt;br /&gt;3. def cb_test(i):&lt;br /&gt;4.         print i&lt;br /&gt;5.&lt;br /&gt;6. root = Tk()&lt;br /&gt;7.&lt;br /&gt;8. for i in range(5):&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;9.&lt;/span&gt;         Button(root, text=str(i), &lt;span style="font-weight: bold;"&gt;command=cb_test(i)&lt;/span&gt;).pack()            &lt;span style="color: rgb(0, 153, 0);"&gt;# test 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;9.&lt;/span&gt;         Button(root, text=str(i), &lt;span style="font-weight: bold;"&gt;command=lambda:cb_test(i)&lt;/span&gt;).pack()     &lt;span style="color: rgb(0, 153, 0);"&gt;# test 2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;9.&lt;/span&gt;         Button(root, text=str(i), &lt;span style="font-weight: bold;"&gt;command=lambda x=i:cb_test(x)&lt;/span&gt;).pack() &lt;span style="color: rgb(0, 153, 0);"&gt;# test 3&lt;/span&gt;&lt;br /&gt;10. Button(root, text="Quit", command=root.quit).pack()&lt;br /&gt;11.&lt;br /&gt;12. root.mainloop()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you would like to try with my codes, please note there are 3 lines denoted as line 9. Keep only one of them and delete the other two.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6652090567287371871?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6652090567287371871/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6652090567287371871' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6652090567287371871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6652090567287371871'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-use-lambda-expression-for-callback.html' title='[Py] Use lambda expression for callback functions of widgets'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6665367430272854216</id><published>2010-06-16T00:35:00.005+08:00</published><updated>2010-06-16T01:05:01.206+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Add new attributes as static variables</title><content type='html'>One problem I have met when coding with Python is that there seems no static variables to apply. A straightforward approach is to use the global variables, but it is not such a safe way.&lt;br /&gt;&lt;br /&gt;Several days ago, when I was writing my nth version of my low-pass/high-pass filtering functions, I found a nice method to keep some values of certain variables which would be used in recursive steps. This method is to create new attributes of the called function, and the created attributes could be used as static variables.&lt;br /&gt;&lt;br /&gt;The original information has been given in Ref. and I would like to repeat it again but with my own understanding. The function which have to keep some local variables as static ones could be as follows.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;1. def foo(argv):&lt;br /&gt;2.         if not "your_static_var" in dir(foo):&lt;br /&gt;3.                 foo.your_static_var = certain initial values&lt;br /&gt;4.         do something with foo.your_static_var&lt;br /&gt;5.         return foo.your_static_var&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In line 2, we check all the attributes of foo() by the built-in function &lt;a href="http://docs.python.org/library/functions.html#dir"&gt;dir()&lt;/a&gt;. If foo() is called for the first time, we could create new attributes with initializations as shown in line 3. I think this is the most brilliant part of the method.&lt;br /&gt;&lt;br /&gt;Next time when you need ``local'' static variables for certain functions, this approach may help.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref: (see &lt;a href="http://www.velocityreviews.com/forums/showpost.php?p=1903678&amp;amp;postcount=10"&gt;the post&lt;/a&gt; by Cameron Laird)&lt;br /&gt;&lt;a href="http://www.velocityreviews.com/forums/t361566-static-variables-in-python.html"&gt;Python - Static Variables in Python?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6665367430272854216?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6665367430272854216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6665367430272854216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6665367430272854216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6665367430272854216'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-add-new-attributes-as-static.html' title='[Py] Add new attributes as static variables'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6163831394605222577</id><published>2010-06-13T12:18:00.004+08:00</published><updated>2010-06-13T12:41:41.102+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Firefox'/><title type='text'>[SW] Color toggle -- Firefox plugin to swap foreground and background color</title><content type='html'>Many of us use browsers very often, and maybe some of you just don't like the default white color of many web pages. I don't like either.&lt;br /&gt;&lt;br /&gt;I am used to work and view documents in black background with white fonts color, just like the appearance of command line terminals. So I began to search the method which can help me in reversing my browser's foreground and background colors.&lt;br /&gt;The answer for Firefox is &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/9408/"&gt;Color toggle&lt;/a&gt; by Nathan Baker. Color toggle is a simple plugin which is very easy to use for swapping or toggling colors between two color profiles. Therefore with this plugin, you can toggle your foreground and background colors in very quick key pressing (the default is Ctrl+Shift+u).&lt;br /&gt;&lt;br /&gt;The original looking:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_a9TRcneUCJM/TBRhQMsmh9I/AAAAAAAAAZE/Zm5Rbm8bGMA/s1600/color_toggle_0.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 232px;" src="http://1.bp.blogspot.com/_a9TRcneUCJM/TBRhQMsmh9I/AAAAAAAAAZE/Zm5Rbm8bGMA/s320/color_toggle_0.png" alt="" id="BLOGGER_PHOTO_ID_5482113577330837458" border="0" /&gt;&lt;/a&gt;After toggling:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_a9TRcneUCJM/TBRhQlyxGbI/AAAAAAAAAZM/G1MiGbuV4Fc/s1600/color_toggle_1.png"&gt;&lt;img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 232px;" src="http://2.bp.blogspot.com/_a9TRcneUCJM/TBRhQlyxGbI/AAAAAAAAAZM/G1MiGbuV4Fc/s320/color_toggle_1.png" alt="" id="BLOGGER_PHOTO_ID_5482113584067582386" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6163831394605222577?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6163831394605222577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6163831394605222577' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6163831394605222577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6163831394605222577'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/sw-color-toggle-firefox-plugin-to-swap.html' title='[SW] Color toggle -- Firefox plugin to swap foreground and background color'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_a9TRcneUCJM/TBRhQMsmh9I/AAAAAAAAAZE/Zm5Rbm8bGMA/s72-c/color_toggle_0.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5960317425062085880</id><published>2010-06-11T20:08:00.001+08:00</published><updated>2010-06-11T20:22:43.174+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[QnA] Command line rocks!! Combine several data files...</title><content type='html'>I have several data files. Each of them has only one column which presents acceleration along one axis. I want to combine them into one single file so that I can read them into my Python program with opening only one file.&lt;br /&gt;&lt;br /&gt;To illustrate the situation, here are some sample contents of the files:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ACC_X.txt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;126&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;127&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;129&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;127&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;137&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ACC_Y.txt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;132&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;106&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;109&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;114&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;105&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ACC_Z.txt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;137&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;139&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;138&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;138&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;144&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What I want is to combine them in columns within a single files as:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;ACC.txt&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;126,132,137&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;127,106,139&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;129,109,138&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;127,114,138&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;137,105,144&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first thing came into my head is using awk. However, I am not familiar with awk script. With brief searching, I found two easy ways in the command line: paste and pr.&lt;br /&gt;&lt;br /&gt;The command using paste could be:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ &lt;span style="color: rgb(0, 0, 153);"&gt;paste -d,&lt;/span&gt; ACC_X.txt ACC_Y.txt ACC_Z.txt &gt; ACC.txt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or you can use pr like this:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ &lt;span style="color: rgb(0, 0, 153);"&gt;pr -mts,&lt;/span&gt; ACC_X.txt ACC_Y.txt ACC_Z.txt &gt; ACC.txt&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The comma in the commands means I am using it as the delimiter or separator.&lt;br /&gt;&lt;br /&gt;Simple and fast. Command line really rocks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5960317425062085880?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5960317425062085880/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5960317425062085880' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5960317425062085880'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5960317425062085880'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/qna-command-line-rocks-combine-several.html' title='[QnA] Command line rocks!! Combine several data files...'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-639785692822656275</id><published>2010-06-06T15:04:00.002+08:00</published><updated>2010-06-06T15:22:32.613+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tkinter'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] To show or update images of label</title><content type='html'>To show or update images in a label, there is one thing important: You have to keep a reference for the image objects or they will be cleared so you won't see them on your label widgets.&lt;br /&gt;&lt;br /&gt;I totally had no idea about this fact and tried for several hours until I read &lt;a href="http://effbot.org/tkinterbook/photoimage.htm"&gt;the following note&lt;/a&gt;:&lt;br /&gt;&lt;blockquote&gt;Note: When a PhotoImage object is garbage-collected by Python (e.g. when you return from a function which stored an image in a local variable), the image is cleared even if it’s being displayed by a Tkinter widget.&lt;br /&gt;&lt;br /&gt;To avoid this, the program must keep an extra reference to the image object. A simple way to do this is to assign the image to a widget attribute, like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;label = Label(image=photo)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-weight: bold;"&gt;label.image = photo&lt;/span&gt; &lt;/span&gt;&lt;span style="font-style: italic; color: rgb(102, 102, 0); font-family: courier new;"&gt;# keep a reference!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;label.pack()&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;It's also true if you want to show images in sequence and then want to keep the last image when the update stops. Without the ``keep reference'' line, you will see the images updated sequentially and disappear after the last image being showed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-639785692822656275?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/639785692822656275/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=639785692822656275' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/639785692822656275'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/639785692822656275'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-to-show-or-update-images-of-label.html' title='[Py] To show or update images of label'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4400368359661234655</id><published>2010-06-05T21:33:00.007+08:00</published><updated>2010-06-06T15:22:59.416+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tkinter'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Update label's content</title><content type='html'>I am writing a simple program in Python with Tkinter, and got troubles when I wanted to update the text showed in the label. I have a variable which has been changed in certain function and I want to show its latest value on a label of the root window.&lt;br /&gt;&lt;br /&gt;Before I find the solutions, I think all I need are Label.config() and time.sleep(). However, they didn't make the program run as what I expected.&lt;br /&gt;&lt;br /&gt;Finally, I found the key is the update() function. There are two ways to do what I want, but I don't know the differences between them. Let me just show the test programs I've written.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255); font-weight: bold;"&gt;[label_test1.py]&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;from Tkinter import *&lt;br /&gt;import time&lt;br /&gt;&lt;br /&gt;class App:&lt;br /&gt;     def __init__(self, master):&lt;br /&gt;&lt;br /&gt;             frame = Frame(master).pack()&lt;br /&gt;             master.geometry("200x100")&lt;br /&gt;&lt;br /&gt;             var_text = StringVar()&lt;br /&gt;             counter = Label(frame)&lt;br /&gt;             counter.config(textvariable=var_text, font=("arial",60,"bold"), bg="green")&lt;br /&gt;             counter.pack(expand=YES, fill=BOTH)&lt;br /&gt;&lt;br /&gt;             for i in range(10):&lt;br /&gt;                     time.sleep(1)&lt;br /&gt;                     var_text.set(i)&lt;br /&gt;                     master.&lt;span style="font-weight: bold;"&gt;update()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;     root = Tk()&lt;br /&gt;     app = App(root)&lt;br /&gt;     root.mainloop()&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;     main()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;[label_test2.py]&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;from Tkinter import *&lt;br /&gt;import time&lt;br /&gt;&lt;br /&gt;class App:&lt;br /&gt;     def __init__(self, master):&lt;br /&gt;&lt;br /&gt;             frame = Frame(master).pack()&lt;br /&gt;             master.geometry("200x100")&lt;br /&gt;&lt;br /&gt;             counter = Label(frame)&lt;br /&gt;             counter.config(font=("arial",60,"bold"), bg="green")&lt;br /&gt;             counter.pack(expand=YES, fill=BOTH)&lt;br /&gt;&lt;br /&gt;             for i in range(10):&lt;br /&gt;                     time.sleep(1)&lt;br /&gt;                     counter.config(text=i)&lt;br /&gt;                     master.&lt;span style="font-weight: bold;"&gt;update()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;     root = Tk()&lt;br /&gt;     app = App(root)&lt;br /&gt;     root.mainloop()&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;     main()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.daniweb.com/code/snippet216604.html"&gt;Tkinter Countdown by bumsfeld&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://bytes.com/topic/python/answers/45706-tkinter-how-can-i-update-image-display"&gt;Tkinter: How can I update an image display?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://effbot.org/tkinterbook/label.htm"&gt;The Tkinter Label Widget&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://effbot.org/tkinterbook/variable.htm"&gt;The Variable Classes (BooleanVar, DoubleVar, IntVar, StringVar)&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4400368359661234655?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4400368359661234655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4400368359661234655' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4400368359661234655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4400368359661234655'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-update-labels-content.html' title='[Py] Update label&apos;s content'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6246180308842065914</id><published>2010-06-05T15:18:00.003+08:00</published><updated>2010-06-06T15:23:27.480+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tkinter'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Countdown counter</title><content type='html'>Here is a countdown counter which counts down in HH:MM:SS format. &lt;a href="http://www.daniweb.com/code/snippet216971.html"&gt;The original example&lt;/a&gt; has given by vegaseat, which counts increasingly. I modified it to be a countdown version as the follows.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;"""&lt;br /&gt;A ``countdown'' counter using Tkinter&lt;br /&gt;Original version has given by  vegaseat  17aug2007&lt;br /&gt;http://www.daniweb.com/code/snippet216971.html&lt;br /&gt;&lt;br /&gt;This version is modified from the original one&lt;br /&gt;by thk 2010/06/05&lt;br /&gt;"""&lt;br /&gt;&lt;br /&gt;import Tkinter as tk&lt;br /&gt;from itertools import count&lt;br /&gt;&lt;br /&gt;def start_counter_down(label):&lt;br /&gt;       counter = count(0)&lt;br /&gt;       begin_time = 10 # sec.&lt;br /&gt;       def update_func():&lt;br /&gt;               left_time = begin_time - counter.next()&lt;br /&gt;               show_hr  = left_time/3600&lt;br /&gt;               show_min = (left_time%3600)/60&lt;br /&gt;               show_sec = (left_time%3660)%60&lt;br /&gt;               label.config(text=\&lt;br /&gt;                       str(show_hr).zfill(2)+':'+\&lt;br /&gt;                       str(show_min).zfill(2)+':'+\&lt;br /&gt;                       str(show_sec).zfill(2))&lt;br /&gt;               label.after(1000, update_func)  # 1000ms&lt;br /&gt;               if left_time &lt;= 0:                         label.config(text="Time's up!")         update_func()       root = tk.Tk() root.title("Counting Down") label = tk.Label(root, fg="red") label.pack() start_counter_down(label) button = tk.Button(root, text='Stop &amp;amp; Quit', width=30, command=root.destroy) button.pack() root.mainloop() &lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6246180308842065914?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6246180308842065914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6246180308842065914' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6246180308842065914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6246180308842065914'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-countdown-counter.html' title='[Py] Countdown counter'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6254929853822368770</id><published>2010-06-01T10:00:00.004+08:00</published><updated>2010-06-06T15:23:59.233+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tkinter'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Canvas example (correction)</title><content type='html'>&lt;a href="http://www.java2s.com/Code/Python/GUI-Tk/CatalogGUI-Tk.htm"&gt;Here&lt;/a&gt; are some GUI examples of Python with Tkinter. &lt;a href="http://www.java2s.com/Code/Python/GUI-Tk/CanvasSimpleplot.htm"&gt;One of the example&lt;/a&gt; shows how to draw lines in the canvas. However, the source code has some errors. I have tested and corrected the errors as the following lines:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;21c21&lt;br /&gt;&lt; x =" 250"&gt;                         y = 250 - (i * 40)&lt;br /&gt;28c28&lt;br /&gt;&lt;&gt;                         scaled.append((100 + 3*x, 250 - (4*y)/5))&lt;br /&gt;33c33&lt;br /&gt;&lt; width="1,"&gt;                         canvas.create_oval(xs-6,ys-6,xs+6,ys+6, width=1,&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6254929853822368770?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6254929853822368770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6254929853822368770' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6254929853822368770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6254929853822368770'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/06/py-canvas-example-correction.html' title='[Py] Canvas example (correction)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7142629274429346619</id><published>2010-05-28T20:17:00.007+08:00</published><updated>2010-06-01T10:00:01.062+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='keymaps'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='wmii'/><title type='text'>[QnA] Use xmodmap to set modifier keys</title><content type='html'>In &lt;a href="http://hiankun.blogspot.com/2010/05/sw-change-modifier-key-for-wmii.html"&gt;the previous article&lt;/a&gt;, I described how to change the modifier key for wmii from Mod1(Alt) to Mod4(Windows key). That's no problem for my PCs, but not okay for my laptop, an &lt;a href="http://en.wikipedia.org/wiki/ThinkPad"&gt;IBM X31&lt;/a&gt;. The laptop has NO Windows key, so I cannot just modify the wmiirc file to make things run.&lt;br /&gt;&lt;br /&gt;Fortunately, Google helped me to find the solution again. There is a command called xmodmap to modify &lt;a href="http://en.wikipedia.org/wiki/Keymap"&gt;keymaps&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The steps are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Create a file, for example, ~/.Xmodmap&lt;/li&gt;&lt;li&gt;Paste the following lines in the created file&lt;/li&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;! No Caps Lock&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;clear lock&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;! Caps Lock as Win key &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;add mod4 = Caps_Lock&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Run xmodmap to enable the settings&lt;/li&gt;&lt;br /&gt;$ xmodmap ~/.Xmodmap&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;---&lt;br /&gt;Reference:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.thinkwiki.org/wiki/How_to_get_special_keys_to_work"&gt;How to get special keys to work&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;---&lt;br /&gt;Edit (2010/06/01):&lt;br /&gt;&lt;br /&gt;After changing Caps Lock key to Windows key, wmii cannot move windows to desktop#2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7142629274429346619?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7142629274429346619/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7142629274429346619' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7142629274429346619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7142629274429346619'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/qna-use-xmodmap-to-set-modifier-keys.html' title='[QnA] Use xmodmap to set modifier keys'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3013285849660218625</id><published>2010-05-28T08:20:00.006+08:00</published><updated>2010-05-28T20:37:19.600+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='keymaps'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='wmii'/><title type='text'>[SW] Change modifier key for wmii</title><content type='html'>I have adopted &lt;a href="http://wmii.suckless.org/"&gt;wmii&lt;/a&gt; as my main &lt;a href="http://en.wikipedia.org/wiki/Window_manager"&gt;WM&lt;/a&gt; for months and it has given pretty good experience in my daily usage. There has been one thing, however, bothering me a bit. The default modifier key of wmii is Alt, which is presented as Mod1 in wmiirc. Because Alt is a frequently used key for tools such as &lt;a href="http://www.gnu.org/software/bash/"&gt;BASH&lt;/a&gt;, this default setting could cause some inconveniences. For example, when you want to move forward in BASH commands, Alt+F won't give you the expected moving but will make the working window run in full screen. Fortunately, wmii has been featured as its configurability.&lt;br /&gt;&lt;br /&gt;In my system, which is Ubuntu 8.04, the confiuration files are located in&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    /etc/X11/wmii-3.5/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two files look like something to be the configureation file: rc.wmii and wmiirc. To make sure which one is used, use the following commands&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    ps aux | grep wmii | grep rc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In my case, it is the wmiirc file.&lt;br /&gt;&lt;br /&gt;In the beginning of wmiirc, there are several lines which set the keys.&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    MODKEY=&lt;span style="font-weight: bold;"&gt;Mod1&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    UP=k&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;span style="font-family: courier new;"&gt;DOWN=j&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;span style="font-family: courier new;"&gt;LEFT=h&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;    &lt;/span&gt;&lt;span style="font-family: courier new;"&gt;RIGHT=l&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I set MODKEY from &lt;span style="font-weight: bold;"&gt;Mod1&lt;/span&gt; to &lt;span style="font-weight: bold;"&gt;Mod4&lt;/span&gt; which is the &lt;a href="http://en.wikipedia.org/wiki/Windows_key"&gt;Windows key&lt;/a&gt;. Re-login and you can use wmii without the ``Alt conflict'' with many other programs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3013285849660218625?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3013285849660218625/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3013285849660218625' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3013285849660218625'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3013285849660218625'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/sw-change-modifier-key-for-wmii.html' title='[SW] Change modifier key for wmii'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6051911730453786933</id><published>2010-05-26T13:15:00.001+08:00</published><updated>2010-05-26T13:42:12.783+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rhythmbox'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Internet radio for Ubuntu</title><content type='html'>&lt;a href="http://projects.gnome.org/rhythmbox/"&gt;Rhythmbox&lt;/a&gt; was the software I used to listen music and internet radios. Due to reasons I don't understand, Rhythmbox does not work properly for the internet radios anymore, and I've tired to find out the solution. I started to search possible alternatives for me to listen internet radios. Firstly I found &lt;a href="http://www.exaile.org/"&gt;Exaile&lt;/a&gt; and it looked good, but I didn't get its plugin (shoutcast radio) work.&lt;br /&gt;&lt;br /&gt;Finally, I found &lt;a href="http://tunapie.sourceforge.net/"&gt;Tunapie&lt;/a&gt;. I installed it and &lt;a href="http://streamripper.sourceforge.net/"&gt;Stremripper&lt;/a&gt; via Synaptic. After the installation, I set the audio player as VLC in Tunapie's preference, then everything goes well. :-)&lt;br /&gt;&lt;br /&gt;(But &lt;a href="http://www.hot108.com/"&gt;Hot 108 Jamz&lt;/a&gt; station cannot be played... Orz)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6051911730453786933?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6051911730453786933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6051911730453786933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6051911730453786933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6051911730453786933'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/sw-internet-radio-for-ubuntu.html' title='[SW] Internet radio for Ubuntu'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5857463317888384733</id><published>2010-05-22T18:59:00.008+08:00</published><updated>2010-05-23T13:03:22.871+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Use ``list comprehensions'' to avoid nesting ``for loops'' too deeply</title><content type='html'>As I have mentioned in the previous post, I am trying to analyze some data using Python as the programming language. The data sets are from 4 sensor nodes, and each nodes give accelerations in 3 axes. Furthermore, I want to process these data sets in sequential mode. So, the original structure of my program looked like this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;    data = zeros((n_nodes,3))&lt;br /&gt;&lt;br /&gt;    for i in range( len(databuffer) ):&lt;br /&gt;            &lt;span style="font-weight: bold;"&gt;for nodes in range(4):&lt;/span&gt;&lt;br /&gt;                    &lt;span style="font-weight: bold;"&gt;for xyz in range(3):&lt;/span&gt;&lt;br /&gt;                            data[nodes][xyz] = databuffer[nodes][xyz][i]&lt;br /&gt;                                    if (some conditions):&lt;br /&gt;                                            do something&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That's crazy! These nested for loops are too deep to be followed. Also, I remember once I read an article written by an experienced programmer, who said if your for loops nested too deep, then maybe you need to redesign you program.&lt;br /&gt;&lt;br /&gt;I had no idea about how to redesign the structure of my program to fit my original requirements. Fortunately, the list comprehensions could resolve this difficulty. Here is the new version using the list comprehensions:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;     for i in range( len(databuffer[0][0]) ):&lt;br /&gt;             data = array([databuffer[nodes][xyz][i]\&lt;br /&gt;             &lt;span style="font-weight: bold;"&gt;for nodes in range(n_nodes) for xyz in range(3)&lt;/span&gt;]).reshape(n_nodes,3)&lt;br /&gt;                     if(some conditions):&lt;br /&gt;                             do something&lt;br /&gt;&lt;/pre&gt;The list comprehensions remove two loops and make a conciser new structure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5857463317888384733?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5857463317888384733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5857463317888384733' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5857463317888384733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5857463317888384733'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/py-use-list-comprehensions-to-avoid.html' title='[Py] Use ``list comprehensions&apos;&apos; to avoid nesting ``for loops&apos;&apos; too deeply'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7293028535928570319</id><published>2010-05-20T16:32:00.008+08:00</published><updated>2010-10-14T10:43:38.095+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='list'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Multi-dimensional list</title><content type='html'>So far, the list in Python has bothered me a lot. I think it's because I do not understand it enough. These days I've been writing a little program to analyze some data, and encountered unexpected situations which almost got me down.&lt;br /&gt;&lt;br /&gt;One unexpected situation was the multi-dimensional list, or the list of lists. The following page describes exactly what had troubled me:&lt;br /&gt;&lt;br /&gt;&lt;s&gt;&lt;a href="http://pyfaq.infogami.com/how-do-i-create-a-multidimensional-list/_comments/4jn5"&gt;(An Unofficial) Python FAQ Wiki&lt;/a&gt; (old link)&lt;/s&gt;&lt;br /&gt;&lt;a href="http://effbot.org/pyfaq/how-do-i-create-a-multidimensional-list.htm"&gt;How do I create a multidimensional list?&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This surprised me and made me thought again: ``Do I really know how to program in Python?'' The answer is definitely no. The low threshold to begin Python programming made me overestimate my understanding of it. Therefore, I told myself to learn more before stepping further.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Another situation surprised me is also about the list creation. The following test shows it:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; a = b = [[]]*3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; a[1] = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; b&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[], 1, []]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To assign values to list a also affects list b. To avoid this situation, you should create the lists separately.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; a = [[]]*3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; b = [[]]*3&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; a[1] = 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&gt;&gt;&gt; b&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[[], [], []]&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7293028535928570319?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7293028535928570319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7293028535928570319' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7293028535928570319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7293028535928570319'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/py-multi-dimensional-list.html' title='[Py] Multi-dimensional list'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6875956067998446551</id><published>2010-05-17T09:35:00.008+08:00</published><updated>2010-12-30T16:44:26.555+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='open source'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='pyode'/><title type='text'>[Py] PyODE installation and test</title><content type='html'>I read about ODE (no, not the ODE in math) in a thesis last week, and searched it to see what it is. ODE is the abbreviation of &lt;a href="http://ode.org/"&gt;Open Dynamic Engine&lt;/a&gt;, an library for simulating rigid body dynamics. As a Python fan, it's reasonable for me to search related module of ODE written in Python. The keywords ``python ode'' brought me the &lt;a href="http://pyode.sourceforge.net/"&gt;PyODE&lt;/a&gt;, a set of Python bindings for ODE.&lt;br /&gt;&lt;br /&gt;There are three examples on the PyODE page. I tried to test it, and installed what my system lacked accordingly.&lt;br /&gt;&lt;br /&gt;The installation in Ubuntu is quite easy as usual. My procedures are listed as the follows.&lt;br /&gt;&lt;br /&gt;First, get the PyODE module, which is the basic one to run the 1st example:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install python-pyode&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then if you want to run the 2nd example, you need &lt;a href="http://www.pygame.org/news.html"&gt;Pygame&lt;/a&gt;:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install python-pygame&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally, the 3rd example demands &lt;a href="http://pyopengl.sourceforge.net/"&gt;PyOpenGL&lt;/a&gt;:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install python-opengl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After these steps, I found the best way to get all these examples is to install the documents of PyODE:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install python-pyode-doc&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You could find the source code of all the three examples in&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;/usr/share/doc/python-pyode-doc/examples&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There are two more examples in the folder, but they needs more libraries. To run the ``transforms.py'' example, the error message showed there was no module named ``cgtypes.'' It seems to be in the &lt;a href="http://cgkit.sourceforge.net/"&gt;cgkit&lt;/a&gt; package. This package cannot be found in Ubuntu repository, so I downloaded the source and read the README. The SCons and Boost are necessary:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get  install scons&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install libboost-dev&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;s&gt;But I couldn't install the package and still get no luck so far.&lt;br /&gt;&lt;br /&gt;I decide not to bother with the Scons and Boost by now. If I have some time, I would like to play with the original 3 examples to see whether I can learn something fun and useful from them.&lt;br /&gt;&lt;/s&gt;&lt;br /&gt;&lt;br /&gt;When I ran the setup.py to install the package, there came lots of error messages. With some efforts, I noticed one of the error message read there was no file named ``&lt;span style="font-weight: bold;"&gt;boost/python.hpp&lt;/span&gt;.'' And with some more efforts, it came to me that maybe something like ``libboost-dev'' is needed. Therefore, I typed libboost in the terminal and used the Tab key to check available packages. Yes, there was a library named ``&lt;span style="font-weight: bold;"&gt;libboost-python-dev&lt;/span&gt;'' which looked like what I needed, so I installed it by typing:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo apt-get install libboost-python-dev&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then, everything was ready to install the cgkit in the downloaded and extracted folder:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;$ sudo python setup.py install&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The cgkit has been installed, though, the example transforms.py cannot be executed correctly. According to the error message (ImportError: No module named cgtypes), I edited the line in the transforms.py from&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;    from cgtypes import *&lt;/span&gt;&lt;br /&gt;to&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;    from cgkit.cgtypes import *&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After the modification, new problem emerged. The window showed up and then closed, with the eorror message given in the terminal:&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;freeglut  ERROR:  Function &lt;glutsolidcube&gt; called without first calling 'glutInit'.&lt;/glutsolidcube&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then I found &lt;a href="http://www.quietearth.us/articles/2006/11/15/Freeglut-error-in-Ubuntu"&gt;the page&lt;/a&gt; talking about this issue. So what I had to do was to find somewhere to put the glutInit function call. I tested for several times but totally had no idea where to add the glutInit, then I noticed the keyword in the error message: &lt;span style="font-family: 'courier new';"&gt;Function &lt;glutsolidcube&gt;&lt;/glutsolidcube&gt;&lt;/span&gt;. It took me to the right location of the code to add a line as follows:&lt;br /&gt;&lt;span style="font-family: 'courier new'; font-weight: bold;"&gt;    glutInit(argc, argv)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;    glutSolidCube(1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It didn't work and threw back a name error:&lt;br /&gt;NameError: global name 'argc' is not defined&lt;br /&gt;&lt;br /&gt;I thought there might be no argument for this function call in the code, so I deleted the argc and argv to make the glutInit be called as the following:&lt;br /&gt;&lt;span style="font-family: 'courier new'; font-weight: bold;"&gt;    glutInit()&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;    glutSolidCube(1)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Bingo! Although I am still not sure whether the transforms.py runs properly, at least the window showed up with several moving cubes inside.&lt;br /&gt;&lt;br /&gt;By far, the problem to run the transforms.py is solved. However, there is still an example code named vehicle.py cannot be run properly in my system. I have to do other works. Maybe I will come back to find out the solution for the vehicle.py.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6875956067998446551?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6875956067998446551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6875956067998446551' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6875956067998446551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6875956067998446551'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/05/py-pyode-installation-and-test.html' title='[Py] PyODE installation and test'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3424961739417636366</id><published>2010-04-16T10:04:00.014+08:00</published><updated>2010-05-17T09:35:16.502+08:00</updated><title type='text'>[Chat] Simple is not so simple -- The hacker emblem and Conway's game of life</title><content type='html'>I am not so good at programming, but I am always willing to know or to learn something new about programming. It's natural for me to getting more and more interesting at the open-source and then the hackers' culture. Of course, I'd tried to find some information about ``how to become a hacker'' and the very same sentence made Google bring me the article ``&lt;a href="http://catb.org/%7Eesr/faqs/hacker-howto.html"&gt;How To Become A Hacker&lt;/a&gt;'' written by &lt;a href="http://www.catb.org/%7Eesr/"&gt;Eric Steven Raymond&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Raymond's article is delightful and easy to read. Howevr, I didn't read it thoroughly at the first reading, and the following tiny picture, which is called ``glider,'' didn't attract me too much. I just wondered what it was and then forgot it.&lt;br /&gt;&lt;a href="http://www.catb.org/hacker-emblem/"&gt;&lt;br /&gt;&lt;img src="http://www.catb.org/hacker-emblem/glider.png" alt="hacker emblem" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;One day, I read &lt;a href="http://catb.org/%7Eesr/hacker-emblem/"&gt;one of Raymond's article&lt;/a&gt; again, and linked to the &lt;a href="http://catb.org/%7Eesr/hacker-emblem/faqs.html"&gt;FAQ&lt;/a&gt; to check out what the ``glider'' is. After I realized what is the glider and what is &lt;a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life"&gt;Conway's Game of Life&lt;/a&gt;, all I wanted to say was ``Wow! Cool!'' just as that have been mentioned in Raymond's article.&lt;br /&gt;&lt;br /&gt;The rules of Game of Life are simple, but the outcome is definitely not simple. You choose random cells' locations, then let the cells ``evolve'' under the simple rules. Just watch the ``evolution'' and it looks so vivid and fun!&lt;br /&gt;&lt;br /&gt;I found &lt;a href="http://conwaylife.com/wiki/index.php?title=Main_Page"&gt;LifeWiki&lt;/a&gt; might be a great page to dive into. You can find many amazing patterns, and play with those patterns online (with your browser's javascript enabled). Also, you can have &lt;a href="http://linux.maruhn.com/sec/xlife.html"&gt;Xlife&lt;/a&gt; in your system to play and test. If you are using Ubuntu, type the following command to install Xlife:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ sudo apt-get install xlife&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally, 2 videos for your reference:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=FdMzngWchDk"&gt;John Conway Talks About the Game of Life&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=XcuBvj0pw-E"&gt;Amazing Game of Life Demo&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3424961739417636366?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3424961739417636366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3424961739417636366' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3424961739417636366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3424961739417636366'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/04/chat-simple-is-not-so-simple-hacker.html' title='[Chat] Simple is not so simple -- The hacker emblem and Conway&apos;s game of life'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4568640449493610893</id><published>2010-03-30T20:12:00.010+08:00</published><updated>2010-05-17T09:31:33.973+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LaTeX'/><title type='text'>[QnA] Use the latest version of exam.cls for preparing exam papers</title><content type='html'>When preparing an exam paper, we might want to have two versions of this exam paper: one with answers for teachers and the other has only questions for students.&lt;br /&gt;&lt;br /&gt;The exam.cls makes this task easy. But make sure you are using the latest version of it or you will not have the handy ``ifprintanswer'' function.&lt;br /&gt;&lt;br /&gt;Here is an sample to show how to use the exam.cls with the ifprintanswer function:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;\documentclass{&lt;span style="color: rgb(0, 0, 153);"&gt;exam&lt;/span&gt;} &lt;span style="color: rgb(0, 102, 0);"&gt;% Set ``exam'' as the document class&lt;/span&gt;&lt;br /&gt;\begin{document}&lt;br /&gt;\newcommand{\ans}[1]{\ifprintanswers{#1}\fi} &lt;span style="color: rgb(0, 102, 0);"&gt;% define a new command to simplify&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;                                             % the following usage&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;\printanswers&lt;/span&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;% Add this line to print the answers.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;              % If no answers printing is wanted, just comment this line out.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;\begin{questions}&lt;br /&gt;\question&lt;br /&gt;\ans{The answer} The question's description&lt;br /&gt;  \begin{choices}&lt;br /&gt;  \choice The choice A&lt;br /&gt;  \choice The choice B&lt;br /&gt;  \choice The choice C&lt;br /&gt;  \choice The choice D&lt;br /&gt;  \end{choices}&lt;br /&gt;\end{questions}&lt;br /&gt;\end{document}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;a href="http://www.semiantics.com/?p=333"&gt;Using the LaTeX exam class&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4568640449493610893?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4568640449493610893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4568640449493610893' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4568640449493610893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4568640449493610893'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/qna-use-latest-version-of-examcls-for.html' title='[QnA] Use the latest version of exam.cls for preparing exam papers'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7461299150224212030</id><published>2010-03-25T09:25:00.002+08:00</published><updated>2010-03-25T09:40:55.048+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='LaTeX'/><title type='text'>[QnA] Add cls or sty files for LaTeX</title><content type='html'>We always use certain packages in the latex files, and sometimes the packages are just not there so we need to add them for further working. It's was a big problem for me when I knew very few about the working principle of LaTeX. Now I think I have got a simple and clear process to add packages, that is, *.cls or *.sty, for LaTeX. Here is an example in which I added a so-called exam package for preparing exam papers.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Step 1. Search for&lt;a href="http://www.ctan.org/tex-archive/macros/latex/contrib/exam/"&gt; the exam package&lt;/a&gt; and download it from &lt;a href="http://www.ctan.org/"&gt;CTAN&lt;/a&gt;, and then of course unzip it.&lt;/li&gt;&lt;li&gt;Step 2. Make a directory for adding the exam package. In my Ubuntu system, it is:&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;/usr/share/texmf-texlive/tex/latex/exam/&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Step 3. Copy all the files of the downloaded and unzipped exam package to the directory we just made.&lt;/li&gt;&lt;li&gt;Step 4. Run the &lt;span style="font-family: courier new;"&gt;texhash&lt;/span&gt; command as root. Done.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7461299150224212030?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7461299150224212030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7461299150224212030' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7461299150224212030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7461299150224212030'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/qna-add-cls-or-sty-files-for-latex.html' title='[QnA] Add cls or sty files for LaTeX'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5848181610112616988</id><published>2010-03-22T11:36:00.003+08:00</published><updated>2010-03-22T13:56:18.279+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='eps'/><category scheme='http://www.blogger.com/atom/ns#' term='ps2pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Use ps2pdf to convert EPS to PDF</title><content type='html'>Sometimes we need to convert the eps files to the pdf format. To utilize ps2pdf is a straightforward choice. However, it's not easy, at least for me, to find out how to use some options. Fortunately, I found one article mentioned about how to fit the eps figure to the output pdf:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://opendevice.blogspot.com/2007/05/eps-to-pdf-how-to-avoid-clipping.html"&gt;EPS to PDF : how to avoid clipping&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just to use the ``-dEPSFitPage'' option. More options can be found at the following site:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pages.cs.wisc.edu/%7Eghost/doc/cvs/Use.htm#EPS_parameters"&gt;How to use Ghostscript&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;(I tried the option ``-dOREIENT1=true/false'' but has no expected results. I cannot find related solution. There is a bug report that followed no further response: ``&lt;a href="http://www.ghostscript.com/pipermail/bug-gs/2002-January/001003.html"&gt;[Bug-gs] Lanscape view instead of Portrait of a pdf file&lt;/a&gt;'')&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5848181610112616988?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5848181610112616988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5848181610112616988' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5848181610112616988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5848181610112616988'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/sw-use-ps2pdf-to-convert-eps-to-pdf.html' title='[SW] Use ps2pdf to convert EPS to PDF'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8970934387622169266</id><published>2010-03-18T16:47:00.003+08:00</published><updated>2010-06-11T20:40:58.335+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='csv'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Plot the CSV files using Gnuplot</title><content type='html'>I have used &lt;a href="http://www.gnuplot.info/"&gt;gnuplot&lt;/a&gt; for data plotting for several years, but there has been one minor thing bothering me until today.&lt;br /&gt;&lt;br /&gt;With my previous (not correct) understanding, gnuplot can only handle data files separated by spaces. Therefore, whenever I wanted to visualize the csv files with gnuplot, I had to use awk or sed to remove the commas and then save the results into new files. It made my folders contain redundant data files which were just for using gnuplot. It's a little stupid, I always thought.&lt;br /&gt;&lt;br /&gt;Today I encountered several csv files again, but this time I made up my mind to find the solution out. From the searching results with Google, I found there have been some people asking the same question but without easy solutions given. Then I found a document of old version gnuplot. It gives the right approach: to &lt;a href="http://www.gnuplot.info/docs_4.0/gnuplot.html#set_datafile_separator"&gt;set datafile separator&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So, next time when you need to handle the csv files with gnuplot, remember to add the following line in the gnuplot script:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-weight: bold;"&gt;set datafile separator ","&lt;/span&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8970934387622169266?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8970934387622169266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8970934387622169266' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8970934387622169266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8970934387622169266'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/sw-plot-csv-files-using-gnuplot.html' title='[SW] Plot the CSV files using Gnuplot'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-9077944513549862207</id><published>2010-03-16T22:34:00.020+08:00</published><updated>2011-02-10T22:41:10.063+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Tips for Gnuplot -- Multiplot with EPS output setting</title><content type='html'>It's very often to show several figures in a single plot. With ``set multiplot,'' &lt;a href="http://www.gnuplot.info/"&gt;gunplot&lt;/a&gt; can do this work pretty good. There will be some problems, however, when we don't give proper settings for gunplot. One of the problems I've met was the gnuplot did not print out complete plot containing multiple figures with the terminal set as postscript.&lt;br /&gt;&lt;br /&gt;I tried and searched for the solution, and finally got the key. It is better to set the size for the entire plot before the multiplot setting.&lt;br /&gt;&lt;br /&gt;Here is my original WRONG setting structure:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;set the terminal&lt;/li&gt;&lt;li&gt;set the output filename&lt;/li&gt;&lt;li style="color: red; font-weight: bold;"&gt;set the size for individual figures&lt;/li&gt;&lt;li&gt;set multiplot&lt;/li&gt;&lt;li style="color: red; font-weight: bold;"&gt;set the origin for individual figures&lt;/li&gt;&lt;li&gt;plot individual figures&lt;/li&gt;&lt;li&gt;unset multiplot&lt;/li&gt;&lt;/ol&gt;And the following is the corrected one:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;set the terminal&lt;/li&gt;&lt;li&gt;set the output filename&lt;/li&gt;&lt;li style="color: #6633ff; font-weight: bold;"&gt;set the size for the entire plot&lt;/li&gt;&lt;li style="color: #6633ff; font-weight: bold;"&gt;set the origin for the entire plot&lt;br /&gt;&lt;/li&gt;&lt;li&gt;set multiplot&lt;/li&gt;&lt;li style="color: #6633ff; font-weight: bold;"&gt;set the size for individual figures&lt;/li&gt;&lt;li style="color: #6633ff; font-weight: bold;"&gt;set the origin for individual figures&lt;/li&gt;&lt;li&gt;plot individual figures&lt;/li&gt;&lt;li&gt;unset multiplot&lt;/li&gt;&lt;/ol&gt;With the wrong setting structure, we can still get normal output with some terminals such as png. If what we want is something like eps files, then it's necessary to use the right setting structure, which actually makes better sense.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Let me show you the (correct) example.&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family: 'courier new';"&gt;1 set terminal postscript eps enhanced color solid 20&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  2 set output "test_nogood.eps"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  3 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  4 set nokey&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  5 set size 1,1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  6 set origin 0,0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  7 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  8 set multiplot&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt;  9 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 10 set tmargin 0.5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 11 set bmargin 0.5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 12 set rmargin 1.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 13 set lmargin 5.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 14 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 15 set xrange [-25:25]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 16 set ylabel "f(x)"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 17 set noxtics&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 18 set noytics&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 19 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 20 set size 1,0.20&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 21 set origin 0.0,0.76&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 22 set title "sin(x)" offset 0,-1.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 23 plot sin(x) w l lt 1 lw 2 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 24 set size 1,0.20 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 25 set origin 0.0,0.54&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 26 set title "cos(x)" offset 0,-1.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 27 plot cos(x) w l lt 9 lw 2 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 28 set size 1,0.20 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 29 set origin 0.0,0.32&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 30 set title "sin(x)/x" offset 0,-1.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 31 plot sin(x)/x w l lt 3 lw 2 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 32 set size 1,0.20 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 33 set origin 0.0,0.10&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 34 set xlabel "x"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 35 set title "x*sin(x)" offset 0,-1.0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 36 plot x*sin(x) w l lt 8 lw 2 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 37 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 38 unset multiplot&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 39 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 40 reset&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'courier new';"&gt; 41 &lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;You will get the following plot:&lt;br /&gt;&lt;pre&gt;&lt;a href="http://3.bp.blogspot.com/_a9TRcneUCJM/S6HlMMNDOFI/AAAAAAAAAX4/eb0oiLjg5VA/s1600-h/test_good_eps.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5449889021692164178" src="http://3.bp.blogspot.com/_a9TRcneUCJM/S6HlMMNDOFI/AAAAAAAAAX4/eb0oiLjg5VA/s320/test_good_eps.png" style="cursor: pointer; display: block; height: 224px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;/pre&gt;If you change line 5 as ``set size 1,0.20'' and comment out lines 6, 20, 24, 28, and 32, the output result will be as the following plot:&lt;br /&gt;&lt;pre&gt;&lt;a href="http://2.bp.blogspot.com/_a9TRcneUCJM/S6HlMY5B3fI/AAAAAAAAAYA/qLgC68ozhjc/s1600-h/test_nogood_eps.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5449889025097850354" src="http://2.bp.blogspot.com/_a9TRcneUCJM/S6HlMY5B3fI/AAAAAAAAAYA/qLgC68ozhjc/s320/test_nogood_eps.png" style="cursor: pointer; display: block; height: 43px; margin: 0px auto 10px; text-align: center; width: 320px;" /&gt;&lt;/a&gt;&lt;/pre&gt;It gives only the last part of the eps file.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;References:&lt;br /&gt;Gnuplot FAQ: 7.6 &lt;a href="http://www.gnuplot.info/faq/faq.html#SECTION00096000000000000000"&gt;My output files are incomplete!&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.ibm.com/developerworks/library/l-gnuplot/"&gt;Visualize your data with gnuplot&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-9077944513549862207?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/9077944513549862207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=9077944513549862207' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/9077944513549862207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/9077944513549862207'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/sw-tips-for-gnuplot-multiplot-with-eps.html' title='[SW] Tips for Gnuplot -- Multiplot with EPS output setting'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_a9TRcneUCJM/S6HlMMNDOFI/AAAAAAAAAX4/eb0oiLjg5VA/s72-c/test_good_eps.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8593265446008608532</id><published>2010-03-12T10:04:00.001+08:00</published><updated>2010-03-12T10:14:38.110+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[SW] Convert XLS to CSV</title><content type='html'>I got a bundle of xls files and want to extract their data for further analysis. The first thought occurred to me was to find some command line tools to help me convert all the xls files into some kind of text files. Then I found &lt;a href="http://search.cpan.org/%7Eken/xls2csv-1.06/script/xls2csv"&gt;xls2csv&lt;/a&gt;, which can be got via apt-get by installing &lt;a href="http://wagner.pp.ru/%7Evitus/software/catdoc/"&gt;catdoc&lt;/a&gt;. So what you need is typing&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family: courier new;"&gt;$ sudo apt-get install catdoc&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;in your Ubuntu terminal.&lt;br /&gt;&lt;br /&gt;The catdoc is useful when you want to take a look at the textual information in doc files.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8593265446008608532?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8593265446008608532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8593265446008608532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8593265446008608532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8593265446008608532'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/sw-convert-xls-to-csv.html' title='[SW] Convert XLS to CSV'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-1622640044260150739</id><published>2010-03-05T16:38:00.006+08:00</published><updated>2010-03-05T16:55:18.395+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pylab'/><category scheme='http://www.blogger.com/atom/ns#' term='matplotlib'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>[Py] Save the figure before show it</title><content type='html'>This might be a simple and trivial tips, but I didn't know it till today. I occasionally got a blank figure saved by &lt;a href="http://matplotlib.sourceforge.net/"&gt;matplotlib&lt;/a&gt;'s &lt;a href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.savefig"&gt;savefig&lt;/a&gt; function and had no idea about that strange result. Then I decided to test it with simple Python code.&lt;br /&gt;&lt;br /&gt;My test code:&lt;br /&gt;--------------------------------------------&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);font-family:courier new;" &gt;&lt;span style="color: rgb(0, 102, 0);"&gt;1&lt;/span&gt; &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;from pylab import *&lt;/span&gt;  &lt;span style="color: rgb(0, 102, 0);font-family:courier new;" &gt;&lt;br /&gt;2&lt;/span&gt;  &lt;span style="color: rgb(0, 102, 0);font-family:courier new;" &gt;&lt;br /&gt;3&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; y = []&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;4&lt;/span&gt; for x in range(0,10):&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;5&lt;/span&gt;     y.append(x*x)&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;6&lt;/span&gt;&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;7&lt;/span&gt; plot(range(0,10), y)&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;8&lt;/span&gt; savefig('fig_saved.png')&lt;/span&gt; &lt;span style="font-family:courier new;"&gt; &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;9&lt;/span&gt; show()&lt;/span&gt;&lt;br /&gt;--------------------------------------------&lt;br /&gt;&lt;br /&gt;After running the above code, you should get the foll0wing figure saved by using savefig() function.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_a9TRcneUCJM/S5DFBHDzFOI/AAAAAAAAAXo/HBSpT83WxFE/s1600-h/fig_saved.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 240px;" src="http://2.bp.blogspot.com/_a9TRcneUCJM/S5DFBHDzFOI/AAAAAAAAAXo/HBSpT83WxFE/s320/fig_saved.png" alt="" id="BLOGGER_PHOTO_ID_5445068572356449506" border="0" /&gt;&lt;/a&gt;But if you exchange line 8 and line 9, you get nothing but a totally blank figure.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-1622640044260150739?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/1622640044260150739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=1622640044260150739' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1622640044260150739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1622640044260150739'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/03/py-save-figure-before-show-it.html' title='[Py] Save the figure before show it'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_a9TRcneUCJM/S5DFBHDzFOI/AAAAAAAAAXo/HBSpT83WxFE/s72-c/fig_saved.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4643588620483378816</id><published>2010-02-28T20:46:00.001+08:00</published><updated>2010-02-28T21:11:38.164+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='quod libet'/><category scheme='http://www.blogger.com/atom/ns#' term='podcast'/><title type='text'>[SW] Podcast in Quod Libet</title><content type='html'>Several moths ago, I installed Quod Libet for the first time. When I could not figure out how to add the podcast feeds in the Quod Libet, and posted &lt;a href="http://ubuntuforums.org/showthread.php?p=7756476#post7756476"&gt;my question&lt;/a&gt; on Ubuntu Forums. But I totally forget it after my posting... O__O"&lt;br /&gt;&lt;br /&gt;I saw the thread when I was searching something else. Then I followed what lazka suggested:&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family: courier new;"&gt;$ sudo apt-get install python-feedparser&lt;/span&gt;&lt;/blockquote&gt;After installing the python-feedparser, just restart Quod Libet and find the Audio Feeds entry in the menu. Use the New button to add podcast feeds.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4643588620483378816?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4643588620483378816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4643588620483378816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4643588620483378816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4643588620483378816'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/sw-podcast-in-quod-libet.html' title='[SW] Podcast in Quod Libet'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3982234469946061246</id><published>2010-02-28T16:15:00.006+08:00</published><updated>2010-02-28T16:28:44.091+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scipy'/><category scheme='http://www.blogger.com/atom/ns#' term='pylab'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='SVM'/><title type='text'>[Py] Random data generation -- a trial</title><content type='html'>I am studying the usage of &lt;a href="http://www.csie.ntu.edu.tw/%7Ecjlin/libsvm/"&gt;LIBSVM&lt;/a&gt; recently. What I want is to test the library with some simple data to enhance my understanding for using the library. Therefore, I thought about generating some random data sets for my own learning purpose, and of course, the first choice came into me was Python.&lt;br /&gt;&lt;br /&gt;The following are my code and the resulting data plot.&lt;br /&gt;---------------------------------------------&lt;br /&gt;Code:&lt;br /&gt;&lt;pre&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;from pylab import *&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;from numpy import *&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;data =[]&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;#generate random data sets&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;data.append( 1.2*random.randn(2,30) )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;data.append( 2.0*random.randn(2,30) )&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;data.append( random.randn(2,30) )&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;#shift the data sets&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;x0 = data[0][0]; y0 = data[0][1]&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;x1 = data[1][0]+3.5; y1 = data[1][1]+2.5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;x2 = data[2][0]-1.5; y2 = data[2][1]+4.5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;f = open('randData','w')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;for i in range(len(x0)):&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;   print &gt;&gt; f, '%f %f %f %f %f %f'\&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;   % (x0[i], y0[i], x1[i], y1[i], x2[i], y2[i])&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;f.close()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;plot(x0, y0, 'ro', x1, y1, 'go', x2, y2, 'bo')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;savefig('randData.png')&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 51);"&gt;show()&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_a9TRcneUCJM/S4on1EZK90I/AAAAAAAAAUw/C5FJSRhGWxA/s1600-h/randData.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 240px;" src="http://3.bp.blogspot.com/_a9TRcneUCJM/S4on1EZK90I/AAAAAAAAAUw/C5FJSRhGWxA/s320/randData.png" alt="" id="BLOGGER_PHOTO_ID_5443206892296533826" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3982234469946061246?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3982234469946061246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3982234469946061246' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3982234469946061246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3982234469946061246'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/py-random-data-generation-trial.html' title='[Py] Random data generation -- a trial'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_a9TRcneUCJM/S4on1EZK90I/AAAAAAAAAUw/C5FJSRhGWxA/s72-c/randData.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7981836682704210461</id><published>2010-02-27T14:33:00.007+08:00</published><updated>2010-02-27T20:52:16.365+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='screensaver'/><title type='text'>[SW] Two CLI screensavers</title><content type='html'>Actually, I do not use screensavers. I always turn off the monitor when I have to leave my PC for a while. As a CLI fan, however, I am willing to see a CLI screensaver running on my monitor, especially when the screensaver is cool.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.asty.org/cmatrix/"&gt;Cmatrix&lt;/a&gt; is a cool screensaver and it's easy for Ubuntu users to install. Just use the command&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ sudo apt-get install cmatrix&lt;/span&gt;&lt;/blockquote&gt;to get it, and you can have a really Matrix-like screensaver. Looks really cool, doesn't it?&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_a9TRcneUCJM/S4kFLL0G7oI/AAAAAAAAASA/wb3_22wSEVs/s1600-h/cmatrix.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 214px;" src="http://2.bp.blogspot.com/_a9TRcneUCJM/S4kFLL0G7oI/AAAAAAAAASA/wb3_22wSEVs/s320/cmatrix.png" alt="" id="BLOGGER_PHOTO_ID_5442887314362003074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The second one I installed is &lt;a href="http://www.robobunny.com/projects/asciiquarium/html/"&gt;ASCIIQuarium&lt;/a&gt;. I found it on the &lt;a href="http://mostlycli.blogspot.com/"&gt;Mostly CLI&lt;/a&gt; blog (&lt;a href="http://mostlycli.blogspot.com/2008/11/is-that-fish-in-your-cli-asciiquarium.html"&gt;Is that a Fish in Your CLI? The asciiquarium Screensaver.&lt;/a&gt;), which is worth visiting if you are also a CLI fan. Followed the steps, I download the &lt;a href="http://freshmeat.net/projects/termanim/"&gt;Term::Animation&lt;/a&gt; module but got a warning when I runned the ``perl Makefile.PL'' command. The warning message was&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;Warning: prerequisite Curses 1.06 not found.&lt;/span&gt;&lt;/blockquote&gt;Then I tried to find out how to installed the so called ``curses'' in my Ubuntu 8.04, even install the libncurses5-dev (it's not the right one), but got no luky. Then, I noticed that all the packages are related to &lt;a href="http://www.perl.org/"&gt;Perl&lt;/a&gt;! I am not familiar with Perl so I had no clear idea what searching strategy was right. Finally I knew that the libcurses-perl is the key. So if you encounter the same problem I had, please use the following command to install the libcurses-perl package.&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ sudo apt-get install libcurses-perl&lt;/span&gt;&lt;/blockquote&gt;Then here comes the ASCII fishes (as well as other things...).&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_a9TRcneUCJM/S4kT2ERO2xI/AAAAAAAAASI/qnx3bC5fIzE/s1600-h/asciiqurium.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 215px;" src="http://2.bp.blogspot.com/_a9TRcneUCJM/S4kT2ERO2xI/AAAAAAAAASI/qnx3bC5fIzE/s320/asciiqurium.png" alt="" id="BLOGGER_PHOTO_ID_5442903444233837330" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7981836682704210461?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7981836682704210461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7981836682704210461' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7981836682704210461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7981836682704210461'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/sw-cli-screensavers.html' title='[SW] Two CLI screensavers'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_a9TRcneUCJM/S4kFLL0G7oI/AAAAAAAAASA/wb3_22wSEVs/s72-c/cmatrix.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7166246427078164567</id><published>2010-02-21T15:28:00.005+08:00</published><updated>2010-02-21T15:46:46.457+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mutt'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[SW] Mutt usage and setting -- with Gmail</title><content type='html'>Thank &lt;a href="http://www.andrews-corner.org/index.html"&gt;Andrew&lt;/a&gt;! I followed his blog article and finally make &lt;a href="http://www.mutt.org/"&gt;Mutt&lt;/a&gt; work with Gmail!&lt;br /&gt;&lt;br /&gt;Here is the excellent instruction for newbies who want to try Mutt but have no idea how to to:&lt;br /&gt;&lt;a href="http://www.andrews-corner.org/mutt.html"&gt;Using Mutt with Gmail&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I have changed some settings for the inbox folder from&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family:courier new;"&gt;/var/spool/mail/your_username&lt;/span&gt;&lt;br /&gt;to&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="font-family:courier new;"&gt;$HOME/mail/inbox&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Although there are more things I need to learn, Andrew's guidance has given a good start. Hope you can benefit from this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7166246427078164567?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7166246427078164567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7166246427078164567' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7166246427078164567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7166246427078164567'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/sw-mutt-usage-and-setting-with-gmail.html' title='[SW] Mutt usage and setting -- with Gmail'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2669037397532538686</id><published>2010-02-19T16:48:00.005+08:00</published><updated>2010-02-19T17:27:58.807+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rhythmbox'/><category scheme='http://www.blogger.com/atom/ns#' term='quod libet'/><title type='text'>[SW] Rhythmbox and Quod Libet don't play music</title><content type='html'>I have used &lt;a href="http://projects.gnome.org/rhythmbox/"&gt;Rhythombox&lt;/a&gt; and &lt;a href="http://code.google.com/p/quodlibet/"&gt;Quod Libet&lt;/a&gt; for listening to music, podcast, and internet radio. But I didn't listen to music on my PC for a while, and these days I encountered a problem when I used Rhythombox and Quod Libet to open my music files. Both of them cannot play the ogg files. I tried to remove and reinstall them, but it didn't work.&lt;br /&gt;&lt;br /&gt;Finally, I found &lt;a href="https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/243432/comments/8"&gt;a post&lt;/a&gt; from ``&lt;a href="https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/243432"&gt;rhythmbox : does not play the songs at times. When I click play song, no response&lt;/a&gt;''.&lt;br /&gt;&lt;br /&gt;So the solution is to change the sound setting to &lt;a href="http://www.alsa-project.org/main/index.php/Main_Page"&gt;ALSA&lt;/a&gt;. The problem for me now is that I don't remember why I changed the sound setting to &lt;a href="http://pulseaudio.org/"&gt;PulseAudio&lt;/a&gt;...&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_a9TRcneUCJM/S35ZOqGURaI/AAAAAAAAAR0/4AE2rl8FNa8/s1600-h/SoundPreferences.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 202px;" src="http://3.bp.blogspot.com/_a9TRcneUCJM/S35ZOqGURaI/AAAAAAAAAR0/4AE2rl8FNa8/s320/SoundPreferences.png" alt="" id="BLOGGER_PHOTO_ID_5439883508263962018" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2669037397532538686?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2669037397532538686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2669037397532538686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2669037397532538686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2669037397532538686'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/sw-rhythmbox-and-quod-libet-dont-play.html' title='[SW] Rhythmbox and Quod Libet don&apos;t play music'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_a9TRcneUCJM/S35ZOqGURaI/AAAAAAAAAR0/4AE2rl8FNa8/s72-c/SoundPreferences.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-460010266737927296</id><published>2010-02-19T16:05:00.004+08:00</published><updated>2010-02-19T16:16:55.535+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='okular'/><title type='text'>[SW] Invert the documents colors in Okular</title><content type='html'>I prefer viewing documents in black background with white text, just as what is usual in the command line environment. It seems no color inverting function in Evince, so I have to use Okular to satisfied my own requirement.&lt;br /&gt;&lt;br /&gt;Open your PDF file with Okular, and follow Settings --&gt; Configure okular to open the following dialog.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_a9TRcneUCJM/S35Hf7HNX5I/AAAAAAAAARU/gRFS2XU_gS0/s1600-h/okular_change_colors.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 216px;" src="http://1.bp.blogspot.com/_a9TRcneUCJM/S35Hf7HNX5I/AAAAAAAAARU/gRFS2XU_gS0/s320/okular_change_colors.png" alt="" id="BLOGGER_PHOTO_ID_5439864013679583122" border="0" /&gt;&lt;/a&gt;Check the ``Chenge Colors'' box and choose ``Invert colors'' of the color mode. Looks great!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_a9TRcneUCJM/S35It3tIhsI/AAAAAAAAARc/9W63vjRq5ho/s1600-h/okular_original.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 142px;" src="http://4.bp.blogspot.com/_a9TRcneUCJM/S35It3tIhsI/AAAAAAAAARc/9W63vjRq5ho/s200/okular_original.png" alt="" id="BLOGGER_PHOTO_ID_5439865352794703554" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_a9TRcneUCJM/S35IzIRRAdI/AAAAAAAAARk/fyNi4Lr0cgY/s1600-h/okular_inverted.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 200px; height: 142px;" src="http://2.bp.blogspot.com/_a9TRcneUCJM/S35IzIRRAdI/AAAAAAAAARk/fyNi4Lr0cgY/s200/okular_inverted.png" alt="" id="BLOGGER_PHOTO_ID_5439865443140567506" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-460010266737927296?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/460010266737927296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=460010266737927296' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/460010266737927296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/460010266737927296'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/sw-invert-documents-colors-in-okular.html' title='[SW] Invert the documents colors in Okular'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_a9TRcneUCJM/S35Hf7HNX5I/AAAAAAAAARU/gRFS2XU_gS0/s72-c/okular_change_colors.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2722428257802704125</id><published>2010-02-19T15:29:00.007+08:00</published><updated>2010-02-26T00:28:10.048+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='okular'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[SW] Invoke Okular from the command line -- use soft symbolic link</title><content type='html'>I have installed &lt;a href="http://okular.kde.org/"&gt;Okular&lt;/a&gt; in my Ubuntu for several months and appreciated its annotation functions which allow me more freedom with my own documents. When I want to invoke Okular from the command line, however, it cannot be found by the system. After some investigations, the &lt;a href="http://en.wikipedia.org/wiki/Symbolic_link"&gt;symbolic link&lt;/a&gt; seems to be the handiest solution.&lt;br /&gt;&lt;br /&gt;Go to &lt;span style="font-family:courier new;"&gt;/usr/bin&lt;/span&gt; and use ln to make a symbolic link:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ sudo ln -s /usr/lib/kde4/bin/okular okular &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is my first time to use ln, and it works as expectation. :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2722428257802704125?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2722428257802704125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2722428257802704125' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2722428257802704125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2722428257802704125'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/qna-invoke-okular-from-command-line-use.html' title='[SW] Invoke Okular from the command line -- use soft symbolic link'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5701145441418482782</id><published>2010-02-12T09:43:00.005+08:00</published><updated>2010-02-19T16:04:47.537+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OpenOffice'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] How to import html tables into the OO Calc?</title><content type='html'>I am working on patent search these days (and it's really a terrible task, at least for me). With some assistant tools I got a downloaded list of the patents I've found, and this list has been given with a &lt;a href="http://en.wikipedia.org/wiki/Microsoft_Excel_file_format#File_formats"&gt;xls&lt;/a&gt; filename extension. The xls file works fine with MS Excel but not &lt;a href="http://www.openoffice.org/product/calc.html"&gt;OO Calc&lt;/a&gt;. When I tried to open the xls file in my Ubuntu, it showed as a text file with gedit with some html tags in the content. So the xls file was essentially a html table file, and OO Calc just cannot open the file directly.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://dag.wieers.com/home-made/unoconv/"&gt;unoconv&lt;/a&gt; was the first possible solution I found. It can convert between formats that supported by OpenOffice. The command line usage is simple, just define the ouput format as the following&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ unoconv -f ods originalfile.html&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;and the unoconv gives the output file with assigned format (originalfile.ods in this example). However, when I tried to open the converted ods file with OO Calc, nothing happened, the OO Calc didn't open anything and showed only empty content.&lt;br /&gt;&lt;br /&gt;Luckily, another simpler solution has been there. &lt;span style="font-weight: bold;"&gt;Just utilize the import function provided by OO Calc itself to import the html table&lt;/span&gt;, then everything goes smoothly. You can find the function in ``Insert/Link to External Data'' and it comes up a dialog for choosing your file.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;a href="http://www.openofficetips.com/blog/archives/2004/10/webquery_import.html"&gt;OpenOffice Calc Tips: Webquery : Importing HTML tables&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5701145441418482782?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5701145441418482782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5701145441418482782' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5701145441418482782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5701145441418482782'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/qna-how-to-import-html-tables-into-oo.html' title='[SW] How to import html tables into the OO Calc?'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-7563547496898099403</id><published>2010-02-09T14:27:00.002+08:00</published><updated>2010-02-09T14:35:42.113+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tool'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[QnA] Convert MOD to AVI using transcode -- without audio ouput</title><content type='html'>Sometimes we might take videos with some environmental noise or conversations which are not suitable to be heard by others. Also, we don't need or want to add other audio into the original video, so just export the video without audio is fine enough.&lt;br /&gt;&lt;br /&gt;I had some MOD files to be converted by &lt;a href="http://hiankun.blogspot.com/2009/08/qna-convert-mod-to-avi-using-transcode.html"&gt;using transcode before&lt;/a&gt;, and this time I want to export my MOD files into avi files with no sound. It's can be done by apply the ``null'' option as the following&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;transcode -i input.MOD -y xvid&lt;span style="font-weight: bold; color: rgb(102, 0, 204);"&gt;,null&lt;/span&gt; -o output.avi&lt;br /&gt;&lt;br /&gt;That's all.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-7563547496898099403?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/7563547496898099403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=7563547496898099403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7563547496898099403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/7563547496898099403'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/02/qna-convert-mod-to-avi-using-transcode.html' title='[QnA] Convert MOD to AVI using transcode -- without audio ouput'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6518425804101866933</id><published>2010-01-08T23:34:00.005+08:00</published><updated>2010-01-12T09:31:36.842+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='DiveIntoPython'/><title type='text'>[Py] Problems of XML processing (Dive Into Python)</title><content type='html'>I am learning how to parse XML content with Python, and the tutorial I've followed is the &lt;a href="http://diveintopython.org/"&gt;Dive Into Python&lt;/a&gt;. In Chapter 9, most of the examples are clear for a newbie to follow. When I tried the example 9.10 (toxml works on any node), however, unexpected results occurred.&lt;br /&gt;&lt;br /&gt;Fortunately, someone had the same problem and there is a solution: &lt;a href="http://mail.python.org/pipermail/python-list/2006-July/1066076.html"&gt;Possible error in 'dive into Python' book, help!&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The key point is to use &lt;span style="font-weight: bold;"&gt;documentElement&lt;/span&gt; instead of &lt;span style="font-weight: bold;"&gt;firstChild&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;I don't realize the reason yet. More study is necessary for me to understand the whole idea.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://docs.python.org/library/xml.dom.html"&gt;xml.dom&lt;/a&gt; — The Document Object Model API&lt;/li&gt;&lt;li&gt;Python and XML: &lt;a href="http://www.boddie.org.uk/python/XML_intro.html"&gt;An Introduction&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6518425804101866933?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6518425804101866933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6518425804101866933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6518425804101866933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6518425804101866933'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2010/01/py-problems-of-xml-processing-dive-into.html' title='[Py] Problems of XML processing (Dive Into Python)'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3743845760065343844</id><published>2009-12-31T23:05:00.005+08:00</published><updated>2009-12-31T23:39:00.662+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='Debian'/><category scheme='http://www.blogger.com/atom/ns#' term='SCIM'/><title type='text'>[QnA] SCIM setting in Debian.. again...</title><content type='html'>I installed the Debian in one of my PC, but then reinstalled it to give a disk space for the &lt;a href="http://www.linuxfromscratch.org/"&gt;LFS&lt;/a&gt;. After the reinstallation, I forgot how to install and set up the SCIM... AGAIN... I even forgot I've had an article about this issue in my own blog &lt;a href="http://hiankun.blogspot.com/2009/09/qna-scim-setting-in-debian.html"&gt;HERE&lt;/a&gt;. Orz&lt;br /&gt;&lt;br /&gt;This time, my procedures are the follows:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# apt-get install scim scim-chinese scim-tables-zh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# vim /etc/X11/Xsession.d/95xinput&lt;/span&gt;&lt;br /&gt;&lt;blockquote&gt;/usr/bin/scim -d&lt;br /&gt;XMODIFIERS="@im=SCIM"&lt;br /&gt;export XMODIFIERS&lt;/blockquote&gt;And didn't get what I want, so I kept tring&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# vim /etc/X11/xinit/xinput.d/all_ALL&lt;/span&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;XMODIFIERS="@im=SCIM"&lt;br /&gt;GTK_IM_MODULE="scim"&lt;br /&gt;QT_IM_MODULE="scim"&lt;/blockquote&gt;Then the SCIM setting had been completed.&lt;br /&gt;&lt;br /&gt;Finally, I installed the Japanese and Chinese imput methods to which I used.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# aptitude install scim-anthy scim-chewing&lt;br /&gt;&lt;br /&gt;(Later, I removed &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;/etc/X11/Xsession.d/95xinput, and everything works well so far.&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;)&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3743845760065343844?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3743845760065343844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3743845760065343844' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3743845760065343844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3743845760065343844'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/12/qna-scim-setting-in-debian-again.html' title='[QnA] SCIM setting in Debian.. again...'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8036047822144596641</id><published>2009-11-14T20:09:00.007+08:00</published><updated>2010-03-18T15:27:10.875+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='framebuffer'/><category scheme='http://www.blogger.com/atom/ns#' term='ImageMagick'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[QnA] Taking screenshots of virtual consoles?</title><content type='html'>I am trying to find ways to take screenshots of virtual consoles. This &lt;a href="http://www.detector-pro.com/2009/01/linux-tip-how-to-take-screenshot.html"&gt;&lt;span style="text-decoration: underline;"&gt;article&lt;/span&gt;&lt;/a&gt; shows the method of taking screenshots from console using the &lt;a href="http://www.imagemagick.org/script/index.php"&gt;ImageMagick&lt;/a&gt;. The author said that the method also works for consoles with the command as the follows&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);font-family:courier new;" &gt;$ sudo chvt N; sleep T; import -display :0.0 -window root output.png; sudo chvt M&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;where N is the target console and T is the time in seconds. The last chvt command is just for returning the original working console.&lt;br /&gt;&lt;br /&gt;After testing with the command, however, I found the png file was generated but the image itself is not what I expected. At the beginning I thought that might due to my framebuffer setting so I disabled the corresponding setting in the /boot/grub/menu.lst. Nothing has been improved and I still can only get the following useless image.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_a9TRcneUCJM/Sv6eL8k3XjI/AAAAAAAAAQA/GGC9F6kzS1w/s1600-h/test.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 300px;" src="http://3.bp.blogspot.com/_a9TRcneUCJM/Sv6eL8k3XjI/AAAAAAAAAQA/GGC9F6kzS1w/s400/test.png" alt="" id="BLOGGER_PHOTO_ID_5403930530967674418" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8036047822144596641?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8036047822144596641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8036047822144596641' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8036047822144596641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8036047822144596641'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/qna.html' title='[QnA] Taking screenshots of virtual consoles?'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_a9TRcneUCJM/Sv6eL8k3XjI/AAAAAAAAAQA/GGC9F6kzS1w/s72-c/test.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6883875521904964736</id><published>2009-11-14T19:42:00.004+08:00</published><updated>2009-11-14T20:09:17.340+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='framebuffer'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><title type='text'>[QnA] FrameBuffer setting</title><content type='html'>Several months ago, I learned the way to view images in the virtual console. I happened to recall the framebuffer and want to know more about it, so I began to search related information again.&lt;br /&gt;&lt;br /&gt;Here are several informative web pages:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://mostlycli.blogspot.com/2007/09/images-and-videos-on-command-line-yes.html"&gt;Images and Videos on the Command Line? YES!&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://tldp.org/HOWTO/Framebuffer-HOWTO-5.html"&gt;Using framebuffer devices on Intel platforms&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="https://wiki.ubuntu.com/FrameBuffer"&gt;Ubuntu wiki: FrameBuffer&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;pre&gt;In the 2nd web page, there is a table showing the values for different resolution as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;Colours   640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;--------+--------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt; 4 bits |    ?       ?     0x302      ?        ?        ?         ?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt; 8 bits |  0x300   0x301   0x303    0x305    0x161    0x307     0x31C&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;15 bits |    ?     0x310   0x313    0x316    0x162    0x319     0x31D&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;16 bits |    ?     0x311   0x314    0x317    0x163    0x31A     0x31E&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;24 bits |    ?     0x312   0x315    0x318      ?      0x31B     0x31F&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(0, 0, 153);"&gt;32 bits |    ?       ?       ?        ?      0x164      ?&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;Furthermore, from the 3rd reference I found more useful setting such as&lt;br /&gt;&lt;ul&gt;&lt;li&gt;``vga=normal'', or ``nofb'', disables the framebuffer &lt;/li&gt;&lt;li&gt;``vga=ask'' will able you to set a value at each boot good for testing out the various modes. &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6883875521904964736?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6883875521904964736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6883875521904964736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6883875521904964736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6883875521904964736'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/qna-framebuffer-setting.html' title='[QnA] FrameBuffer setting'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-4845678822074458129</id><published>2009-11-13T22:36:00.004+08:00</published><updated>2009-11-13T23:30:06.787+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='wmii'/><title type='text'>[QnA] Sound volume control in command line</title><content type='html'>I've used &lt;a href="http://wmii.suckless.org/"&gt;wmii&lt;/a&gt; for several weeks, and it meets most of my need well. Sometimes, however, I want to control the volume but there is no the control panel as in the Gnome desktop environment.&lt;br /&gt;&lt;br /&gt;Here is the solution: amixer (or alsamixer, which has the &lt;a href="http://www.gnu.org/software/ncurses/ncurses.html"&gt;ncurses&lt;/a&gt; interface).&lt;br /&gt;&lt;br /&gt;To use alsamixer is easier due to the straightforward interface. If you get the following error message when you type ``alsamixer'' in the command&lt;br /&gt;&lt;blockquote&gt;alsamixer: function snd_ctl_open failed for default: Connection refused&lt;/blockquote&gt;then do the following steps:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;$ rm ~/.asoundrc and then do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ asoundconf list&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt; $ asoundconf set-default-card foo&lt;/span&gt;&lt;/blockquote&gt;where the foo is one of the sound cards listed by `asoundconf list.'&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref:&lt;br /&gt;&lt;a href="http://ubuntuforums.org/showthread.php?t=597765"&gt;http://ubuntuforums.org/showthread.php?t=597765&lt;/a&gt;&lt;br /&gt;&lt;a href="http://ubuntuforums.org/showpost.php?p=3631606&amp;amp;postcount=4"&gt;http://ubuntuforums.org/showpost.php?p=3631606&amp;amp;postcount=4&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-4845678822074458129?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/4845678822074458129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=4845678822074458129' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4845678822074458129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/4845678822074458129'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/qna-sound-volume-control-in-command.html' title='[QnA] Sound volume control in command line'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-6141651398933454884</id><published>2009-11-12T11:59:00.002+08:00</published><updated>2009-11-12T12:03:22.277+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Big5 and utf-8 in Vim</title><content type='html'>To make Vim open big5 files properly, just set the following&lt;br /&gt;&lt;pre&gt;set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1&lt;br /&gt;set encoding=utf8&lt;br /&gt;set tenc=utf8&lt;br /&gt;&lt;/pre&gt;---&lt;br /&gt;Ref: &lt;a href="http://wiki.debian.org.tw/index.php/Unicode#VIM"&gt;http://wiki.debian.org.tw/index.php/Unicode#VIM&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-6141651398933454884?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/6141651398933454884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=6141651398933454884' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6141651398933454884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/6141651398933454884'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/sw-big5-and-utf-8-in-vim.html' title='[SW] Big5 and utf-8 in Vim'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8204437044361503216</id><published>2009-11-05T11:17:00.003+08:00</published><updated>2010-01-09T00:03:08.225+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Equal sign</title><content type='html'>&lt;a href="http://linux.byexamples.com/archives/350/python-careful-with-equal-sign/"&gt;Python: Careful with equal sign&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I found this article when I was searching for the information about comparisons in Python.&lt;br /&gt;&lt;br /&gt;When we assign a variable to another, for example, a = 1; b = a, Python just passes the reference (of variable a) to the new one (i.e., the variable b) but not creates a new copy with new memory address.&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt; a = 1&lt;br /&gt;&gt;&gt;&gt; b = a&lt;br /&gt;&gt;&gt;&gt; id(a) == id(b)&lt;br /&gt;&gt;&gt;&gt; True&lt;br /&gt;&lt;br /&gt;But if we change the value of b, then a new memory block will be used to store the new assigned value.&lt;br /&gt;&lt;br /&gt;&gt;&gt;&gt; b = 2&lt;br /&gt;&gt;&gt;&gt; id(a) == id(b)&lt;br /&gt;&gt;&gt;&gt; False&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8204437044361503216?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8204437044361503216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8204437044361503216' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8204437044361503216'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8204437044361503216'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/py-equal-sign.html' title='[Py] Equal sign'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-417943921268133543</id><published>2009-11-05T11:03:00.005+08:00</published><updated>2010-01-09T00:04:38.434+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Comparisons -- ``=='' vs. ``is''</title><content type='html'>In Python, there two operators which check whether things are the same. One is ``=='' and another is ``is.'' They may produce identical results but actually they have different meanings.&lt;br /&gt;&lt;br /&gt;I found an article talked about this: &lt;a href="http://www.peterbe.com/plog/is-equal-in-python"&gt;is is not the same as equal in Python&lt;/a&gt;&lt;a href="http://docs.python.org/library/stdtypes.html#comparisons"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The simple guideline has been given by Eric:&lt;br /&gt;&lt;span class="commenttext"&gt;&lt;blockquote&gt;You should really only use 'is' to check for object identity, and for any kind of value comparison, == is the way to go.&lt;/blockquote&gt;And an interesting example has been given by Kevin:&lt;br /&gt;&lt;/span&gt;&lt;span class="commenttext"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span class="commenttext"&gt;&gt;&gt;&gt; "peter" == "peter"&lt;br /&gt;&gt;&gt;&gt; True&lt;br /&gt;&gt;&gt;&gt; "peter" is "peter"&lt;br /&gt;&gt;&gt;&gt; True&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="commenttext"&gt;&gt;&gt;&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="commenttext"&gt;"peter" is "peter1"[:-1]&lt;br /&gt;&gt;&gt;&gt; False&lt;br /&gt;&gt;&gt;&gt; "peter" == "peter1"[:-1]&lt;/span&gt;&lt;br /&gt;&gt;&gt;&gt;True&lt;/blockquote&gt;---&lt;br /&gt;ref: Python built-in types: &lt;a href="http://docs.python.org/library/stdtypes.html#comparisons"&gt;comparison&lt;/a&gt;&lt;br /&gt;&lt;span class="commenttext"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-417943921268133543?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/417943921268133543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=417943921268133543' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/417943921268133543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/417943921268133543'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/py-comparisons-vs-is.html' title='[Py] Comparisons -- ``==&apos;&apos; vs. ``is&apos;&apos;'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2028623885002304369</id><published>2009-11-05T08:30:00.002+08:00</published><updated>2009-11-05T08:44:10.039+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>[Py] Guidelines for Python coding style</title><content type='html'>Here are two links about the Python coding style:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.python.org/dev/peps/pep-0008/"&gt;Style Guide for Python Code&lt;/a&gt; (by Guido van Rossum and Barry Warsaw)&lt;/li&gt;&lt;li&gt;&lt;a href="http://jaynes.colorado.edu/PythonGuidelines.html"&gt;Python Coding Guidelines&lt;/a&gt; (by Rob Knight)&lt;/li&gt;&lt;/ul&gt;One thing I've never noticed is the indentation problem. Python relies on consistent indentation of code blocks, so if the programmer mixed spaces and tabs in the code there could be problems when others open or edit the code with other editors with different tab setting.&lt;br /&gt;&lt;br /&gt;The above links give many information that I cannot read throughly in limited time, but they have offered me some useful guidelines to follow in the future.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2028623885002304369?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2028623885002304369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2028623885002304369' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2028623885002304369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2028623885002304369'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/py-guidelines-for-python-coding-style.html' title='[Py] Guidelines for Python coding style'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-2499791514429553525</id><published>2009-11-03T15:12:00.002+08:00</published><updated>2009-11-03T15:19:31.321+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='mount'/><title type='text'>[QnA] Cannot mount disk -- you are not privileged to mount volume</title><content type='html'>One of my Windows XP disk partition happened to be unmountable and I totally didn't know why. I've set the auto mounting in /etc/fstab and it has worked well till today.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.steveify.com/ubuntu/ubuntu-problem-you-are-not-privileged-to-mount-volume/"&gt;To solve this problem&lt;/a&gt;, use:&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$sudo mount -t ntfs-3g /dev/&lt;span style="font-family: times new roman;"&gt;yourdevice&lt;/span&gt; /media/&lt;span style="font-family: times new roman;"&gt;yourfolder&lt;/span&gt; -o force&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-2499791514429553525?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/2499791514429553525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=2499791514429553525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2499791514429553525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/2499791514429553525'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/qna-cannot-mount-disk-you-are-not.html' title='[QnA] Cannot mount disk -- you are not privileged to mount volume'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-49574264769505102</id><published>2009-11-03T08:41:00.002+08:00</published><updated>2009-11-03T08:50:11.398+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='GPG'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>[QnA] GPG error -- the solution</title><content type='html'>When the Ubuntu users update and upgrade their system, there are, sometimes, GPG error messages shown in the GUI dialog or command line terminal.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://ubuntuforums.org/showthread.php?t=1046158"&gt;Here are a solution&lt;/a&gt; I've found useful and easy (only two steps):&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ gpg --keyserver keyserver.ubuntu.com --recv &lt;span style="font-family:times new roman;"&gt;put_the_last_8_digits_of_the_key_here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ gpg --export --armor &lt;span style="font-family:times new roman;"&gt;put_the_last_8_digits_of_the_key_here&lt;/span&gt; | sudo apt-key add -&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Some other related links (for backup and reference):&lt;br /&gt;&lt;a href="https://answers.launchpad.net/easyubuntu/+question/73458"&gt;https://answers.launchpad.net/easyubuntu/+question/73458&lt;/a&gt;&lt;br /&gt;&lt;a href="https://answers.launchpad.net/ubuntu/+question/73171"&gt;https://answers.launchpad.net/ubuntu/+question/73171&lt;/a&gt;&lt;br /&gt;&lt;a href="http://kovyrin.net/2006/11/28/debian-problem-apt-get-update/"&gt;http://kovyrin.net/2006/11/28/debian-problem-apt-get-update/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-49574264769505102?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/49574264769505102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=49574264769505102' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/49574264769505102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/49574264769505102'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/11/qna-gpg-error-solution.html' title='[QnA] GPG error -- the solution'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-1701787582552886165</id><published>2009-10-26T15:10:00.004+08:00</published><updated>2009-10-26T16:11:58.994+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Learning Lsip using Vim as the editor</title><content type='html'>I prefer Vim to Emacs. One day, I happened to be curious about Lisp, and then found the page ``&lt;a href="http://gigamonkeys.com/book/"&gt;Practical Common Lisp&lt;/a&gt;.'' The so-called ``programming environment'' confused me. Furthermore, Emacs seems to be the standard (or mainstream) editor/environment for the Lisp programming.&lt;br /&gt;&lt;br /&gt;I've set the Emacs and SLIME for a try, but it's not easy for me to remember the key stroking in Emacs. So I also found some approaches to let me learning Lisp with my beloved Vim.&lt;br /&gt;&lt;br /&gt;The first approach I found was: &lt;a href="http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/"&gt;slime.vim&lt;/a&gt;, but I do neither understand the script nor the steps. After trying and trying, I gave it up.&lt;br /&gt;&lt;br /&gt;The second approach is to install the &lt;a href="http://www.vim.org/scripts/script.php?script_id=2219"&gt;Limp&lt;/a&gt;, a plugin for Vim. It does not work identically to what has shown on the &lt;a href="http://mikael.jansson.be/hacking/limp/docs/"&gt;web page&lt;/a&gt;, but it seems not bad and simple enough for me.&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;(Maybe my problems are due to my poor understanding of how Lisp works.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-1701787582552886165?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/1701787582552886165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=1701787582552886165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1701787582552886165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/1701787582552886165'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/10/sw-learning-lsip-using-vim-as-editor.html' title='[SW] Learning Lsip using Vim as the editor'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-3579725569833578027</id><published>2009-10-26T13:21:00.003+08:00</published><updated>2009-10-26T13:29:23.705+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><title type='text'>[SW] Emacs and SLIME for Common Lisp</title><content type='html'>I am not familiar with &lt;a href="http://www.gnu.org/software/emacs/"&gt;Emacs&lt;/a&gt;, but I still tried to install Emacs as well as &lt;a href="http://common-lisp.net/project/slime/"&gt;SLIME&lt;/a&gt; for trial.&lt;br /&gt;&lt;br /&gt;Here are simple steps for setting all these up:&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 51, 255);"&gt;$ sudo apt-get install clisp emacs slime sbcl cl-asdf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then, in the .emacs file:&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 51, 255);"&gt;(setq inferior-lisp-program "/usr/bin/sbcl")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 51, 255);"&gt;(add-to-list 'load-path "/usr/share/common-lisp/source/slime/")&lt;/span&gt;&lt;br /&gt; &lt;span style="font-family: courier new; color: rgb(51, 51, 255);"&gt;(require 'slime)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new; color: rgb(51, 51, 255);"&gt; (slime-setup)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br /&gt;Ref: &lt;a href="http://functionalrants.wordpress.com/2008/09/06/how-to-set-up-emacs-slime-sbcl-under-gnulinux/"&gt;How to set up Emacs + SLIME + SBCL under GNU/Linux&lt;br /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-3579725569833578027?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/3579725569833578027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=3579725569833578027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3579725569833578027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/3579725569833578027'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/10/sw-emacs-and-slime-for-common-lisp.html' title='[SW] Emacs and SLIME for Common Lisp'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-5674278738004101403</id><published>2009-10-26T09:01:00.001+08:00</published><updated>2009-10-26T09:05:11.180+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><category scheme='http://www.blogger.com/atom/ns#' term='CLI'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>[QnA] Using the terminal in Ubuntu -- simple but useful commands</title><content type='html'>Here is a web page for newbies: &lt;a href="https://help.ubuntu.com/community/UsingTheTerminal"&gt;UseingTheTerminal&lt;/a&gt;. Most of the commands are simple but could be useful in daily operation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-5674278738004101403?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/5674278738004101403/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=5674278738004101403' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5674278738004101403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/5674278738004101403'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/10/qna-using-terminal-in-ubuntu-simple-but.html' title='[QnA] Using the terminal in Ubuntu -- simple but useful commands'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21954772.post-8972475714895266490</id><published>2009-10-25T19:39:00.029+08:00</published><updated>2010-05-26T21:25:11.001+08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='QnA'/><title type='text'>[SW] Taglist -- a Vim plugin for browsing the source code</title><content type='html'>To make Vim handier for programming, the &lt;a href="http://www.vim.org/scripts/script.php?script_id=273"&gt;taglist&lt;/a&gt; is a good choice. It works with &lt;a href="http://ctags.sourceforge.net/"&gt;Exuberant Ctags&lt;/a&gt; to make you browse the variables, functions, or classes of the source code easily.&lt;br /&gt;&lt;br /&gt;Just make sure you have installed Exuberant Ctags:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;$ sudo apt-get install exuberant-ctags&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It's a good idea to set hot-key to toggle the TlistToggle function (use &amp;#x3C;F12&amp;#x3E; as the example):&lt;br /&gt;&lt;face="courier new"&gt;&lt;s&gt;nnoremap :TlistToggle&lt;/s&gt;&lt;br /&gt;nnoremap &amp;#x3C;F12&amp;#x3E; :TlistToggle &amp;#x3C;CR&amp;#x3E;&lt;/face="courier&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21954772-8972475714895266490?l=hiankun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hiankun.blogspot.com/feeds/8972475714895266490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21954772&amp;postID=8972475714895266490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8972475714895266490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21954772/posts/default/8972475714895266490'/><link rel='alternate' type='text/html' href='http://hiankun.blogspot.com/2009/10/sw-taglist-vim-plugin-for-browsing.html' title='[SW] Taglist -- a Vim plugin for browsing the source code'/><author><name>THK</name><uri>http://www.blogger.com/profile/10803822820165706025</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_a9TRcneUCJM/S_x-YzuuL0I/AAAAAAAAAYM/9tVrjlbkYi0/S220/logo_thk.png'/></author><thr:total>0</thr:total></entry></feed>
