<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Xun's blog</title>
	<link>http://uthz.com</link>
	<description>简单生活</description>
	<pubDate>Mon, 20 Oct 2008 15:14:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Problem 4</title>
		<link>http://uthz.com/2008/10/20/problem-4/</link>
		<comments>http://uthz.com/2008/10/20/problem-4/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 15:05:07 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/20/problem-4/</guid>
		<description><![CDATA[A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91  99.
Find the largest palindrome made from the product of two 3-digit numbers.
int euler4()      {      &#160;&#160;&#160;&#160;&#160;&#160; int max=0;     [...]]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/20/problem-4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>素数分解</title>
		<link>http://uthz.com/2008/10/20/%e7%b4%a0%e6%95%b0%e5%88%86%e8%a7%a3/</link>
		<comments>http://uthz.com/2008/10/20/%e7%b4%a0%e6%95%b0%e5%88%86%e8%a7%a3/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 06:57:58 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Study]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/20/%e7%b4%a0%e6%95%b0%e5%88%86%e8%a7%a3/</guid>
		<description><![CDATA[Project Euler的第三题。
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
当时马上写下的代码是
_int64 euler3(_int64&#160; n)      {       &#160;&#160;&#160; for(_int64 i=n-1;i&#62;1;i&#8211;)       &#160;&#160;&#160; {       &#160;&#160;&#160;&#160;&#160;&#160;&#160; if(IsPrime(i)) [...]]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/20/%e7%b4%a0%e6%95%b0%e5%88%86%e8%a7%a3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>欧拉工程</title>
		<link>http://uthz.com/2008/10/15/%e6%ac%a7%e6%8b%89%e5%b7%a5%e7%a8%8b/</link>
		<comments>http://uthz.com/2008/10/15/%e6%ac%a7%e6%8b%89%e5%b7%a5%e7%a8%8b/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 08:01:02 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/15/%e6%ac%a7%e6%8b%89%e5%b7%a5%e7%a8%8b/</guid>
		<description><![CDATA[显然这不是一个创造欧拉的工程，做做题而已，一想到欧拉几百年前就懂了我现在还不明白的东西就比较汗颜。
http://projecteuler.net
第一题
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
&#160;
static int&#160; Euler(int max)    {     &#160;&#160;&#160; int [...]]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/15/%e6%ac%a7%e6%8b%89%e5%b7%a5%e7%a8%8b/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Linux输入法</title>
		<link>http://uthz.com/2008/10/08/linux%e8%be%93%e5%85%a5%e6%b3%95/</link>
		<comments>http://uthz.com/2008/10/08/linux%e8%be%93%e5%85%a5%e6%b3%95/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 13:23:01 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/08/linux%e8%be%93%e5%85%a5%e6%b3%95/</guid>
		<description><![CDATA[Linux下的输入法有一个XIM框架，X程序通过XIM协议与输入法联系。如用户按下键盘按键后不直接把字符传给X程序，而是输入法程序，输入法处理后再传给X程序。aptitude install scim-pinyin同时安装了scim平台和拼音输入法。接下来就是启动scim和通知x程序使用scim。把这些事情放在一个脚本里面就是：
/usr/bin/scim -dexport&#160; XMODIFIERS=&#8221;@im=SCIM&#8221;export GTK_IM_MODULE=scim
XMODIFIERS是X程序用来识别输入法的标记，GTK和QT也有单独的一套。
为了开机自动运行把这个脚本保存为~/.xinput，然后再~/.xinitrc中加一句source ~/.xinput。
如果输入法工作不正常，检查一下
ps aux&#124;grep scim&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; scim是否启动。export &#124;grep XMODIFIERS&#160;&#160;&#160;&#160;&#160;&#160;&#160; XMODIFIERS变量是否正确设置。locale&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; LC_CTYPE是否设为zh_CN.UTF-8
&#160;
http://www.scim-im.org/projects/imengineshttp://code.google.com/p/ibus/wiki/PinYinUserGuideCNhttp://sourceforge.net/projects/novel-pinyin/http://www.opensolaris.org/os/project/input-method/
&#160;
]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/08/linux%e8%be%93%e5%85%a5%e6%b3%95/feed/</wfw:commentRss>
		</item>
		<item>
		<title>启动X</title>
		<link>http://uthz.com/2008/10/03/%e5%90%af%e5%8a%a8x/</link>
		<comments>http://uthz.com/2008/10/03/%e5%90%af%e5%8a%a8x/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 12:30:40 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[startx]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/03/%e5%90%af%e5%8a%a8x/</guid>
		<description><![CDATA[X的启动方法几种   最直接的是运行xinit或xinit firefox，不带参数的话会默认打开一个term，进入这样的X能做的事情很有限（窗口不能移动会互相覆盖），但可以让我们对窗口管理器有一个感性的认识。
 startx     在装了某个窗口管理器（如openbox或fluxbox）后，可以用startx命令进入一个带窗口管理功能的X界面。startx是一个在/usr/bin目录下的脚本，它会分别读取用户级和系统级的一些配置，然后用xinit运行X。配置文件有xinitrc，xserverrc，xsession等，一般系统级的配置在/etc/X11目录下，而用户级配置在用户主目录并用.xinitrc的形式命名，原则是用户级配置覆盖系统级配置。    如果系统安装了多个窗口管理器可用startx -m openbox的形式指定，或者在.xinitrc中加一句exec openbox。否则startx会调用/usr/bin/x-window-manager启动默认窗口管理器，它是一个指向/etc/alternatives/x-window-manager的链接，而后者是一个指向真正窗口管理器如/usr/bin/openbox的链接。这个链接通过update-alternative &#8211;config x-window-manager维护，但update-alternative是怎样知道系统有多少个窗口管理器呢。    在Debian下用strace -eopen update-alternatives &#8211;config x-window-manager监控update-alternatives的文件操作，可以发现它打开了/var/lib/dpkg/alternatives/x-window-manager，这是一个记录了系统安装的窗口管理器的文本文件，估计用Apt安装的窗口管理器都会来这里登记一下。
关于update-alternatives       因为Linux有很多相同功能的软件，alternatives是一个用来统一这些软件的机制，比如我想开一个浏览器只需要运行x-www-browser而不用管系统是装了Firefox还是Opera，alternatives机制会帮我们选择一个可用的。具体实现是在/etc/alternatives/目录创建一些通用的链接，并根据情况指向真实的程序，update-alternatives是Debian用来维护/etc/alternatives/目录下那些链接的Perl程序。如update-alternatives &#8211;config x-window-manager用来更新/etc/alternatives/x-window-manager这个链接。      

或者还可以安装启动管理器。
启动管理器是一个管理登录的程序，如GNOME用的gdm和KDE用的kdm。用这种方法的话就不需要用户手动输入命令，而是像Windows一样开机后直接得到一个输入帐号密码的登录界面。gdm们获取自动运行机会的方法是把自己加到开机默认运行级别的rc*.d目录。
]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/03/%e5%90%af%e5%8a%a8x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Debian Guest下安装VirtualBox的Additions</title>
		<link>http://uthz.com/2008/10/01/debian-guest%e4%b8%8b%e5%ae%89%e8%a3%85virtualbox%e7%9a%84additions/</link>
		<comments>http://uthz.com/2008/10/01/debian-guest%e4%b8%8b%e5%ae%89%e8%a3%85virtualbox%e7%9a%84additions/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 14:28:53 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/01/debian-guest%e4%b8%8b%e5%ae%89%e8%a3%85virtualbox%e7%9a%84additions/</guid>
		<description><![CDATA[在VBox窗口的Devices， mount CD， CD image然后选中VBoxGuestAdditions.iso确定。
Debian控制台下： mkdir /mnt/cd mount /dev/cdrom /mnt/cd -t iso9660 cd /dev/cdrom sh VBoxLinuxAdditions-x86.run help sh VBoxLinuxAdditions-x86.run
之前要安装build-essential和Linux-header文件 aptitude install build-essential uname -r查看内核版本。 aptitude search linux-header。 安装对应的头文件。
GuestAdditions的一些功能：

鼠标指针无缝连接，无需按右Ctrl切换。
更好的显示支持，在用户缩放Vbox窗口的时候自动调整Guest的分辨率来配合缩放。
共享文件夹。
共享剪切板。
以及非常酷的无缝窗口。 

共享文件夹访问 net use x: file:///P&#124;/vboxsvr/sharename mount -t vboxsf sharename /mnt/vb
无缝窗口把程序窗口从虚拟机里分离出来，这样可以把两个系统中的程序窗口统一起来，貌似Wine的完美替换，右Ctrl+L呼出。
另外装上GuestAdditions以后，就不能以Framebuffer方式启动Linux，否则会僵死掉，至少在我的机器上是这样。
]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/01/debian-guest%e4%b8%8b%e5%ae%89%e8%a3%85virtualbox%e7%9a%84additions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>控制台下的Linux</title>
		<link>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e4%b8%8b%e7%9a%84linux/</link>
		<comments>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e4%b8%8b%e7%9a%84linux/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 13:10:49 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[console]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e4%b8%8b%e7%9a%84linux/</guid>
		<description><![CDATA[图形界面下面的Linux更易于理解也更接近Linux的本质，而且基本上大部分的事情在startx之前就可以完成了。
控制台下的图像处理如mplayer和fb开头的软件都依赖framebuffer，framebuffer是Linux对显示设备的抽象，设备符号一般为/dev/fb0，可以把它理解为一幅显示到屏幕的图像，用户只要修改这幅图像就能修改显示器的视频显示，比如用dd if=/dev/fb0 of=fb.raw就可以截屏，只是因为生成的是raw图像数据，无法用图像浏览软件直接打开，还需用fbgrab等软件处理一下。而 dd if=fb.raw of=/dev/fb0则可以把之前保存的图像写回显示屏。 Debian默认支持framebuffer，但须手动开启，方法是编辑/boot/grub/menu.lst在kernel那行加上vga=ask或0&#215;343，具体值的设置可先用hwinfo &#8211;framebuffer确定。
控制台下的软件： ftp:lftp http下载：wget 浏览器：lynx 图片浏览：fbi 截屏：fbgrab 编辑：vi 文件管理：mc 影音：mplayer -vo fbdev 鼠标支持：gpm
lynx export WWW_HOME=www.google.com设置主页。 方向键操作，d下载选中文件。a书签。g跳转。k显示命令列表。 
wget export http_proxy=&#8221;http://proxy.com:8080&#8243;设置代理。 wget -r -l2 &#8211;accept=bz2,gz http://cross-lfs.org/view/clfs-sysroot/arm/materials/packages.html 下载指定页面两层链接内的所有bz2和gz文件。 wget -rkpN -np -t 5 -T 20 URL 抓全站。
lftp get ，put， mirror，mirror -r，bookmark。
vi i,a,o,O进入编辑模式。 r修改一个字符后返回Normal模式，R进入修改模式。 x删除一个字符。 dd删除行。 yyp复制行。 
http://www.linuxsir.org/bbs/thread245239.html http://www.linuxsir.org/bbs/thread199931.html http://fbsplash.berlios.de/wiki/doku.php 
]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e4%b8%8b%e7%9a%84linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>控制台字体</title>
		<link>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e5%ad%97%e4%bd%93/</link>
		<comments>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e5%ad%97%e4%bd%93/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 13:10:39 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[console]]></category>

		<category><![CDATA[font]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e5%ad%97%e4%bd%93/</guid>
		<description><![CDATA[因为当时X还没有开启，控制台不可能用X核心字体或者xft，而是有自己的一套，一般放在/usr/share/consolefonts下。可以用aptitude install console-terminus安装专门为其准备的console-terminus字体，这是一套适合控制台使用很漂亮的等宽字体。
在使用之前，用unicode_start打开Unicode模式。 whereis unicode_start vi unicode_start
db_mode -u dumpkeys &#124; loadkeys &#8211;unicode consolechars &#8211;font= &#8211;sfm= echo -n -e &#8216;33%G&#8217;

这个脚本先把键盘置于Unicode模式，然后用consolechars工具接受我们传来的参数设置字体，最后用echo -n -e &#8216;33%G&#8217;命令把控制台置为Unicode模式。 
自己设置字体的话，先ls /usr/share/consolefonts浏览字体。 consolechars -f Uni3-TerminusBoldVGA16查看效果。 确定了以后在/etc/console-tools/config中修改SCREEN_FONT为自己指定的字体。 如SCREEN_FONT=Uni3-TerminusBoldVGA16.psf
控制台只能使用这种psf字体，而系统提供的包括安装的Terminus字体中都没有中文字符，所以有Unicode编码的中文名文件时用ls命令查看会是一些小方框。
所以如果想让控制台支持中文显示以及输入，还需要其他更麻烦的步骤，如安装zhcon，然后用zhcon &#8211;utf8开启一个新的支持中文的控制台，那样刚才针对fb设置的字体都会无效。 也可以安装unicon，unicon通过修改内核提供中文支持，需要重新编译内核。另外还有fbiterm, jfbterm等。
以繁體中文介面安裝 Debian 時預設會安裝的套件
http://www.turbolinux.com.cn/products/tlw/tlc/node143.html
http://tetralet.luna.com.tw/index.php?op=ViewArticle&#38;articleId=194&#38;blogId=1
]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/01/%e6%8e%a7%e5%88%b6%e5%8f%b0%e5%ad%97%e4%bd%93/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Aptitude替换apt-get</title>
		<link>http://uthz.com/2008/10/01/aptitude%e6%9b%bf%e6%8d%a2apt-get/</link>
		<comments>http://uthz.com/2008/10/01/aptitude%e6%9b%bf%e6%8d%a2apt-get/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 06:44:22 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[未分类]]></category>

		<category><![CDATA[aptitude]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/10/01/aptitude%e6%9b%bf%e6%8d%a2apt-get/</guid>
		<description><![CDATA[


apt-get install
aptitude install pkgname
安装软件


apt-get update
aptitude update 
更新本地软件数据库


apt-get upgrade
aptitude upgrade
更新所有软件


apt-get dist-upgrade
aptitude dist-upgrade
版本升级


apt-get remove
aptitude remove pkgname
卸载软件


apt-get &#8211;purge remove
aptitude purge pkgname
卸载软件并删除配置


apt-cache search string
aptitude search string
搜索软件


apt-cache show pkgname
aptitude show pkgname
显示包信息


apt-get clean
aptitude clean
删除安装包


apt-get autoclean
aptitude autoclean
删除过期的安装包


&#160;
aptitude hold pkgname
upgrade时不升级



]]></description>
		<wfw:commentRss>http://uthz.com/2008/10/01/aptitude%e6%9b%bf%e6%8d%a2apt-get/feed/</wfw:commentRss>
		</item>
		<item>
		<title>locale设置</title>
		<link>http://uthz.com/2008/09/30/locale%e8%ae%be%e7%bd%ae/</link>
		<comments>http://uthz.com/2008/09/30/locale%e8%ae%be%e7%bd%ae/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 08:31:10 +0000</pubDate>
		<dc:creator>uthz</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[locale]]></category>

		<guid isPermaLink="false">http://uthz.com/2008/09/30/locale%e8%ae%be%e7%bd%ae/</guid>
		<description><![CDATA[locale -a列出所有locale
Debian可用dpkg-reconfigure locales重新配置locale。
或者手动编辑 /etc/locale.gen(从/usr/share/i18n/SUPPORTED选择想要的locale），然后运行locale-gen。
编辑/etc/defaults/locale设置默认local。
locale变量：
LANG 语言
c程序运行时会依次检查LC_ALL,LC_CTYPE,LANG并使用第一个有效值作为locale并加载相关locale data。
所谓的locale主要就是决定字符的解码方式，以及数字时间货币等每个地区不同的显示方式。
LANG=en_US.UTF-8
en语言，US国家，utf-8编码。en_US.UTF-8和zh_CN.UTF-8的区别，不是说有几种UTF-8，而是前面两个变量的区别。任选一种带UTF-8的locale就可以正常显示中文，只是货币时间等的表示会有不习惯，另外输入法会依赖中文locale。
LC_CTYPE定义字符编码。
LC_COLLATE定义字符串如何排序。
其他的LC_都是自解释的，就不赘述了。
LC_ALL和LANG都可以做LC_*没有设置时的默认值，但LC_*单独设置时只能覆盖LANG加与的默认值，LC_ALL的默认的优先级别最高，一旦设置了LC_ALL其他的设置都会无效。所以一般只设置LANG和LC_CTYPE。
比如LANG=en_US.UTF-8
LC_TYPE=zh_CN.UTF-8这样就可以配一个使用中文的英文环境。
]]></description>
		<wfw:commentRss>http://uthz.com/2008/09/30/locale%e8%ae%be%e7%bd%ae/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
