<?xml version="1.0" encoding="GBK" ?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dcterms="http://purl.org/dc/terms/">
 <channel>
  	  <title><![CDATA[体温-37℃ · 重生]]></title>
	  <link>http://blog.163.com/sishen_freecity</link>
	  <description><![CDATA[LOST! Prison Break! Heroes! Good programmers are made, not born.]]></description>
	  <language>zh-CN</language>
	  <pubDate>Thu, 4 Sep 2008 01:50:04 +0800</pubDate>
	  <lastBuildDate>Thu, 4 Sep 2008 01:50:04 +0800</lastBuildDate>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <generator><![CDATA[NetEase Space]]></generator>
	  <managingEditor><![CDATA[sishen_freecity]]></managingEditor>
	  <webMaster><![CDATA[sishen]]></webMaster>
		  <ttl>120</ttl>
	  <image>
	  	<title><![CDATA[体温-37℃ · 重生]]></title>
	  	<url>http://ava.blog.163.com/photo/vTVQHQWyBUUjvRXxpXLRFg==/436004738925819104.jpg</url>
	  	<link>http://blog.163.com/sishen_freecity</link>
	  </image>
  <item>
  	<title><![CDATA[The hope of new striker]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720088414958679</link>
    <description><![CDATA[<div>Hope Dimitar Berbatov can have a bright future in Manchester United. We very need a strong real CF and fortunately we got one in Sep 1th. Good luck for the new season. <br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720088414958679</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720088414958679</guid>
    <pubDate>Thu, 4 Sep 2008 01:49:58 +0800</pubDate>
    <dcterms:modified>2008-09-04T01:49:58+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[这是一个无敌的产品...]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720086108511939</link>
    <description><![CDATA[<div>几个月来没成功登陆过PoPo有感.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720086108511939</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720086108511939</guid>
    <pubDate>Thu, 10 Jul 2008 08:05:11 +0800</pubDate>
    <dcterms:modified>2008-07-10T08:05:11+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[That&apos;s Football!]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720084226228791</link>
    <description><![CDATA[<div>没话说了. 太兴奋了.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720084226228791</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720084226228791</guid>
    <pubDate>Thu, 22 May 2008 06:02:28 +0800</pubDate>
    <dcterms:modified>2008-05-22T06:02:28+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Once burn out, hard to recover.]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720083175834299</link>
    <description><![CDATA[<div>Should I need some change?<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720083175834299</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720083175834299</guid>
    <pubDate>Tue, 1 Apr 2008 19:58:34 +0800</pubDate>
    <dcterms:modified>2008-04-01T19:58:34+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[学生真好... -,-]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/160172008226101117850</link>
    <description><![CDATA[<div>可以参加GSoC... 可惜自己学生生涯的时候没抓住机会...<br><br>钱不多, 但是挺好玩, 对里面的Merb/Mahout/Hadoop三个项目的idea感兴趣.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/160172008226101117850</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/160172008226101117850</guid>
    <pubDate>Wed, 26 Mar 2008 10:11:17 +0800</pubDate>
    <dcterms:modified>2008-03-26T10:11:17+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[I&amp;#241;t&amp;#235;rn&amp;#226;ti&amp;#244;nàliz&amp;#230;ti&amp;#248;n]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200710275226698</link>
    <description><![CDATA[<div>I&#241;t&#235;rn&#226;ti&#244;nàliz&#230;ti&#248;n is a test.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200710275226698</comments>
    <slash:comments>8</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200710275226698</guid>
    <pubDate>Tue, 27 Nov 2007 05:22:06 +0800</pubDate>
    <dcterms:modified>2007-11-27T05:22:06+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[[Ann] Google translate ruby client api 0.1 release.]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200710167560477</link>
    <description><![CDATA[<div><h2><a href="http://sishen.lifegoo.com/?p=51" rel="bookmark" title="Permanent Link: [Ann] Google translate ruby client api 0.1 release.">[Ann] Google translate ruby client api 0.1 release.</a></h2>

   
    <p>I
really like the google translate service. It’s very useful, especially
to someone whose is not a native english speaker, such as me. However,
I really hate to open a browser/tab to get a translation of some words.
It’s no doubt that this work is time-consuming.<br>
&nbsp;Programmer is lazy, :)</p>
<p>&nbsp;</p>
<p>So i wrote a ruby client api fro google translate service, then i
can get the answer directly from the terminal. The world is much more
beautiful. lol~</p>
<p>&nbsp;</p>
<p><strong>Install</strong></p>
<blockquote><p>sudo gem install rtranslate
</p></blockquote>
<p><strong>Usage</strong></p>
<blockquote><p>sishen@lifegoo:~$ irb -rubygems<br>
irb(main):001:0&gt; require ‘rtranslate’<br>
=&gt; true<br>
irb(main):002:0&gt; $KCODE = ‘u’<br>
=&gt; "u"<br>
irb(main):003:0&gt; result = Translate.t("china", Language::ENGLISH, Language::CHINESE_SIMPLIFIED)<br>
=&gt; "中国"<br>
irb(main):004:0&gt; result = Translate.t("china", Language::ENGLISH, Language::JAPANESE)<br>
=&gt; "中華人民共和国"<br>
irb(main):005:0&gt; result = Translate.t("china", Language::ENGLISH, "zh-TW")<br>
=&gt; "中國"</p>
</blockquote>

<p>Really very easy to use, I think. And the source is hosting on <a href="http://rtranslate.googlecode.com/">http://rtranslate.googlecode.com</a>. Enjoy it.</p></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200710167560477</comments>
    <slash:comments>3</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200710167560477</guid>
    <pubDate>Fri, 16 Nov 2007 07:56:00 +0800</pubDate>
    <dcterms:modified>2007-11-16T07:56:37+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[太干了..  先移两篇过来..]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200710241220345</link>
    <description><![CDATA[<div>提示说内容不能为空. 也就意味着不能标灌.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200710241220345</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200710241220345</guid>
    <pubDate>Fri, 2 Nov 2007 16:12:20 +0800</pubDate>
    <dcterms:modified>2007-11-02T16:12:20+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[[Postgresql] levenshtein distance support multibyte string]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720071024952520</link>
    <description><![CDATA[<div><h2><a href="http://sishen.lifegoo.com/?p=48" rel="bookmark" title="Permanent Link to [Postgresql] levenshtein distance support multibyte string">[Postgresql] levenshtein distance support multibyte string</a></h2>
    <small>August 26th, 2007 <!-- by sishen --></small>

    
     <div style="width: 100%; text-align: right;"><a title="Cite to NextLib" alt="Cite to NextLib" href="http://nextlib.lifegoo.com/citeit?url=http%3A%2F%2Fsishen.lifegoo.com%2F&amp;title=Live%20Strong&amp;av=0&amp;client=citebtn&amp;feed=http%3A%2F%2Fsishen.lifegoo.com%2F%3Ffeed%3Drss2"><img src="http://nextlib.lifegoo.com/images/cite_nextlib_small.gif" border="0"></a></div>
<p>I don’t want to explain what the levenshtein distance mean, if you need some basic knowledge about this, check here <span nltag="levenshtein-distance" nluser="sishen" ><a href="http://nextlib.lifegoo.com/user/sishen/tag/levenshtein-distance" target="_blank"><span style="margin-left: 18px;"></span></a><a href="http://nextlib.lifegoo.com/user/sishen/tag/levenshtein-distance" target="_blank"><span style="margin-left: 18px;">levenshtein distance</span></a></span>.</p>
<p>Postgresql have the build-in support for levenshtein distance which is written by Joe Conway,</p>
<p>Let’s see the results at first.</p>
<blockquote><p><span >postgres=&gt; select length(’阿’);<br>
&nbsp;length<br>
——–<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>
(1 row)</span></p>
<p>postgres=&gt; select levenshtein(’阿’, ‘俄’);<br>
&nbsp;levenshtein<br>
————-<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3<br>
(1 row)
</p></blockquote>
<p>
Do you find anything strangely? The length of ‘阿’ is 1, it’s ok. It
means postgresql have great support with the unicode/utf8 encoding. But
the levenshtein result isn’t very friendly. From the above output, it’s
clear that it can only support the ascii character, that’s why the
result is 3. I think it disobeyed the design principle of postgresql.</p>
<p>I hacked the code and add the support of multibyte string. It works very well in my environment.</p>
<blockquote><p><span >postgres=&gt; select levenshtein(’阿’);<br>
&nbsp;levenshtein<br>
————-<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>
(1 row)</span></p>
<p>postgres=&gt; select levenshtein(’阿’, ‘俄’);<br>
&nbsp;levenshtein<br>
————-<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>
(1 row)
</p></blockquote>
<p>
You can download the patch <a href="http://sishen.lifegoo.com/%7Esishen/56-contrib-fuzzystrmatch.patch">here</a>. Or if you are a debian user, i rebuild the contrib package with the 8.1.9 version. You can get it <a href="http://sishen.lifegoo.com/%7Esishen/postgresql-contrib-8.1_8.1.9-1.1_i386.deb">here</a>.</p>
<p>
If you have any problem, please contact me(yedingding@gmail.com), thanks.</p></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720071024952520</comments>
    <slash:comments>0</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720071024952520</guid>
    <pubDate>Fri, 2 Nov 2007 16:09:52 +0800</pubDate>
    <dcterms:modified>2007-11-02T16:09:52+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[[rubygem]A library to convert chinese to pinyin]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200710248242</link>
    <description><![CDATA[<div><h2><a href="http://sishen.lifegoo.com/?p=45" rel="bookmark" title="Permanent Link to [rubygem]A library to convert chinese to pinyin">[rubygem]A library to convert chinese to pinyin</a></h2>
    <small>August 1st, 2007 <!-- by sishen --></small>

    
     <p>前些日子, 用ruby写了一个汉字转化为拼音的类. 大家有用的话就自便吧, :).</p>
<p>原理很简单. 现在网上到处可以见到各种语种的实现, 原理都是大同小异. 简而言之, 先把汉字转化成GB2312编码, 然后查阅<span  nluser="sishen" nlaid="830"><a href="http://nextlib.lifegoo.com/user/sishen/article/830" target="_blank"><span style="margin-left: 18px;">GB2312 Character Coding Table</span></a></span>, 获取其对应的拼音码.</p>
<p><strong>主代码</strong>:</p>
<blockquote><p><span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def to_pinyin(chinese)</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; array = chinese.unpack("U*")</span></p>
<p><span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pinyin = array.inject("") do |pinyin, integer|</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if isChineseUnicode(integer)</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pinyin += to_Pronunciation(integer)</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # todo: other unicode</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pinyin += integer.chr</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pinyin.strip!</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pinyin</span><br>
<span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end</span>
</p></blockquote>
<p>&nbsp;<br>
由上面可以看出, 整个处理process是 chinese -&gt; Unicode number -&gt; iconv (ucs-2 -&gt; gb2312) -&gt; pinyin table, 具体的还是自己看代码吧, 很简单, :)</p>
<p><strong>Test Case</strong>:</p>
<blockquote><p><span >$:.unshift "../lib"</span></p>
<p><span >require ‘test/unit’</span><br>
<span >require ‘pinyin’</span></p>
<p><span >class ChineseToPinyinTest &lt; Test::Unit::TestCase</span><br>
<span >&nbsp; def test_pinyin</span><br>
<span >&nbsp;&nbsp;&nbsp; assert_equal("zhong", Chinese::Pronunciation.to_pinyin("中"))</span><br>
<span >&nbsp;&nbsp;&nbsp; assert_equal("ss", Chinese::Pronunciation.to_pinyin("ss"))</span><br>
&nbsp;&nbsp;&nbsp; <span >assert_equal("zhongguo", Chinese::Pronunciation.to_pinyin("中国"))</span><br>
&nbsp;&nbsp;&nbsp; <span >assert_equal(’womenenglishzifu’, Chinese::Pronunciation.to_pinyin(’我们english字符’))</span><br>
<span >&nbsp;&nbsp;&nbsp; assert_equal(’zhonghuarenmingongheguo’, Chinese::Pronunciation.to_pinyin(’中华人民共和国’))</span><br>
<span >&nbsp; end</span><br>
<span >end</span>
</p></blockquote>
<p>Let’s run it:</p>
<blockquote><p>$ rake<br>
/usr/bin/ruby1.8 -Ilib:lib "/var/lib/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader.rb" "tests/ts_pinyin.rb" <br>
Loaded suite /var/lib/gems/1.8/gems/rake-0.7.3/lib/rake/rake_test_loader<br>
Started<br>
.<br>
Finished in 0.001338 seconds.</p>
<p>1 tests, 7 assertions, 0 failures, 0 errors
</p></blockquote>
<p><strong>README</strong>:</p>
<blockquote><p>= Pinyin<br>
Turn chinese to pronunciation</p>
<p>This class enable ruby programs to turn chinese hanzi to its<br>
pronunciation, that is, pinyin. It supports the GB2312 character<br>
set coding table.</p>
<p>== Usage</p>
<p>require "pinyin"</p>
<p>pinyin = Chinese::Pronunciation.to_pinyin("xxx")</p>
<p>== CHANGES<br>
v0.1.0 July 18<br>
* initial release</p>
<p>Copyright (c) 2007 Dingding Ye &lt;yedingding@gmail.com&gt;<br>
Distributed under MIT License
</p></blockquote>
<p>&nbsp;</p>
<p>You can download the gem <a href="http://sishen.lifegoo.com/%7Esishen/pinyin-0.1.0.gem">here</a>.&nbsp; I hope it’s helpful.</p></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200710248242</comments>
    <slash:comments>3</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200710248242</guid>
    <pubDate>Fri, 2 Nov 2007 16:08:02 +0800</pubDate>
    <dcterms:modified>2007-11-02T16:08:02+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[[GM Script]Baidu Mp3 Show download link]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720076113101245</link>
    <description><![CDATA[<div><div class="entry">
     <p>GreaseMonkey is really a evil, :)&nbsp; It makes our life easier and comfortable.</p>
<p>Userscripts.org has a <a href="http://userscripts.org/scripts/show/3277">script</a>
which used to show the directly baidu mp3 download link. Of course it’s
useful, especially for me. But it’s pity that it doesn’t work any more.
So i made some changes depends on his base, also <a href="http://iescripts.org/view-scripts-11p1.htm">this</a>.</p>

<blockquote>
<p><strong>ChangeLog:</strong></p>
<ol><li>process dom to get the url, instead of xpath.</li><li>use GM_xmlhttpRequest to get the url.&nbsp;</li></ol>
</blockquote>

<p>You can see the effect from the below picture, :)</p>
<p><img alt="greasemonkey script for baidu mp3 link show" src="http://sishen.lifegoo.com/wp-content/uploads/baidump3show.png" height="146" width="872"></p>
<p>&nbsp;</p>
<p>在这里, 我支持Allen su一下, ^_^</p>
<p>You can download the src <a href="http://sishen.lifegoo.com/wp-content/uploads/baidump3showdownloadurlv.user.js">here</a>.</p>
    </div></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720076113101245</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720076113101245</guid>
    <pubDate>Wed, 11 Jul 2007 15:10:12 +0800</pubDate>
    <dcterms:modified>2007-07-11T15:10:12+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Blog.. 能给我PSE吗?]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200751101217180</link>
    <description><![CDATA[<div>没数据支持, 以下存属胡言乱语.<br><br>我相信用户去搜索都是有一定的目的性的, 所以我很难理解为什么有人去选择去用163博客搜索而不是用通用搜索引擎比如google. 找出含有某些关键字的文章? why not google or baidu?<br><br>从访问来源来看, 基本没有从搜索页面中refer过来的, baidu倒是挺多. 需求驱使, 我不认为博客搜索能有多少的用处. 但是, 从另外一个角度说, 我需要PSE, 个性化搜索引擎. 理想状态下, 有个PSE模块, 我可以往里面加入想要索引的blog, 比如我自己的博客, 我一些好友的博客. 我认为这种搜索引擎的目的性会较之原来更强. <br><br>因为对恶意代码的限制, 目前已有的PSE如google-coop, yahoo search builder都无法使用于blog, 既然让我无法选择, 那么, blog.. 能给我PSE吗?<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200751101217180</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200751101217180</guid>
    <pubDate>Mon, 11 Jun 2007 12:12:17 +0800</pubDate>
    <dcterms:modified>2007-06-11T12:12:17+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[我不想公开我的访问模块.. 但是我想看我的访问... 咋办...]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720075811418505</link>
    <description><![CDATA[<div>权限机制做得不够.</div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720075811418505</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720075811418505</guid>
    <pubDate>Fri, 8 Jun 2007 01:14:18 +0800</pubDate>
    <dcterms:modified>2007-06-08T01:14:18+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ansit.el : 语法着色FreeCity版]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/1601720074302158524</link>
    <description><![CDATA[<div>
<h2><a href="http://sishen.lifegoo.com/?p=40" rel="bookmark" title="Permanent Link to ansit.el : 语法着色FreeCity版">ansit.el : 语法着色FreeCity版</a></h2><p>Freecity即<a href="http://www.zju88.cn/">浙江大学飘渺水云间BBS</a>.
Web做得越来越cool了, :)&nbsp; 当然, 本文所说的环境是telnet bbs. 文本的界面, 想搞点五颜六色的,
还要用ascii控制符, 对于我这种偶尔贴贴代码的, 着实让人累死. 可是, 既然是ascii控制符, 那么,
为啥不根据一些语法高亮的编辑器(如emacs)的效果而自动生成呢. 基于这个想法, 因为elisp, ansit.el诞生了. <br></p>

<p>首先, 感谢emacs, 他让整个世界更加美好, nothing is impossible, :)<br>
再次, 感谢crazycool@smth, ansit.el是其于2004年为水木而写. 我在其基础上, 支持了freecity站点, 实际上, 只动了一点点代码… -,-&nbsp;</p>
<p>效果:<br>
<img src="http://sishen.lifegoo.com/wp-content/uploads/ansit.png" alt="ansit.el for freecity 效果图"></p>

<p><br>下载:</p>
<p><a href="http://sishen.lifegoo.com/wp-content/uploads/ansit.el">ansit.el</a></p>

<p>PS:<br>配置方法: 以我的配置为例</p>
<blockquote><p><span >(add-to-list ‘load-path (expand-file-name "~/EmacsLisp/"))</span>; EmacsLisp是我个人的elisp存放目录<br>
<span >(require ‘ansit)</span></p>
</blockquote>
<p>使用方法: 具体参考源代码. 简单而言, 就是select the block and M-x ansit.&nbsp;&nbsp; 另外,
ansit-ansify-this-in-new-buffer包含preview功能, 需要ansi-color lib,
一般当前的emacs版本都已自带(个人使用的是emacs-snapshot-unicode).</p>
</div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/1601720074302158524</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/1601720074302158524</guid>
    <pubDate>Wed, 30 May 2007 02:01:58 +0800</pubDate>
    <dcterms:modified>2007-05-30T02:01:58+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Haml or Not?]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/160172007422113124328</link>
    <description><![CDATA[<div><div >
    <p>Jack在几个月前给了一个<a href="http://haml.hamptoncatlin.com/">Haml</a>的<a href="http://jack.lifegoo.com/?p=115">简单介绍</a>.&nbsp; 可以看出, Haml(XHTML Abstraction Markup Language)最主要的3点好处: 干净, 简单, 方便维护.</p>
<p>我个人非常讨厌HTML, 主要是因为它可阅读性极差和冗余代码极多. 我相信很多人也都有这种感觉. 所以, Haml很适合我.</p>


<p>RoR在应用上的优势在于其的敏捷开发, 而技术上的优势在于其的pure ruby code, no javascript, no
SQL, Really cool. 但是, RHTML templates的存在, 还是让人一头扎进了XHTML/HTML的深渊. The
world needs heroes, :)&nbsp; Haml的出现, 极大程度上的解决了这个问题. Haml is a high-level
abstraction of XHTML useful for website development.<br><br>Ok. 来个例子. 下面是一个登录程序的View代码. 更有对比性的例子可以参照<a href="http://haml.hamptoncatlin.com/">The showdown@Haml</a>.</p>
<table align="left" border="1" cellpadding="1" cellspacing="1" height="273" width="732">
<caption>Haml VS RHTML</caption>
<tbody>
<tr>
<td>Haml</td>
<td>RHTML</td>
</tr>
<tr>
<td>- form_tag do<br>
            &nbsp; %p<br>
            &nbsp;&nbsp;&nbsp; %label{:for =&gt; "login"} Login<br>
            &nbsp;&nbsp;&nbsp; %br/<br>
            &nbsp;&nbsp;&nbsp; = text_field_tag ‘login’<br>
            &nbsp; %p<br>
            &nbsp;&nbsp;&nbsp; %label{:for =&gt; "password"} Password<br>
            &nbsp;&nbsp;&nbsp; %br/<br>
            &nbsp;&nbsp;&nbsp; = password_field_tag ‘password’<br>
            &nbsp; %p<br>
            &nbsp;&nbsp;&nbsp; %label{:for =&gt; "remember_me"} Remember me:<br>
            &nbsp;&nbsp;&nbsp; = check_box_tag ‘remember_me’<br>
            &nbsp; %p= submit_tag ‘Log in’</td>
<td>&lt;% form_tag do -%&gt;<br>
            &lt;p&gt;&lt;label for="login"&gt;Login&lt;/label&gt;&lt;br/&gt;<br>
            &lt;%= text_field_tag ‘login’ %&gt;&lt;/p&gt;
<p>            &lt;p&gt;&lt;label for="password"&gt;Password&lt;/label&gt;&lt;br/&gt;<br>
            &lt;%= password_field_tag ‘password’ %&gt;&lt;/p&gt;</p>
<p>            &lt;p&gt;&lt;label for="remember_me"&gt;Remember me:&lt;/label&gt;<br>
            &lt;%= check_box_tag ‘remember_me’ %&gt;&lt;/p&gt;</p>
<p>            &lt;p&gt;&lt;%= submit_tag ‘Log in’ %&gt;&lt;/p&gt;<br>
            &lt;% end -%&gt;</p></td>
</tr>
</tbody>
</table>
<p><br></p>















<p><br><br><br><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br>从对比中, 我们可以看出比之RHTML几个特点:</p>
<ol><li>给予缩进, 增加代码可读性(缩进可选)</li><li>well-formed markup</li><li>DRY. It’s very important!!</li></ol>

<p>So, 让我们立刻投入Haml怀抱吧~&nbsp; No, no, no, still some problems. 我们还是谨慎一点吧, 来分析一下Haml可能的潜在问题, :p</p>
<ul><li>毫无疑问Haml给开发带来了极大的效率提升, 我相信developer都能开心地接受并使用之. 但是, developer之外呢?
虽然Haml可以和RHTML, RXML混用, 但是这种混血儿就无法被我接受了..&nbsp; 所以, 对于美工/UI设计者,
Haml无法和DreamWeaver之类的网页制作工具很好的结合, 是个不好的消息.. :(</li><li>调试上的间接性. 由于Haml是被render成HTML后传送给Client. 我们能获得的所有错误信息都是基于之后的HTML页面的. 那么, 当系统庞大时, 调试难度也随之加大了. 毕竟, 我们和problem domain之间隔了一层. 更甚的是, <a href="http://haml.hamptoncatlin.com/docs/sass">SASS-&gt;CSS</a>的调试较之HAML更加复杂.</li><li>Performance. 这是最关键的. 我们可以预见到Haml在效率上较之RHTML会有所下降. Hampton的一段关于性能的言论:"<font  face="Courier, Monospaced">Pure haml is 2.7 times slower than pure erb. This is a fact. And this isn’t due to Haml being slow, just erb being REALLY fast. </font><font  face="Courier, Monospaced">However,
most of your time "rendering" in a Rails applications is spent with
your models/helpers/etc building them as the template is processed. So,
your total rendering time doesn’t increase by 2.7, just the
pure-template part which is a trivial section in the first place. I’ve
found that total page-rendering time only slows by about 2-5% when
using Haml in a real Rails application. Haml is much faster than all
the things you are doing *in* your application." 在提升Haml的性能方面, <a href="http://groups.google.com/group/haml">Haml | Google Group</a></font>上有不少讨论, 而且有不少优化的方法, 有兴趣的可以自己看看. 可以预见的是, Haml 2.0在性能上会有大量提升.&nbsp;</li></ul>

<p>另外值得一提的是, Haml虽然是为了rails而生, 但是它完全可以脱离rails独立而生. 目前, 已经有了<a href="http://sourceforge.net/projects/phphaml/">phphaml</a>. Haml只是一个非常简单的标记语言, 我们完全可以为之编写parser来建立与其他语言的关联. 评判一个软件的好处, 可以以其的port版本多少为一标准. 所以, 未来是光明的, :)</p>

<p>Haml, or not? Depent on you! If i were you, i will, i’m a lazy developer, :)</p>
<p>Ok. Let have a rest and see a site built using pure haml: <a href="http://www.projectbreakout.com/">Project Breakout</a>.</p>

    
    

   </div></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/160172007422113124328</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/160172007422113124328</guid>
    <pubDate>Tue, 22 May 2007 11:31:24 +0800</pubDate>
    <dcterms:modified>2007-05-22T11:31:24+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Google Reader Clip Client Code Review]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200741163050722</link>
    <description><![CDATA[<div><p><a href="http://sishen.lifegoo.com/?p=38" target="_blank">Google Reader Clip Client Code Review</a></p><p>我承认自己是Google的<font size="3">拥趸, :)  干净简洁的风格, 比较符合我的思想. </font><a href="http://www.google.com/reader" mce_href="http://www.google.com/reader">Google Reader</a><font size="3">就是其一.</font> 其上的附属服务, 也打上了深深的google烙印. Clip就是其一.</p>
<p>Why Google Reader Clip? <a href="http://www.google.com/reader" mce_href="http://www.google.com/reader">Google Reader</a>
lets you tag blogs and blog posts and share those items with your
friends. 简而而已, 可以把你的Feed items集成到你的个人网站里. 贴心的小服务, 又是很好的宣传手段, cool~</p>
<p>Howto? <a href="http://googlesystem.blogspot.com/2007/03/customize-google-readers-clips.html" title="customize google readers clips" mce_href="http://googlesystem.blogspot.com/2007/03/customize-google-readers-clips.html">Customize Google Reader's Clip.</a> 还有很多教程, google吧...</p>
<p>最后得到的html snippet就是:</p>
<p>本文的目的在于分析这段代码是如何工作的.</p>
<p>首先, 关注两个URL.</p>
<ul><li>http://www.google.com/reader/ui/publisher.js</li><li>http://www.google.com/reader/public/javascript/user/01965866220529097173/label/developerworks?n=5&amp;callback=GRC_p({c:\"green\",t:\"\\\"developerworks\\\"
via sishen\",s:\"false\"});new GRC</li></ul>
<p>publisher.js是被混淆过的JS, 其职责在于提供提供默认clip显示函数库. 看得我累死了... &gt;_&lt;<br>
下一个URL则是整个clip的生成脚本. 如果你细心的话, 就会发现query string里面有个callback参数. 很精妙的设计,
:) 通过callback参数值, 我们可以自主控制clip的显示方式(customize, 见前面的link). 当然, 现在默认使用的是<br>
GRC_p({c:\"green\",t:\"\\\"developerworks\\\" via sishen\", s:\"false\"}); new GRC. 而这个就是publisher.js里的object.</p>
<p>那么, 下面的主题就是publisher.js了. 一段很短小精悍的程序(其中50%是浏览器判断+异常处理). 整个核心在于GRC
object. 在介绍GRC object前,
有一点需要说明的是在clip里的item是通过http:
//www.google.com/reader/public/javascript/user/:id/label/lablename获得的.
至于怎么获得的, 不是我所关心的. 最后的形式就是<br>
GRC_p({c:"gray",t:"\"developerworks\" via sishen",s:"false"});new GRC({--item description--}).<br>
GRC_p里面的是参数配置, c为背景色, t为标题, s为显示item来源.</p>
<p>对应的代码为:</p>
<blockquote><p>function ca(a)<br>
{<br>&nbsp; u=a<br>
}<br>
function readerpublisher(a,b)<br>
{<br>&nbsp; this.id="readerpublishermodule"+this.version();<br>&nbsp; this.g = a;<br>&nbsp; this.o = u["c"];<br>&nbsp; this.p = u["t"];<br>&nbsp; this.J = u["s"]=="true";<br>&nbsp;
if(b)<br>&nbsp;
{<br>&nbsp;&nbsp;&nbsp;
b.innerHTML="";<br>&nbsp;&nbsp;&nbsp;
b.id=this.id;<br>&nbsp;&nbsp;&nbsp;
this.createTN(getElemById(this.id))<br>&nbsp; }<br>&nbsp;
else<br>&nbsp;
{<br>&nbsp;&nbsp;&nbsp;
document.write('');<br>&nbsp;&nbsp;&nbsp; var c=this;<br>&nbsp;&nbsp;&nbsp; window.setTimeout(function() {c.createTN(getElemById(c.l))}, 0)<br></p>
<div +this.id+="">&nbsp; }<br>
}</div>
</blockquote>
<p>GRC({})则根据items来生成相应的html代码. item格式为:</p>
<blockquote>
<pre>"id": "user/01965866220529097173/label/developerworks",<br>"title": "u0022developerworksu0022 via sishen in Google Reader",<br>"continuation": "CMfBw7COhIwC",<br>"author": "sishen",<br>"updated": 1178866000,<br>"items": [<br>{<br>"id": "tag:google.com,2005:reader/item/bc6a9f32df0c289b",<br>"categories": [<br>],<br>"title": "u00E5u0153u00A8 Linux on POWER u00E4u00B8u0160u00E8u00BFu203Au00E8u00A1u0152u00E5u00BAu201Du00E7u201Du00A8u00E7u00A8u2039u00E5u00BA u00E5u00BCu20ACu00E5 u2018",<br>"published": 1178866000,<br>"updated": 1178866000,<br>"alternate": {<br>"href": "http://www.ibm.com/developerworks/cn/linux/linux_app.html?cau003Ddrs-tp2007",<br>"type": "text/html"<br>},<br>"summarySnippet": "u00E5u0153u00A8 IBM System pu00E2u201Eu00A2 u00E5u2019u0152 System iu00E2u201Eu00A2 POWER u00E5u00B9u00B3u00E5 u00B0u00E4u00B8u0160u00E5u00BCu20ACu00E5 u2018u00E5u2019u0152u00E9u0192u00A8u00E7u00BDu00B2 Linuxu00C2u00AE nu00E5u00BAu201Du00E7u201Du00A8u00E7u00A8u2039u00E5u00BA u00E4u00B8u017Du00E5u0153u00A8u00E5u2026u00B6u00E4u00BBu2013 Linux u00E7u00B3u00BBu00E7u00BBu0178u00E4u00B8u0160u00E7u0161u201Eu00E5u00BCu20ACu00E5 nu2018u00E5u2019u0152u00E9u0192u00A8u00E7u00BDu00B2u00E7u203Au00B8u00E4u00BCu00BCu00E3u20ACu201Au00E5u0153u00A8u00E6u0153u00ACu00E6u2013u2021u00E4u00B8u00ADu00EFu00BCu0152u00E8u00AEu00A8u00E8u00AEu00BAu00E5u00AFu00B9u00E4u00BAu017D Linux on POWER nu00E7u00B3u00BBu00E7u00BBu0178u00E5u00BAu201Du00E8u00AFu00A5u00E4u00BAu2020u00E8u00A7u00A3u00E7u0161u201Eu00E7u203Au00B8u00E4u00BCu00BCu00E6u20ACu00A7u00E5u2019u0152u00E5u00B7u00AEu00E5u00BCu201Au00E3u20ACu201A",<br>"origin": {<br>"streamId": "feed/http://www.ibm.com/developerworks/cn/rss/dwcn_dwtp.rss",<br>"title": "IBM developerWorks u00E4u00B8u00ADu00E5u203Au00BD",<br>"htmlUrl": "http://www.ibm.com/developerworks/cn/index.html?cau003Ddrs-tp2007"<br>}]<br>}</pre>
</blockquote>
<p>ok. 切入主题. 整个clip的生成过程就是createElement和createTextNode的过程.</p>
<blockquote><p>function createElement(a,b)<br>
{<br>&nbsp; var c=document.createElement(a);<br>&nbsp; if(b)<br>&nbsp;
{<br>&nbsp;&nbsp;&nbsp;
for(var d in b)<br>&nbsp;&nbsp;&nbsp;
{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var f=b[d];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if($.q()&amp;&amp;d=="class")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d="className"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c.setAttribute(d,f)<br>&nbsp;&nbsp; }<br>&nbsp;}<br>&nbsp;return c<br>
}</p>
<p>function createTextNode(a)<br>
{<br>&nbsp;return document.createTextNode(a)<br>
}</p></blockquote>
<p>看一下例子:</p>
<blockquote><p>var h3_elem =createElem("h3");<br>
this.merge_style(c.H, h3_elem);<br>
d.appendChild(createTN(this.p));<br>
a.appendChild(h3_elem);</p></blockquote>
<p>其显示效果就是:</p>
<pre>&lt;<span>h3</span><span> style</span>=<span>"i hidden the style... it's too long"</span>&gt;"developerworks" via sishen&lt;/<!--<span -->h3&gt;</pre>
<pre>接下去是一个大循环, 遍历所有item.</pre>
<blockquote>
<pre>var f=createElem("ul");<br>for(var F=0,m;m=this.document.items[F];F++)<br>{<br>}</pre>
</blockquote>
<p>具体的为:</p>
<blockquote><p>var w=createElem("li");<br>
var G=createElem("a",{href:link(m[alternate].href),title:m[title],"class":"i"});<br>
var h=strip_tag(m[title]);<br>
if(!(strip(h)==""))<br>
{<br>&nbsp;&nbsp; h=fa(h,48)<br>
}<br>
G.appendChild(createTN(h));<br>
w.appendChild(G);<br>
f.appendChild(w)</p></blockquote>
<p>最后的生成效果为:</p>
<pre>&lt;<span>a</span><span> style</span>=<span>"</span><span>i hidden the style... it's too long</span><span>" </span><span>class</span>=<span>"i" </span><span>title</span>=<span>"Make a List and Check It Twice: A Real-World Guide for Speakers and Presenters" </span><span>href</span>=<span>"http://feeds.feedburner.com/%7Er/guykawasaki/Gypm/%7E3/115725056/make_a_list_and.html"</span>&gt;Make a List and Check It Twice: A Real-World Guide...<!--<span --></pre>
<p>基本整个publisher.js的核心就在于上面了. 当然, 还有很多辅助函数, 有兴趣的就自己看吧, :)
</p>
</div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200741163050722</comments>
    <slash:comments>4</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200741163050722</guid>
    <pubDate>Fri, 11 May 2007 18:30:50 +0800</pubDate>
    <dcterms:modified>2007-05-11T18:33:53+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[如果]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200702852043869</link>
    <description><![CDATA[<div>如果一个公司实行这种策略: 奖励每月bug最少的程序员. 这种外在激励能获得多少成效? 或者, 能带来多大的危害?<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200702852043869</comments>
    <slash:comments>6</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200702852043869</guid>
    <pubDate>Sun, 28 Jan 2007 17:20:43 +0800</pubDate>
    <dcterms:modified>2007-01-28T17:20:43+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[Wikiasari, 值得期待]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/160172006113132120991</link>
    <description><![CDATA[<div><a href="http://sishen.lifegoo.com/?p=31" rel="bookmark">Wikiasari: 值得期待</a><br><br>最近Search方面比较注目的新闻应该当属Wikipedia创始人Jimme Wales吐露出将在来年里开始一个新的搜索引擎的项目. 个人认为, 这个对Google是个大挑战.<br><br>Jimme自已也把目标指向了Google:<br><div style="margin-left: 40px;">“Google is very good at many types of search, but in many instances it
produces nothing but spam and useless crap. Try searching for the term
‘Tampa hotels’, for example, and you will not get any useful
results…Essentially, if you consider one of the basic tasks of a search
engine, it is to make a decision: ‘this page is good, this page sucks.’
Computers are notoriously bad at making such judgments, so algorithmic
search has to go about it in a roundabout way…But we have a really
great method for doing that ourselves. We just look at the page. It
usually only takes a second to figure out if the page is good, so the
key here is building a community of trust that can do that.”<br></div>从这里我们不难看出, 他关注的是Search Quality, 而这也是目前的搜索比较缺乏的. 有调查显示, 目前互联网上的搜索, 有60%以上是属于Q&amp;A的. 用户的条件是为了找到对应的最精确的答案. 而Wikipedia在这方面具有很大优势, 因为一来其特点就是有针对Q&amp;A的特性, 而来其上所构建的community, 会对page进行很好的人工筛选. 以Wikipedia自身作为入口, 然后扩展出去, 就算depth不深, 我们也可以保证获得的都是高质量的搜索结果. <br><br>Quality first, depth second. 诚如Jimme所言, Google的问题在于PageRank只计算网页流程度, 却无法分辨具有该流行度的网页是属于good, 还是sucks. 在如何给出真正优质的流程网页这点上, 还需要很多的工作要做. 值得一提的是, HTML4里加了一个很有意思的属性: Vote Link. 其大概意思就是在目前的链接标签的基础上, 让网页程序员通过Vote属性来给链接评价: "vote-for" "vote-abstain" or "vote-against". 具体的内容可以参照这里: <a href="http://microformats.org/wiki/vote-links" target="_blank">Vote Link</a>. 当然, Vote Link要流行起来可能还需要一段时间, 但是至少我们可以看到这方面开始越来越受到关注.<br><br>Wikiasasi, 绝对是2007年一个值得期待的开源产品.<br></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/160172006113132120991</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/160172006113132120991</guid>
    <pubDate>Sun, 31 Dec 2006 03:21:20 +0800</pubDate>
    <dcterms:modified>2006-12-31T03:21:20+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ Use ant to send file to remote automatically]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/160172006112932947825</link>
    <description><![CDATA[<div><h3  ><a href="http://sishen.lifegoo.com/?p=30" rel="bookmark">
      Use ant to send file to remote automatically</a></h3><p>最近一直在做测试, 需要把自己的程序扔到远程服务器上执行. 于是, 在起初的阶段, 我每次都非常痛苦地打一堆字”scp -P xx  file user@host:/some/dir”, 让人接近崩溃.. -,-</p>
<p>痛定思痛, 决定来自动化这个过程. 所以直接把目光投向了Ant, 一个强大的构建工具. Ant是伟大的, :) 它提供了remote task, 支持通过ftp/scp/sshexec等任务来完成远程操作. 我下面将针对scp task.</p>
<p>Scp task是Ant的一个optional task, 所以要运行这个task, 首先需要解决dependencies — jsch(java对ssh2的实现).  注: jsch需要0.1.29以上版本.  可以去<a title="Jsch Homepage" href="http://www.jcraft.com/jsch/index.html">Jsch主页</a>下载.</p>
<p>关于Scp task的每个parameters的用法, 我这里就不累赘了. 可以去<a title="Ant Homepage" href="http://ant.apache.org/manual/index.html">Ant主页</a>上查看. 我下面就给出几个简单的例子.</p>
<p><strong>Copy a remote directory to a local directory</strong></p>
<p>&lt;scp file=”user:pass@host:/home/sishen/*” todir=”/home/sishen”/&gt;</p>
<p><strong>Copy a single local file to a remote machine with separate password attribute</strong></p>
<p>&lt;scp file=”file” todir=”user@host:/home/sishen” password=”pass”/&gt;</p>

<p><strong>Copy a single local file to a remote machine using key base authentication.</strong></p>
<blockquote><p>&lt;scp  file=”myfile.txt”<br>&nbsp;&nbsp;&nbsp;&nbsp; todir=”user@somehost:/home/chuck”<br>&nbsp;&nbsp;&nbsp;&nbsp; keyfile=”${user.home}/.ssh/id_dsa”<br>&nbsp;&nbsp;&nbsp;&nbsp; passphrase=”my extremely secret passphrase”/&gt;</p></blockquote>

<p>在这基础上, 你还可以用FileSet, DirSet, FileList来group要传送的文件. 比如</p>
<blockquote><p>&lt;scp todir=”xxx@xxx:~/xxx”<br>&nbsp;&nbsp;&nbsp;&nbsp; port=”22″<br>&nbsp;&nbsp;&nbsp;&nbsp; keyfile=”${user.home}/.ssh/id_rsa”<br>&nbsp;&nbsp;&nbsp;&nbsp; passphrase=”xxxx”&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;fileset dir=”lib”&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;include &nbsp;&nbsp;&nbsp; &lt;exclude &lt;/fileset&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;fileset dir=”${build.dir}”&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;include &lt;/fileset&gt;<br>
&lt;/scp&gt;</p></blockquote>
<p>这里也引进了一个问题.  密码是以明文的形式直接显示的,  而这却是我们无法接受的. 针对这个, 我们有3种解决方法.</p>
<ol><li>通过command argument来输入密码. 比如ant -Dpassphrase=xxxxx.</li><li>把passphrase=xxx存储在文件里, 设置权限为600. 然后ant -propertyfile 来获取密码.</li><li>通过input task. 由用户交互输入密码.</li></ol>
<p>从 安全性考虑, 只有方法3才是让我满意. 然而, 使用方法3, 你又将面临一个问题, 密码输入过程是明文的.
这是则是InputHandler的决策. 当不指定InputHandler, ant将使用DefaultInputHandler,
而DefaultInputHandler则是读取用户输入, 然后显示在console上. 那么, 解决的方法也就明了了.
我们需要实现一个MaskPasword的InputHandler. 关于这个, 已经有实现了.
其中心思想是设置InputStream为System.err(即取消buffer),
然后读取用户输入,读到一个就用\b*(backspace+*)来代替.</p>
<p>下面是我的一个完整的应用. 我用了单独的target.</p>
<blockquote><p>&lt;target depends=”jars” description=”send  file to remote server”&gt;<br>
&lt;echo level=”warning” message=”send file through ssh ing”/&gt;<br>
&lt;input message=”Enter passphrase for key ‘${user.home}/.ssh/id_rsa’” addproperty=”passphrase”/&gt;<br>
&lt;scp file=”${build.dir}/${app.jar}”<br>&nbsp;&nbsp;&nbsp;&nbsp; todir=”user@host:~/dir/”<br>&nbsp;&nbsp;&nbsp;&nbsp; port=”22″<br>&nbsp;&nbsp;&nbsp;&nbsp; keyfile=”${user.home}/.ssh/id_rsa”<br>&nbsp;&nbsp;&nbsp;&nbsp; passphrase=”${passphrase}”<br>&nbsp;&nbsp;&nbsp;&nbsp; trust=”yes”/&gt;<br>
&lt;/target&gt;</p></blockquote>
<p>这里有一点要注意, 就是trust=”yes”. 这个是表示接受所有unknown的host.
Jsch只支持SSHV2的known_host. 而Openssh在knows_host文件里, 对host进行了hash,
所以造成每次匹配不成功, 因而使用openssh的客户端, 必须得加上trust=”yes”.</p>
<p>自此以后,  轻松了. 只要运行ant remote -inputhandler org.apache.tools.ant.input.PasswordInputHandler, 输入密码, 所以要传送的文件就会乖乖的到远方去了…  如果嫌麻烦的话, 把remote设为default…</p>
<p><strong>Resource:</strong></p>
<ul><li><a title="PasswordInputHandler" href="http://sishen.lifegoo.com/wp-content/uploads/2006/12/extendinput.jar">extendinput.jar</a>:   PasswordInputHandler的jar包</li></ul></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/160172006112932947825</comments>
    <slash:comments>1</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/160172006112932947825</guid>
    <pubDate>Fri, 29 Dec 2006 15:29:47 +0800</pubDate>
    <dcterms:modified>2006-12-29T15:29:47+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[ 在线协同开发, 你用什么?]]></title>	
    <link>http://blog.163.com/sishen_freecity/blog/static/16017200611225028790</link>
    <description><![CDATA[<div><h3  ><a href="http://sishen.lifegoo.com/?p=29" rel="bookmark">
      在线协同开发, 你用什么?</a></h3><p>在软件开发工程中, 如何提高协同开发的效率是关键. 一个好的平台, 给生产力带来的提高绝对不止一倍两倍. 网络的普及,
使得传统的会议式协同合作, 已经满足不了需求, 在线协同开发逐渐成为了项目管理的主流方式. 尤其是Open Source的流行,
给协同开发带来了很多新的模式, 也出现了很多优秀的开源在线协同开发工具.</p>
<p>在我看来, 一个合适的协同开发平台, 至少应该包括source control system, issue tracking system,  bug tracking system, 还有是团队的交流平台.</p>
<p>SVN/CVS作为SCM, 为协同开发提供了很好的代码控制系统. 基本上, 在VC方面, 这个不大有改变.</p>
<p>很多时候, issue tracking system和bug tracking system可以重用(当然, 从细致上讲,
独立为好). 一个bug也算是一个defect issue. 目前, 应用比较广泛的如Bugzilla, trac,
roundup都是不算的工具.</p>
<p>交流平台也有很多工具. 从原始的EMail, 到Maillist/Group/Forum/IM, 进而Wiki/IRC, 都是不错的创新. Maillist/Wiki之类, 缺少实时性; IM/IRC则缺少点沉淀. 如何合理使用也是一门学问.</p>
<p>推荐一个工具, 呵呵. 最近一直在用trac. 觉得是一个很不错的在线协同开发工具. 它集成了wiki/issue tracking system/svn. 使用简单, 功能强大.  有兴趣的自己google, <img src="http://sishen.lifegoo.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" > </p>
<p>总之, 一切用了程序员的偷懒, <img src="http://sishen.lifegoo.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" > </p>
<p>在线协同开发, 你用什么?</p>
<p>ps: 有些online的在线协同开发平台, 如SourceForage, Basecamp, 也是不错的选择喔, <img src="http://sishen.lifegoo.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" >
</p></div>]]></description>
	    <author><![CDATA[sishen]]></author>
	    <comments>http://blog.163.com/sishen_freecity/blog/static/16017200611225028790</comments>
    <slash:comments>2</slash:comments>
    <guid isPermaLink="true">http://blog.163.com/sishen_freecity/blog/static/16017200611225028790</guid>
    <pubDate>Fri, 22 Dec 2006 17:00:28 +0800</pubDate>
    <dcterms:modified>2006-12-22T17:00:28+08:00</dcterms:modified>
  </item>    
  <item>
  	<title><![CDATA[我的密友]]></title>	
    <link></link>
    <description><![CDATA[<div>
			<a href="http://blog.163.com/birdlet_zju/" target="_blank"><img src="http://ava.blog.163.com/photo/qWCWs4y81Z9dDw6M5CdpLQ==/1483373127265310348.jpg" border="0" />小鸟！！</a>
			<a href="http://tianchunbinghe.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/Ri7eCBCBgSRA0p-6N2TgJg==/169166461003771609.jpg" border="0" />氷河</a>
			<a href="http://bezy1985.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/g48m7u4HhXbD6HATKrkpyw==/176766285374628486.jpg" border="0" />B.E.</a>
			<a href="http://erathem.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/VTSq5tDvRkyKzM63gEX7ZQ==/3148860564462206740.jpg" border="0" />紫</a>
			<a href="http://butyy.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/h9o5_UrE5qhXvRJCwK4xBg==/909727124728847246.jpg" border="0" />绿茶</a>
			<a href="http://leedsmark.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/Gv9kTuoznm6Iv2naLvy2uA==/3113957667350137418.jpg" border="0" />leedsmark</a>
			<a href="http://ryanwool.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/2GQOWc4an93BtZxeDMLxbA==/425590164786670370.jpg" border="0" />雨衣</a>
			<a href="http://joyous.peng.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/s2NTuIF6yO9dwahwlcFYaw==/219831956811024807.jpg" border="0" />joyous</a>
			<a href="http://smamonkey.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/EL2k5gH3Lo-qWN7NwVt87Q==/431782614275664804.jpg" border="0" />smamonkey</a>
			<a href="http://luoyan5.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/GJFq-y87KQzVHSQKhjhIRg==/4504444052300745520.jpg" border="0" />luohandsome</a>
			<a href="http://loveconnie84.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/r4Zp0TTlbXWko3MAUg2hyQ==/4569746246897501844.jpg" border="0" />loveconnie</a>
			<a href="http://zealot0630.blog.163.com/" target="_blank"><img src="http://ava.blog.163.com/photo/bVRIPqB6YKH8vzkGFva-3g==/1440307455828426788.jpg" border="0" />zealot0630</a>
</div>]]></description>
    <guid isPermaLink="false">http://blog.163.com/sishen_freecity/friends</guid>
    <pubDate>Tue, 1 Jan 2008 00:00:00 +0800</pubDate>
    <dcterms:modified>2008-01-01T00:00:00+08:00</dcterms:modified>
  </item>    
 </channel>
</rss>