<?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>Memories of Klesh</title>
	<atom:link href="http://kleshwong.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://kleshwong.com/blog</link>
	<description>不知不觉中，你和我都被人代表了。</description>
	<lastBuildDate>Sun, 08 Aug 2010 01:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>通过 GreaseMonkey 脚本改善 Google Reader 阅读体验</title>
		<link>http://kleshwong.com/blog/2010/08/%e9%80%9a%e8%bf%87-greasemonkey-%e8%84%9a%e6%9c%ac%e6%94%b9%e5%96%84-google-reader-%e9%98%85%e8%af%bb%e4%bd%93%e9%aa%8c</link>
		<comments>http://kleshwong.com/blog/2010/08/%e9%80%9a%e8%bf%87-greasemonkey-%e8%84%9a%e6%9c%ac%e6%94%b9%e5%96%84-google-reader-%e9%98%85%e8%af%bb%e4%bd%93%e9%aa%8c#comments</comments>
		<pubDate>Sun, 08 Aug 2010 01:27:29 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[随记]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=198</guid>
		<description><![CDATA[a script that improve google reader reading experience]]></description>
			<content:encoded><![CDATA[<pre>function addGlobalStyle(css) {
  var head, style;
  head = document.getElementsByTagName('head')[0];
  if (!head) { return; }
  style = document.createElement('style');
  style.type = 'text/css';
  style.innerHTML = css;
  head.appendChild(style);
}

addGlobalStyle(".entry .entry-body, .entry .entry-title{font-family:'Lucida Grande', '微软雅黑';font-size:16px;line-height:135%;max-width:100%}");
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2010/08/%e9%80%9a%e8%bf%87-greasemonkey-%e8%84%9a%e6%9c%ac%e6%94%b9%e5%96%84-google-reader-%e9%98%85%e8%af%bb%e4%bd%93%e9%aa%8c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>centos + nginx + php-fpm</title>
		<link>http://kleshwong.com/blog/2010/06/centos-nginx-php-fpm</link>
		<comments>http://kleshwong.com/blog/2010/06/centos-nginx-php-fpm#comments</comments>
		<pubDate>Tue, 29 Jun 2010 03:03:12 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[随记]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[php-fpm]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=187</guid>
		<description><![CDATA[php-fpm php-fpm 专门为高负载网站设计，与 nginx 搭配，效果最佳。php-fpm 需要对 php 源码打补丁重编译，整个过程比较复杂且慢。个人比较喜欢使用现成的包方式安装，通过 centos.alt.ru 这个源，可以得到相当新的 php-fpm 包。 当然，这个源还有许多其它包。 1. 添加 rusia-repo 源，将以下内容保存到 /etc/yum.repos.d/rusia-repo.repo : [rusia-repo] name=CentOS-$releasever  rusia packages for $basearch baseurl=http://centos.alt.ru/pub/repository/centos/5/i386/ enabled=1 gpgcheck=0 protect=1 然后开始安装 php-fpm 和必要的 php extension yum install php-mysql php-mcrypt php-mbstring php-gd php-fpm 添加 php-fpm 自启动 chkconfig --level 345 php-fpm on nginx 1. nginx 源码不大，编译安装简单，推荐直接从官网下载源码自行编译安装： wget http://nginx.org/download/nginx-0.7.67.tar.gz [...]]]></description>
			<content:encoded><![CDATA[<h2><strong>php-fpm</strong></h2>
<p><a href="http://php-fpm.org/">php-fpm</a> 专门为高负载网站设计，与 nginx 搭配，效果最佳。php-fpm 需要对 php 源码打补丁重编译，整个过程比较复杂且慢。个人比较喜欢使用现成的包方式安装，通过 centos.alt.ru 这个源，可以得到相当新的 php-fpm 包。 当然，这个源还有许多其它包。</p>
<p>1. 添加 rusia-repo 源，将以下内容保存到 /etc/yum.repos.d/rusia-repo.repo :</p>
<pre>[rusia-repo]
name=CentOS-$releasever  rusia packages for $basearch
baseurl=http://centos.alt.ru/pub/repository/centos/5/i386/
enabled=1
gpgcheck=0
protect=1</pre>
<p>然后开始安装 php-fpm 和必要的 php extension</p>
<pre>yum install php-mysql php-mcrypt php-mbstring php-gd php-fpm</pre>
<p>添加 php-fpm 自启动</p>
<pre>chkconfig --level 345 php-fpm on</pre>
<h2>nginx</h2>
<p>1. nginx 源码不大，编译安装简单，推荐直接从<a href="http://nginx.org/en/download.html">官网下载</a>源码自行编译安装：</p>
<pre>wget http://nginx.org/download/nginx-0.7.67.tar.gz
tar zxvf nginx-0.7.67.tar.gzcd nginx-0.7.67./configure
make
make install</pre>
<p>2. 制作 nginx 启动脚本 vim /etc/init.d/nginx</p>
<pre>#!/bin/bash
# v.0.0.1
# create by jackbillow at 2007.10.15
# nginx - This shell script takes care of start ing and stopping nginx.
#
# chkconfig: - 60 50
# description: nginx [engine x] is light http web/proxy server
# that answers incoming ftp service requests.
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
nginx_path="/usr/local/nginx"
nginx_pid="/usr/local/nginx/logs/nginx.pid"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] &amp;&amp; exit 0
[ -x $nginx_path/sbin/nginx ] || exit 0
RETVAL=0
prog="nginx"
start() {
# Start daemons.
if [ -e $nginx_pid -a ! -z $nginx_pid ];then
echo "nginx already running...."
exit 1
fi

if [ -e /usr/local/nginx/conf/nginx.conf ];then
 echo -n $"Starting $prog: "
 $nginx_path/sbin/nginx -c /usr/local/nginx/conf/nginx.conf &amp;
 RETVAL=$?
[ $RETVAL -eq 0 ] &amp;&amp; {
touch /var/lock/subsys/$prog
success $"$prog"
}
echo
else
RETVAL=1
fi
return $RETVAL
}
# Stop daemons.
stop() {
 echo -n $"Stopping $prog: "
 killproc -d 10 $nigx_path/sbin/nginx
 RETVAL=$?
 echo
 [ $RETVAL = 0 ] &amp;&amp; rm -f $nginx_pid /var/lock/subsys/$prog
}
# See how we were called.
case "$1" in
start)
 start
 ;;
stop)
 stop
 ;;
reload)
 kill -HUP `cat $nginx_pid`
 ;;
reconfigure)
 stop
 start
 ;;
status)
 status $prog
 RETVAL=$?
 ;;
