2008年09月 存档

Google Android里面的GB2312中文字体(TTF)

2008年09月30日,星期二

Google出手机了。大家都晓得

Open Handset Alliance

Google 请Ascender Corporation(传说是国际字体公司巨头)为Android设计了一套字体,叫droid family。里面有GB2312的字体哦

Google Android Font

12.Nov.2007 1.07pm
ELK GROVE VILLAGE, IL – November 12, 2007 – Ascender Corporation, a leading provider of advanced font products and innovative applications for mobile devices, today announced that it designed and engineered a new set of system User Interface (UI) fonts named “Droid” for the Android platform built by the Open Handset Alliance. The Android platform is a complete mobile phone software stack that will be made available under the Apache open source license. The fonts provided by Ascender ensure that users of handsets developed from the Android platform will enjoy highly legible text resulting in easy to use interfaces.

The Droid family of fonts consists of Droid Sans, Droid Sans Mono and Droid Serif. Each contains extensive character set coverage including Western Europe, Eastern/Central Europe, Baltic, Cyrillic, Greek and Turkish support. The Droid Sans regular font also includes support for Simplified and Traditional Chinese, Japanese and Korean support for the GB2312, Big 5, JIS 0208 and KSC 5601 character sets respectively.

如何得到这个字体呢?下载91MB的Android SDK后发现,system.img是yaffs2文件系统,我也不会解压,传说可以mount -t yaffs2

所以我直接下载别人dump的system.tar.gz(感谢Beeno)。路径是system.tar.gz\system\fonts。有这么几个文件:
DroidSans-Bold.ttf
DroidSans.ttf
DroidSansFallback.ttf
DroidSansMono.ttf
DroidSerif-Bold.ttf
DroidSerif-BoldItalic.ttf
DroidSerif-Italic.ttf
DroidSerif-Regular.ttf

对比微软雅黑一张图。不专业测评哈。(更新:SimHei 黑体 貌似同样也是Ascender这家公司做的。。。囧)

112.jpg

事实上Droid字体Droid Sans和Droid Serif用来编程再爽不过啦。哦也

Droid fixedwidth fonts for programming

可以去damieng.comDroid Sans Mono (47 KB),Droid Font Family(1.8 MB))下载。这种行为貌似是违法版权的。请在24小时之内删除并将其遗忘。

示例:
Windows XP via WordPad
droid font 1
Mac OS X 10.5 via TextEdit
droid font 2

国内有高手把这套字体移植到s60了。大家自己搜索下吧。

最后在Ascender公司的网站发现了一个字体图片生成工具。哈哈

黑体

方法是:

http://www.ascenderfonts.com/services/imaging.ashx?txt=这里是UTF-8编码的文字&em=字号&pid=8153

pid=8153的意思应该是采用黑体。
例如:

http://www.ascenderfonts.com/services/imaging.ashx?txt=%E4%B8%AD%E5%9B%BD&em=24&pid=8153

Digsby - 不错的多协议IM客户端。

2008年09月30日,星期二

推荐的原因是它是用pyxmpp+webkit写的。支持xmpp,gtalk,facebook chat等多种协议。

使用了这么多开源技术,digsby可惜不开源。平时占用5MB左右内存。不容易了。

Digsby的口号是:Digsby = IM + Email + SNS。还是不错的

Digsby

Digsby

目前我用它来登录XMPP和xiaonei。。。

缺点:不支持群聊和plug-in。当然语音之类的也相当遥远。

Digsby主页 | 下载

[Linux]用inittab实现进程异常退出则自动重启

2008年09月29日,星期一

写了个脚本,需要跑一个服务器,但是这个业务比较关键,不能down掉。怎么办呢?写一个daemon监视pid是否存在不存在则exec?daemon本身挂掉了怎么办?双进程互相监视?

无意中查到了一个Linux现有机制可以很好的完成这个问题;inittab

使用很简单,编辑 /etc/inittab 文件在最后一行写自己的东西就行了。语法可以照抄,格式为:

