<?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>Liu Zhongshu</title>
	<atom:link href="http://www.liuzhongshu.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.liuzhongshu.com</link>
	<description>开心工作，用心玩。</description>
	<lastBuildDate>Tue, 31 Aug 2010 06:21:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bookmarklet</title>
		<link>http://www.liuzhongshu.com/tech/bookmarklet.html</link>
		<comments>http://www.liuzhongshu.com/tech/bookmarklet.html#comments</comments>
		<pubDate>Tue, 24 Aug 2010 01:48:13 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/bookmarklet.html</guid>
		<description><![CDATA[Bookmarklet是那种可以像书签一样加入收藏夹，但又不仅只是跳转到某个网页，通常是具有某种“功能”的小程序片段，Wikipedia上给Bookmarklet有详细的定义。
一个具体的例子是Delicious的收藏按钮，它就是一个Bookmarklet，因为它在点击后会弹出一个对话框，并将输入的信息保存到Delicious书签中，Delicious网站也给出了各种浏览器下安装这个Bookmarklet的方法（其实大部分浏览器都很简单，将一个链接拖放到书签栏就好了）
http://www.delicious.com/help/bookmarklets
Bookmarklet与GMarks
除了一般浏览器的书签栏，如果使用一些浏览器的书签扩展插件，方法可能有所不同。比如GMarks（我在用的），要想添加Bookmarklet到GMarks，则需要在链接地址的前面加上一个空格，否则GMark会不认的 ; )
 
注意上面的javascript前面留了一个空格。
我在用的Bookmarklet
我在用的Bookmarklet并不多，分享一下，如果你有好的推荐，请留言告诉我。

BugMeNot的Bookmarklet：可以让你在一些需要登录的网站的地方，自动替你找到用户、密码并登录，对很多站不起作用，不过有些站点可用。
Readability的Bookmarket：自动让网页更易阅读的一个Bookmarklet。
Tineye的Bookmarklet：Tineye是一个图像搜索引擎，这个Bookmarklet可以自动以当前网页的图片作为源来搜索他们的来源。

如果你想要更多的Bookmarklet，这里有比较多的候选 ;)
]]></description>
			<content:encoded><![CDATA[<p>Bookmarklet是那种可以像书签一样加入收藏夹，但又不仅只是跳转到某个网页，通常是具有某种“功能”的小程序片段，Wikipedia上给<a href="http://en.wikipedia.org/wiki/Bookmarklet" target="_blank">Bookmarklet</a>有详细的定义。</p>
<p>一个具体的例子是<a href="http://www.delicious.com/" target="_blank">Delicious</a>的收藏按钮，它就是一个Bookmarklet，因为它在点击后会弹出一个对话框，并将输入的信息保存到Delicious书签中，Delicious网站也给出了各种浏览器下安装这个Bookmarklet的方法（其实大部分浏览器都很简单，将一个链接拖放到书签栏就好了）</p>
<p><a title="http://www.delicious.com/help/bookmarklets" href="http://www.delicious.com/help/bookmarklets">http://www.delicious.com/help/bookmarklets</a></p>
<p><strong>Bookmarklet与GMarks</strong></p>
<p>除了一般浏览器的书签栏，如果使用一些浏览器的书签扩展插件，方法可能有所不同。比如<a href="https://addons.mozilla.org/en-US/firefox/addon/2888/" target="_blank">GMarks</a>（我在用的），要想添加Bookmarklet到GMarks，则需要在链接地址的前面加上一个空格，否则GMark会不认的 ; )</p>
<p><img title="gmarks-add-bookmarklet" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="226" alt="gmarks-add-bookmarklet" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/gmarksaddbookmarklet.png" width="333" border="0" /> </p>
<p>注意上面的javascript前面<strong>留了一个空格</strong>。</p>
<p><strong>我在用的Bookmarklet</strong></p>
<p>我在用的Bookmarklet并不多，分享一下，如果你有好的推荐，请留言告诉我。</p>
<ul>
<li><a href="http://www.bugmenot.com/faq.php#05" target="_blank">BugMeNot的Bookmarklet</a>：可以让你在一些需要登录的网站的地方，自动替你找到用户、密码并登录，对很多站不起作用，不过有些站点可用。</li>
<li><a href="http://lab.arc90.com/experiments/readability/" target="_blank">Readability的Bookmarket</a>：自动让网页更易阅读的一个Bookmarklet。</li>
<li><a href="http://www.tineye.com/bookmarklet" target="_blank">Tineye的Bookmarklet</a>：Tineye是一个图像搜索引擎，这个Bookmarklet可以自动以当前网页的图片作为源来搜索他们的来源。</li>
</ul>
<p>如果你想要更多的Bookmarklet，<a href="http://webapps.stackexchange.com/questions/293/what-useful-bookmarklets-do-you-use" target="_blank">这里</a>有比较多的候选 ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/bookmarklet.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>使用虚拟机做开发</title>
		<link>http://www.liuzhongshu.com/tech/vm-for-development.html</link>
		<comments>http://www.liuzhongshu.com/tech/vm-for-development.html#comments</comments>
		<pubDate>Wed, 11 Aug 2010 08:23:09 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/vm-for-development.html</guid>
		<description><![CDATA[因为烦透了PC越来越慢，甚至不得不重装，开始用虚拟机做开发，小有心得。
速度和功能
我在VMware 7的虚拟机（Windows XP/1.5G内存）上做开发，所有的PC功能：网络、USB、音频都正常，只是3D显示没有，不过我做开发，并不介意，代价是速度稍慢。
同时我有安装其他操作系统的虚拟机做一些实验，Windows7， Windows 2003 Server， Ubuntu9.04， Mac OSX 10.5，都一切正常。 只是Mac非常慢，可能是驱动的问题，Windows 7也稍慢。
只要内存够大，同时跑多个虚拟机没有问题，对开发来说，有时需要跑两个，偶尔我会跑三个。
如果性能足够好，将虚拟机安装在移动硬盘上，那就可以随身携带喜欢的开发环境了。
操作
不管是VirtualBox还是VMware，安装了相应的虚拟机驱动之后，在虚拟机和主机（host）间都以无缝切换了。甚至两者也都支持在主机的桌面上显示虚拟机的窗口（VMware中叫做Unity），挺神奇的。
基本上，当以全屏模式跑虚拟机的时候，你会忘了自己在虚拟机下，和主机可以用share folder共享文件。VMware下，也可以在窗口模式下用拖放的方式来拷贝文件，甚至可以在两个虚拟机间也可以拖放文件。
Snapshot
用虚拟机的主要的好处是Snapshot功能，再也不用担心试用某个软件会让系统崩掉或者速度越来越慢了，只要随时打一个Snapshot，就像SVN的标签一样，需要的时候，回到Snapshot就好了。在这个功能上，VMware要比VirutualBox强不少，VMware允许在Snapshot间任意跳转，也可以任意删除，用起来很方便。
 
经验
用下来，虚拟机的感觉不错，几点小提示：

要有足够大的内存，4G是起码的。。
如果你的开发是性能敏感的，用虚拟机就不太合适，如果你的开发时环境敏感的（需要在不同环境下测试你的应用），虚拟机就非常合适。
在虚拟机下难免要使用Snapshot恢复系统，因此要习惯将自己的数据文件放在host的share folder里。

未来
我知道基于内核的虚拟化会速度更快，我还没有尝试过，希望某天可以试下Hyper-V或者Vmware ESXi。
]]></description>
			<content:encoded><![CDATA[<p>因为烦透了PC越来越慢，甚至不得不重装，开始用虚拟机做开发，小有心得。</p>
<p><strong>速度和功能</strong></p>
<p>我在VMware 7的虚拟机（Windows XP/1.5G内存）上做开发，所有的PC功能：网络、USB、音频都正常，只是3D显示没有，不过我做开发，并不介意，代价是速度稍慢。</p>
<p>同时我有安装其他操作系统的虚拟机做一些实验，Windows7， Windows 2003 Server， Ubuntu9.04， Mac OSX 10.5，都一切正常。 只是Mac非常慢，可能是驱动的问题，Windows 7也稍慢。</p>
<p>只要内存够大，同时跑多个虚拟机没有问题，对开发来说，有时需要跑两个，偶尔我会跑三个。</p>
<p>如果性能足够好，将虚拟机安装在移动硬盘上，那就可以随身携带喜欢的开发环境了。</p>
<p><strong>操作</strong></p>
<p>不管是VirtualBox还是VMware，安装了相应的虚拟机驱动之后，在虚拟机和主机（host）间都以无缝切换了。甚至两者也都支持在主机的桌面上显示虚拟机的窗口（VMware中叫做Unity），挺神奇的。</p>
<p>基本上，当以全屏模式跑虚拟机的时候，你会忘了自己在虚拟机下，和主机可以用share folder共享文件。VMware下，也可以在窗口模式下用拖放的方式来拷贝文件，甚至可以在两个虚拟机间也可以拖放文件。</p>
<p><strong>Snapshot</strong></p>
<p>用虚拟机的主要的好处是Snapshot功能，再也不用担心试用某个软件会让系统崩掉或者速度越来越慢了，只要随时打一个Snapshot，就像SVN的标签一样，需要的时候，回到Snapshot就好了。在这个功能上，VMware要比VirutualBox强不少，VMware允许在Snapshot间任意跳转，也可以任意删除，用起来很方便。</p>
<p><img title="vmware-snapshot" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="514" alt="vmware-snapshot" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/vmwaresnapshot.png" width="444" border="0" /> </p>
<p><strong>经验</strong></p>
<p>用下来，虚拟机的感觉不错，几点小提示：</p>
<ul>
<li>要有足够大的内存，4G是起码的。。</li>
<li>如果你的开发是性能敏感的，用虚拟机就不太合适，如果你的开发时环境敏感的（需要在不同环境下测试你的应用），虚拟机就非常合适。</li>
<li>在虚拟机下难免要使用Snapshot恢复系统，因此要习惯将自己的数据文件放在host的share folder里。</li>
</ul>
<p><strong>未来</strong></p>
<p>我知道基于内核的虚拟化会速度更快，我还没有尝试过，希望某天可以试下<a href="http://www.microsoft.com/hyper-v-server/en/us/default.aspx" target="_blank">Hyper-V</a>或者<a href="http://www.vmware.com/products/vsphere/esxi-and-esx/index.html" target="_blank">Vmware ESXi</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/vm-for-development.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java XSLT</title>
		<link>http://www.liuzhongshu.com/code/java-xslt.html</link>
		<comments>http://www.liuzhongshu.com/code/java-xslt.html#comments</comments>
		<pubDate>Tue, 10 Aug 2010 08:57:55 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[code|编程]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/?p=1183</guid>
		<description><![CDATA[XSLT是将一种XML转到另一种XML的标准技术，说是转换到另一种XMl，实际上转成html、text也都是可以的，下面是XSLT的极好的一个教程：
http://www.zvon.org/xxl/XSLTutorial/Books/Output/index.html
XSL转换代码
使用Java可以容易的做简单的XSLT转换，比如下面的代码：

String xsltFile = &#34;xxx.xsl&#34;;
String xmlsource = &#34;xxx.xml&#34;;
String locationOfNewContentXml = &#34;xxx.csv&#34;;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance&#40;&#41;;
docBuilderFactory.setIgnoringElementContentWhitespace&#40;true&#41;;
TransformerFactory transformerFactory = TransformerFactory.newInstance&#40;&#41;;
Source xsltSource = new StreamSource&#40;xsltFile&#41;;
File xmlSourceFile = new File&#40;xmlsource&#41;;
try
&#123;
	Transformer sourcetransormer = transformerFactory.newTransformer&#40;xsltSource&#41;;
	OutputStream yourFileOutputStream = new FileOutputStream&#40;new File&#40;locationOfNewContentXml&#41;&#41;;
	sourcetransormer.transform&#40;new StreamSource&#40;xmlSourceFile&#41;,  new StreamResult&#40;new OutputStreamWriter&#40;yourFileOutputStream&#41;&#41;&#41;;
	yourFileOutputStream.close&#40;&#41;;
&#125;
catch&#40;Exception e&#41;
&#123;
	e.printStackTrace&#40;&#41;;
&#125;

在Java世界，除了Java标准库以外，saxon和xalan是最常用的两个做XSLT的库。
XSL文件
XSL文件本身也是XML，功能很强大，在2.0版本中，支持很多函数，XSL写下来像是脚本语言了。

&#60;xsl:stylesheet version=&#34;1.0&#34; xmlns:xsl=&#34;http://www.w3.org/1999/XSL/Transform&#34; &#62;
&#60;xsl:output method=&#34;text&#34; encoding=&#34;UTF-8&#34;/&#62;
&#160;
&#60;xsl:param name=&#34;delim&#34; select=&#34;string(',')&#34; /&#62;
&#60;xsl:param name=&#34;quote&#34; select=&#34;string('&#38;quot;')&#34; /&#62;
&#60;xsl:param name=&#34;break&#34; select=&#34;string('&#38;#xD;')&#34; /&#62;
&#60;xsl:template match=&#34;/&#34;&#62;
&#160;
&#60;xsl:value-of select=&#34;property[@name='description']/@value&#34;/&#62; 
&#60;xsl:value-of [...]]]></description>
			<content:encoded><![CDATA[<p>XSLT是将一种XML转到另一种XML的标准技术，说是转换到另一种XMl，实际上转成html、text也都是可以的，下面是XSLT的极好的一个教程：</p>
<p><a title="http://www.zvon.org/xxl/XSLTutorial/Books/Output/index.html" href="http://www.zvon.org/xxl/XSLTutorial/Books/Output/index.html">http://www.zvon.org/xxl/XSLTutorial/Books/Output/index.html</a></p>
<p><strong>XSL转换代码</strong></p>
<p>使用Java可以容易的做简单的XSLT转换，比如下面的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> xsltFile <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxx.xsl&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> xmlsource <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxx.xml&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> locationOfNewContentXml <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxx.csv&quot;</span><span style="color: #339933;">;</span>
DocumentBuilderFactory docBuilderFactory <span style="color: #339933;">=</span> DocumentBuilderFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
docBuilderFactory.<span style="color: #006633;">setIgnoringElementContentWhitespace</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
TransformerFactory transformerFactory <span style="color: #339933;">=</span> TransformerFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Source xsltSource <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StreamSource<span style="color: #009900;">&#40;</span>xsltFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">File</span> xmlSourceFile <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>xmlsource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">try</span>
<span style="color: #009900;">&#123;</span>
	Transformer sourcetransormer <span style="color: #339933;">=</span> transformerFactory.<span style="color: #006633;">newTransformer</span><span style="color: #009900;">&#40;</span>xsltSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">OutputStream</span> yourFileOutputStream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>locationOfNewContentXml<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	sourcetransormer.<span style="color: #006633;">transform</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> StreamSource<span style="color: #009900;">&#40;</span>xmlSourceFile<span style="color: #009900;">&#41;</span>,  <span style="color: #000000; font-weight: bold;">new</span> StreamResult<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">OutputStreamWriter</span><span style="color: #009900;">&#40;</span>yourFileOutputStream<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	yourFileOutputStream.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>在Java世界，除了Java标准库以外，<a href="http://saxon.sourceforge.net/" target="_blank">saxon</a>和<a href="http://xml.apache.org/xalan-j/" target="_blank">xalan</a>是最常用的两个做XSLT的库。</p>
<p><strong>XSL文件</strong></p>
<p>XSL文件本身也是XML，功能很强大，在2.0版本中，支持很多函数，XSL写下来像是脚本语言了。</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:stylesheet</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">xmlns:xsl</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/XSL/Transform&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:output</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;delim&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;string(',')&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;quote&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;string('&amp;quot;')&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;break&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;string('&amp;#xD;')&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;property[@name='description']/@value&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> 
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$break&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;property[@name='subnode']/nodeItems&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:if</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;property[@name='prop1']&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:for-each</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;property[@name='prop1']/subnode&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;@prop2&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:if</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;following-sibling::*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$break&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:if<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:for-each<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>函数</strong></p>
<p>有的时候，需要在XSL文件中定义自己用的函数，在XSLT1.0中，可以用模板来做，比如这样的字符串replace函数：</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;string-replace-all&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;replace&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;by&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:when</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;contains($text,$replace)&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;substring-before($text,$replace)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$by&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:call-template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;string-replace-all&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;substring-after($text,$replace)&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;replace&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$replace&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;by&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$by&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:call-template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:when<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/java-xslt.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Swing</title>
		<link>http://www.liuzhongshu.com/code/visual-swing.html</link>
		<comments>http://www.liuzhongshu.com/code/visual-swing.html#comments</comments>
		<pubDate>Wed, 04 Aug 2010 00:05:38 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/code/visual-swing.html</guid>
		<description><![CDATA[用Java Swing写GUI的好处是比较好的跨平台特性，不过Eclipse中没有一个好的界面编辑器，尝试了开源的Visual Swing，感觉一般。
Visual Swing插件在Eclipse中安装后，就可以在工程中新建Visual Swing的Form了，下面是可视化的editor，可以在上面改UI，下面改代码：
&#160; 
和大部分GUI Builder一样，提供控件库和属性编辑窗口：
 
看起来都还不错，中文也正常，不过用下来发现的问题：

在编辑Form的代码时，很多键都不能用，甚至Ctrl-V也不能，只能一点点输入进去，真是相当麻烦，幸好一般不用去手动编辑它，把程序逻辑部分的代码放到别的class中即可。 
当UI变的复杂以后，有时鼠标会选不中某些控件。 
最后如果要发布，还是要一个Visual Swing的jar的，不大，但是通常就需要写一下Ant脚本了，记录下我用的脚本，以后也许还要参考，那个grouplayout.jar就是来自Visual Swing。 

&#60;?xml version=&#34;1.0&#34;?&#62; 
&#60;project name=&#34;xxx&#34; xmlns:antelope=&#34;antlib:ise.antelope.tasks&#34;&#62; 
&#160;&#160;&#160; &#60;target name=&#34;clean&#34;&#62;    &#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;delete dir=&#34;classes&#34;/&#62;     &#160;&#160;&#160; &#60;/target&#62;     &#160;&#160;&#160; &#60;target name=&#34;compile&#34; depends=&#34;clean&#34;&#62;     &#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;mkdir dir=&#34;classes&#34;/&#62;     &#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;javac encoding=&#34;UTF-8&#34; srcdir=&#34;src&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>用Java Swing写GUI的好处是比较好的跨平台特性，不过Eclipse中没有一个好的界面编辑器，尝试了开源的<a href="http://code.google.com/p/visualswing4eclipse/" target="_blank">Visual Swing</a>，感觉一般。</p>
<p>Visual Swing插件在Eclipse中安装后，就可以在工程中新建Visual Swing的Form了，下面是可视化的editor，可以在上面改UI，下面改代码：</p>
<p><img title="visual-swing-editor" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="573" alt="visual-swing-editor" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/visualswingeditor2.png" width="500" border="0" />&#160; </p>
<p>和大部分GUI Builder一样，提供控件库和属性编辑窗口：</p>
<p><img title="visual-swing-palette" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="946" alt="visual-swing-palette" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/visualswingpalette.png" width="287" border="0" /> </p>
<p>看起来都还不错，中文也正常，不过用下来发现的问题：</p>
<ul>
<li>在编辑Form的代码时，很多键都不能用，甚至Ctrl-V也不能，只能一点点输入进去，真是相当麻烦，幸好一般不用去手动编辑它，把程序逻辑部分的代码放到别的class中即可。 </li>
<li>当UI变的复杂以后，有时鼠标会选不中某些控件。 </li>
<li>最后如果要发布，还是要一个Visual Swing的jar的，不大，但是通常就需要写一下Ant脚本了，记录下我用的脚本，以后也许还要参考，那个grouplayout.jar就是来自Visual Swing。 </li>
</ul>
<p>&lt;?xml version=&quot;1.0&quot;?&gt; </p>
<p>&lt;project name=&quot;xxx&quot; xmlns:antelope=&quot;antlib:ise.antelope.tasks&quot;&gt; </p>
<p>&#160;&#160;&#160; &lt;target name=&quot;clean&quot;&gt;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;delete dir=&quot;classes&quot;/&gt;     <br />&#160;&#160;&#160; &lt;/target&gt;     <br />&#160;&#160;&#160; &lt;target name=&quot;compile&quot; depends=&quot;clean&quot;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;mkdir dir=&quot;classes&quot;/&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;javac encoding=&quot;UTF-8&quot; srcdir=&quot;src&quot; destdir=&quot;classes&quot; &gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;classpath path=&quot;libs/grouplayout.jar&quot;/&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/javac&gt;     <br />&#160;&#160;&#160; &lt;/target&gt;     <br />&#160;&#160;&#160; &lt;target name=&quot;jar&quot; depends=&quot;compile&quot;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;jar jarfile=&quot;xxx.jar&quot;&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;zipfileset dir=&quot;classes&quot; prefix=&quot;&quot; /&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;zipfileset src=&quot;libs/grouplayout.jar&quot; includes=&quot;**/*.class&quot;/&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;manifest&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;attribute name=&quot;Main-class&quot; value=&quot;xxx.yyy.zzz&quot;/&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/manifest&gt;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/jar&gt;     <br />&#160;&#160;&#160; &lt;/target&gt;     <br />&lt;/project&gt;</p>
<p>Netbeans应该有自带的不错的<a href="http://netbeans.org/features/java/swing.html" target="_blank">UI设计工具</a>，也许会比这个好用些，谁有经验？</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/visual-swing.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows下为Linux打包</title>
		<link>http://www.liuzhongshu.com/tech/package-for-linux-in-windows.html</link>
		<comments>http://www.liuzhongshu.com/tech/package-for-linux-in-windows.html#comments</comments>
		<pubDate>Mon, 02 Aug 2010 06:54:32 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/package-for-linux-in-windows.html</guid>
		<description><![CDATA[想要跨平台制作一个压缩包，比如想在Windows下制作一个可在Linux下用的zip，可不是那么容易，会遇到两个问题：

Windows文件是没有权限的，而权限对于Linux下的文件至关重要，尤其是执行权限。 
不同的系统下文件名的编码规则是不一样的，所以对于非ASCII文件名，比如中文文件名，可能出现乱码。 

如果是在Linux下打包到Windows下使用，上面的问题1不会出现，但问题2仍然是有的，我被迫耐心的对tar/zip/rar/7z做了些测试，结果是这个样子的：

只有tar文件解开后才能具有正确的权限（或者说是宽松的权限），其他格式在Linux下解开后都只有644的权限，如果要执行某个文件，还要再用chmod来修改权限。 
只有7z和RAR可以正确识别文件名的编码，而tar/zip在不同编码的Windows系统和Linux系统下，遇到中文文件，解压后文件名会乱码。 

我的结论是这样子的：

绝大部分时候tar.gz应该是最好的选择，本身这种格式很通用，压缩率高，文件权限又没有问题。但如果涉及中文文件，则要考虑Linux下的Locale，使用正确的编码去做压缩，通常在Windows下直接压缩tar.gz，文件名应该是gb码编码的。 
如果压缩包中有中文文件，且你不知道你的用户会使用什么Locale，并且你的压缩包中叶没有可执行文件，你的用户也知道如何解压缩7z格式的话，这个时候7z是个好的选择，它可以保证绝对不会出现文件名乱码的问题，因为7z在压缩包中已经指明了使用何种编码编码了文件名，这样解压缩时它会根据本地locale转换一下就绝对不会错了。 

最后，在Gmail中下载附件时，可以看到下面的界面，印证我的结论:
 
如果想用zip方式下载附件，需要设置一个编码，就是这个原因。
]]></description>
			<content:encoded><![CDATA[<p>想要跨平台制作一个压缩包，比如想在Windows下制作一个可在Linux下用的zip，可不是那么容易，会遇到两个问题：</p>
<ol>
<li>Windows文件是没有权限的，而权限对于Linux下的文件至关重要，尤其是执行权限。 </li>
<li>不同的系统下文件名的编码规则是不一样的，所以对于非ASCII文件名，比如中文文件名，可能出现乱码。 </li>
</ol>
<p>如果是在Linux下打包到Windows下使用，上面的问题1不会出现，但问题2仍然是有的，我被迫耐心的对tar/zip/rar/7z做了些测试，结果是这个样子的：</p>
<ul>
<li>只有tar文件解开后才能具有正确的权限（或者说是宽松的权限），其他格式在Linux下解开后都只有644的权限，如果要执行某个文件，还要再用chmod来修改权限。 </li>
<li>只有7z和RAR可以正确识别文件名的编码，而tar/zip在不同编码的Windows系统和Linux系统下，遇到中文文件，解压后文件名会乱码。 </li>
</ul>
<p>我的结论是这样子的：</p>
<ol>
<li>绝大部分时候tar.gz应该是最好的选择，本身这种格式很通用，压缩率高，文件权限又没有问题。但如果涉及中文文件，则要考虑Linux下的Locale，使用正确的编码去做压缩，通常在Windows下直接压缩tar.gz，文件名应该是gb码编码的。 </li>
<li>如果压缩包中有中文文件，且你不知道你的用户会使用什么Locale，并且你的压缩包中叶没有可执行文件，你的用户也知道如何解压缩7z格式的话，这个时候7z是个好的选择，它可以保证绝对不会出现文件名乱码的问题，因为7z在压缩包中已经指明了使用何种编码编码了文件名，这样解压缩时它会根据本地locale转换一下就绝对不会错了。 </li>
</ol>
<p>最后，在Gmail中下载附件时，可以看到下面的界面，印证我的结论:</p>
<p><img title="gmail-download-attachment" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="45" alt="gmail-download-attachment" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/gmaildownloadattachment.png" width="487" border="0" /> </p>
<p>如果想用zip方式下载附件，需要设置一个编码，就是这个原因。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/package-for-linux-in-windows.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Offline Application</title>
		<link>http://www.liuzhongshu.com/tech/html5-offline-application.html</link>
		<comments>http://www.liuzhongshu.com/tech/html5-offline-application.html#comments</comments>
		<pubDate>Fri, 30 Jul 2010 07:10:44 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/html5-offline-application.html</guid>
		<description><![CDATA[原有的HTML的cache机制，并不能保证浏览器cache的时效和离线应用，也不能对cache做什么过多的控制，我想将一个大的资源（比如一个图片、一个flash等）永久的cache在浏览器端就做不到。
HTML5中引入了Offline Application，似乎能解决我的困惑，一切看起来很美好，可以参考这篇很棒的文章：
http://diveintohtml5.org/offline.html
看了一下，通过offline cache，可以得到的好处有：

现在，我们可以在HTML页面中简单加入一个manifest文件来指明哪些资源是需要cache的，并可以指定cache策略。 
我们有一组cache相关的接口，可以得到cache变化的事件通知，可以控制向cache中加入或删除对象。 
在离线时，cache可以让我们的Web应用看起来还一切正常工作。 

我很有兴趣的尝试了一下，写好我的manifest文件，将一个大文件指定为offline cache，遗憾的是，在Firefox 3.6.8上面，有时似乎cache起了作用，有时又没有作用。 到了后来，连firefox自己的清除offline cache的按钮也不工作了：
 
搜索了一下，有人提交了bug, 我只好去附和一下，灰心的撤了。
]]></description>
			<content:encoded><![CDATA[<p>原有的HTML的cache机制，并不能保证浏览器cache的时效和离线应用，也不能对cache做什么过多的控制，我想将一个大的资源（比如一个图片、一个flash等）永久的cache在浏览器端就做不到。</p>
<p>HTML5中引入了Offline Application，似乎能解决我的困惑，一切看起来很美好，可以参考这篇很棒的文章：</p>
<p><a title="http://diveintohtml5.org/offline.html" href="http://diveintohtml5.org/offline.html">http://diveintohtml5.org/offline.html</a></p>
<p>看了一下，通过offline cache，可以得到的好处有：</p>
<ul>
<li>现在，我们可以在HTML页面中简单加入一个manifest文件来指明哪些资源是需要cache的，并可以指定cache策略。 </li>
<li>我们有一组cache相关的接口，可以得到cache变化的事件通知，可以控制向cache中加入或删除对象。 </li>
<li>在离线时，cache可以让我们的Web应用看起来还一切正常工作。 </li>
</ul>
<p>我很有兴趣的尝试了一下，写好我的manifest文件，将一个大文件指定为offline cache，遗憾的是，在Firefox 3.6.8上面，有时似乎cache起了作用，有时又没有作用。 到了后来，连firefox自己的清除offline cache的按钮也不工作了：</p>
<p><img title="firefox-clear-offline-cache" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="482" alt="firefox-clear-offline-cache" src="http://www.liuzhongshu.com/wp-content/uploads/2010/07/firefoxclearofflinecache.png" width="511" border="0" /> </p>
<p>搜索了一下，有人提交了<a href="http://support.mozilla.com/tiki-view_forum_thread.php?comments_parentId=683900&amp;forumId=1" target="_blank">bug</a>, 我只好去附和一下，灰心的撤了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/html5-offline-application.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>获取自己的外网IP</title>
		<link>http://www.liuzhongshu.com/tech/get-your-wan-ip.html</link>
		<comments>http://www.liuzhongshu.com/tech/get-your-wan-ip.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 01:22:02 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[cli]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/get-your-wan-ip.html</guid>
		<description><![CDATA[在NAT的环境下（比如家里用路由器），我有时想知道自己的外网IP，比如开一个服务给别人访问什么的，方法有三：
1）访问路由器的配置页面
一般的路由器都提供一个类似status的页面，上面的WAN口信息中就会有当前的外网IP。
2）访问一些可以提供客户ip地址的网站，比如
http://www.whatismyip.com/

http://www.whatsmyip.org/
&#160;
3）脚本的方法，这个是程序员喜欢的：

curl http://checkip.dyndns.org 得到的就是这样的输出了：
&#160;
&#60;html&#62;&#60;head&#62;&#60;title&#62;Current IP Check&#60;/title&#62;&#60;/head&#62;&#60;body&#62;Current IP Address: 200.
  100.50.25&#60;/body&#62;&#60;/html&#62; 
接下来，如何做，就是正则表达式的地盘了。 
update： mrluanma指出了更简洁的方法，可以直接得到ip地址，谢了。。。
curl http://ip.appspot.com
]]></description>
			<content:encoded><![CDATA[<p>在NAT的环境下（比如家里用路由器），我有时想知道自己的外网IP，比如开一个服务给别人访问什么的，方法有三：</p>
<p>1）访问路由器的配置页面</p>
<p>一般的路由器都提供一个类似status的页面，上面的WAN口信息中就会有当前的外网IP。</p>
<p>2）访问一些可以提供客户ip地址的网站，比如</p>
<pre><code><a href="http://www.whatismyip.com/">http://www.whatismyip.com/
</a></code></pre>
<pre><code><a href="http://www.whatsmyip.org/">http://www.whatsmyip.org/</a></code></pre>
<pre><code></code>&#160;</pre>
<pre><code>3）脚本的方法，</code><code>这个是程序员喜欢的：</code></pre>
<pre><code></code></pre>
<pre>curl <a href="http://checkip.dyndns.org">http://checkip.dyndns.org</a> 得到的就是这样的输出了：</pre>
<pre>&#160;</pre>
<p>&lt;html&gt;&lt;head&gt;&lt;title&gt;Current IP Check&lt;/title&gt;&lt;/head&gt;&lt;body&gt;Current IP Address: 200.<br />
  <br />100.50.25&lt;/body&gt;&lt;/html&gt; </p>
<p>接下来，如何做，就是正则表达式的地盘了。 </p>
<p><strong>update</strong>： mrluanma指出了更简洁的方法，可以直接得到ip地址，谢了。。。</p>
<p>curl <a href="http://ip.appspot.com">http://ip.appspot.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/get-your-wan-ip.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>有趣的即时通讯工具Miranda</title>
		<link>http://www.liuzhongshu.com/tech/miranda.html</link>
		<comments>http://www.liuzhongshu.com/tech/miranda.html#comments</comments>
		<pubDate>Thu, 15 Jul 2010 08:13:11 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/miranda.html</guid>
		<description><![CDATA[Miranda是一个占用很小资源的多账号即时通讯客户端，在我的PC上，加一个MSN账号后大约用到3M内存，这点让我很喜欢。不过用Miranda的人却很少，因为Miranda有那么一些功能，设计的很奇怪，让初用的人很不习惯，所以我也不会把它加到我的百佳软荐中，但在这里记录一下Miranda的几个tip，让有兴趣尝试的人少走一些弯路。
自动登录
Miranda下，你配置了即时通讯的账号密码并不能让你自动登录，登录一次之后也不能让你自动登录，要点是要用通知区域的右键菜单下的状态来切换，这样切换了状态之后，下次就会自动记住而登录了。
 
自动弹出窗口
缺省情况下，Miranda收到消息不会自动弹出，我知道很多人喜欢这样的设置，不过我更喜欢直接弹出窗口，下面就是这个设置的地方，我找了好一会：
 
添加好友
很奇怪的是Miranda不能通过主窗口右键的方式添加好友，而要在菜单的这里来添加：
 
最后， 也有很多人发现Miranda是一个需要不少设置才能用好的软件，于是就有专门一个网页教你如何细致的调校它，http://miranda-im.info/ ，不过我发现我知道了上面记录的这些设置之后就用的很好了。
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.miranda-im.org" target="_blank">Miranda</a>是一个占用很小资源的多账号即时通讯客户端，在我的PC上，加一个MSN账号后大约用到3M内存，这点让我很喜欢。不过用Miranda的人却很少，因为Miranda有那么一些功能，设计的很奇怪，让初用的人很不习惯，所以我也不会把它加到我的百佳软荐中，但在这里记录一下Miranda的几个tip，让有兴趣尝试的人少走一些弯路。</p>
<p><strong>自动登录</strong></p>
<p>Miranda下，你配置了即时通讯的账号密码并不能让你自动登录，登录一次之后也不能让你自动登录，要点是要用通知区域的右键菜单下的状态来切换，这样切换了状态之后，下次就会自动记住而登录了。</p>
<p><img title="miranda-auto-login" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="235" alt="miranda-auto-login" src="http://www.liuzhongshu.com/wp-content/uploads/2010/07/mirandaautologin.png" width="304" border="0" /> </p>
<p><strong>自动弹出窗口</strong></p>
<p>缺省情况下，Miranda收到消息不会自动弹出，我知道很多人喜欢这样的设置，不过我更喜欢直接弹出窗口，下面就是这个设置的地方，我找了好一会：</p>
<p><strong><img title="miranda-message-window" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="485" alt="miranda-message-window" src="http://www.liuzhongshu.com/wp-content/uploads/2010/08/mirandamessagewindow.png" width="600" border="0" /> </strong></p>
<p><strong>添加好友</strong></p>
<p>很奇怪的是Miranda不能通过主窗口右键的方式添加好友，而要在菜单的这里来添加：</p>
<p><a href="http://www.liuzhongshu.com/wp-content/uploads/2010/07/mirandaaddfriend.png" rel="lightbox[1162]"><img title="miranda-add-friend" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="269" alt="miranda-add-friend" src="http://www.liuzhongshu.com/wp-content/uploads/2010/07/mirandaaddfriend_thumb.png" width="205" border="0" /></a> </p>
<p>最后， 也有很多人发现Miranda是一个需要不少设置才能用好的软件，于是就有专门一个网页教你如何细致的调校它，<a title="http://miranda-im.info/" href="http://miranda-im.info/">http://miranda-im.info/</a> ，不过我发现我知道了上面记录的这些设置之后就用的很好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/miranda.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>微笑的餐具</title>
		<link>http://www.liuzhongshu.com/life/smile-dishware.html</link>
		<comments>http://www.liuzhongshu.com/life/smile-dishware.html#comments</comments>
		<pubDate>Sun, 11 Jul 2010 13:25:16 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[life|随笔、杂七杂八]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/life/smile-dishware.html</guid>
		<description><![CDATA[有段时间之前，我在这个网站上发现有一个有趣的活动（现在这个活动应该是结束了），就是用免费赠送一个小礼物来得到一份问卷调查和一篇博客，我觉得这种推广的方法还蛮新颖的，当即完成了问卷，并留下了博客。
在不短的时间（记不清多长时间了）后，我收到了他们寄来的礼物，一对还蛮精致的带着微笑的刀和叉的餐具。
 
我拍了上面的照片，和留下这篇博客以兑现我的承诺，顺便也预祝这个网站能办的好。
想起多年以前，这种免费得到网站寄出礼物的事情我还遇到过一次，那次是新浪，刚开始推他的搜索引擎的时候，我得到了一幅手套和一条围巾，至今手套和围巾仍然在用，但新浪的搜索引擎却黯然下线。
]]></description>
			<content:encoded><![CDATA[<p>有段时间之前，我在<a href="http://www.lepu.com/" target="_blank">这个网站</a>上发现有一个有趣的活动（现在这个活动应该是结束了），就是用免费赠送一个小礼物来得到一份问卷调查和一篇博客，我觉得这种推广的方法还蛮新颖的，当即完成了问卷，并留下了博客。</p>
<p>在不短的时间（记不清多长时间了）后，我收到了他们寄来的礼物，一对还蛮精致的带着微笑的刀和叉的餐具。</p>
<p><img title="smile_dishware" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="332" alt="smile_dishware" src="http://www.liuzhongshu.com/wp-content/uploads/2010/07/smile_dishware.jpg" width="500" border="0" /> </p>
<p>我拍了上面的照片，和留下这篇博客以兑现我的承诺，顺便也预祝这个网站能办的好。</p>
<p>想起多年以前，这种免费得到网站寄出礼物的事情我还遇到过一次，那次是新浪，刚开始推他的搜索引擎的时候，我得到了一幅手套和一条围巾，至今手套和围巾仍然在用，但新浪的搜索引擎却黯然下线。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/life/smile-dishware.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何用大显示器</title>
		<link>http://www.liuzhongshu.com/tech/use-large-monitor.html</link>
		<comments>http://www.liuzhongshu.com/tech/use-large-monitor.html#comments</comments>
		<pubDate>Fri, 09 Jul 2010 02:53:59 +0000</pubDate>
		<dc:creator>zhongshu</dc:creator>
				<category><![CDATA[tech|软件、开源、业界]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/tech/use-large-monitor.html</guid>
		<description><![CDATA[我最近在用一台1920*1080的显示器，在显示器越来越大的情况下，自己的使用习惯也必须要相应的修改，才能更好的适应并发挥大显示器的长处，小小总结一下：

不要轻易使用最大化按钮了，在1920这种分辨率下，大部分应用程序最大化之后都是一种屏幕资源的浪费。 
如果适应了上一条，逐渐习惯于将窗口排列好的方式工作，比如在调试时，一个IDE和一个输出窗口并排将会显著提高效率。 
如果适应了上面一条，还可以将工作区域分成几个虚拟桌面，每个桌面上的窗口排列好，以适应不同的工作上下文。 

上面的后面两条，显然需要一些软件的支持，下面就是了。
窗口排列
毫无疑问，Windows下做这件事最好（如果不是，请告诉我）的软件是WinSplit Revolution，Windows7 也已经包含了它的部分功能，只是WinSplit做的更专业一些，它将屏幕定义出9个区域，可以用快键键将窗口排到指定区域，这样的话，就很容易排列你的窗口了，你也可以任意安排自己的窗口排列情况。

９个区域分别是左上，上，右上，左，中，右，左下，下，右下，这些都是可以自己定义的，缺省是９个的原因是，它们正好对应到小键盘的９个数字键，所以快键键定义起来会非常直观。
还可以为每个区域定义多种大小，这样当你按下这个快捷键后，你可以在多种大小间切换，比如左上，你可以定义三种宽度，50%宽度的，60%和40%的，这样，你可以按一个快捷键在三种宽度间做选择。
如果嫌每次定位一个窗口太麻烦，WinSplit还支持自动的窗口排列，不过我还是更喜欢一个个安排好我的工作窗口。
虚拟桌面
虚拟桌面的软件可就是大把了，你可以轻易的找到几十个这样的软件，从微软自己的Desktops到各种免费及商业软件，选择很多，我不敢说哪个最好了，我自己用的是开源的VirtuaWin，因为有这么一个开源的实现，对其他商业软件就少有尝试了。
 
VirtuaWin用起来没有什么问题，但不能算特别满意，因为我觉得，能有下面两个“锦上添花”的功能就更好了：

每个虚拟桌面可以独立设置背景 
可以使用桌面缩略图的方式切换虚拟桌面 

说起来很有意思，微软从Sysintenals得到的Desktops小工具倒是完美支持上面两个功能，可惜的是，Desktops基本功能方面做的实在差劲，很多窗口在虚拟桌面下显示都有问题，俺只好继续使用VirtuaWin了。

除了排列窗口和虚拟桌面，如果还拥有多显示器，那么就更好了，可以将虚拟桌面换成物理桌面，多窗口平铺也可以使用更大的空间，这里有一篇老外的博客，介绍了这方面的经验之谈，他和我在软件的选择上倒是有些相似，嘿。
]]></description>
			<content:encoded><![CDATA[<p>我最近在用一台1920*1080的显示器，在显示器越来越大的情况下，自己的使用习惯也必须要相应的修改，才能更好的适应并发挥大显示器的长处，小小总结一下：</p>
<ol>
<li>不要轻易使用最大化按钮了，在1920这种分辨率下，大部分应用程序最大化之后都是一种屏幕资源的浪费。 </li>
<li>如果适应了上一条，逐渐习惯于将窗口排列好的方式工作，比如在调试时，一个IDE和一个输出窗口并排将会显著提高效率。 </li>
<li>如果适应了上面一条，还可以将工作区域分成几个虚拟桌面，每个桌面上的窗口排列好，以适应不同的工作上下文。 </li>
</ol>
<p>上面的后面两条，显然需要一些软件的支持，下面就是了。</p>
<p><strong>窗口排列</strong></p>
<p>毫无疑问，Windows下做这件事最好（如果不是，请告诉我）的软件是<a href="http://www.winsplit-revolution.com/">WinSplit Revolution</a>，Windows7 也已经包含了它的部分功能，只是WinSplit做的更专业一些，它将屏幕定义出9个区域，可以用快键键将窗口排到指定区域，这样的话，就很容易排列你的窗口了，你也可以任意安排自己的窗口排列情况。</p>
<p><img src="http://www.winsplit-revolution.com/images/myimages/scheme_1.jpg" /></p>
<p>９个区域分别是左上，上，右上，左，中，右，左下，下，右下，这些都是可以自己定义的，缺省是９个的原因是，它们正好对应到小键盘的９个数字键，所以快键键定义起来会非常直观。</p>
<p>还可以为每个区域定义多种大小，这样当你按下这个快捷键后，你可以在多种大小间切换，比如左上，你可以定义三种宽度，50%宽度的，60%和40%的，这样，你可以按一个快捷键在三种宽度间做选择。</p>
<p>如果嫌每次定位一个窗口太麻烦，WinSplit还支持自动的窗口排列，不过我还是更喜欢一个个安排好我的工作窗口。</p>
<p><strong>虚拟桌面</strong></p>
<p>虚拟桌面的软件可就是大把了，你可以轻易的找到几十个这样的软件，从微软自己的Desktops到各种免费及商业软件，选择很多，我不敢说哪个最好了，我自己用的是开源的<a href="http://virtuawin.sourceforge.net/" target="_blank">VirtuaWin</a>，因为有这么一个开源的实现，对其他商业软件就少有尝试了。</p>
<p><img src="http://virtuawin.sourceforge.net/img/home/screen_1.jpg" /> <img src="http://virtuawin.sourceforge.net/img/home/screen_2.jpg" /></p>
<p>VirtuaWin用起来没有什么问题，但不能算特别满意，因为我觉得，能有下面两个“锦上添花”的功能就更好了：</p>
<ul>
<li>每个虚拟桌面可以独立设置背景 </li>
<li>可以使用桌面缩略图的方式切换虚拟桌面 </li>
</ul>
<p>说起来很有意思，微软从Sysintenals得到的<a href="http://technet.microsoft.com/en-us/sysinternals/cc817881.aspx" target="_blank">Desktops</a>小工具倒是完美支持上面两个功能，可惜的是，Desktops基本功能方面做的实在差劲，很多窗口在虚拟桌面下显示都有问题，俺只好继续使用VirtuaWin了。</p>
<p><img src="http://i.technet.microsoft.com/cc817881.desktops(en-us,MSDN.10).png" /></p>
<p>除了排列窗口和虚拟桌面，如果还拥有多显示器，那么就更好了，可以将虚拟桌面换成物理桌面，多窗口平铺也可以使用更大的空间，这里有一篇<a href="http://www.codinghorror.com/blog/2007/08/the-large-display-paradox.html" target="_blank">老外的博客</a>，介绍了这方面的经验之谈，他和我在软件的选择上倒是有些相似，嘿。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/tech/use-large-monitor.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
