2008年9月25日星期四

What is sun4u and sun4v?

They are both variants of the so called sun-4 platform, launched by Sun from 1987. The u(ultra) variant dervied from the used Ultra-series CPU, and the v(virtual) variant derived from the Virtualization enabled CPU. See http://en.wikipedia.org/wiki/Sun-4 for more detail.

2007年5月14日星期一

桌上足球比赛闯入四强

今天中午连赛两场,第一场由于对方防守队员比较弱,被我狂轰乱炸一通,最终进了16个球(8分钟)。其实还是蛮惊险的,上半场一路领先,结束时我方以 10:4 领先。下半场对方发起了猛烈的进攻,比分竟然被追为 10 平。我方又发扬愈战愈勇的精神,连续进了六个球,直接打击了对方的嚣张气焰,最终将比分锁定为 16:11。呵呵,这场打的确实爽啊,看得观众们惊呼不断。

第二场迎战夺冠热门队,对方的实力确实很强。进攻球员非常的沉着冷静,我方后卫很难招架;而对方防守队员也不弱。上半场结束时落后一分,本想在下半场追回,不想下半场对方的后卫加强了防守,竟然没有什么机会破门,相比之下,我方又被连进 N 球,最终败北。

在前两场连败的情况下,我队以三负一胜的战绩排名第四(有一队全败),顺利晋级四强。接下来就是淘汰赛了,各个对手都非常的强悍。如何确定一个有效的战术,还真是一个问题。如果防守队员稍加训练,就能有效的阻止前锋的进攻,所以后防线确实是一个非常重要的事情啊。

酒精是脑细胞杀手

前两天有个兄弟举办婚宴,喝了一点白酒,直接导致我当天下午兼晚上头晕,脑袋象生锈了一般,无法思考。睡了一觉起来,仍觉得晕晕糊糊,看来酒精的确是脑细胞杀手。以后发誓不饮白酒,身体先天不适合喝酒。

给 TeX 增加一个中文字体

今天在网上看到方正发布了一款徐静蕾的手写字体,看上去蛮清秀的,于是乎就下载了一个(莫 BS 我),准备在自己的 TeX 系统中使用。记得以前写过一个在 TeX 下增加中文字体的脚本,现在找不到了,不过好在 dvipdfmx 的字体还是很容易配置的。简单介绍一下,添加字体的过程分为三步:

第一步:为 TeX 增加字体配置
(1) 在 tex/latex/CJK/UTF8/ 下增加一个 c70jinglei.fd,内容按照 c70song.fd 替换 song 为 jinglei 即可;
(2) 生成 tfm/enc 文件,具体命令为:
ttf2tfm jinglei.ttf -q -w unijinglei@your_path/Unicode.sfd@
move *.tfm ../tfm/unicode/unijinglei;
move *.enc ../enc/pdftex/unicode/unijinglei;
(3) 运行 texhash;

第二步:为 dvipdfmx 增加字体配置
(1) 修改 tex/fonts/map/dvipfdm/cid-x.map,在其中增加一行即可;

第三步:为 ttf2pk 增加字体配置
(1) 修改 tex/fonts/ttf2pk/ttfonts.map,增加一行即可;

第四步:为 dvips 增加字体配置
(1) 这个需要生成 Type1 字体,比较麻烦,暂且不做了,dvipdfmx 挺好用的

If you can't read Chinese, it is ok for you to ignore this article. It is about adding a Chinese font in TeX system.

2007年5月9日星期三

Predefined Macros in gcc

gcc has many predefined macros, which can be list by

cpp -dM /dev/null

2007年4月17日星期二

Make xdvi use Type1 fonts

Traditionally, xdvi use pk fonts to display preview which are usually generated from Truetype fonts. This process could be slow and the generated pk fonts could consume a lot of disk space. Actually, xdvi can use Type1 fonts. If you have Type1 fonts on your disk, xdvi can use them to display preview and save lots of time. Here is how to do that:

Step1: copy xdvi.cfg from TEXMF/xdvi/ to TEXMF-LOCAL/xdvi;
Step2: add the dvips map file into xdvi.cfg;
Step3: texhash;

Now no pk fonts were generated anymore. Chinese fonts just looks great.

For more details, refer to http://xdvi.sourceforge.net/README.t1fonts

2007年4月11日星期三

Some Experiences on Big Project

Principle1: do NOT give more than necessary access permissions, for example:
1. define variables used exclusively in only one function as local;
2. define variables used exclusively in only one file as static;
3. declare read only argument as const *;

Principle2: tag code snippet according to its semantics;
1. declare all global variables with a tag like GLOBAL, so that you can list them;
2. use static_cast instead of forced type conversion;

Principle3: locality in SE:
1. gather all operations on some type of object in one or two files;