id:runlevels:action:进程名

id是不能重复的一个唯一标志

runlevel 就是进程运行级别。0是halt,1是单用户模式,6是重启。一般的程序在普通模式下的runlevel都是 2到5。Debian一般是2。可以参考wikipedia上的定义

action 就是采取的动作。分下面这么几种:

respawn
The process will be restarted whenever it terminates (e.g. getty).
wait
The process will be started once when the specified runlevel is entered and init will wait for its termination.
once
The process will be executed once when the specified runlevel is entered.
boot
The process will be executed during system boot. The runlevels field is ignored.
bootwait
The process will be executed during system boot, while init waits for its termination (e.g. /etc/rc). The runlevels field is ignored.
off
This does nothing.
ondemand
A process marked with an ondemand runlevel will be executed whenever the specified ondemand runlevel is called. However, no runlevel change will occur (ondemand runlevels are `a', `b', and `c').
initdefault
An initdefault entry specifies the runlevel which should be entered after system boot. If none exists, init will ask for a runlevel on the console. The process field is ignored.
sysinit
The process will be executed during system boot. It will be executed before any boot or bootwait entries. The runlevels field is ignored.
powerwait
The process will be executed when the power goes down. Init is usually informed about this by a process talking to a UPS connected to the computer. Init will wait for the process to finish before continuing.
powerfail
As for powerwait, except that init does not wait for the process's completion.
powerokwait
This process will be executed as soon as init is informormed that the power has been restored.
powerfailnow
This process will be executed when init is told that the battery of the external UPS is almost empty and the power is failing (provided that the external UPS and the monitoring process are able to detect this condition).
ctrlaltdel
The process will be executed when init receives the SIGINT signal. This means that someone on the system console has pressed the CTRL-ALT-DEL key combination. Typically one wants to execute some sort of shutdown either to get into single-user level or to reboot the machine.
kbrequest
The process will be executed when init receives a signal from the keyboard handler that a special key combination was pressed on the console keyboard.
The documentation for this function is not complete yet; more documentation can be found in the kbd-x.xx packages (most recent was kbd-0.94 at the time of this writing). Basically you want to map some keyboard combination to the "KeyboardSignal" action. For example, to map Alt-Uparrow for this purpose use the following in your keymaps file:

alt keycode 103 = KeyboardSignal

貌似很有用~~~

24小时没看cnBeta和Google Reader了

2008年09月28日,星期日

成都的雨:

Chengdu rain

这几天在实习的公司里,做一个不大不小的项目,用到了asyncore和cx_Oracle,写了个738字节长的SQL查询语句,解决了Python乱码问题。虽然拖延了工期,加班了,心里还是有那么一点高兴的。哈哈~~

上传图片到Picasa的时候,想到了。其实Picasa, Youtube, Flickr这样的网站,需求很简单:

1. 满足偷玉枕纱厨窥和集体偷玉枕纱厨窥的需要。以及digg、群体讨论和炒作。
2. 满足有了数码设备,把照片、图片、音频等方便发布到网上并流畅、方便观看的需要。
3. 最后创造社区自己的价值和价值观。

24小时没看cnBeta和Google Reader了。这个记录能坚持多久呢?

So concentrate and WIN!

同步ID的两种模型

2008年09月28日,星期日

网站做大了,如果用户使用论坛需要注册一次,使用FTP也需要注册一次,使用Blog也注册一次,自然很麻烦。整合账户当然是必须的。其实有2种模式

1. Push模式。首先禁用所有模块的新用户注册功能,然后建立一个Account Center,用户在账户中心里激活一项服务,就把ID和密码推送到模块的内建数据库。如果用户在账户中心修改密码,也要同步一次。

2. Pull模式。用户在其他子功能模块登录的时候,去读取中心帐号服务器的数据库/Web Service来验证密码是否正确。缺点:中心服务器down了就永远没法登录了。延迟也比较高。

如果要形成Single Sign-On方案的话,需要设计token传递,也就是跨进程、跨服务器共享session的机制,注销的时候也需要递归销毁token和cookie。

