<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DUEDRno-fip7ImA9WxNUEUo.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413</id><updated>2009-11-03T00:01:17.456+08:00</updated><title>Thoughts in Air</title><subtitle type="html">Thoughts on programming, gadgets, and more...</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://yujianzhang.blogspot.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>39</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><geo:lat>39.55</geo:lat><geo:long>116.20</geo:long><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/2.0/" /><link rel="self" href="http://feeds.feedburner.com/yujian" type="application/atom+xml" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fyujian" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/yujian" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fyujian" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fyujian" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry gd:etag="W/&quot;C0AHRHoyeyp7ImA9WxVXE04.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2279269894005734058</id><published>2009-01-01T21:31:00.003+08:00</published><updated>2009-02-11T13:55:35.493+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-11T13:55:35.493+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sbcl" /><category scheme="http://www.blogger.com/atom/ns#" term="stumpwm" /><title>Upgrading SBCL</title><content type="html">&lt;p&gt;Recently I upgraded SBCL from version 1.0.22 to
1.0.23. Then my window
manager, &lt;a href="http://yujianzhang.blogspot.com/2008/07/experiencing-stumpwm.html"&gt;Stumpwm&lt;/a&gt;
refused to start. I have to solve the issue, otherwise I will start
using console exclusively starting from 2009.&lt;/p&gt;

&lt;p&gt;My first reaction was to reinstall stumpwm package. But when
compiling, SBCL is complaining that there are version mismatch for
stumpwm dependencies. I tried to solve the issue by reinstalling that
package, but I met the same problem for its dependencies. I realized
that I just stumbled upon dependency hell. I don't want to go through
the same process of installing every CL package when I upgrade
SBCL. So I need to find one simple solution. Indeed it exists: just
delete all *.fasl files in SBCL's site directory (which
is &lt;em&gt;/usr/lib/sbcl/site&lt;/em&gt; under Arch Linux.), and then SBCL will
rebuild all the installed packages. So the following command just
solves the problem (assuming Arch Linux).&lt;/p&gt;

&lt;pre class="code"&gt;
find /usr/lib/sbcl/site -name &lt;span class="string"&gt;"*.fasl"&lt;/span&gt; -delete
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; (2009-2-11): do &lt;strong&gt;NOT&lt;/strong&gt; run above command on the parent
directory &lt;em&gt;/usr/lib/sbcl&lt;/em&gt;, otherwise the fasl files bundled with SBCL will be deleted 
and many functionalities (e.g. ASDF) will break.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2279269894005734058?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=kBb0-4txNXM:77Y0XmZblaY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=kBb0-4txNXM:77Y0XmZblaY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=kBb0-4txNXM:77Y0XmZblaY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=kBb0-4txNXM:77Y0XmZblaY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=kBb0-4txNXM:77Y0XmZblaY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=kBb0-4txNXM:77Y0XmZblaY:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/kBb0-4txNXM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2279269894005734058/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2009/01/upgrading-sbcl.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2279269894005734058?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2279269894005734058?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/kBb0-4txNXM/upgrading-sbcl.html" title="Upgrading SBCL" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2009/01/upgrading-sbcl.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0INQHo4eSp7ImA9WxVTFU0.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-3043190908786333499</id><published>2008-12-24T20:37:00.001+08:00</published><updated>2008-12-29T08:13:11.431+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-29T08:13:11.431+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="photo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="imagemagick" /><title>Adjusting Photos for Web Albums in Batch Mode</title><content type="html">&lt;p&gt;I use Picasa Web Album to
store &lt;a href="http://picasaweb.google.com/yujian.zhang"&gt;my photos
online&lt;/a&gt;. To save the precious storage at server, I have to change
jpeg files before uploading them even for those taken by my old
PowerShot S30 (which outputs photos with resolution 2048x1536, which
is beyond the display capacity of most monitors today). To reduce file
size, one normally need to reduce both resolution and image
quality.&lt;/p&gt;

&lt;p&gt;So how to adjust images in batch mode? There are various solutions
of course. The one I take is to use the combination of
find/xargs/mogrify (Note that &lt;em&gt;mogrify&lt;/em&gt; modifies files in
place. Therefore one may use &lt;em&gt;convert&lt;/em&gt; instead of
&lt;em&gt;mogrify&lt;/em&gt; to preserve original files.) in Linux. Note that
mogrify is one of ImageMagick utilities and may need separate
installation depending on distribution. Following is my work flow when
publishing images online.&lt;/p&gt;

&lt;p&gt;Firstly, I select images with my preferred viewer
&lt;em&gt;gthumb&lt;/em&gt;. Images are rotated if necessary. During browsing, I
copy the chosen files to another folder and run the following command
in that folder:&lt;/p&gt;

&lt;kbd&gt;find . -iname "*.jpg" | xargs mogrify -resize
&lt;em&gt;resize-option&lt;/em&gt; -quality &lt;em&gt;quality-option&lt;/em&gt;&lt;/kbd&gt;

&lt;p&gt;(I find the above command from &lt;a
href="http://www.perturb.org/display/entry/632/"&gt;here&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;Several notes regarding the above command:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;resize-option&lt;/em&gt; could be either absolute (e.g. &lt;em&gt;800x600&lt;/em&gt;)
  or relative (e.g. &lt;em&gt;50%&lt;/em&gt;). For my S30, I use the latter which
  reduce the photo resolution to 1/4 of its original size.
  &lt;/li&gt;
  &lt;li&gt;&lt;em&gt;quality-option&lt;/em&gt; is JPEG compression level. The larger
  the value, the better the quality, but the larger the file size. I often
  set the value as &lt;em&gt;60&lt;/em&gt; to save space.
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So for photos from my S30, I use the following command:&lt;/p&gt;

&lt;kbd&gt;find . -iname "*.jpg" | xargs mogrify -resize 50%
-quality 60&lt;/kbd&gt;

&lt;p&gt;After running above command, photo file size can be reduced around 10
times. This means that I can put more images into my web album.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-3043190908786333499?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=_5-y8ydlmwU:OIa35r8t1Ow:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=_5-y8ydlmwU:OIa35r8t1Ow:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=_5-y8ydlmwU:OIa35r8t1Ow:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=_5-y8ydlmwU:OIa35r8t1Ow:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=_5-y8ydlmwU:OIa35r8t1Ow:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=_5-y8ydlmwU:OIa35r8t1Ow:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/_5-y8ydlmwU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/3043190908786333499/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/12/adjusting-photos-for-web-albums-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3043190908786333499?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3043190908786333499?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/_5-y8ydlmwU/adjusting-photos-for-web-albums-in.html" title="Adjusting Photos for Web Albums in Batch Mode" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/12/adjusting-photos-for-web-albums-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YNQnk_fip7ImA9WxdaEk4.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-8412210122565372639</id><published>2008-08-20T20:25:00.000+08:00</published><updated>2008-08-20T20:26:33.746+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-08-20T20:26:33.746+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="virtualbox" /><title>W(S)XGA+ Resolution in VirtualBox</title><content type="html">&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this post is related to a workaround for one
specific problem encountered by the author.&lt;/p&gt;

&lt;p&gt;Recently I switched from coLinux to VirtualBox. VirtualBox provides
guest addition which includes enhanced support for Video. Originally
it worked fine for me. Due to unknown reason, the problem arises: I
could not use resolution 1440x900 (WXGA+) or 1680x1050 (WSXGA+) any
more. WXGA+ is the native resolution of my laptop, while WSXGA+ is the
resolution of the external LCD when the laptop is placed in a
dock. After tweaking for a long time, following is the solution I
found so far (I installed Gentoo Linux as guest OS).&lt;/p&gt;

&lt;h4&gt;1. Revert video driver from VirtualBox to Vesa&lt;/h4&gt;

&lt;p&gt;This is done by editing &lt;em&gt;/etc/X11/xorg.conf&lt;/em&gt;, change one
line in Section &lt;em&gt;Device&lt;/em&gt; from &lt;code&gt;Driver "vboxvideo"&lt;/code&gt;
to &lt;code&gt;Driver "vesa".&lt;/p&gt;

&lt;h4&gt;2. Install support of 1440x900 and 1680x1050 to VESA BIOS&lt;/h4&gt;

&lt;p&gt;Add parameter &lt;code&gt;vga=864&lt;/code&gt; as Linux bootup parameter
(e.g. in &lt;em&gt;/boot/grub/grub.conf&lt;/em&gt;) for resolution 1440x900,
or &lt;code&gt;vga=865&lt;/code&gt; for 1680x1050.&lt;/p&gt;

&lt;p&gt;When Virtual machine is turned off, run the following two commands
at Windows command line prompt, assuming virtual machine is named
"Gentoo":&lt;/p&gt;

&lt;pre class="code"&gt;
VBoxManage setextradata "Gentoo" "CustomeVideoMode1" "1440x900x24"
VBoxManage setextradata "Gentoo" "CustomeVideoMode2" "1680x1050x24"
&lt;/pre&gt;

&lt;p&gt;Start virtual machine, select resolution 1440x900 or 1680x1050 for
console display. Note that the resolution for console is not
necessarily the same resolution for X, i.e. you can use 1440x900 for
console, and 1680x1050 for X.&lt;/p&gt;

&lt;h4&gt;3. Add modelines for resolution 1440x900 and 1680x1050.&lt;/h4&gt;

&lt;p&gt;I use &lt;em&gt;gtf&lt;/em&gt; to generate needed modelines. For example for
resolution 1440x900 with 60 Hz refresh rate, I use the following
command:&lt;/p&gt;

&lt;pre class="code"&gt;
$ gtf 1440 900 60
&lt;/pre&gt;

&lt;p&gt;which give the following line:&lt;/p&gt;

&lt;pre class="code"&gt;
  Modeline "1440x900_60.00"  106.47  1440 1520 1672 1904  900 901 904 932  -HSync +Vsync
&lt;/pre&gt;

&lt;p&gt;I do not like the suffix &lt;em&gt;_60.00&lt;/em&gt;, therefore what finally
end up in section &lt;em&gt;Monitor&lt;/em&gt; of &lt;em&gt;/etc/X11/xorg.conf&lt;/em&gt; is
(with addition of modeline for 1680x1050):&lt;/p&gt;

&lt;pre class="code"&gt;
 modeline "1440x900" 106.47 1440 1520 1672 1904 900 901 904 932 -HSync +Vsync
 modeline  "1680x1050"  147.14  1680 1784 1968 2256  1050 1051 1054 1087  -HSync +Vsync
&lt;/pre&gt;

&lt;p&gt;In addition, the two modes should be added in
section &lt;em&gt;Screen&lt;/em&gt; of &lt;em&gt;/etc/X11/xorg.conf&lt;/em&gt; as well, my
current setting is:&lt;/p&gt;

&lt;pre class="code"&gt;
Section "Screen"
 Identifier "Screen0"
 Device     "Card0"
 Monitor    "Monitor0"
 DefaultDepth     24
 SubSection "Display"
  Viewport   0 0
  Depth     24
  Modes    "1680x1050" "1440x900"
 EndSubSection
EndSection
&lt;/pre&gt;

&lt;h4&gt;4. Select the resolution&lt;/h4&gt;

&lt;p&gt;Now the toughest part. You may have noticed that in
section &lt;em&gt;Monitor&lt;/em&gt;, there are two lines about &lt;em&gt;HorizSync&lt;/em&gt;
and &lt;em&gt;VertRefresh&lt;/em&gt;. After experimenting, my conclusion is that
one should comment out them when using 1680x1050 while enable them for
1440x900. Weird.&lt;/p&gt;

&lt;p&gt;Since I need to switch between these two resolutions frequently,
manually editing file &lt;em&gt;/etc/X11/xorg.conf&lt;/em&gt; is boring. Therefore
I write one script to automate the task. I named the script
as &lt;em&gt;xres&lt;/em&gt; and invoke it as &lt;kbd&gt;sudo xres 1440&lt;/kbd&gt; for resolution
1440x900 and &lt;kbd&gt;sudo xres 1680&lt;/kbd&gt; for 1680x1050. Following is its
content:&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="comment-delimiter"&gt;#&lt;/span&gt;&lt;span class="comment"&gt;!/bin/&lt;/span&gt;&lt;span class="keyword"&gt;bash&lt;/span&gt;&lt;span class="comment"&gt;
&lt;/span&gt;&lt;span class="keyword"&gt;case&lt;/span&gt; $&lt;span class="variable-name"&gt;1&lt;/span&gt;&lt;span class="keyword"&gt; in&lt;/span&gt;
    1440)
        sed -i &lt;span class="string"&gt;'s/^#    HorizSync    31.5 - 64.3/       HorizSync    31.5 - 64.3/'&lt;/span&gt; /etc/X11/xorg.conf
        sed -i &lt;span class="string"&gt;'s/^#    VertRefresh  50.0 - 70.0/       VertRefresh  50.0 - 70.0/'&lt;/span&gt; /etc/X11/xorg.conf
        ;;
    1680)
        sed -i &lt;span class="string"&gt;'s/^     HorizSync    31.5 - 64.3/#      HorizSync    31.5 - 64.3/'&lt;/span&gt; /etc/X11/xorg.conf
        sed -i &lt;span class="string"&gt;'s/^     VertRefresh  50.0 - 70.0/#      VertRefresh  50.0 - 70.0/'&lt;/span&gt; /etc/X11/xorg.conf
        ;;
    *)
        &lt;span class="builtin"&gt;echo&lt;/span&gt; &lt;span class="string"&gt;"Supported horizontal resolution: 1440 and 1680."&lt;/span&gt;
        &lt;span class="keyword"&gt;exit&lt;/span&gt;
        ;;
&lt;span class="keyword"&gt;esac&lt;/span&gt;
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-8412210122565372639?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=-0TJTKmBX3M:huIV0MOt7mc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=-0TJTKmBX3M:huIV0MOt7mc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=-0TJTKmBX3M:huIV0MOt7mc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=-0TJTKmBX3M:huIV0MOt7mc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=-0TJTKmBX3M:huIV0MOt7mc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=-0TJTKmBX3M:huIV0MOt7mc:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/-0TJTKmBX3M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/8412210122565372639/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/08/wsxga-resolution-in-virtualbox.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/8412210122565372639?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/8412210122565372639?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/-0TJTKmBX3M/wsxga-resolution-in-virtualbox.html" title="W(S)XGA+ Resolution in VirtualBox" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/08/wsxga-resolution-in-virtualbox.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEEQnc8fyp7ImA9WxdVGUs.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-4078904903330752470</id><published>2008-07-24T00:43:00.002+08:00</published><updated>2008-07-25T14:50:03.977+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-25T14:50:03.977+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="stumpwm" /><title>Experiencing Stumpwm</title><content type="html">&lt;blockquote&gt;What Emacs is to editors, Stumpwm is to window managers.
&lt;br/&gt; --Bill Clementson (&lt;a
href="http://bc.tech.coop/blog/080429.html"&gt;link&lt;/a&gt;)&lt;/blockquote&gt;

&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Recently I switched from GNOME to &lt;a
href="http://www.nongnu.org/stumpwm/"&gt;Stumpwm&lt;/a&gt; (&lt;a
href="http://en.wikipedia.org/wiki/Stumpwm"&gt;wiki&lt;/a&gt;), which means
that I jumped out of a desktop environment to a simple window manager.
So far, I'm very satisfied with such a change and never looked back.
Stumpwm, as its website says, &lt;q&gt;is a tiling, keyboard driven X11
Window Manager written entirely in Common Lisp&lt;/q&gt;. This definition
summarizes the reasons why Stumpwm is so suitable for me.&lt;/p&gt;

&lt;p&gt;First, Stumpwm is a &lt;strong&gt;tiling, keyboard driven&lt;/strong&gt; window
manager. This is very useful to boost productivity. When working, it
is desirable to minimize context switching. Tilting combined with
keyboard driven enables working with several applications
simultaneously as if your are dealing with one single program. Let me
give an example. As described in &lt;a
href="http://yujianzhang.blogspot.com/2007/11/emacs-firefox-as-blog-development.html"&gt;previous
post&lt;/a&gt;, with Emacs as development environment, it is easy to fire up
one browser within Emacs itself to preview blog post. However it is
painful to switch between Emacs and browser. Before using Stumpwm, I
am considering ways to integrate Emacs and Firefox together. With
Stumpwm, such &lt;em&gt;dream&lt;/em&gt; is just trivial to fulfill: one can show
Emacs and browser side by side, with a few keystrokes to switch
between them. Everytime you make changes in Emacs and request the
results to be shown in Firefox, they are shown simultaneously. No more
need to leave your hand for mouse to click back and forth between
Emacs and Firefox. This gives you the feeling of &lt;em&gt;integrated&lt;/em&gt;
environment. Note that I just use Emacs and Firefox as an example, and
such convenience is applicable for every application. Currently, the
problem is that I'm so accustomed to Stumpwm keystrokes that I somehow
confused the keystrokes of switching between windows in Stumpwm and
Emacs!&lt;/p&gt;

&lt;p&gt;Second, Stumpwm is &lt;strong&gt;written in Common Lisp&lt;/strong&gt;.  which
means that you can build Stumpwm with your favorite CL implementation
and you have a Lisp runtime when you work under Stumpwm. A powerful
programming language is just embedded within your window manager and
you can invoke it at any time. The other benefit is that you can
configure your window manager as you like, even when it is
running!&lt;/p&gt;

&lt;p&gt;You may get a feeling on how Stumpwm works by watching this nice &lt;a
href="http://www.archive.org/details/TheStumpWMExperience"&gt;video&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;Given the above lengthy introduction of Stumpwm, you may wonder how
to install this gem. Here we assume that you have some knowledge about
Common Lisp. Basically, installing Stumpwm is to compile it with your
preferred CL implementation, and tell your system to run Stumpwm as
your window manager.&lt;/p&gt;

&lt;p&gt;Installing Stumpwm on Gentoo Linux is straightforward. Throughout
this section, we will assume that SBCL is the CL
implementation. Stumpwm website suggests turn off threading support in
SBCL (disable USE flag &lt;em&gt;threads&lt;/em&gt;) for better performance. To
install, simply type &lt;kbd&gt;emerge stumpwm&lt;/kbd&gt;. Note
that at the time of writing, there is also an ebuild called
stumpwm-cvs. Simply ignore it since it is actually a very old version,
not the bleeding edge version suggested by its name. Advanced users
might consider to get git version for latest cool features. &lt;/p&gt;

&lt;p&gt;There are mainly two ways to invoke Stumpwm. One is to run it by
calling SBCL, the other is to dump a core image containing Stumpwm
within SBCL and invoke that image. We will take the latter
approach. To proceed, first start SBCL by typing &lt;kbd&gt;sbcl&lt;/kbd&gt;. Next
issue the following in REPL sequentially:&lt;/p&gt;