*)
 echo $"Usage: $0 {start|stop|reconfigure|reload|status}"
 exit 1
esac
exit $RETVAL
</pre>
<p>保存退出，改模式，加启动：</p>
<p>chmod +x nginx</p>
<p>chkconfig &#8211;level 2345 nginx on</p>
<p>3. 配置 nginx 虚拟主机:</p>
<p>每个虚拟主机都要配置 php 的话，比较麻烦，可以把这些共通的设置单独保存到一个文件，再在 server 节 include 一下。</p>
<p>virtual_host_share.conf :</p>
<pre>index  index.html index.htm index.php;
location ~* ^.+\.(jpg|jpeg|png|ico|gif|css|js)$ {
 access_log   off;
 expires      30d;
}
location ~ \.php$ {
 fastcgi_pass   127.0.0.1:9000;
 fastcgi_index  index.php;
 fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
 fastcgi_connect_timeout 60;
 fastcgi_send_timeout 180;
 fastcgi_read_timeout 180;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 fastcgi_intercept_errors on;
 include        fastcgi_params;
}
</pre>
<p>配置虚拟主机例子：</p>
<pre>server {</pre>
<pre>  listen: 80;</pre>
<pre>  server_name example.com www.example.com;</pre>
<pre>  root /path/to/your/website/public;</pre>
<pre>  #access_log /path/to/your/website/log/access.log;</pre>
<pre>  #error_log /path/to your/website/log/error.log;
</pre>
<pre>  include /path/to/virtual_host_share.conf;
</pre>
<pre>}</pre>
<p>好了，启动 nginx 和 php-fpm 测试一下吧。</p>
<pre>/etc/init.d/nginx start</pre>
<pre>/etc/init.d/php-fpm start</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2010/06/centos-nginx-php-fpm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache/Nginx url rewrite trick: 目录下 index.html 不存在时重写</title>
		<link>http://kleshwong.com/blog/2010/06/apachenginx-url-rewrite-trick-rewrite-if-index-file-doesnt-exists</link>
		<comments>http://kleshwong.com/blog/2010/06/apachenginx-url-rewrite-trick-rewrite-if-index-file-doesnt-exists#comments</comments>
		<pubDate>Sat, 26 Jun 2010 15:15:10 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[服务器]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[url rewrite]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=179</guid>
		<description><![CDATA[目录存在，而默认文档不存在时实行重写]]></description>
			<content:encoded><![CDATA[<p>最近做一个被动式静态页生成功能，即是在请求发生时若静态文件不存在，便将请求重写到PHP生成内容，再在输出前将内容存入到对应路径，下次请求时服务器便直接输出静态页，不用经过PHP。生成部分相当简单，没费什么周折。</p>
<p>Apache 重写规则设定如下：</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f</pre>
<pre>RewriteCond %{REQUEST_FILENAME} !-d</pre>
<pre>RewriteRule . /index.php [L]</pre>
<p>当请求的URL为 /products/ipad_16g.html 时，一切行为都很符合期望。</p>
<p>但我同时也期望请求URL为 /products 时，可以看到产品的列表，实际上当 /products 目录存在而默认文档 index.html 不存在时便会报错。好在 Apache Rewrite 支持逻辑操作符，解决起来也方便，加上对 index.html 的判断便可完美解决：</p>
<pre>RewriteCond %{REQUEST_FILENAME} !-f [OR]</pre>
<pre>RewriteCond %{REQUEST_FILENAME}/index.html !-f</pre>
<pre>RewriteRule . /index.php [L]</pre>
<p>Nginx rewrite 不支持逻辑操作符，利用 break 可达到同一效果：</p>
<pre>if (-f $request_filename) {</pre>
<pre>break;</pre>
<pre>}</pre>
<pre>if (-f $request_filename/index.html) {</pre>
<pre>break;</pre>
<pre>}</pre>
<pre>rewrite ^ /index.php last;</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2010/06/apachenginx-url-rewrite-trick-rewrite-if-index-file-doesnt-exists/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu 9.04 体验</title>
		<link>http://kleshwong.com/blog/2009/04/ubuntu-904-experience</link>
		<comments>http://kleshwong.com/blog/2009/04/ubuntu-904-experience#comments</comments>
		<pubDate>Fri, 24 Apr 2009 07:23:52 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[随记]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=172</guid>
		<description><![CDATA[改进 Firefox 似乎比较稳定，因装插件或升级而重启的时候没有发生配置丢失的情况。 蓝牙浏览设备时不能往设备拷贝文件的BUG已经修复，地址栏也得到加强，能够正常显示中文。 登录界面美观了许多，之前一直在用的NEW WAVW主题被直接集成到系统，不用另外下载安装，相当方便，另外DUST主题也加进来了。 新的系统消息通知界面是挺好看，不过在右上角弹出会挡住“最小化，最大化，关闭”那些按钮。 中文字体 毫无疑问，新的 ubuntu 自带的中文字体依然是文泉点阵，可以选用 Driod 或 文泉微米黑作为默认中文字体，微米黑还没正式发布，但可以下到 nightly build 版本，现在的标点符号明显比 Driod 好看， 支持的字符也明显较多。 下载后将字体拷贝到 /usr/share/fonts/truetype 下 fc-cache -f -v 更新字体缓存 然后新建 /etc/fonts/local.conf 文件，将下面内容输入，保存，将微米黑就设置为系统默认中文字体。 &#60;?xml version="1.0"?&#62; &#60;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&#62; &#60;fontconfig&#62;   &#60;!--   Serif faces   --&#62;   &#60;alias&#62;     &#60;family&#62;serif&#60;/family&#62;     &#60;prefer&#62;       &#60;family&#62;Bitstream Vera Serif&#60;/family&#62;       [...]]]></description>
			<content:encoded><![CDATA[<h2>改进</h2>
<ol>
<li>Firefox 似乎比较稳定，因装插件或升级而重启的时候没有发生配置丢失的情况。</li>
<li>蓝牙浏览设备时不能往设备拷贝文件的BUG已经修复，地址栏也得到加强，能够正常显示中文。</li>
<li>登录界面美观了许多，之前一直在用的NEW WAVW主题被直接集成到系统，不用另外下载安装，相当方便，另外DUST主题也加进来了。</li>
<li>新的系统消息通知界面是挺好看，不过在右上角弹出会挡住“最小化，最大化，关闭”那些按钮。</li>
</ol>
<h2>中文字体</h2>
<p>毫无疑问，新的 ubuntu 自带的中文字体依然是文泉点阵，可以选用 Driod 或 文泉微米黑作为默认中文字体，微米黑还没正式发布，但可以下到 <a href="http://wenq.org/forum/viewtopic.php?f=4&amp;t=764">nightly build</a> 版本，现在的标点符号明显比 Driod 好看， 支持的字符也明显较多。</p>
<ol>
<li>下载后将字体拷贝到 /usr/share/fonts/truetype 下</li>
<li>fc-cache -f -v 更新字体缓存</li>
<li>然后新建 /etc/fonts/local.conf 文件，将下面内容输入，保存，将微米黑就设置为系统默认中文字体。</li>
</ol>
<pre>&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
&lt;fontconfig&gt;
  &lt;!--
  Serif faces
  --&gt;
  &lt;alias&gt;
    &lt;family&gt;serif&lt;/family&gt;
    &lt;prefer&gt;
      &lt;family&gt;Bitstream Vera Serif&lt;/family&gt;
      &lt;family&gt;WenQuanYi Micro Hei&lt;/family&gt;
    &lt;/prefer&gt;
  &lt;/alias&gt;
  &lt;!--
  Sans-serif faces
  --&gt;
  &lt;alias&gt;
    &lt;family&gt;sans-serif&lt;/family&gt;
    &lt;prefer&gt;
      &lt;family&gt;Bitstream Vera Sans&lt;/family&gt;
      &lt;family&gt;WenQuanYi Micro Hei&lt;/family&gt;
    &lt;/prefer&gt;
  &lt;/alias&gt;
  &lt;!--
  Monospace faces
  --&gt;
  &lt;alias&gt;
    &lt;family&gt;monospace&lt;/family&gt;
    &lt;prefer&gt;
      &lt;family&gt;Bitstream Vera Sans Mono&lt;/family&gt;
      &lt;family&gt;WenQuanYi Micro Hei&lt;/family&gt;
    &lt;/prefer&gt;
  &lt;/alias&gt;
&lt;/fontconfig&gt;</pre>
<h2>输入法</h2>
<p>个人习惯用英文界面，加上SCIM不好用，干脆就连中文包也不装了，只装个 fcitx 。</p>
<pre>sudo apt-get install fcitx
update-alternatives --install /etc/X11/xinit/xinput.d/all_ALL xinput-all_ALL /etc/X11/xinit/xinput.d/fcitx 30
sudo im-switch -s fcitx -z all_ALL</pre>
<p>装好要重新 login 一下激活 fcitx. 如无意外，此时看到的 fcitx 应该是一片乱码，需要配置一下</p>
<pre>gedit ~/.fcitx/config --encoding=gb2312</pre>
<p>指定显示字体为 WenQuanYi Micro Hei ，保存，退出，按 ctrl + space 激活 fcitx, 看到输入框再按 ctrl + 5 强制 fcitx 重读配置文件，搞定。</p>
<h2>更新源</h2>
<p>国内镜像动作超慢，目前还没 jaunty 源可用，官方源又太慢，试了下法国的源，速度还将就。</p>
<pre>deb http://archive.monubuntu.fr/ jaunty main restricted universe multiverse
deb-src http://archive.monubuntu.fr/ jaunty main restricted universe multiverse
deb http://archive.monubuntu.fr/ jaunty-security main restricted universe multiverse
deb-src http://archive.monubuntu.fr/ jaunty-security main restricted universe multiverse
deb http://archive.monubuntu.fr/ jaunty-updates main restricted universe  multiverse
deb-src http://archive.monubuntu.fr/ jaunty-updates main restricted universe  multiverse
deb http://archive.monubuntu.fr/ jaunty-backports main restricted universe multiverse
deb-src http://archive.monubuntu.fr/ jaunty-backports main restricted universe  multiverse
deb http://archive.monubuntu.fr/ jaunty-proposed main restricted universe multiverse
deb-src http://archive.monubuntu.fr/ jaunty-proposed main restricted universe  multiverse</pre>
<p>4月27日，网易镜像加入 jaunty 更新源</p>
<pre>deb http://mirrors.163.com/ubuntu/ jaunty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jaunty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jaunty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jaunty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jaunty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ jaunty-backports main restricted universe multiverse</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/04/ubuntu-904-experience/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>railscaffold script &#8211; for namespace supporting</title>
		<link>http://kleshwong.com/blog/2009/03/supports-namespace-scaffold-script</link>
		<comments>http://kleshwong.com/blog/2009/03/supports-namespace-scaffold-script#comments</comments>
		<pubDate>Thu, 12 Mar 2009 15:44:59 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[开发]]></category>
		<category><![CDATA[namespace scaffold]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=163</guid>
		<description><![CDATA[使用 rails 2.2.2 自带的 scaffold 生成带命名空间的脚本架时(如 Admin::Product)，scaffold 会生成带命名空间的model(app/models/admin/product.rb)，并且生成的 controller 代码看起来也很怪异，不能工作，想到后面还有那么多 scaffold 要生成，一个一个手动改实不在符合 DRY 精神，So， 写个脚本做些自动清理调整的工作看来相当有必要。 when running scaffold came with rails 2.2.2 with namespace(i.e. Admin::Product), it generates new model with namespace(app/models/admin/product.rb) and controller code looks wierd, which normally you didn&#8217;t expect it, this script done some fixing for u 环境 Env ruby 1.8.7 / gems [...]]]></description>
			<content:encoded><![CDATA[<p>使用 rails 2.2.2 自带的 scaffold 生成带命名空间的脚本架时(如 Admin::Product)，scaffold 会生成带命名空间的model(app/models/admin/product.rb)，并且生成的 controller 代码看起来也很怪异，不能工作，想到后面还有那么多 scaffold 要生成，一个一个手动改实不在符合 DRY 精神，So， 写个脚本做些自动清理调整的工作看来相当有必要。</p>
<p>when running scaffold came with rails 2.2.2 with namespace(i.e. Admin::Product), it generates new model with namespace(app/models/admin/product.rb) and controller code looks wierd, which normally you didn&#8217;t expect it, this script done some fixing for u</p>
<p><strong>环境 Env</strong><br />
ruby 1.8.7 / gems 1.3 / rails 2.2.2</p>
<p><strong>注意 Notice</strong><br />
脚本只能在 rails app 的根目录下运行<br />
this script can only run in rails app root directory.</p>
<pre>#!/usr/bin/env ruby
require 'rubygems'
require 'active_support/inflector'

include ActiveSupport

scaffold = ARGV[0]
puts `script/generate scaffold #{scaffold}`
if scaffold =~ /::|\//
  puts `script/destroy model #{scaffold}`
  path = Inflector.underscore(Inflector.pluralize(scaffold))
  full_class_name = Inflector.camelize(Inflector.singularize(path))
  class_name = Inflector.demodulize(full_class_name)
  model = Inflector.underscore(class_name)
  models = Inflector.pluralize(model)
  controller_path = "app/controllers/#{path}_controller.rb"
  code = File.open(controller_path, 'r') {|f| f.read}
  wrong_path = path.gsub('/', '_')
  code.gsub!(/\/#{wrong_path}/, '/'+path)
  code.gsub!(/@#{wrong_path}/, '@'+models)
  code.gsub!(/#{full_class_name}(\W)/, class_name+'\1')
  code.gsub!(/redirect_to\(@#{model}\)/, "redirect_to(['#{File.dirname(path)}', @#{model}])")
  File.open(controller_path, 'w') {|f| f.write code}
end</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/03/supports-namespace-scaffold-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dorid Sans Fallback 中文字体效果不错 &#8211; 请抛弃雅黑吧</title>
		<link>http://kleshwong.com/blog/2009/03/dorid-sans-fallback-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e6%95%88%e6%9e%9c%e4%b8%8d%e9%94%99-%e8%af%b7%e6%8a%9b%e5%bc%83%e9%9b%85%e9%bb%91%e5%90%a7</link>
		<comments>http://kleshwong.com/blog/2009/03/dorid-sans-fallback-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e6%95%88%e6%9e%9c%e4%b8%8d%e9%94%99-%e8%af%b7%e6%8a%9b%e5%bc%83%e9%9b%85%e9%bb%91%e5%90%a7#comments</comments>
		<pubDate>Wed, 11 Mar 2009 03:44:56 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[技巧]]></category>
		<category><![CDATA[Droid]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[中文字体]]></category>
		<category><![CDATA[雅黑]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=156</guid>
		<description><![CDATA[Ubuntu 中文 Wiki 有一《免费中文字体》的条目，专门介绍目前开源或免费的中文字体，看惯矢量字体的朋友不必再受WenQuanYi Bitmap Song的折磨了。 原先看“文泉驿正黑”的效果不错，可惜实际试用效果完全不行，微米黑属于Droid Sans Fallback的增补集，可惜还没开发好，最后试用 Droid 字体，效果相当不错，以下是 ubuntu wiki 对 Dorid 的介绍： Google委托Ascender公司为其手机Android设计的系统字体，Droid字体中提供了对简体、繁体中文、日文和韩文的双字节文字支持，涵 盖了 GB2312, Big-5, JIS-0208 和KSC-5601字符集，使用的是简体中文书写习惯，包含CJK标准汉字16000余个。由于采用了特别的技术,字体文件的体积仅有 3.04MB 。 说是特别技术，但其实文件这么小，主要还是没有嵌入小字体字形，因此 Dorid 在小字体下会有发糊的现象，尤其是字比较复杂的时候，而雅黑因内嵌特别为小字体设计的字库，即使是小字体，可读效果稍微好些。但奇怪的是，在 linux 下， 雅黑的小字体似乎没有被启用，一样存在发糊的现象。 目前，Droid 的简体部份字符集只支持到 GB2312， 像“嘅”，“啲” 等属于GB2312标准以外的字形，只能期待微米黑补完计划鸟。 先下载 Droid 字体，将字体cp或者ln到 /usr/share/fonts/truetype/droid tar zxvf DroidFamily.zip sudo cp DroidFamily /usr/share/truetype/droid 刷新字体缓存 fc-cache -v -f 将 Droid 设为全局默认字体, sudo /etc/fonts/local.conf [...]]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 中文 Wiki 有一《<a href="http://wiki.ubuntu.org.cn/%E5%85%8D%E8%B4%B9%E4%B8%AD%E6%96%87%E5%AD%97%E4%BD%93">免费中文字体</a>》的条目，专门介绍目前开源或免费的中文字体，看惯矢量字体的朋友不必再受WenQuanYi Bitmap Song的折磨了。</p>
<p>原先看“文泉驿正黑”的效果不错，可惜实际试用效果完全不行，微米黑属于Droid Sans Fallback的增补集，可惜还没开发好，最后试用 Droid 字体，效果相当不错，以下是 ubuntu wiki 对 Dorid 的介绍：</p>
<blockquote><p>Google委托Ascender公司为其手机Android设计的系统字体，Droid字体中提供了对简体、繁体中文、日文和韩文的双字节文字支持，涵 盖了 GB2312, Big-5, JIS-0208 和KSC-5601字符集，使用的是简体中文书写习惯，包含CJK标准汉字16000余个。由于采用了特别的技术,字体文件的体积仅有 3.04MB 。</p></blockquote>
<p>说是特别技术，但其实文件这么小，主要还是没有嵌入小字体字形，因此 Dorid 在小字体下会有发糊的现象，尤其是字比较复杂的时候，而雅黑因内嵌特别为小字体设计的字库，即使是小字体，可读效果稍微好些。但奇怪的是，在 linux 下， 雅黑的小字体似乎没有被启用，一样存在发糊的现象。</p>
<p>目前，Droid 的简体部份字符集只支持到 GB2312， 像“嘅”，“啲” 等属于GB2312标准以外的字形，只能期待微米黑补完计划鸟。</p>
<p>先下载 Droid 字体，将字体cp或者ln到 /usr/share/fonts/truetype/droid</p>
<pre>tar zxvf DroidFamily.zip
sudo cp DroidFamily /usr/share/truetype/droid</pre>
<p>刷新字体缓存</p>
<p>fc-cache -v -f</p>
<p>将 Droid 设为全局默认字体,</p>
<pre>sudo /etc/fonts/local.conf</pre>
<p>内容如下</p>
<pre>&lt;?xml version="1.0"?&gt;                                                                                                                                       
&lt;!DOCTYPE fontconfig SYSTEM "fonts.dtd"&gt;
&lt;fontconfig&gt;
  &lt;!--
  Serif faces
  --&gt; 
  &lt;alias&gt;
    &lt;family&gt;serif&lt;/family&gt;
    &lt;prefer&gt;
      &lt;family&gt;Bitstream Vera Serif&lt;/family&gt;
      &lt;family&gt;Droid Serif&lt;/family&gt;
      &lt;family&gt;Droid Sans Fallback&lt;/family&gt;
    &lt;/prefer&gt;
  &lt;/alias&gt;
  &lt;!--
  Sans-serif faces
  --&gt; 
  &lt;alias&gt;
    &lt;family&gt;sans-serif&lt;/family&gt;
    &lt;prefer&gt;
      &lt;family&gt;Bitstream Vera Sans&lt;/family&gt;
      &lt;family&gt;Droid Serif&lt;/family&gt;
      &lt;family&gt;Droid Sans Fallback&lt;/family&gt;
    &lt;/prefer&gt;
  &lt;/alias&gt;
  &lt;!--
  Monospace faces
  --&gt;
&lt;/fontconfig&gt;</pre>
<p>操作系统使用的字体一般有三大类， 分别是衬线serif，无衬线(sans-serif)和等宽(monospace)，这里只配置衬线字体和无衬线字体序列，系统默认的等宽字体效果很好，不需另外配置。</p>
<p>保存后按 Ctrl + Alt + 退格键重启 X</p>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/03/dorid-sans-fallback-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e6%95%88%e6%9e%9c%e4%b8%8d%e9%94%99-%e8%af%b7%e6%8a%9b%e5%bc%83%e9%9b%85%e9%bb%91%e5%90%a7/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>强制 linux 下 firefox 使用特定字体</title>
		<link>http://kleshwong.com/blog/2009/02/%e5%bc%ba%e5%88%b6-linux-%e4%b8%8b-firefox-%e4%bd%bf%e7%94%a8%e7%89%b9%e5%ae%9a%e5%ad%97%e4%bd%93</link>
		<comments>http://kleshwong.com/blog/2009/02/%e5%bc%ba%e5%88%b6-linux-%e4%b8%8b-firefox-%e4%bd%bf%e7%94%a8%e7%89%b9%e5%ae%9a%e5%ad%97%e4%bd%93#comments</comments>
		<pubDate>Tue, 10 Feb 2009 15:12:46 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[技巧]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=145</guid>
		<description><![CDATA[现在绝大多数网站都是针对 windows 进行设计，linux 并没有也不能有 windows 那些字体，当在 linux 下浏览时，看到的中文字体一般默认是文泉驿宋体。看惯了 ClearType 字体，再回来看点阵字体实在是种折磨，特别是我需要长时间对着电脑。看来不动手DIY下是不行。 首先，在 /usr/share/fonts/truetype 下建了个 myfonts 文件夹，把自己喜欢字体 copy 或者 ln 进去。再执行 fc-cache -f 更新字体缓存，然后在 firefox -&#62; edit -&#62; preference -&#62; content -&#62;  fonts &#38; colors -&#62; advanced 里面可以看到新增的字体，把 western 里的字体改为自己喜欢英文字体，simplified chinese 改成相应的中文字体。再把 “Allow pages to chose their own fonts&#8230;..&#8221; 选项打掉。这样大部份网页都会使用设定好的字体进行显示，并且在中文网页中的英文字体则会使用 western 设定的字体进行显示。 但是，总有那么一部份顽固的网页依然会使用默认字体显示中文。 我想到曾经用过 greasemonkey 调整 google [...]]]></description>
			<content:encoded><![CDATA[<p>现在绝大多数网站都是针对 windows 进行设计，linux 并没有也不能有 windows 那些字体，当在 linux 下浏览时，看到的中文字体一般默认是文泉驿宋体。看惯了 ClearType 字体，再回来看点阵字体实在是种折磨，特别是我需要长时间对着电脑。看来不动手DIY下是不行。</p>
<p>首先，在 /usr/share/fonts/truetype 下建了个 myfonts 文件夹，把自己喜欢字体 copy 或者 ln 进去。再执行 fc-cache -f 更新字体缓存，然后在 firefox -&gt; edit -&gt; preference -&gt; content -&gt;  fonts &amp; colors -&gt; advanced 里面可以看到新增的字体，把 western 里的字体改为自己喜欢英文字体，simplified chinese 改成相应的中文字体。再把 “Allow pages to chose their own fonts&#8230;..&#8221; 选项打掉。这样大部份网页都会使用设定好的字体进行显示，并且在中文网页中的英文字体则会使用 western 设定的字体进行显示。</p>
<p>但是，总有那么一部份顽固的网页依然会使用默认字体显示中文。 我想到曾经用过 <a href="http://kleshwong.com/blog/2009/02/google-reader-interface-fine-tune-greasemonkey-script">greasemonkey 调整 google reader 在两栏模式下正文宽度，让它变成100％宽以方便阅读</a>，便立即写了个脚本将字体设定自动加到样式表里，试了几下，目的可以达到，可惜 greasemonkey 是在页面完全载入之后再执行，所以在轮到 greasemonkey 起作用之前看到的还是点阵字体。</p>
<p>最后想起曾经有篇文章介绍过通过 userContent.css 使 firefox 也具有“像 Google Chrome 那样的活动输入框高亮显示”功能。firefox 是基于 Mozilla XUL 架构，本身的界面元素可以通过 userChrome.css 来自定义， userContent.css 则对应页面样式进行默认定义。通过这两个文件来控制明显是最完美方案了，yes，在 ~/.mozilla/firefox/chrome/xxxxxx.default/chrome (xxxxxx视具体替换)里面建立 userChrome.css 和 userContent.css 内容如下：</p>
<pre>* { font-family : 'english font name', '中文字体名称' }</pre>
<p>字体从左到右优先显示，名称中有空格需以单引号括起。名称以 firefox preferences 里看到的字体名称为准，重启 firefox， 这回连界面字体也一併改了，舒服了。</p>
<p>环境：</p>
<p>xubuntu 8.10</p>
<p>firefox 3.0.5</p>
<p>顺便再说说 Mozilla XUL， 这是一个界面框架， 允许开发者以HTML代码创建Native用户界面，许多 Mozilla 的项目也是基于 XUL开发，ActiveState 的 Komodo 开发工具系统也是基于 XUL。</p>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/02/%e5%bc%ba%e5%88%b6-linux-%e4%b8%8b-firefox-%e4%bd%bf%e7%94%a8%e7%89%b9%e5%ae%9a%e5%ad%97%e4%bd%93/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>几个好用的 vim 插件</title>
		<link>http://kleshwong.com/blog/2009/02/%e5%87%a0%e4%b8%aa%e5%a5%bd%e7%94%a8%e7%9a%84-vim-%e6%8f%92%e4%bb%b6</link>
		<comments>http://kleshwong.com/blog/2009/02/%e5%87%a0%e4%b8%aa%e5%a5%bd%e7%94%a8%e7%9a%84-vim-%e6%8f%92%e4%bb%b6#comments</comments>
		<pubDate>Mon, 09 Feb 2009 10:39:36 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[开发]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=143</guid>
		<description><![CDATA[NERDTree TextMate 有工程管理功能，其实就是在编辑窗口左边附一个以工程根目录为其根目录的树形文件管理器，pspad、editplus 也带有类似作用的树形文件管理器。VIM也有强大的工程管理插件 Project，可以仔细到哪些文件夹，哪些文件要归入工程里。强大的代价就是用起来麻烦，新文件夹什么得手动往里面加也不省心。NERDTree就是一款简单的树形文件管理器，可以把目录加入 bookmark, 一个工程一个bookmark跳起来方便。安装简单，下载，直接解压到 vimfiles 目录(windows)，或者 ~/.vim (unix/linux)，然后打开 vim 执行一下 :helptags ~/.vim/doc snippetsEmu snippetsEmu的slogon是&#8220;An attempt to emulate TextMate&#8217;s snippet expansio&#8221;， 嗯，TextMate确实挺牛逼，大家都要抄它。相当好用的功能，当你用 vim 编写 html 页面， 那一堆必要的 DOCTYPE head body 标签复制来粘贴去也是一件麻烦事。把它交给 snippetsEmu 吧。snippetsEmu，安装过程比较特别，snippy_plugin.vba 是插件安装文件，下载后用 vim 打开然后执行 :source % 命令即完成 snippetsEmu 安装。 snippy_bundles.vba 是默认的自动完成代码片段，安装后可以在 ~/.vim/after/ftplugin (unix/linux) 或者 vimfiles/after/ftplugin (windows) 下面找到自动完成脚本，了解会对哪些类型哪些关键字进行自动完成。使用也简单，如在编辑 html 文件时， 打入 ref [...]]]></description>
			<content:encoded><![CDATA[<h2><a href="http://www.vim.org/scripts/script.php?script_id=1658">NERDTree</a></h2>
<p>TextMate 有工程管理功能，其实就是在编辑窗口左边附一个以工程根目录为其根目录的树形文件管理器，pspad、editplus 也带有类似作用的树形文件管理器。VIM也有强大的工程管理插件 Project，可以仔细到哪些文件夹，哪些文件要归入工程里。强大的代价就是用起来麻烦，新文件夹什么得手动往里面加也不省心。NERDTree就是一款简单的树形文件管理器，可以把目录加入 bookmark, 一个工程一个bookmark跳起来方便。安装简单，下载，直接解压到 vimfiles 目录(windows)，或者 ~/.vim (unix/linux)，然后打开 vim 执行一下 :helptags ~/.vim/doc</p>
<h2><a href="http://www.vim.org/scripts/script.php?script_id=1318"><span class="txth1">snippetsEmu</span></a></h2>
<p><span class="txth1">snippetsEmu的slogon是</span><span class="txth1">&#8220;An attempt to emulate TextMate&#8217;s snippet expansio&#8221;， 嗯，TextMate确实挺牛逼，大家都要抄它。相当好用的功能，当你用 vim 编写 html 页面， 那一堆必要的 DOCTYPE head body 标签复制来粘贴去也是一件麻烦事。把它交给 </span><span class="txth1">snippetsEmu 吧。</span><span class="txth1">snippetsEmu，</span>安装过程比较特别，snippy_plugin.vba 是插件安装文件，下载后用 vim 打开然后执行 :source % 命令即完成 <span class="txth1">snippetsEmu 安装。 </span>snippy_bundles.vba 是默认的自动完成代码片段，安装后可以在 ~/.vim/after/ftplugin (unix/linux) 或者 vimfiles/after/ftplugin (windows) 下面找到自动完成脚本，了解会对哪些类型哪些关键字进行自动完成。使用也简单，如在编辑 html 文件时， 打入 ref 之后按 &lt;TAB&gt; 就会出现 &lt;a href=&#8221;"&gt;&lt;{}&gt;&lt;/a&gt;&lt;{}&gt;，&lt;{}&gt;代表需要输入位置，按一下 &lt;TAB&gt; 跳到第一个&lt;{}&gt;，输入完成后再按&lt;TAB&gt;跳到最后一个&lt;{}&gt;让它消失，完成！</p>
<h2><a href="http://www.vim.org/scripts/script.php?script_id=1697"><span class="txth1">surround</span></a></h2>
<p><span class="txth1">这也是一个在 html/xhtml 编辑方面很强力的工具，可以方便地把文字用引号、括号、HTML标签包围起来，当然也可以取消包围，甚至替换包围。安装方式很传统，解压，执行 :helptags xxxx 即可。<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/02/%e5%87%a0%e4%b8%aa%e5%a5%bd%e7%94%a8%e7%9a%84-vim-%e6%8f%92%e4%bb%b6/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>改进 google reader 界面的 greasemonkey 脚本</title>
		<link>http://kleshwong.com/blog/2009/02/google-reader-interface-fine-tune-greasemonkey-script</link>
		<comments>http://kleshwong.com/blog/2009/02/google-reader-interface-fine-tune-greasemonkey-script#comments</comments>
		<pubDate>Sat, 07 Feb 2009 02:38:17 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[技巧]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=136</guid>
		<description><![CDATA[两栏模式下的 google reader, 右边正文是固定宽度, 浪费了不少空间, 字体看起来也太小,不舒服, 每次总要把侧栏关掉再加大字体实在不便. 有了 GreaseMonkey 就方便多了. // ==UserScript== // @name Google Reader Interface Fine-Tune // @namespace kleshwong.com // @include https://www.google.com/reader/* // @include http://www.google.com/reader/* // ==/UserScript== function addGlobalStyle(css) { var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = css; head.appendChild(style); } addGlobalStyle(".entry [...]]]></description>
			<content:encoded><![CDATA[<p>两栏模式下的 google reader, 右边正文是固定宽度, 浪费了不少空间, 字体看起来也太小,不舒服, 每次总要把侧栏关掉再加大字体实在不便. 有了 GreaseMonkey 就方便多了.</p>
<pre>// ==UserScript==
// @name           Google Reader Interface Fine-Tune
// @namespace      kleshwong.com
// @include        https://www.google.com/reader/*
// @include        http://www.google.com/reader/*
// ==/UserScript==

function addGlobalStyle(css) {
  var head, style;
  head = document.getElementsByTagName('head')[0];
  if (!head) { return; }
  style = document.createElement('style');
  style.type = 'text/css';
  style.innerHTML = css;
  head.appendChild(style);
}

addGlobalStyle(".entry .entry-body, .entry .entry-title{font-family:'Lucida Grande', '微软雅黑';font-size:16px;line-height:135%;max-width:100%}");

//eof</pre>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2009/02/google-reader-interface-fine-tune-greasemonkey-script/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>利用 auto_complete 插件作类似 google 搜索的智能提示</title>
		<link>http://kleshwong.com/blog/2008/12/rails-auto-complete</link>
		<comments>http://kleshwong.com/blog/2008/12/rails-auto-complete#comments</comments>
		<pubDate>Fri, 26 Dec 2008 10:15:06 +0000</pubDate>
		<dc:creator>Klesh Wong</dc:creator>
				<category><![CDATA[随记]]></category>
		<category><![CDATA[auto_complete]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://kleshwong.com/blog/?p=126</guid>
		<description><![CDATA[rails 2.x (应该是2.1) 以后加入了 forgery protection authentication 功能，所有 post 到 controller action 的表单需带有 authenticity_token 字段。 该字段由 form_for 自动生成附加到表单中，可以通过观察 rails 生成的表单可以看到。 auto_complete 插件默认使用 post 动作请求提示项，但并不会附加该 authenticity_token，因此会产生错误，比较简便的解决方案就是把 text_field_with_auto_complete 请求动作更改为 get]]></description>
			<content:encoded><![CDATA[<p>rails 2.x (应该是2.1) 以后加入了 forgery protection authentication 功能，所有 post 到 controller action 的表单需带有 authenticity_token 字段。 该字段由 form_for 自动生成附加到表单中，可以通过观察 rails 生成的表单可以看到。 auto_complete 插件默认使用 post 动作请求提示项，但并不会附加该 authenticity_token，因此会产生错误，比较简便的解决方案就是把 text_field_with_auto_complete 请求动作更改为 get</p>
<p>1. 安装 auto_complete plugin</p>
<pre>cd /path/to/railsapp
ruby script/plugin install git://github.com/rails/auto_complete.git</pre>
<p>2. controller 添加代码</p>
<pre>class MyController &lt; ApplicationController
  auto_complete_for :model, :field
end</pre>
<p>3. view 添加代码</p>
<pre>&lt;%= javascript_include_tag :defaults %&gt;
&lt;%= text_field_with_auto_complete :model, :field, {:value =&gt; 'default text'}, <strong>{:method =&gt; :get}</strong> %&gt;</pre>
<p>需指定 method 为 get 自动完成功能才能正常工作， 否则默认的 post 动作会通不过 rails 的 forgery protection 校验</p>
]]></content:encoded>
			<wfw:commentRss>http://kleshwong.com/blog/2008/12/rails-auto-complete/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