Python中Unicode转string绝对不会exception的方法

2008年09月28日,星期日

如果你被这个错误信息惹冒火了

UnicodeEncodeError: 'ascii' codec can't encode character \x4b in position 0: ordinal not in range(12 8)

可以试试这个函数:


def fstr(input, encoding='utf-8'):
        """Force convert """
        import cStringIO, codecs
        s = cStringIO.StringIO()
        w = codecs.getwriter(encoding)(s)
        w.write(input)
        return s.getvalue()

Python的中文乱码问题真是一陀屎。Python社区一帮只用ASCII字符的装B的老外也几乎没遇到过。一点都不体贴我们CJK开发人员的艰辛。

作为CPython标准发行版的内置函数:str(),理论上应该可以把任意object转换为字符串表示形式。不知道地球上除了python之外,还有什么伟大的语言,连内置函数 object.__str__() (相当于其他语言里的object.toString())都会抛出一个异常~~~~~~wtf~~~~~~~~~

Job hunting today @ UESTC, III

2008年09月26日,星期五

今天整天比较失落。。。。

先是实习里要做Oracle的一个接口。我折腾虚拟机就折腾郁闷咯。。。

然后看到身边的同学们一个一个都接到了baidu的面试通知。我心里简直嫉妒惨了。

最后晚上23:00的时候,电话响了。原来,我投的Web应用开发部门被鄙视了。调剂到Web前端。相当于高半夜凉初透考第二志愿吧。

提问的hr是一个牛人。问了好多技术细节。我后悔这3年没有能够深入的研究CSS,Javascript和浏览器行为。

YSlow,笔试的时候,我提到了。面试的时候没描述出来。失败。

Ajax我想我应该是描述的比较彻底的。但是Backspace键的细节不清楚。失败

还有详细描述IE7, IE8和FF的CSS。我也支支吾吾只说了一些。。。。

hr很猛。对functional programming也了解的很多。

看来baidu是没有希望了。唉

网易也没有通知我面试。我希望是因为我没有申请技术职位的原因。

Baidu的hr说:“你不要把平时cnBeta上都能看到的新闻拿出来说”。我当时那个汗啊。。。。。。我问了下他,他订了400多条国外设计类站点的RSS,而且他一般都不怎么上国内的Web开发社区(51js和blueidea之类的)

其实这也是国内一些公司的不足吧。cnBeta的确有点俗。我只下决心拒绝过一次cnbeta。当时还拒绝了脑残的solidot。但是不行。cnbeta文章质量不怎么样。但是评论还是可以看到国内互联网草根民瑞脑消金兽意的。有些国内土生土长相当山寨想当闪光的新闻是cnbeta首发的。solidot可以得到最新的脑残slashdot翻译。没想到现在居然成了求职的绊脚石。。。。囧。。。看来得缩减一下在cnbeta的注意力了。多关注一下国外的动向。

很多冠冕堂皇的的大公司在cnBeta上名声都不怎么好。我想是他们的垄断程度,是直接鄙视来自cnBeta的声音的原因吧。

baidu的前端团队没有自己的技术圈子。但是传说中有一个10多k的比jQuery还好用的库。也就是说,前端在Baidu不是特别的重视。

其实做hr挺容易的。不管你自己懂不懂,只管问就行了。当然面试者也容易装逼,那就是吹嘘hr也不懂的算法。(zsp学长告诉我的-_-!)面试者是进攻方,很容易露出马脚。而且面试者不能得罪了hr,也就是说不能打架但是不能打脸。。。。所以求职难那。。。

想到了腾讯。腾讯、baidu这2个国内IT巨头,在很多网民心目中,口碑很差。过几天腾讯就会笔试了。。。觉得腾讯的Web前端应该比Baidu更难。但是作为求职者,还是很希望进入这些公司的。