&lt;pre class="code"&gt;
(asdf:oos 'asdf:load-op &lt;span class="builtin"&gt;:stumpwm&lt;/span&gt;)
(sb-ext:save-lisp-and-die &lt;span class="string"&gt;"stumpwm"&lt;/span&gt; &lt;span
class="builtin"&gt;:executable&lt;/span&gt; t
                          &lt;span class="builtin"&gt;:toplevel&lt;/span&gt; #'(&lt;span class="keyword"&gt;lambda&lt;/span&gt; () (stumpwm:stumpwm &lt;span class="string"&gt;":0"&lt;/span&gt;)))
&lt;/pre&gt;

&lt;p&gt;Next, put the generated executable &lt;em&gt;stumpwm&lt;/em&gt; somewhere in
PATH (I put it under /usr/local/bin). Since I always start X Window by
typing &lt;kbd&gt;startx&lt;/kbd&gt;, following command is used to use Stumpwm as
my window manager:&lt;/p&gt;

&lt;pre class="code"&gt;
$ echo "exec stumpwm" &gt;&gt; ~/.xinitrc
&lt;/pre&gt;

&lt;h2&gt;Using Stumpwm&lt;/h2&gt;

&lt;h3&gt;Configuration&lt;/h3&gt;

&lt;p&gt;All stumpwm configurations are stored in
file &lt;em&gt;~/.stumpwmrc&lt;/em&gt;, which is written in Common Lisp. Just
like &lt;em&gt;.emacs&lt;/em&gt;, this file allows you to fully customize
Stumpwm. Following is my current configuration:&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="comment-delimiter"&gt;;;;; &lt;/span&gt;&lt;span class="comment"&gt;-*- Mode: Lisp -*-
&lt;/span&gt;
(&lt;span class="keyword"&gt;in-package&lt;/span&gt; &lt;span class="builtin"&gt;:stumpwm&lt;/span&gt;)

&lt;span class="comment-delimiter"&gt;;; &lt;/span&gt;&lt;span class="comment"&gt;Load swank.
&lt;/span&gt;(load &lt;span class="string"&gt;"/usr/share/emacs/site-lisp/slime/swank-loader.lisp"&lt;/span&gt;)
(swank-loader:init)
(define-stumpwm-command &lt;span class="string"&gt;"swank"&lt;/span&gt; ()
  (setf stumpwm:*top-level-error-action* &lt;span class="builtin"&gt;:break&lt;/span&gt;)
  (swank:create-server &lt;span class="builtin"&gt;:port&lt;/span&gt; 4005
                       &lt;span class="builtin"&gt;:style&lt;/span&gt; swank:*communication-style*
                       &lt;span class="builtin"&gt;:dont-close&lt;/span&gt; t)
  (echo-string (current-screen) &lt;span class="string"&gt;"Starting swank."&lt;/span&gt;))
(define-key *root-map* (kbd &lt;span class="string"&gt;"C-s"&lt;/span&gt;) &lt;span class="string"&gt;"swank"&lt;/span&gt;)       

&lt;span class="comment-delimiter"&gt;;; &lt;/span&gt;&lt;span class="comment"&gt;Customize bars and modeline.
&lt;/span&gt;(setf *message-window-gravity* &lt;span class="builtin"&gt;:center&lt;/span&gt;)
(setf *input-window-gravity* &lt;span class="builtin"&gt;:center&lt;/span&gt;)
&lt;span class="comment-delimiter"&gt;;; &lt;/span&gt;&lt;span class="comment"&gt;Turn on mode line.
&lt;/span&gt;(toggle-mode-line (current-screen) (current-head))
(setf *screen-mode-line-format* 
      (list &lt;span class="string"&gt;"%w | "&lt;/span&gt;
            '(&lt;span class="builtin"&gt;:eval&lt;/span&gt; (run-shell-command &lt;span class="string"&gt;"date"&lt;/span&gt; t))))

(set-prefix-key (kbd &lt;span class="string"&gt;"C-i"&lt;/span&gt;))
(define-key *root-map* (kbd &lt;span class="string"&gt;"c"&lt;/span&gt;) 
  &lt;span class="string"&gt;"exec urxvt +sb -fn \"xft:Bitstream Vera Sans Mono:&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="flyspell-incorrect"&gt;pixelsize&lt;/span&gt;&lt;/span&gt;&lt;span class="string"&gt;=20\""&lt;/span&gt;)

(define-stumpwm-command &lt;span class="string"&gt;"&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="flyspell-duplicate"&gt;firefox&lt;/span&gt;&lt;/span&gt;&lt;span class="string"&gt;"&lt;/span&gt; ()
  &lt;span class="string"&gt;"Run or switch to firefox."&lt;/span&gt;
  (run-or-raise &lt;span class="string"&gt;"firefox"&lt;/span&gt; '(&lt;span class="builtin"&gt;:class&lt;/span&gt; &lt;span class="string"&gt;"Firefox"&lt;/span&gt;)))
(define-key *root-map* (kbd &lt;span class="string"&gt;"f"&lt;/span&gt;) &lt;span class="string"&gt;"&lt;/span&gt;&lt;span class="string"&gt;&lt;span class="flyspell-duplicate"&gt;firefox&lt;/span&gt;&lt;/span&gt;&lt;span class="string"&gt;"&lt;/span&gt;)
&lt;/pre&gt;

&lt;p&gt;Some explanations of my configuration:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Prefix key&lt;/strong&gt;: I use &lt;kbd&gt;C-i&lt;/kbd&gt; instead of
  default &lt;kbd&gt;C-t&lt;/kbd&gt;. The reason is that &lt;kbd&gt;C-t&lt;/kbd&gt; is used in
  Firefox to open a new tab and also in Emacs for transpose. Then why
  choose &lt;kbd&gt;C-i&lt;/kbd&gt;? I'd like to admit that it is quite difficult
  to select a prefix key for Emacs user. Before settle down
  on &lt;kbd&gt;C-i&lt;/kbd&gt;, I fired up Emacs to see whether there is any key
  binding &lt;kbd&gt;C-x&lt;/kbd&gt; where &lt;em&gt;x&lt;/em&gt; from a to z is not used by
  Emacs. Unfortunately (fortunately?), Emacs binds every
  combination. So I can only choose one prefix key which is easy to
  type and I uses infrequently in Emacs. Then &lt;kbd&gt;C-i&lt;/kbd&gt; is
  selected. Note that you can send &lt;kbd&gt;C-i&lt;/kbd&gt; to application like
  Emacs by typing &lt;kbd&gt;C-i i&lt;/kbd&gt;. For the following sections, please
  replace &lt;kbd&gt;C-i&lt;/kbd&gt; with your favorite prefix key.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;SLIME&lt;/strong&gt;: the section staring with
  comments &lt;em&gt;Load swank&lt;/em&gt; provides ways to load
  swank. Type &lt;kbd&gt;C-i C-s&lt;/kbd&gt; to start swank. To connect to swank,
  simply run Emacs, and type &lt;kbd&gt;slime-connect&lt;/kbd&gt; within Emacs,
  and type &lt;kbd&gt;RET&lt;/kbd&gt; and &lt;kbd&gt;RET&lt;/kbd&gt; to accept default host
  (127.0.0.1) and default port (4005). Then you can play with Stumpwm
  as you wish: change parameters, add your own functions etc. Note
  that I do not start swank automatically for security reasons. &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Key bindings&lt;/strong&gt;: I use &lt;kbd&gt;C-i c&lt;/kbd&gt; to start
  console: &lt;em&gt;urxvt&lt;/em&gt; instead of &lt;em&gt;xterm&lt;/em&gt;. Note that I have
  also set the font for urxvt. In addition I have setup using &lt;kbd&gt;C-i
  f&lt;/kbd&gt; to start Firefox in case Firefox is not started, or bring
  Firefox window to front if it is already running.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Key Bindings&lt;/h3&gt;

&lt;p&gt;Following is a list of key bindings I used frequently. For
simplicity, I have omitted the prefix key.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;kbd&gt;?&lt;/kbd&gt;: Stumpwm help&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;;&lt;/kbd&gt;: Run Stumpwm commands&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;:&lt;/kbd&gt;: Send commands to Common Lisp interpreter.&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;Space&lt;/kbd&gt;: Go to next window&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;c&lt;/kbd&gt;: Run X terminal&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;e&lt;/kbd&gt;: Run Emacs or raise it if it is already running&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;f&lt;/kbd&gt;: Run Firefox or raise it if it is already running&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;k&lt;/kbd&gt;: Kill current window&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;g c&lt;/kbd&gt;: Create a new group&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;g k&lt;/kbd&gt;: Kill current group&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;g m&lt;/kbd&gt;: Move current window to a specified group&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;g Space&lt;/kbd&gt;: Next group&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;o&lt;/kbd&gt;: Focus shifts to next frame&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;Q&lt;/kbd&gt;: Remove all splits&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;s&lt;/kbd&gt;: Vertical split&lt;/li&gt;
  &lt;li&gt;&lt;kbd&gt;S&lt;/kbd&gt;: Horizontal split&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/6613449007994858413-4078904903330752470?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=yYainFxfAvU:WNJzA-AnV7I:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=yYainFxfAvU:WNJzA-AnV7I:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=yYainFxfAvU:WNJzA-AnV7I:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=yYainFxfAvU:WNJzA-AnV7I:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=yYainFxfAvU:WNJzA-AnV7I:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=yYainFxfAvU:WNJzA-AnV7I:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/yYainFxfAvU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/4078904903330752470/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/07/experiencing-stumpwm.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4078904903330752470?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4078904903330752470?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/yYainFxfAvU/experiencing-stumpwm.html" title="Experiencing Stumpwm" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/07/experiencing-stumpwm.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcNQ3s7eyp7ImA9WxdSE0o.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-4753644910073532044</id><published>2008-05-21T20:13:00.000+08:00</published><updated>2008-05-21T20:14:52.503+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-21T20:14:52.503+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="colinux" /><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Using PulseAudio for OSS Applications</title><content type="html">&lt;p&gt;In my &lt;a
href="yujianzhang.blogspot.com/2008/04/enable-sound-for-colinux.html"&gt;previous
post&lt;/a&gt;, I discussed how to use PulseAudio to enable sound for
coLinux. This works fine for programs like MPlayer, but has issues
with some programs Solfege.&lt;/p&gt;

&lt;p&gt;The solution is simple: if the problematic applications have
support for OSS, then emerge them with &lt;em&gt;OSS&lt;/em&gt; USE flag on. In
addition, PulseAudio should also be emerged with &lt;em&gt;OSS&lt;/em&gt; USE flag
(to enable the building of padsp, a PulseAudio OSS wrapper, which will
be discussed below). Under Gentoo Linux, one way is to simply
add &lt;em&gt;OSS&lt;/em&gt; USE flag to &lt;em&gt;/etc/make.conf&lt;/em&gt;. Alternative way
is to enable the USE flag application by application. For example, to
enable OSS USE flag for Solfege, type the following:&lt;/p&gt;

&lt;pre class="code"&gt;
# echo "media-sound/solfege oss" &gt;&gt; /etc/portage/package.use
&lt;/pre&gt;

&lt;p&gt;When running these applications, prefix the command line
with &lt;em&gt;padsp&lt;/em&gt; like the following:&lt;/p&gt;

&lt;pre class="code"&gt;
$ padsp solfege
&lt;/pre&gt;

&lt;p&gt;Note that you may need additional configurations in the application
 to use OSS for audio output.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-4753644910073532044?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ksItaC_Ri1g:7zFkneUsHGI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ksItaC_Ri1g:7zFkneUsHGI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=ksItaC_Ri1g:7zFkneUsHGI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ksItaC_Ri1g:7zFkneUsHGI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=ksItaC_Ri1g:7zFkneUsHGI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ksItaC_Ri1g:7zFkneUsHGI:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/ksItaC_Ri1g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/4753644910073532044/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/05/using-pulseaudio-for-oss-applications.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4753644910073532044?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4753644910073532044?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/ksItaC_Ri1g/using-pulseaudio-for-oss-applications.html" title="Using PulseAudio for OSS Applications" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/05/using-pulseaudio-for-oss-applications.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEHR3kyeyp7ImA9WxdTEEk.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2935692554054278519</id><published>2008-05-05T21:22:00.002+08:00</published><updated>2008-05-06T10:57:16.793+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-06T10:57:16.793+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gadget" /><category scheme="http://www.blogger.com/atom/ns#" term="hv30" /><category scheme="http://www.blogger.com/atom/ns#" term="camcorder" /><title>HV30: Camcorder and Accessories</title><content type="html">&lt;p&gt;I just bought Canon HV30 (&lt;a
href="http://www.amazon.com/dp/B00114PN1U/thoinair-20"&gt;Amazon&lt;/a&gt;, &lt;a
href="http://www.camcorderinfo.com/content/Canon-HV30-Camcorder-Review-34401.htm"&gt;Review&lt;/a&gt;)
recently for my baby. Before buying HV30, I was agonizing over the
selection between HV30 and Canon HF10 (&lt;a
href="http://www.amazon.com/dp/B001144JQU/thoinair-20"&gt;Amazon&lt;/a&gt;, &lt;a
href="http://www.camcorderinfo.com/content/Canon-Vixia-HF10-Camcorder-Review-34711.htm"&gt;Review&lt;/a&gt;)
(although I know that HF100 is better than HF10 from money point of
view since the internal 16GB flash drive of HF10 does not justify the
price difference, I do like the black paint job of HF10 and HV30).&lt;/p&gt;

&lt;h3&gt;Comparison of HV30 vs. HF10&lt;/h3&gt;

&lt;p&gt;So why I chose HV30 over HF10? The following is my comparison.&lt;/p&gt;

&lt;table cellspacing="0" cellpadding="1" border="1"&gt;
&lt;tr&gt;&lt;th&gt;Features&lt;/th&gt;&lt;th&gt;HV30&lt;/th&gt;&lt;th&gt;HF10&lt;/th&gt;&lt;th&gt;Comments&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Price&lt;/th&gt;
  &lt;td style="background: lime"&gt;MSRP price is $999 in US and
  &amp;yen;10580.00 (about $1514) in China&lt;/td&gt;
  &lt;td&gt;MSRP price is $1099 in US and &amp;yen;14080.00 (about $2014) in
  China&lt;/td&gt;
  &lt;td&gt;The price difference in China is quite significant, which is
  true even for street price.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Performance&lt;/th&gt;
  &lt;td style="background: lime"&gt;1/2.7 in. sensor&lt;/td&gt;
  &lt;td&gt;1/3.2 in. sensor&lt;/td&gt;
  &lt;td&gt;According to the &lt;a
href="http://www.camcorderinfo.com/content/Canon-Vixia-HF10-Camcorder-Review-34711.htm"&gt;review&lt;/a&gt;,
HV30 has slightly better performance over HF10 thanks to larger
sensor, however the gain seems to be marginal for most cases.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Functionalities&lt;/th&gt;
  &lt;td style="background: lime"&gt;Viewfinder, Zebra, Peaking&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Accessories&lt;/th&gt;
  &lt;td style="background: lime"&gt;Standard accessory shoe&lt;/td&gt;
  &lt;td&gt;Canon proprietary accessory shoe&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Backup&lt;/th&gt;
  &lt;td style="background: lime"&gt;Tapes are cheap for backup&lt;/td&gt;
  &lt;td&gt;Additional backup is needed since SDHC cards are expensive and
  will be reused.&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Community&lt;/th&gt;
  &lt;td style="background: lime"&gt;A mature community (looking at hv20.com
  for example)&lt;/td&gt;
  &lt;td&gt;Situation will improve&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Form Factor&lt;/th&gt;
  &lt;td&gt;88x82x138 mm (3.5x3.2x5.4 in.), 535 g (1.2 lb.)&lt;/td&gt;
  &lt;td style="background: lime"&gt;73x64x129 mm (2.9x2.5x5.1 in.), 380 g
  (13.4 oz)&lt;/td&gt;
  &lt;td&gt;HF10 is small and light, which is ideal for traveling. Normally
  the camcorder which you takes out often is the most useful one.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Media&lt;/th&gt;
  &lt;td&gt;Tape&lt;/td&gt;
  &lt;td style="background: lime"&gt;SDHC card + internal Flash&lt;/td&gt;
  &lt;td&gt;Flash card is really convenient: just like small DCs. No hassles
  for rewinding and no worry for overriding.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Zoom&lt;/th&gt;
  &lt;td&gt;10x optical zoom&lt;/td&gt;
  &lt;td style="background: lime"&gt;12x optical zoom&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Noise&lt;/th&gt;
  &lt;td&gt;Tape noise can be heard in silent environment&lt;/td&gt;
  &lt;td style="background: lime"&gt;No such noise since flash card is
  used.&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;h3&gt;Accessories&lt;/h3&gt;

&lt;p&gt;What I have:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Battery and charger: compatible ones&lt;/li&gt;
  &lt;li&gt;Camera bag: Lowepro Edit 120+&lt;/li&gt;
  &lt;li&gt;CPL filter: Kenko 43mm&lt;/li&gt;
  &lt;li&gt;HDMI cable&lt;/li&gt;
  &lt;li&gt;IEEE 1394 cable: Belkin 4-pin to 4-pin&lt;/li&gt;
  &lt;li&gt;Lens cap&lt;/li&gt;
  &lt;li&gt;miniSD: Transcend 2G. Not sure whether 4G could be used (the
  manual only states that up to 2G has been tested).&lt;/li&gt;
  &lt;li&gt;Tape: Panasonic AY-DVM63PQ&lt;/li&gt;
  &lt;li&gt;UV filter: Kenko MC-UV 43mm&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For future purchase:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;35mm adapter&lt;/li&gt;
  &lt;li&gt;Close-up lens: +1/+2/+4&lt;/li&gt;
  &lt;li&gt;Mic: Canon DM-50, or combination of Rode Videomic and stereo
  mic. Maybe XLR adapters with XLR Mics?&lt;/li&gt;
  &lt;li&gt;Neutral density filters: ND2/4/8&lt;/li&gt;
  &lt;li&gt;Shoulder strap&lt;/li&gt;
  &lt;li&gt;Steadicam Merlin&lt;/li&gt;
  &lt;li&gt;Telephoto lens: Canon TL-H43 (any black version?)&lt;/li&gt;
  &lt;li&gt;Tripod and fluid head: Manfrotto 190XPROB (tripod) + 701RC2
  (fluid head) + MBAG70 (bag)&lt;/li&gt;
  &lt;li&gt;Video light: Canon VL-3&lt;/li&gt;
  &lt;li&gt;Wide angle lens: Canon WD-H43 (any black version?)&lt;/li&gt;
  &lt;li&gt;Wrist strap&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Final Words&lt;/h3&gt;

&lt;p&gt;After over 1 month's usage of HV30, I'm pretty satisfied with
it. There is a lot of things for me to learn: how to shoot, how to
edit, just to name a few. But all the efforts are worthy when you view
the video clips produced from it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2935692554054278519?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=bvRjQ-Eavuo:9zQ6SCYvYkQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=bvRjQ-Eavuo:9zQ6SCYvYkQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=bvRjQ-Eavuo:9zQ6SCYvYkQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=bvRjQ-Eavuo:9zQ6SCYvYkQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=bvRjQ-Eavuo:9zQ6SCYvYkQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=bvRjQ-Eavuo:9zQ6SCYvYkQ:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/bvRjQ-Eavuo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2935692554054278519/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/05/hv30-camcorder-and-accessories.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2935692554054278519?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2935692554054278519?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/bvRjQ-Eavuo/hv30-camcorder-and-accessories.html" title="HV30: Camcorder and Accessories" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/05/hv30-camcorder-and-accessories.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcDQn49eip7ImA9WxZaF0w.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-6830701535064161338</id><published>2008-05-02T16:30:00.000+08:00</published><updated>2008-05-02T16:31:13.062+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-02T16:31:13.062+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Automatic Backup</title><content type="html">&lt;p&gt;We need to backup our stuff in case that some disasters might
happen. One way is to backup to some external medias like tape, USB
drives, or CD/DVDs. However working with them is somehow tedious and
manual intervention is needed. People tend to be lazy therefore we are
reluctant to backup if the process is inconvenient. If we have one
additional machine with link in between (throughout this article, we
assume the remote machine is named as &lt;em&gt;remotebox&lt;/em&gt;), we can setup
an automatic backup mechanism.&lt;/p&gt;

&lt;h2&gt;Overview&lt;/h2&gt;

&lt;p&gt;We use crontab to schedule rsync jobs to backup our files to
another machine. Since rsync is secured with SSH, to suppress the
password prompt, we have to setup SSH keychain.&lt;/p&gt;

&lt;h2&gt;Setup SSH Keychain&lt;/h2&gt;

&lt;h3&gt;Generate Keys&lt;/h3&gt;

&lt;p&gt;This section mainly follows this &lt;a
href="http://www.ibm.com/developerworks/library/l-keyc.html"&gt;nice
guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We use the DSA approach.&lt;/p&gt;

&lt;pre class="code"&gt;
$ ssh-keygen -t dsa
$ scp ~/.ssh/id_dsa.pub user@remotebox
&lt;/pre&gt;

&lt;p&gt;Then log in to &lt;em&gt;remotebox&lt;/em&gt; and append the public key to
~/.ssh/authorized_keys file like so:&lt;/p&gt;

&lt;pre class="code"&gt;
cat id_dsa.pub &gt;&gt; ~/.ssh/authorized_keys
rm id_dsa.pub
&lt;/pre&gt;

&lt;h3&gt;Install Keychain&lt;/h3&gt;

&lt;p&gt;Keychain is a nice package which prompt you for your passphrase
once you log into the system, and automatically provides passwords for
later SSH session. Note this incurs security risks (there are always
tradeoffs between security and convenience) therefore attention is
needed.&lt;/p&gt;

&lt;p&gt;This part mainly follows &lt;a
href="http://gentoo-wiki.com/TIP_keychain"&gt;this guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First install keychain by typing &lt;kbd&gt;emerge keychain&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;Then add following lines to your ~/.bash_profile.&lt;/p&gt;

&lt;pre class="code"&gt;
/keychain id_dsa
. ~/.keychain/$HOSTNAME-sh
&lt;/pre&gt;

&lt;h2&gt;Setup Crontab Job&lt;/h2&gt;

&lt;p&gt;We can then setup our automatic backup system now. Since there are
almost infinite number of combinations of crontab and rsync patterns,
I just shown one example below (many interesting examples of rsync
usage can be found by typing &lt;kbd&gt;man rsync&lt;/kbd&gt;).&lt;/p&gt;

&lt;pre class="code"&gt;
0 9,16 * * 1-5 rsync -az -e ssh --delete ~/work/ remotebox:~/backup/
&lt;/pre&gt;

&lt;p&gt;The above example synchronizes local directory &lt;em&gt;~/work&lt;/em&gt; to
remote directory &lt;em&gt;~/backup&lt;/em&gt; on host &lt;em&gt;remotebox&lt;/em&gt;, on 9
a.m. and 4 p.m. of every working day. Note that I have used
option &lt;em&gt;--delete&lt;/em&gt;, which will try to delete extraneous files
from destination directory. This can ensure that the destination
directory is an exact copy of source directory but it would be
dangerous if the destination directory contains some files already. So
test this option before you actually use it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-6830701535064161338?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Dvs8zC8S0Zw:IKIEZ-8pXt8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Dvs8zC8S0Zw:IKIEZ-8pXt8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Dvs8zC8S0Zw:IKIEZ-8pXt8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Dvs8zC8S0Zw:IKIEZ-8pXt8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Dvs8zC8S0Zw:IKIEZ-8pXt8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Dvs8zC8S0Zw:IKIEZ-8pXt8:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/Dvs8zC8S0Zw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/6830701535064161338/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/05/automatic-backup.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6830701535064161338?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6830701535064161338?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/Dvs8zC8S0Zw/automatic-backup.html" title="Automatic Backup" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/05/automatic-backup.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEDQ3c_eyp7ImA9WxdVGEo.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-6610153663891900827</id><published>2008-05-02T16:24:00.001+08:00</published><updated>2008-07-24T11:37:52.943+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-07-24T11:37:52.943+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Switching Browsers in Emacs</title><content type="html">&lt;p&gt;Recently, I have met one dilemma in Emacs. Since I'm &lt;a
href=""&gt;using Emacs for my blog writing&lt;/a&gt;, Firefox is used for
previewing. Also as an Common Lisp user, I use emacs-w3m to read
HyperSpec. Here comes the problem: I can only set one browser
for &lt;em&gt;browse-url-browser-function&lt;/em&gt;. How can I suit my
requirements simultaneously?&lt;/p&gt;

&lt;p&gt;Fortunately, Emacs is highly extensible. I just write one simple
interactive function &lt;em&gt;toggle-browser&lt;/em&gt;, which can toggle between
Firefox and emacs-w3m when pressing &lt;kbd&gt;M-x
toggle-browser&lt;/kbd&gt;. Following is the code:&lt;/p&gt;

&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;toggle-browser&lt;/span&gt; ()
  &lt;span class="doc"&gt;"Toggle browser between Firefox and emacs-w3m."&lt;/span&gt;
  (interactive)
  (setq browse-url-browser-function 
        (&lt;span class="keyword"&gt;if&lt;/span&gt; (eql browse-url-browser-function 'browse-url-firefox)
            'w3m-browse-url
          'browse-url-firefox))
  (message &lt;span class="string"&gt;"%s"&lt;/span&gt; browse-url-browser-function))
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: please look at the 1st comment from pedro for a better solution.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-6610153663891900827?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=reWk-Y_AGgQ:lLGYTNhtiBs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=reWk-Y_AGgQ:lLGYTNhtiBs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=reWk-Y_AGgQ:lLGYTNhtiBs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=reWk-Y_AGgQ:lLGYTNhtiBs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=reWk-Y_AGgQ:lLGYTNhtiBs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=reWk-Y_AGgQ:lLGYTNhtiBs:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/reWk-Y_AGgQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/6610153663891900827/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/05/switching-browsers-in-emacs.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6610153663891900827?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6610153663891900827?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/reWk-Y_AGgQ/switching-browsers-in-emacs.html" title="Switching Browsers in Emacs" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/05/switching-browsers-in-emacs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ICQ384fCp7ImA9WxZUGEU.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-4250995800448979849</id><published>2008-04-10T00:37:00.002+08:00</published><updated>2008-04-11T11:46:02.134+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-11T11:46:02.134+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="maxima" /><category scheme="http://www.blogger.com/atom/ns#" term="texlive" /><title>Using Imaxima with Texlive in Gentoo Linux</title><content type="html">&lt;p&gt;Imaxima is an Emacs extension to interface with Maxima (see &lt;a
href="http://bc.tech.coop/blog/051029.html"&gt;here&lt;/a&gt; for a nice
tutorial). To use it, one need a LaTeX distribution. However with
default Texlive installation in Gentoo, imaxima cannot work. Following
is a sample session:&lt;/p&gt;

&lt;pre class="code"&gt;
(%i1) integrate(x,x);
LaTex error in: \ifracn{x^{2}}{2}
&lt;/pre&gt;

&lt;p&gt;The problem here is that there is another package &lt;em&gt;breqn&lt;/em&gt;
needed. Breqn is inlcuded in Texlive
package &lt;em&gt;texlive-mathextra&lt;/em&gt;, which is not installed when
you &lt;kbd&gt;emerge texlive&lt;/kbd&gt;. The package is also masked by default,
therefore you need to unmask it before emerging. Following is a list
of commands to install the package (substitute &lt;em&gt;x86&lt;/em&gt;
with &lt;em&gt;amd64&lt;/em&gt; for x86-64 systems).&lt;/p&gt;

&lt;pre class="code"&gt;
# echo "dev-texlive/texlive-mathextra ~x86" &gt;&gt; /etc/portage/package.keywords
# emerge texlive-mathextra
&lt;/pre&gt;

&lt;p&gt;After installation, fire up your Emacs and enjoy (I)maxima!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: if you are not comfortable with the
default equation size (as in my case), you can add the following line
into your .emacs (adjust the number to suit your own taste):&lt;/p&gt;

&lt;pre class="code"&gt;
(setq imaxima-scale-factor 2.0)
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-4250995800448979849?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ycDccTO_x_A:pKeHzCvTbb8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ycDccTO_x_A:pKeHzCvTbb8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=ycDccTO_x_A:pKeHzCvTbb8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ycDccTO_x_A:pKeHzCvTbb8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=ycDccTO_x_A:pKeHzCvTbb8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=ycDccTO_x_A:pKeHzCvTbb8:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/ycDccTO_x_A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/4250995800448979849/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/04/using-imaxima-with-texlive-in-gentoo.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4250995800448979849?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4250995800448979849?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/ycDccTO_x_A/using-imaxima-with-texlive-in-gentoo.html" title="Using Imaxima with Texlive in Gentoo Linux" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/04/using-imaxima-with-texlive-in-gentoo.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0ANR3c4fyp7ImA9WxZUFks.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2215437040221583735</id><published>2008-04-08T21:36:00.001+08:00</published><updated>2008-04-08T21:36:36.937+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-08T21:36:36.937+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Copy and Paste between Windows and Linux</title><content type="html">&lt;p&gt;Many people use Windows as primary working machine and login to
remote Linux/Unix (we will use Linux as shorthand afterwards)
boxes. There are times when we need to &lt;a
href="http://en.wikipedia.org/wiki/Cut,_copy,_and_paste"&gt;copy and
paste&lt;/a&gt; information between Windows and Linux. Below we are going to
discuss convenient ways to do so.&lt;/p&gt;

&lt;h3&gt;Tools&lt;/h3&gt;

&lt;p&gt;PuTTY and Xming are two popular programs to run in Windows host to
facilitate communication to Linux. PuTTY provides console connection
while Xming X Window connection. For Xming, Ensure you start Xming
with parameter &lt;em&gt;-clipboard&lt;/em&gt; (which is enabled by default). Our
discussion below is focused on how to copy/paste within
PuTTY/Xming. Copy/paste for other Windows applications is quite
general (&lt;kbd&gt;Ctrl+C&lt;/kbd&gt; and &lt;kbd&gt;Ctrl+V&lt;/kbd&gt;) and should be
familiar to the reader, therefore omitted.&lt;/p&gt;

&lt;h3&gt;Ways&lt;/h3&gt;

&lt;h4&gt;PuTTY&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Copy to clipboard&lt;/em&gt;: click-and-drag to
highlight. Just select, no need to press any key.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Paste from clipboard&lt;/em&gt;: &lt;em&gt;right&lt;/em&gt; mouse
button.&lt;/p&gt;

&lt;h4&gt;Xming&lt;/h4&gt;

&lt;p&gt;For Xming applications, copy/paste follows the X window
standard as discussed below.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Copy to clipboard&lt;/em&gt;: click-and-drag to
highlight. Same as PuTTY.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Paste from clipboard&lt;/em&gt;: &lt;em&gt;middle&lt;/em&gt; mouse
button.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2215437040221583735?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=E_TJ9X1tqt0:c3nJ8gs28v8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=E_TJ9X1tqt0:c3nJ8gs28v8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=E_TJ9X1tqt0:c3nJ8gs28v8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=E_TJ9X1tqt0:c3nJ8gs28v8:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=E_TJ9X1tqt0:c3nJ8gs28v8:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=E_TJ9X1tqt0:c3nJ8gs28v8:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/E_TJ9X1tqt0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2215437040221583735/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/04/copy-and-paste-between-windows-and.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2215437040221583735?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2215437040221583735?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/E_TJ9X1tqt0/copy-and-paste-between-windows-and.html" title="Copy and Paste between Windows and Linux" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/04/copy-and-paste-between-windows-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4GSXo_eyp7ImA9WxdQEEg.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-7264003697085114511</id><published>2008-04-07T21:17:00.002+08:00</published><updated>2008-06-10T08:48:48.443+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-10T08:48:48.443+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Installation of Gentoo Linux 2008.0 Beta 1 with LiveCD</title><content type="html">&lt;p&gt;I just started yet another process of installing Gentoo Linux, and
following is my record of the installation step by step. Previously I
preferred to install from stage 1/3 following
&lt;a href="http://forums.gentoo.org/viewtopic-t-319349.html"&gt;this
guide&lt;/a&gt;. I decided to try LiveCD this time.&lt;/p&gt;

&lt;h2&gt;1. Boot the machine.&lt;/h2&gt;

&lt;p&gt;Download the 2008.0 LiveCD from &lt;a
href="http://www.gentoo.org/main/en/where.xml"&gt;here&lt;/a&gt;. Burn the CD
and boot the machine with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: in my case, the boot process is stalled. I
solved it (according to &lt;a
href="http://www.gvenkat.com/archives/2007/08/09/gentoo-linux-20070-intel-dg965wh-and-ide-cddvd-drives/"&gt;this
article&lt;/a&gt;) by appending kernel options during GRUB screen
(press &lt;kbd&gt;e&lt;/kbd&gt; to edit and append &lt;kbd&gt;all-generic-ide irqpoll
pci=nommconf&lt;/kbd&gt;).&lt;/p&gt;

&lt;h2&gt;2. Installation.&lt;/h2&gt;

&lt;p&gt;After boot, I click icon "Gentoo Linux Installation (GTK+)" in the
desktop.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partitioning&lt;/strong&gt;: I selected &lt;em&gt;Recommended
Layout&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local Mounts&lt;/strong&gt;: accept the defaults without any
changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Timezone&lt;/strong&gt;: Asia/Shanghai.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Networking&lt;/strong&gt;: Dhcp is used. Appropriate host and
domain name are provided.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Users&lt;/strong&gt;: Just add the regular user for daily
usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra Packages&lt;/strong&gt;: I selected screen and slocate. In
my first installation I also selected xorg-x11, gdm, firefox
etc. However the installation simply failed when emerging
x11-apps/xinit (and I cannot rescue the system since even /etc/fstab
is not correctly setup), therefore my second try is quite
conservative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Startup services&lt;/strong&gt;: I selected sshd.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other Settings&lt;/strong&gt;: Although I have not installed X11
or Gnome yet, I selected as following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Display Manager: gdm&lt;/li&gt;
  &lt;li&gt;Clock: local&lt;/li&gt;
  &lt;li&gt;XSession: Gnome&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;3. Post Installation.&lt;/h2&gt;

&lt;p&gt;This section is similar as what I have described for coLinux
(see &lt;a
href="http://yujianzhang.blogspot.com/2008/03/install-gentoo-with-colinux.html"&gt;here&lt;/a&gt;),
but is modified specifically for a standalone Gentoo Linux
installation.&lt;/p&gt;

&lt;h4&gt;3.0 Tiny Cleanups.&lt;/h4&gt;

&lt;p&gt;After rebooting, perform the following steps. Note that if your
system was stalled as described before, you can use same trick in GRUB
screen and you should add the kernel options to /boot/grub/grub.conf
after login.&lt;/p&gt;

&lt;p&gt;To avoid some warning, you might need to perform following
steps.&lt;/p&gt;

&lt;pre class="code"&gt;
# mkdir -p /usr/local/portage
&lt;/pre&gt;

&lt;p&gt;To change host name (according to &lt;a
href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=8"&gt;Gentoo
Handbook&lt;/a&gt;), edit file &lt;em&gt;/etc/conf.d/hostname&lt;/em&gt;, if you call
your coLinux machine as &lt;em&gt;tux&lt;/em&gt;, then set the following line.&lt;/p&gt;

&lt;pre class="code"&gt;
HOSTNAME="tux"
&lt;/pre&gt;

&lt;p&gt;In addition, remove string &lt;em&gt;.\O&lt;/em&gt; from
file &lt;em&gt;/etc/issue&lt;/em&gt; to get rid of the
annoying &lt;em&gt;unknown_domain&lt;/em&gt; in the welcome message "This is
host.unknown_domain ...".&lt;/p&gt;

&lt;h4&gt;3.1 Network&lt;/h4&gt;

&lt;p&gt;We have already specified using DHCP. It works but the
configuration files is using old syntax. Let's clean it up to avoid
future complaints. Edit file &lt;em&gt;/etc/conf.d/net&lt;/em&gt; as
follows.&lt;/p&gt;

&lt;pre class="code"&gt;
config_eth0=( "dhcp" )
&lt;/pre&gt;

&lt;h5&gt;3.1.1 Proxy&lt;/h5&gt;

&lt;p&gt;If you connect to Internet directly, you can skip this section.&lt;/p&gt;

&lt;p&gt;To use proxy server, add the
following lines into &lt;em&gt;/etc/env.d/99local&lt;/em&gt;:&lt;/p&gt;

&lt;pre class="code"&gt;
http_proxy="http://proxy.server.com:8080"
ftp_proxy="http://proxy.server.com:8080"
&lt;/pre&gt;

&lt;p&gt;Replace the port and domain name according to your situation.  Then
run:&lt;/p&gt;

&lt;pre class="code"&gt;
env-update &amp;amp;&amp;amp; source /etc/profile
&lt;/pre&gt;

&lt;h4&gt;3.2 Add additional locales&lt;/h4&gt;

&lt;p&gt;Modify file &lt;em&gt;/etc/locale.gen&lt;/em&gt;, select appropriate
locales. For me, the locales are:&lt;/p&gt;

&lt;pre class="code"&gt;
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
&lt;/pre&gt;

&lt;p&gt;Then run command &lt;kbd&gt;locale-gen&lt;/kbd&gt;.&lt;/p&gt;

&lt;h4&gt;3.3 Modify &lt;em&gt;/etc/make.conf&lt;/em&gt;&lt;/h4&gt;

&lt;p&gt;This is specific for your computer type and other
factors. Following is my configuration (I'm using a Core 2 Duo
CPU). Please refer to Gentoo documentation for your own
reference. &lt;em&gt;GENTOO_MIRRORS&lt;/em&gt; reflects the fastest mirrors for my
connection, as discussed below.&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="variable-name"&gt;CFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"-march=nocona -O2 -fomit-frame-pointer -pipe -fno-ident"&lt;/span&gt;
&lt;span class="variable-name"&gt;CXXFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"${CFLAGS}"&lt;/span&gt;
&lt;span class="variable-name"&gt;CHOST&lt;/span&gt;=&lt;span class="string"&gt;"x86_64-pc-linux-gnu"&lt;/span&gt;
&lt;span class="variable-name"&gt;LDFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"-Wl,-O1"&lt;/span&gt;
&lt;span class="variable-name"&gt;MAKEOPTS&lt;/span&gt;=&lt;span class="string"&gt;"-j3"&lt;/span&gt;
&lt;span class="variable-name"&gt;ACCEPT_KEYWORDS&lt;/span&gt;=&lt;span class="string"&gt;"amd64"&lt;/span&gt;
&lt;span class="variable-name"&gt;FEATURES&lt;/span&gt;=&lt;span class="string"&gt;"parallel-fetch"&lt;/span&gt;
&lt;span class="variable-name"&gt;LINGUAS&lt;/span&gt;=&lt;span class="string"&gt;"en zh zh_CN"&lt;/span&gt;
&lt;span class="variable-name"&gt;INPUT_DEVICES&lt;/span&gt;=&lt;span class="string"&gt;"keyboard mouse"&lt;/span&gt;
&lt;span class="variable-name"&gt;VIDEO_CARDS&lt;/span&gt;=&lt;span class="string"&gt;"i810"&lt;/span&gt;
&lt;span class="variable-name"&gt;PORTDIR_OVERLAY&lt;/span&gt;=&lt;span class="string"&gt;"/usr/local/portage"&lt;/span&gt;
&lt;span class="variable-name"&gt;GENTOO_MIRRORS&lt;/span&gt;=&lt;span class="string"&gt;"http://ftp.iij.ad.jp/pub/linux/gentoo/ http://ftp.kaist.ac.kr/pub/gentoo/"&lt;/span&gt;

&lt;span class="variable-name"&gt;USE_DEV&lt;/span&gt;=&lt;span class="string"&gt;"bash-completion doc emacs latex ruby sbcl source spell"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_HW&lt;/span&gt;=&lt;span class="string"&gt;"cpudetection mmx sse sse2"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_LIB&lt;/span&gt;=&lt;span class="string"&gt;"curl gd glibc-omitfp ncurses readline zlib"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_MM&lt;/span&gt;=&lt;span class="string"&gt;"aac alsa encode ffmpeg flac midi mp3 ogg pulseaudio quicktime theora xvid"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_PIC&lt;/span&gt;=&lt;span class="string"&gt;"gif jpeg png raw svg tiff xpm"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_SECURITY&lt;/span&gt;=&lt;span class="string"&gt;"crypt pam ssl tcpd"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_SW&lt;/span&gt;=&lt;span class="string"&gt;"bzip2"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_SYS&lt;/span&gt;=&lt;span class="string"&gt;"cjk nls nptl nptlonly opengl truetype unicode xinerama xml"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE_X11&lt;/span&gt;=&lt;span class="string"&gt;"cairo gnome gtk X xft xorg"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE&lt;/span&gt;=&lt;span class="string"&gt;"-* ${USE_DEV} ${USE_HW} ${USE_LIB} ${USE_MM} \
     ${USE_PIC} ${USE_SECURITY} ${USE_SW} ${USE_SYS} ${USE_X11}"&lt;/span&gt;
&lt;/pre&gt;

&lt;h4&gt;3.4 Synchronize Portage&lt;/h4&gt;

&lt;p&gt;Use either &lt;kbd&gt;emerge --sync&lt;/kbd&gt; or &lt;kbd&gt;emerge-webrsync
-v&lt;/kbd&gt; to update the portage.&lt;/p&gt;

&lt;h4&gt;3.5 Mirror selection&lt;/h4&gt;

&lt;p&gt;First run &lt;kbd&gt;emerge mirrorselect&lt;/kbd&gt;. To select the fastest
mirror. I use the following command &lt;kbd&gt;mirrorselect -D -H
-s2&lt;/kbd&gt; to select the mirror. It means
that:&lt;/p&gt;

&lt;ul&gt;

  &lt;li&gt;-D: actual file will be downloaded from the mirror to test speed.&lt;/li&gt;
  &lt;li&gt;-H: test http mirrors only.&lt;/li&gt;
  &lt;li&gt;-s2: only select 2 mirrors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the command, original &lt;em&gt;/etc/make.conf&lt;/em&gt; will be
backed up as /etc/make.conf.backup and your selected mirrors will be
reflected in make.conf. Type &lt;kbd&gt;mirrorselect -h&lt;/kbd&gt; for
details.&lt;/p&gt;

&lt;h4&gt;3.6 Update system&lt;/h4&gt;

&lt;p&gt;Run the following suites of commands (we need the -p argument to
check what the commands are supposed to do since they're somehow
"dangerous"):&lt;/p&gt;

&lt;pre class="code"&gt;
emerge -uDNpv world
emerge -uDNv world
emerge --depclean -pv 
emerge --depclean -v
revdep-rebuild -pv
revdep-rebuild -v
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: if you encounter circular dependency when
&lt;kbd&gt;emerge -uDNv world&lt;/kbd&gt;, try to remove &lt;em&gt;gtk&lt;/em&gt; USE flag
from &lt;em&gt;/etc/make.conf&lt;/em&gt;. After successful emerging, add
&lt;em&gt;gtk&lt;/em&gt; flag again and run &lt;kbd&gt;emerge -uDNv world&lt;/kbd&gt; again. &lt;/p&gt;

&lt;p&gt;After update, run &lt;kbd&gt;dispatch-conf&lt;/kbd&gt; to update the
configuration files.&lt;/p&gt;

&lt;h4&gt;3.7 Install X11 and GNOME.&lt;/h4&gt;

&lt;p&gt;Run command &lt;kbd&gt;emerge xorg-x11&lt;/kbd&gt; to install X11. Then
use &lt;kbd&gt;xorgcfg -textmode&lt;/kbd&gt; to configure X server.&lt;/p&gt;

&lt;p&gt;I'm using a LCD with resolution of 1680x1050, which is not listed
in standard configurations. To use it, first run &lt;kbd&gt;gtf 1680 1050
60&lt;/kbd&gt;, copy the output to the &lt;em&gt;Monitor&lt;/em&gt; section
of &lt;em&gt;/etc/X11/xorg.conf&lt;/em&gt;, and modify section &lt;em&gt;Screen&lt;/em&gt; to
the resolution 1680x1050.&lt;/p&gt;

&lt;p&gt;For GNOME, I prefer to install gnome-light to avoid the gigantic
full GNOME installation. To do so, simply run &lt;kbd&gt;emerge
gnome-light&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;If one use &lt;em&gt;startx&lt;/em&gt; to run X11, one can simply
type &lt;kbd&gt;echo "exec gnome-session" &gt; ~/.xinitrc&lt;/kbd&gt; to configure
so.&lt;/p&gt;

&lt;p&gt;To make gdm the default login screen, run the following commands:&lt;/p&gt;

&lt;pre class="code"&gt;
# emerge gdm
# rc-update add xdm default
&lt;/pre&gt;

&lt;p&gt;And then edit /etc/conf.d/xdm, changing DISPLAYMANAGER
to &lt;em&gt;gdm&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;3.8 Install Other programs.&lt;/h4&gt;

&lt;p&gt;This section is left empty intentionally :-)&lt;/p&gt;

&lt;hr/&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;It is quite convenient to install with LiveCD. There are some
hassles during installation, but I assume the reason is that I'm using
a beta version. Since beta version is not stable, my suggestion is to
install minimal components therefore you can quickly finish the
installation and boot from hard drive.&lt;/p&gt;

&lt;p&gt;Although GRP install is not so optimal, the pre-compiled packages
should be quite close to optimal ones for 64-bit machines. Also as a
Gentoo user, I'm always in the process of customization the OS to suit
my needs, therefore a not-so-ideal-initial-setup is not an issue. In
summary, livecd approach can save a lot of time, with almost similar
end result as installing from stage 1/3.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-7264003697085114511?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=CHObtRtyjs8:6MEpbYHalZM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=CHObtRtyjs8:6MEpbYHalZM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=CHObtRtyjs8:6MEpbYHalZM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=CHObtRtyjs8:6MEpbYHalZM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=CHObtRtyjs8:6MEpbYHalZM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=CHObtRtyjs8:6MEpbYHalZM:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/CHObtRtyjs8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/7264003697085114511/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/04/installation-of-gentoo-linux-20080-beta.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/7264003697085114511?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/7264003697085114511?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/CHObtRtyjs8/installation-of-gentoo-linux-20080-beta.html" title="Installation of Gentoo Linux 2008.0 Beta 1 with LiveCD" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/04/installation-of-gentoo-linux-20080-beta.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYCRHoycSp7ImA9WxZUFUo.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2580639685328970701</id><published>2008-04-07T21:15:00.000+08:00</published><updated>2008-04-07T21:16:05.499+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-07T21:16:05.499+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Ripping CD to FLAC in Gentoo Linux</title><content type="html">&lt;p&gt;This post is just a simple note, inspired from &lt;a
href="http://www.linuxquestions.org/linux/blog/Caysho/2006-12-29/Rip_CD_to_FLAC_then_convert_FLAC_to_Ogg_Vorbis"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, install &lt;em&gt;cdparanoia&lt;/em&gt; and &lt;em&gt;flac&lt;/em&gt;:&lt;/p&gt;

&lt;pre class="code"&gt;
# emerge cdparanoia flac
&lt;/pre&gt;

&lt;p&gt;Next, issue the following commands (I deleted the original WAV
files after conversion). All tracks are extracted and converted to
FLAC format.&lt;/p&gt;

&lt;pre class="code"&gt;
# cdparanoia -B
# find . -name "*.wav" -print0 | xargs -0 flac
# rm *.wav
&lt;/pre&gt;

&lt;p&gt;Then enjoy the music with your favorite player. Since I'm using
mplayer, I call Ruby to generate the playlist and invoke mplayer with
it (in the 1st line below, the last track number is 16. Change it
according to your own situation).&lt;/p&gt;

&lt;pre class="code"&gt;
$ ruby -e '(0..16).map{|i| printf("track%02d.cdda.flac\n", i)}' &gt; pl
$ mplayer -playlist pl
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2580639685328970701?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Y4hXkblGlnc:MTca_AHqG4Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Y4hXkblGlnc:MTca_AHqG4Q:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Y4hXkblGlnc:MTca_AHqG4Q:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Y4hXkblGlnc:MTca_AHqG4Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Y4hXkblGlnc:MTca_AHqG4Q:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Y4hXkblGlnc:MTca_AHqG4Q:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/Y4hXkblGlnc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2580639685328970701/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/04/ripping-cd-to-flac-in-gentoo-linux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2580639685328970701?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2580639685328970701?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/Y4hXkblGlnc/ripping-cd-to-flac-in-gentoo-linux.html" title="Ripping CD to FLAC in Gentoo Linux" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/04/ripping-cd-to-flac-in-gentoo-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUHQ3Y6eip7ImA9WxZUEUk.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-6022420268025695607</id><published>2008-04-02T20:36:00.000+08:00</published><updated>2008-04-02T20:43:52.812+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-02T20:43:52.812+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="colinux" /><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Enable Sound for coLinux</title><content type="html">&lt;p&gt;In my previous post about &lt;a
href="http://yujianzhang.blogspot.com/2008/03/install-gentoo-with-colinux.html"&gt;installing
coLinux with Gentoo&lt;/a&gt;, audio part is not touched. Here comes the
solution on how to use PulseAudio to bridge coLinux to sound
world. This is adapted from &lt;a
href="http://colinux.wikia.com/wiki/Sound_support_in_Colinux"&gt;here&lt;/a&gt;
with contents modified for Gentoo Linux. &lt;/p&gt;

&lt;h3&gt;Windows side&lt;/h3&gt;

&lt;p&gt;We need to install PulseAudio &lt;em&gt;server&lt;/em&gt; on Windows. Frist
download binaries for Windows from &lt;a
href="http://www.cendio.com/pulseaudio"&gt;here&lt;/a&gt;. Extract to one
directory (&lt;em&gt;c:\bin\pulseaudio&lt;/em&gt; in my case).&lt;/p&gt;

&lt;p&gt;In the directory of the binaries, create a text config file named
&lt;em&gt;default.pa&lt;/em&gt; with the content:&lt;/p&gt;

&lt;pre class="code"&gt;
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24
load-module module-esound-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24
load-module module-detect
&lt;/pre&gt;

&lt;p&gt;We start PulseAudio automatically when coLinux starts, by adding
the following line to the coLinux configuration file:&lt;/p&gt;

&lt;pre class="code"&gt;
exec0=c:\bin\pulseaudio\pulseaudio.exe
&lt;/pre&gt;

&lt;h3&gt;Linux side&lt;/h3&gt;

&lt;h4&gt;Install and configure PulseAudio &lt;em&gt;client&lt;/em&gt;&lt;/h4&gt;

&lt;p&gt;Install PulseAudio by &lt;kbd&gt;emerge pulseaudio&lt;/kbd&gt;. Then
edit &lt;em&gt;/etc/pulse/client.conf&lt;/em&gt; to set the address of the Windows
host that runs the PulseAudio server:&lt;/p&gt;

&lt;pre class="code"&gt;
default-server = 192.168.0.1
&lt;/pre&gt;

&lt;p&gt;where &lt;em&gt;192.168.0.1&lt;/em&gt; is the IP address of the Windows
host.&lt;/p&gt;

&lt;p&gt;Make sure to add USE flag &lt;em&gt;alsa&lt;/em&gt;
to &lt;em&gt;/etc/make.conf&lt;/em&gt;. If you just add this USE flag, update your
system with &lt;kbd&gt;emerge -uDNv world&lt;/kbd&gt;. ALSA would be automatically
emerged.&lt;/p&gt;

&lt;h4&gt;Install alsa-plugins&lt;/h4&gt;

&lt;p&gt;In addition, we should install alsa-plugins:&lt;/p&gt;

&lt;pre class="code"&gt;
# echo "media-plugins/alsa-plugins pulseaudio" &gt;&gt; /etc/portage/package.use
# emerge alsa-plugins
&lt;/pre&gt;

&lt;p&gt;Edit &lt;em&gt;~/.asoundrc&lt;/em&gt; with the following contents.&lt;/p&gt;

&lt;pre class="code"&gt;
pcm.!default {
    type pulse
}

ctl.!default {
    type pulse
}

pcm.pulse {
    type pulse
}

ctl.pulse {
    type pulse
}
&lt;/pre&gt;

&lt;h4&gt;Test&lt;/h4&gt;

&lt;p&gt;As a final step, you can test with an ALSA player:&lt;/p&gt;

&lt;pre class="code"&gt;
aplay /usr/share/sounds/alsa/Front_Center.wav
&lt;/pre&gt;

&lt;p&gt;You should hear a voice saying "Front Center". Enjoy!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-6022420268025695607?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=U9bRFlYRCjo:jGg-N_yHGFg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=U9bRFlYRCjo:jGg-N_yHGFg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=U9bRFlYRCjo:jGg-N_yHGFg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=U9bRFlYRCjo:jGg-N_yHGFg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=U9bRFlYRCjo:jGg-N_yHGFg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=U9bRFlYRCjo:jGg-N_yHGFg:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/U9bRFlYRCjo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/6022420268025695607/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/04/enable-sound-for-colinux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6022420268025695607?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6022420268025695607?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/U9bRFlYRCjo/enable-sound-for-colinux.html" title="Enable Sound for coLinux" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/04/enable-sound-for-colinux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UERn85fCp7ImA9WxdTE0w.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2167155226705602904</id><published>2008-03-16T14:53:00.006+08:00</published><updated>2008-05-09T13:33:27.124+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-09T13:33:27.124+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="colinux" /><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Install Gentoo with coLinux</title><content type="html">&lt;p&gt;coLinux is gaining momentum as a way to run Linux programs on
Windows, and I decided to try it. As a &lt;a
href="http://yujianzhang.blogspot.com/2007/11/is-gentoo-linux-choice-for-minimalists.html"&gt;user
of Gentoo&lt;/a&gt;, my first choice is to use Gentoo with coLinux. The
following description documents what I have done to run Gentoo
&lt;em&gt;cooperatively&lt;/em&gt; in Windows laptop. I mainly follows up the &lt;a
href="http://gentoo-wiki.com/CoLinux"&gt;Gentoo Wiki Howto article&lt;/a&gt;
and other coLinux resources.&lt;/p&gt;

&lt;h2&gt;1. Installation&lt;/h2&gt;

&lt;p&gt;First download the latest &lt;a
href="http://colinux.org/snapshots/"&gt;coLinux snapshot&lt;/a&gt; (you can
also get it from &lt;a
href="http://sourceforge.net/project/showfiles.php?group_id=98788"&gt;SourceForge&lt;/a&gt;). The
file I used is coLinux-0.7.2.exe from SourceForge. Run the
installer. Some notes during installation:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;In screen &lt;em&gt;Choose Components&lt;/em&gt;, leave the default settings
  on (i.e. selecting all components), but uncheck &lt;em&gt;Root FileSystem
  image download&lt;/em&gt; (we will download it separately).&lt;/li&gt;
  &lt;li&gt; In addition, change the &lt;em&gt;Destination folder&lt;/em&gt; to
  &lt;em&gt;c:\bin\coLinux&lt;/em&gt; (note that all the description below assumes
  coLinux is installed into this directory. If you prefer other
  directory, please modify accordingly in steps below). &lt;/li&gt;
  &lt;li&gt;Installer prompts to download and install WinPCap separately,
  but my network configuration does not need WinPCap therefore I don't
  install it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then download &lt;em&gt;Gentoo-colinux-i686-2007-03-03.7z&lt;/em&gt; from &lt;a
href="http://sourceforge.net/project/showfiles.php?group_id=98788"&gt;SourceForge&lt;/a&gt;,
extract the archive into &lt;em&gt;c:\bin\coLinux&lt;/em&gt;, with a
&lt;em&gt;gentoo&lt;/em&gt; subdirectory created during extraction. Copy file
&lt;em&gt;gentoo.conf&lt;/em&gt; in &lt;em&gt;gentoo&lt;/em&gt; to the parent directory and
modify it as follows:&lt;/p&gt;

&lt;pre class="code"&gt;
kernel=vmlinux
cobd0=C:\bin\coLinux\gentoo\gentoo-root
cobd1=C:\bin\coLinux\gentoo\linux-swap
root=/dev/cobd0
hdc=\Device\Cdrom0
initrd=initrd.gz
mem=1024
eth0=tuntap
cofs0=c:\linux
&lt;/pre&gt;

&lt;p&gt;Some explanations of the above file, details will be covered in
later sections.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;For &lt;em&gt;mem&lt;/em&gt;, I set it to 1G. Choose according to your own
  situation.&lt;/li&gt;
  &lt;li&gt;For network, I only select TAP driver.&lt;/li&gt;
  &lt;li&gt;I shared Windows folder &lt;em&gt;c:\linux&lt;/em&gt; to coLinux.&lt;/li&gt;
  &lt;li&gt;CD/DVD-Drive is mounted. 
&lt;/ul&gt;

&lt;p&gt;To test drive, open a command prompt, change to the directory
&lt;em&gt;c:\bin\coLinux&lt;/em&gt;, and run the following command:&lt;/p&gt;

&lt;pre class="code"&gt;
colinux-daemon @gentoo.conf
&lt;/pre&gt;

&lt;p&gt;coLinux console should run. If there is something wrong, please
check previous steps. After some time, you are prompted for log in.
You can now login as root with password. Change your password
immediately.&lt;/p&gt;

&lt;p&gt;Congratulations! You just successfully run Gentoo in coLinux! You
can now fool around with the system. Type &lt;kbd&gt;halt&lt;/kbd&gt; when you are
tired. There is still a long road ahead to fully harness the
power. Following is two optional steps, but highly recommended.&lt;/p&gt;

&lt;h4&gt;Run coLinux during system startup&lt;/h4&gt;

&lt;p&gt;First, we need to install coLinux as a service. Open a command
prompt, change to the directory &lt;em&gt;c:\bin\coLinux&lt;/em&gt;, and run the
following command:&lt;/p&gt;

&lt;pre class="code"&gt;
colinux-daemon.exe @gentoo.conf --install-service "CoGentoo Linux" 
&lt;/pre&gt;

&lt;p&gt;Then open &lt;em&gt;Control Panel&lt;/em&gt;, first select &lt;em&gt;Administrative
Tools&lt;/em&gt;, then &lt;em&gt;Services&lt;/em&gt;, click service &lt;em&gt;CoGentoo Linux&lt;/em&gt;, and
change its &lt;em&gt;Startup type&lt;/em&gt; to &lt;em&gt;Automatic&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;Enlarge the image file&lt;/h4&gt;

&lt;p&gt;The original image size is 2G. This might not be sufficient. To
enlarge it, you need to download the tools from &lt;a
href="http://csemler.com/toporesize-0.7.zip"&gt;here&lt;/a&gt;. Extract the
archive and run file &lt;em&gt;toporesize.bat&lt;/em&gt;. Use the program to
resize file &lt;em&gt;c:\bin\coLinux\gentoo\gentoo-root&lt;/em&gt; to whatever
size you want. Make sure you &lt;strong&gt;uncheck&lt;/strong&gt; "resize file
only no resize2fs".&lt;/p&gt;

&lt;h2&gt;2. Configuration&lt;/h2&gt;

&lt;h4&gt;2.1 Timezone&lt;/h4&gt;

&lt;p&gt;Since I'm located in Beijing, I set the corresponding info as
follows. The related configuration files is
&lt;em&gt;/etc/conf.d/clock&lt;/em&gt;. I changed two lines as follows.&lt;/p&gt;

&lt;pre class="code"&gt;
CLOCK="local"
TIMEZONE="Asia/Shanghai"
&lt;/pre&gt;

&lt;p&gt;Also run command &lt;kbd&gt;ln -fs /usr/share/zoneinfo/Asia/Shanghai
/etc/localtime&lt;/kbd&gt;.&lt;/p&gt;

&lt;p&gt;It is interesting that Beijing cannot manage to snap one place
inside &lt;em&gt;/usr/share/zoneinfo/Asia&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;2.2 Network&lt;/h4&gt;

&lt;p&gt;Based on &lt;a href="http://colinux.wikia.com/wiki/Network"&gt;coLinux
wiki article&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;2.2.1 One network interface&lt;/h5&gt;

&lt;p&gt;This configuration only enable TAP, which is used to enable both
the high-speed private connection between Windows host and Linux
guest, and also to bridge the connection to Internet. One drawback of
this setup is that when you Internet connection changes (e.g. from
ADSL to WiFi, you have to adjust bridging and some parameters
manually).&lt;/p&gt;

&lt;p&gt;File &lt;em&gt;gentoo.conf&lt;/em&gt; discussed above already contains the
setup for coLinux. Next steps are as follows.&lt;/p&gt;

&lt;p&gt;On hosting OS (Windows), configure &lt;em&gt;TAP-Win32 Adapter V8
(coLinux)&lt;/em&gt; with following properties (make sure to leave
&lt;em&gt;Default Gateway&lt;/em&gt; as blank):&lt;/p&gt;

&lt;pre class="code"&gt;
Ethernet adapter:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : TAP-Win32 Adapter V8 (coLinux)
        Dhcp Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 192.168.0.1
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :
&lt;/pre&gt;

&lt;p&gt;We need to bridge the Internet connection with TAP interface. For
example, assume you're using an ADSL PPPoE connection. In Windows
host, select &lt;em&gt;Control Panel -&gt; Network Connections&lt;/em&gt;, right
click the PPPoE interface, and select &lt;em&gt;Properties&lt;/em&gt;. In tab
&lt;em&gt;Advanced&lt;/em&gt;, for &lt;em&gt;Internet Connection Sharing&lt;/em&gt;, check
&lt;em&gt;Allow other network users to connect through this computer's
Internet connection&lt;/em&gt;, and for the &lt;em&gt;Home networking
connection&lt;/em&gt;, select the TAP interface (e.g. Local Area Connection
2). When Windows prompts that TAP interface IP address will be set to
192.168.0.1, choose OK.&lt;/p&gt;

&lt;p&gt;Under coLinux, edit file &lt;em&gt;/etc/conf.d/net&lt;/em&gt; as follows.&lt;/p&gt;

&lt;pre class="code"&gt;
config_eth0=( "192.168.0.20/24" )
routes_eth0=( "default via 192.168.0.1" )
dns_servers_eth0=(" xxx.xxx.xxx.xxx " )
&lt;/pre&gt;

&lt;p&gt;Please change the DNS server information (shown as xxx above) to
those obtained in windows (e.g. via &lt;em&gt;ipconfig&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;We have to emphasize here that in this setup, Linux guest has IP
address 192.168.0.20 (this is arbitrarily selected, could be other
numbers like 192.168.0.x when 2 &lt;= x &lt;= 254), and Windows host has IP
address 192.168.0.1 interfacing Linux (of course Windows host has
external IP addresses as well).&lt;/p&gt;

&lt;h5&gt;2.2.2 For two network interfaces&lt;/h5&gt;

&lt;p&gt;Note this part is NOT compatible with other sections. The purpose
of this section is only to document alternatives to above solution. If
one interface solution is fine for you, you can skip this section.&lt;/p&gt;

&lt;p&gt;This configuration enables both SLiRP and TAP connections. SLiRP is
used to connect outside world while TAP enables the high-speed private
connection between Windows host and Linux guest, which is desirable
for X protocol. The benefits of this configuration includes improved
security and that SLiRP can automatically use current Windows Internet
connection for outgoing connections (i.e. you do not need to enter DNS
server information) without reconfigurations. This works fine for
Wireless LANs, but I did meet problems for ADSL and finally decided to
use TAP only.&lt;/p&gt;

&lt;p&gt;Anyway, let's look at how to setup two network interfaces.&lt;/p&gt;

&lt;p&gt;First, we need to modify the aforementioned file
&lt;em&gt;gentoo.conf&lt;/em&gt; located in coLinux directory. Change the line
&lt;em&gt;eth0=tuntap&lt;/em&gt; with two lines as below.&lt;/p&gt;

&lt;pre class="code"&gt;
eth0=slirp
eth1=tuntap
&lt;/pre&gt;

&lt;p&gt;Then edit file &lt;em&gt;/etc/conf.d/net&lt;/em&gt; on Linux guest. This
enables both SLiRP and TAP.&lt;/p&gt;

&lt;pre class="code"&gt;
config_eth0=( "dhcp" )
config_eth1=( "192.168.37.20/24" )
&lt;/pre&gt;

&lt;p&gt;We then need to setup DHCP client as following:&lt;/p&gt;

&lt;pre class="code"&gt;
emerge dhcpcd
rc-update add dhcpcd default
/etc/init.d/dhcpcd start
&lt;/pre&gt;

&lt;p&gt;Since only eth0 device is generated, we need to generate
&lt;em&gt;eth1&lt;/em&gt; device by &lt;/p&gt;

&lt;pre class="code"&gt;
cd /etc/init.d
ln -s net.lo net.eth1
&lt;/pre&gt;

&lt;p&gt;On hosting OS (Windows), configure &lt;em&gt;TAP-Win32 Adapter V8
(coLinux)&lt;/em&gt; with following properties (make sure to leave
&lt;em&gt;Default Gateway&lt;/em&gt; as blank):&lt;/p&gt;

&lt;pre class="code"&gt;
Ethernet adapter:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : TAP-Win32 Adapter V8 (coLinux)
        Dhcp Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 192.168.37.10
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . :
&lt;/pre&gt;

&lt;h5&gt;2.2.3 Proxy&lt;/h5&gt;

&lt;p&gt;If you connect to Internet directly, you can skip this section.&lt;/p&gt;

&lt;p&gt;To use proxy server, add the
following lines into &lt;em&gt;/etc/env.d/99local&lt;/em&gt;:&lt;/p&gt;

&lt;pre class="code"&gt;
http_proxy="http://proxy.server.com:8080"
ftp_proxy="http://proxy.server.com:8080"
&lt;/pre&gt;

&lt;p&gt;Replace the port and domain name according to your situation.  Then
run:&lt;/p&gt;

&lt;pre class="code"&gt;
env-update &amp;amp;&amp;amp; source /etc/profile
&lt;/pre&gt;

&lt;h4&gt;2.3 Add additional locales&lt;/h4&gt;

&lt;p&gt;Modify file &lt;em&gt;/etc/locale.gen&lt;/em&gt;, select appropriate
locales. For me, the locales are:&lt;/p&gt;

&lt;pre class="code"&gt;
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
&lt;/pre&gt;

&lt;p&gt;Then run command &lt;kbd&gt;locale-gen&lt;/kbd&gt;.&lt;/p&gt;

&lt;h4&gt;2.4 Mirror selection&lt;/h4&gt;

&lt;p&gt;First run &lt;kbd&gt;emerge mirrorselect&lt;/kbd&gt;. To select the fastest
mirror. I use the following command &lt;kbd&gt;mirrorselect -D -H
-s2&lt;/kbd&gt; to select the mirror. It means
that:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;-D: actual file will be downloaded from the mirror to test speed.&lt;/li&gt;
  &lt;li&gt;-H: test http mirrors only.&lt;/li&gt;
  &lt;li&gt;-s2: only select 2 mirrors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After running the command, original &lt;em&gt;/etc/make.conf&lt;/em&gt; will be
backed up as /etc/make.conf.backup and your selected mirrors will be
reflected in make.conf. Type &lt;kbd&gt;mirrorselect -h&lt;/kbd&gt; for
details.&lt;/p&gt;

&lt;h4&gt;2.5 Modify &lt;em&gt;/etc/make.conf&lt;/em&gt;&lt;/h4&gt;

&lt;p&gt;This is specific for your computer type and other
factors. Following is my configuration (I'm using a Core 2 Duo CPU on
32 bit Windows). Please refer to Gentoo documentation for your own
reference. &lt;em&gt;GENTOO_MIRRORS&lt;/em&gt; reflects the fastest mirrors for my
connection, so you may skip that line if your have already performed
mirrorselect above.&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="variable-name"&gt;CFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"-march=prescott -O2 -fomit-frame-pointer -pipe -fno-ident"&lt;/span&gt;
&lt;span class="variable-name"&gt;CXXFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"${CFLAGS}"&lt;/span&gt;
&lt;span class="variable-name"&gt;CHOST&lt;/span&gt;=&lt;span class="string"&gt;"i686-pc-linux-gnu"&lt;/span&gt;
&lt;span class="variable-name"&gt;LDFLAGS&lt;/span&gt;=&lt;span class="string"&gt;"-Wl,-O1"&lt;/span&gt;
&lt;span class="variable-name"&gt;MAKEOPTS&lt;/span&gt;=&lt;span class="string"&gt;"-j2"&lt;/span&gt;
&lt;span class="variable-name"&gt;ACCEPT_KEYWORDS&lt;/span&gt;=&lt;span class="string"&gt;"x86"&lt;/span&gt;
&lt;span class="variable-name"&gt;FEATURES&lt;/span&gt;=&lt;span class="string"&gt;"parallel-fetch"&lt;/span&gt;
&lt;span class="variable-name"&gt;LINGUAS&lt;/span&gt;=&lt;span class="string"&gt;"en zh"&lt;/span&gt;
&lt;span class="variable-name"&gt;USE&lt;/span&gt;=&lt;span class="string"&gt;"-* auctex bash-completion bzip2 cjk crypt curl doc emacs gd gif glibc-omitfp gtk \
     javascript jpeg mmx mozilla ncurses nls nptl nptlonly opengl pam png readline \
     ruby sbcl source spell sse sse2 ssl svg tcpd tiff truetype \
     unicode X xft xml xorg xpm zlib"&lt;/span&gt;
&lt;span class="variable-name"&gt;PORTDIR_OVERLAY&lt;/span&gt;=&lt;span class="string"&gt;"/usr/local/portage"&lt;/span&gt;
&lt;span class="variable-name"&gt;GENTOO_MIRRORS&lt;/span&gt;=&lt;span class="string"&gt;"http://ftp.iij.ad.jp/pub/linux/gentoo/ http://ftp.kaist.ac.kr/pub/gentoo/"&lt;/span&gt;
&lt;/pre&gt;

&lt;h4&gt;2.6 Update system&lt;/h4&gt;

&lt;p&gt;Since our original system is somehow outdated, we need to update
it. First run &lt;kbd&gt;emerge --sync&lt;/kbd&gt; or &lt;kbd&gt;emerge-webrsync
-v&lt;/kbd&gt; to synchronize portage, then run the following suites of
commands (we need the -p argument to check what the commands are
supposed to do since they're somehow "dangerous"):&lt;/p&gt;

&lt;pre class="code"&gt;
emerge -uDNpv world
emerge -uDNv world
emerge --depclean -pv 
emerge --depclean -v
revdep-rebuild -pv
revdep-rebuild -v
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: if you encounter circular dependency when
&lt;kbd&gt;emerge -uDNv world&lt;/kbd&gt;, try to remove &lt;em&gt;gtk&lt;/em&gt; USE flag
from &lt;em&gt;/etc/make.conf&lt;/em&gt;. After successful emerging, add
&lt;em&gt;gtk&lt;/em&gt; flag again and run &lt;kbd&gt;emerge -uDNv world&lt;/kbd&gt; again. &lt;/p&gt;

&lt;p&gt;After update, run &lt;kbd&gt;dispatch-conf&lt;/kbd&gt; to update the
configuration files (you need to avoid the update of
&lt;em&gt;/bin/setfont&lt;/em&gt;. If you accidentally updated the file, you can
remedy the situation as discussed below):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: if during booting, you meet the error
message &lt;q&gt;putfont: PIO_FONT: Function not supported&lt;/q&gt;, Solve the
problem as follows (as discussed &lt;a
href="http://colinux.wikia.com/wiki/FedoraHowTo"&gt;here&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;First, run command &lt;kbd&gt;mv /bin/setfont /bin/setfont.old&lt;/kbd&gt;&lt;/p&gt;

&lt;p&gt;Create a new file /bin/setfont with the following content:&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="comment-delimiter"&gt;#&lt;/span&gt;&lt;span class="comment"&gt;!/bin/&lt;/span&gt;&lt;span class="keyword"&gt;bash&lt;/span&gt;&lt;span class="comment"&gt;
&lt;/span&gt;
&lt;span class="keyword"&gt;if&lt;/span&gt; ! uname -r | grep -q -e &lt;span class="string"&gt;"-co-"&lt;/span&gt;
&lt;span class="keyword"&gt;then&lt;/span&gt;
        /bin/setfont.old $@
&lt;span class="keyword"&gt;fi&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;and make it executable by running &lt;kbd&gt;chmod +x /bin/setfont&lt;/kbd&gt;&lt;/p&gt;

&lt;h2&gt;3. Run X&lt;/h2&gt;

&lt;p&gt;X.org is already installed in coLinux machine when we update the
system as discussed in section 2.6 (we have include &lt;em&gt;X&lt;/em&gt; USE
flag). Therefore the remaining steps are just to install X server in
Windows host.&lt;/p&gt;

&lt;p&gt;We choose Xming considering it is lightweight and widely used. To
install Xming, Download &lt;a
href="http://sourceforge.net/projechft/showfiles.php?group_id=156984&amp;package_id=175377"&gt;Xming
installer&lt;/a&gt;, &lt;a
href="http://sourceforge.net/project/downloading.php?group_id=156984&amp;filename=Xming-fonts-7-3-0-11-setup.exe"&gt;font
installer&lt;/a&gt; and &lt;a
href="http://sourceforge.net/project/downloading.php?group_id=156984&amp;filename=Xming-tools-and-clients-6-9-0-28.zip"&gt;Xming-tools-and-clients&lt;/a&gt;. You
may use &lt;a
href="http://www.straightrunning.com/candidate/Xming-mesa-7-3-0-14-setup.exe"&gt;Xming-mesa&lt;/a&gt;
installer to replace Xming installer for stable OpenGL operation (only
do so if you meet problems with Xming installer).&lt;/p&gt;

&lt;p&gt;My settings during installation of Xming are as follows:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Xming
    &lt;ul&gt;
      &lt;li&gt;Destination directory: changed to &lt;em&gt;c:\bin\Xming&lt;/em&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Xming-fonts
    &lt;ul&gt;
      &lt;li&gt;Destination directory: changed to the same directory as
      Xming (c:\bin\Xming)&lt;/li&gt;
      &lt;li&gt;Fonts to be installed: select according to your own taste.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Xming-tools-and-clients &lt;ul&gt;&lt;li&gt;extract the zip file of
  Xming-tools-and-clients to the directory where Xming is installed
  (&lt;em&gt;c:\bin\Xming&lt;/em&gt; in this case).&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Settings on Windows host&lt;/h4&gt;

&lt;p&gt;For file &lt;em&gt;x0.hosts&lt;/em&gt; in Xming directory, make sure the IP
address of coLinux machines (192.168.0.20) is added.&lt;/p&gt;

&lt;p&gt;If you want to run the tools and clients bundled with Xming in
Windows host, you need to type &lt;kbd&gt;set DISPLAY=127.0.0.1:0&lt;/kbd&gt; in
your Windows host.&lt;/p&gt;

&lt;p&gt;Following steps are used to enable Windows fonts to be used by X
application. This step is &lt;em&gt;optional&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Open a command prompt window, change to directory
&lt;em&gt;c:\bin\Xming&lt;/em&gt;, and type the following commands:&lt;/p&gt;

&lt;pre class="code"&gt;
mkfontscale C:/WINDOWS/Fonts
mkfontscale -b -s -l C:/WINDOWS/Fonts
&lt;/pre&gt;

&lt;p&gt;Make sure that directory &lt;em&gt;C:\Windows\Fonts&lt;/em&gt; appeared in the
file &lt;em&gt;font-dirs&lt;/em&gt; in Xming directory.&lt;/p&gt;

&lt;h4&gt;On coLinux machine&lt;/h4&gt;

&lt;p&gt;Add the following line into &lt;em&gt;/etc/profile&lt;/em&gt;.&lt;/p&gt;

&lt;pre class="code"&gt;
export DISPLAY=192.168.0.1:0
&lt;/pre&gt;

&lt;p&gt;After start Xming (preferably to start it automatically when
Windows start), you can simply invoke any command inside Linux console
like:&lt;/p&gt;

&lt;pre class="code"&gt;
xterm &amp;amp;
&lt;/pre&gt;

&lt;h2&gt;4. Miscellaneous&lt;/h2&gt;

&lt;h4&gt;Change host name&lt;/h4&gt;

&lt;p&gt;According to &lt;a
href="http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=8"&gt;Gentoo
Handbook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Edit file &lt;em&gt;/etc/conf.d/hostname&lt;/em&gt;, if you call your coLinux
machine as &lt;em&gt;tux&lt;/em&gt;, then set the following line.&lt;/p&gt;

&lt;pre class="code"&gt;
HOSTNAME="tux"
&lt;/pre&gt;

&lt;p&gt;Edit file &lt;em&gt;/etc/conf.d/net&lt;/em&gt;, if you call your domain as
&lt;em&gt;homenetwork&lt;/em&gt;, then set the following line.&lt;/p&gt;

&lt;pre class="code"&gt;
dns_domain_lo="homenetwork"
&lt;/pre&gt;

&lt;p&gt;Remove string &lt;em&gt;.\O&lt;/em&gt; from file &lt;em&gt;/etc/issue&lt;/em&gt; to get rid
of the annoying &lt;em&gt;unknown_domain&lt;/em&gt; in the welcome message "This
is host.unknown_domain ...".&lt;/p&gt;

&lt;h4&gt;Create regular user accounts&lt;/h4&gt;

&lt;p&gt;With the following command, I created a new user named foo as a
powerful user (with the ability to su to root and also invoke some
portage related commands). Pleas substitute &lt;em&gt;foo&lt;/em&gt; above with
your desired user name.&lt;/p&gt;

&lt;pre class="code"&gt;
useradd foo -m -G users,wheel,portage
passwd foo
&lt;/pre&gt;

&lt;h4&gt;Access Windows folder&lt;/h4&gt;

&lt;p&gt;When we edit &lt;em&gt;gentoo.conf&lt;/em&gt; above, we have already enabled
coLinux to share folder c:\linux. To make our regular user to access
this directory in Linux, edit file &lt;em&gt;/etc/fstab&lt;/em&gt; and add the
following line:&lt;/p&gt;

&lt;pre class="code"&gt;
cofs00  /home/foo/windows  cofs  uid=foo,gid=foo,dmask=0755,fmask=0644 0 0
&lt;/pre&gt;

&lt;p&gt;The above line will enable the Windows folder to be shared in Linux
as a folder /home/foo/windows. You can modify above line for your own
user.&lt;/p&gt;

&lt;h4&gt;Additional programs&lt;/h4&gt;

&lt;p&gt;Following is a list of commands to install my own favorite
programs. Your situation would be of course different.&lt;/p&gt;

&lt;pre class="code"&gt;
&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;Some system utilities
&lt;/span&gt;emerge gentoolkit slocate

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;Development tools
&lt;/span&gt;&lt;span class="builtin"&gt;echo&lt;/span&gt; &lt;span class="string"&gt;"dev-lang/erlang hipe"&lt;/span&gt; &amp;gt;&amp;gt; /etc/portage/package.use
emerge aspell ruby sbcl erlang dev-util/git maxima

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;Gfx (GLEidescope is one of my favorite XScreenSaver)
&lt;/span&gt;emerge inkscape blender xscreensaver

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;Netowork
&lt;/span&gt;emerge mozilla-firefox

&lt;span class="comment-delimiter"&gt;# &lt;/span&gt;&lt;span class="comment"&gt;X tools
&lt;/span&gt;emerge xlsfonts xfontsel
&lt;/pre&gt;

&lt;p&gt;Before &lt;kbd&gt;emerge texlive&lt;/kbd&gt;, I have to add a bunch of keywords
for dependencies in &lt;em&gt;/etc/portage/package.keywords&lt;/em&gt; as
follows.&lt;/p&gt;

&lt;pre class="code"&gt;
app-text/texlive ~x86
app-text/texlive-core ~x86
dev-texlive/texlive-metapost ~x86
dev-texlive/texlive-basic ~x86
dev-texlive/texlive-documentation-base ~x86
dev-texlive/texlive-psutils ~x86
dev-texlive/texlive-langcjk ~x86
dev-tex/cjk-latex ~x86
dev-texlive/texlive-documentation-english ~x86
dev-texlive/texlive-genericrecommended ~x86
dev-texlive/texlive-latexrecommended ~x86
dev-texlive/texlive-latex ~x86
dev-texlive/texlive-texinfo ~x86
dev-texlive/texlive-latex3 ~x86
dev-texlive/texlive-htmlxml ~x86
app-text/jadetex ~x86
dev-texlive/texlive-fontsrecommended ~x86
app-text/dvipdfm ~x86
dev-texlive/texlive-documentation-chinese ~x86
dev-texlive/texlive-langmanju ~x86
&lt;/pre&gt;

&lt;h4&gt;Use CVS version of Emacs&lt;/h4&gt;

&lt;p&gt;Run the following commands:&lt;/p&gt;

&lt;pre class="code"&gt;
echo "app-editors/emacs-cvs ~x86" &gt;&gt; /etc/portage/package.keywords
emerge emacs-cvs
&lt;/pre&gt;

&lt;p&gt;If you want to use this bleeding-edge version &lt;em&gt;only&lt;/em&gt;, you
can uninstall the previous version of Emacs (if you have installed)
and type:&lt;/p&gt;

&lt;pre class="code"&gt;
echo "virtual/emacs ~x86" &gt;&gt; /etc/portage/package.keywords
&lt;/pre&gt;

&lt;p&gt;Otherwise (i.e. you have multiple versions of Emacs), when you
emerge packages requiring Emacs, a &lt;em&gt;stable&lt;/em&gt; version
(e.g. v22.1) will be installed. For the multiple-version-installation,
you can use &lt;kbd&gt;eselect emacs list&lt;/kbd&gt; to see a list of available
version. To use Emacs 23 just installed, you can type &lt;kbd&gt;eselect
emacs set emacs-23&lt;/kbd&gt;. For details, please consult &lt;a
href="http://www.gentoo.org/proj/en/lisp/emacs/xft.xml"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Emacs extensions&lt;/h4&gt;

&lt;p&gt;I run the following commands to install a few Emacs
extensions. Note that in Gentoo, many extensions (e.g. those related
to development) are automatically installed for you when you emerge
the related tools and enable &lt;em&gt;emacs&lt;/em&gt; USE flag.&lt;/p&gt;

&lt;pre class="code"&gt;
echo "app-emacs/gentoo-syntax ~x86" &gt;&gt; /etc/portage/package.keywords
echo "app-emacs/imaxima ~x86" &gt;&gt; /etc/portage/package.keywords
emerge htmlize imaxima app-emacs/gentoo-syntax keywiz
&lt;/pre&gt;

&lt;h4&gt;Enable SSH server&lt;/h4&gt;

&lt;p&gt;You may want to enable SSH access to your coLinux machine. There
are some benefits. Examples are shown below (assuming PuTTY is
used):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;More flexibilities to configure the client (e.g. pretty fonts)
  and nice scrollbars.&lt;/li&gt;
  &lt;li&gt;The title of PuTTY indicates what coLinux is doing (such
  information might be useful during a long emerge process).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To start SSH server, type the following commands.&lt;/p&gt;

&lt;pre class="code"&gt;
rc-update add sshd default
/etc/init.d/sshd start
&lt;/pre&gt;

&lt;p&gt;When you use PuTTY client, you should fill &lt;em&gt;192.168.0.20&lt;/em&gt;
as the host address to utilize the high speed internal connection.&lt;/p&gt;

&lt;h4&gt;GTK configrations&lt;/h4&gt;

&lt;p&gt;Change the default GTK+ font. Edit file &lt;em&gt;~/.gtkrc-2.0&lt;/em&gt;, add
the following line, and change the font name and size to your
preferred one.&lt;/p&gt;

&lt;pre class="code"&gt;
gtk-font-name = "Arial 15"
&lt;/pre&gt;

&lt;h4&gt;Mount CD&lt;/h4&gt;

&lt;p&gt;Simply type the following&lt;/p&gt;

&lt;pre class="code"&gt;
# mount -t iso9660 -o ro /dev/hdc /mnt/cdrom
&lt;/pre&gt;

&lt;hr/&gt;

&lt;h2&gt;Final Words&lt;/h2&gt;

&lt;p&gt;coLinux is an interesting way to run Linux applications in Windows
host. One drawback of coLinux is that the daemon process is pinned to
one processor only. This avoids some bizarre issues, however it does
not utilize the potentials of modern multi-core systems. This is
disappointing especially for a Gentoo user who requires lots of
computation power. Hope the situation could be improved in the
future.&lt;/p&gt;

&lt;p&gt;&lt;ins&gt;Update: please refer this post on &lt;a href="http://yujianzhang.blogspot.com/2008/04/enable-sound-for-colinux.html"&gt;how to enable sound.&lt;/a&gt;&lt;/ins&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2167155226705602904?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=FzjzqkVv7UU:f0XCTfce2Wo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=FzjzqkVv7UU:f0XCTfce2Wo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=FzjzqkVv7UU:f0XCTfce2Wo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=FzjzqkVv7UU:f0XCTfce2Wo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=FzjzqkVv7UU:f0XCTfce2Wo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=FzjzqkVv7UU:f0XCTfce2Wo:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/FzjzqkVv7UU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2167155226705602904/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/03/install-gentoo-with-colinux.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2167155226705602904?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2167155226705602904?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/FzjzqkVv7UU/install-gentoo-with-colinux.html" title="Install Gentoo with coLinux" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/03/install-gentoo-with-colinux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUEDRno9fip7ImA9WxNUEUo.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-225433735601639295</id><published>2008-01-17T12:33:00.088+08:00</published><updated>2009-11-03T00:01:17.466+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-03T00:01:17.466+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Reading List</title><content type="html">&lt;p&gt;My previous post discussed my thoughts on &lt;a
href="http://yujianzhang.blogspot.com/2008/01/read-programming-books.html"&gt;how
to read programming books&lt;/a&gt;, here comes my reading list of
programming/computer science books. The books I have completed reading after this post are listed for each year, afterwards come the books I am reading and those I plan to read (all books I have completed before this post is not listed
here). Note that this is a &lt;strong&gt;living&lt;/strong&gt; document.&lt;/p&gt;

&lt;SCRIPT charset="utf-8" type="text/javascript" src="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822/US/thoinair-20/8001/1f15069e-8d7c-4c8f-9fd2-6ccadb4149ad"&gt; &lt;/SCRIPT&gt; &lt;NOSCRIPT&gt;&lt;A HREF="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822%2FUS%2Fthoinair-20%2F8001%2F1f15069e-8d7c-4c8f-9fd2-6ccadb4149ad&amp;Operation=NoScript"&gt;2008&lt;/A&gt;&lt;/NOSCRIPT&gt;

&lt;SCRIPT charset="utf-8" type="text/javascript" src="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822/US/thoinair-20/8001/4ebe2414-e34e-4111-9620-02f669735b39"&gt; &lt;/SCRIPT&gt; &lt;NOSCRIPT&gt;&lt;A HREF="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&amp;MarketPlace=US&amp;ID=V20070822%2FUS%2Fthoinair-20%2F8001%2F4ebe2414-e34e-4111-9620-02f669735b39&amp;Operation=NoScript"&gt;2009&lt;/A&gt;&lt;/NOSCRIPT&gt;

&lt;h4&gt;Reading&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0201558025/thoinair-20"&gt;Concrete Mathematics &lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0070004846/thoinair-20"&gt;Structure and Interpretation of
  Computer Programs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0521562473/thoinair-20"&gt;Lisp in Small Pieces&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0201657880/thoinair-20"&gt;Programming
  Pearls&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0195105192/thoinair-20"&gt;What Is Mathematics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0201021153/thoinair-20"&gt;The Feynman Lectures
  on Physics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0324224729/thoinair-20"&gt;Principles of Economics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a
  href="http://www.amazon.com/dp/0691025096/thoinair-20"&gt;Mathematics and Plausible Reasoning (Volume I)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0131429388/thoinair-20"&gt;Operating Systems Design and Implementation (3rd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0764579010/thoinair-20"&gt;Professional Assembly Language&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0521845270/thoinair-20"&gt;Fundamentals of Wireless Communication&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0072970545/thoinair-20"&gt;Introduction to Algorithms (2nd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0262062798/thoinair-20"&gt;Essentials of Programming Languages (3rd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0486256642/thoinair-20"&gt;One Two Three . . . Infinity&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0140433937/thoinair-20"&gt;The History of the Decline and Fall of the Roman Empire, Vol. 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/071671017X/thoinair-20"&gt;Aha! Insight&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0137903952/thoinair-20"&gt;Artificial Intelligence: A Modern Approach (2nd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0465030912/thoinair-20"&gt;The Mind's I: Fantasies and Reflections on Self &amp; Soul&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0553380168/thoinair-20"&gt;A Brief History of Time&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/1590592395/thoinair-20"&gt;Practical Common Lisp&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.douban.com/subject/1478256/"&gt;围棋死活大全&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.douban.com/subject/3610681/"&gt;海子诗全集&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;To Read&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0471694665/thoinair-20"&gt;Operating System Concepts (7th Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0321486811/thoinair-20"&gt;Compilers: Principles, Techniques, and Tools (2nd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0201848406/thoinair-20"&gt;Computer Graphics: Principles and Practice in C (2nd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0201896834/thoinair-20"&gt;Art of Computer Programming, Volume 1: Fundamental Algorithms (3rd Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0735619670/thoinair-20"&gt;Code Complete: A Practical Handbook of Software Construction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0132400855/thoinair-20"&gt;Astronomy Today (6th Edition)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/1420922610/thoinair-20"&gt;Walden&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0195061357/thoinair-20"&gt;Mathematical Thought from Ancient to Modern Times, Vol. 1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0671201581/thoinair-20"&gt;A History of Western Philosophy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/026256100X/thoinair-20"&gt;The Seasoned Schemer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0262162091/thoinair-20"&gt;Types and Programming Languages&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0262220695/thoinair-20"&gt;Concepts, Techniques, and Models of Computer Programming&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0521642981/thoinair-20"&gt;Information Theory, Inference &amp; Learning Algorithms&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/1429215976/thoinair-20"&gt;Psychology&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.amazon.com/dp/0763740632/thoinair-20"&gt;Genes IX&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;

&lt;hr/&gt;

&lt;p&gt;&lt;strong&gt;Update (2008-8-18)&lt;/strong&gt;: started to add books other
than CS/programming, e.g. mathematics, physics, literature,
communications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2009-2-25)&lt;/strong&gt;: replaced table format with lists (lists with year heading consists books completed in that year), partly because lists are easier to update, but mainly because that I tend to sneak more books into reading queue when no free "slots" available, which makes the table format itself somehow "cheating".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2009-3-13)&lt;/strong&gt;: started to use Amazon widget; correct the 1st paragraph to reflect the status of reading.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-225433735601639295?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=lbugdOGeufw:-Z3OXQCF-SM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=lbugdOGeufw:-Z3OXQCF-SM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=lbugdOGeufw:-Z3OXQCF-SM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=lbugdOGeufw:-Z3OXQCF-SM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=lbugdOGeufw:-Z3OXQCF-SM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=lbugdOGeufw:-Z3OXQCF-SM:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/lbugdOGeufw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/225433735601639295/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/01/reading-list.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/225433735601639295?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/225433735601639295?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/lbugdOGeufw/reading-list.html" title="Reading List" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/01/reading-list.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMNQ3k4fSp7ImA9WxZTFEg.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-3137409207504901216</id><published>2008-01-16T12:39:00.000+08:00</published><updated>2008-01-16T12:41:32.735+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-16T12:41:32.735+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Read Programming Books</title><content type="html">&lt;p&gt;Although learning programming can be achieved via online tutorials,
reading books is still the preferred way for systematic learning (see
some discussions &lt;a
href="http://www.codinghorror.com/blog/archives/000971.html"&gt;here&lt;/a&gt;,
&lt;a href="http://www.charlespetzold.com/blog/0512130901.html"&gt;here&lt;/a&gt;,
and &lt;a
href="http://www.charlespetzold.com/blog/2007/10/081247.html"&gt;here&lt;/a&gt;
from author's point of view). Following list is gathered along my
adventure on reading programming books, especially on programming
&lt;em&gt;language&lt;/em&gt; books (for books &lt;strong&gt;not&lt;/strong&gt; requiring
active participations, it is recommended that you follow &lt;a
href="http://www.charlespetzold.com/blog/2007/06/230501.html"&gt;advices
from Charles Petzold&lt;/a&gt;). Some suggestions are easier to be said than
to be done, therefore the list is also a reminder to myself.&lt;/p&gt;

&lt;h3&gt;1. Select the right book&lt;/h3&gt;

&lt;p&gt;Reading a programming book requires enormous time and
energy. Before embarking on the hundreds-hour-adventure, it is
justified to spend sometime to select the correct path. Sometimes
starting reading an excellent book itself is an achievement. So which
book to read? The simplest solution is to search in Google or Amazon
and select those with enthsiastic reviews.  Google/Amazon are always
handy since you can get more details/reviews on books. There are
alternatives of course, as we will discuss below.&lt;/p&gt;

&lt;p&gt;If you just want to read &lt;em&gt;great&lt;/em&gt; programming books without
any specific topics, you are lucky since this important question has
already been discussed again and again. For example, you may refer to
this &lt;a
href="http://programming.reddit.com/info/62dme/comments/"&gt;Reddit
thread&lt;/a&gt;, or you can consult the opinions of some outstanding
programmers/bloggers (e.g. Steve Yegge's recommendations &lt;a
href="http://steve.yegge.googlepages.com/ten-great-books"&gt;here&lt;/a&gt; and
&lt;a href="http://steve.yegge.googlepages.com/ten-challenges"&gt;here&lt;/a&gt;,
&lt;a
href="http://www.joelonsoftware.com/navLinks/fog0000000262.html"&gt;Joel
Spolsky's advices&lt;/a&gt;, and &lt;a
href="http://www.codinghorror.com/blog/archives/000020.html"&gt;Jeff
Atwood's list&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;If you do have some topics in mind (e.g. one particular programming
language), there are various ways in addition to Google/Amazon
approach.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Lookup in Wikipedia. Typically for one programming language,
  there will be one related article. At the end of the article, there
  is one &lt;em&gt;References&lt;/em&gt; section, where you can find some
  interesting links to books. &lt;/li&gt;
 &lt;li&gt;Consult the FAQ of the language newsgroup. Normally, language X
 has one corresponding newsgroup like comp.lang.X. Generally the FAQ
 (sometimes quite outdated) of the newsgroup contains some book
 recommendations.&lt;/li&gt;
 &lt;li&gt;For some languages with &lt;em&gt;official&lt;/em&gt; website (e.g. &lt;a
 href="http://www.haskell.org"&gt;Haskell&lt;/a&gt;, &lt;a
 href="http://www.perl.org"&gt;Perl&lt;/a&gt;, and &lt;a
 href="http://www.python.org"&gt;Python&lt;/a&gt;), you can easily find book
 recommendations in the site.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's name a few commonly recommended books for some programming
languages: &lt;em&gt;&lt;acronym title="Structure and Interpretation of
Computer Programs"&gt;SICP&lt;/acronym&gt;&lt;/em&gt; (a.k.a. Wizard Book) for
Scheme, &lt;em&gt;Practical Common Lisp&lt;/em&gt; for Common Lisp,
&lt;em&gt;Programming Ruby&lt;/em&gt; (a.k.a. The PickAxe Book) for Ruby, and
&lt;em&gt;Javascript, the Definitive Guide&lt;/em&gt; (a.k.a. The Rhino Book) for
the &lt;a
href="http://steve-yegge.blogspot.com/2007/02/next-big-language.html
"&gt;Next Big Language&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;2. Setup programming environment and prepare related resources&lt;/h3&gt;

&lt;p&gt;You can't learn programming without your hands dirty. To study one
programming language, you have to install necessary package(s).
"Modern" programming books (e.g. &lt;em&gt;Practical Common Lisp&lt;/em&gt;,
&lt;em&gt;Programming Ruby&lt;/em&gt;, &lt;em&gt;Javascript, the Definitive Guide&lt;/em&gt;,
and &lt;em&gt;Programming Erlang&lt;/em&gt;) typically have one chapter getting
you started. If your book does not contain such part, you can always
consult online tutorials to setup the environment.&lt;/p&gt;

&lt;p&gt;Typically the package contains some kind of editor or IDE for
developing. You need to familiarize yourself with them either by
reading your book or tutorial. For Emacs users, you can install
related mode and simply fire up Emacs.&lt;/p&gt;

&lt;p&gt;If the book is not so cutting-edge, you can find abundant resources
in the web: source code, discussion on exercises, and even video
lectures. You can bookmark or download these resources for your future
reference. &lt;em&gt;SICP&lt;/em&gt; is an excellent example here: great &lt;a
href="http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/"&gt;video
lectures&lt;/a&gt;, and &lt;a href="http://sicp.org.ua/"&gt;nice wiki&lt;/a&gt; to
discuss solutions to exercises.&lt;/p&gt;

&lt;h3&gt;3. Practice, practice, and practice&lt;/h3&gt;

&lt;p&gt;You can't learn a language without sustained practice. We will
focus on the examples and exercises contained in the book here. &lt;/p&gt;

&lt;p&gt;When you read one example, simply &lt;em&gt;reading&lt;/em&gt; is not
enough. It is better if you &lt;em&gt;type&lt;/em&gt; the example and run
it. Note: &lt;em&gt;type&lt;/em&gt;, not copy &amp;amp; paste. The reason is similar
as when you write programs. After compilation, you think your code has
achieved the task. But typically you need several iterations to make
it right. Similar thing happens for reading. You think you understand
the code on paper, but actually you do not. You should type it in and
run it to really understand it. When you type, you can think about the
meaning of the code, syntax and idioms associated simultaneously. A
more paranoid yet effective way is that you first read the example,
and then enter it without even referring to the book. You then run the
code, analyze the results, and compare your code with the example
supplied in the book.&lt;/p&gt;

&lt;p&gt;Now for exercises. Do them all if you can. Excellent books come
with excellent exercises, if any. You could gain more insight when you
employ the techniques you just learned. (If you have any doubt on the
value of exercises, you can look at &lt;a
href="http://steve.yegge.googlepages.com/scheming-is-believing"&gt;Steve
Yegge's example&lt;/a&gt; on how doing exercises can change a person's view
about a language.) If you cannot solve one problem with
&lt;em&gt;serious&lt;/em&gt; try, you can leave it for a while and attack it
later. If you really cannot handle it, you can refer to the solutions,
which you can typically find online. Believe me, you can easily find
the answers to these hard problems of excellent books in the web.&lt;/p&gt;

&lt;h3&gt;4. Develop hobby project&lt;/h3&gt;

&lt;p&gt;When you have already read several chapters of the book and feel
comfortable to write a few small programs with the language you just
learned, you may consider to setup some hobby projects. You can use
the project to automate some day-to-day tasks, either in home or at
work. Or you may try to implement/interface some (emerging) cool
things (e.g. &lt;a href="http://code.google.com/apis/chart/"&gt;Google Chart
API&lt;/a&gt; or &lt;a
href="http://www.ffconsultancy.com/languages/ray_tracer/"&gt;Ray
tracing&lt;/a&gt;) with the language you are learning. Make sure the skills
to complete the project match the skills you just learned. You may
meet some problems you cannot handle with the skills you just
acquired. Don't panic. Just peep the later chapters of the book you
are reading, or Google around. Try to finish the project if you can
(and then you can blog about it if nobody has not done so or your way
is quite interesting). If you cannot finish it, you can leave it for a
later attempt. You may try several such projects when you progress in
the reading. The further you progress, the more ambitious task you can
try. Such hobby project itself can be viewed as extended exercises,
but designed by you, instead of the author.&lt;/p&gt;

&lt;p&gt;(Note: this section is largely influenced by a nice article/post
related to reading &lt;em&gt;On Lisp&lt;/em&gt;. Unfortunately I cannot find the
URL now.)&lt;/p&gt;

&lt;h3&gt;5. Never give up&lt;/h3&gt;

&lt;p&gt;The last but not the least advice is that you should read the book
from the beginning to the end. Spending a lot of time on one book but
giving it up when approaching say one third of it is just wasting
time. Since you only touched the surface of the book, which is easier
to learn and also easier to &lt;em&gt;forget&lt;/em&gt;. Authors arrange the books
in such a way that you could linearly read along, which typically
means that advanced topics come later. You may get stuck with one
chapter and cannot understand the topics discussed there. At this
point, don't give up. Remember that you can only achieve a higher
level of understanding of one language/technique if you can understand
the difficult part of it. Just read it, understand it, try it, or
Google around to find different (maybe better) treatment of the
topic. Attack this &lt;a
href="http://www.joelonsoftware.com/items/2007/12/06.html"&gt;gnarly
problem&lt;/a&gt; and you will gain lots from it. You have now learned some
unique things of the language, you can now look at the language in a
different yet more insightful view, and of course, you can now proceed
further to read the great book and learn more.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy reading!&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-3137409207504901216?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=zJmB4rbAG_Y:rBXBnIF8kHY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=zJmB4rbAG_Y:rBXBnIF8kHY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=zJmB4rbAG_Y:rBXBnIF8kHY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=zJmB4rbAG_Y:rBXBnIF8kHY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=zJmB4rbAG_Y:rBXBnIF8kHY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=zJmB4rbAG_Y:rBXBnIF8kHY:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/zJmB4rbAG_Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/3137409207504901216/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/01/read-programming-books.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3137409207504901216?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3137409207504901216?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/zJmB4rbAG_Y/read-programming-books.html" title="Read Programming Books" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/01/read-programming-books.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQBQns6fSp7ImA9WxVUF0o.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2553095749530564032</id><published>2008-01-14T12:48:00.001+08:00</published><updated>2009-03-23T09:55:53.515+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-23T09:55:53.515+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mid" /><category scheme="http://www.blogger.com/atom/ns#" term="gadget" /><title>MID for Programmers</title><content type="html">&lt;p&gt;Lots of &lt;acronym title="Mobile Internet Device"&gt;&lt;a
href="http://en.wikipedia.org/wiki/Mobile_Internet_Device"&gt;MID&lt;/a&gt;&lt;/acronym&gt;s
were showed off in CES 2008. However, none of them satisfy my
requirements. What I need is a device for web surfing, RSS feed
consuming, programming, and of course blogging. The one closest to my
criterial is &lt;a
href="http://www.engadget.com/2008/01/08/hands-on-with-lgs-new-menlow-based-mid/"&gt;from
LG&lt;/a&gt;, however I shunned away from Windows. Following is a list of
features I expect an MID to have, from a programmer's perspective.&lt;/p&gt;

&lt;h4&gt;Mandatory factors:&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Around 5 inch touchscreen&lt;/em&gt;. Size matters. The screen
  size is the most difficult factor when making tradeoffs. We want it
  smaller for portability (otherwise why not a gorgeous 17 inch
  MacBook Pro?), but not so small to hurt our eyes. 5 inch seems to
  strike a nice balance. At this size, 800x600 resolution seems to be
  preferred.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Full keyboard&lt;/em&gt; (similar as that of laptop in terms of
  keys equipped). Interface is critical. I am an Emacs fan, and the
  main usage of the MID is to try interesting programming ideas within
  Emacs and to compose blogs as well. Therefore I need the keyboard to
  have Ctrl and Alt equipped as a minimum. I also hope numerical keys
  have their independent positions (e.g. not shared with QWERTYUIOP as
  my Dopod 838, which is really painful). Keyboard from LG prototype
  satisfies all requirements here, therefore I do hope other vendors
  could follow suit.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Fast CPU&lt;/em&gt;. &lt;a
  href="http://yujianzhang.blogspot.com/2007/11/is-gentoo-linux-choice-for-minimalists.html"&gt;Gentoo
  is my favorite Linux distribution&lt;/a&gt;, therefore I may try to
  install it (somebody has already &lt;a
  href="http://gentoo-wiki.com/HARDWARE_Samsung_UMPC_Q1-Ultra"&gt;done so
  on Q1 Ultra&lt;/a&gt;). In addition to satisfy a power-demanding
  distribution, a powerful CPU is also a &lt;a
  href="http://www.codinghorror.com/blog/archives/000666.html"&gt;right
  for programmer&lt;/a&gt; even on such a tiny gadget.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Linux based OS&lt;/em&gt;. Linux will shine on MID, which is
  actually an &lt;em&gt;old&lt;/em&gt; news. However, there are also devices
  running Windows at least for Menlow based MIDs, e.g. the one from
  LG. The reason for me to mandate Linux here is that I can easily
  install other flavors of Linux distributions if the device itself
  comes with one. With built-in Linux, we can make sure that source
  code for hardware is readily accessible: every vendor should learn
  something from the event of &lt;a
  href="http://www.google.com/search?hl=en&amp;q=eee+pc+gpl"&gt;Eee PC GPL
  issues&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;WiFi access&lt;/em&gt;. Connection is important. Without WiFi
  access, I guess we can remove &lt;em&gt;Internet&lt;/em&gt; from the name of
  MID.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Miscellaneous&lt;/em&gt;. We should match the fast CPU with at
  least 512 MB RAM. 8 GB internal storage is a minimum to fool
  around. SD card slot is a must to connect the MID with other
  devices, and Bluetooth with A2DP support is necessary to avoid hairy
  wires.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Optional features:&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Phone capability&lt;/em&gt;. This feature is actually desperately
  needed. However I doubt whether I could find one MID if I insist on
  this feature. There are various reasons for vendors to drop this
  feature: maturity of the needed software, regulation aspects, and
  marketing issues (imagine the impact on N95 if N810 is a phone)
  etc.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;GPS&lt;/em&gt;. This is always a nice feature to enjoy.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Nice camera&lt;/em&gt;. Just imagine the wow moment when you use
  your 5-inch-LCD-digital-camera.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, is it possible for MID + Android?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2553095749530564032?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=w0NR9sA0Os8:kRHcCHRUeXk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=w0NR9sA0Os8:kRHcCHRUeXk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=w0NR9sA0Os8:kRHcCHRUeXk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=w0NR9sA0Os8:kRHcCHRUeXk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=w0NR9sA0Os8:kRHcCHRUeXk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=w0NR9sA0Os8:kRHcCHRUeXk:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/w0NR9sA0Os8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2553095749530564032/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/01/mid-for-programmers.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2553095749530564032?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2553095749530564032?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/w0NR9sA0Os8/mid-for-programmers.html" title="MID for Programmers" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/01/mid-for-programmers.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMASHY5cSp7ImA9WxZTEUk.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-3229143023644843473</id><published>2008-01-12T20:08:00.000+08:00</published><updated>2008-01-12T20:20:49.829+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-12T20:20:49.829+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Gentoo's Crisis</title><content type="html">&lt;p&gt;Sad to
learn &lt;a href="http://slashdot.org/article.pl?sid=08/01/12/0152208"&gt;Gentoo's
crisis from Slashdot&lt;/a&gt;. I unsubscribed from Gentoo newsletter several months
ago (even the newsletter itself has not been updated for some
time), and I do not have any clue on this crisis. But according
to my knowledge, there is no Gentoo 2007.1 release, which is a
dangerous signal. Although the periodical release in Gentoo itself is
not as important as for other distributions (actually there is no
impact for users who have already installed Gentoo), bleeding-edge
release is a must for newcomers.&lt;/p&gt;

&lt;p&gt;As
a &lt;a href="http://yujianzhang.blogspot.com/2007/11/is-gentoo-linux-choice-for-minimalists.html"&gt;fan
of Gentoo&lt;/a&gt;, I do hope that Robbins's offer will be accepted and all
the issues will be sorted out quickly.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-3229143023644843473?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=9oeFgwvdd9c:DwOnh1iTvOA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=9oeFgwvdd9c:DwOnh1iTvOA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=9oeFgwvdd9c:DwOnh1iTvOA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=9oeFgwvdd9c:DwOnh1iTvOA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=9oeFgwvdd9c:DwOnh1iTvOA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=9oeFgwvdd9c:DwOnh1iTvOA:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/9oeFgwvdd9c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/3229143023644843473/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2008/01/gentoos-crisis.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3229143023644843473?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3229143023644843473?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/9oeFgwvdd9c/gentoos-crisis.html" title="Gentoo's Crisis" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2008/01/gentoos-crisis.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04NR3g-fyp7ImA9WxZXFkw.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-6014268728012089207</id><published>2007-12-28T12:30:00.001+08:00</published><updated>2008-03-04T15:33:16.657+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-04T15:33:16.657+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><title>Install Proggy Fonts for Emacs in Gentoo</title><content type="html">&lt;p&gt;Coding horror discussed various nice programming fonts (see &lt;a
href="http://www.codinghorror.com/blog/archives/000157.html"&gt;here&lt;/a&gt;
and &lt;a
href="http://www.codinghorror.com/blog/archives/000969.html"&gt;here&lt;/a&gt;). Intrigued
by these posts, I decided to try these fonts on my Gentoo
box. Following is a record of what I have done.&lt;/p&gt;

&lt;h3&gt;Install Fonts in Gentoo&lt;/h3&gt;

&lt;p&gt;I decided to use Proggy Clean font (website is &lt;a
href="http://www.proggyfonts.com/"&gt;here&lt;/a&gt;). This section is mainly
related to this particular font, but I will discuss at the end of this
section how to handle other fonts in the same site.&lt;/p&gt;

&lt;p&gt;Instead of manually installing the font, I determined to writer one
ebuild. Main rationale is to rely on font eclass to automate font
installation work. The ebuild could be easily reused and even
incorporate into Gentoo portage (hopefully). The other reason is that
I want to practice a little bit on portage overlay and to write my
first (trivial) ebuild.&lt;/p&gt;

&lt;h4&gt;Create portage overlay&lt;/h4&gt;

&lt;p&gt;If you have already setup a overlay, you may skip this
part. However it should be noted that all the description in this post
assumes that your overlay is located in
&lt;code&gt;/usr/local/portage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run the following commands.&lt;/p&gt;

&lt;pre class="code"&gt;
# mkdir -p /usr/local/portage
# echo 'PORTDIR_OVERLAY=&amp;quot;/usr/local/portage&amp;quot;' &amp;gt;&amp;gt; /etc/make.conf    
&lt;/pre&gt;

&lt;h4&gt;Create the ebuild&lt;/h4&gt;

&lt;p&gt;First, create the directories.&lt;/p&gt;

&lt;pre class="code"&gt;
mkdir -p /usr/local/portage/media-fonts/ttf-proggy-clean
&lt;/pre&gt;

&lt;p&gt;Next, create a file named ttf-proggy-clean-1.0.ebuild under the
directory just created. Fill the contents as below.&lt;/p&gt;

&lt;pre class="code"&gt;
inherit font

&lt;span class="variable-name"&gt;DESCRIPTION&lt;/span&gt;=&lt;span class="string"&gt;"Proggy Clean TTF font"&lt;/span&gt;
&lt;span class="variable-name"&gt;HOMEPAGE&lt;/span&gt;=&lt;span class="string"&gt;"http://www.proggyfonts.com/"&lt;/span&gt;
&lt;span class="variable-name"&gt;SRC_URI&lt;/span&gt;=&lt;span class="string"&gt;"http://www.proggyfonts.com/download/download_bridge.php?get=ProggyClean.ttf.zip"&lt;/span&gt;

&lt;span class="variable-name"&gt;LICENSE&lt;/span&gt;=&lt;span class="string"&gt;"Proggy"&lt;/span&gt;
&lt;span class="variable-name"&gt;SLOT&lt;/span&gt;=&lt;span class="string"&gt;"0"&lt;/span&gt;
&lt;span class="variable-name"&gt;KEYWORDS&lt;/span&gt;=&lt;span class="string"&gt;"alpha amd64 arm ia64 ppc s390 sh sparc x86"&lt;/span&gt;
&lt;span class="variable-name"&gt;IUSE&lt;/span&gt;=&lt;span class="string"&gt;""&lt;/span&gt;

&lt;span class="variable-name"&gt;DEPEND&lt;/span&gt;=&lt;span class="string"&gt;""&lt;/span&gt;

&lt;span class="variable-name"&gt;S&lt;/span&gt;=&lt;span class="string"&gt;"${WORKDIR}"&lt;/span&gt;
&lt;span class="variable-name"&gt;FONT_S&lt;/span&gt;=${&lt;span class="variable-name"&gt;S&lt;/span&gt;}
&lt;span class="variable-name"&gt;FONT_SUFFIX&lt;/span&gt;=&lt;span class="string"&gt;"ttf"&lt;/span&gt;
&lt;span class="variable-name"&gt;DOCS&lt;/span&gt;=&lt;span class="string"&gt;"Licence.txt Readme.txt"&lt;/span&gt;

&lt;span class="variable-name"&gt;RESTRICT&lt;/span&gt;=&lt;span class="string"&gt;"mirror"&lt;/span&gt; 
&lt;/pre&gt;

&lt;p&gt;Some explanations of the ebuild:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Version: I believe the font is quite stable, therefore version
  1.0 should be OK :-).&lt;/li&gt;
  &lt;li&gt;License: the license in the package is quite permissive, but
  since I cannot link it to any existing license, I category it simply
  as &lt;em&gt;Proggy&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the following command to sign the ebuild.&lt;/p&gt;

&lt;pre class="code"&gt;
# ebuild /usr/local/portage/media-fonts/ttf-proggy-clean/ttf-proggy-clean-1.0.ebuild digest
&lt;/pre&gt;

&lt;p&gt;BTW, I refers a lot to &lt;a
href="http://www.gentoo.org/proj/en/desktop/games/games-ebuild-howto.xml?style=printable"&gt;this&lt;/a&gt;
when writing this first ebuild (of course, the skeleton is from
&lt;kbd&gt;man font.eclass&lt;/kbd&gt;).&lt;/p&gt;

&lt;h4&gt;Install font&lt;/h4&gt;

&lt;p&gt;Now comes our familiar emerge.&lt;/p&gt;

&lt;pre class="code"&gt;
# emerge media-fonts/ttf-proggy-clean
&lt;/pre&gt;

&lt;p&gt;Now we need to add the font path. Open file
&lt;code&gt;/etc/X11/xorg.conf&lt;/code&gt;, find the section &lt;code&gt;Section
&amp;quot;Files&amp;quot;&lt;/code&gt;, and add the following line within the
section:&lt;/p&gt;

&lt;pre class="code"&gt;
  FontPath "/usr/share/fonts/ttf-proggy-clean"
&lt;/pre&gt;

&lt;p&gt;Then press &lt;kbd&gt;Ctrl-Alt-Backspace&lt;/kbd&gt; to restart X server. After
login again, you may issue the following command (if you have not
installed xlsfonts, please do so by typing &lt;kbd&gt;emerge
xlsfonts&lt;/kbd&gt;).&lt;/p&gt;

&lt;pre class="code"&gt;
# xlsfonts | grep proggy
&lt;/pre&gt;

&lt;p&gt;You should see several lines looking like
&lt;em&gt;-altsys-proggycleantt...&lt;/em&gt;. If not, there is something wrong to
fix (please check previous typings).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: before I add the FontPath line in section
Files, that section is actually empty! Therefore X simply cannot
restart. The solution is to add some default paths into that section,
e.g. /usr/share/fonts/100dpi, /usr/share/fonts/misc.&lt;/p&gt;

&lt;h4&gt;How to use other fonts&lt;/h4&gt;

&lt;p&gt;Following is a guideline for other fonts listed in the same website.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Use appropriate directory and file name to represent the
  font. For example, for Proggy Square X font, one might setup
  directory &lt;code&gt;/usr/local/portage/media-fonts/proggy-square&lt;/code&gt;,
  and create a ebuild called
  &lt;code&gt;proggy-square-1.0.ebuild&lt;/code&gt;. The directory should be added
  into /etc/X11/xorg.conf as described above.&lt;/li&gt;
  &lt;li&gt;Modify the ebuild:
    &lt;ul&gt;
      &lt;li&gt;Specify appropriate &lt;em&gt;DESCRIPTION&lt;/em&gt;.&lt;/li&gt;
      &lt;li&gt;Use correct &lt;em&gt;SRC_URI&lt;/em&gt;.&lt;/li&gt;
      &lt;li&gt;Specify &lt;em&gt;DOCS&lt;/em&gt; correctly. I found that X font package
      does not contain Readme.txt.&lt;/li&gt;
      &lt;li&gt;Specify &lt;em&gt;FONT_SUFFIX&lt;/em&gt;. For X fonts, use &lt;em&gt;gz&lt;/em&gt;;
      use &lt;em&gt;ttf&lt;/em&gt; (like above) for TTF fonts.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Configure Emacs&lt;/h3&gt;

&lt;p&gt;Compared with the installation described above, this part is rather
easy. Assume that you want to use the font
&lt;em&gt;-altsys-proggycleantt-medium-r-normal--0-0-0-0-m-0-iso8859-1&lt;/em&gt;
(you may select one from the output of &lt;kbd&gt;xlsfonts&lt;/kbd&gt; as
described above)d, simply add the following line in your .emacs:&lt;/p&gt;

&lt;pre class="code"&gt;
(set-default-font &amp;quot;-altsys-proggycleantt-medium-r-normal--0-0-0-0-m-0-iso8859-1&amp;quot;)
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-6014268728012089207?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Xm3IO_-LeIQ:9RzA3os7i2U:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Xm3IO_-LeIQ:9RzA3os7i2U:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Xm3IO_-LeIQ:9RzA3os7i2U:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Xm3IO_-LeIQ:9RzA3os7i2U:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Xm3IO_-LeIQ:9RzA3os7i2U:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Xm3IO_-LeIQ:9RzA3os7i2U:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/Xm3IO_-LeIQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/6014268728012089207/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/12/install-proggy-fonts-for-emacs-in.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6014268728012089207?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/6014268728012089207?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/Xm3IO_-LeIQ/install-proggy-fonts-for-emacs-in.html" title="Install Proggy Fonts for Emacs in Gentoo" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/12/install-proggy-fonts-for-emacs-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkABSHszfCp7ImA9WB9bFEU.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-5285590974809026463</id><published>2007-12-24T17:32:00.000+08:00</published><updated>2007-12-24T17:32:39.584+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-24T17:32:39.584+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="erlang" /><title>Weirdness of Erlang</title><content type="html">&lt;blockquote&gt;But Erlang itself? It's too weird, and in my brief
experiments, the implementation shows its age; we have in fact learned
some things about software since way back then.
&lt;br/&gt;
--Tim Bray, &lt;a
href="http://www.tbray.org/ongoing/When/200x/2007/08/13/Prognostication"&gt;Prognostication&lt;/a&gt;&lt;/blockquote&gt;

&lt;p&gt;I'm just quite new to Erlang and read through Chapter 10 of &lt;em&gt;&lt;a
href="http://www.pragprog.com/titles/jaerlang"&gt;Programming
Erlang&lt;/a&gt;&lt;/em&gt; so far. The language really expand my mind greatly,
with its pattern-matching capability (even for a Haskell user), and of
course concurrency oriented programming. Inter-process communication,
even across different machines, is a quite simple task in
Erlang. However, as stated by Tim Bray, Erlang is too weird. In the
following, I will list some weird things I met when studying
Erlang. The focus is mainly on syntax, which seems to be non-essential
but should have been easily improved (if backward compatibility is not
an issue).&lt;/p&gt;

&lt;h3&gt;Usage of punctuation&lt;/h3&gt;

&lt;p&gt;A newcomer to Erlang will almost forget to type period after an
expression one or more times. Why do we need such punctuation even in
an interactive shell? I admit that using period, semicolon and comma
in Emacs makes source editing more automatic, but I prefer not using
them at all. Erlang should learn something from the elegance of
Haskell in this aspect.&lt;/p&gt;

&lt;h3&gt;Awkward &lt;em&gt;fun&lt;/em&gt;ctional programming with &lt;em&gt;fun&lt;/em&gt;&lt;/h3&gt;

&lt;p&gt;There is no fun when using &lt;em&gt;fun&lt;/em&gt;. When writing an anonymous
function, one have to use &lt;code&gt;fun&lt;/code&gt; and append
&lt;code&gt;end&lt;/code&gt;. Even when calling a named function within a higher
order function, one has to use &lt;code&gt;fun&lt;/code&gt; like this
&lt;code&gt;lists:map(fun math:sqrt/1, [1.0, 2.0, 3.0]).&lt;/code&gt; This is
awkward and Haskell way is way better again.&lt;/p&gt;

&lt;h3&gt;Handling Records&lt;/h3&gt;

&lt;p&gt;Although records are tuples in disguise, they are treated in a
C-style way: i.e. if one record definition is to be used by multiple
source files, it has to be put into an include file. Weird.&lt;/p&gt;

&lt;h3&gt;Macro&lt;/h3&gt;

&lt;p&gt;Fans of C/C++ may applaud when they learn that Erlang provided
similar macro facilities. However it is doubtful whether this
controversial feature is needed for such a functional programming
language.&lt;/p&gt;

&lt;h3&gt;Makefile&lt;/h3&gt;

&lt;p&gt;Again advocates of C/C++ might be pleased to know that Erlang also
relies on makefile for package management/build. Shed by the light of
Haskell/Cabal, Common Lisp/ASDF or X/Y (put your favorite language and
package management system here), one may expect that Erlang has a more
modern way?&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Apparently, above weird aspects are not show-stopper for the
popularity of Erlang. However, appreciating the Ruby principle of
&lt;em&gt;Least Surprise&lt;/em&gt;, I cannot help but rant my impressions
gathered when climbing the mind-blown-away learning curve.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-5285590974809026463?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Eo2eHAsXkfY:0q38AP_s_K4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Eo2eHAsXkfY:0q38AP_s_K4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Eo2eHAsXkfY:0q38AP_s_K4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Eo2eHAsXkfY:0q38AP_s_K4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=Eo2eHAsXkfY:0q38AP_s_K4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=Eo2eHAsXkfY:0q38AP_s_K4:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/Eo2eHAsXkfY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/5285590974809026463/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/12/weirdness-of-erlang.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/5285590974809026463?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/5285590974809026463?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/Eo2eHAsXkfY/weirdness-of-erlang.html" title="Weirdness of Erlang" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/12/weirdness-of-erlang.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcHR348fip7ImA9WxZbEU4.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-4109380278020635621</id><published>2007-12-17T13:03:00.002+08:00</published><updated>2008-04-14T09:53:56.076+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-14T09:53:56.076+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sbcl" /><category scheme="http://www.blogger.com/atom/ns#" term="lisp" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Minimize Diagnostics in Common Lisp</title><content type="html">&lt;p&gt;Diagnostics generated by compilers are quite useful for programmers
to spot bugs or inefficiencies in the first place. It is quite often
to observe that &lt;a
href="http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options"&gt;command
options&lt;/a&gt; &lt;kbd&gt;-Wall -pedantic&lt;/kbd&gt; (or even &lt;kbd&gt;-Werror&lt;/kbd&gt;)
are used to invoke gcc. When investigating the situation in Common
Lisp, a newcomer would be surprised to see that diagnostics and ways
to handle them are actually standardized (just like other
implementation-like-stuff-in-other-languages, say
&lt;kbd&gt;disassemble&lt;/kbd&gt;). In addition to the already standardized
diagnostics like &lt;a
href="http://www.lisp.org/HyperSpec/Body/contyp_warning.html#warning"&gt;warning&lt;/a&gt;
and &lt;a
href="http://www.lisp.org/HyperSpec/Body/contyp_style-warning.html"&gt;style
warning&lt;/a&gt; (the latter is actually a subtype of the former), some CL
implementations (notably CMUCL and SBCL) provides &lt;a
href="http://common-lisp.net/project/cmucl/doc/cmu-user/compiler-hint.html#toc214"&gt;efficiency
notes&lt;/a&gt;, which alerts the user that the compiler has chosen a rather
inefficient implementation for some operations. For SBCL users, it is
highly recommended to read &lt;a
href="http://www.sbcl.org/manual/Understanding-Compiler-Diagnostics.html"&gt;one
part of SBCL manual&lt;/a&gt; to learn how to interpret SBCL
diagnostics.&lt;/p&gt;

&lt;p&gt;In typical development cycle, after writing/modifying some code and
compilation, if compiler complains with such diagnostics, you know
that somewhere needs your attention. However, you can only sense these
&lt;em&gt;new&lt;/em&gt; diagnostics if the number of existing diagnostics is
quite small or zero. Otherwise you many not even notice the new
diagnostics since you already have a bunch of them. In this sense,
existing diagnostics are like &lt;em&gt;broken windows&lt;/em&gt;, and they
discourage you to identify new diagnostics. Your program will
deteriorate if you do not fix these broken windows. In summary, to
make the diagnostics useful, you have to minimize, or better yet,
eliminate existing diagnostics.&lt;/p&gt;

&lt;p&gt;There are two ways to stop the compiler emitting diagnostics:
removal and muffling. We will discuss them separately. Note that we
will use SBCL as our CL implementation in the following
discussion.&lt;/p&gt;

&lt;h2&gt;1. Removing Diagnostics&lt;/h2&gt;

&lt;p&gt;This is of course our first choice, since diagnostics are
indications of some risks in the code. In the following, we give some
simple examples to illustrate how to delete such annoying (but useful
somehow) complaints.&lt;/p&gt;

&lt;h3&gt;1.1 Warnings&lt;/h3&gt;

&lt;p&gt;Typically warnings are serious issues to be resolved
immediately. One exception is that sometimes if one file contains
multiple style warnings, a warning will be issued for the file itself
as well. Therefore to remove such warning requires eliminating related
style warnings, as discussed below.&lt;/p&gt;

&lt;h3&gt;1.2 Style Warnings&lt;/h3&gt;

&lt;h4&gt;1.2.1 Variable X defined but never used.&lt;/h4&gt;

&lt;p&gt;The first consideration here should be to remove the variable
causing diagnostics if possible, which has the additional benefit of
simplifying code. However there are cases when we cannot change the
function interface. For example, when we write reader macros with
&lt;code&gt;set-dispatch-macro-character&lt;/code&gt;, the 3rd argument is itself
a function with 3 arguments like &lt;code&gt;(stream char1 char2)&lt;/code&gt;,
and typically we do not use either &lt;var&gt;char1&lt;/var&gt; or
&lt;var&gt;char2&lt;/var&gt;. In this situation, we can use declarations like
&lt;code&gt;(declare (ignore char1 char2))&lt;/code&gt;. Sometimes, if the
argument is used in some scenarios while not in other cases (typically
in macro definitions), we can use declaration
&lt;code&gt;ignorable&lt;/code&gt;. An example here is the anaphoric macro
&lt;code&gt;acond2&lt;/code&gt; defined in &lt;em&gt;On Lisp&lt;/em&gt;, a declaration
&lt;code&gt;(declare (ignorable it))&lt;/code&gt; is needed for the ubiquitous
&lt;em&gt;it&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;1.2.2 Redefining FOO in BAR.&lt;/h4&gt;

&lt;p&gt;Typically such style warnings are issued when one file is reload,
hence can be simply ignored. However there are some more complicated
cases. One example is again related to the reader macro. If one want to
use the reader macro in the same file, the definition of the reader
macro should be encompassed with &lt;code&gt;(eval-when (:compile-toplevel
:load-toplevel :execute)&lt;/code&gt;, as illustrated in &lt;a
href="http://www.lisp.org/HyperSpec/Body/speope_eval-when.html"&gt;HyperSpec&lt;/a&gt;. The
problem is that if you write a function instead, every time you load
the file, this style warning pops up. The solution? Either use
anonymous functions as illustrated in HyperSpec, or spin out related
part into a separate file without the &lt;code&gt;eval-when&lt;/code&gt; stuff.&lt;/p&gt;

&lt;h3&gt;1.3 Efficiency Notes&lt;/h3&gt;

&lt;p&gt;It should be noted that efficiency notes are emitted only when we
turn on optimization declarations, e.g. &lt;code&gt;(declare (optimize
(speed 3) (safety 0)))&lt;/code&gt;. It is well known that &lt;a
href="http://en.wikipedia.org/wiki/Optimization_(computer_science)"&gt;premature
optimization is the root of all evil&lt;/a&gt;. Therefore before battling
against those notes, one should check whether the function in question
is the bottleneck or not. If not, one should remove those optimization
declarations, which can make the core simpler and more maintanable;
otherwise (when the optimization is really necessary), one can proceed
further with techniques discussed below.&lt;/p&gt;

&lt;p&gt;As indicated by the informative &lt;a
href="http://common-lisp.net/project/cmucl/doc/cmu-user/compiler-hint.html#toc214"&gt;CMUCL
manual on efficiency notes&lt;/a&gt;, the solution to dismiss these notes is
to provide sufficient type declarations. It should be noted that
current SBCL is smart enough to perform type inference, therefore it
is unnecessary to clutter the code with type declarations for every
expressions.&lt;/p&gt;

&lt;h4&gt;1.3.1 Doing X to pointer coercion&lt;/h4&gt;

&lt;p&gt;Such notes are typically emitted for function return values which
are of boxed types. For example, on 64-bit machines, double-float is
still boxed (it requires exactly 64-bits!), therefore compiling the
following functions will get a note &lt;q&gt;doing float to pointer coercion
(cost 13) to &amp;quot;&amp;lt;return value&amp;gt;&amp;quot;&lt;/q&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-list-1&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;df+&lt;/span&gt; (x y)
  (&lt;span class="keyword"&gt;declare&lt;/span&gt; (optimize (speed 3) (safety 0))
           (double-float x y))
  (+ x y))
&lt;/pre&gt;

&lt;p&gt;How to remove these notes? One way is to use unboxed types. For
example, in above example, one can use &lt;code&gt;single-float&lt;/code&gt;
instead of double-float for 64-bit CPUs. However such solution is not
always available: one reason is that there are only a few unboxed
types, and the other one is that sometimes the boxed types are what we
really need: e.g. double-float is required from accuracy point of
view. Another solution is to use local functions. Since compiler know
how to utilize the return value, the efficiency notes will not be
emitted. One example is shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-list-2&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;df-outer&lt;/span&gt; ()
  (&lt;span class="keyword"&gt;flet&lt;/span&gt; ((df+ (x y)
           (&lt;span class="keyword"&gt;declare&lt;/span&gt; (optimize (speed 3) (safety 0))
                    (double-float x y))
           (+ x y)))
    (coerce (df+ 1.0d0 2.0d0) 'float)))
&lt;/pre&gt;

&lt;p&gt;Note that the above example is simply contrived to illustrate that
using local functions can remove efficiency notes.&lt;/p&gt;

&lt;h2&gt;2. Muffling Diagnostics&lt;/h2&gt;

&lt;p&gt;There are many occasions that above solutions cannot be applied. In
this case, we can muffle the diagnostics. The intention of muffling is
not that we are going to adopt an ostrich policy for those
diagnostics. The underlying rationale is actually as following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We acknowledge that there is no way to eliminate the diagnostics.&lt;/li&gt;
  &lt;li&gt;The diagnostics do not impose any risks to the program per se.&lt;/li&gt;
  &lt;li&gt;The diagnostics have to be suppressed in order not to obscure
  other diagnostics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One example is the above code-list-1. If such a standalone function
optimized for double-float is really what we want, we cannot remove
the efficiency note on 64-bit machines (when will 128-bit CPUs become
mainstream?). Since there is no problem with the code, we can safely
muffle the annoying note to avoid it to distract our attention
further.&lt;/p&gt;

&lt;p&gt;Common Lisp does provide a standard way to muffle standard
diagnostics (i.e. warnings and style warnings, but not notes since
they are not standardized). This is function &lt;a
href="http://www.lisp.org/HyperSpec/Body/fun_abortcm_c_cm_use-value.html"&gt;muffle-warning&lt;/a&gt;,
however its usage seems not straightforward. SBCL wraps it up and
provides a pair of declarations &lt;a
href="http://www.sbcl.org/manual/Controlling-Verbosity.html"&gt;
&lt;code&gt;sb-ext:muffle-conditions&lt;/code&gt; and
&lt;code&gt;sb-ext:unmuffle-conditions&lt;/code&gt;&lt;/a&gt; to muffle diagnostics. We
will use them in the following discussion. If portability is
desirable, one should use &lt;code&gt;#+sbcl&lt;/code&gt;; however in the
following examples, we do not use it for simplicity.&lt;/p&gt;

&lt;h3&gt;2.1 Local Control&lt;/h3&gt;

&lt;p&gt;It is preferred that we muffle the diagnostics in a local
definition if possible. We can specify which types of diagnostics to
muffle and use the pair of extensions for advanced purposes, as
illustrated in SBCL manual. Following is an example to illustrate how
it is applied to our example (code-list-1) above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-list-3&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;defun&lt;/span&gt; &lt;span class="function-name"&gt;df+&lt;/span&gt; (x y)
  (&lt;span class="keyword"&gt;declare&lt;/span&gt; (optimize (speed 3) (safety 0))
           (double-float x y)
           (sb-ext:muffle-conditions sb-ext:compiler-note))
  (+ x y))
&lt;/pre&gt;

&lt;p&gt;Note the usage of &lt;code&gt;sb-ext:muffle-conditions&lt;/code&gt; in line 4
above.&lt;/p&gt;

&lt;h3&gt;2.2 Global Control&lt;/h3&gt;

&lt;p&gt;One can muffle diagnostics globally in the way like &lt;code&gt;(declaim
(sb-ext:muffle-conditions sb-ext:compiler-note))&lt;/code&gt;. However it is
not recommend to do so since we will lose the whole point of using
diagnostics. Nevertheless using pairs of global declarations is useful
sometimes, since it can muffle the diagnostics issued for top level
structures, and allow the compiler to complain again if it meets
issues in other places.&lt;/p&gt;

&lt;p&gt;Let's use code in &lt;em&gt;On Lisp&lt;/em&gt; again as another example. When
emulating Scheme-like continuations in Common Lisp, Paul Graham
defined parameter &lt;var&gt;*cont*&lt;/var&gt; as &lt;code&gt;(setq *cont*
#'identity)&lt;/code&gt; in top level. SBCL emits a warning &lt;q&gt;undefined
variable: *cont*&lt;/q&gt; when compiling the code. It should be noted that
we cannot use &lt;code&gt;defvar&lt;/code&gt; for this parameter, as discussed in
the text. To muffle the warning, we can add a pair of declarations as
in code-list-4 below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-list-4&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;declaim&lt;/span&gt; (sb-ext:muffle-conditions warning))
(setq *cont* #'identity)
(&lt;span class="keyword"&gt;declaim&lt;/span&gt; (sb-ext:unmuffle-conditions warning))
&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: as pointed out by Lars Rune N&amp;oslash;stdal
in the comment below, a cleaner way is to use &lt;em&gt;locally&lt;/em&gt;. The
above example can be simplified as following:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code-list-5&lt;/strong&gt;&lt;/p&gt;
&lt;pre class="code"&gt;
(&lt;span class="keyword"&gt;locally&lt;/span&gt; (&lt;span class="keyword"&gt;declare&lt;/span&gt; (sb-ext:muffle-conditions warning))
  (setq *cont* #'identity))
&lt;/pre&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;To make the best of compiler diagnostics, it is good to remove the
existing ones. Happy hacking beautiful code!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-4109380278020635621?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=6v5Ga5xse_Y:2fj5tMW24ZA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=6v5Ga5xse_Y:2fj5tMW24ZA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=6v5Ga5xse_Y:2fj5tMW24ZA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=6v5Ga5xse_Y:2fj5tMW24ZA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=6v5Ga5xse_Y:2fj5tMW24ZA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=6v5Ga5xse_Y:2fj5tMW24ZA:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/6v5Ga5xse_Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/4109380278020635621/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/12/minimize-diagnostics-in-common-lisp.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4109380278020635621?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4109380278020635621?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/6v5Ga5xse_Y/minimize-diagnostics-in-common-lisp.html" title="Minimize Diagnostics in Common Lisp" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/12/minimize-diagnostics-in-common-lisp.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cEQns8fyp7ImA9WB9UE0k.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2667311955630752061</id><published>2007-12-11T12:51:00.000+08:00</published><updated>2007-12-11T12:56:43.577+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-11T12:56:43.577+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sicp" /><title>The Last Clip of SICP Video</title><content type="html">&lt;p&gt;This morning, I finished watching &lt;a
href="http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/"&gt;SICP
video lectures&lt;/a&gt; with my tiny Dopod 838 QVGA screen when commuting
on company shuttle bus. As I have pointed out in &lt;a
href="http://yujianzhang.blogspot.com/2007/09/learning-by-watching.html"&gt;previous
post&lt;/a&gt;, learning such a mind-expanding book has never been such a
pleasure with the aid of videos.&lt;/p&gt;

&lt;p&gt;When watching the video, one may have already noticed at the beginning that the atmosphere
was somehow different, with Abelson wearing a foolscap and almost
everybody wearing sunglasses. In this very last clip, after Sussman
explained the simple-but-very-effective Minsky garbage collector and
discussed the halting problem, the usual Q&amp;A section started. The
&lt;strong&gt;last&lt;/strong&gt; tricky question was &lt;q&gt;Is this the last
question?&lt;/q&gt;, and Sussman replied &lt;q&gt;Apparently yes&lt;/q&gt; after a long
pause. And the lecture just closed here, with every student (actually
HP employees) getting a close-up. &lt;/p&gt;

&lt;p&gt;I just studied the lectures along with them, learned a lot of
things, and was delighted and blown away many times. The video was
taken in July 1986, when I had no idea of what computer is. It's interesting that I
managed to learn things together with them. Although I have not really
dived into the books and the exercises, I'm sure I will do so quite
soon, at least to meet the authors again during reading.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2667311955630752061?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=3gai1uhvVT8:Z5QHQDwxD34:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=3gai1uhvVT8:Z5QHQDwxD34:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=3gai1uhvVT8:Z5QHQDwxD34:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=3gai1uhvVT8:Z5QHQDwxD34:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=3gai1uhvVT8:Z5QHQDwxD34:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=3gai1uhvVT8:Z5QHQDwxD34:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/3gai1uhvVT8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2667311955630752061/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/12/last-clip-of-sicp-video.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2667311955630752061?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2667311955630752061?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/3gai1uhvVT8/last-clip-of-sicp-video.html" title="The Last Clip of SICP Video" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/12/last-clip-of-sicp-video.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UMSX0-fyp7ImA9WxRQFEg.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-2437249639309138014</id><published>2007-12-07T12:52:00.001+08:00</published><updated>2008-10-08T15:34:48.357+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-08T15:34:48.357+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gnuplot" /><category scheme="http://www.blogger.com/atom/ns#" term="gentoo" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Nicer Fonts for Gnuplot</title><content type="html">&lt;p&gt;&lt;a href="http://www.gnuplot.info/"&gt;Gnuplot&lt;/a&gt; is a great
visualization tool to use. However the default font is not so pleasant
for me. Following is the record on my adventure for alternative
fonts. The description is mainly Gentoo oriented.&lt;/p&gt;

&lt;h4&gt;Which font to use?&lt;/h4&gt;

&lt;p&gt;I'd like to try TTF font for nicer looking, and Bitstream Vera
bundled with Gnome just fits my taste. In case that you have not
installed Gnome (e.g. you're pretty much satisfied with the plain
terminal, or you use X only without any desktop environment, or you
are a fan of other desktop environments like KDE or E17), you may
install the font with one command in Gentoo: &lt;kbd&gt;emerge
ttf-bitstream-vera&lt;/kbd&gt;.&lt;/p&gt;

&lt;h4&gt;Build Gnuplot&lt;/h4&gt;

&lt;p&gt;Gnuplot should be built with libgd support. To do so, you should
enable the USE flag "gd". You may add gd to your make.conf, or use the
following command to add it for gnuplot alone:&lt;/p&gt;

&lt;pre&gt;echo "sci-visualization/gnuplot gd" &gt;&gt; /etc/portage/package.use&lt;/pre&gt;

&lt;p&gt;After that, build gnuplot by typing &lt;kbd&gt;emerge gnuplot&lt;/kbd&gt;. The
version I'm using for this post is 4.2.2.&lt;/p&gt;

&lt;h4&gt;Configure environment variable&lt;/h4&gt;

&lt;p&gt;Add the following line to one of the shell profiles
(e.g. ~/.bash_profile):

&lt;pre&gt;export GDFONTPATH=/usr/share/fonts/ttf-bitstream-vera&lt;/pre&gt;

&lt;h4&gt;Try it out&lt;/h4&gt;
&lt;p&gt;Now launch gnuplot. To test whether our settings take effect, type
the following at gnuplot prompt:&lt;/p&gt;

&lt;pre&gt;
gnuplot&gt; set term png enhanced font "Vera,12"
Terminal type set to 'png'
Options are 'nocrop enhanced font Vera 12 '
gnuplot&gt; set output "test.png"
gnuplot&gt; plot sin(x)
gnuplot&gt; quit
&lt;/pre&gt;

&lt;p&gt;Now start your favorite photo viewer to examine test.png (I use
Emacs in this case). Does the figure looks prettier than before? (Note: it seems that the font name is case sensitive and should be consistent with the actual file name of the font: "Vera" works in above example while "vera" not.)&lt;/p&gt;

&lt;p&gt;One limitation is that TTF fonts are not available to X11 terminal
therefore you cannot directly enjoy the effect within gnuplot. Emacs
users using gnuplot-mode might not feel too much switching pain in
this case. Another solution is: if you have ImageMagick installed, you can use png terminal, and pipe the output to ImageMagick by typing &lt;kbd&gt;set output '|display png:-'&lt;/kbd&gt; instead of plain test.png as shown above.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-2437249639309138014?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=QkYRaCrVemg:JiKhZbcG7DA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=QkYRaCrVemg:JiKhZbcG7DA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=QkYRaCrVemg:JiKhZbcG7DA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=QkYRaCrVemg:JiKhZbcG7DA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=QkYRaCrVemg:JiKhZbcG7DA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=QkYRaCrVemg:JiKhZbcG7DA:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/QkYRaCrVemg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/2437249639309138014/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/12/nicer-fonts-for-gnuplot.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2437249639309138014?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/2437249639309138014?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/QkYRaCrVemg/nicer-fonts-for-gnuplot.html" title="Nicer Fonts for Gnuplot" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/12/nicer-fonts-for-gnuplot.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYHRn08cCp7ImA9WxZTFU4.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-4219923707706081429</id><published>2007-11-28T12:52:00.000+08:00</published><updated>2008-01-17T09:42:17.378+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-17T09:42:17.378+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="blog" /><category scheme="http://www.blogger.com/atom/ns#" term="html" /><title>Format Source Code for Web</title><content type="html">&lt;h3&gt;Introduction&lt;/h3&gt;

&lt;p&gt;As both a programmer and blogger, one needs to publish source code
on blogs frequently. So how to do it? As a newcomer to blogger
community, I looked into the problem for a while. There are two issues
related to this if you only want to display your code plainly, without
syntax highlighting:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;HTML treats consecutive spaces, tabs, line breaks as a single
  space, which removes indentations of the code.&lt;/li&gt;
  &lt;li&gt;Special characters like &amp;amp;, &amp;lt;, &amp;gt;, and &amp;quot; need
  escaping, especially for HTML code itself.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My initial thought is to use &lt;em&gt;sed&lt;/em&gt;, since the above issues can be
simply solved with line by line processing, which is what sed is
designed for. Later on I realized that why not use Javascript? Then I
can publish code everywhere, which means that I can mobilize web
&lt;em&gt;authoring&lt;/em&gt;, in addition to &lt;a
href="http://yujianzhang.blogspot.com/2007/11/mobilize-web-surfing.html"&gt;mobilizing
web &lt;em&gt;surfing&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Solution&lt;/h3&gt;

&lt;p&gt;Following is the tool to convert source code to HTML fragments to
be inserted in blogs or normal web pages. Simply paste your source
code into the 1st textarea, and copy the HTML code out from the 2nd
textarea. &lt;/p&gt;

&lt;p&gt;It should be noted that I use CSS to format the source code in
&amp;lt;pre&amp;gt; element, therefore one attribute &amp;quot;code&amp;quot; appears
in the 1st line of the HTML output. One may tweak it according to
his/her own preference, e.g. change to inline style sheets.&lt;/p&gt;

&lt;form name="converter" action=""&gt;
  &lt;table&gt;
    &lt;tr&gt;&lt;td&gt;Source code:&lt;br/&gt;
      &lt;textarea name="source" onchange="formatCode();" rows="10" cols="80"&gt;
      &lt;/textarea&gt;
    &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td&gt;HTML output:&lt;br/&gt;
      &lt;textarea name="output" rows="10" cols="80"&gt;
      &lt;/textarea&gt;
    &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
&lt;/form&gt;

&lt;script type="text/javascript"&gt;
  //&lt;![CDATA[
  function formatCode () {
    var form = document.converter;
    var s = form.source.value.replace(/&amp;/g, '&amp;amp;');
    s = s.replace(/&lt;/g, '&amp;lt;').replace(/&gt;/g, '&amp;gt;').replace(/"/g, '&amp;quot;');
    form.output.value = "&lt;pre class=\"code\"&gt;\n" + s + "\n&lt;/pre&gt;\n";
    form.output.select();
  }
  //]]&gt;
&lt;/script&gt;

&lt;h3&gt;Implementation&lt;/h3&gt;

&lt;p&gt;The source code for above form and related script is shown below
formatted with itself.&lt;/p&gt;

&lt;pre class="code"&gt;
&amp;lt;form name=&amp;quot;converter&amp;quot; action=&amp;quot;&amp;quot;&amp;gt;
  &amp;lt;table&amp;gt;
    &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Source code:&amp;lt;br/&amp;gt;
      &amp;lt;textarea name=&amp;quot;source&amp;quot; onchange=&amp;quot;formatCode();&amp;quot; rows=&amp;quot;10&amp;quot; cols=&amp;quot;80&amp;quot;&amp;gt;
      &amp;lt;/textarea&amp;gt;
    &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
    &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;HTML output:&amp;lt;br/&amp;gt;
      &amp;lt;textarea name=&amp;quot;output&amp;quot; rows=&amp;quot;10&amp;quot; cols=&amp;quot;80&amp;quot;&amp;gt;
      &amp;lt;/textarea&amp;gt;
    &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/form&amp;gt;

&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
  //&amp;lt;![CDATA[
  function formatCode () {
    var form = document.converter;
    var s = form.source.value.replace(/&amp;amp;/g, '&amp;amp;amp;');
    s = s.replace(/&amp;lt;/g, '&amp;amp;lt;').replace(/&amp;gt;/g, '&amp;amp;gt;').replace(/&amp;quot;/g, '&amp;amp;quot;');
    form.output.value = &amp;quot;&amp;lt;pre class=\&amp;quot;code\&amp;quot;&amp;gt;\n&amp;quot; + s + &amp;quot;\n&amp;lt;/pre&amp;gt;\n&amp;quot;;
    form.output.select();
  }
  //]]&amp;gt;
&amp;lt;/script&amp;gt;      
&lt;/pre&gt;

&lt;p&gt;We use HTML element &amp;lt;pre&amp;gt; to solve the 1st issue listed
above. In the script, function &lt;code&gt;formatCode&lt;/code&gt; escapes special
characters; note that we should handle character &amp;amp; first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (2008-1-17)&lt;/strong&gt;: for Emacs users, you may find
&lt;a href="http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el"&gt;htmlize&lt;/a&gt;
useful for this task (with many cool features). Gentoo users can
simple &lt;kbd&gt;emerge htmlize&lt;/kbd&gt;. I just stumbled upon this cool
extension when reading the comments for &lt;a
href="http://steve.yegge.googlepages.com/saving-time"&gt;Steve Yegge's
nice post&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-4219923707706081429?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=pKR-7C-wxv8:8w9eeKN_lOI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=pKR-7C-wxv8:8w9eeKN_lOI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=pKR-7C-wxv8:8w9eeKN_lOI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=pKR-7C-wxv8:8w9eeKN_lOI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=pKR-7C-wxv8:8w9eeKN_lOI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=pKR-7C-wxv8:8w9eeKN_lOI:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/pKR-7C-wxv8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/4219923707706081429/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/11/format-source-code-for-web.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4219923707706081429?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/4219923707706081429?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/pKR-7C-wxv8/format-source-code-for-web.html" title="Format Source Code for Web" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/11/format-source-code-for-web.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUARnY_fip7ImA9WB9WEU0.&quot;"><id>tag:blogger.com,1999:blog-6613449007994858413.post-3757013134224932367</id><published>2007-11-15T13:06:00.000+08:00</published><updated>2007-11-15T13:07:27.846+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-15T13:07:27.846+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="web" /><title>Mobilize Web Surfing</title><content type="html">&lt;p&gt;At first glance, web surfing is naturally in a mobile way. You can
surf anywhere, anytime nowadays. However, the important data
associated with web surfing are not mobilized at the begining. The
most noteworthy example is your favorite websites. Traditionally, you
have to store them locally in your computer, in a format only known by
your chosen web browser. You have to copy your bookmarks around and
import them whenever you use a different computer, or even try a new
browser. That is possibly why web browsers are bundled with features
like import/export bookmarks and even the tool to migrate bookmarks
from competing browsers. Even armed with those weapons, you still have
the problem of synchronizing your bookmarks between different
computers; not to mention that the import/export process is really
boring.&lt;/p&gt;

&lt;p&gt;So here comes the so-called &lt;em&gt;social bookmark&lt;/em&gt;, with the most
successful example: &lt;a href="http://del.icio.us"&gt;del.icio.us&lt;/a&gt;. As
its name suggests, it is really a &lt;em&gt;delicious&lt;/em&gt; tool to
use. After registration, you can install browser extentions to make
the service provided by del.icio.us to integrate with your browser
seamlessly. Now you can access your bookmark anywhere: even on a
computer without the extension installed, you can simply access your
bookmarks by visiting the del.icio.us website. With the latest Firefox
extension, one bookmark sidebar is installed, which gives you instant
access to your bookmarks. In addition to these handy bookmark
functionalities, you also get &lt;em&gt;social&lt;/em&gt; effects. When you add
one nice page to your collection, you now can choose &lt;em&gt;popular&lt;/em&gt;
tags which is automatically provided by the service by examining who
else chosen to tag the same page. You now can select the
&lt;em&gt;right&lt;/em&gt; tag easily. &lt;/p&gt;

&lt;p&gt;A more efficient way, compared with checking updates of your
favorite web pages individually, is to syndicate them and process them
in a RSS reader. Most web surfers have already done so. At first, we
use a &lt;em&gt;offline&lt;/em&gt; RSS reader, i.e. subscription file is stored
locally and RSS updates are also fetched to local computer. A question
then arises, similar to the bookmark problem: how can we read RSS
updates in different places: e.g. work and home? We can synchronize
the subscription (although tedious), but we then have to manually mark
those already read in one place (note that typically new items pop up
very quickly). Online RSS reader comes into rescue now. Simple
register one, e.g. &lt;a href="http://reader.google.com/"&gt;Google
Reader&lt;/a&gt;, import your subscription file and start reading
everywhere. For my own experience, the online reader can compete with
the offline reader in almost every area, and the developing pace of
such online readers is also extremely fast!&lt;/p&gt;

&lt;p&gt;Yet another example is online notebook like &lt;a
href="http://www.google.com/notebook"&gt;Google Notebook&lt;/a&gt;. Remember
those yellow stick notes? One certainly take many notes during web
surfing. Now you can write and read them everywhere.&lt;/p&gt;

&lt;p&gt;There seems to be endless examples to fully mobilize your web
surfing experience: you can put your calendar online, write your
report online, investigate your financial status online, or prepare
your presentation online. Such experience is really excellent, and the
only thing we should be cautious is to guarantee the network
connection to avoid any agony.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6613449007994858413-3757013134224932367?l=yujianzhang.blogspot.com'/&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/yujian?a=S72r4x8GHCw:Awon3oQcnHE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=S72r4x8GHCw:Awon3oQcnHE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=S72r4x8GHCw:Awon3oQcnHE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=S72r4x8GHCw:Awon3oQcnHE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?i=S72r4x8GHCw:Awon3oQcnHE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/yujian?a=S72r4x8GHCw:Awon3oQcnHE:cGdyc7Q-1BI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/yujian?d=cGdyc7Q-1BI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/yujian/~4/S72r4x8GHCw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://yujianzhang.blogspot.com/feeds/3757013134224932367/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://yujianzhang.blogspot.com/2007/11/mobilize-web-surfing.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3757013134224932367?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6613449007994858413/posts/default/3757013134224932367?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/yujian/~3/S72r4x8GHCw/mobilize-web-surfing.html" title="Mobilize Web Surfing" /><author><name>Yujian Zhang</name><uri>http://www.blogger.com/profile/11205967188770463624</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="12454558857760247867" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://yujianzhang.blogspot.com/2007/11/mobilize-web-surfing.html</feedburner:origLink></entry></feed>
