二月, 2008 的文章

windows命令行(Command Prompt / Console)字体设置

Windows命令行的字体一直让我不爽,只有两个选项,英文版还有个Lucida Console比较好看,切换到中文版以后,就只有很让人抓狂的Fixedsys和新宋体,唉,现在只要是可以输入的地方,哪有不让改字体的。

今天搜了一下,英文系统下,通过改注册表是可以做到的:
http://www.orablogs.com/duffblog/archives/001209.html
http://support.microsoft.com/kb/247815

但是中文系统下仍然不行,我先切换到英文系统,然后搞了几个快捷方式再切回来,试了几次总算成功了。

这里有张截图,其中用的是Bitstream Vera Sans Mono字体:
console_font_veramono.gif

为了以后方便,我做了一个包,按照说明安装之后重启机器,就可以在中英文系统上用了。
在这儿下载
http://www.2maomao.com/blog/wp-content/uploads/win_console_fonts.zip

压缩包里面包含了:
—— Lucida Console和Bitstream Vera Sans Mono字体
(参见我以前的文章:程序员最喜欢用的编程字体

—— 修改好的注册表项:console_font_setting.reg

—— 一些配置好字体的命令行快捷方式,包括Courier New / Lucida Console / Consolas / Bitstream Vera Sans Mono

使用方式
1. 下载,解压,先随便找个地方放一下
2. 导入注册表:双击console_font_setting.reg导入注册表
3. 安装字体:把ttf文件全部安装到c:\windows\font 目录下
4. 重启系统(必须),把四个快捷方式打开看看。

然后嘛,就看你自己做什么了,修改一下那些快捷方式里面的属性一般就够用了。

Update:
Fatalerr同学在随时随地进入命令行的评论中指出,要改变直接运行cmd.exe出来的窗口字体,需如下操作:
在注册表HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe下面增加以下String:
FaceName = Bitstream Vera Sans Mono
之后你再运行cmd.exe,字体就变成bitstream mono了!

reStructered Text & VIM 的一些资源

呵呵,做个简介吧:就是用文本的一些简单明了的方式表示段落、加粗、列表等文件结构,然后找个工具一转就变成pdf/html/latex

restructured text - Markup Syntax and Parser Component of Docutils
reST online render
结构化文本入门
reStructured Text Quick reference

VIM reST转HTML / Tex / PDF插件
VST(Vim reStructured Text)簡介
Vim reStructured Text, English Version

VIM rest语法高亮插件
下载安装到vim的syntax目录以后,在vim的filetype.vim找个空,插一句:

" reStructuredText Documentation Format,这句是注释:D
au BufNewFile,BufRead *.rest	setf rest

千字文有多少字?是否无重复?

今天和老婆吹嘘千字文如何如何厉害,顺口说千字文一个字也不重复。
老婆质疑,遂起而写一python脚本如下:

#!/usr/bin/env python
#encoding=utf-8
str = u'天地玄黄宇宙洪荒...中间略去...谓语助者焉哉乎也'
print "len = ", len(str)
s = {}
for c in str:
    
if c in s: print c
    
else: s[c] = 1

呵呵结果发现,真有六个字出现了两次“发云昆巨资戚”。
而奇怪的是长度是996个字而不是一千个,不知道为什么

整个的源码在这里:http://www.fayaa.com/code/view/109/

赞一下python,写起来真快,两分钟搞定。

Update: 据Izual_Yang提醒,原版是没有重复的,重复是因为简化字的原因,参见这篇文章


周发殷汤 周殷湯
盖此身发 蓋此身


剑号巨阙 劍號
巨野洞庭 野洞庭


玉出昆冈 玉出
昆池碣石 池碣石


戚谢欢招 謝歡招
亲戚故旧 親故舊


云腾致雨 騰致雨
禅主云亭 禪主

资≠兹
资父事君 父事君
务资稼穑 務稼穡

简单更改CSS显示醒目的代码块

写上篇文章的时候,发现这儿的代码块,黑底绿字,没有代码加色,也很好。coolcode适合于显示某个语言的代码块,这个适合于shell脚本,或者命令行操作等内容的显示,比较醒目。

firebug 看了一下,很简单。在我的主题的style.css后面添了一句如下:

.mycode {
color:lime;background-color:black
}

然后在使用的时候,简单的用pre模块(class=”mycode”)把要显示的内容包括进去即可

<pre class="mycode">
要显示的内容
</pre>

手工加这个还是比较麻烦,我在wordpress后台用的是简单的Quicktags编辑器,自己曾经改过,加上下面这段:

edButtons[edButtons.length] =
new edButton('ed_code'
    ,
'code'
    ,
'<pre class="mycode">\n'
    ,
'</pre>\n'
    ,
'c'
);

现在用起来很方便,在后台选中一块文字,点击编辑器上面的”code”按钮,就一切OK了。

configure your own python 2.5.2 on bluehost

[I suppose the guy who need this will be able to read this article]

I have a shared host on Bluehost.com, and want to have a lot of python libraries and applications to work on it.

Since it’s a shared host, I can’t install python libs, while I love ez_setup so much, I can’t live on python world without it.

Knowing from python-cn group, that I could build and use my own python on it. I should have got this solution earlier, this might be simple and naive for linux users.

OK, now let’s do it:

——————————————–

1. you must have shell access, please contact the bluehost support for a shell access

2. my dev box is windows xp, so I use putty, to connect my host 2maomao.com

3. then use wget to download latest python, unzip it

wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
tar xvzf Python-2.5.2.tgz

4. this step is critical, you need to replace “twomaom1″ to your own user name below:

cd Python-2.5.2
./configure --prefix=/home/twomaom1/mypython –enable-unicode=ucs4
make
make install

5. now, let’s use the new python instead of the old one, you need to
a). cd ~
b). use any editor(I use vim), to edit your “.bashrc” file, add the following line at the end of the file

export PATH=/home/twomaom1/mypython/bin/:$PATH

6. now type “bash” and enter to refresh the shell, type “python -V” to view the python version.

You should already been successful.

from now on, easy_install or “python setup.py”, it’s your choice :)

Oh…don’t forget, in your python script, use the correct python path in the head, like mine:

#!/home/twomaom1/bin/python

Enjoy it ~!

Main Reference: Custom Python installation for Django on Dreamhost

下一页 »