<?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>idea&#039;s blog</title>
	<atom:link href="http://www.ideawu.net/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ideawu.net/blog</link>
	<description>PHP Web后端和Web前端开发, 网站架构, Linux C语言编程, Java Spring开发.</description>
	<lastBuildDate>Thu, 12 Apr 2012 07:52:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nginx + PHP 配置和启动脚本</title>
		<link>http://www.ideawu.net/blog/archives/637.html</link>
		<comments>http://www.ideawu.net/blog/archives/637.html#comments</comments>
		<pubDate>Thu, 12 Apr 2012 07:52:17 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/637.html</guid>
		<description><![CDATA[<p>做个笔记.</p>
<pre>
# nginx.conf

server {
    listen 8080 ;
    server_name localhost;

    location / {
        root           /home/work/htdocs;
        expires 1d;
        autoindex on;
        index  index.php index.html;
    }
    location ~* \.php$ {
        root           /home/work/htdocs;
        fastcgi_pass   127.0.0.1:30000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/work/htdocs/$fastcgi_script_name;
        client_max_body_size       100m;
        include        fastcgi_params;
        fastcgi_connect_timeout 1000s;
        fastcgi_send_timeout 1000s;
        fastcgi_read_timeout 1000s;
    }
}

# nginx.sh ngix 启动脚本

#!/bin/sh
case "$1" in
    'start')
        sudo /usr/local/nginx/sbin/nginx -s start
        ;;
    'stop')
        sudo /usr/local/nginx/sbin/nginx -s stop
        ;;
    'restart')
        sudo /usr/local/nginx/sbin/nginx -s reload
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
    ;;
esac

# spaw-php.sh php-cgi 启动脚本
#!/bin/sh
dir=`dirname $0`
PID_FILE=/home/work/htdocs/spaw-php.pid
PHP_FCGI="/home/work/php/bin/php-cgi -f /home/work/htdocs/php.ini"

case "$1" in
    'start')
        spawn-fcgi -C 3 -p 30000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    'stop')
        kill `cat $PID_FILE`
        ;;
    'restart')
        kill `cat $PID_FILE`
        spawn-fcgi -C 3 -p 30000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
    ;;
esac
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/98.html' rel='bookmark' title='Permanent Link: Linux下整合Apache和Tomcat'>Linux下整合Apache和Tomcat</a></li>
<li><a href='http://www.ideawu.net/blog/archives/628.html' rel='bookmark' title='Permanent Link: MySQL 基本配置'>MySQL 基本配置</a></li>
<li><a href='http://www.ideawu.net/blog/archives/352.html' rel='bookmark' title='Permanent Link: 3行代码的分页算法(求起始页和结束页)'>3行代码的分页算法(求起始页和结束页)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/58.html' rel='bookmark' title='Permanent Link: Linux下安装和设置Tomcat,解决JSP中文乱码'>Linux下安装和设置Tomcat,解决JSP中文乱码</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/637.html" title="Nginx + PHP 配置和启动脚本">Nginx + PHP 配置和启动脚本</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>做个笔记.</p>
<pre>
# nginx.conf

server {
    listen 8080 ;
    server_name localhost;

    location / {
        root           /home/work/htdocs;
        expires 1d;
        autoindex on;
        index  index.php index.html;
    }
    location ~* \.php$ {
        root           /home/work/htdocs;
        fastcgi_pass   127.0.0.1:30000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/work/htdocs/$fastcgi_script_name;
        client_max_body_size       100m;
        include        fastcgi_params;
        fastcgi_connect_timeout 1000s;
        fastcgi_send_timeout 1000s;
        fastcgi_read_timeout 1000s;
    }
}

# nginx.sh ngix 启动脚本

#!/bin/sh
case "$1" in
    'start')
        sudo /usr/local/nginx/sbin/nginx -s start
        ;;
    'stop')
        sudo /usr/local/nginx/sbin/nginx -s stop
        ;;
    'restart')
        sudo /usr/local/nginx/sbin/nginx -s reload
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
    ;;
esac

# spaw-php.sh php-cgi 启动脚本
#!/bin/sh
dir=`dirname $0`
PID_FILE=/home/work/htdocs/spaw-php.pid
PHP_FCGI="/home/work/php/bin/php-cgi -f /home/work/htdocs/php.ini"

case "$1" in
    'start')
        spawn-fcgi -C 3 -p 30000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    'stop')
        kill `cat $PID_FILE`
        ;;
    'restart')
        kill `cat $PID_FILE`
        spawn-fcgi -C 3 -p 30000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
    ;;