总体来说呢,Baidu还是一个互联网泡沫破灭之后快速称霸的幸运儿。其实baidu当年能做的,换我做CEO我也不会做的比现在的baidu更好。换了qihoo和youdao之类的来做华文搜索引擎老大也不见得比现在的baidu差。

今天激动的看了神舟7号的发射,还是挺激动的。所以就没有去新校区参加taobao的笔试了。因为貌似没有任何我能够立即胜任的职位。

总结了一下经验教训:
1. 一定要投递正确的职位。不一定要最理想的,要最能够进入公司的。进去再说。日后再说。
2. 一定要对对方的公司了如指掌。至少可以扯近乎。
3. 一定要及时分析笔试题。很有可能面试的时候就是对笔试题的review
4. 学好C和算法就是 ** !
5. 要混饭吃,还是java和php。当然还有运维。不过进公司就是做技术工人。
6. 一个非CS专业的要抢CS专业的饭碗,还是有一定障碍的。

So life rocks on.

Job hunting today @ UESTC, part II

2008年09月24日,星期三

再写写今天求职的感受吧

1. 网易 vs EMC。很多IT公司,零食和点心都是免费的。网易广州办公室的饮料,以前是免费的,现在需要自己掏1元钱,有个典故。很多员工,开了一罐可乐,中午吃饭了,就放在那里,下午回来就没气了,热了,不能喝了。造成了浪费。于是公司就“象征性”的收一元钱。EMC在北京的办公室,饮料也要收一元钱,你看别人是怎么解释的:“那一元钱将会捐助给贫困灾区的学校”。呵呵。同样的一元钱意义不一样。国际巨头和土生土长民族企业的内涵也就区别开来了。

2. Baidu的笔试题,个人觉得有点“山寨”。很多问题,不知道怎么形容,还是相当有意思吧。但是我个人觉得Baidu和Google走的是2条路。Google走的是国际化开源社区,你看Chrome浏览器用了那么多的开源技术啊。Baidu不一样。Baidu最喜欢说自己是“完全自己掌握核心技术的民族搜索引擎产业”。的确是。很多题都是让你用C语言操作字符串。我个人觉得这个东西比较囧。C语言里的字符串其实就是byte array,而且结束字符是0x00,纯C不能直接处理UTF-8的。所以到现在为止Baidu依然不能检索UTF-8专有字符和URL。Baidu立志做国内的老大,华文、大中国区的老大,东亚的老大,却忽视了IT行业,能够迅速形成国际规模的特点,说不定最后就不能形成竞争力而被国际巨头吞灭。所以Baidu的笔试题总给我一种谭浩强系列扩展习题的感觉。很囧很orz。

最后还是说下,baidu的题比较难。我应该是被鄙视了。

极品网站。。。

2008年09月23日,星期二

中国密码学会的网站可以随便进后台,哈哈

http://xn--fiq7vi3qbveynay21l.com/admin/MeetManage.aspx

太极品了 。大家去玩吧。哈哈

装逼就是要这么装

2008年09月23日,星期二

reddit上网友AnimalMachine一个巨汗的评论

I just rewrote my website using sbcl/emacs/slime, hunchentoot, cl-who, sqlite3, and clsql. It's nothing but a basic blog, but it only took me one day (including time to reformat my vps and reinstall gentoo). Hell, I haven't programmed anything for almost two years (switch professions - now working on becoming a paramedic).
It's not that hard. There are plenty of tutorials on getting hunchentoot up. Sqlite3 is a no-brainer. clsql made database calls as easy as creating a class. Cl-who took a little bit to get the hang of (their website lacks sufficiently complex samples), but still cake over all.
The drama's overplayed in the article. Yes learning new things isn't as easy as choosing something you already know. The basic parts of lisp are actually pretty easy to learn because the syntax is so regular. No everything in lisp is macro juggling.

大致翻译了一下

我刚刚用sbcl/emacs/slime, hunchentoot, cl-who, sqlite3, and clsql把我的blog重写了一遍。只花了我一天的时间(包括在VPN上重装Gentoo)。老子一年没有碰编程了(换专业了。)

囧rz