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

<channel>
	<title>A Geek's Page</title>
	<atom:link href="http://wangcong.org/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://wangcong.org/blog</link>
	<description>Stay Hungry, Stay Foolish</description>
	<lastBuildDate>Sun, 22 Jan 2012 07:56:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>2012 年祝你幸运</title>
		<link>http://wangcong.org/blog/archives/1879</link>
		<comments>http://wangcong.org/blog/archives/1879#comments</comments>
		<pubDate>Sun, 22 Jan 2012 04:54:37 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1879</guid>
		<description><![CDATA[2011 年马上就要过去了，回顾过去的一年，我发现最正确的决定就是离开北京。北京的空气污染已经到了非常严重的程度，奉劝各位能不去北京就别去，别拿自己的身体健康开玩笑。在这个神奇... ]]></description>
			<content:encoded><![CDATA[<p>2011 年马上就要过去了，回顾过去的一年，我发现最正确的决定就是离开北京。北京的空气污染已经到了非常严重的程度，奉劝各位能不去北京就别去，别拿自己的身体健康开玩笑。在这个神奇的国度，能让自己健康地活着本身就是一种很大的成功！</p>
<p>在 2011 年中，中华民族已经到了最坑爹的时候，所以在 2012 年里，祝愿大家都能有新鲜的空气呼吸，能有正常的牛奶喝，能有健康的食用油吃，能有一所房子不被强拆，能有个孩子是亲生的，能扶起老太不被讹，最关键的是，能让自己不被活埋！</p>
<p>虽然你仍然不可能像对岸一样能投上一票，但是你能选择离开。所以，有钱有本事的还是尽早移民吧！没本事的就好好练习游泳，游到对岸去！要自由从来都不丢人，“我们这儿”才丢人！</p>
<p>说了那么多，我觉得，在所有的新年祝福辞里，“祝你幸运”是最好的，也是最现实的祝福了。所以，祝你 2012 年幸运！</p>
<p>最后祝愿所有的五毛，全家都搬到朝鲜去，早日体会到社会主义的优越性！</p>
<p>2012 年，要幸福，更要自由。</p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1879/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>扩展文件属性</title>
		<link>http://wangcong.org/blog/archives/1871</link>
		<comments>http://wangcong.org/blog/archives/1871#comments</comments>
		<pubDate>Thu, 19 Jan 2012 02:52:55 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Linux Application]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1871</guid>
		<description><![CDATA[我们知道，在 Linux 上最基本的文件属性是，

# ls -l foo
-rw-r--r--. 1 root root 0 Jan 19 00:03 foo

可以通过chmod 命令来更改，ls -l 来查看。
除此之外，一些文件系统上还提供额外的属性，比如 ext4 提供... ]]></description>
			<content:encoded><![CDATA[<p>我们知道，在 Linux 上最基本的文件属性是，</p>
<pre>
# ls -l foo
-rw-r--r--. 1 root root 0 Jan 19 00:03 foo
</pre>
<p>可以通过chmod 命令来更改，ls -l 来查看。</p>
<p>除此之外，一些文件系统上还提供额外的属性，比如 ext4 提供了额外的属性，比如 append only (a), compressed (c), immutable (i) 等属性，这些属性可以通过 e2fsprogs 软件包提供的 chattr(1) 来改变，lsattr(1) 来查看。更多属性也可参考 chattr(1)。比如：</p>
<pre>
# chattr +i foo
# lsattr foo
----i--------e- foo
</pre>
</p>
<p>这个是和文件系统密切相关的，一是因为 chattr 来自 e2fsprogs，二是因为它调用的系统调用也是和文件系统相关的一个 ioctl，可以看下面 strace 的输出：</p>
<pre>
open("foo", O_RDONLY|O_NONBLOCK|O_LARGEFILE) = 3
ioctl(3, EXT2_IOC_SETFLAGS or EXT3_IOC_SETFLAGS or FIONCLEX, 0xfffc347335c) = 0
close(3)                                = 0
</pre>
</p>
<p>
还有一种文件属性叫扩展文件属性，<a href="http://en.wikipedia.org/wiki/Extended_file_attributes">eXtended ATTRibutes</a>，也就是通常所说的 xattr。和前一种相比，这个就不那么和文件系统密切相关了，但是仍然需要文件系统的支持。这个是通过系统调用 getxattr(2) 和 setxattr(2) 来实现的，对应的命令是 getfattr(1) 和 setfattr(1)，来自 <a href="http://acl.bestbits.at/">attr 软件包</a>。看例子：</p>
<pre>
# mount -o remount,acl,user_xattr /home
# touch bar
# setfattr -n user.comment -v "this is a comment" bar
# getfattr bar
# file: bar
user.comment

# getfattr bar -n user.comment
# file: bar
user.comment="this is a comment"
</pre>
<p>需要注意两点：一，挂载时需要加 &#8220;user_xattr&#8221; 选项；二，name 是有命名空间的，并不是任何命名空间都可以，比如，</p>
<pre>
# setfattr -n my.comment -v "this is my comment" bar
setfattr: bar: Operation not supported
</pre>
<p>用户只能用 user.* 名字，而后面的 ACL 则会用 system.posix_acl_access。当然了，SELinux 也会用到 xattr，security.*。
</p>
<p>
基于此，ACL 实现了访问控制列表，也就是说，设置某些用户的文件权限不再依赖于用户所在的组了，省去了不少麻烦。对应的命令是 setfacl(1) 和 getfacl(1) ，来自 <a href="http://acl.bestbits.at/">acl 软件包</a>。从下面 strace 的输出，也可以看出它们确实是基于 xattr 的：</p>
<pre>
getxattr("foo", "system.posix_acl_access", 0xfffe455cca0, 132) = -1 ENODATA (No data available)
stat("foo", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
setxattr("foo", "system.posix_acl_access", "\x02\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x02\x00\x06\x00\x00\x00\x00\x00\x04\x00\x04\x00\xff\xff\xff\xff\x10\x00\x06\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff", 44, 0) = -1 EPERM (Operation not permitted)
</pre>
<p>之所以出现 ENODATA 是因为挂载文件系统时我没有指定&#8221;acl&#8221;，需要重新挂载：mount -o remount,acl /home 然后重新创建文件，因为旧的文件依旧是没有 ACL的。</p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1871/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>抵制 SOPA</title>
		<link>http://wangcong.org/blog/archives/1857</link>
		<comments>http://wangcong.org/blog/archives/1857#comments</comments>
		<pubDate>Wed, 18 Jan 2012 10:19:00 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1857</guid>
		<description><![CDATA[世界上最遥远的距离不是生与死，而是人家那儿都开始抵制 SOPA 了，组建盗版党了，我们这儿（张绍刚同志对此有贡献）还在热火朝天地搞 GFW 呢！
下面是几大网站今天的首页，最后一张截图... ]]></description>
			<content:encoded><![CDATA[<p>世界上最遥远的距离不是生与死，而是人家那儿都开始抵制 SOPA 了，组建盗版党了，我们这儿（张绍刚同志对此有贡献）还在热火朝天地搞 GFW 呢！</p>
<p>下面是几大网站今天的首页，最后一张截图最能说明问题！</p>
<p>gnu.org （标题变成了01000100010010010100011101001001010101000100000101001100）</p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/gnu.png"><img class="size-full wp-image-1862    aligncenter" title="GNU" src="http://wangcong.org/blog/wp-content/uploads/2012/01/gnu.png" alt="" width="347" height="339" /></a></p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_003.png"><img class="size-large wp-image-1858  aligncenter" title="We're going to black out all our sites at the Free Software Foundation..." src="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_003-1024x418.png" alt="" width="717" height="293" /></a></p>
<p>wikipedia.org</p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_004.png"><img class="size-large wp-image-1859  aligncenter" title="wikipedia.org" src="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_004-1024x558.png" alt="" width="717" height="391" /></a></p>
<p>fedoraproject.org</p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_007.png"><img class="size-full wp-image-1861  aligncenter" title="fedoraproject.org" src="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_007.png" alt="" width="637" height="305" /></a></p>
<p>reddit.com</p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_006.png"><img class="size-full wp-image-1860  aligncenter" title="reddit.com" src="http://wangcong.org/blog/wp-content/uploads/2012/01/Selection_006.png" alt="" width="229" height="71" /></a></p>
<p>wordpress.org</p>
<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/wordpress.png"></a><a href="http://wangcong.org/blog/wp-content/uploads/2012/01/wordpress1.png"><img class="size-full wp-image-1868  aligncenter" title="wordpress.org" src="http://wangcong.org/blog/wp-content/uploads/2012/01/wordpress1.png" alt="" width="541" height="720" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1857/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>kindle 相关</title>
		<link>http://wangcong.org/blog/archives/1854</link>
		<comments>http://wangcong.org/blog/archives/1854#comments</comments>
		<pubDate>Mon, 09 Jan 2012 03:53:07 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1854</guid>
		<description><![CDATA[上周末在淘宝上拍了一个 Kindle DXG，今天终于拿到手了。买之前做了大量的功课，经过了N次纠结之后最终敲定买 DXG。一是因为，我个人认为看书嘛，屏幕好一点儿很重要，DX 系列是大屏幕；二... ]]></description>
			<content:encoded><![CDATA[<p>上周末在淘宝上拍了一个 Kindle DXG，今天终于拿到手了。买之前做了大量的功课，经过了N次纠结之后最终敲定买 DXG。一是因为，我个人认为看书嘛，屏幕好一点儿很重要，DX 系列是大屏幕；二是，我感觉 WIFI 可有可无，我又没打算拿它当 fire 用，而且自带的 3G 是免费的。所以最后选择了 Kindle DXG。</p>
<p>网上有很多写 kindle 的文章，我就不再啰嗦了，把我看的一些文章整理一下和大家分享。</p>
<p>1. 出手前对比：</p>
<p>Compare Kindles：<a href="www.amazon.com/gp/product/B002Y27P3M/ref=sv_kinh_0" target="_blank">www.amazon.com/gp/product/B002Y27P3M/ref=sv_kinh_0</a><br />
Kindle 3 vs. Kindle DXG：<a href="http://www.conanblog.me/life/kindle-3-vs-kindle-dxg/" target="_blank">http://www.conanblog.me/life/kindle-3-vs-kindle-dxg/</a><br />
入手了个Kindle：<a href="http://www.xuwenhao.com/2011/06/08/bought-a-kindle-and-ideas-on-ebook/" target="_blank">http://www.xuwenhao.com/2011/06/08/bought-a-kindle-and-ideas-on-ebook/</a><br />
入手Kindle Fire，简单评测：<a href="http://" target="_blank">http://jayshao.com/kindle-fire/</a><br />
关于入手kindle一记：<a href="http://blog.yousri.org/2011/12/07/something-about-buying-kindle.html" target="_blank">http://blog.yousri.org/2011/12/07/something-about-buying-kindle.html</a><br />
玩物不能丧志——Kindle Fire手记：<a href="http://www.baizhiheizi.com/archives/497" target="_blank">http://www.baizhiheizi.com/archives/497</a><br />
入手 Kindle：<a href="http://blog.solrex.org/articles/bought-a-kindle.html" target="_blank">http://blog.solrex.org/articles/bought-a-kindle.html</a><br />
没有3G的Kindle是残缺的，不推荐国人买纯WIFI版：<a href="http://www.v2ex.com/t/10062" target="_blank">http://www.v2ex.com/t/10062</a></p>
<p>2. 购买：</p>
<p>我是在老大推荐的一个淘宝店买的：<a href="http://5friends.taobao.com/" target="_blank">http://5friends.taobao.com/</a></p>
<p>其它店铺请自行搜索。</p>
<p>3. 越狱和汉化：</p>
<p>Kindle DXG 完美中文支持：<a href="http://www.conanblog.me/it/kindle-dxg-perfect-font-hack/" target="_blank">http://www.conanblog.me/it/kindle-dxg-perfect-font-hack/</a><br />
Kindle DXG 汉化：<a href="http://hardywang.wordpress.com/2011/12/25/kindle-dxg-%E6%B1%89%E5%8C%96/" target="_blank">http://hardywang.wordpress.com/2011/12/25/kindle-dxg-%E6%B1%89%E5%8C%96/</a><br />
Kindle 全型号、全版本，汉化升级包 完全防呆 完美功能 终结版：<a href="http://is.gd/cFAy5A" target="_blank"> http://is.gd/cFAy5A</a><br />
Kindle Touch 5.0系统越狱：<a href="http://irising.me/2011/12/12591/" target="_blank">http://irising.me/2011/12/12591/</a></p>
<p>4. 各种折腾：</p>
<p>Kindle 3注册全过程：<a href="http://www.hiadmin.org/shares/kindle3/" target="_blank">http://www.hiadmin.org/shares/kindle3/</a><br />
Kindle-DXG升级到3.2.1的好处：<a href="http://laoyang.info/why-you-should-update-kindle-dxg-to-3-2-1/" target="_blank">http://laoyang.info/why-you-should-update-kindle-dxg-to-3-2-1/</a><br />
如何用Kindle看RSS：<a href="http://laoyang.info/kindle-rss/" target="_blank">http://laoyang.info/kindle-rss/</a><br />
推荐多看系统 for Kindle DXG：<a href="http://zhiqiang.org/blog/it/duokan-for-kindle-dxg.html" target="_blank">http://zhiqiang.org/blog/it/duokan-for-kindle-dxg.html</a></p>
<p>5. Kindle 电子书：</p>
<p>Kindle电子书搜索：<a href="http://forfrigg.com/" target="_blank">http://forfrigg.com/</a><br />
kindle专用搜索工具：<a href="http://kindle.youliao.org/" target="_blank">http://kindle.youliao.org/</a><br />
Free Kindle Books：<a href="http://blog.booksontheknob.org/p/kindle-free-reads-list.html" target="_blank">http://blog.booksontheknob.org/p/kindle-free-reads-list.html</a><br />
iKindle：<a href="http://ikindle.mobi/" target="_blank">http://ikindle.mobi/</a><br />
Kindle4RSS：<a href="http://kindle4rss.com/" target="_blank">http://kindle4rss.com/</a><br />
读览天下：<a href="http://www.dooland.com/" target="_blank">http://www.dooland.com/</a></p>
<p>6. Kindle 论坛：</p>
<p>豆瓣小组：<a href="http://www.douban.com/group/Kindle/" target="_blank">http://www.douban.com/group/Kindle/</a><br />
电子书论坛：<a href="http://bbs.mydoo.cn/forum.php?mod=forumdisplay&amp;fid=28&amp;page=1" target="_blank">http://bbs.mydoo.cn/forum.php?mod=forumdisplay&amp;fid=28&amp;page=1</a><br />
多看论坛：<a href="http://bbs.duokan.com/forum/" target="_blank">http://bbs.duokan.com/forum/</a><br />
Hi! PDA：<a href="http://www.hi-pda.com/forum/" target="_blank">http://www.hi-pda.com/forum/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1854/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>洱海，2011年12月9日</title>
		<link>http://wangcong.org/blog/archives/1848</link>
		<comments>http://wangcong.org/blog/archives/1848#comments</comments>
		<pubDate>Fri, 23 Dec 2011 07:23:42 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1848</guid>
		<description><![CDATA[
这次骑车环洱海的时候天空多云，本以为不会看到太漂亮的景色，没想到正好看到阳光透过云层洒向湖面，犹如仙境一般。。。
... ]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://wangcong.org/blog/wp-content/uploads/2011/12/R0030887.jpg"><img class="size-large wp-image-1849  aligncenter" title="洱海" src="http://wangcong.org/blog/wp-content/uploads/2011/12/R0030887-1024x768.jpg" alt="" width="717" height="538" /></a></p>
<p>这次骑车环洱海的时候天空多云，本以为不会看到太漂亮的景色，没想到正好看到阳光透过云层洒向湖面，犹如仙境一般。。。</p>
<p><script type="text/javascript" src="http://www.xiami.com/widget/player-single?uid=0&#038;sid=1770568566&#038;mode=js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1848/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>C 语言新标准——C11</title>
		<link>http://wangcong.org/blog/archives/1843</link>
		<comments>http://wangcong.org/blog/archives/1843#comments</comments>
		<pubDate>Wed, 21 Dec 2011 14:46:14 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1843</guid>
		<description><![CDATA[12月8号，ISO 发布了新的 C 语言的新标准——C11，之前被称为C1X，官方名称 ISO/IEC 9899:2011。新的标准可以这里下载。这个标准是基于今年4月发布的名为 N1570 的草稿，但据说并未做任何改动。
根... ]]></description>
			<content:encoded><![CDATA[<p>12月8号，ISO <a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=57853" target="_blank">发布了</a>新的 C 语言的新标准——C11，之前被称为C1X，官方名称 ISO/IEC 9899:2011。新的标准可以<a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf" target="_blank">这里</a>下载。这个标准是基于今年4月发布的名为 N1570 的草稿，但据说并未做任何改动。</p>
<p>根据 <a href="http://en.wikipedia.org/wiki/C1X" target="_blank">wikipedia 记载</a>，相比 C99，C11 做了以下重要的更新：</p>
<p>1. 对齐处理操作符 alignof，函数 aligned_alloc()，以及  头文件 &lt;stdalign.h&gt;。见 7.15 节。</p>
<p>2.  _Noreturn 函数标记，类似于 gcc 的 __attribute__((noreturn))。例子：</p>
<pre>	_Noreturn void thrd_exit(int res);</pre>
<p>3.  _Generic 关键词，有点儿类似于 gcc 的 typeof。例子：</p>
<pre>#define cbrt(X) _Generic((X), long double: cbrtl, \
                              default: cbrt, \
                              float: cbrtf)(X)</pre>
<p>4.  静态断言（ static assertions），_Static_assert()，在解释 #if 和 #error 之后被处理。例子：</p>
<pre>	_Static_assert(FOO &gt; 0, "FOO has a wrong value");</pre>
<p>5. 删除了 gets() 函数，C99中已经将此函数被标记为过时，推荐新的替代函数 gets_s()。</p>
<p>6. 新的 fopen() 模式，(&#8220;…x&#8221;)。类似 POSIX 中的 O_CREAT|O_EXCL，在文件锁中比较常用。</p>
<p>7. 匿名结构体/联合体，这个早已经在 gcc 中了，我们并不陌生，定义在 6.7.2.1 p13。</p>
<p>8. 多线程支持，包括：_Thread_local，头文件 &lt;threads.h&gt;，里面包含线程的创建和管理函数（比如 thrd_create()，thrd_exit()），mutex （比如 mtx_lock()，mtx_unlock()）等等，更多内容清参考 7.26 节。</p>
<p>9. _Atomic类型修饰符和  头文件 &lt;stdatomic.h&gt;，见 7.17 节。</p>
<p>10. 带边界检查（Bounds-checking）的函数接口，定义了新的安全的函数，例如 fopen_s()，strcat_s() 等等。更多参考 Annex K。</p>
<p>11. 改进的 Unicode 支持，新的头文件 &lt;uchar.h&gt; 等。</p>
<p>12. 新增 quick_exit() 函数，作为第三种终止程序的方式，当 <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1327.htm" target="_blank">exit() 失败</a>时可以做最少的清理工作（deinitializition），具体见 7.22.4.7。</p>
<p>13. <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1464.htm" target="_blank">创建复数</a>的宏， CMPLX()，见 7.3.9.3。</p>
<p>14. 更多浮点数处理的宏 （More macros for querying the characteristics of floating point types, concerning subnormal floating point numbers and the number of decimal digits the type is able to store）。</p>
<p>15. struct timespec 成为 time.h 的一部分，以及宏 TIME_UTC，函数 timespec_get()。</p>
<p>gcc 4.6 中新增了新的选项 -std=c1x 来支持这一标准，更多支持参考<a href="http://gcc.gnu.org/gcc-4.6/changes.html#c" target="_blank">这里</a>。但是 glibc 相关的部分尚未实现，所以你还不能马上在 Linux 上体验最新的 C11 特性。</p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1843/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Polyglot</title>
		<link>http://wangcong.org/blog/archives/1838</link>
		<comments>http://wangcong.org/blog/archives/1838#comments</comments>
		<pubDate>Sat, 17 Dec 2011 07:02:54 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1838</guid>
		<description><![CDATA[可能你之前也见过这种程序：它是用两种以上的编程语言写成，可以不经修改作为两种语言编译/解释。今天在 wikipedia 上看到了它的定义：
In computing, a polyglot is a computer program or script written in a ... ]]></description>
			<content:encoded><![CDATA[<p>可能你之前也见过这种程序：它是用两种以上的编程语言写成，可以不经修改作为两种语言编译/解释。今天在 wikipedia 上看到了它的<a href="http://en.wikipedia.org/wiki/Polyglot_%28computing%29">定义</a>：</p>
<blockquote><p>In computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independent of the programming language used to compile or interpret it.</p></blockquote>
<p>之前见过的用2种语言写的 Polyglot 简直弱爆了，这里有用至少6种语言写成的 Polyglot：</p>
<p><a href="http://ideology.com.au/polyglot/">http://ideology.com.au/polyglot/</a> （8种语言）<br />
<a href="http://mauke.dyndns.org/stuff/poly.poly">http://mauke.dyndns.org/stuff/poly.poly</a> (16种语言！原链接不能用，我<a href="http://wangcong.org/down/poly.poly">备份了一下</a>。)</p>
<p>更多的 Polyglot：</p>
<p><a href="http://www.nyx.net/~gthompso/poly/polyglot.htm">http://www.nyx.net/~gthompso/poly/polyglot.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1838/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在窗口中显示X桌面</title>
		<link>http://wangcong.org/blog/archives/1835</link>
		<comments>http://wangcong.org/blog/archives/1835#comments</comments>
		<pubDate>Fri, 16 Dec 2011 10:59:47 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Linux Application]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1835</guid>
		<description><![CDATA[最近在鼓捣 awesome 的时候看到这么一个脚本，可以在 gnome (或其它任何桌面) 的窗口中显示 X 桌面，这样以来测试 awesome 的配置就很方便了！Xephyr 真是个好东西啊！
PLAIN TEXT
BASH:




#!/bin/sh


##


... ]]></description>
			<content:encoded><![CDATA[<p>最近在鼓捣 awesome 的时候看到这么一个脚本，可以在 gnome (或其它任何桌面) 的窗口中显示 X 桌面，这样以来测试 awesome 的配置就很方便了！Xephyr 真是个好东西啊！</p>
<div class="igBar"><span id="lbash-2"><a href="#" onclick="javascript:showPlainTxt('bash-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">BASH:</span>
<div id="bash-2">
<div class="bash" style="font-family: monospace;">
<ol>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## test.sh</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## Login : &lt;ctaf@ctaf-maptop&gt;</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## Started on &nbsp;Thu Sep &nbsp;3 15:29:14 2009 Cedric GESTES</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## $Id$</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## Author(s):</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## &nbsp;- Cedric GESTES &lt;ctaf42@gmail.com&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## Copyright (C) 2009 Cedric GESTES</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## This program is free software; you can redistribute it and/or modify</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## it under the terms of the GNU General Public License as published by</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## the Free Software Foundation; either version 3 of the License, or</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## (at your option) any later version.</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## This program is distributed in the hope that it will be useful,</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. &nbsp;See the</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## GNU General Public License for more details.</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## You should have received a copy of the GNU General Public License</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## along with this program; if not, write to the Free Software</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">##</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">&nbsp;</div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">Xephyr -ac -br -noreset -screen 800x600 :<span style="color: #000000;color:#800000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;color:#800000;">1</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #007800;">DISPLAY=</span>:<span style="color: #000000;color:#800000;">1.0</span> awesome -c ~<span style="color: #000000; font-weight: bold;">/</span>.config<span style="color: #000000; font-weight: bold;">/</span>awesome<span style="color: #000000; font-weight: bold;">/</span>rc.lua</div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1835/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>再遇 bash 引号问题</title>
		<link>http://wangcong.org/blog/archives/1833</link>
		<comments>http://wangcong.org/blog/archives/1833#comments</comments>
		<pubDate>Thu, 08 Dec 2011 15:45:51 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/?p=1833</guid>
		<description><![CDATA[最近在工作中再次遇到引号的问题，与以往不同，这次这个更加棘手。
问题是这样的：我要在某个 bash 脚本中调用某个命令，根据配置文件来决定应该传递哪些参数给调用的那个命令。而且，... ]]></description>
			<content:encoded><![CDATA[<p>最近在工作中再次遇到引号的问题，与以往不同，这次这个更加棘手。</p>
<p>问题是这样的：我要在某个 bash 脚本中调用某个命令，根据配置文件来决定应该传递哪些参数给调用的那个命令。而且，该命令的其中一个参数中带有空格，所以必须使用双引号把这一参数作为整体传递进去。你可以试一下，无论怎么使用引号都无法解决这个问题。</p>
<p>最后，我在 <a href="http://mywiki.wooledge.org/BashFAQ/050" target="_blank">Bash FAQ 中</a>找到了答案！解决方法是，把该命令的每一个参数作为 bash 数组的一个元素，最后用 "${args[@]}" 一起传递给该命令即可！</p>
<p>另，<a href="http://mywiki.wooledge.org/BashFAQ" target="_blank">Bash FAQ</a> 质量非常高，强烈推荐认真读一下。</p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1833/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>显示 shell 函数定义</title>
		<link>http://wangcong.org/blog/archives/1831</link>
		<comments>http://wangcong.org/blog/archives/1831#comments</comments>
		<pubDate>Thu, 01 Dec 2011 05:44:02 +0000</pubDate>
		<dc:creator>王 聪</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wangcong.org/blog/archives/1831</guid>
		<description><![CDATA[我们知道在 bash/zsh 中可以用 "typeset -f" 来显示某个函数的定义。如果不用这个内置命令的话我们应该怎么显示函数定义呢？
下面这个技巧就可以用来显示函数定义：
PLAIN TEXT
BASH:




#!/bin/bash


&... ]]></description>
			<content:encoded><![CDATA[<p>我们知道在 bash/zsh 中可以用 "typeset -f" 来显示某个函数的定义。如果不用这个内置命令的话我们应该怎么显示函数定义呢？</p>
<p>下面这个技巧就可以用来显示函数定义：</p>
<div class="igBar"><span id="lbash-4"><a href="#" onclick="javascript:showPlainTxt('bash-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">BASH:</span>
<div id="bash-4">
<div class="bash" style="font-family: monospace;">
<ol>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">&nbsp;</div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">def<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">&nbsp; <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;$1() $2&quot;</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">&nbsp; <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;function_$1=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\$</span>1() <span style="color: #000099; font-weight: bold;">\$</span>2<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #7a0874; font-weight: bold;">&#125;</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;">def foo <span style="color: #ff0000;">'{</span></div>
</li>
<li style="font-weight: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #ff0000;"> &nbsp;echo bar</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;"><span style="color: #ff0000;">}'</span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>其中 foo 是定义的函数，$function_foo 是函数 foo 的定义。不过缺点也很明显，每次定义函数必须使用"def"，而且后面用的单引号也是个问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://wangcong.org/blog/archives/1831/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.278 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-23 17:18:09 -->

