<?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>I&#039;m Donkey</title>
	<atom:link href="http://imdonkey.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://imdonkey.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 09 Jul 2010 15:58:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>初识PHP中的闭包</title>
		<link>http://imdonkey.com/blog/archives/526</link>
		<comments>http://imdonkey.com/blog/archives/526#comments</comments>
		<pubDate>Fri, 09 Jul 2010 15:58:31 +0000</pubDate>
		<dc:creator>luoxi</dc:creator>
				<category><![CDATA[坨坨胡同儿]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=526</guid>
		<description><![CDATA[闭包的概念早已应用在其他某些编程语言中，而且使用的人越来越多，可见大家对函数式编程的喜爱。PHP从5.3后也开始支持闭包，此文就简单介绍一下PHP中闭包的实现。由于本人对闭包的理解和应用水平不高，所以疏漏误解之处请多多包涵并指正 <img src='http://imdonkey.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />
首先来看看这两个概念：Lambda和Closure，其实说它们是“两个”概念有些不合适，Lambda是Closure的基础，两者都是匿名方法，只是使用时略有不同。
引用一下网上的介绍：
Lambda函数（通常所谓的匿名函数）简单来说就是一次性函数，可以在任何时候定义，且经常赋值给一个变量。函数自身和对应变量处于同一个作用域内，当离开变量的作用域后，该函数也将消亡，Lambda不保存任何状态。
闭包(Closure)是指一个可以在自己环境中执行的函数，调用时可以访问已经绑定的变量。它们来源于函数式编程世界，在那里有非常多的应用。闭包和Lambda函数类似，但是闭包还可以和定义时指定的外部变量交互。
我们可以简单地理解为Closure可以访问父级视野（parent scope）定义的变量，而Lambda不行。
下面举个例子来说明，比如我想对某一数组的每个元素追加<p class='read-more'><a href='http://imdonkey.com/blog/archives/526'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>闭包的概念早已应用在其他某些编程语言中，而且使用的人越来越多，可见大家对函数式编程的喜爱。PHP从5.3后也开始支持闭包，此文就简单介绍一下PHP中闭包的实现。由于本人对闭包的理解和应用水平不高，所以疏漏误解之处请多多包涵并指正 <img src='http://imdonkey.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /><br />
首先来看看这两个概念：Lambda和Closure，其实说它们是“两个”概念有些不合适，Lambda是Closure的基础，两者都是匿名方法，只是使用时略有不同。</p>
<p>引用一下网上的介绍：</p>
<blockquote><p>Lambda函数（通常所谓的匿名函数）简单来说就是一次性函数，可以在任何时候定义，且经常赋值给一个变量。函数自身和对应变量处于同一个作用域内，当离开变量的作用域后，该函数也将消亡，Lambda不保存任何状态。</p>
<p>闭包(Closure)是指一个可以在自己环境中执行的函数，调用时可以访问已经绑定的变量。它们来源于函数式编程世界，在那里有非常多的应用。闭包和Lambda函数类似，但是闭包还可以和定义时指定的外部变量交互。</p></blockquote>
<p>我们可以简单地理解为Closure可以访问父级视野（parent scope）定义的变量，而Lambda不行。<br />
下面举个例子来说明，比如我想对某一数组的每个元素追加一个字符后缀，后缀的内容作为参数传递给函数。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Lambda实现代码：</span>
<span style="color: #7F0055; font-weight: bold;">function</span> appendPostfix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #000000;">,</span> <span style="color: #000088;">$postfix</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$anonyFun</span> <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #000000;">,</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #7F0055;">return</span> <span style="color: #000088;">$e</span><span style="color: #000000;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #000000;">.</span><span style="color: #000088;">$p</span><span style="color: #000000;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000;">;</span>
	<span style="color: #7F0055;">return</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$anonyFun</span><span style="color: #000000;">,</span> <span style="color: #000088;">$array</span><span style="color: #000000;">,</span> <span style="color: #990000;">array_fill</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #000000;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">,</span> <span style="color: #000088;">$postfix</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>由于Lambda不能直接调用$postfix变量，所以只好对匿名函数多加个参数，并在调用array_map时将$postfix作为callback参数再次传递一次。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Closure实现代码：</span>
<span style="color: #7F0055; font-weight: bold;">function</span> appendPostfix<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #000000;">,</span> <span style="color: #000088;">$postfix</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$anonyFun</span> <span style="color: #000000;">=</span> <span style="color: #7F0055; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> use<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postfix</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #7F0055;">return</span> <span style="color: #000088;">$e</span><span style="color: #000000;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #000000;">.</span><span style="color: #000088;">$postfix</span><span style="color: #000000;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000;">;</span>
	<span style="color: #7F0055;">return</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$anonyFun</span><span style="color: #000000;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>通过使用use关键字，将$postfix传入匿名函数（值传递），于是代码简洁了许多。这里只是说明一下闭包的应用，当然可以通过其他方式实现此功能。</p>
<p>那么对于PHP语言来讲使用闭包都有哪些好处：<br />
1. 代码简洁<br />
不用将函数定义在其他地方，提高代码可读性。也不用为避免函数名重复而而额外添加诸如“if(!function_exists(&#8216;xxx&#8217;))” 的判断。如果你留意Ruby或Python的代码，会惊讶地发现其简洁的风格和直观的可读性。虽然目前PHP的闭包还达不到那些动态语言的水平，但毕竟是向那个方向所作出的第一步尝试。</p>
<p>2.性能<br />
如果按照以前的办法动态定义一个函数(利用create_function)，会有几点不足：由于都是字符串形式，一般IDE无法实现语法高亮；还有就是动态函数是在运行期编译的，而非编译期，所以不能通过<a href="http://blog.csdn.net/laruence/archive/2008/07/18/2673488.aspx">opcode</a>来缓存优化性能。</p>
<p>相对的，PHP的闭包有哪些缺点或者说不足：<br />
1. 留意内存泄露<br />
先看一段简单的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #7F0055; font-weight: bold;">function</span> increase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$x</span> <span style="color: #000000;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #000000;">;</span>
	<span style="color: #7F0055;">return</span> <span style="color: #7F0055; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> use <span style="color: #009900;">&#40;</span><span style="color: #000000;">&amp;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #7F0055;">return</span> <span style="color: #000088;">$x</span><span style="color: #000000;">++;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$f</span> <span style="color: #000000;">=</span> increase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #000088;">$r</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$f</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$r</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$f</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>increase方法中的$x是函数局部变量，但是在执行完$f = increase()后并没有被释放掉，因为返回的闭包一直保留着对其的引用。所以在程序输出结果中$x的值会不断递增。这说成是需要注意的地方，不如视为一种编程技巧，我们可以利用这种特性延长函数内部变量的生命周期，相当于在闭包中定义了一个全局的静态变量。</p>
<p>2. 局限<br />
直到5.3.2，PHP的闭包中还<a href="http://wiki.php.net/rfc/closures/removal-of-this">不能直接使用$this</a>，需要先将$this赋给一个临时变量，再通过这个临时变量操纵$this，比如：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #7F0055; font-weight: bold;">class</span> Foo
<span style="color: #009900;">&#123;</span>
    <span style="color: #7F0055; font-weight: bold;">private</span> <span style="color: #000088;">$x</span> <span style="color: #000000;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #000000;">;</span>
    <span style="color: #7F0055; font-weight: bold;">private</span> <span style="color: #7F0055; font-weight: bold;">function</span> f<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #7F0055;">return</span> <span style="color: #cc66cc;">15</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    <span style="color: #7F0055; font-weight: bold;">public</span> <span style="color: #7F0055; font-weight: bold;">function</span> getClosureUsingPrivates<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$self</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$this</span><span style="color: #000000;">;</span> <span style="color: #666666; font-style: italic;">//注意这行</span>
        <span style="color: #7F0055;">return</span> <span style="color: #7F0055; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> use <span style="color: #009900;">&#40;</span><span style="color: #000088;">$self</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #7F0055;">return</span> <span style="color: #000088;">$self</span><span style="color: #000000;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #000000;">*</span> <span style="color: #000088;">$self</span><span style="color: #000000;">-&gt;</span><span style="color: #004000;">f</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>当然，闭包还有很多特性和应用可以挖掘，借鉴下网上总结的常用闭包应用：重构、定制、遍历集合、管理资源、实施策略。<br />
以后可以考虑多使用闭包的形式，以此来学习和体验闭包带来的不同体验。</p>
<p>部分参考文章：<br />
<a href="http://wiki.php.net/rfc/closures"> Lambda functions and closures</a><br />
<a href="http://www.phpv.net/html/1703.html">谈PHP 闭包特性在实际应用中的问题</a></p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/526/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>倔倔死磕Javascript之放大镜</title>
		<link>http://imdonkey.com/blog/archives/478</link>
		<comments>http://imdonkey.com/blog/archives/478#comments</comments>
		<pubDate>Sun, 09 May 2010 13:49:30 +0000</pubDate>
		<dc:creator>Ting</dc:creator>
				<category><![CDATA[倔倔在前端]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[事件]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=478</guid>
		<description><![CDATA[<div id="_mcePaste">上次我已经预告了下一个要用javascript实现的是放大镜效果~</div>
<div id="_mcePaste">最开始是在<a href="http://ued.taobao.com/blog/about/" target="_blank">淘宝UED官方博客</a>上看到的.觉得很不错,以为是flash. F12一下才知道是js实现的.当时没具体看,现在开始学javascript了,突然想到这个效果,决定挑战一下哈~开始吧~</div>
<h2>Mockup</h2>
<a href="http://www.imdonkey.com/demo/img_zoomout.html" target="_blank"><img class="alignnone size-full wp-image-477" title="javascript_demo_mockup_2" src="http://imdonkey.com/blog/wp-content/uploads/2010/05/javascript_demo_mockup_2.jpg" alt="" width="508" height="496" /></a><p class='read-more'><a href='http://imdonkey.com/blog/archives/478'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>上次我已经预告了下一个要用javascript实现的是放大镜效果~</p>
<p>最开始是在<a href="http://ued.taobao.com/blog/about/" target="_blank">淘宝UED官方博客</a>上看到的.觉得很不错,以为是flash. F12一下才知道是js实现的.当时没具体看,现在开始学javascript了,突然想到这个效果,决定挑战一下哈~开始吧~</p>
<h2>Mockup</h2>
<p><a href="http://www.imdonkey.com/demo/img_zoomout.html" target="_blank"><img class="alignnone size-full wp-image-477" title="javascript_demo_mockup_2" src="http://imdonkey.com/blog/wp-content/uploads/2010/05/javascript_demo_mockup_2.jpg" alt="" width="508" height="496" /></a></p>
<h2>第一步:HTML&amp;CSS</h2>
<p>先不要着急写代码,先要考虑考虑实现这个效果对于代码结构上有什么特别的要求,我想到了两个方案:</p>
<p>1.一个小图容器,一个放大镜容器.<span style="color: #ff6600;">原图做为放大镜容器的背景</span></p>
<p>2.一个小图容器,一个放大镜容器.<span style="color: #ff6600;">原图做为放大镜子容器</span></p>
<p>这两个方案其实实现起来差别不大,但是考虑到将来图片有可能是动态读取出来的,而且大小不定,所以我们不推荐放在CSS背景中来实现,最后选择第二种方案.</p>
<p>HTML代码片段如下:</p>
<pre class="brush: xml;">
&lt;div onMouseMove=&quot;imgZoomOut(event)&quot; id=&quot;smallImgCon&quot;&gt;
	&lt;img src=&quot;img/airport_small_1.jpg&quot; id=&quot;smallImg&quot;/&gt;
	&lt;div id=&quot;magnifierCon&quot; style=&quot;display:none&quot;&gt;
		&lt;img src=&quot;img/magnifier.png&quot; id=&quot;magnifierBg&quot;/&gt;
		&lt;img src=&quot;img/airport_large_1.jpg&quot; id=&quot;largeImg&quot;/&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>CSS代码片段如下:</p>
<pre class="brush: css;">
#smallImgCon {position:relative;left:0;top:0;}
#magnifierCon {height:276px;width:276px;position:absolute;overflow:hidden;z-index:3}
	#magnifierCon img#magnifierBg {position:absolute;z-index:2}
	#magnifierCon img#largeImg {position:absolute;z-index:1}
</pre>
<h2>第二步:准备好我们需要的信息</h2>
<p>我们暂且不去考虑图片大小不定这样一种情况,我们目前可以只针对这其中一张图片.只是放大镜大小固定而已.这里我使用的大小是276*276.<br />
大致思路是可以通过下图来了解:</p>
<p><a href="http://imdonkey.com/blog/wp-content/uploads/2010/05/magnifier_model_eg.gif"><img class="alignnone size-full wp-image-477" title="magnifier_model_eg" src="http://imdonkey.com/blog/wp-content/uploads/2010/05/magnifier_model_eg.gif" alt="" /></a></p>
<p>Step1.得到小图所在位置,即坐标,并将其做为原点.<br />
Step2.得到鼠标当前所在位置,这里是指相对于原点的,所以需要减去上一步得到的坐标值.<br />
Step3.有了这个距离,再减去放大镜长宽的一半就得到了放大镜的坐标.即它相对于原点的距离.<br />
<span style="color: #ff6600;">Step4.关键一步大图如何定位呢?</span><br />
这里需要注意的是这几个容器的层级关系:最外层容器是爷爷,放大镜与小图同是兄弟俩,大图是孙子(哈哈~~不是骂人哈)<br />
说白了就是将光标与原点之间的距离*缩放比例=相对应的大图坐标<br />
再减去放大镜宽高一半就得到了超出放大镜的那段距离 也就是大图相对于其父级容器(放大镜)的距离.将这两个值的赋给大图的left,top就基本搞定了~~<br />
大家晕不?呵呵 我都有点儿晕了&#8230;思路及表达能力有待进一步提高 <img src='http://imdonkey.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>那么按照以上步骤写代码吧:<br />
主要代码如下</p>
<pre class="brush: jscript;">
	var smallImgCon = document.getElementById(&quot;smallImgCon&quot;);
	var smallImg = document.getElementById(&quot;smallImg&quot;);
	var magnifierCon = document.getElementById(&quot;magnifierCon&quot;);
	var magnifierBg = document.getElementById(&quot;magnifierBg&quot;);
	var largeImg = document.getElementById(&quot;largeImg&quot;);

	function imgZoomOut(event) {

		//Step 1得到小图位置,即原点.
		smallImgConLocationX = smallImgCon.offsetLeft;
		smallImgConLocationY = smallImgCon.offsetTop;

		//Step2.得到光标相对于原点的坐标值.
		x = event.clientX - smallImgConLocationX;
		y = event.clientY - smallImgConLocationY;

		//Step3.放大镜相对于原点的距离.
		magnifierCon.style.left = x - magnifierWidth/2 + &quot;px&quot;;
		magnifierCon.style.top = y - magnifierHeight/2 + &quot;px&quot;;

		//Step4.大图定位
		x = - x*(largeImgWidth/smallImgWidth) + magnifierWidth/2;
		y = - y*(largeImgWidth/smallImgWidth) + magnifierHeight/2;

		largeImg.style.left = x + &quot;px&quot;;
		largeImg.style.top = y + &quot;px&quot;;

	}
</pre>
<p>写到这里基本结构有了,但还有一些问题需要考虑:</p>
<ol>
<li>鼠标移到图像外面了怎么办?</li>
<li>如何动态得到各个元素的大小,便于将来扩展呢?</li>
</ol>
<p>于是我们要添加另外两个函数跟一个条件判断:</p>
<pre class="brush: jscript;">
	function getImageSize(imageEl) {
		var i = new Image();
		i.src = imageEl.src;
		return new Array(i.width, i.height);
	}
	function dispear() {
		magnifierCon.style.display = &quot;none&quot;;
	}
	if ( x &lt; 0 || x &gt; smallImgWidth || y &lt; 0 || y &gt; smallImgHeight) {
		dispear();
	}else {
		...
	}
</pre>
<p><a href="http://www.imdonkey.com/demo/img_zoomout.html" target="_blank">最终效果演示</a><br />
小提示:大小图最后比例差别大些 这样效果更好更明显~<br />
再次强调,因为是初学,所以代码还有很多地方需要优化,再小的功能也要不断完善,倔倔会在学习中不断完善之前的练习~希望大家能多多帮助倔倔~~:)</p>
<h2>知识点总结:</h2>
<ol>
<li>函数之间的调用</li>
<li>数组的定义</li>
<li>鼠标事件的概念</li>
</ol>
<h2>下期预告:图片浏览+放大镜</h2>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/478/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>PHP简单实现：阿拉伯数字-&gt;汉字</title>
		<link>http://imdonkey.com/blog/archives/504</link>
		<comments>http://imdonkey.com/blog/archives/504#comments</comments>
		<pubDate>Fri, 07 May 2010 14:15:16 +0000</pubDate>
		<dc:creator>luoxi</dc:creator>
				<category><![CDATA[坨坨胡同儿]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/archives/504</guid>
		<description><![CDATA[<div id="_mcePaste">
<div id="_mcePaste">数字转汉字，如：123 转为 一百二十三。这种需求遇到的时候不多，但，我还是遇到了</div>
<div id="_mcePaste">闲话不多说，直接上代码：</div>
</div><p class='read-more'><a href='http://imdonkey.com/blog/archives/504'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>数字转汉字（只支持整数），这种需求遇到的时候不多，但，我还是遇到了<br />
闲话不多说，直接上代码：</p>
<pre class="brush: php;">
&lt;?php
/*
数字转汉字
如：123 转为 一百二十三
*/
function num2str($num) {
	if(!is_numeric($num)) return false;

	$ret = '';
	if($num &lt; 0) {
		$ret = '负';
		$num = -$num;
	}

	$zhNumArray = array(
		&quot;1&quot; =&gt; &quot;一&quot;,
		&quot;2&quot; =&gt; &quot;二&quot;,
		&quot;3&quot; =&gt; &quot;三&quot;,
		&quot;4&quot; =&gt; &quot;四&quot;,
		&quot;5&quot; =&gt; &quot;五&quot;,
		&quot;6&quot; =&gt; &quot;六&quot;,
		&quot;7&quot; =&gt; &quot;七&quot;,
		&quot;8&quot; =&gt; &quot;八&quot;,
		&quot;9&quot; =&gt; &quot;九&quot;,
		&quot;0&quot; =&gt; &quot;零&quot;,
	);

	$bitStrArray = array(
		&quot;1&quot; =&gt; &quot;&quot;,
		&quot;10&quot; =&gt; &quot;十&quot;,
		&quot;100&quot; =&gt; &quot;百&quot;,
		&quot;1000&quot; =&gt; &quot;千&quot;,
		&quot;10000&quot; =&gt; &quot;万&quot;,
		&quot;100000000&quot; =&gt; &quot;亿&quot;,
	);

	$prebit = 0;//上次记录的位数
	krsort($bitStrArray);
	foreach($bitStrArray as $bit =&gt; $name) {
		$bit = floatval($bit);
		if($num &gt;= $bit) {
			$tmpNum = floor($num / $bit);
			if($tmpNum &gt;= 10) {
				$tmpRet = num2str($tmpNum);
				$ret .= $tmpRet . $name;
			} else {
				if($prebit/$bit &gt; 10) {//按照中文习惯补零
					$ret .= '0';
				}
				$ret .= $tmpNum . $name;
			}
			$prebit = $bit;
			$num = fmod($num, $bit);//取模
		}
	}

	$ret = str_replace(array_keys($zhNumArray), array_values($zhNumArray), $ret);
	return $ret;
}

$test = '1234567890';
echo num2str($test);
?&gt;
</pre>
<p>这段代码算不上优美，可读性还凑合，bug肯定会有（那还展示出来干嘛呀- -!）。但我还是幻想万一对人能有所帮助呢，或者引来某个迷路的高手指点一二，都算是件好事。</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/504/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP简单实现中文分词——二分法</title>
		<link>http://imdonkey.com/blog/archives/500</link>
		<comments>http://imdonkey.com/blog/archives/500#comments</comments>
		<pubDate>Fri, 07 May 2010 14:06:41 +0000</pubDate>
		<dc:creator>luoxi</dc:creator>
				<category><![CDATA[坨坨胡同儿]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[分词]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=500</guid>
		<description><![CDATA[<div id="_mcePaste">
<div id="_mcePaste">二分法是一种简单的中文分词方法，其原理就是把中文字符串按两个字进行切分，如“imdonkey的主人要发奋了”，拆分完就是“imdonkey/的主/主人/人要/要发/发奋/奋了”。当然，为了更好的被搜索引擎利用，现实项目中还会对结果进一步处理，这里就不多说了，因为作者本人目前也不懂呢。</div>
<div id="_mcePaste"></div>
<div id="_mcePaste">好，闲话不多说，直接上代码：</div>
</div><p class='read-more'><a href='http://imdonkey.com/blog/archives/500'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>二分法是一种简单的中文分词方法，其原理就是把中文字符串按两个字进行切分，如“imdonkey的主人要发奋了”，拆分完就是“imdonkey/的主/主人/人要/要发/发奋/奋了”。当然，为了更好的被搜索引擎利用，现实项目中还会对结果进一步处理，这里就不多说了，因为作者本人目前也不懂呢。</p>
<p>好，闲话不多说，直接上代码：</p>
<pre class="brush: php;">
&lt;?php
/*
*功能：对于输入的内容按照二分法规则进行分词，遵循以下规则
*实例：imdonkey的主人要发奋了
*结果：imdonkey 的主 主人 人要 要发 发奋 奋了
*/

function binary_split($str) {
	$ret = array();
	$preword = '';
	$preischinese = false;
	for($i = 0; $i &lt; strlen($str); $i++) {
		$cur = $str[$i];
		if(ord($cur) &gt; 0x80) {
			// current is chinese
			if(!empty($preword)) {
				if($preischinese){
					// preword is chinese
					if(strlen($preword) == 4) {
						$ret[] = $preword.$cur;
						$preword = substr($preword, 2);
					}

				} else {
					// preword is non-chinese
					$ret[] = $preword;
					$preword = '';
				}
			}
			$preword .= $cur;
			$preischinese = true;

		} else {
			// current is non-chinese
			if(!empty($preword)) {
				if($preischinese){
					// preword is chinese
					$ret[] = $preword;
					$preword = '';

				} else {
					// preword is non-chinese

				}
			}
			$preword .= $cur;
			$preischinese = false;
		}

	}//end for
	if(!empty($preword)) $ret[] = $preword;

	return $ret;
}

$test = 'imdonkey的主人要发奋了';
print_r(binary_split($test));
?&gt;
</pre>
<p>这段代码算不上优美，可读性还凑合，bug肯定会有（那还展示出来干嘛呀- -!）。但我还是幻想万一对人能有所帮助呢，或者引来某个迷路的高手指点一二，都算是件好事。</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/500/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>倔倔跟风学Vim(2)-vimtutor</title>
		<link>http://imdonkey.com/blog/archives/450</link>
		<comments>http://imdonkey.com/blog/archives/450#comments</comments>
		<pubDate>Thu, 06 May 2010 04:28:37 +0000</pubDate>
		<dc:creator>Ting</dc:creator>
				<category><![CDATA[倔倔在前端]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[vimtutor]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=450</guid>
		<description><![CDATA[安装过后就要开始熟悉Vim那些强大的命令了,一直看中文手册也不是办法,没有实践根本记不住.好在vim自带一个简单的入门教程,可以通过边看边练习的方式在半小时内掌握vim基本的命令.
在windows下要运行安装根目录下的vimtutor.bat.打开的文件默认就是一个副本,所以你可以尽情地在上面练习修改.
倔倔现在就要开始练习啦~哈
&#8230;
过了一遍vimtutor确实感觉不错~,好多命令都非常吸引人,我已经感觉到了熟练使用了这些命令后,编写代码时会有多么惊人的效率了~~
教程中每讲小结如下:
====================================================
1. 光标在屏幕文本中的移动既可以用箭头键，也可以使用 hjkl 字母键。


h (左移)	j (下行)       k (上行)	    l (右移)


2. 欲进入vim编辑器(从命令行提示符)，请输入∶vim 文件名 &#60;回车&#62;
3. 欲退出vim编辑器，请输入以下命令放弃所有修改∶
&#60;ESC&#62;   :q!	 &#60;回车&#62;
或者输入以下命令保存<p class='read-more'><a href='http://imdonkey.com/blog/archives/450'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>安装过后就要开始熟悉Vim那些强大的命令了,一直看中文手册也不是办法,没有实践根本记不住.好在vim自带一个简单的入门教程,可以通过边看边练习的方式在半小时内掌握vim基本的命令.</p>
<p>在windows下要运行安装根目录下的vimtutor.bat.打开的文件默认就是一个副本,所以你可以尽情地在上面练习修改.</p>
<p>倔倔现在就要开始练习啦~哈</p>
<p>&#8230;</p>
<p>过了一遍vimtutor确实感觉不错~,好多命令都非常吸引人,我已经感觉到了熟练使用了这些命令后,编写代码时会有多么惊人的效率了~~</p>
<h2>教程中每讲小结如下:</h2>
<div id="_mcePaste">====================================================<br />
1. 光标在屏幕文本中的移动既可以用箭头键，也可以使用 hjkl 字母键。</p>
<blockquote>
<div id="_mcePaste">
<p>h (左移)	j (下行)       k (上行)	    l (右移)</p>
</div>
</blockquote>
<p>2. 欲进入vim编辑器(从命令行提示符)，请输入∶vim 文件名 &lt;回车&gt;</p>
<p>3. 欲退出vim编辑器，请输入以下命令放弃所有修改∶</p>
<blockquote><p>&lt;ESC&gt;   :q!	 &lt;回车&gt;<br />
或者输入以下命令保存所有修改∶<br />
&lt;ESC&gt;   :wq	 &lt;回车&gt;</p></blockquote>
<p>4. 在正常模式下删除光标所在位置的字符，请按∶ x</p>
<p>5. 在正常模式下要在光标所在位置开始插入文本，请按∶</p>
<blockquote><p>i     输入必要文本	&lt;ESC&gt;</p></blockquote>
<p>====================================================<br />
1. 欲从当前光标删除至单字/单词末尾，请输入∶dw</p>
<p>2. 欲从当前光标删除至当前行末尾，请输入∶d$</p>
<p>3. 欲删除整行，请输入∶dd</p>
<p>4. 在正常模式下一个命令的格式是∶</p>
<blockquote><p>[number]   command   object     或者     command<span style="white-space: pre;"> </span>[number]   object<br />
其意是∶<br />
number &#8211; 代表的是命令执行的次数<br />
command &#8211; 代表要做的事情，比如 d 代表删除<br />
object &#8211; 代表要操作的对象，比如 w 代表单字/单词，$ 代表到行末等等。<br />
<span style="white-space: pre;"> </span>$ (to the end of line), etc.</p></blockquote>
<p>5. 欲撤消以前的操作，请输入∶u (小写的u)<br />
欲撤消在一行中所做的改动，请输入∶U (大写的U)<br />
欲撤消以前的撤消命令，恢复以前的操作结果，请输入∶CTRL-R<br />
====================================================<br />
1. 要重新置入已经删除的文本内容，请输入小写字母 p。该操作可以将已删除的文本内容置于光标之后。如果最后一次删除的是一个整行，那么该行将置于当前光标所在行的下一行。</p>
<p>2. 要替换光标所在位置的字符，请输入小写的 r 和要替换掉原位置字符的新字符即可。</p>
<p>3. 更改类命令允许您改变指定的对象，从当前光标所在位置直到对象的末尾。比如输入 cw 可以替换当前光标到单词的末尾的内容；输入 c$ 可以替换当前光标到行末的内容。</p>
<p>4. 更改类命令的格式是∶</p>
<blockquote><p><span style="white-space: pre;"> </span> [number]   c<span style="white-space: pre;"> </span>object<span style="white-space: pre;"> </span> 或者<span style="white-space: pre;"> </span>c   [number]   object</p></blockquote>
<p>====================================================</p>
<p>1. Ctrl-g 用于显示当前光标所在位置和文件状态信息。Shift-G 用于将光标跳转至文件最后一行。先敲入一个行号然后按 Shift-G 则是将光标移动至该行号代表的行。</p>
<p>2. 输入 / 然后紧随一个字符串是则是在当前所编辑的文档中向后查找该字符串。输入问号   然后紧随一个字符串是则是在当前所编辑的文档中向前查找该字符串。完成一次查找之后按 n 键则是重复上一次的命令，可在同一方向上查找下一个字符串所在；或者按 Shift-N 向相反方向查找下该字符串所在。</p>
<p>3. 如果光标当前位置是括号(、)、[、]、{、}，按 % 可以将光标移动到配对的括号上。</p>
<p>4. 在一行内替换头一个字符串 old 为新的字符串 new，请输入  :s/old/new<br />
在一行内替换所有的字符串 old 为新的字符串 new，请输入  :s/old/new/g<br />
在两行内替换所有的字符串 old 为新的字符串 new，请输入  :#,#s/old/new/g<br />
在文件内替换所有的字符串 old 为新的字符串 new，请输入  :%s/old/new/g<br />
进行全文替换时询问用户确认每个替换需添加 c 选项，请输入 :%s/old/new/gc<br />
====================================================</p>
<p>1. :!command 用于执行一个外部命令 command。</p>
<blockquote><p>请看一些实际例子∶<br />
<span style="white-space: pre;"> </span> :!dir  &#8211;  用于显示当前目录的内容。<br />
<span style="white-space: pre;"> </span> :!rm FILENAME  -<span style="white-space: pre;"> </span>用于删除名为 FILENAME 的文件。</p></blockquote>
<p>2. :w FILENAME  可将当前 VIM 中正在编辑的文件保存到名为 FILENAME 的文件中。<br />
<span style="color: #ff6600;">3. :#,#w FILENAME 可将当前编辑文件第 # 行至第 # 行的内容保存到文件FILENAME 中。</span></p>
<p>4. :r FILENAME 可提取磁盘文件 FILENAME 并将其插入到当前文件的光标位置后面。<br />
====================================================<br />
1. 输入小写的 o 可以在光标下方打开新的一行并将光标置于新开的行首，进入插入模式。<br />
输入大写的 O 可以在光标上方打开新的一行并将光标置于新开的行首，进入插入模式。</p>
<p>2. 输入小写的 a 可以在光标所在位置之后插入文本。<br />
输入大写的 A 可以在光标所在行的行末之后插入文本。</p>
<p>4. 输入大写的 R 将进入替换模式，直至按 &lt;ESC&gt; 键退出替换模式而进入正常模式。</p>
<p>4. 输入 :set xxx 可以设置 xxx 选项。<br />
====================================================<br />
Vim 拥有一个细致全面的在线帮助系统。要启动该帮助系统，请选择如下三种方法之一∶</p>
<blockquote><p>- 按下 &lt;HELP&gt; 键 (如果键盘上有的话)<br />
- 按下 &lt;F1&gt; 键 (如果键盘上有的话)<br />
- 输入:help &lt;回车&gt;<br />
输入 :q &lt;回车&gt; 可以关闭帮助窗口。</p></blockquote>
<p>提供一个正确的参数给&#8221;:help&#8221;命令，您可以找到关于该主题的帮助。请试验以下参数(可别忘了按回车键哦。:)∶</p>
<blockquote><p>:help w &lt;回车&gt;<br />
:help c_&lt;T &lt;回车&gt;<br />
:help insert-index &lt;回车&gt;<br />
:help user-manual &lt;回车&gt;</p></blockquote>
<p>====================================================<br />
Vim的功能特性要比vi多得多，但大部分功能都没有缺省激活。为了启动更多的功能，您得创建一个vimrc文件。</p>
<p>1. 开始编辑vimrc文件，这取决于您所使用的操作系统∶</p>
<blockquote><p>:edit ~/.vimrc     这是Unix系统所使用的命令<br />
:edit $VIM/_vimrc     这是Windows系统所使用的命令</p></blockquote>
<p>2. 接着导入vimrc范例文件∶</p>
<blockquote><p>:read $VIMRUNTIME/vimrc_example.vim</p></blockquote>
<p>3. 保存文件，命令为∶</p>
<blockquote><p>:write</p></blockquote>
<p>在下次您启动vim的时候，编辑器就会有了语法高亮的功能。您可以继续把您喜欢的其它功能设置添加到这个vimrc文件中。</p>
<p>====================================================</p>
<p>PS.在发这篇文章的时候我是复制粘贴了每讲的小结,但复制过后格式有些乱,还有多余的html 标签,于是用vim %s/old/new/g这个命令查找替换了这些标签,轻松完成~~哈!</p>
<p>大家一定要多多实践啊~~</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/450/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>倔倔跟风学Vim(1)</title>
		<link>http://imdonkey.com/blog/archives/433</link>
		<comments>http://imdonkey.com/blog/archives/433#comments</comments>
		<pubDate>Wed, 28 Apr 2010 08:47:14 +0000</pubDate>
		<dc:creator>Ting</dc:creator>
				<category><![CDATA[倔倔在前端]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[zen-coding]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=433</guid>
		<description><![CDATA[<p>最近总时不时的听大家提到Vim.可它到底是个什么东西我一丁儿丁儿概念都没有...后来觉得做技术的不懂介个有点儿丢人吧,今天就找时间要会会 Vim.会了几个小时之后,我决定继续会下去~哈哈</p> <p>熟悉Linux的同学应该对Vim很了解,也清楚它的神通广大~可我一做前端爱设计的人对这东西根本没接触.所以接下来的介绍依然是为那些同类的朋友们准备的.很简单,我也尽量将步骤说得详细些~</p> <p>先记住它是一个编辑器其它的先不用管,马上开始!</p><p class='read-more'><a href='http://imdonkey.com/blog/archives/433'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>最近总时不时的听大家提到Vim.可它到底是个什么东西我一丁儿丁儿概念都没有&#8230;后来觉得做技术的不懂介个有点儿丢人吧,今天就找时间要会会Vim.会了几个小时之后,我决定继续会下去~哈哈</p>
<p>熟悉Linux的同学应该对Vim很了解,也清楚它的神通广大~可我一做前端爱设计的人对这东西根本没接触.所以接下来的介绍依然是为那些同类的朋友们准备的.很简单,我也尽量将步骤说得详细些~</p>
<p>先记住它是一个编辑器其它的先不用管,马上开始!</p>
<h2>安装</h2>
<p>了解之前咱得先看看这东西长什么样儿. <a href="ftp://ftp.vim.org/pub/vim/pc/gvim72.exe" target="_blank">Download Vim for Win</a></p>
<p>不用修改什么,一直Next下去就成~除非你要改安装路径跟选择语言.</p>
<h2>中文手册安装</h2>
<p>这种编辑器的命令忒多,看英文的手册头疼,下个中文的吧.<a href="http://prdownloads.sourceforge.net/vimcdoc/vimcdoc-1.7.0-setup.exe?download" target="_blank">这里</a></p>
<p>下载之后运行,安装成功后重启Vim,启动界面是中文了,可是菜单上的中文却成了乱码.google之后发现一篇<a href="http://blog.sina.com.cn/s/blog_665923650100hv9s.html" target="_blank">文章</a>,修改后问题解决</p>
<h2>配色方案设置及保存</h2>
<p>但这次修改明白了Vim的用户设置基本都可以通过在_vimrc这个文件里修改添加</p>
<p>于是修改了配色方案,如果不在_vimrc文件里设置的话,下次打开Vim又会还原到最初始状态.</p>
<p>找到 Vim 官方百科 按照<a href="http://vim.wikia.com/wiki/Setting_the_font_in_the_GUI" target="_blank">这篇文章</a> 顺便将字体跟大小也一起改了</p>
<p>我目前选用的是Consolas:h14</p>
<p>效果如下:</p>
<p><a href="http://imdonkey.com/blog/wp-content/uploads/2010/04/vim_screenshot.gif"><img class="alignnone size-full wp-image-452" title="vim_screenshot" src="http://imdonkey.com/blog/wp-content/uploads/2010/04/vim_screenshot.gif" alt="" width="410" height="389" /></a></p>
<h2>在Vim下安装zen coding</h2>
<p><a href="http://www.vim.org/scripts/script.php?script_id=2981" target="_blank">这里</a>包含了所有安装zen-coding的信息.</p>
<p>如果想了解什么是zen-coding可以参看<a href="http://www.qianduan.net/zen-coding-a-new-way-to-write-html-code.html" target="_blank">这里</a></p>
<p>最后阅读中文手册,练习了一些最基本的操作命令(多了也记不住哈哈).目前感觉很不错~</p>
<p>以后会慢慢熟悉Vim,希望自己能快快进步~大家共勉~:)</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/433/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>倔倔死磕Javascript之开篇</title>
		<link>http://imdonkey.com/blog/archives/368</link>
		<comments>http://imdonkey.com/blog/archives/368#comments</comments>
		<pubDate>Tue, 27 Apr 2010 04:00:16 +0000</pubDate>
		<dc:creator>Ting</dc:creator>
				<category><![CDATA[倔倔在前端]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=368</guid>
		<description><![CDATA[倔倔这个名字不是白起的,完全源于本人性格中最大的特点:那就是倔!

最近各种刺激扑面而来,叫我怎能不好好学习?在坨坨同学的指导下 我开始了"又"一次的Javascript之旅~(之所以说"又"是因为07年自己买下了《<a href="http://product.dangdang.com/product.aspx?product_id=9211839&#38;amp;ref=search-0-A" target="_blank">Javascript高级程序设计</a>》,现在想来真不知道当时自己怎么了....好在是本好书~银子没白花)

先做几个很简单的实例,把自己学习的兴趣提起来.这点很重要.

声明:本人可以说是0基础,所以初学JS的朋友也可以一起学习.高手们可以飘过,多多指导哈 :)<p class='read-more'><a href='http://imdonkey.com/blog/archives/368'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>倔倔这个名字不是白起的,完全源于本人性格中最大的特点:那就是倔!</p>
<p>最近各种刺激扑面而来,叫我怎能不好好学习?在坨坨同学的指导下 我开始了&#8221;又&#8221;一次的Javascript之旅~(之所以说&#8221;又&#8221;是因为07年自己买下了《<a href="http://product.dangdang.com/product.aspx?product_id=9211839&amp;ref=search-0-A" target="_blank">Javascript高级程序设计</a>》,现在想来真不知道当时自己怎么了&#8230;.好在是本好书~银子没白花)</p>
<p>先做几个很简单的实例,把自己学习的兴趣提起来.这点很重要.</p>
<p>声明:本人可以说是0基础,所以初学JS的朋友也可以一起学习.高手们可以飘过,多多指导哈 <img src='http://imdonkey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>实例一:图片浏览</h2>
<p><a href="http://imdonkey.com/blog/wp-content/uploads/2010/04/imgSlider_demo_mockup1.gif"><img class="alignnone size-full wp-image-380" title="imgSlider_demo_mockup" src="http://imdonkey.com/blog/wp-content/uploads/2010/04/imgSlider_demo_mockup1.gif" alt="" width="479" height="386" /></a></p>
<p>实现效果:点击&#8221;Previous&#8221;和&#8221;Next&#8221; button实现连续几张图片的切换. 很简单吧~</p>
<h3>第一步:HTML&amp;CSS</h3>
<p>这一步对各位来说应该并不难,不过既然元素少,又是做Demo用的,我们就对自己的要求放松些吧,我说的放松是对于浏览器兼容问题的放松.我们选择HTML5与CSS3.可以暂时不用过多管IE678.(但你可以下载IE9的preview版来看看,也无妨)</p>
<p>主要HTML代码如下:</p>
<pre class="brush: xml;">
	&lt;input type=&quot;button&quot; id=&quot;btn_previous&quot; value=&quot;Previous&quot;/&gt;
	&lt;input type=&quot;button&quot;  id=&quot;btn_next&quot; value=&quot;Next&quot;/&gt;
	&lt;ul id=&quot;container&quot;&gt;
		&lt;li id=&quot;pic_1&quot; class=&quot;current&quot;&gt;
			&lt;img src=&quot;../images/demo/pic_1.gif&quot; title=&quot;NO.1&quot; alt=&quot;NO.1&quot;/&gt;
			&lt;p title=&quot;NO.1&quot;&gt;NO.1&lt;/p&gt;
		&lt;/li&gt;
		&lt;li id=&quot;pic_2&quot;&gt;
			&lt;img src=&quot;../images/demo/pic_2.gif&quot; title=&quot;NO.2&quot; alt=&quot;NO.2&quot;/&gt;
			&lt;p title=&quot;NO.2&quot;&gt;NO.2&lt;/p&gt;
		&lt;/li&gt;
		&lt;li id=&quot;pic_3&quot;&gt;
			&lt;img src=&quot;../images/demo/pic_3.gif&quot; title=&quot;NO.3&quot; alt=&quot;NO.3&quot;/&gt;
			&lt;p title=&quot;NO.3&quot;&gt;NO.3&lt;/p&gt;
		&lt;/li&gt;
		&lt;li id=&quot;pic_4&quot;&gt;
			&lt;img src=&quot;../images/demo/pic_4.gif&quot; title=&quot;NO.4&quot; alt=&quot;NO.4&quot;/&gt;
			&lt;p title=&quot;NO.4&quot;&gt;NO.4&lt;/p&gt;
		&lt;/li&gt;
		&lt;li id=&quot;pic_5&quot;&gt;
			&lt;img src=&quot;../images/demo/pic_5.gif&quot; title=&quot;NO.5&quot; alt=&quot;NO.5&quot;/&gt;
			&lt;p title=&quot;NO.5&quot;&gt;NO.5&lt;/p&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
</pre>
<h3>第二步:梳理思路</h3>
<p>想想需要解决哪几个问题:</p>
<ol>
<li>怎么知道是显示当前图片的上一张还是下一张?</li>
<li>如何替换当前图片?</li>
</ol>
<p>好,先解决掉这两个问题事情就好办多了.</p>
<ol>
<li>我们需要将&#8221;向前&#8221;和&#8221;向后&#8221;分别用两个数值来代替,做为参数传给接下来我们要完成的函数,这里用(-1)和(1)来表示.</li>
<li>知道了是向前还是向后之后 我们就要把当前图片隐藏起来,然后显示出它的上一张或者下一张图片.</li>
</ol>
<p>Ok,那我们就开始吧~</p>
<h3>第三步:编写代码</h3>
<p>首先我们给函数起个名字,就叫 imgSlider.(也许并不贴切,但以后会改进功能).把要传给这个函数的值取名为n.所以简单写下来函数应该长这个样子:</p>
<pre class="brush: jscript;">
function imgSlider(n) {

}
</pre>
<p>然后我们需要一个变量,这个变量用来存储当前显示的是第几张图片,我们先赋一个初始值给它,像这样.</p>
<pre class="brush: jscript;">
var currentImg = 1;
function imgSlider(n) {

}
</pre>
<p>为什么要把这个赋值语句写在函数外面呢?(全局变量)因为函数要对这个值做处理,也就是说将来一旦触发了这个函数,currentImg这个值会改变,所以我们将它写在外面.</p>
<p>接下来我们需要得到网页中的几个对象,取得对象的方法是采用document.getElementById(&#8220;idname&#8221;):</p>
<pre class="brush: jscript;">
var currentImg = 1;
function imgSlider(n) {
	var currentImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
	var btn_previous = document.getElementById(&quot;btn_previous&quot;);
	var btn_next = document.getElementById(&quot;btn_next&quot;);
}
</pre>
<p>哈哈,现在就到了最关键的步骤了,到目前为至我们还没有用到传进来的参数呢,想想假设现在传进来的是(1),即用户要显示下一张图片的话,我们要做何处理呢?很简单,就是在当前图片基础上+1 显示下一张呗~</p>
<pre class="brush: jscript;">
var currentImg = 1;
function imgSlider(n) {
	var currentImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
	var btn_previous = document.getElementById(&quot;btn_previous&quot;);
	var btn_next = document.getElementById(&quot;btn_next&quot;);
	currentImg = currentImg + n;
	targetImgCon.setAttribute(&quot;class&quot;,&quot;current&quot;);
	targetImgCon.className = &quot;current&quot;;
}
</pre>
<p>currentImg加了1后,我们根据currentImg的最新值通过document.getElementById()这个方法找到了我们要显示的那个图片,并且将得到的对象命名为targetImgCon,然后将current这个class加到这个对象上,那么第二张图片就显示出来了.可不要忘记在这之前要先将之前的图片隐藏起来,所以还要对代码要做以下修改</p>
<pre class="brush: jscript; highlight: [6,7];">
var currentImg = 1;
function imgSlider(n) {
	var currentImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
	var btn_previous = document.getElementById(&quot;btn_previous&quot;);
	var btn_next = document.getElementById(&quot;btn_next&quot;);
	currentImgCon.setAttribute(&quot;class&quot;,&quot;&quot;);
	currentImgCon.className = &quot;&quot;;
	currentImg = currentImg + n;
	var targetImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
	targetImgCon.setAttribute(&quot;class&quot;,&quot;current&quot;);
	targetImgCon.className = &quot;current&quot;;
}
</pre>
<p>到此为至主要功能实现了,但完整程度还差好多~.不信可以将事件加到两个button上,如下:</p>
<pre class="brush: xml;">
&lt;input type=&quot;button&quot; onclick=&quot;imgSlider(-1)&quot; id=&quot;btn_previous&quot; value=&quot;Previous&quot; disabled=&quot;disabled&quot;/&gt;
&lt;input type=&quot;button&quot; onclick=&quot;imgSlider(1)&quot; id=&quot;btn_next&quot; value=&quot;Next&quot;/&gt;
</pre>
<p>那么我们还要做什么呢?目前页面中只有5张图片,我们不希望用户一直点击向前向后,那样currentImg数值会越来越大,而执行过程中又取不到数值大于5的图片,会报错.所以现在我们要对临界值做一个判断处理.我们希望只有在1-5这个范围内再做我们以上的那些事情.</p>
<pre class="brush: jscript; highlight: [9,13];">
var currentImg = 1;
function imgSlider(n) {
	var currentImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
	var btn_previous = document.getElementById(&quot;btn_previous&quot;);
	var btn_next = document.getElementById(&quot;btn_next&quot;);
	currentImgCon.setAttribute(&quot;class&quot;,&quot;&quot;);
	currentImgCon.className = &quot;&quot;;
	currentImg = currentImg + n;
	if (currentImg &gt; 1 || currentImg &lt; 5 ) {
		var targetImgCon = document.getElementById(&quot;pic_&quot;+ currentImg);
		targetImgCon.setAttribute(&quot;class&quot;,&quot;current&quot;);
		targetImgCon.className = &quot;current&quot;;
	}
}
</pre>
<p>可运行一下,发现到第5张时候再点&#8221;Next&#8221;就什么都显示不出来了,再点&#8221;Previous&#8221;也没反应了,为什么呢?我们用input来跟踪下currentImg的数值变化:<br />
在HTML中添加一个input:</p>
<pre class="brush: xml;">
&lt;input type=&quot;text&quot; value=&quot;&quot; id=&quot;logger&quot;/&gt;
</pre>
<p>JavaScript做如下修改:</p>
<pre class="brush: jscript;">
document.getElementById(&quot;logger&quot;).value = currentImg;
</pre>
<p>刷新下页面,点到最后发现currentImg的值是6,超出了1-5这个范围,自然执行不了我们if条件里的语句了.怎么解决这个问题呢,其实很简单,当页面当前显示的是第一张图片时我们就将&#8221;Previous&#8221;button 屏蔽掉,同理,当页面当前显示的是第5张,也就是最后一张的时候屏蔽掉&#8221;Next&#8221;button,事情就解决了.其它情况下两个button正常显示~~哈哈</p>
<p>初始的时候就要先将&#8221;Previous&#8221; button 置为disabled</p>
<pre class="brush: xml;">
&lt;input type=&quot;button&quot; onclick=&quot;imgSlider(-1)&quot; id=&quot;btn_previous&quot; value=&quot;Previous&quot; disabled=&quot;disabled&quot;/&gt;
</pre>
<p>JavaScript添加如下代码:</p>
<pre class="brush: jscript;">
if(currentImg == 1) {
	btn_previous.setAttribute(&quot;disabled&quot;,&quot;disabled&quot;);
}else {
	btn_previous.removeAttribute(&quot;disabled&quot;);
}

if(currentImg == 5) {
	btn_next.setAttribute(&quot;disabled&quot;,&quot;disabled&quot;);
}else {
	btn_next.removeAttribute(&quot;disabled&quot;);
}
</pre>
<p>大功告成~~<a href="http://www.imdonkey.com/demo/img_slider.html" target="_blank">最终效果</a></p>
<h2><a href="http://www.imdonkey.com/demo/img_slider.html" target="_blank"></a><br />
知识点:</h2>
<ol>
<li>CSS3 渐变<a href="http://www.qianduan.net/understand-the-css3-gradient.html">http://www.qianduan.net/understand-the-css3-gradient.html</a></li>
<li>CSS Selector</li>
<li>CSS 缩写<a href="http://www.qianduan.net/css-font-shorthand-attribute-handbook.html">http://www.qianduan.net/css-font-shorthand-attribute-handbook.html</a></li>
<li>input disabled属性</li>
<li>function定义</li>
<li>全局变量定义/初始化</li>
<li>document.getElementById(&#8220;idName&#8221;)</li>
<li>setAttribute(&#8220;attributeName&#8221;,&#8221;attributeValue&#8221;)</li>
<li>removeAttribute(&#8220;attributeName&#8221;)</li>
<li>if else</li>
</ol>
<h2>下期预告:放大镜~~~</h2>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/368/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>检测链表中是否有环</title>
		<link>http://imdonkey.com/blog/archives/356</link>
		<comments>http://imdonkey.com/blog/archives/356#comments</comments>
		<pubDate>Sun, 25 Apr 2010 17:02:13 +0000</pubDate>
		<dc:creator>luoxi</dc:creator>
				<category><![CDATA[坨坨胡同儿]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=356</guid>
		<description><![CDATA[<div id="_mcePaste">其实这是个经典算法题，但我却刚刚听说，可见对于算法，我已经漠视很久了。这不是一个专业程序员应该有的状态…… 在此推荐一篇关于<a href="http://static.icybear.net/[CN]Programmer%20competency%20matrix.htm">程序员能力矩阵</a>的文章，please enjoy~ :)</div>
<div id="_mcePaste">这个题目是听公司同事说起的，当时我的第一反应也是建立一个哈希表，然后循环检查元素是否已经存在于这个表中，没有就添加进去，并检查下一个，如果有就说明此链表是个环。甚至为了优化性能，可以隔几个检查一次，这样还能减少比对次数。后来google了一下，豁然开朗~</div>
<div id="_mcePaste">简单说来，就是设置两个指针(fast, slow)，初始值都指向头，slow每次前进一步，fast每次前进二步(如果能证明其他数值性能更高，欢迎补充)，如果链表存在环，则fast必定先进入环，而slow后进入环，两个指针必定相遇。(当然，fast先行头到尾部为NULL，则为无环链表)</div><p class='read-more'><a href='http://imdonkey.com/blog/archives/356'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>其实这是个经典算法题，但我却刚刚听说，可见对于算法，我已经漠视很久了。这不是一个专业程序员应该有的状态…… 在此推荐一篇关于<a href="http://static.icybear.net/[CN]Programmer%20competency%20matrix.htm">程序员能力矩阵</a>的文章，please enjoy~ <img src='http://imdonkey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>这个题目是听公司同事说起的，当时我的第一反应也是建立一个哈希表，然后循环检查元素是否已经存在于这个表中，没有就添加进去，并检查下一个，如果有就说明此链表是个环。甚至为了优化性能，可以隔几个检查一次，这样还能减少比对次数。后来google了一下，豁然开朗~</p>
<p>简单说来，就是设置两个指针(fast, slow)，初始值都指向头，slow每次前进一步，fast每次前进二步(如果能证明其他数值性能更高，欢迎补充)，如果链表存在环，则fast必定先进入环，而slow后进入环，两个指针必定相遇。(当然，fast先行头到尾部为NULL，则为无环链表)，具体到Java代码是这样的：</p>
<p>首先先定义LinkedNode类，为了简化代码，我只给它设置了一个属性：next</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">class</span> LinkedNode <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">private</span> LinkedNode next <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">void</span> setNext<span style="color: #009900;">&#40;</span>LinkedNode _next<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">this</span>.<span style="color: #006633;">next</span> <span style="color: #339933;">=</span> _next<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> LinkedNode next<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">return</span> <span style="color: #006699; font-weight: bold;">this</span>.<span style="color: #006633;">next</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>然后开始写测试代码：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">class</span> CircleChecker <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> <span style="color: #006699; font-weight: bold;">int</span> HASHCHECK <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">final</span> <span style="color: #006699; font-weight: bold;">int</span> STEPCHECK <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008200;">/**
	 * Generate a linked list
	 * @param circle if true, return a circle list
	 * @param capital list size
	 * @return linked list
	 */</span>
	<span style="color: #006699; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> getLinkedList<span style="color: #009900;">&#40;</span><span style="color: #006699; font-weight: bold;">boolean</span> circle, <span style="color: #006699; font-weight: bold;">int</span> capital<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> list <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">new</span> LinkedList<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		LinkedNode head <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">new</span> LinkedNode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>head<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">--</span>capital <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			LinkedNode node <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">new</span> LinkedNode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>list.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setNext</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			list.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #006699; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>circle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>list.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setNext</span><span style="color: #009900;">&#40;</span>head<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;List size is :&quot;</span> <span style="color: #339933;">+</span> list.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">return</span> list<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">boolean</span> hashCheck<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> list<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">boolean</span> hasCircle <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		Set<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> hash <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">new</span> HashSet<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		LinkedNode node <span style="color: #339933;">=</span> list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		hash.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> times <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> step <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>node.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006699; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #006699; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> step <span style="color: #339933;">&amp;&amp;</span> node.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				node <span style="color: #339933;">=</span> node.<span style="color: #006633;">next</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: #006699; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>hash.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				hasCircle <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #006699; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			times<span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Check Time: &quot;</span> <span style="color: #339933;">+</span> times<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">return</span> hasCircle<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">boolean</span> stepCheck<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> list<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">boolean</span> hasCircle <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> i<span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> step1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> step2 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
&nbsp;
		LinkedNode node1 <span style="color: #339933;">=</span> list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		LinkedNode node2 <span style="color: #339933;">=</span> list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">int</span> times <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>node1.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> node2.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006699; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> step1 <span style="color: #339933;">&amp;&amp;</span> node1.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				node1 <span style="color: #339933;">=</span> node1.<span style="color: #006633;">next</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: #006699; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> step2 <span style="color: #339933;">&amp;&amp;</span> node2.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #006699; font-weight: bold;">null</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				node2 <span style="color: #339933;">=</span> node2.<span style="color: #006633;">next</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: #006699; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>node1 <span style="color: #339933;">==</span> node2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				hasCircle <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #006699; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			times<span style="color: #339933;">++;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Check Time: &quot;</span> <span style="color: #339933;">+</span> times<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">return</span> hasCircle<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">void</span> startCheck<span style="color: #009900;">&#40;</span>List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> list, <span style="color: #006699; font-weight: bold;">int</span> mode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">long</span> start <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">boolean</span> result <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>mode<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006699; font-weight: bold;">case</span> HASHCHECK<span style="color: #339933;">:</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[Hash Check]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			result <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">this</span>.<span style="color: #006633;">hashCheck</span><span style="color: #009900;">&#40;</span>list<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006699; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">case</span> STEPCHECK<span style="color: #339933;">:</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[Step Check]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			result <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">this</span>.<span style="color: #006633;">stepCheck</span><span style="color: #009900;">&#40;</span>list<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #006699; font-weight: bold;">break</span><span style="color: #339933;">;</span>
		<span style="color: #006699; font-weight: bold;">default</span><span style="color: #339933;">:</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Unsupported Mode&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #006699; font-weight: bold;">long</span> end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;RunningTime: &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>end <span style="color: #339933;">-</span> start<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Result is &quot;</span> <span style="color: #339933;">+</span> result <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006699; font-weight: bold;">public</span> <span style="color: #006699; font-weight: bold;">static</span> <span style="color: #006699; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		CircleChecker app <span style="color: #339933;">=</span> <span style="color: #006699; font-weight: bold;">new</span> CircleChecker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> testList <span style="color: #339933;">=</span> app.<span style="color: #006633;">getLinkedList</span><span style="color: #009900;">&#40;</span><span style="color: #006699; font-weight: bold;">true</span>, <span style="color: #cc66cc;">500000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		app.<span style="color: #006633;">startCheck</span><span style="color: #009900;">&#40;</span>testList, HASHCHECK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		app.<span style="color: #006633;">startCheck</span><span style="color: #009900;">&#40;</span>testList, STEPCHECK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>运行结果如下：<br />
List size is :500000</p>
<p>[Hash Check]<br />
Check Time: 249999<br />
RunningTime: 453<br />
Result is true</p>
<p>[Step Check]<br />
Check Time: 499999<br />
RunningTime: 40<br />
Result is true</p>
<p>这是对一个环路链表的检测结果，下面再试试无环路链表。把main函数中的</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> testList <span style="color: #339933;">=</span> app.<span style="color: #006633;">getLinkedList</span><span style="color: #009900;">&#40;</span><span style="color: #006699; font-weight: bold;">true</span>, <span style="color: #cc66cc;">500000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>改为：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>LinkedNode<span style="color: #339933;">&gt;</span> testList <span style="color: #339933;">=</span> app.<span style="color: #006633;">getLinkedList</span><span style="color: #009900;">&#40;</span><span style="color: #006699; font-weight: bold;">false</span>, <span style="color: #cc66cc;">500000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>运行结果如下：<br />
List size is :500000</p>
<p>[Hash Check]<br />
Check Time: 250000<br />
RunningTime: 448<br />
Result is false</p>
<p>[Step Check]<br />
Check Time: 250000<br />
RunningTime: 24<br />
Result is false</p>
<p>可见虽然哈希表检查法可能在比较次数上较少，但是总耗时多了很多，主要耗费在hash.add(node)上，因为选择的是Set，所以为了保证元素唯一性，在add数据时会检查是否已存在。而且当要检查的元素数量巨大时，要占用非常大的内存，甚至OutOfMemoryError。而快慢两步走法（sorry，我起得名字有点土），仅仅进行指针比较既可，极其快速，而且不占内存！<br />
这才是我们应该追求的终极目标</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/356/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP中json_decode的整型溢出问题</title>
		<link>http://imdonkey.com/blog/archives/346</link>
		<comments>http://imdonkey.com/blog/archives/346#comments</comments>
		<pubDate>Sun, 25 Apr 2010 03:53:40 +0000</pubDate>
		<dc:creator>luoxi</dc:creator>
				<category><![CDATA[坨坨胡同儿]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=346</guid>
		<description><![CDATA[编码过程中遇到个错误，就是在处理json时，数值较大的int值在解码后数据被损坏，比如：

<span style="color: #000088;">$array</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&#34;id1&#34;</span> <span style="color: #000000;">=&#62;</span> <span style="color: #cc66cc;">2147483647</span><span style="color: #000000;">,</span>
    <span style="color: #0000ff;">&#34;id2&#34;</span> <span style="color: #000000;">=&#62;</span> <span style="color: #cc66cc;">2147483648</span>
<span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$json</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$out</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #000000;">,</span> <span style="color: #7F0055; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$out</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>

理论上应该看到：

array(2) {
    ["id1"]=>int(2147483647)
    ["id2"]=>int(2147483648)
}
但实际在我的电脑上却得到：
array(2) {
    ["id1"]=>int(2147483647)
    ["id2"]=>int(<span style="color: #3366ff;">-2147483646</span>)
}
这是由PHP整数值范围决定的，而这个范围依赖于操作系统。在32位操作系统中，PHP的整数最大值是2147483647，你可以通过输出PHP_INT_MAX看到。
一般情况下<p class='read-more'><a href='http://imdonkey.com/blog/archives/346'>阅读全文 »</a></p>]]></description>
			<content:encoded><![CDATA[<p>编码过程中遇到个错误，就是在处理json时，数值较大的int值在解码后数据被损坏，比如：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;id1&quot;</span> <span style="color: #000000;">=&gt;</span> <span style="color: #cc66cc;">2147483647</span><span style="color: #000000;">,</span>
    <span style="color: #0000ff;">&quot;id2&quot;</span> <span style="color: #000000;">=&gt;</span> <span style="color: #cc66cc;">2147483648</span>
<span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$json</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$out</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #000000;">,</span> <span style="color: #7F0055; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$out</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>理论上应该看到：</p>
<pre>
array(2) {
    ["id1"]=>int(2147483647)
    ["id2"]=>int(2147483648)
}</pre>
<p>但实际在我的电脑上却得到：</p>
<pre>array(2) {
    ["id1"]=>int(2147483647)
    ["id2"]=>int(<span style="color: #3366ff;">-2147483646</span>)
}</pre>
<p>这是由PHP整数值范围决定的，而这个范围依赖于操作系统。在32位操作系统中，PHP的整数最大值是2147483647，你可以通过输出PHP_INT_MAX看到。</p>
<p>一般情况下，你赋值一个很大的数，PHP会自动判定这个数值的范围并自动转换类型，如：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$large_number</span> <span style="color: #000000;">=</span> <span style="color: #cc66cc;">2147483647</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$large_number</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>                     <span style="color: #666666; font-style: italic;">// int(2147483647)</span>
&nbsp;
<span style="color: #000088;">$large_number</span> <span style="color: #000000;">=</span> <span style="color: #cc66cc;">2147483648</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$large_number</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>                     <span style="color: #666666; font-style: italic;">// float(2147483648)</span>
&nbsp;
<span style="color: #000088;">$million</span> <span style="color: #000000;">=</span> <span style="color: #cc66cc;">1000000</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$large_number</span> <span style="color: #000000;">=</span>  <span style="color: #cc66cc;">50000</span> <span style="color: #000000;">*</span> <span style="color: #000088;">$million</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$large_number</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>                     <span style="color: #666666; font-style: italic;">// float(50000000000)</span></pre></div></div>

<p>但是在json_decode方法中没有进行这种检测，这是PHP（旧版本）的bug，在5.3以后的版本，就不存在这个问题了。</p>
<p>如果你不想更新你的PHP，那还有个办法，就是将数字转为字符串。还是以上面的代码为例：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">&quot;id1&quot;</span> <span style="color: #000000;">=&gt;</span> <span style="color: #cc66cc;">2147483647</span><span style="color: #000000;">,</span>
    <span style="color: #0000ff;">&quot;id2&quot;</span> <span style="color: #000000;">=&gt;</span> <span style="color: #cc66cc;">2147483648</span>
<span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$json</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #000088;">$json</span> <span style="color: #000000;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(&quot;id\d&quot;:)(\d{9,})/i'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'${1}&quot;${2}&quot;'</span><span style="color: #000000;">,</span> <span style="color: #000088;">$json</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #000088;">$out</span> <span style="color: #000000;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #000000;">,</span> <span style="color: #7F0055; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$out</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>当然，这个怎么替换是按需而定的，而且需要比较细致的测试。</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/346/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>5月9日 W3C CEO与工程师面对面</title>
		<link>http://imdonkey.com/blog/archives/309</link>
		<comments>http://imdonkey.com/blog/archives/309#comments</comments>
		<pubDate>Mon, 19 Apr 2010 02:53:29 +0000</pubDate>
		<dc:creator>Ting</dc:creator>
				<category><![CDATA[Web标准化交流会]]></category>
		<category><![CDATA[Dr. Jeff Jaffe]]></category>
		<category><![CDATA[W3C]]></category>

		<guid isPermaLink="false">http://imdonkey.com/blog/?p=309</guid>
		<description><![CDATA[<blockquote><p><a href="http://imdonkey.com/blog/wp-content/uploads/2010/04/180_250.jpg"><img class="alignnone size-full wp-image-332" title="180_250" src="http://imdonkey.com/blog/wp-content/uploads/2010/04/180_250.jpg" alt="" width="180" height="250" /></a></p>
<p>会议主题：<a href="http://www.w3ctech.com/zt/w3cceo" target="_blank">W3C CEO与工程师面对面</a><br />
会议日期：5月9日(周日)下午1点开始<br />
会议地点：北航会议中心<br />
预定人数：50人<br />
参与费用：不收取任何费用<br />
主办方：<a href="http://www.chinaw3c.org/" target="_blank">W3C中国</a>，<a href="http://www.w3ctech.com/" target="_blank">Web标准化交流会</a></p></blockquote>
<p>W3C CEO <a href="http://www.w3.org/People/Jeff/" target="_blank">Dr. Jeff Jaffe</a> 5月来北京, <a href="http://www.w3ctech.com/" target="_blank">Web标准化交流会</a>努力争取到了这次难得的机会,邀请到<a href="http://www.w3.org/People/Jeff/" target="_blank">Dr. Jeff Jaffe</a>与工程师一起探讨Web前端的发展和与之相关的各类问题.希望大家积极报名.相信一定会收获不小~</p>]]></description>
			<content:encoded><![CDATA[<blockquote><p><a href="http://imdonkey.com/blog/wp-content/uploads/2010/04/180_250.jpg"><img class="alignnone size-full wp-image-332" title="180_250" src="http://imdonkey.com/blog/wp-content/uploads/2010/04/180_250.jpg" alt="" width="180" height="250" /></a></p>
<p>会议主题：<a href="http://www.w3ctech.com/zt/w3cceo" target="_blank">W3C CEO与工程师面对面</a><br />
会议日期：5月9日(周日)下午1点开始<br />
会议地点：北航会议中心<br />
预定人数：50人<br />
参与费用：不收取任何费用<br />
主办方：<a href="http://www.chinaw3c.org/" target="_blank">W3C中国</a>，<a href="http://www.w3ctech.com/" target="_blank">Web标准化交流会</a></p></blockquote>
<p>W3C CEO <a href="http://www.w3.org/People/Jeff/" target="_blank">Dr. Jeff Jaffe</a> 5月来北京, <a href="http://www.w3ctech.com/" target="_blank">Web标准化交流会</a>努力争取到了这次难得的机会,邀请到<a href="http://www.w3.org/People/Jeff/" target="_blank">Dr. Jeff Jaffe</a>与工程师一起探讨Web前端的发展和与之相关的各类问题.希望大家积极报名.相信一定会收获不小~</p>
]]></content:encoded>
			<wfw:commentRss>http://imdonkey.com/blog/archives/309/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
