君子剑的密室

Thursday, September 13, 2007

Debian下每30次的磁盘检查

今天有朋友说起来了这个事儿。呵呵,说实话,在某些情况下,当开机时发现该检查径自开始而不管你的感受时,的确是件让人有些郁闷的事儿。但是,不得不说,定期的磁盘检查的确是应该的,因此完全地禁止这种设定,实属不该。毕竟,在linux下,磁盘分区的检查必须是在unmounted状态下,所以往往不是随时随地都能开始的,并且因此经常被用户一再忽略,即使用户偶尔想起它来。
解决的办法倒也简单,一个呢是临时性的,既通过在/上创建fastboot文件来阻止下次开机的强制检查。这个方法的原理记载于/etc/init.d/checkfs.sh。另一个方法是直接修改ext3分区强制执行的启动条件:通过tune2fs命令可以修改强制检查前的次数不为30,而为其他的用户更想要的数值。

Wednesday, September 12, 2007

Google Earth里面的飞行模拟游戏

http://earth.google.com/intl/en/userguide/v4/flightsim/index.html
经过验证,Linux/Mac/Windows下的最新版的Google Earth应该都带了这个游戏,启动方法是Ctrl-Alt-A组合键。不过,在Linux下,具体的激活方法和窗口管理器还有一定的关系,至少Gnome/Metacity下使用Ctrl-Alt-a就可以了,Ctrl-Alt-A(大写A)反而不行,古怪。

Monday, September 10, 2007

Linus Torvalds炮轰C++

From: Linus Torvalds linux-foundation.org>
Subject: Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.
Newsgroups: gmane.comp.version-control.git
Date: 2007-09-06 17:50:28 GMT (12 hours and 25 minutes ago)

On Wed, 5 Sep 2007, Dmitry Kakurin wrote:
>
> When I first looked at Git source code two things struck me as odd:
> 1. Pure C as opposed to C++. No idea why. Please don't talk about portability,
> it's BS.

*YOU* are full of bullshit.

C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

- infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)

- inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that
do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage.

If you want a VCS that is written in C++, go play with Monotone. Really. They use a "real database". They use "nice object-oriented libraries". They use "nice C++ abstractions". And quite frankly, as a result of all these design decisions that sound so appealing to some CS people, the end result is a horrible and unmaintainable mess.

But I'm sure you'd like it more than git.

可叹可笑的贾柳楼结拜

三国中的桃园三结义、说唐里面的贾柳楼四十六友结拜、水浒里面的一百零八人英雄排座次,向来是脍炙人口的义结金兰的故事。但是依我看来,三国小说中的刘关张之间是真信义真兄弟;水浒里面的一百单八将虽然下场不好,但是至少没有什么相负的事情发生;唯独这个贾柳楼结拜,真真令人可叹可笑。他们结拜之初便充满了矛盾,结拜也几乎出于徐茂公和魏征的有心算无心,论及下场更是悲惨。其中既有为了旧主而丧命的(王伯当),也有誓不降隋而被杀的(单雄信),即便是活着的也分为几派。异性兄弟最终为了富贵而手足相残,怎么能够不令人可叹可笑呢。

Sunday, September 09, 2007

在Eclipse中用gvim作编辑器

Eclipse和gvim是啥就不用我罗唆了,而如何将二者结合起来却一直是广大vim&Eclipse用户关心的问题。如今这个问题终于有了个比较漂亮的解决方案:
http://code.google.com/p/eeedit/

通过这个Eclipse插件,凡是支持Netbeans external editor protocol的编辑器都可以被设置为Eclipse的编辑器(至少理论上如此)。因此,如果要使用这一解决方案,需要先确定你的gvim在编译时加入了该协议的支持。这一点可以通过:version看到(+netbeans_intg)。对于Debian用户,安装vim-full包即可。

然后从上述的eeedit主页下载编译好的plugin包(形如org.eeedit.vimclient_.zip的文件),并将其中的org.eeedit.vimclient_文件夹解压缩到Eclipse的plugins目录中(比如/usr/lib/eclipse/plugins/)。然后启动eclipse,通过其菜单Help->About Eclipse SDK->Plug-in Details确认Eeedit插件已经生效。然后通过菜单Window->Preferences->Eeedit Prerences->Vim Preferences进行相应的设置,比如打开embed功能。

安装过程到此结束,可以开始在Eclipse环境中用gvim冲浪了。

“两肋插刀”的来历

不知道从什么时候开始就知道了这个词儿,但是却始终没有仔细琢磨过其含义,更没有认真考虑过其合理性。今天听田连元先生的评书,才知道了这个词儿的一种来源解释:秦琼访出了劫皇杠的真凶尤俊达、程咬金,但是出于朋友义气却又必须为其隐瞒。尤俊达、程咬金住在汝南庄,而皇杠的主人靠山王杨林则驻军于登州。当秦琼纵马到了汝南庄和登州的岔路口“两累庄”时,决定不去汝南庄继续办案,反而去登州冒名定罪。秦琼的这种为朋友甘于赴死的义气,便被传为“为朋友两累庄岔道”,并且逐渐被讹传成了“两肋插刀”。