esac
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/98.html' rel='bookmark' title='Permanent Link: Linux下整合Apache和Tomcat'>Linux下整合Apache和Tomcat</a></li>
<li><a href='http://www.ideawu.net/blog/archives/628.html' rel='bookmark' title='Permanent Link: MySQL 基本配置'>MySQL 基本配置</a></li>
<li><a href='http://www.ideawu.net/blog/archives/352.html' rel='bookmark' title='Permanent Link: 3行代码的分页算法(求起始页和结束页)'>3行代码的分页算法(求起始页和结束页)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/58.html' rel='bookmark' title='Permanent Link: Linux下安装和设置Tomcat,解决JSP中文乱码'>Linux下安装和设置Tomcat,解决JSP中文乱码</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/637.html" title="Nginx + PHP 配置和启动脚本">Nginx + PHP 配置和启动脚本</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/637.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>韩寒现象和中国足球</title>
		<link>http://www.ideawu.net/blog/archives/636.html</link>
		<comments>http://www.ideawu.net/blog/archives/636.html#comments</comments>
		<pubDate>Sat, 07 Apr 2012 18:23:04 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Diary]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=636</guid>
		<description><![CDATA[<p>中国足球技术不差吗? 战绩不丢人吗? 球员不猥琐吗? 假球不普遍吗? 足球官员不腐败吗? 中国足球不是十几年没有任何进步吗? 为什么还是有无数的人喜欢和支持?</p>
<p>你对中国足球嗤之以鼻, 你对中国足球怒其不争, 你用尽所有脏话污辱中国足球(中国的球员, 教练, 官员, 观众), 这确实是他们应得的. 但是, 你能说球场看台上那些花了钱进场欢呼呐喊, 一会儿喜极而泣, 一会儿唉声叹气, 一会儿激动不已的球迷, 这些一个个鲜活的脸, 都不是真实的吗?</p>
<p>你能说中国足球骗了一批又一批刚长大或者还未长大的无知小孩, 你安慰自己这些人很快就会识破的中国足球垃圾和狗屎的本质, 但是, 中国足球(包括有中国球员参与的)的赛场看台上的观众和电视机前衷心的观众全部都是毛头小孩吗? 那些十几年如一日地发自内心地支持中国足球的球迷, 他们真的是愚蠢到了极点了吗?</p>
<p>当某人嘲讽了中国足球的某支联赛球队, 立即便有成千上万的该俱乐部的忠实球迷出来对嘲讽的人进行人身攻击, 极尽恶毒的语言, 难道你能说, 对于垃圾的中国足球及其所有甲A球队 &#8212; 当然他们也都是垃圾和狗屎 &#8212; 任何人都有权污辱他们吗? 那些狂热的球迷他们真挚的感情难道不是应该值得敬畏的吗?</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/525.html' rel='bookmark' title='Permanent Link: 永恒的变化'>永恒的变化</a></li>
<li><a href='http://www.ideawu.net/blog/archives/425.html' rel='bookmark' title='Permanent Link: 今天的午饭: 啤酒+炒蚬子'>今天的午饭: 啤酒+炒蚬子</a></li>
<li><a href='http://www.ideawu.net/blog/archives/350.html' rel='bookmark' title='Permanent Link: 我和赵薇的一次近距离接触'>我和赵薇的一次近距离接触</a></li>
<li><a href='http://www.ideawu.net/blog/archives/190.html' rel='bookmark' title='Permanent Link: 凉爽的天气'>凉爽的天气</a></li>
<li><a href='http://www.ideawu.net/blog/archives/110.html' rel='bookmark' title='Permanent Link: 傲慢与偏见'>傲慢与偏见</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/636.html" title="韩寒现象和中国足球">韩寒现象和中国足球</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>中国足球技术不差吗? 战绩不丢人吗? 球员不猥琐吗? 假球不普遍吗? 足球官员不腐败吗? 中国足球不是十几年没有任何进步吗? 为什么还是有无数的人喜欢和支持?</p>
<p>你对中国足球嗤之以鼻, 你对中国足球怒其不争, 你用尽所有脏话污辱中国足球(中国的球员, 教练, 官员, 观众), 这确实是他们应得的. 但是, 你能说球场看台上那些花了钱进场欢呼呐喊, 一会儿喜极而泣, 一会儿唉声叹气, 一会儿激动不已的球迷, 这些一个个鲜活的脸, 都不是真实的吗?</p>
<p>你能说中国足球骗了一批又一批刚长大或者还未长大的无知小孩, 你安慰自己这些人很快就会识破的中国足球垃圾和狗屎的本质, 但是, 中国足球(包括有中国球员参与的)的赛场看台上的观众和电视机前衷心的观众全部都是毛头小孩吗? 那些十几年如一日地发自内心地支持中国足球的球迷, 他们真的是愚蠢到了极点了吗?</p>
<p>当某人嘲讽了中国足球的某支联赛球队, 立即便有成千上万的该俱乐部的忠实球迷出来对嘲讽的人进行人身攻击, 极尽恶毒的语言, 难道你能说, 对于垃圾的中国足球及其所有甲A球队 &#8212; 当然他们也都是垃圾和狗屎 &#8212; 任何人都有权污辱他们吗? 那些狂热的球迷他们真挚的感情难道不是应该值得敬畏的吗?</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/525.html' rel='bookmark' title='Permanent Link: 永恒的变化'>永恒的变化</a></li>
<li><a href='http://www.ideawu.net/blog/archives/425.html' rel='bookmark' title='Permanent Link: 今天的午饭: 啤酒+炒蚬子'>今天的午饭: 啤酒+炒蚬子</a></li>
<li><a href='http://www.ideawu.net/blog/archives/350.html' rel='bookmark' title='Permanent Link: 我和赵薇的一次近距离接触'>我和赵薇的一次近距离接触</a></li>
<li><a href='http://www.ideawu.net/blog/archives/190.html' rel='bookmark' title='Permanent Link: 凉爽的天气'>凉爽的天气</a></li>
<li><a href='http://www.ideawu.net/blog/archives/110.html' rel='bookmark' title='Permanent Link: 傲慢与偏见'>傲慢与偏见</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/636.html" title="韩寒现象和中国足球">韩寒现象和中国足球</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/636.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Facebook 网站架构</title>
		<link>http://www.ideawu.net/blog/archives/635.html</link>
		<comments>http://www.ideawu.net/blog/archives/635.html#comments</comments>
		<pubDate>Fri, 06 Apr 2012 05:17:22 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[高性能Web架构]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/635.html</guid>
		<description><![CDATA[<p>我收集到一些文章和视频, 可以带你窥探 Facebook 的架构. Facebook 承载了几十亿的用户, 它的架构(包括思想和实现)是非常值得参考的. 当然, 你要小心不要照搬 Facebook 的每一字一句, 因为任何思想和实现都是有自己的应用场景的.</p>
<ul>
<li>文章: <a href="http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919">BigPipe: Pipelining web pages for high performance</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=76191543919">Needle in a haystack: efficient storage of billions of photos</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=10150148835363920">http://www.facebook.com/note.php?note_id=10150148835363920</a></li>
<li>文章: <a href="https://www.facebook.com/note.php?note_id=454991608919">The Underlying Technology of Messages</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=14218138919">Facebook Chat</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=10150144039563920">Building Efficient Data Centers with the Open Compute Project</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=409881258919">Scaling Facebook to 500 Million Users and Beyond</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=307069903919">Making Facebook 2x Faster</a></li>
<li>文章: <a href="http://opencompute.org/">Hacking Conventional Computing Infrastructure</a></li>
<li>视频: <a href="http://www.facebook.com/video/video.php?v=690851516105">The Underlying Technology of Messages Tech Talk (12/7/10)</a></li>
<li>视频: <a href="http://www.facebook.com/video/video.php?v=432864835468">Typeahead Search Tech Talk (6/15/2010)</a></li>
</ul>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/299.html' rel='bookmark' title='Permanent Link: Google Talk 界面开发分析'>Google Talk 界面开发分析</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
<li><a href='http://www.ideawu.net/blog/archives/301.html' rel='bookmark' title='Permanent Link: Google Talk Developer Home 中文翻译'>Google Talk Developer Home 中文翻译</a></li>
<li><a href='http://www.ideawu.net/blog/archives/144.html' rel='bookmark' title='Permanent Link: 使用Gaim连接Gtalk'>使用Gaim连接Gtalk</a></li>
<li><a href='http://www.ideawu.net/blog/archives/611.html' rel='bookmark' title='Permanent Link: 强大的纯JS数据图工具-flot'>强大的纯JS数据图工具-flot</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/635.html" title="Facebook 网站架构">Facebook 网站架构</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>我收集到一些文章和视频, 可以带你窥探 Facebook 的架构. Facebook 承载了几十亿的用户, 它的架构(包括思想和实现)是非常值得参考的. 当然, 你要小心不要照搬 Facebook 的每一字一句, 因为任何思想和实现都是有自己的应用场景的.</p>
<ul>
<li>文章: <a href="http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919">BigPipe: Pipelining web pages for high performance</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=76191543919">Needle in a haystack: efficient storage of billions of photos</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=10150148835363920">http://www.facebook.com/note.php?note_id=10150148835363920</a></li>
<li>文章: <a href="https://www.facebook.com/note.php?note_id=454991608919">The Underlying Technology of Messages</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=14218138919">Facebook Chat</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=10150144039563920">Building Efficient Data Centers with the Open Compute Project</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=409881258919">Scaling Facebook to 500 Million Users and Beyond</a></li>
<li>文章: <a href="http://www.facebook.com/note.php?note_id=307069903919">Making Facebook 2x Faster</a></li>
<li>文章: <a href="http://opencompute.org/">Hacking Conventional Computing Infrastructure</a></li>
<li>视频: <a href="http://www.facebook.com/video/video.php?v=690851516105">The Underlying Technology of Messages Tech Talk (12/7/10)</a></li>
<li>视频: <a href="http://www.facebook.com/video/video.php?v=432864835468">Typeahead Search Tech Talk (6/15/2010)</a></li>
</ul>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/299.html' rel='bookmark' title='Permanent Link: Google Talk 界面开发分析'>Google Talk 界面开发分析</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
<li><a href='http://www.ideawu.net/blog/archives/301.html' rel='bookmark' title='Permanent Link: Google Talk Developer Home 中文翻译'>Google Talk Developer Home 中文翻译</a></li>
<li><a href='http://www.ideawu.net/blog/archives/144.html' rel='bookmark' title='Permanent Link: 使用Gaim连接Gtalk'>使用Gaim连接Gtalk</a></li>
<li><a href='http://www.ideawu.net/blog/archives/611.html' rel='bookmark' title='Permanent Link: 强大的纯JS数据图工具-flot'>强大的纯JS数据图工具-flot</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/635.html" title="Facebook 网站架构">Facebook 网站架构</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/635.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux 核心编程 &#8211; fsync, write</title>
		<link>http://www.ideawu.net/blog/archives/634.html</link>
		<comments>http://www.ideawu.net/blog/archives/634.html#comments</comments>
		<pubDate>Sat, 24 Mar 2012 08:14:19 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fsync]]></category>
		<category><![CDATA[write]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/634.html</guid>
		<description><![CDATA[<h3>write</h3>
<pre>ssize_t write(int fd, const void *buf, size_t count);</pre>
<p>将数据写到文件中. 注意, 如果文件是保存在硬盘中, write() 函数调用返回之后, 并不表示数据已经写入到硬盘中, 这时如果掉电, 数据可能会丢失.</p>
<h3>fsync</h3>
<pre>int fsync(int fd);</pre>
<p>程序调用本函数, 通知内核把数据写到硬盘(file)中. 比如, 你开发一个数据库软件, 就需要这样的函数, 否则掉电或者系统崩溃时便会丢失数据.</p>
<p>如果你的程序不调用 fsync(), Linux 内核也会自动在&#8221;合适&#8221;的时候将你的数据真正写入到硬盘(类似调用 fsync), 最长的延时默认是 30 秒.</p>
<h3>阻塞</h3>
<p>阻塞是 IO 的精华所在, 不管是文件 IO 还是网络 IO, 只有真正了理解了 IO 阻塞, 才能做出所谓在高并发高性能软件(服务器).</p>
<p>当 fsync() 和 write() 同一个 fd 时, write() 必然阻塞. 当系统 IO 非常繁忙时, fsync() 可能会阻塞, 即使系统 IO 不繁忙, fsync() 也会因为数据量大而慢.</p>
<p><strong>注:</strong> 许多 Linux 系统函数如 read(), write() 等, 粗看起来很简单, 也很容易用. 正如所有的事情一样, 要做到精致肯定不简单. 当你脱离初级的学习阶段, 要写真正生产环境的软件时, 这些&#8221;简单&#8221;的函数就大有门道了. 你需要不断的阅读它们的手册, 了解每一个参数, 每一个返回值, 同时还要阅读和试验在各种条件和环境下这些函数的表现, 这样, 才有可能做出真正的软件.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/633.html' rel='bookmark' title='Permanent Link: Redis被bgsave和bgrewriteaof阻塞的解决方法'>Redis被bgsave和bgrewriteaof阻塞的解决方法</a></li>
<li><a href='http://www.ideawu.net/blog/archives/267.html' rel='bookmark' title='Permanent Link: 软件体系结构模式-层'>软件体系结构模式-层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/174.html' rel='bookmark' title='Permanent Link: 安装和使用Skype for Linux'>安装和使用Skype for Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/148.html' rel='bookmark' title='Permanent Link: 安装和使用Google Earth &#8211; Linux'>安装和使用Google Earth &#8211; Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/87.html' rel='bookmark' title='Permanent Link: Debian Linux 系统提速'>Debian Linux 系统提速</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/634.html" title="Linux 核心编程 &#8211; fsync, write">Linux 核心编程 &#8211; fsync, write</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<h3>write</h3>
<pre>ssize_t write(int fd, const void *buf, size_t count);</pre>
<p>将数据写到文件中. 注意, 如果文件是保存在硬盘中, write() 函数调用返回之后, 并不表示数据已经写入到硬盘中, 这时如果掉电, 数据可能会丢失.</p>
<h3>fsync</h3>
<pre>int fsync(int fd);</pre>
<p>程序调用本函数, 通知内核把数据写到硬盘(file)中. 比如, 你开发一个数据库软件, 就需要这样的函数, 否则掉电或者系统崩溃时便会丢失数据.</p>
<p>如果你的程序不调用 fsync(), Linux 内核也会自动在&#8221;合适&#8221;的时候将你的数据真正写入到硬盘(类似调用 fsync), 最长的延时默认是 30 秒.</p>
<h3>阻塞</h3>
<p>阻塞是 IO 的精华所在, 不管是文件 IO 还是网络 IO, 只有真正了理解了 IO 阻塞, 才能做出所谓在高并发高性能软件(服务器).</p>
<p>当 fsync() 和 write() 同一个 fd 时, write() 必然阻塞. 当系统 IO 非常繁忙时, fsync() 可能会阻塞, 即使系统 IO 不繁忙, fsync() 也会因为数据量大而慢.</p>
<p><strong>注:</strong> 许多 Linux 系统函数如 read(), write() 等, 粗看起来很简单, 也很容易用. 正如所有的事情一样, 要做到精致肯定不简单. 当你脱离初级的学习阶段, 要写真正生产环境的软件时, 这些&#8221;简单&#8221;的函数就大有门道了. 你需要不断的阅读它们的手册, 了解每一个参数, 每一个返回值, 同时还要阅读和试验在各种条件和环境下这些函数的表现, 这样, 才有可能做出真正的软件.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/633.html' rel='bookmark' title='Permanent Link: Redis被bgsave和bgrewriteaof阻塞的解决方法'>Redis被bgsave和bgrewriteaof阻塞的解决方法</a></li>
<li><a href='http://www.ideawu.net/blog/archives/267.html' rel='bookmark' title='Permanent Link: 软件体系结构模式-层'>软件体系结构模式-层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/174.html' rel='bookmark' title='Permanent Link: 安装和使用Skype for Linux'>安装和使用Skype for Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/148.html' rel='bookmark' title='Permanent Link: 安装和使用Google Earth &#8211; Linux'>安装和使用Google Earth &#8211; Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/87.html' rel='bookmark' title='Permanent Link: Debian Linux 系统提速'>Debian Linux 系统提速</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/634.html" title="Linux 核心编程 &#8211; fsync, write">Linux 核心编程 &#8211; fsync, write</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/634.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redis被bgsave和bgrewriteaof阻塞的解决方法</title>
		<link>http://www.ideawu.net/blog/archives/633.html</link>
		<comments>http://www.ideawu.net/blog/archives/633.html#comments</comments>
		<pubDate>Fri, 23 Mar 2012 05:50:34 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Computer System]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[aof]]></category>
		<category><![CDATA[appendfsync]]></category>
		<category><![CDATA[bgrewriteaof]]></category>
		<category><![CDATA[bgsave]]></category>
		<category><![CDATA[no-appendfsync-on-rewrite]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[Redis性能优化]]></category>
		<category><![CDATA[Redis阻塞]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/633.html</guid>
		<description><![CDATA[<p>Redis 是一个性能非常高效的内存 Key-Value 存储服务, 同时它还具有两个非常重要的特性: 1. 持久化; 2. Value 数据结构. 这两个特性让它在不少场景轻松击败了 Memcached 和 Casandra 等.</p>
<p>Redis 的持久化在两种方式: Snapshotting(快照) 和 Append-only file(aof). 在一个采用了 aof 模式的 Redis 服务器上, 当执行 bgrewriteaof 对 aof 进行归并优化时, 出现了 Redis 被阻塞的问题, 此时, Redis 无法提供任何读取和写入操作.</p>
<p>按字面理解, bgrewriteaof 是在后台进行操作, 不应该影响 Redis 的正常服务. 原理也确实是这样的, Redis 首先 fork 一个子进程, 并在该子进程里进行归并和写持久化存储设备(如硬盘)的. 按照正常逻辑, 在一台多核的机器上, 即使子进程占满 CPU 和硬盘, 也不应该导致 Redis 服务阻塞啊!</p>
<p>其实, 问题就出在硬盘上.</p>
<p><span id="more-633"></span>Redis 服务设置了 appendfsync everysec, 主进程每秒钟便会调用 fsync(), 要求内核将数据&#8221;确实&#8221;写到存储硬件里. 但由于子进程同时也在写硬盘, 从而导致主进程 fsync()/write() 操作被阻塞, 最终导致 Redis 主进程阻塞了.</p>
<p>解决方法便是设置 no-appendfsync-on-rewrite yes, 在子进程处理和写硬盘时, 主进程不调用 fsync() 操作. 注意, 即使进程不调用 fsync(), 系统内核也会根据自己的算法在适当的时机将数据写到硬盘(Linux 默认最长不超过 30 秒).</p>
<p>不过, 虽然某个 Redis A 并没有在 rewriteaof, 这时便进行 fsync(), 但系统里的其它进程, 如其它的 Redis 实例也可能导致 A 的 fsync 阻塞.</p>
<p>相关讨论:<br />
<a href="https://groups.google.com/group/redis-db/browse_thread/thread/a9c5a6019108319e">https://groups.google.com/group/redis-db/browse_thread/thread/a9c5a6019108319e</a><br />
<a href="http://antirez.com/post/fsync-different-thread-useless.html">http://antirez.com/post/fsync-different-thread-useless.html</a><br />
<a href="http://redis.io/topics/latency">http://redis.io/topics/latency</a></p>
<blockquote><p>
* When appendfsync is set to the value of no Redis performs no fsync. In this configuration the only source of latency can be write(2). When this happens usually there is no solution since simply the disk can&#8217;t cope with the speed at which Redis is receiving data, however this is uncommon if the disk is not seriously slowed down by other processes doing I/O.</p>
<p>* When appendfsync is set to the value of everysec Redis performs an fsync every second. It uses a different thread, and if the fsync is still in progress Redis uses a buffer to delay the write(2) call up to two seconds (since write would block on Linux if an fsync is in progress against the same file). However if the fsync is taking too long Redis will eventually perform the write(2) call even if the fsync is still in progress, and this can be a source of latency.</p>
<p>* When appendfsync is set to the value of always an fsync is performed at every write operation before replying back to the client with an OK code (actually Redis will try to cluster many commands executed at the same time into a single fsync). In this mode performances are very low in general and it is strongly recommended to use a fast disk and a file system implementation that can perform the fsync in short time.
</p></blockquote>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/634.html' rel='bookmark' title='Permanent Link: Linux 核心编程 &#8211; fsync, write'>Linux 核心编程 &#8211; fsync, write</a></li>
<li><a href='http://www.ideawu.net/blog/archives/216.html' rel='bookmark' title='Permanent Link: 用mplayer,toolame提取rmvb等视频文件中的音频为mp3'>用mplayer,toolame提取rmvb等视频文件中的音频为mp3</a></li>
<li><a href='http://www.ideawu.net/blog/archives/267.html' rel='bookmark' title='Permanent Link: 软件体系结构模式-层'>软件体系结构模式-层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/246.html' rel='bookmark' title='Permanent Link: 对P2P应用不友好的NAT'>对P2P应用不友好的NAT</a></li>
<li><a href='http://www.ideawu.net/blog/archives/229.html' rel='bookmark' title='Permanent Link: P2P穿透NAT的思路'>P2P穿透NAT的思路</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/633.html" title="Redis被bgsave和bgrewriteaof阻塞的解决方法">Redis被bgsave和bgrewriteaof阻塞的解决方法</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>Redis 是一个性能非常高效的内存 Key-Value 存储服务, 同时它还具有两个非常重要的特性: 1. 持久化; 2. Value 数据结构. 这两个特性让它在不少场景轻松击败了 Memcached 和 Casandra 等.</p>
<p>Redis 的持久化在两种方式: Snapshotting(快照) 和 Append-only file(aof). 在一个采用了 aof 模式的 Redis 服务器上, 当执行 bgrewriteaof 对 aof 进行归并优化时, 出现了 Redis 被阻塞的问题, 此时, Redis 无法提供任何读取和写入操作.</p>
<p>按字面理解, bgrewriteaof 是在后台进行操作, 不应该影响 Redis 的正常服务. 原理也确实是这样的, Redis 首先 fork 一个子进程, 并在该子进程里进行归并和写持久化存储设备(如硬盘)的. 按照正常逻辑, 在一台多核的机器上, 即使子进程占满 CPU 和硬盘, 也不应该导致 Redis 服务阻塞啊!</p>
<p>其实, 问题就出在硬盘上.</p>
<p><span id="more-633"></span>Redis 服务设置了 appendfsync everysec, 主进程每秒钟便会调用 fsync(), 要求内核将数据&#8221;确实&#8221;写到存储硬件里. 但由于子进程同时也在写硬盘, 从而导致主进程 fsync()/write() 操作被阻塞, 最终导致 Redis 主进程阻塞了.</p>
<p>解决方法便是设置 no-appendfsync-on-rewrite yes, 在子进程处理和写硬盘时, 主进程不调用 fsync() 操作. 注意, 即使进程不调用 fsync(), 系统内核也会根据自己的算法在适当的时机将数据写到硬盘(Linux 默认最长不超过 30 秒).</p>
<p>不过, 虽然某个 Redis A 并没有在 rewriteaof, 这时便进行 fsync(), 但系统里的其它进程, 如其它的 Redis 实例也可能导致 A 的 fsync 阻塞.</p>
<p>相关讨论:<br />
<a href="https://groups.google.com/group/redis-db/browse_thread/thread/a9c5a6019108319e">https://groups.google.com/group/redis-db/browse_thread/thread/a9c5a6019108319e</a><br />
<a href="http://antirez.com/post/fsync-different-thread-useless.html">http://antirez.com/post/fsync-different-thread-useless.html</a><br />
<a href="http://redis.io/topics/latency">http://redis.io/topics/latency</a></p>
<blockquote><p>
* When appendfsync is set to the value of no Redis performs no fsync. In this configuration the only source of latency can be write(2). When this happens usually there is no solution since simply the disk can&#8217;t cope with the speed at which Redis is receiving data, however this is uncommon if the disk is not seriously slowed down by other processes doing I/O.</p>
<p>* When appendfsync is set to the value of everysec Redis performs an fsync every second. It uses a different thread, and if the fsync is still in progress Redis uses a buffer to delay the write(2) call up to two seconds (since write would block on Linux if an fsync is in progress against the same file). However if the fsync is taking too long Redis will eventually perform the write(2) call even if the fsync is still in progress, and this can be a source of latency.</p>
<p>* When appendfsync is set to the value of always an fsync is performed at every write operation before replying back to the client with an OK code (actually Redis will try to cluster many commands executed at the same time into a single fsync). In this mode performances are very low in general and it is strongly recommended to use a fast disk and a file system implementation that can perform the fsync in short time.
</p></blockquote>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/634.html' rel='bookmark' title='Permanent Link: Linux 核心编程 &#8211; fsync, write'>Linux 核心编程 &#8211; fsync, write</a></li>
<li><a href='http://www.ideawu.net/blog/archives/216.html' rel='bookmark' title='Permanent Link: 用mplayer,toolame提取rmvb等视频文件中的音频为mp3'>用mplayer,toolame提取rmvb等视频文件中的音频为mp3</a></li>
<li><a href='http://www.ideawu.net/blog/archives/267.html' rel='bookmark' title='Permanent Link: 软件体系结构模式-层'>软件体系结构模式-层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/246.html' rel='bookmark' title='Permanent Link: 对P2P应用不友好的NAT'>对P2P应用不友好的NAT</a></li>
<li><a href='http://www.ideawu.net/blog/archives/229.html' rel='bookmark' title='Permanent Link: P2P穿透NAT的思路'>P2P穿透NAT的思路</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/633.html" title="Redis被bgsave和bgrewriteaof阻塞的解决方法">Redis被bgsave和bgrewriteaof阻塞的解决方法</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/633.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP的优势</title>
		<link>http://www.ideawu.net/blog/archives/632.html</link>
		<comments>http://www.ideawu.net/blog/archives/632.html#comments</comments>
		<pubDate>Thu, 08 Mar 2012 02:43:18 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/632.html</guid>
		<description><![CDATA[<p>以前偶尔被人问到, 为什么你(和大部分互联网公司)做Web开发要选择PHP, PHP有什么好处. 简单的回答便是&#8221;PHP简单,开发快速&#8221;.</p>
<p>但是, ASP.NET不简单吗? ASP.NET上手不快吗? Python呢?</p>
<p>有些人用各种PHP框架能快速搭建简单博客的例子来说明PHP的优势, 但这全是狗屎! 实际的业务不可能是博客那么简单.</p>
<p>我认为, PHP的最大优势便是他的数据结构和内置函数, 具体地说便是字符串和数组, 以及字符串和数组的函数.</p>
<p>PHP的字符串既能表示一般文本, 也能表示任意二进制数据, 也就是说, PHP的字符串就是一段内存. PHP的的字符串操作函数囊括了大部分常见和不常见的文本操作: 截取, 查找, 正则, 字符集编码转换&#8230;每一个都是一把利器.</p>
<p>PHP的数组是整合了列表和哈希表的数据结构. 由于&#8221;树&#8221;是最能描述现实世界的数据结构, 而PHP的数组可以(轻松地)表示任意树, 所以, PHP的数组也最能描述现实世界(建模).</p>
<p>如果要用一句话来描述PHP的优势, 我会用这一句:&#8221;PHP语言的数据结构和内置函数, 可以几乎直接地描述和处理实际业务. PHP是计算机与现实业务的最直接胶合剂.&#8221;</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
<li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/519.html' rel='bookmark' title='Permanent Link: Wordpress评论转义HTML标签'>Wordpress评论转义HTML标签</a></li>
<li><a href='http://www.ideawu.net/blog/archives/474.html' rel='bookmark' title='Permanent Link: 我们丢失了Model层'>我们丢失了Model层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/263.html' rel='bookmark' title='Permanent Link: PHP str_replace 函数的参数设计不合理之处'>PHP str_replace 函数的参数设计不合理之处</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/632.html" title="PHP的优势">PHP的优势</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>以前偶尔被人问到, 为什么你(和大部分互联网公司)做Web开发要选择PHP, PHP有什么好处. 简单的回答便是&#8221;PHP简单,开发快速&#8221;.</p>
<p>但是, ASP.NET不简单吗? ASP.NET上手不快吗? Python呢?</p>
<p>有些人用各种PHP框架能快速搭建简单博客的例子来说明PHP的优势, 但这全是狗屎! 实际的业务不可能是博客那么简单.</p>
<p>我认为, PHP的最大优势便是他的数据结构和内置函数, 具体地说便是字符串和数组, 以及字符串和数组的函数.</p>
<p>PHP的字符串既能表示一般文本, 也能表示任意二进制数据, 也就是说, PHP的字符串就是一段内存. PHP的的字符串操作函数囊括了大部分常见和不常见的文本操作: 截取, 查找, 正则, 字符集编码转换&#8230;每一个都是一把利器.</p>
<p>PHP的数组是整合了列表和哈希表的数据结构. 由于&#8221;树&#8221;是最能描述现实世界的数据结构, 而PHP的数组可以(轻松地)表示任意树, 所以, PHP的数组也最能描述现实世界(建模).</p>
<p>如果要用一句话来描述PHP的优势, 我会用这一句:&#8221;PHP语言的数据结构和内置函数, 可以几乎直接地描述和处理实际业务. PHP是计算机与现实业务的最直接胶合剂.&#8221;</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
<li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/519.html' rel='bookmark' title='Permanent Link: Wordpress评论转义HTML标签'>Wordpress评论转义HTML标签</a></li>
<li><a href='http://www.ideawu.net/blog/archives/474.html' rel='bookmark' title='Permanent Link: 我们丢失了Model层'>我们丢失了Model层</a></li>
<li><a href='http://www.ideawu.net/blog/archives/263.html' rel='bookmark' title='Permanent Link: PHP str_replace 函数的参数设计不合理之处'>PHP str_replace 函数的参数设计不合理之处</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/632.html" title="PHP的优势">PHP的优势</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/632.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>给笔记本装SSD硬盘</title>
		<link>http://www.ideawu.net/blog/archives/630.html</link>
		<comments>http://www.ideawu.net/blog/archives/630.html#comments</comments>
		<pubDate>Fri, 02 Mar 2012 17:19:43 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[IT技术和评论]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=630</guid>
		<description><![CDATA[<p>最近用脚本处理一些数据, 才真正意识到, 现在的计算机, 的确是机械硬盘拖了大后腿. 启动浏览器, 复制文件, 看到硬盘指示灯狂闪时, 真担心硬盘要散架了. 这时, 我才决定要为我的<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIA%2Br4lUkol75nQiPP%2FoLXx1a4YQyHqSJPexhg%3D%3D&#038;p=mm_13929649_0_0">东芝笔记本电脑</a>买一个固态硬盘(SSD)了.</p>
<p>查了下, 固态硬盘价格还是有些贵, SATA-2 的大概10元/G, SATA-3 更要贵得多了, 最终买了一个<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIOXvHo7kijVDwIMM7aYCc6giwEBMVuRo%2BiVhg%3D%3D&#038;p=mm_13929649_0_0">三星470系列 64G SSD硬盘</a>. 计划把 SSD 硬盘装在原来的硬盘位, 然后把原装的硬盘安装到光驱位, 以后再买个外置光驱盒. 没想到, 由于不懂路, 竟然买了一个台式机用的 SSD 硬盘架.</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2012/03/sanxing-ssd.jpg" alt="" title="三星SSD固态硬盘" width="350" height="350" class="alignnone size-full wp-image-629" /></p>
<p>京东没有笔记本光驱位硬盘托架, 只能在淘宝上买了. 虽然淘宝价格有些便宜, 但物流和坏货风险太多, 所以我一般不在淘宝买东西, 这次是不得已而为之. 买了这个<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIKkWuc2XxvZbbn2Y9XNvCzcYfkmjAGox%2Bt%2F%2BA%3D%3D&#038;p=mm_13929649_0_0">笔记本光驱位硬盘托架</a>.</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2012/03/yingpantuojia.jpg" alt="" title="笔记本光驱位 第二块硬盘托架" width="310" height="275" class="alignnone size-full wp-image-631" /></p>
<p>安装步骤如下:</p>
<ul>
<li>三星的固态硬盘配有一个 Ghost 光盘, 先用光盘启动, 把 C 盘克隆到移动硬盘.</li>
<li>换装固态硬盘, 替换掉原来的机械光盘. 用 Ghost 盘启动, 克隆 Windows XP 到固态硬盘上.</li>
<li>重启确认没问题, 再用买来的硬盘托架把机械硬盘安装上, 替换掉光驱.</li>
</ul>
<p>SSD 硬盘确实非常值得拥有, 首先从操作系统启动第一步就感受到, 很快就进入 Windows 桌面, 而且显示桌面后不会有停滞, 就可以立即操作.</p>
<p>VMware 虚拟机从休眠到恢复, 3到5秒便可完成.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/230.html' rel='bookmark' title='Permanent Link: 我要转到 Windows 平台了'>我要转到 Windows 平台了</a></li>
<li><a href='http://www.ideawu.net/blog/archives/231.html' rel='bookmark' title='Permanent Link: 转到 Windows 平台的事需要考虑'>转到 Windows 平台的事需要考虑</a></li>
<li><a href='http://www.ideawu.net/blog/archives/12.html' rel='bookmark' title='Permanent Link: DOS常用命令全攻略'>DOS常用命令全攻略</a></li>
<li><a href='http://www.ideawu.net/blog/archives/555.html' rel='bookmark' title='Permanent Link: Firefox火狐安装Flash插件'>Firefox火狐安装Flash插件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/214.html' rel='bookmark' title='Permanent Link: Web设计与开发服务'>Web设计与开发服务</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/630.html" title="给笔记本装SSD硬盘">给笔记本装SSD硬盘</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>最近用脚本处理一些数据, 才真正意识到, 现在的计算机, 的确是机械硬盘拖了大后腿. 启动浏览器, 复制文件, 看到硬盘指示灯狂闪时, 真担心硬盘要散架了. 这时, 我才决定要为我的<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIA%2Br4lUkol75nQiPP%2FoLXx1a4YQyHqSJPexhg%3D%3D&#038;p=mm_13929649_0_0">东芝笔记本电脑</a>买一个固态硬盘(SSD)了.</p>
<p>查了下, 固态硬盘价格还是有些贵, SATA-2 的大概10元/G, SATA-3 更要贵得多了, 最终买了一个<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIOXvHo7kijVDwIMM7aYCc6giwEBMVuRo%2BiVhg%3D%3D&#038;p=mm_13929649_0_0">三星470系列 64G SSD硬盘</a>. 计划把 SSD 硬盘装在原来的硬盘位, 然后把原装的硬盘安装到光驱位, 以后再买个外置光驱盒. 没想到, 由于不懂路, 竟然买了一个台式机用的 SSD 硬盘架.</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2012/03/sanxing-ssd.jpg" alt="" title="三星SSD固态硬盘" width="350" height="350" class="alignnone size-full wp-image-629" /></p>
<p>京东没有笔记本光驱位硬盘托架, 只能在淘宝上买了. 虽然淘宝价格有些便宜, 但物流和坏货风险太多, 所以我一般不在淘宝买东西, 这次是不得已而为之. 买了这个<a href="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIKkWuc2XxvZbbn2Y9XNvCzcYfkmjAGox%2Bt%2F%2BA%3D%3D&#038;p=mm_13929649_0_0">笔记本光驱位硬盘托架</a>.</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2012/03/yingpantuojia.jpg" alt="" title="笔记本光驱位 第二块硬盘托架" width="310" height="275" class="alignnone size-full wp-image-631" /></p>
<p>安装步骤如下:</p>
<ul>
<li>三星的固态硬盘配有一个 Ghost 光盘, 先用光盘启动, 把 C 盘克隆到移动硬盘.</li>
<li>换装固态硬盘, 替换掉原来的机械光盘. 用 Ghost 盘启动, 克隆 Windows XP 到固态硬盘上.</li>
<li>重启确认没问题, 再用买来的硬盘托架把机械硬盘安装上, 替换掉光驱.</li>
</ul>
<p>SSD 硬盘确实非常值得拥有, 首先从操作系统启动第一步就感受到, 很快就进入 Windows 桌面, 而且显示桌面后不会有停滞, 就可以立即操作.</p>
<p>VMware 虚拟机从休眠到恢复, 3到5秒便可完成.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/230.html' rel='bookmark' title='Permanent Link: 我要转到 Windows 平台了'>我要转到 Windows 平台了</a></li>
<li><a href='http://www.ideawu.net/blog/archives/231.html' rel='bookmark' title='Permanent Link: 转到 Windows 平台的事需要考虑'>转到 Windows 平台的事需要考虑</a></li>
<li><a href='http://www.ideawu.net/blog/archives/12.html' rel='bookmark' title='Permanent Link: DOS常用命令全攻略'>DOS常用命令全攻略</a></li>
<li><a href='http://www.ideawu.net/blog/archives/555.html' rel='bookmark' title='Permanent Link: Firefox火狐安装Flash插件'>Firefox火狐安装Flash插件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/214.html' rel='bookmark' title='Permanent Link: Web设计与开发服务'>Web设计与开发服务</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/630.html" title="给笔记本装SSD硬盘">给笔记本装SSD硬盘</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/630.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL 基本配置</title>
		<link>http://www.ideawu.net/blog/archives/628.html</link>
		<comments>http://www.ideawu.net/blog/archives/628.html#comments</comments>
		<pubDate>Thu, 01 Mar 2012 02:41:23 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/628.html</guid>
		<description><![CDATA[<p>query_cache_size, tmp_table_size 这两个选项一定要设置!</p>
<pre>
# The following options will be passed to all MySQL clients
[client]
#password	= your_password
port		= 3306
socket		= /home/work/mysql/tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port		= 3306
bind-address = 127.0.0.1
socket		= /home/work/mysql/tmp/mysql.sock
#skip-locking
max_allowed_packet = 1M
table_open_cache = 16
sort_buffer_size = 8M
read_buffer_size = 512K
read_rnd_buffer_size = 256K
net_buffer_length = 8K
thread_stack = 128K

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size = 8M

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size = 8M

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=16M

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=16M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
skip-networking
server-id	= 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Uncomment the following if you are using InnoDB tables
#default_storage_engine=InnoDB

innodb_data_home_dir = /home/work/mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /home/work/mysql/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 32M
innodb_additional_mem_pool_size = 4M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 10M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/417.html' rel='bookmark' title='Permanent Link: MySQL 建立外键约束'>MySQL 建立外键约束</a></li>
<li><a href='http://www.ideawu.net/blog/archives/356.html' rel='bookmark' title='Permanent Link: JavaScript+CSS实现数据表格条纹'>JavaScript+CSS实现数据表格条纹</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
<li><a href='http://www.ideawu.net/blog/archives/590.html' rel='bookmark' title='Permanent Link: MySQL&#8221;海量数据&#8221;查询性能分析'>MySQL&#8221;海量数据&#8221;查询性能分析</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/628.html" title="MySQL 基本配置">MySQL 基本配置</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>query_cache_size, tmp_table_size 这两个选项一定要设置!</p>
<pre>
# The following options will be passed to all MySQL clients
[client]
#password	= your_password
port		= 3306
socket		= /home/work/mysql/tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port		= 3306
bind-address = 127.0.0.1
socket		= /home/work/mysql/tmp/mysql.sock
#skip-locking
max_allowed_packet = 1M
table_open_cache = 16
sort_buffer_size = 8M
read_buffer_size = 512K
read_rnd_buffer_size = 256K
net_buffer_length = 8K
thread_stack = 128K

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size = 8M

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size = 8M

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=16M

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=16M

# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
skip-networking
server-id	= 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format - mixed recommended
#binlog_format=mixed

# Uncomment the following if you are using InnoDB tables
#default_storage_engine=InnoDB

innodb_data_home_dir = /home/work/mysql/var/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /home/work/mysql/var/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 32M
innodb_additional_mem_pool_size = 4M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 10M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/417.html' rel='bookmark' title='Permanent Link: MySQL 建立外键约束'>MySQL 建立外键约束</a></li>
<li><a href='http://www.ideawu.net/blog/archives/356.html' rel='bookmark' title='Permanent Link: JavaScript+CSS实现数据表格条纹'>JavaScript+CSS实现数据表格条纹</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
<li><a href='http://www.ideawu.net/blog/archives/590.html' rel='bookmark' title='Permanent Link: MySQL&#8221;海量数据&#8221;查询性能分析'>MySQL&#8221;海量数据&#8221;查询性能分析</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/628.html" title="MySQL 基本配置">MySQL 基本配置</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/628.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>网站如何禁止非浏览器访问?</title>
		<link>http://www.ideawu.net/blog/archives/627.html</link>
		<comments>http://www.ideawu.net/blog/archives/627.html#comments</comments>
		<pubDate>Sat, 18 Feb 2012 03:50:43 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/627.html</guid>
		<description><![CDATA[<p>网站如果禁止非浏览器访问, 一般主要还是防止自动 Spam, 主要是:</p>
<ul>
<li>防止网站被机器人恶意抓取</li>
<li>防止网站被机器人恶意提交</li>
</ul>
<p>判断恶意请求(程序和软件直接发送 HTTP 请求)的方法有很多, 比如同 IP 请求频率是. 但一旦判定某个请求为异常行为之后, 并不适合直接关闭该连接, 或者返回出错页. 因为绝大多数的判定方法都无法做到很高的正确率, 其主要原来就是缺少&#8221;交互性&#8221;. &#8220;交互性&#8221;是判断人和机器的主要因素.</p>
<p>这里判断一种利用交互性来判别是否浏览器正常访问的方法:</p>
<ol>
<li>
		当初步判定请求为异常时, 给该请求返回一个动态令牌, 要求对方在下次重新带着该令牌来访问原先请求的资源;
	</li>
<li>
		如何告知用户进行这个行为, 根据交互性的强弱依次为:</p>
<ol>
<li>设置 Cookie</li>
<li>通过 JavaScript 脚本的执行(设置 Cookie, 生成带令牌的链接并访问)</li>
<li>显示网页表单, 要求用户进行点击和输入等操作(单纯的无输入表单, 图片验证码, 声音验证码)</li>
</ol>
</li>
<li>第一种设置 Cookie 太过于简单, 因为一般的机器人都能执行该行为. 第二种 JavaScript 脚本的方式, 其实已经能阻挡大部分机器人. 第三种是非常好的识别那漏掉的一小撮高级机器人, 但同时也可能影响正常用户体验.</li>
</ol>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/396.html' rel='bookmark' title='Permanent Link: 博客防垃圾评论探讨'>博客防垃圾评论探讨</a></li>
<li><a href='http://www.ideawu.net/blog/archives/399.html' rel='bookmark' title='Permanent Link: JavaScript+jQuery两栏选择控件'>JavaScript+jQuery两栏选择控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/611.html' rel='bookmark' title='Permanent Link: 强大的纯JS数据图工具-flot'>强大的纯JS数据图工具-flot</a></li>
<li><a href='http://www.ideawu.net/blog/archives/352.html' rel='bookmark' title='Permanent Link: 3行代码的分页算法(求起始页和结束页)'>3行代码的分页算法(求起始页和结束页)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/412.html' rel='bookmark' title='Permanent Link: JavaScript分页控件'>JavaScript分页控件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/627.html" title="网站如何禁止非浏览器访问?">网站如何禁止非浏览器访问?</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>网站如果禁止非浏览器访问, 一般主要还是防止自动 Spam, 主要是:</p>
<ul>
<li>防止网站被机器人恶意抓取</li>
<li>防止网站被机器人恶意提交</li>
</ul>
<p>判断恶意请求(程序和软件直接发送 HTTP 请求)的方法有很多, 比如同 IP 请求频率是. 但一旦判定某个请求为异常行为之后, 并不适合直接关闭该连接, 或者返回出错页. 因为绝大多数的判定方法都无法做到很高的正确率, 其主要原来就是缺少&#8221;交互性&#8221;. &#8220;交互性&#8221;是判断人和机器的主要因素.</p>
<p>这里判断一种利用交互性来判别是否浏览器正常访问的方法:</p>
<ol>
<li>
		当初步判定请求为异常时, 给该请求返回一个动态令牌, 要求对方在下次重新带着该令牌来访问原先请求的资源;
	</li>
<li>
		如何告知用户进行这个行为, 根据交互性的强弱依次为:</p>
<ol>
<li>设置 Cookie</li>
<li>通过 JavaScript 脚本的执行(设置 Cookie, 生成带令牌的链接并访问)</li>
<li>显示网页表单, 要求用户进行点击和输入等操作(单纯的无输入表单, 图片验证码, 声音验证码)</li>
</ol>
</li>
<li>第一种设置 Cookie 太过于简单, 因为一般的机器人都能执行该行为. 第二种 JavaScript 脚本的方式, 其实已经能阻挡大部分机器人. 第三种是非常好的识别那漏掉的一小撮高级机器人, 但同时也可能影响正常用户体验.</li>
</ol>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/396.html' rel='bookmark' title='Permanent Link: 博客防垃圾评论探讨'>博客防垃圾评论探讨</a></li>
<li><a href='http://www.ideawu.net/blog/archives/399.html' rel='bookmark' title='Permanent Link: JavaScript+jQuery两栏选择控件'>JavaScript+jQuery两栏选择控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/611.html' rel='bookmark' title='Permanent Link: 强大的纯JS数据图工具-flot'>强大的纯JS数据图工具-flot</a></li>
<li><a href='http://www.ideawu.net/blog/archives/352.html' rel='bookmark' title='Permanent Link: 3行代码的分页算法(求起始页和结束页)'>3行代码的分页算法(求起始页和结束页)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/412.html' rel='bookmark' title='Permanent Link: JavaScript分页控件'>JavaScript分页控件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/627.html" title="网站如何禁止非浏览器访问?">网站如何禁止非浏览器访问?</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/627.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome浏览器必装的插件</title>
		<link>http://www.ideawu.net/blog/archives/625.html</link>
		<comments>http://www.ideawu.net/blog/archives/625.html#comments</comments>
		<pubDate>Thu, 12 Jan 2012 14:55:11 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[etc]]></category>
		<category><![CDATA[Chrome Toolbox]]></category>
		<category><![CDATA[SwitchySharp]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=625</guid>
		<description><![CDATA[<p>默认的Chrome浏览器非常弱智, 弱智到不可用. 举两点:</p>
<ul>
<li>关闭最后一个标签时, Chrome程序就退出了 &#8211; 而且没有选项可以配置.</li>
<li>和IE共用同一个代理(Proxy)设置, Google的人技术会差到不能开发一个HTTP库, 而要用操作系统自带的吗?!.</li>
</ul>
<p>为了解决这两个问题, 必须安装两个插件:</p>
<ul>
<li><a href="https://chrome.google.com/webstore/detail/fjccknnhdnkbanjilpjddjhmkghmachn">Chrome Toolbox</a></li>
<li><a href="https://chrome.google.com/webstore/detail/dpplabbmogkhghncfbfdeeokoefdjegm">SwitchySharp</a></li>
</ul>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/510.html' rel='bookmark' title='Permanent Link: SSH ProxyCommand及其思想'>SSH ProxyCommand及其思想</a></li>
<li><a href='http://www.ideawu.net/blog/archives/511.html' rel='bookmark' title='Permanent Link: endless_tcp &#8211; 一种适应极端网络环境的网络软件架构'>endless_tcp &#8211; 一种适应极端网络环境的网络软件架构</a></li>
<li><a href='http://www.ideawu.net/blog/archives/396.html' rel='bookmark' title='Permanent Link: 博客防垃圾评论探讨'>博客防垃圾评论探讨</a></li>
<li><a href='http://www.ideawu.net/blog/archives/125.html' rel='bookmark' title='Permanent Link: 从感观上体验桌面Linux'>从感观上体验桌面Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/32.html' rel='bookmark' title='Permanent Link: Java中文问题及最优解决方法'>Java中文问题及最优解决方法</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/625.html" title="Chrome浏览器必装的插件">Chrome浏览器必装的插件</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>默认的Chrome浏览器非常弱智, 弱智到不可用. 举两点:</p>
<ul>
<li>关闭最后一个标签时, Chrome程序就退出了 &#8211; 而且没有选项可以配置.</li>
<li>和IE共用同一个代理(Proxy)设置, Google的人技术会差到不能开发一个HTTP库, 而要用操作系统自带的吗?!.</li>
</ul>
<p>为了解决这两个问题, 必须安装两个插件:</p>
<ul>
<li><a href="https://chrome.google.com/webstore/detail/fjccknnhdnkbanjilpjddjhmkghmachn">Chrome Toolbox</a></li>
<li><a href="https://chrome.google.com/webstore/detail/dpplabbmogkhghncfbfdeeokoefdjegm">SwitchySharp</a></li>
</ul>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/510.html' rel='bookmark' title='Permanent Link: SSH ProxyCommand及其思想'>SSH ProxyCommand及其思想</a></li>
<li><a href='http://www.ideawu.net/blog/archives/511.html' rel='bookmark' title='Permanent Link: endless_tcp &#8211; 一种适应极端网络环境的网络软件架构'>endless_tcp &#8211; 一种适应极端网络环境的网络软件架构</a></li>
<li><a href='http://www.ideawu.net/blog/archives/396.html' rel='bookmark' title='Permanent Link: 博客防垃圾评论探讨'>博客防垃圾评论探讨</a></li>
<li><a href='http://www.ideawu.net/blog/archives/125.html' rel='bookmark' title='Permanent Link: 从感观上体验桌面Linux'>从感观上体验桌面Linux</a></li>
<li><a href='http://www.ideawu.net/blog/archives/32.html' rel='bookmark' title='Permanent Link: Java中文问题及最优解决方法'>Java中文问题及最优解决方法</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/625.html" title="Chrome浏览器必装的插件">Chrome浏览器必装的插件</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/625.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python logging 标准配置</title>
		<link>http://www.ideawu.net/blog/archives/624.html</link>
		<comments>http://www.ideawu.net/blog/archives/624.html#comments</comments>
		<pubDate>Wed, 04 Jan 2012 09:10:57 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/624.html</guid>
		<description><![CDATA[<pre>
# encoding=UTF-8
import logging
import logging.config

logging.addLevelName(5, 'TRACE')
logging.addLevelName(30, 'WARN')
logging.addLevelName(50, 'FATAL')

logging.config.fileConfig('my.conf')
logger = logging.getLogger('root')
</pre>
<p>my.conf:</p>
<pre>
[loggers]
keys=root

[handlers]
keys=consoleHandler, fileHandler

[formatters]
keys=simpleFormatter

[logger_root]
#level=ERROR
level=DEBUG
handlers=consoleHandler, fileHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=simpleFormatter
args=('a.log', 'a')

[formatter_simpleFormatter]
#format=%(asctime)s [%(levelname)-5s] %(name)s %(message)s
format=%(asctime)s [%(levelname)-5s] %(message)s
#datefmt= %Y-%m-%d %H:%M:%S
datefmt=
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/407.html' rel='bookmark' title='Permanent Link: .Net程序中使用log4net记录日志'>.Net程序中使用log4net记录日志</a></li>
<li><a href='http://www.ideawu.net/blog/archives/426.html' rel='bookmark' title='Permanent Link: C#封装log4net'>C#封装log4net</a></li>
<li><a href='http://www.ideawu.net/blog/archives/155.html' rel='bookmark' title='Permanent Link: 如何使用ServletContextListener'>如何使用ServletContextListener</a></li>
<li><a href='http://www.ideawu.net/blog/archives/508.html' rel='bookmark' title='Permanent Link: Windows Python select标准输入输出'>Windows Python select标准输入输出</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/624.html" title="Python logging 标准配置">Python logging 标准配置</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<pre>
# encoding=UTF-8
import logging
import logging.config

logging.addLevelName(5, 'TRACE')
logging.addLevelName(30, 'WARN')
logging.addLevelName(50, 'FATAL')

logging.config.fileConfig('my.conf')
logger = logging.getLogger('root')
</pre>
<p>my.conf:</p>
<pre>
[loggers]
keys=root

[handlers]
keys=consoleHandler, fileHandler

[formatters]
keys=simpleFormatter

[logger_root]
#level=ERROR
level=DEBUG
handlers=consoleHandler, fileHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=simpleFormatter
args=('a.log', 'a')

[formatter_simpleFormatter]
#format=%(asctime)s [%(levelname)-5s] %(name)s %(message)s
format=%(asctime)s [%(levelname)-5s] %(message)s
#datefmt= %Y-%m-%d %H:%M:%S
datefmt=
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/407.html' rel='bookmark' title='Permanent Link: .Net程序中使用log4net记录日志'>.Net程序中使用log4net记录日志</a></li>
<li><a href='http://www.ideawu.net/blog/archives/426.html' rel='bookmark' title='Permanent Link: C#封装log4net'>C#封装log4net</a></li>
<li><a href='http://www.ideawu.net/blog/archives/155.html' rel='bookmark' title='Permanent Link: 如何使用ServletContextListener'>如何使用ServletContextListener</a></li>
<li><a href='http://www.ideawu.net/blog/archives/508.html' rel='bookmark' title='Permanent Link: Windows Python select标准输入输出'>Windows Python select标准输入输出</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/624.html" title="Python logging 标准配置">Python logging 标准配置</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/624.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让他们来告我吧!</title>
		<link>http://www.ideawu.net/blog/archives/623.html</link>
		<comments>http://www.ideawu.net/blog/archives/623.html#comments</comments>
		<pubDate>Thu, 01 Dec 2011 06:16:37 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[IT技术和评论]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/archives/623.html</guid>
		<description><![CDATA[<p>事情是这样的，</p>
<p>那是1998年，互联网经济爆发的年代。我22岁，是一名自由职业的程序员，在纽约从事网站开发。第一个客户我收了他1400美元，第二个客户给了我5400美元。之后的一笔收入是2万4千美元。我清清楚楚的记得这些数字——这是我当时见过的最大面额的支票。</p>
<p>然后我写了一份价值34万美元的方案来帮助一个在线零售商改进他们的网站。当时我和5个全职的程序员一起干(全在我家工作)，这也是不小的开销。客户同意了这个方案，但他们要求我签一份合同——一切看来都很正常。</p>
<p>没问题。我把合同发给了我的律师。她做了些修改，然后发给了客户。然后客户又做了些修改，发回我的律师。这样来来回回，大概进行了一个月。我毫无经验，以为做生意就是这样。</p>
<p>不堪我合同条文上的折腾，客户最终放弃了我，采用了其他人的方案。</p>
<p>该死。</p>
<p>但是我很幸运，另外一个大客户来敲门了。一个世界500强的大公司需要一个电子商务网站。我写了一个400万美元的方案(哇塞，这互联网经济繁荣的日子…)。客户接受了，并给了我一份合同让我签署。</p>
<p>这回，我没有把它发给我的律师，而是发给了我的老爸——他是一个老企业家。</p>
<p>“只管签，”老爸冷静的说。</p>
<p><span id="more-623"></span>“可是里面写着各种各样让人抓狂的条款！”我回复道。“上面说，如果事情办不好，我个人要承担法律责任的！上面说，如果逾期未完成，我要赔偿损失的！”等等。</p>
<p>“只管签，”他说。</p>
<p>“但是，如果出了什么意外了呢？？如果网站宕机了呢？如果我没有按时完工呢？如果…??”</p>
<p>“你觉得这些事情会发生吗？”他问。</p>
<p>“应该不会。但万一呢？”</p>
<p>“到时你知道该怎么做吗？”他说。“告诉他们，‘去告我吧。’”</p>
<p>老爸是对的。我接下来这个项目，他们付了款，事情很顺利，没有人被起诉。</p>
<p>之后有个时间，我需要雇一个全职的程序员。我很不安，因为我的积蓄只够支付他两个月的薪水，除非我能尽快的找到下一个客户。</p>
<p>“两个月后再考虑这个问题，”老爸说。</p>
<p>他已经为我工作好几年了。</p>
<p>这种完全不考虑风险的做法让我受益不少。人们说企业家就是探险者。我觉得我是太懒、太大意，没有去全面的了解这种风险。</p>
<p>我喜欢这种行事风格。</p>
<p>我不知道这能给你们什么启示。</p>
<p>转自: http://www.aqee.net/fucking-sue-me/</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/572.html' rel='bookmark' title='Permanent Link: Groupon团购网站启示录'>Groupon团购网站启示录</a></li>
<li><a href='http://www.ideawu.net/blog/archives/523.html' rel='bookmark' title='Permanent Link: 他们为什么恨Twitter &#8211; Twitter四大原罪'>他们为什么恨Twitter &#8211; Twitter四大原罪</a></li>
<li><a href='http://www.ideawu.net/blog/archives/384.html' rel='bookmark' title='Permanent Link: 你所不知道的腾讯和马化腾'>你所不知道的腾讯和马化腾</a></li>
<li><a href='http://www.ideawu.net/blog/archives/294.html' rel='bookmark' title='Permanent Link: 今年IT相关的大学本科生就业形势非常好!'>今年IT相关的大学本科生就业形势非常好!</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/623.html" title="让他们来告我吧!">让他们来告我吧!</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>事情是这样的，</p>
<p>那是1998年，互联网经济爆发的年代。我22岁，是一名自由职业的程序员，在纽约从事网站开发。第一个客户我收了他1400美元，第二个客户给了我5400美元。之后的一笔收入是2万4千美元。我清清楚楚的记得这些数字——这是我当时见过的最大面额的支票。</p>
<p>然后我写了一份价值34万美元的方案来帮助一个在线零售商改进他们的网站。当时我和5个全职的程序员一起干(全在我家工作)，这也是不小的开销。客户同意了这个方案，但他们要求我签一份合同——一切看来都很正常。</p>
<p>没问题。我把合同发给了我的律师。她做了些修改，然后发给了客户。然后客户又做了些修改，发回我的律师。这样来来回回，大概进行了一个月。我毫无经验，以为做生意就是这样。</p>
<p>不堪我合同条文上的折腾，客户最终放弃了我，采用了其他人的方案。</p>
<p>该死。</p>
<p>但是我很幸运，另外一个大客户来敲门了。一个世界500强的大公司需要一个电子商务网站。我写了一个400万美元的方案(哇塞，这互联网经济繁荣的日子…)。客户接受了，并给了我一份合同让我签署。</p>
<p>这回，我没有把它发给我的律师，而是发给了我的老爸——他是一个老企业家。</p>
<p>“只管签，”老爸冷静的说。</p>
<p><span id="more-623"></span>“可是里面写着各种各样让人抓狂的条款！”我回复道。“上面说，如果事情办不好，我个人要承担法律责任的！上面说，如果逾期未完成，我要赔偿损失的！”等等。</p>
<p>“只管签，”他说。</p>
<p>“但是，如果出了什么意外了呢？？如果网站宕机了呢？如果我没有按时完工呢？如果…??”</p>
<p>“你觉得这些事情会发生吗？”他问。</p>
<p>“应该不会。但万一呢？”</p>
<p>“到时你知道该怎么做吗？”他说。“告诉他们，‘去告我吧。’”</p>
<p>老爸是对的。我接下来这个项目，他们付了款，事情很顺利，没有人被起诉。</p>
<p>之后有个时间，我需要雇一个全职的程序员。我很不安，因为我的积蓄只够支付他两个月的薪水，除非我能尽快的找到下一个客户。</p>
<p>“两个月后再考虑这个问题，”老爸说。</p>
<p>他已经为我工作好几年了。</p>
<p>这种完全不考虑风险的做法让我受益不少。人们说企业家就是探险者。我觉得我是太懒、太大意，没有去全面的了解这种风险。</p>
<p>我喜欢这种行事风格。</p>
<p>我不知道这能给你们什么启示。</p>
<p>转自: http://www.aqee.net/fucking-sue-me/</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/572.html' rel='bookmark' title='Permanent Link: Groupon团购网站启示录'>Groupon团购网站启示录</a></li>
<li><a href='http://www.ideawu.net/blog/archives/523.html' rel='bookmark' title='Permanent Link: 他们为什么恨Twitter &#8211; Twitter四大原罪'>他们为什么恨Twitter &#8211; Twitter四大原罪</a></li>
<li><a href='http://www.ideawu.net/blog/archives/384.html' rel='bookmark' title='Permanent Link: 你所不知道的腾讯和马化腾'>你所不知道的腾讯和马化腾</a></li>
<li><a href='http://www.ideawu.net/blog/archives/294.html' rel='bookmark' title='Permanent Link: 今年IT相关的大学本科生就业形势非常好!'>今年IT相关的大学本科生就业形势非常好!</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/623.html" title="让他们来告我吧!">让他们来告我吧!</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/623.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP重用curl句柄, CURLOPT_HTTPGET的BUG</title>
		<link>http://www.ideawu.net/blog/archives/622.html</link>
		<comments>http://www.ideawu.net/blog/archives/622.html#comments</comments>
		<pubDate>Wed, 12 Oct 2011 10:55:51 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/2011/10/php%e9%87%8d%e7%94%a8curl%e5%8f%a5%e6%9f%84-curlopt_httpget%e7%9a%84bug.html</guid>
		<description><![CDATA[<p>重用一个CURL句柄时, 发现curl_setopt($ch, CURLOPT_HTTPGET, TRUE) 不起作用. 期望在调用这条语句之后发起请求, 应该发送的是GET, 但看服务器log, 却使用了和前一次请求相同的HTTP方法.</p>
<p>PHP脚本:</p>
<pre>
&lt;?php
$url = 'http://www.ideawu.net/';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_exec($ch);

curl_setopt($ch, CURLOPT_HTTPGET, true); // 错误! BUG
curl_exec($ch);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); // 正确
curl_exec($ch);
?&gt;
</pre>
<p>web server log:</p>
<pre>
124.127.130.50 "2011-10-12 18:55:09" "POST / HTTP/1.1" 200 3516 "-" www.ideawu.net
124.127.130.50 "2011-10-12 18:55:09" "POST / HTTP/1.1" 200 3516 "-" www.ideawu.net
124.127.130.50 "2011-10-12 18:55:09" "GET / HTTP/1.1" 200 3516 "-" www.ideawu.net
</pre>
<p>这个BUG目前还没找到相关的资料.</p>
<p><b>补充: 不仅仅是CURLOPT_HTTPGET, CURLOPT_POST也有同样的问题. 所以, 结论是: 只有CURLOPT_CUSTOMREQUEST才是正确的方法.</b></p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/517.html' rel='bookmark' title='Permanent Link: HTTP POST using PHP cURL'>HTTP POST using PHP cURL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/556.html' rel='bookmark' title='Permanent Link: lighttpd配置HTTPS(SSL)'>lighttpd配置HTTPS(SSL)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/410.html' rel='bookmark' title='Permanent Link: PHP字符串==比较的副作用'>PHP字符串==比较的副作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/114.html' rel='bookmark' title='Permanent Link: 艾薇儿Avril Lavigne的照片'>艾薇儿Avril Lavigne的照片</a></li>
<li><a href='http://www.ideawu.net/blog/archives/376.html' rel='bookmark' title='Permanent Link: 使用i_am_not_spam Wordpress插件'>使用i_am_not_spam Wordpress插件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/622.html" title="PHP重用curl句柄, CURLOPT_HTTPGET的BUG">PHP重用curl句柄, CURLOPT_HTTPGET的BUG</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>重用一个CURL句柄时, 发现curl_setopt($ch, CURLOPT_HTTPGET, TRUE) 不起作用. 期望在调用这条语句之后发起请求, 应该发送的是GET, 但看服务器log, 却使用了和前一次请求相同的HTTP方法.</p>
<p>PHP脚本:</p>
<pre>
&lt;?php
$url = 'http://www.ideawu.net/';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_exec($ch);

curl_setopt($ch, CURLOPT_HTTPGET, true); // 错误! BUG
curl_exec($ch);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); // 正确
curl_exec($ch);
?&gt;
</pre>
<p>web server log:</p>
<pre>
124.127.130.50 "2011-10-12 18:55:09" "POST / HTTP/1.1" 200 3516 "-" www.ideawu.net
124.127.130.50 "2011-10-12 18:55:09" "POST / HTTP/1.1" 200 3516 "-" www.ideawu.net
124.127.130.50 "2011-10-12 18:55:09" "GET / HTTP/1.1" 200 3516 "-" www.ideawu.net
</pre>
<p>这个BUG目前还没找到相关的资料.</p>
<p><b>补充: 不仅仅是CURLOPT_HTTPGET, CURLOPT_POST也有同样的问题. 所以, 结论是: 只有CURLOPT_CUSTOMREQUEST才是正确的方法.</b></p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/517.html' rel='bookmark' title='Permanent Link: HTTP POST using PHP cURL'>HTTP POST using PHP cURL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/556.html' rel='bookmark' title='Permanent Link: lighttpd配置HTTPS(SSL)'>lighttpd配置HTTPS(SSL)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/410.html' rel='bookmark' title='Permanent Link: PHP字符串==比较的副作用'>PHP字符串==比较的副作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/114.html' rel='bookmark' title='Permanent Link: 艾薇儿Avril Lavigne的照片'>艾薇儿Avril Lavigne的照片</a></li>
<li><a href='http://www.ideawu.net/blog/archives/376.html' rel='bookmark' title='Permanent Link: 使用i_am_not_spam Wordpress插件'>使用i_am_not_spam Wordpress插件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/622.html" title="PHP重用curl句柄, CURLOPT_HTTPGET的BUG">PHP重用curl句柄, CURLOPT_HTTPGET的BUG</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/622.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell循环</title>
		<link>http://www.ideawu.net/blog/archives/621.html</link>
		<comments>http://www.ideawu.net/blog/archives/621.html#comments</comments>
		<pubDate>Fri, 30 Sep 2011 04:14:11 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/2011/09/shell%e5%be%aa%e7%8e%af.html</guid>
		<description><![CDATA[<p>做个笔记:</p>
<p>SHELL循环:</p>
<p>1. while<br />
i=0; while [ $i -lt 10 ]; do echo $i; i=$(($i+1)); done</p>
<p>2. for<br />
for ((i=1; i<=10; i++)); do echo $i; done</p>
<p>3. while<br />
cat file.txt | while read line; do echo $line; done<br />
while read line; do echo $line; done < file.txt</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/518.html' rel='bookmark' title='Permanent Link: if-else对优化代码冗余度的反作用'>if-else对优化代码冗余度的反作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/619.html' rel='bookmark' title='Permanent Link: PHP浮点数显示和转成字符串'>PHP浮点数显示和转成字符串</a></li>
<li><a href='http://www.ideawu.net/blog/archives/367.html' rel='bookmark' title='Permanent Link: Wordpress分页代码'>Wordpress分页代码</a></li>
<li><a href='http://www.ideawu.net/blog/archives/464.html' rel='bookmark' title='Permanent Link: 用PHP去除重复图片文件'>用PHP去除重复图片文件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/621.html" title="Shell循环">Shell循环</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>做个笔记:</p>
<p>SHELL循环:</p>
<p>1. while<br />
i=0; while [ $i -lt 10 ]; do echo $i; i=$(($i+1)); done</p>
<p>2. for<br />
for ((i=1; i<=10; i++)); do echo $i; done</p>
<p>3. while<br />
cat file.txt | while read line; do echo $line; done<br />
while read line; do echo $line; done < file.txt</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/518.html' rel='bookmark' title='Permanent Link: if-else对优化代码冗余度的反作用'>if-else对优化代码冗余度的反作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/619.html' rel='bookmark' title='Permanent Link: PHP浮点数显示和转成字符串'>PHP浮点数显示和转成字符串</a></li>
<li><a href='http://www.ideawu.net/blog/archives/367.html' rel='bookmark' title='Permanent Link: Wordpress分页代码'>Wordpress分页代码</a></li>
<li><a href='http://www.ideawu.net/blog/archives/464.html' rel='bookmark' title='Permanent Link: 用PHP去除重复图片文件'>用PHP去除重复图片文件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/621.html" title="Shell循环">Shell循环</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/621.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linode日本东京机房速度飞快</title>
		<link>http://www.ideawu.net/blog/archives/620.html</link>
		<comments>http://www.ideawu.net/blog/archives/620.html#comments</comments>
		<pubDate>Tue, 27 Sep 2011 16:18:54 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[IT技术和评论]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=620</guid>
		<description><![CDATA[<p>为了应对亚太地区快速增长的需求, <a href="http://www.linode.com/?r=cdac879712675bce943d61e99e1f8ea81b6b3e33">Linode</a> 开始把机房建在亚洲了! 第一个 Linode 亚洲机房<a href="http://blog.linode.com/2011/09/19/linode-cloud-asia-pacific/">选择在日本东京</a>.</p>
<p>我测了下, 速度比原来在美国加州快多了, 应该主要得益于网络延时的减少. 所以, 我立即开了张 Support Ticket 将我的 VPS 迁到了日本. 迁完之后, 访问速度飞快! 和原来在国内某机房没有感觉上的区别.</p>
<p>大家可以反馈下你访问的速度是否有提升?</p>
<p>注: Linode VPS 是完整的 VPS, 一年的费用在人民币一千五左右, 可以月付, 建议选择年付(可优惠10%). <a href="http://www.linode.com/?r=cdac879712675bce943d61e99e1f8ea81b6b3e33">看看去&#8230;</a></p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/459.html' rel='bookmark' title='Permanent Link: IT牛人博客聚合和Linode虚拟主机'>IT牛人博客聚合和Linode虚拟主机</a></li>
<li><a href='http://www.ideawu.net/blog/archives/476.html' rel='bookmark' title='Permanent Link: Linode虚拟主机Linux安全第一步'>Linode虚拟主机Linux安全第一步</a></li>
<li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/493.html' rel='bookmark' title='Permanent Link: 程序员的投资和理财之道'>程序员的投资和理财之道</a></li>
<li><a href='http://www.ideawu.net/blog/archives/422.html' rel='bookmark' title='Permanent Link: 炮轰IT写书神棍 &#8211; 由炮轰JavaScript征途有感而发'>炮轰IT写书神棍 &#8211; 由炮轰JavaScript征途有感而发</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/620.html" title="Linode日本东京机房速度飞快">Linode日本东京机房速度飞快</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>为了应对亚太地区快速增长的需求, <a href="http://www.linode.com/?r=cdac879712675bce943d61e99e1f8ea81b6b3e33">Linode</a> 开始把机房建在亚洲了! 第一个 Linode 亚洲机房<a href="http://blog.linode.com/2011/09/19/linode-cloud-asia-pacific/">选择在日本东京</a>.</p>
<p>我测了下, 速度比原来在美国加州快多了, 应该主要得益于网络延时的减少. 所以, 我立即开了张 Support Ticket 将我的 VPS 迁到了日本. 迁完之后, 访问速度飞快! 和原来在国内某机房没有感觉上的区别.</p>
<p>大家可以反馈下你访问的速度是否有提升?</p>
<p>注: Linode VPS 是完整的 VPS, 一年的费用在人民币一千五左右, 可以月付, 建议选择年付(可优惠10%). <a href="http://www.linode.com/?r=cdac879712675bce943d61e99e1f8ea81b6b3e33">看看去&#8230;</a></p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/459.html' rel='bookmark' title='Permanent Link: IT牛人博客聚合和Linode虚拟主机'>IT牛人博客聚合和Linode虚拟主机</a></li>
<li><a href='http://www.ideawu.net/blog/archives/476.html' rel='bookmark' title='Permanent Link: Linode虚拟主机Linux安全第一步'>Linode虚拟主机Linux安全第一步</a></li>
<li><a href='http://www.ideawu.net/blog/archives/585.html' rel='bookmark' title='Permanent Link: 史上最强大的PHP Web面试题(会做就能进百度)'>史上最强大的PHP Web面试题(会做就能进百度)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/493.html' rel='bookmark' title='Permanent Link: 程序员的投资和理财之道'>程序员的投资和理财之道</a></li>
<li><a href='http://www.ideawu.net/blog/archives/422.html' rel='bookmark' title='Permanent Link: 炮轰IT写书神棍 &#8211; 由炮轰JavaScript征途有感而发'>炮轰IT写书神棍 &#8211; 由炮轰JavaScript征途有感而发</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/620.html" title="Linode日本东京机房速度飞快">Linode日本东京机房速度飞快</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/620.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP浮点数显示和转成字符串</title>
		<link>http://www.ideawu.net/blog/archives/619.html</link>
		<comments>http://www.ideawu.net/blog/archives/619.html#comments</comments>
		<pubDate>Fri, 09 Sep 2011 03:33:47 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/2011/09/php%e6%b5%ae%e7%82%b9%e6%95%b0%e6%98%be%e7%a4%ba%e5%92%8c%e8%bd%ac%e6%88%90%e5%ad%97%e7%ac%a6%e4%b8%b2.html</guid>
		<description><![CDATA[<p>你可能会觉得PHP中将浮点数(float)转成字符串非常简单, 但是, 常用的方法隐藏着严重的bug. 因为, PHP在处理浮点数时有非常不合理的做法, 会有精度丢失. 经研究, 其实是PHP在显示浮点数时的问题, 也可以说是BUG. PHP内置的echo, var_dump, json_encode, 字符串拼接等函数(指令)在显示浮点数时都有问题, 导致精度丢失.</p>
<pre>
&lt;?php
$a = 1315537636.338467;
printf("%f", $a); echo "\n";
echo $a . "\n";
echo $a; echo "\n";
</pre>
<p>结果</p>
<pre>
1315537636.338467
1315537636.3385
1315537636.3385
</pre>
<p>也就是说, 用PHP最顺手的方法将浮点数转成字符串或者显示是不行的, 必须使用printf/sprintf将浮点数转成字符串.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/518.html' rel='bookmark' title='Permanent Link: if-else对优化代码冗余度的反作用'>if-else对优化代码冗余度的反作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/468.html' rel='bookmark' title='Permanent Link: 后端开发工程师的DIV+CSS两栏布局入门'>后端开发工程师的DIV+CSS两栏布局入门</a></li>
<li><a href='http://www.ideawu.net/blog/archives/582.html' rel='bookmark' title='Permanent Link: PHP的continue 2'>PHP的continue 2</a></li>
<li><a href='http://www.ideawu.net/blog/archives/367.html' rel='bookmark' title='Permanent Link: Wordpress分页代码'>Wordpress分页代码</a></li>
<li><a href='http://www.ideawu.net/blog/archives/464.html' rel='bookmark' title='Permanent Link: 用PHP去除重复图片文件'>用PHP去除重复图片文件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/619.html" title="PHP浮点数显示和转成字符串">PHP浮点数显示和转成字符串</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>你可能会觉得PHP中将浮点数(float)转成字符串非常简单, 但是, 常用的方法隐藏着严重的bug. 因为, PHP在处理浮点数时有非常不合理的做法, 会有精度丢失. 经研究, 其实是PHP在显示浮点数时的问题, 也可以说是BUG. PHP内置的echo, var_dump, json_encode, 字符串拼接等函数(指令)在显示浮点数时都有问题, 导致精度丢失.</p>
<pre>
&lt;?php
$a = 1315537636.338467;
printf("%f", $a); echo "\n";
echo $a . "\n";
echo $a; echo "\n";
</pre>
<p>结果</p>
<pre>
1315537636.338467
1315537636.3385
1315537636.3385
</pre>
<p>也就是说, 用PHP最顺手的方法将浮点数转成字符串或者显示是不行的, 必须使用printf/sprintf将浮点数转成字符串.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/518.html' rel='bookmark' title='Permanent Link: if-else对优化代码冗余度的反作用'>if-else对优化代码冗余度的反作用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/468.html' rel='bookmark' title='Permanent Link: 后端开发工程师的DIV+CSS两栏布局入门'>后端开发工程师的DIV+CSS两栏布局入门</a></li>
<li><a href='http://www.ideawu.net/blog/archives/582.html' rel='bookmark' title='Permanent Link: PHP的continue 2'>PHP的continue 2</a></li>
<li><a href='http://www.ideawu.net/blog/archives/367.html' rel='bookmark' title='Permanent Link: Wordpress分页代码'>Wordpress分页代码</a></li>
<li><a href='http://www.ideawu.net/blog/archives/464.html' rel='bookmark' title='Permanent Link: 用PHP去除重复图片文件'>用PHP去除重复图片文件</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/619.html" title="PHP浮点数显示和转成字符串">PHP浮点数显示和转成字符串</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/619.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache用mod_rewrite配置子域名</title>
		<link>http://www.ideawu.net/blog/archives/618.html</link>
		<comments>http://www.ideawu.net/blog/archives/618.html#comments</comments>
		<pubDate>Sun, 04 Sep 2011 14:26:02 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/2011/09/apache%e7%94%a8mod_rewrite%e9%85%8d%e7%bd%ae%e5%ad%90%e5%9f%9f%e5%90%8d.html</guid>
		<description><![CDATA[<p>虽然用vhost可以支持子域名, 但不方便.</p>
<pre>
RewriteCond $1 !^bbs/
RewriteCond %{HTTP_HOST} bbs.example.com
RewriteRule (.*) /bbs/$1 [L]
</pre>
<p>RewriteCond $1 !^bbs/ 避免内部无限redirect.</p>
<p><span id="more-618"></span><del datetime="2011-09-04T16:16:59+00:00">或者支持无限子域名:</del></p>
<pre>
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1/$1 [E=Rewrite-Done:Yes,L]
</pre>
<p>注: Apache mod_rewrite 有一个严重的BUG, 无法获取自己设置的环境变量. 所以上面的代码有问题! 所以还是半自动:</p>
<pre>
RewriteCond $1 !^bbs/
RewriteCond $1 !^OTHER_SUBDOMAIN/
......
# BUG: RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1/$1 [E=Rewrite-Done:Yes,L]
</pre>
<p><strong>补充</strong>: <a href="http://xiaobin.net/201109/apache-mapping-subdomain-to-subdir-with-mod_vhost_alias/">xiaobin</a> 提到可以使用 vhost_alias 模块. 我在他的基础之上做了改进, 结合 mod_rewrite, 可以更好的兼容www子域:</p>
<pre>
&lt;VirtualHost *:80&gt;
	ServerAlias ideawu.net *.ideawu.net
	VirtualDocumentRoot /home/work/htdocs/ideawu.net/%1

	RewriteEngine On
	RewriteCond %{HTTP_HOST} ^ideawu.net$
	RewriteRule /(.*) http://www.ideawu.net/$1 [R=301,L]
&lt;/VirtualHost&gt;
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/494.html' rel='bookmark' title='Permanent Link: 链接包含&#8221;%2F&#8221;导致mod_rewrite失效'>链接包含&#8221;%2F&#8221;导致mod_rewrite失效</a></li>
<li><a href='http://www.ideawu.net/blog/archives/556.html' rel='bookmark' title='Permanent Link: lighttpd配置HTTPS(SSL)'>lighttpd配置HTTPS(SSL)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/169.html' rel='bookmark' title='Permanent Link: Tomcat网站server.xml设置'>Tomcat网站server.xml设置</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/618.html" title="Apache用mod_rewrite配置子域名">Apache用mod_rewrite配置子域名</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>虽然用vhost可以支持子域名, 但不方便.</p>
<pre>
RewriteCond $1 !^bbs/
RewriteCond %{HTTP_HOST} bbs.example.com
RewriteRule (.*) /bbs/$1 [L]
</pre>
<p>RewriteCond $1 !^bbs/ 避免内部无限redirect.</p>
<p><span id="more-618"></span><del datetime="2011-09-04T16:16:59+00:00">或者支持无限子域名:</del></p>
<pre>
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1/$1 [E=Rewrite-Done:Yes,L]
</pre>
<p>注: Apache mod_rewrite 有一个严重的BUG, 无法获取自己设置的环境变量. 所以上面的代码有问题! 所以还是半自动:</p>
<pre>
RewriteCond $1 !^bbs/
RewriteCond $1 !^OTHER_SUBDOMAIN/
......
# BUG: RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule (.*) /%1/$1 [E=Rewrite-Done:Yes,L]
</pre>
<p><strong>补充</strong>: <a href="http://xiaobin.net/201109/apache-mapping-subdomain-to-subdir-with-mod_vhost_alias/">xiaobin</a> 提到可以使用 vhost_alias 模块. 我在他的基础之上做了改进, 结合 mod_rewrite, 可以更好的兼容www子域:</p>
<pre>
&lt;VirtualHost *:80&gt;
	ServerAlias ideawu.net *.ideawu.net
	VirtualDocumentRoot /home/work/htdocs/ideawu.net/%1

	RewriteEngine On
	RewriteCond %{HTTP_HOST} ^ideawu.net$
	RewriteRule /(.*) http://www.ideawu.net/$1 [R=301,L]
&lt;/VirtualHost&gt;
</pre>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/447.html' rel='bookmark' title='Permanent Link: Linux下编译安装Apache/Lighttpd+PHP+MySQL'>Linux下编译安装Apache/Lighttpd+PHP+MySQL</a></li>
<li><a href='http://www.ideawu.net/blog/archives/494.html' rel='bookmark' title='Permanent Link: 链接包含&#8221;%2F&#8221;导致mod_rewrite失效'>链接包含&#8221;%2F&#8221;导致mod_rewrite失效</a></li>
<li><a href='http://www.ideawu.net/blog/archives/556.html' rel='bookmark' title='Permanent Link: lighttpd配置HTTPS(SSL)'>lighttpd配置HTTPS(SSL)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/169.html' rel='bookmark' title='Permanent Link: Tomcat网站server.xml设置'>Tomcat网站server.xml设置</a></li>
<li><a href='http://www.ideawu.net/blog/archives/637.html' rel='bookmark' title='Permanent Link: Nginx + PHP 配置和启动脚本'>Nginx + PHP 配置和启动脚本</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/618.html" title="Apache用mod_rewrite配置子域名">Apache用mod_rewrite配置子域名</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/618.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>云计算不靠谱?</title>
		<link>http://www.ideawu.net/blog/archives/615.html</link>
		<comments>http://www.ideawu.net/blog/archives/615.html#comments</comments>
		<pubDate>Sun, 07 Aug 2011 12:57:17 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[IT技术和评论]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=615</guid>
		<description><![CDATA[<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2011/08/dark-clouds-200x133.jpg" alt="" title="dark-clouds" width="200" height="133" class="alignright size-thumbnail wp-image-616" /></p>
<p>最近, 两大知名的社交游戏厂商, Zynga 和 Digital Chocolate 开始建造自己的服务器硬件环境(IDC)了. 之前, 这两家公司完全使用的是 Amazon 的 AWS 云计算服务. 也就是说, 虽然他们从创业到发展壮大, 却从来不知道也不用关心自己所用的服务器和机房是什么样子. 但是, 现在他们开始控制这部分的内容了, 比如Zynga 建造自己了云计算环境.</p>
<p>这似乎就是云计算服务的作用, 它可以帮助你创业时减少支基础计算能力的考虑, 关注于自己的服务更好的服务于用户. 但一旦发展壮大, 就要把云给踢开了.</p>
<p>不过, 在中国创业初期连这个选择都没有, 必须一开始就要被服务器购买, IDC 机架位租用, 操作系统和软件(如 LAMP)安装等烦恼, 更困难的还是在与管理部门打交道, 耗费大量精力.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/476.html' rel='bookmark' title='Permanent Link: Linode虚拟主机Linux安全第一步'>Linode虚拟主机Linux安全第一步</a></li>
<li><a href='http://www.ideawu.net/blog/archives/630.html' rel='bookmark' title='Permanent Link: 给笔记本装SSD硬盘'>给笔记本装SSD硬盘</a></li>
<li><a href='http://www.ideawu.net/blog/archives/588.html' rel='bookmark' title='Permanent Link: 面试IT业界顶尖企业所应该知道的10道题(2)'>面试IT业界顶尖企业所应该知道的10道题(2)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/506.html' rel='bookmark' title='Permanent Link: IT员工无前途, 何不跳槽, 而要跳楼?'>IT员工无前途, 何不跳槽, 而要跳楼?</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/615.html" title="云计算不靠谱?">云计算不靠谱?</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2011/08/dark-clouds-200x133.jpg" alt="" title="dark-clouds" width="200" height="133" class="alignright size-thumbnail wp-image-616" /></p>
<p>最近, 两大知名的社交游戏厂商, Zynga 和 Digital Chocolate 开始建造自己的服务器硬件环境(IDC)了. 之前, 这两家公司完全使用的是 Amazon 的 AWS 云计算服务. 也就是说, 虽然他们从创业到发展壮大, 却从来不知道也不用关心自己所用的服务器和机房是什么样子. 但是, 现在他们开始控制这部分的内容了, 比如Zynga 建造自己了云计算环境.</p>
<p>这似乎就是云计算服务的作用, 它可以帮助你创业时减少支基础计算能力的考虑, 关注于自己的服务更好的服务于用户. 但一旦发展壮大, 就要把云给踢开了.</p>
<p>不过, 在中国创业初期连这个选择都没有, 必须一开始就要被服务器购买, IDC 机架位租用, 操作系统和软件(如 LAMP)安装等烦恼, 更困难的还是在与管理部门打交道, 耗费大量精力.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/476.html' rel='bookmark' title='Permanent Link: Linode虚拟主机Linux安全第一步'>Linode虚拟主机Linux安全第一步</a></li>
<li><a href='http://www.ideawu.net/blog/archives/630.html' rel='bookmark' title='Permanent Link: 给笔记本装SSD硬盘'>给笔记本装SSD硬盘</a></li>
<li><a href='http://www.ideawu.net/blog/archives/588.html' rel='bookmark' title='Permanent Link: 面试IT业界顶尖企业所应该知道的10道题(2)'>面试IT业界顶尖企业所应该知道的10道题(2)</a></li>
<li><a href='http://www.ideawu.net/blog/archives/506.html' rel='bookmark' title='Permanent Link: IT员工无前途, 何不跳槽, 而要跳楼?'>IT员工无前途, 何不跳槽, 而要跳楼?</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/615.html" title="云计算不靠谱?">云计算不靠谱?</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/615.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fn和CTRL的故事</title>
		<link>http://www.ideawu.net/blog/archives/614.html</link>
		<comments>http://www.ideawu.net/blog/archives/614.html#comments</comments>
		<pubDate>Fri, 05 Aug 2011 14:55:50 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Computer System]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/2011/08/fn%e5%92%8cctrl%e7%9a%84%e6%95%85%e4%ba%8b.html</guid>
		<description><![CDATA[<p>从前, 键盘工程师新创造了一个叫&#8221;Fn&#8221;的人造人, 想把它加入到键盘按键的队伍里. 工程师想, 它是一个革命性的产品, 因为, 它功能强大, 这从它的名字就能看出它的工程师老母对它的期望. 它可以帮忙打开键盘灯, 这样, 在黑暗中你也可以使用笔记本电脑. 它还可以帮忙调整屏幕亮度, 调整音量, 真是一个强大贴心的助手. 所以, 工程师决定把它放到了原来一个叫&#8221;CTRL&#8221;的人的位置, 把CTRL排挤到了一边. 那是键盘上最左下角的地方, 也是手指流量最密集的地方.</p>
<p>但是, Fn并不受欢迎, 因为没有人经常需要, 没有人天天不停地打开和关闭键盘灯, 即使好几年下来有一天遇到了, 先开灯或者在进入黑暗之前打开键盘灯也很正常.</p>
<p>相反, 人们怀念CTRL, 因为人们每天要把手指放在CTRL上面上千遍:</p>
<p>CTRL + C: 复制<br />
CTRL + V: 粘贴<br />
CTRL + S: 保存<br />
CTRL + A: 全选<br />
CTRL + X: 剪切<br />
CTRL + W: 关闭窗口<br />
CTRL + T: 打开浏览器标签<br />
CTRL + 空格: 切换输入法</p>
<p>对比Fn, Fn用不了一两回. 因为那些自以为是很内裤的功能, 其实都是和硬件有关, 根本就不常用到. 比如谁会没事按Fn让自己的键盘灯一亮一灭的, 或者没完没了地调整屏幕亮度和音量, 他有病啊!</p>
<p>大部分的电脑厂商都明白了这个道理, 绝情地把Fn赶走了, 重新迎回CTRL. 但是, 有一个叫IBM的巨人和它的买主还是坚持迂腐, 感情上不愿意把CTRL接回来, 最终决定帮人在BIOS里偷偷给Fn和CTRL换了衣服.</p>
<p>Fn垂头丧气, 成了不受欢迎的失败产品. 现在, 它在寻找一个最不起眼的角落, 想静地躺在那里, 不要像以前那么招摇.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/512.html' rel='bookmark' title='Permanent Link: screen 命令使用'>screen 命令使用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/42.html' rel='bookmark' title='Permanent Link: Linux不是Windows'>Linux不是Windows</a></li>
<li><a href='http://www.ideawu.net/blog/archives/606.html' rel='bookmark' title='Permanent Link: 关系数据库应用设计基础'>关系数据库应用设计基础</a></li>
<li><a href='http://www.ideawu.net/blog/archives/391.html' rel='bookmark' title='Permanent Link: 一对多关系的不稳定性'>一对多关系的不稳定性</a></li>
<li><a href='http://www.ideawu.net/blog/archives/329.html' rel='bookmark' title='Permanent Link: 一种有趣的编程模型'>一种有趣的编程模型</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/614.html" title="Fn和CTRL的故事">Fn和CTRL的故事</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>从前, 键盘工程师新创造了一个叫&#8221;Fn&#8221;的人造人, 想把它加入到键盘按键的队伍里. 工程师想, 它是一个革命性的产品, 因为, 它功能强大, 这从它的名字就能看出它的工程师老母对它的期望. 它可以帮忙打开键盘灯, 这样, 在黑暗中你也可以使用笔记本电脑. 它还可以帮忙调整屏幕亮度, 调整音量, 真是一个强大贴心的助手. 所以, 工程师决定把它放到了原来一个叫&#8221;CTRL&#8221;的人的位置, 把CTRL排挤到了一边. 那是键盘上最左下角的地方, 也是手指流量最密集的地方.</p>
<p>但是, Fn并不受欢迎, 因为没有人经常需要, 没有人天天不停地打开和关闭键盘灯, 即使好几年下来有一天遇到了, 先开灯或者在进入黑暗之前打开键盘灯也很正常.</p>
<p>相反, 人们怀念CTRL, 因为人们每天要把手指放在CTRL上面上千遍:</p>
<p>CTRL + C: 复制<br />
CTRL + V: 粘贴<br />
CTRL + S: 保存<br />
CTRL + A: 全选<br />
CTRL + X: 剪切<br />
CTRL + W: 关闭窗口<br />
CTRL + T: 打开浏览器标签<br />
CTRL + 空格: 切换输入法</p>
<p>对比Fn, Fn用不了一两回. 因为那些自以为是很内裤的功能, 其实都是和硬件有关, 根本就不常用到. 比如谁会没事按Fn让自己的键盘灯一亮一灭的, 或者没完没了地调整屏幕亮度和音量, 他有病啊!</p>
<p>大部分的电脑厂商都明白了这个道理, 绝情地把Fn赶走了, 重新迎回CTRL. 但是, 有一个叫IBM的巨人和它的买主还是坚持迂腐, 感情上不愿意把CTRL接回来, 最终决定帮人在BIOS里偷偷给Fn和CTRL换了衣服.</p>
<p>Fn垂头丧气, 成了不受欢迎的失败产品. 现在, 它在寻找一个最不起眼的角落, 想静地躺在那里, 不要像以前那么招摇.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/512.html' rel='bookmark' title='Permanent Link: screen 命令使用'>screen 命令使用</a></li>
<li><a href='http://www.ideawu.net/blog/archives/42.html' rel='bookmark' title='Permanent Link: Linux不是Windows'>Linux不是Windows</a></li>
<li><a href='http://www.ideawu.net/blog/archives/606.html' rel='bookmark' title='Permanent Link: 关系数据库应用设计基础'>关系数据库应用设计基础</a></li>
<li><a href='http://www.ideawu.net/blog/archives/391.html' rel='bookmark' title='Permanent Link: 一对多关系的不稳定性'>一对多关系的不稳定性</a></li>
<li><a href='http://www.ideawu.net/blog/archives/329.html' rel='bookmark' title='Permanent Link: 一种有趣的编程模型'>一种有趣的编程模型</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/614.html" title="Fn和CTRL的故事">Fn和CTRL的故事</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/614.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>强大的纯JS数据图工具-flot</title>
		<link>http://www.ideawu.net/blog/archives/611.html</link>
		<comments>http://www.ideawu.net/blog/archives/611.html#comments</comments>
		<pubDate>Wed, 03 Aug 2011 17:03:09 +0000</pubDate>
		<dc:creator>ideawu</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[flot]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.ideawu.net/blog/?p=611</guid>
		<description><![CDATA[<p>发现一个在网页中绘制数据图, 如曲线图, 柱状图的纯 JavaScript 工具: <a href="http://code.google.com/p/flot/">flot</a>. 极度推荐啊! 有图和代码为证:</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2011/08/flot.png" alt="" title="flot" width="526" height="253" class="alignnone size-full wp-image-612" /></p>
<p>*代码附后*</p>
<p>以前知道的工具有 <a href="http://teethgrinder.co.uk/open-flash-chart/index.php">Open Flash Chart</a>, 还有 Google 出品的 <a href="http://code.google.com/apis/chart/">Google Chart Tool</a>. 两者使用不同的技术, 同时也是两种截然不同的设计理念. 相比较而言, 我更认同 Google Chart 的设计理念. 原因如下:</p>
<p><span id="more-611"></span>Open Flash Chart 使用 Flash 来做图, 这本来也可以接受. 但是, 图形的样式必须通过一个 URL 返回的数据来指定, 而不是网页端技术.</p>
<p>Google Chart Tool 使用 VML 来做图, 同时实现数据和表现的分离, 是 MVC 的思想. 这样的好处是, 同一份数据, 可以用来显示曲线图, 也可以显示成柱状图等等.</p>
<p>显而易见, Open Flash Chart 的技术和理念太陈旧了, 所以不推荐使用. 但是, Google Chart Tool 也有一个重大缺陷, 就是不能离线使用. 当网络状况不好时(在中国大陆经常遇到), 就没法使用了. Google 太霸道, 也不能用.</p>
<p>flot 也是 Google Chart Tool 类似的理念, 所以使用起来非常方便, 而且 demo 代码简单修改就能运行, 学习曲线非常轻松. 而且完美支持 IE6.</p>
<p>附一个可以运行的 flot 例子代码, 将下面的代码保存成 a.html, 然后到 flot 网站下载 JavaScript 代码, 保证路径正确即可用浏览器打开看效果.</p>
<pre>
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
	&lt;title&gt;flot&lt;/title&gt;
	&lt;!--[if lte IE 8]&gt;
		&lt;script language="javascript" type="text/javascript" src="excanvas.min.js"&gt;&lt;/script&gt;
	&lt;![endif]--&gt;
	&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="jquery.flot.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
var data = [];
data.push({
    "label": "中国",
    "data": [[2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1]]
});

$(function(){
    var options = {
        lines: { show: true },
        points: { show: true },
        xaxis: { tickDecimals: 0, tickSize: 1 }
    };
    var placeholder = $("#placeholder");
    $.plot(placeholder, data, options);
});
//--&gt;
&lt;/script&gt;

&lt;div id="placeholder" style="width:500px;height:240px"&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>flot 项目首页: <a href="http://code.google.com/p/flot/">http://code.google.com/p/flot/</a></p>
<p><strong>补充:</strong> 再推荐另外一个非常不错的工具 &#8211; <a href="http://www.highcharts.com/">Highcharts</a>, 看起来功能更强大, 但还没调研使用是否简便.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/399.html' rel='bookmark' title='Permanent Link: JavaScript+jQuery两栏选择控件'>JavaScript+jQuery两栏选择控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/434.html' rel='bookmark' title='Permanent Link: 最简单的JavaScript两级联动示例'>最简单的JavaScript两级联动示例</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
<li><a href='http://www.ideawu.net/blog/archives/412.html' rel='bookmark' title='Permanent Link: JavaScript分页控件'>JavaScript分页控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/542.html' rel='bookmark' title='Permanent Link: 以浏览器为核心的客户端软件的安全问题'>以浏览器为核心的客户端软件的安全问题</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/611.html" title="强大的纯JS数据图工具-flot">强大的纯JS数据图工具-flot</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></description>
			<content:encoded><![CDATA[<p>发现一个在网页中绘制数据图, 如曲线图, 柱状图的纯 JavaScript 工具: <a href="http://code.google.com/p/flot/">flot</a>. 极度推荐啊! 有图和代码为证:</p>
<p><img src="http://www.ideawu.net/blog/wp-content/uploads/2011/08/flot.png" alt="" title="flot" width="526" height="253" class="alignnone size-full wp-image-612" /></p>
<p>*代码附后*</p>
<p>以前知道的工具有 <a href="http://teethgrinder.co.uk/open-flash-chart/index.php">Open Flash Chart</a>, 还有 Google 出品的 <a href="http://code.google.com/apis/chart/">Google Chart Tool</a>. 两者使用不同的技术, 同时也是两种截然不同的设计理念. 相比较而言, 我更认同 Google Chart 的设计理念. 原因如下:</p>
<p><span id="more-611"></span>Open Flash Chart 使用 Flash 来做图, 这本来也可以接受. 但是, 图形的样式必须通过一个 URL 返回的数据来指定, 而不是网页端技术.</p>
<p>Google Chart Tool 使用 VML 来做图, 同时实现数据和表现的分离, 是 MVC 的思想. 这样的好处是, 同一份数据, 可以用来显示曲线图, 也可以显示成柱状图等等.</p>
<p>显而易见, Open Flash Chart 的技术和理念太陈旧了, 所以不推荐使用. 但是, Google Chart Tool 也有一个重大缺陷, 就是不能离线使用. 当网络状况不好时(在中国大陆经常遇到), 就没法使用了. Google 太霸道, 也不能用.</p>
<p>flot 也是 Google Chart Tool 类似的理念, 所以使用起来非常方便, 而且 demo 代码简单修改就能运行, 学习曲线非常轻松. 而且完美支持 IE6.</p>
<p>附一个可以运行的 flot 例子代码, 将下面的代码保存成 a.html, 然后到 flot 网站下载 JavaScript 代码, 保证路径正确即可用浏览器打开看效果.</p>
<pre>
&lt;html&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
	&lt;title&gt;flot&lt;/title&gt;
	&lt;!--[if lte IE 8]&gt;
		&lt;script language="javascript" type="text/javascript" src="excanvas.min.js"&gt;&lt;/script&gt;
	&lt;![endif]--&gt;
	&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="jquery.flot.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
var data = [];
data.push({
    "label": "中国",
    "data": [[2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1]]
});

$(function(){
    var options = {
        lines: { show: true },
        points: { show: true },
        xaxis: { tickDecimals: 0, tickSize: 1 }
    };
    var placeholder = $("#placeholder");
    $.plot(placeholder, data, options);
});
//--&gt;
&lt;/script&gt;

&lt;div id="placeholder" style="width:500px;height:240px"&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>flot 项目首页: <a href="http://code.google.com/p/flot/">http://code.google.com/p/flot/</a></p>
<p><strong>补充:</strong> 再推荐另外一个非常不错的工具 &#8211; <a href="http://www.highcharts.com/">Highcharts</a>, 看起来功能更强大, 但还没调研使用是否简便.</p>


<h3>Related posts:</h3><ol><li><a href='http://www.ideawu.net/blog/archives/399.html' rel='bookmark' title='Permanent Link: JavaScript+jQuery两栏选择控件'>JavaScript+jQuery两栏选择控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/434.html' rel='bookmark' title='Permanent Link: 最简单的JavaScript两级联动示例'>最简单的JavaScript两级联动示例</a></li>
<li><a href='http://www.ideawu.net/blog/archives/270.html' rel='bookmark' title='Permanent Link: 使用Python POST任意的HTTP数据以及使用Cookie'>使用Python POST任意的HTTP数据以及使用Cookie</a></li>
<li><a href='http://www.ideawu.net/blog/archives/412.html' rel='bookmark' title='Permanent Link: JavaScript分页控件'>JavaScript分页控件</a></li>
<li><a href='http://www.ideawu.net/blog/archives/542.html' rel='bookmark' title='Permanent Link: 以浏览器为核心的客户端软件的安全问题'>以浏览器为核心的客户端软件的安全问题</a></li>
</ol><div><p><img src="http://www.ideawu.net/favicon.ico" /> 你现在看的文章是: <a href="http://www.ideawu.net/blog/archives/611.html" title="强大的纯JS数据图工具-flot">强大的纯JS数据图工具-flot</a></p>

<div>
	<a href="http://www.benegg.com/linode-ad.php">
		Linode VPS - 美国虚拟主机
	</a>
	|
	<a href="http://www.udpwork.com/">
		IT牛人博客聚合网站
	</a>
</div></div>]]></content:encoded>
			<wfw:commentRss>http://www.ideawu.net/blog/archives/611.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

