<?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>小居</title>
	<atom:link href="http://liunian.info/feed" rel="self" type="application/rss+xml" />
	<link>http://liunian.info</link>
	<description>流年逝水，不过一地鸡毛</description>
	<lastBuildDate>Fri, 18 May 2012 14:13:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>JavaScript 之 String.replace</title>
		<link>http://liunian.info/string-replace-in-javascript.html</link>
		<comments>http://liunian.info/string-replace-in-javascript.html#comments</comments>
		<pubDate>Fri, 18 May 2012 14:05:11 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[模板]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=732</guid>
		<description><![CDATA[最简单的用法 直接的用字符串替换字符串是最简单的用法，这种情况下将只会替换掉第一个匹配的字符串。 1var res = 'a1a2a3'.replace&#40;'a', 'b'&#41;; // =&#62; 'b1a2a3' 使用正则来达到复杂的要求 JavaScript 中正则的介绍可参照 MDN 的 RegExp。 1234// 把字符串的所有英文字符都去掉，不论大小写 var pattern = /[a-z]/gi; var str = '1aBc2d3E4f5e'; var res = str.replace&#40;pattern, ''&#41;; // =&#62; '12345' 使用函数来对匹配内容做高级处理 在使用正则匹配的同时，可以使用一个函数来对匹配的内容来做更加复杂的一些处理，比如下面的把 &#60; 和 &#62; 做转义，而不用通过执行两次的 replace 操作。 12345678910// 转移 html 标签 var str = '&#60;span&#62;&#60;/span&#62;', &#160; &#160; specialMap = &#123; [...]<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/quick-insert-a-cutline-in-office.html' title='Office 快速插入分割线' rel='bookmark'>Office 快速插入分割线</a></li><li class='rand_post'><a href='http://liunian.info/custom-searchform.html' title='自定义search form' rel='bookmark'>自定义search form</a></li><li class='rand_post'><a href='http://liunian.info/%e5%bf%a0%e8%af%9a%e5%8f%aa%e5%9b%a0%e8%83%8c%e5%8f%9b%e7%9a%84%e4%bb%a3%e4%bb%b7%e5%a4%aa%e9%ab%98.html' title='忠诚只因背叛的代价太高' rel='bookmark'>忠诚只因背叛的代价太高</a></li><li class='rand_post'><a href='http://liunian.info/lingoes-defeat-ie.html' title='Lingoes打败IE' rel='bookmark'>Lingoes打败IE</a></li><li class='rand_post'><a href='http://liunian.info/2010-year-end-summary.html' title='2010年终总结' rel='bookmark'>2010年终总结</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p class="main-point">最简单的用法</p>
<p>直接的用字符串替换字符串是最简单的用法，这种情况下将只会替换掉第一个匹配的字符串。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> res <span style="color: #339933;">=</span> <span style="color: #3366CC;">'a1a2a3'</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// =&gt; 'b1a2a3'</span></div></td></tr></tbody></table></div>
<p class="main-point">使用正则来达到复杂的要求</p>
<p>JavaScript 中正则的介绍可参照 MDN 的 <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp" title="RegExp">RegExp</a>。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// 把字符串的所有英文字符都去掉，不论大小写</span><br />
<span style="color: #003366; font-weight: bold;">var</span> pattern <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/[a-z]/gi</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'1aBc2d3E4f5e'</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> res <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>pattern<span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// =&gt; '12345'</span></div></td></tr></tbody></table></div>
<p><span id="more-732"></span></p>
<p class="main-point">使用函数来对匹配内容做高级处理</p>
<p>在使用正则匹配的同时，可以使用一个函数来对匹配的内容来做更加复杂的一些处理，比如下面的把 &lt; 和 &gt; 做转义，而不用通过执行两次的 replace 操作。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// 转移 html 标签</span><br />
<span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;span&gt;&lt;/span&gt;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; specialMap <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">'&gt;'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'&gt;'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> newStr <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[&lt;&gt;]/gm</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>match<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> specialMap<span style="color: #009900;">&#91;</span>match<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// =&gt; '&lt;span&gt;&lt;/span&gt;'</span></div></td></tr></tbody></table></div>
<p class="sub-mainpoint">匹配函数的参数</p>
<p>在上面的例子中，匹配函数带了一个参数，其代表了当前匹配的内容。这个函数还可以带更多的参数。</p>
<p>匹配函数一共可以带 <em>m+3</em> 个参数，其中 m 是正则表达式中组（group）的个数（没 group 时 m 为 0）。</p>
<p>第一个参数是当前匹配内容；倒数第二个参数是当前匹配内容在待匹配字符串中的 index；最后一个参数是带匹配字符串；中间的 m 个参数则依次是各个分组内容。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// 演示匹配函数的参数</span><br />
<span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #3366CC;">'555-666-777-888'</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> pattern <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/(\d+)-(\d+)/g</span><span style="color: #339933;">;</span><br />
<br />
str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>pattern<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>match<span style="color: #339933;">,</span> g1<span style="color: #339933;">,</span> g2<span style="color: #339933;">,</span> index<span style="color: #339933;">,</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>match<span style="color: #339933;">,</span> g1<span style="color: #339933;">,</span> g2<span style="color: #339933;">,</span> index<span style="color: #339933;">,</span> str<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// =&gt; 555-666 555 666 0 555-666-777-888</span><br />
<span style="color: #006600; font-style: italic;">// =&gt; 777-888 777 888 8 555-666-777-888</span><br />
<br />
<span style="color: #006600; font-style: italic;">// 注意：匹配函数中没有 return，那么最终将不会替换</span></div></td></tr></tbody></table></div>
<p class="main-point">构建一个简单的模板函数</p>
<p>在现在，越来越多的功能依赖于 js，比如通过 ajax 等来获取 json 数据，然后拼成相应的 HTML 代码，然后插入到页面。在 HTML 结构复杂的情况下，拼 HTML 字符串是一件极其痛苦的事情，需要十分留意代码嵌套的问题；另外，后期的维护修改起来也是非常的痛苦的，特别是经过压缩的代码。</p>
<p>应对这个问题的一个解决方法就是：模板。正如JSP/PHP/Python 等模板系统一样，通过把 HTML 结构写写来，然后用数据来填写对应的变量，这样便方便了撰写/修改/维护。</p>
<p>现有的 JS 模板系统不少了，但在非大规模应用的情况下，可以简单地写一个函数来实现基本的功能。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
&nbsp;* @overview 根据字符串模板从json数据中生成字符串，模板标志为 {variable}<br />
&nbsp;* @param {String} str 字符串形式的模板<br />
&nbsp;* @param {JSON} data 待生成字符串的 json 数据<br />
&nbsp;*/</span><br />
<span style="color: #003366; font-weight: bold;">function</span> sub<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/{(.*?)}/igm</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">,</span>$1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> data<span style="color: #009900;">&#91;</span>$1<span style="color: #009900;">&#93;</span> <span style="color: #339933;">?</span> data<span style="color: #009900;">&#91;</span>$1<span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">var</span> tpl <span style="color: #339933;">=</span> <span style="color: #3366CC;">'{name} (blog: {blog})'</span><span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> json <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'John'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; blog<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://xx.oo'</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/chinese-in-php.html' title='PHP中的UTF-8中文长度和截断' rel='bookmark'>PHP中的UTF-8中文长度和截断</a></li><li class='rand_post'><a href='http://liunian.info/skip-sensation.html' title='跳过煽情' rel='bookmark'>跳过煽情</a></li><li class='rand_post'><a href='http://liunian.info/%e9%bc%a0%e6%a0%87%e6%bb%9a%e8%bd%ae%e7%bc%a9%e6%94%be%e5%9b%be%e7%89%87.html' title='鼠标滚轮缩放图片' rel='bookmark'>鼠标滚轮缩放图片</a></li><li class='rand_post'><a href='http://liunian.info/trim-for-ie.html' title='trim for IE' rel='bookmark'>trim for IE</a></li><li class='rand_post'><a href='http://liunian.info/use-python3-in-cygwin.html' title='在Cygwin中使用Python 3' rel='bookmark'>在Cygwin中使用Python 3</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/string-replace-in-javascript.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>把JavaScript中的伪数组转换为真数组</title>
		<link>http://liunian.info/convert-fake-array-to-real-array-in-javascript.html</link>
		<comments>http://liunian.info/convert-fake-array-to-real-array-in-javascript.html#comments</comments>
		<pubDate>Wed, 16 May 2012 12:00:45 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[程序设计]]></category>
		<category><![CDATA[arguments]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[NodeList]]></category>
		<category><![CDATA[slice]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=730</guid>
		<description><![CDATA[在 JavaScript 中， 函数中的隐藏变量 arguments 和用  getElementsByTagName 获得的元素集合（NodeList）都不是真正的数组，不能使用 push 等方法，在有这种需要的时候只能先转换为真正的数组。arguments 可以使用 Array.prototype.slice.call 来转换，但在 ie8 及以下，此方法对 NodeList 无效，所以需要循环来实现。<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/%e6%89%be%e5%9b%9eubuntu%e5%8f%b3%e4%b8%8a%e8%a7%92%e7%9a%84%e7%bd%91%e7%bb%9c%e6%8c%87%e7%a4%ba%e5%99%a8.html' title='找回ubuntu右上角的网络指示器' rel='bookmark'>找回ubuntu右上角的网络指示器</a></li><li class='rand_post'><a href='http://liunian.info/somebodys-interview-of-cmcc.html' title='某人的移动面试' rel='bookmark'>某人的移动面试</a></li><li class='rand_post'><a href='http://liunian.info/input-file-in-different-browsers.html' title='input file 在不同浏览器中的呈现' rel='bookmark'>input file 在不同浏览器中的呈现</a></li><li class='rand_post'><a href='http://liunian.info/the-reason-we-break-up.html' title='分手的理由' rel='bookmark'>分手的理由</a></li><li class='rand_post'><a href='http://liunian.info/make-it-crazy-before-destroy-it.html' title='欲毁之，先疯之' rel='bookmark'>欲毁之，先疯之</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>在 JavaScript 中， 函数中的隐藏变量 <span class="code">arguments</span> 和用 <span class="code">getElementsByTagName</span> 获得的元素集合（NodeList）都不是真正的数组，不能使用 <span class="code">push</span> 等方法，在有这种需要的时候只能先转换为真正的数组。</p>
<p>对于 <span class="code">arguments</span>，可以使用 <span class="code">Array.prototype.slice.call(arguments);</span> 来达到转换的目的，但对于 NodeList 则不行了，其在 IE8 及以下将会报错，只能说其 JS 引擎有所限制。</p>
<p>因此，如果需要把 NodeList 转换为真正的数组，则需要做下兼容处理。</p>
<div class="codecolorer-container javascript geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> realArray<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">slice</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> ret <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> len <span style="color: #339933;">=</span> c.<span style="color: #660066;">length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ret<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> ret<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p class="main-point">References</p>
<ol>
<li><a href="http://www.jb51.net/article/24956.htm" title="javascript Array.prototype.slice使用说明">javascript Array.prototype.slice使用说明</a></li>
<li><a href="http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/" title="Advanced Javascript: Objects, Arrays, and Array-Like objects">Advanced Javascript: Objects, Arrays, and Array-Like objects</a></li>
</ol>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/temporarily-relax.html' title='暂时可以休息一下了' rel='bookmark'>暂时可以休息一下了</a></li><li class='rand_post'><a href='http://liunian.info/%e6%81%8d%e7%84%b6%e6%97%b6%e6%97%a5%e8%bf%87.html' title='恍然时日过' rel='bookmark'>恍然时日过</a></li><li class='rand_post'><a href='http://liunian.info/a-little-change.html' title='小打小闹的修改' rel='bookmark'>小打小闹的修改</a></li><li class='rand_post'><a href='http://liunian.info/qqmail-doodle.html' title='QQ邮箱节日Logo' rel='bookmark'>QQ邮箱节日Logo</a></li><li class='rand_post'><a href='http://liunian.info/photoshop-remove-slice.html' title='Photoshop删除切片' rel='bookmark'>Photoshop删除切片</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/convert-fake-array-to-real-array-in-javascript.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>短链公关</title>
		<link>http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html</link>
		<comments>http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html#comments</comments>
		<pubDate>Sun, 06 May 2012 12:00:51 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[随行札记]]></category>
		<category><![CDATA[公关]]></category>
		<category><![CDATA[微博]]></category>
		<category><![CDATA[短链]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=729</guid>
		<description><![CDATA[李开复一条微博的链接无法访问会自动跳回到腾讯微博个人首页。 此时方觉，短链除了节约带宽达到 140 字的目的外，还可以用作公关啊！对于负面影响的外链，不需粗暴删贴，只需腾讯等不解析该短链即可。<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/upgrade-atbhost-space.html' title='升级AtbHost' rel='bookmark'>升级AtbHost</a></li><li class='rand_post'><a href='http://liunian.info/yaca-2011.html' title='YACA五一动漫嘉年华' rel='bookmark'>YACA五一动漫嘉年华</a></li><li class='rand_post'><a href='http://liunian.info/ace-has-dead.html' title='艾斯已死' rel='bookmark'>艾斯已死</a></li><li class='rand_post'><a href='http://liunian.info/view-android-version-of-m9.html' title='查看M9的Android版本' rel='bookmark'>查看M9的Android版本</a></li><li class='rand_post'><a href='http://liunian.info/box-shadow-in-css3.html' title='CSS3 box-shadow' rel='bookmark'>CSS3 box-shadow</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>李开复<a href="http://t.qq.com/p/t/93246038152382" title="李开复抗议媒体误导">一条微博</a>的链接无法访问会自动跳回到腾讯微博个人首页。</p>
<p>此时方觉，短链除了节约带宽达到 140 字的目的外，还可以用作公关啊！对于负面影响的外链，不需粗暴删贴，只需腾讯等不解析该短链即可。</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/jquery-tmpl.html' title='jQuery tmpl' rel='bookmark'>jQuery tmpl</a></li><li class='rand_post'><a href='http://liunian.info/two-problems-in-windows.html' title='两个Windows操作的小问题' rel='bookmark'>两个Windows操作的小问题</a></li><li class='rand_post'><a href='http://liunian.info/change-to-orign-feed.html' title='改回原始feed' rel='bookmark'>改回原始feed</a></li><li class='rand_post'><a href='http://liunian.info/closure-in-javascript.html' title='JavaScript 中的闭包 ' rel='bookmark'>JavaScript 中的闭包 </a></li><li class='rand_post'><a href='http://liunian.info/%e6%94%b9%e5%8f%98%e7%9a%84%e5%85%85%e8%a6%81%e6%9d%a1%e4%bb%b6.html' title='改变的充要条件' rel='bookmark'>改变的充要条件</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>以用户之名</title>
		<link>http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html</link>
		<comments>http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html#comments</comments>
		<pubDate>Sat, 05 May 2012 12:00:19 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[随行札记]]></category>
		<category><![CDATA[用户]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=728</guid>
		<description><![CDATA[“用户觉得”、“用户不觉得”、“用户会”、“用户不会”…… 这样的话语听多了就挺无奈也挺郁闷的：用户来用户去的，谁才是用户？说话者是吗？如果是，不如直接说“我”；如果不是，为何大胆地说“用户觉得”？<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/the-tragic-death-of-practically-everything.html' title='僵尸之地' rel='bookmark'>僵尸之地</a></li><li class='rand_post'><a href='http://liunian.info/mail-direct-link-to-comment.html' title='邮件通知直达评论' rel='bookmark'>邮件通知直达评论</a></li><li class='rand_post'><a href='http://liunian.info/%e8%bd%a6%e6%ac%a1%e5%a2%9e%ef%bc%8c%e5%bc%82%e8%83%bd%e7%8e%b0%ef%bc%8c%e7%a9%bf%e7%9f%ad%e8%a3%99.html' title='车次增，异能现，穿短裙' rel='bookmark'>车次增，异能现，穿短裙</a></li><li class='rand_post'><a href='http://liunian.info/hard-to-a-new-blog.html' title='历尽艰辛搬新家' rel='bookmark'>历尽艰辛搬新家</a></li><li class='rand_post'><a href='http://liunian.info/input-chinese-in-opera-under-ubuntu.html' title='ubuntu下opera中文输入法解决方法' rel='bookmark'>ubuntu下opera中文输入法解决方法</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>“用户觉得”、“用户不觉得”、“用户会”、“用户不会”……</p>
<p>这样的话语听多了就挺无奈也挺郁闷的：用户来用户去的，谁才是用户？说话者是吗？如果是，不如直接说“我”；如果不是，为何大胆地说“用户觉得”？</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/programmers-fate.html' title='程序员的宿命' rel='bookmark'>程序员的宿命</a></li><li class='rand_post'><a href='http://liunian.info/wordpress-rss-favicon-and-robots.html' title='WordPress RSS、favicon和robots技巧' rel='bookmark'>WordPress RSS、favicon和robots技巧</a></li><li class='rand_post'><a href='http://liunian.info/clean-up-wordpress-database.html' title='整理WordPress数据库' rel='bookmark'>整理WordPress数据库</a></li><li class='rand_post'><a href='http://liunian.info/reinstall-grub.html' title='久违的修复grub' rel='bookmark'>久违的修复grub</a></li><li class='rand_post'><a href='http://liunian.info/%e6%82%b2%e8%a7%82%e5%9c%b0%e6%83%b3.html' title='悲观地想' rel='bookmark'>悲观地想</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ubuntu下2个拾色器</title>
		<link>http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html</link>
		<comments>http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html#comments</comments>
		<pubDate>Fri, 04 May 2012 12:00:07 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[color picker]]></category>
		<category><![CDATA[gcolor2]]></category>
		<category><![CDATA[gpick]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[拾色器]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=727</guid>
		<description><![CDATA[Ubuntu 下的使用中的 2 个拾色器工具，Gcolor2 和 Gpick。 Gcolor2 1sudo apt-get install gcolor2 Gcolor2 界面简单美观，只可惜取色的时候没有实时显示选取的地方和颜色，需要点击才能取色，对于细微地方的取色来说可能有点难度。 Gpick 1sudo apt-get install gpick Gpick 界面则稍显复杂一点，但功能强大很多，除了可以实时取色和显示取色点外，还可以自定义颜色方案、分析图片来获取颜色和颜色方案预览（比如web界面）等。<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/%e8%b7%9f%e7%9d%80%e6%84%9f%e8%a7%89%e8%b5%b0.html' title='跟着感觉走' rel='bookmark'>跟着感觉走</a></li><li class='rand_post'><a href='http://liunian.info/software-self-discipline-alliance.html' title='软件自律联盟' rel='bookmark'>软件自律联盟</a></li><li class='rand_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='rand_post'><a href='http://liunian.info/internationalization.html' title='国际化' rel='bookmark'>国际化</a></li><li class='rand_post'><a href='http://liunian.info/%e9%bc%a0%e6%a0%87%e6%bb%9a%e8%bd%ae%e7%bc%a9%e6%94%be%e5%9b%be%e7%89%87.html' title='鼠标滚轮缩放图片' rel='bookmark'>鼠标滚轮缩放图片</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>Ubuntu 下的使用中的 2 个拾色器工具，<strong>Gcolor2</strong> 和 <strong>Gpick</strong>。</p>
<p class="main-point">Gcolor2</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> gcolor2</div></td></tr></tbody></table></div>
<p>Gcolor2 界面简单美观，只可惜取色的时候没有实时显示选取的地方和颜色，需要点击才能取色，对于细微地方的取色来说可能有点难度。</p>
<p><img src="http://img.liunian.info/images/2012/05/Gcolor2.png" width="535" height="337" alt="Gcolor2" /><br />
<span id="more-727"></span></p>
<p class="main-point">Gpick</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> gpick</div></td></tr></tbody></table></div>
<p>Gpick 界面则稍显复杂一点，但功能强大很多，除了可以实时取色和显示取色点外，还可以自定义颜色方案、<strong>分析图片来获取颜色</strong>和颜色方案预览（比如web界面）等。</p>
<p><img src="http://img.liunian.info/images/2012/05/Gpick.png" width="732" height="532" alt="Gpick" /></p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/monthly-summary.html' title='月结' rel='bookmark'>月结</a></li><li class='rand_post'><a href='http://liunian.info/%e6%89%be%e5%9b%9eubuntu%e5%8f%b3%e4%b8%8a%e8%a7%92%e7%9a%84%e7%bd%91%e7%bb%9c%e6%8c%87%e7%a4%ba%e5%99%a8.html' title='找回ubuntu右上角的网络指示器' rel='bookmark'>找回ubuntu右上角的网络指示器</a></li><li class='rand_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='rand_post'><a href='http://liunian.info/the-reason-we-break-up.html' title='分手的理由' rel='bookmark'>分手的理由</a></li><li class='rand_post'><a href='http://liunian.info/emule-nice-at-night.html' title='夜间表现不错的电驴' rel='bookmark'>夜间表现不错的电驴</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>为gimp添加【保存为web格式】功能</title>
		<link>http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html</link>
		<comments>http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html#comments</comments>
		<pubDate>Thu, 03 May 2012 12:00:39 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[gimp]]></category>
		<category><![CDATA[save for web]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[保存为web格式]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=726</guid>
		<description><![CDATA[gimp 默认没有 Photoshop 中的 保存为web格式 的选项，这样发布出去的图片就太大了，可以通过安装插件的形式来达到这个目的。 ubuntu 下 直接 apt-get 即可： 1sudo apt-get install gimp-plugin-registry 这样在 gimp 的 File 菜单中即可看到 save for web 选项，打开后和 Photoshop 的界面大同小异。 windows 下也可以安装，只是需要手动下载解压到 plugins 目录，具体可参照 How to Enable Photoshop Save For Web Feature in GIMP 。<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/codecolorer-in-tiny-mce.html' title='开启CodeColorer可视化编辑' rel='bookmark'>开启CodeColorer可视化编辑</a></li><li class='rand_post'><a href='http://liunian.info/%e8%87%aa%e8%a1%8c%e8%bd%a6%e4%b9%9f%e6%98%af%e8%bd%a6%e5%95%8a.html' title='自行车也是车啊' rel='bookmark'>自行车也是车啊</a></li><li class='rand_post'><a href='http://liunian.info/under-the-bridge-04.html' title='荒川爆笑团04' rel='bookmark'>荒川爆笑团04</a></li><li class='rand_post'><a href='http://liunian.info/change-permalink.html' title='更改固定链接' rel='bookmark'>更改固定链接</a></li><li class='rand_post'><a href='http://liunian.info/sniff-your-browser-history-in-silence.html' title='于悄无声息中获取你的访问记录' rel='bookmark'>于悄无声息中获取你的访问记录</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>gimp 默认没有 Photoshop 中的 <strong>保存为web格式</strong> 的选项，这样发布出去的图片就太大了，可以通过安装插件的形式来达到这个目的。</p>
<p>ubuntu 下 直接 apt-get 即可：</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> gimp-plugin-registry</div></td></tr></tbody></table></div>
<p>这样在 gimp 的 <strong>File</strong> 菜单中即可看到 <strong>save for web</strong> 选项，打开后和 Photoshop 的界面大同小异。</p>
<p><img src="http://img.liunian.info/images/2012/05/gimp-save-for-web.jpg" width="720" height="488" alt="add save for web to gimp" /></p>
<p>windows 下也可以安装，只是需要手动下载解压到 plugins 目录，具体可参照 <a href="http://maketecheasier.com/enable-photoshop-save-for-web-feature-in-gimp/2009/11/22" title="How to Enable Photoshop Save For Web Feature in GIMP">How to Enable Photoshop Save For Web Feature in GIMP</a> 。</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/on-fire.html' title='流刃若火' rel='bookmark'>流刃若火</a></li><li class='rand_post'><a href='http://liunian.info/firefox-outline-boxshadow-bug.html' title='Firefox Box-shadow &amp; Outline bug' rel='bookmark'>Firefox Box-shadow &amp; Outline bug</a></li><li class='rand_post'><a href='http://liunian.info/all-the-same.html' title='都这样' rel='bookmark'>都这样</a></li><li class='rand_post'><a href='http://liunian.info/cache-gravatar-for-wordpress.html' title='Gravatar头像缓存' rel='bookmark'>Gravatar头像缓存</a></li><li class='rand_post'><a href='http://liunian.info/separate-internet-in-china.html' title='【转载】被人为割裂的中国互联网' rel='bookmark'>【转载】被人为割裂的中国互联网</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ubuntu之tree命令</title>
		<link>http://liunian.info/ubuntu%e4%b9%8btree%e5%91%bd%e4%bb%a4.html</link>
		<comments>http://liunian.info/ubuntu%e4%b9%8btree%e5%91%bd%e4%bb%a4.html#comments</comments>
		<pubDate>Mon, 30 Apr 2012 12:00:50 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[tree]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=721</guid>
		<description><![CDATA[一般而言，ls 只是一个简单的 list 工具（虽然可以用各种参数组合来达到一些复杂的功能），但如果想要查看一个目录的目录结构就力不从心了，需要一种打印目录树的 tree 工具。 一段简短而强大的代码 很早以前，在网上看到一段简短而强大的代码，最终可以达到下面这种效果： dem@ubuntu:~$ tree .local /home/dem/.local &#124;-share &#124;---applications &#124;---desktop-directories dem@ubuntu:~$ cd apps/firefox dem@ubuntu:~$ tree /home/dem/apps/firefox &#124;-chrome &#124;---icons &#124;-----default &#124;-components &#124;-defaults &#124;---autoconfig &#124;---pref &#124;---profile &#124;-----chrome &#124;-extensions &#124;---{972ce4c6-7e08-474-a285-320298ce6fd} &#124;---inspector~mozilla.org &#124;-----chrome &#124;-----components &#124;-----defaults &#124;-------preferences &#124;---talkback~mozilla.org &#124;-----components &#124;-------talkback &#124;-greprefs &#124;-icons &#124;-plugins &#124;-res &#124;---dtd &#124;---entityTables &#124;---fonts &#124;---html &#124;-searchplugins &#124;-updates &#124;---0 代码如下（下载链接）： 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647#!/bin/sh ####################################################### # [...]<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/yaca-images-2.html' title='YACA图集2' rel='bookmark'>YACA图集2</a></li><li class='rand_post'><a href='http://liunian.info/how-to-fix-any-computer.html' title='How to fix any computer' rel='bookmark'>How to fix any computer</a></li><li class='rand_post'><a href='http://liunian.info/these-days.html' title='这些日子' rel='bookmark'>这些日子</a></li><li class='rand_post'><a href='http://liunian.info/%e4%b8%8d%e8%a7%81%e5%bd%93%e5%b9%b4%e6%a2%85%e6%8c%af%e8%a1%a3.html' title='不见当年梅振衣' rel='bookmark'>不见当年梅振衣</a></li><li class='rand_post'><a href='http://liunian.info/beautify-and-optimize-wordpress.html' title='美化、优化博客' rel='bookmark'>美化、优化博客</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>一般而言，<span class="code">ls</span> 只是一个简单的 list 工具（虽然可以用各种参数组合来达到一些复杂的功能），但如果想要查看一个目录的目录结构就力不从心了，需要一种打印目录树的 tree 工具。</p>
<p class="main-point">一段简短而强大的代码</p>
<p>很早以前，在网上看到<a href="http://www.centerkey.com/tree/" title="Unix Tree">一段简短而强大的代码</a>，最终可以达到下面这种效果：</p>
<style>span.prompt { color: #5EB847; }span.output { color: #067AEF; }</style>
<table class="box">
<tbody>
<tr>
<td>
<pre><span class="prompt">dem@ubuntu:~$</span> tree .local
<span class="output">
/home/dem/.local
   |-share
   |---applications
   |---desktop-directories
   </span>
<span class="prompt">dem@ubuntu:~$</span> cd apps/firefox
<span class="prompt">dem@ubuntu:~$</span> tree
<span class="output">
/home/dem/apps/firefox
   |-chrome
   |---icons
   |-----default
   |-components
   |-defaults
   |---autoconfig
   |---pref
   |---profile
   |-----chrome
   |-extensions
   |---{972ce4c6-7e08-474-a285-320298ce6fd}
   |---inspector~mozilla.org
   |-----chrome
   |-----components
   |-----defaults
   |-------preferences
   |---talkback~mozilla.org
   |-----components
   |-------talkback
   |-greprefs
   |-icons
   |-plugins
   |-res
   |---dtd
   |---entityTables
   |---fonts
   |---html
   |-searchplugins
   |-updates
   |---0</span></pre>
</td>
</tr>
</tbody>
</table>
<p><span id="more-721"></span><br />
代码如下（<a href="http://www.centerkey.com/tree/tree.sh" title="download tree bash file">下载链接</a>）：</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<span style="color: #666666; font-style: italic;">#######################################################</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;UNIX TREE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Version: 2.3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;File: ~/apps/tree/tree.sh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Displays Structure of Directory Hierarchy &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;------------------------------------------------- &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;This tiny script uses &quot;ls&quot;, &quot;grep&quot;, and &quot;sed&quot; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;in a single command to show the nesting of &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;sub-directories. &nbsp;The setup command for PATH &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;works with the Bash shell (the Mac OS X default). &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Setup: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ cd ~/apps/tree &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ chmod u+x tree.sh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ ln -s ~/apps/tree/tree.sh ~/bin/tree &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ echo &quot;PATH=~/bin:\${PATH}&quot; &gt;&gt; ~/.profile &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Usage: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ tree [directory] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Examples: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ tree &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ tree /etc/opt &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; $ tree .. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;Public Domain Software -- Free to Use as You Like &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp;http://www.centerkey.com/tree &nbsp;- &nbsp;By Dem Pilafian &nbsp;#</span><br />
<span style="color: #666666; font-style: italic;">#######################################################</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> &nbsp;<span style="color: #666666; font-style: italic;">#if parameter exists, use as base folder</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">then</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;$1&quot;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">pwd</span><br />
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-R</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;:$&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> &nbsp; \<br />
&nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/:$//'</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/[^-][^\/]*\//--/g'</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/^/ &nbsp; /'</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/-/|/'</span><br />
<span style="color: #666666; font-style: italic;"># 1st sed: remove colons</span><br />
<span style="color: #666666; font-style: italic;"># 2nd sed: replace higher level folder names with dashes</span><br />
<span style="color: #666666; font-style: italic;"># 3rd sed: indent graph three spaces</span><br />
<span style="color: #666666; font-style: italic;"># 4th sed: replace first dash with a vertical bar</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-F</span> <span style="color: #660033;">-1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> &nbsp; <span style="color: #666666; font-style: italic;"># check if no folders</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">then</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; &nbsp; -&gt; no sub-directories&quot;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">echo</span><br />
<span style="color: #7a0874; font-weight: bold;">exit</span></div></td></tr></tbody></table></div>
<p class="main-point">仓库里的 tree 工具</p>
<p>因为前段时间使用 fedora，在没有上面那段脚本的情况下，敲入 tree 命令时却有输出，于是在 Ubuntu 下 <span class="code">apt-get install tree</span> 了一下，果然有这个软件，而且功能很强大。</p>
<p>想想也是，上面那段代码有说 “Unix Tree / Linux Tree”，那自然是模拟实现已有程序的功能。</p>
<p>参数较多，man 一下或看<a href="http://www.computerhope.com/unix/tree.htm" title="unix tree">在线版</a>，比如可以用 L 参数来设定遍历层数，用 C 参数来使用颜色标识，使用 d 参数来只看目录。</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/%e5%a4%a7%e5%ad%a6.html' title='大学' rel='bookmark'>大学</a></li><li class='rand_post'><a href='http://liunian.info/%e5%8a%a0%e6%9d%af%e8%b1%86%e6%b5%86.html' title='加杯豆浆' rel='bookmark'>加杯豆浆</a></li><li class='rand_post'><a href='http://liunian.info/finish-reading-a-book.html' title='读完一本书' rel='bookmark'>读完一本书</a></li><li class='rand_post'><a href='http://liunian.info/%e7%bd%91%e6%96%87%e5%90%90%e6%a7%bd.html' title='网文吐槽' rel='bookmark'>网文吐槽</a></li><li class='rand_post'><a href='http://liunian.info/%e5%a2%83%e7%95%8c%e5%93%a6.html' title='境界' rel='bookmark'>境界</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/ubuntu%e4%b9%8btree%e5%91%bd%e4%bb%a4.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>更改 Ubuntu 触摸板滚动为自然滚动</title>
		<link>http://liunian.info/add-natural-scrolling-to-ubuntu.html</link>
		<comments>http://liunian.info/add-natural-scrolling-to-ubuntu.html#comments</comments>
		<pubDate>Sun, 29 Apr 2012 14:19:03 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[natural scroll]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[自然滚动]]></category>
		<category><![CDATA[触摸板]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=720</guid>
		<description><![CDATA[前段时间通过修改 grub 参数的形式来让 Ubuntu 识别了触摸板，基本的移动和点击功能可以使用了，但边缘滚动和双指滚动功能还无法正常使用。 但在 Ubuntu 正式发布了 12.04 后，从 beta 版 upgrade 了一下，发现滚动功能居然可以使用了，系统设置了也有了 Touchpad 这个选项卡。 这样，边缘滚动和双指滚动便可以使用了。但默认情况下的滚动是和鼠标的滚动一样的，手指运动方向和滚动条的运动方向一致而和内容的滚动方向相反，对于习惯了手机等触摸屏的滚动方式来说，触摸板的滚动方式有一点违和感，决定调为和触屏手机一致的滚动方式，或者说是 mac 宣称的 natural scroll。 方法一 一开始找到的是个极其简单的方法，只需要添加或修改一个文件即可，具体如下： 在当前用户 home 目录下添加或修改 .Xmodmap 文件 里面内容为：pointer = 1 2 3 5 4 7 6 8 9 10 11 12 注销当前用户再登录即可 虽然具体的数值含义不是很明白，但从 5/4、7/6 的交换情况来看，还是大抵明白是什么原理了：交换了滚动方向的信号。 我尝试后的确可以了，但使用了一会后，当我接上我的无线鼠标后，发现一种更加强烈的违和感了：常规鼠标的滚动方向也被相反了。这应该是那个配置文件做了全局映射的原因，无奈，放弃这种方法。 方法二 在第一个方案的评论中，找到了另一种解决方法，通过安装一个小软件来达到目的，具体如下： 123sudo add-apt-repository ppa:zedtux/naturalscrolling sudo apt-get update [...]<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/no-power-today.html' title='没动力了' rel='bookmark'>没动力了</a></li><li class='rand_post'><a href='http://liunian.info/make-font-better-with-infinality-in-fedora16.html' title='安装配置infinality 优化 fedora 16字体显示' rel='bookmark'>安装配置infinality 优化 fedora 16字体显示</a></li><li class='rand_post'><a href='http://liunian.info/pppoe-on-ubuntu.html' title='Ubuntu下使用宽带' rel='bookmark'>Ubuntu下使用宽带</a></li><li class='rand_post'><a href='http://liunian.info/%e8%ba%ab%e5%b7%b2%e5%88%b0%ef%bc%8c%e5%bf%83%e6%9c%aa%e8%87%b3.html' title='身已到，心未至' rel='bookmark'>身已到，心未至</a></li><li class='rand_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>前段时间通过修改 grub 参数的形式来让 Ubuntu 识别了触摸板，基本的移动和点击功能可以使用了，但边缘滚动和双指滚动功能还无法正常使用。</p>
<p>但在 Ubuntu 正式发布了 12.04 后，从 beta 版 upgrade 了一下，发现滚动功能居然可以使用了，系统设置了也有了 <strong>Touchpad</strong> 这个选项卡。</p>
<p><img src="http://img.liunian.info/images/2012/04/touchpad-settings.png" alt="ubuntu's touchpad settings" width="742" height="543" /><br />
<span id="more-720"></span><br />
这样，边缘滚动和双指滚动便可以使用了。但默认情况下的滚动是和鼠标的滚动一样的，手指运动方向和滚动条的运动方向一致而和内容的滚动方向相反，对于习惯了手机等触摸屏的滚动方式来说，触摸板的滚动方式有一点违和感，决定调为和触屏手机一致的滚动方式，或者说是 mac 宣称的 <em>natural scroll</em>。</p>
<p class="main-point">方法一</p>
<p>一开始找到的是个<a title="adding OSX Lion scrolling to Ubuntu" href="http://iamtherockstar.com/blog/2011/08/15/adding-os-x-lion-scrolling-ubuntu/">极其简单的方法</a>，只需要添加或修改一个文件即可，具体如下：</p>
<blockquote>
<ol>
<li>在当前用户 home 目录下添加或修改 <strong><em>.Xmodmap</em></strong> 文件</li>
<li>里面内容为：<span class="code">pointer = 1 2 3 5 4 7 6 8 9 10 11 12</span></li>
<li>注销当前用户再登录即可</li>
</ol>
</blockquote>
<p>虽然具体的数值含义不是很明白，但从 5/4、7/6 的交换情况来看，还是大抵明白是什么原理了：交换了滚动方向的信号。</p>
<p>我尝试后的确可以了，但使用了一会后，当我接上我的无线鼠标后，发现一种更加强烈的违和感了：常规鼠标的滚动方向也被相反了。这应该是那个配置文件做了全局映射的原因，无奈，放弃这种方法。</p>
<p class="main-point">方法二</p>
<p>在第一个方案的评论中，找到了<a title="naturall scrolling for linux" href="https://github.com/cemmanouilidis/naturalscrolling">另一种解决方法</a>，通过安装一个小软件来达到目的，具体如下：</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> add-apt-repository ppa:zedtux<span style="color: #000000; font-weight: bold;">/</span>naturalscrolling<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> naturalscrolling</div></td></tr></tbody></table></div>
<p>安装完毕后启动这个应用程序即可设置是否启动 natural scrolling 以及是否开机启动。</p>
<p>我专门测试了下触摸板和鼠标的工作情况，触摸板可以使用 natural scrolling，而鼠标也可以维持原有的滚动方式，不错。</p>
<p class="main-point">方法三</p>
<p>方法二可以后，我想了想，既然方法一可以通过简单的配置文件来达到目的，那么按理说，应该不需要常驻一个程序来监控，方便随时调整的 GUI 界面也不是必须的。只是问题是，如何把全局的映射改为只映射触摸版呢？</p>
<p>想了又想，想起当初查找资料来让系统识别触摸板的时候似乎 <span class="code">xinput</span> 有一些设置功能的，尝试地敲了一下帮助命令 <span class="code">xinput -h</span>，发现里面有 <span class="code">get-button-map</span> 和 <span class="code">set-button-map</span> 参数，这下高兴了，找着门道了。</p>
<p>于是先获取到触摸板对应的设备id，然后查看一下其原有的 button-map，然后设置新的 button-map，具体的过程如下图：</p>
<p><img src="http://img.liunian.info/images/2012/04/set-button-map.png" alt="set natural scroll button map for touchpad" width="787" height="521" /></p>
<p>需要注意的是，这种方法会在重启后失效，所以需要把最后那个 <span class="code">set-button-map</span> 命令加到 startup 中，让其开机启动。</p>
<p class="sub-mainpoint">update in 2012-05-03</p>
<p>发现触摸板的 id 会发生变化，从而导致有时 set-button-map 失效，这样的话，直接用 devices name 会更加合适，即：</p>
<div class="codecolorer-container bash geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xinput set-button-map <span style="color: #ff0000;">&quot;FSPPS/2 Sentelic FingerSensingPad&quot;</span> <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">5</span> <span style="color: #000000;">4</span> <span style="color: #000000;">7</span> <span style="color: #000000;">6</span> <span style="color: #000000;">8</span> <span style="color: #000000;">9</span> <span style="color: #000000;">10</span> <span style="color: #000000;">11</span> <span style="color: #000000;">12</span></div></td></tr></tbody></table></div>
<p class="main-point">mouse button maps</p>
<p>查了一下，<a href="http://wiki.birth-online.de/know-how/software/linux/remapping-mousebuttons" title="Remapping mouse buttons">Remapping mouse buttons</a> 一文记录的 mouse button maps 如下：</p>
<table class="bordered-table" border="1" cellspacing="0" cellpadding="3">
<tbody>
<tr>
<th>1</th>
<td>Left click</td>
</tr>
<tr>
<th>2</th>
<td>Middle click</td>
</tr>
<tr>
<th>3</th>
<td>Right click</td>
</tr>
<tr>
<th>4</th>
<td>Wheel up</td>
</tr>
<tr>
<th>5</th>
<td>Wheel down</td>
</tr>
<tr>
<th>6</th>
<td>Wheel left</td>
</tr>
<tr>
<th>7</th>
<td>Wheel right</td>
</tr>
<tr>
<th>8</th>
<td>Thumb1</td>
</tr>
<tr>
<th>9</th>
<td>Thumb2</td>
</tr>
<tr>
<th>10</th>
<td>ExtBt7</td>
</tr>
<tr>
<th>11</th>
<td>ExtBt8</td>
</tr>
</tbody>
</table>
<p>从那文来看，甚至可以做到不同程序使用不同的键映射。</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/a-little-change.html' title='小打小闹的修改' rel='bookmark'>小打小闹的修改</a></li><li class='rand_post'><a href='http://liunian.info/solve-unable-to-remap-in-cygwin.html' title='解决Cygwin『unable to remap』' rel='bookmark'>解决Cygwin『unable to remap』</a></li><li class='rand_post'><a href='http://liunian.info/mid-autumn-festival.html' title='中秋之行' rel='bookmark'>中秋之行</a></li><li class='rand_post'><a href='http://liunian.info/wordpress-object-cache.html' title='开启WordPress Object-cache缓存' rel='bookmark'>开启WordPress Object-cache缓存</a></li><li class='rand_post'><a href='http://liunian.info/input-file-in-different-browsers.html' title='input file 在不同浏览器中的呈现' rel='bookmark'>input file 在不同浏览器中的呈现</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/add-natural-scrolling-to-ubuntu.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>一大步还是只是一小步</title>
		<link>http://liunian.info/%e4%b8%80%e5%a4%a7%e6%ad%a5%e8%bf%98%e6%98%af%e5%8f%aa%e6%98%af%e4%b8%80%e5%b0%8f%e6%ad%a5.html</link>
		<comments>http://liunian.info/%e4%b8%80%e5%a4%a7%e6%ad%a5%e8%bf%98%e6%98%af%e5%8f%aa%e6%98%af%e4%b8%80%e5%b0%8f%e6%ad%a5.html#comments</comments>
		<pubDate>Wed, 25 Apr 2012 12:00:37 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[随行札记]]></category>
		<category><![CDATA[一步]]></category>
		<category><![CDATA[垃圾分类]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=719</guid>
		<description><![CDATA[在广州的道路上，基本上有垃圾桶的地方都有 2 个：可回收垃圾桶和不可回收垃圾桶。 这一步的迈出可以认为是环保观念的改善。 然而，我所存疑的是，究竟这个分类起到作用吗？ 先不说那些可回收和不可回收共存只是中间挡板隔离的垃圾桶是如何达到分取垃圾的情况，姑且先看独立一桶的情况。 按理说，这样足以达到垃圾简单分类处理的目的，因为可以分别回收了。但就我平常的不经意观察来看，环保工人往往只是推了车过来，然后把可回收的、不可回收的都倒进车里。最终，和没有分类放置没有任何的区别。 在此之外，还有别的问题，在扔垃圾的时候有多少是有确定过手头的垃圾该扔那个垃圾桶？家庭垃圾又有多少是有分类带出去的呢？就我自己而言，前一点还好，后一点完全没做到。 垃圾分类，垃圾桶分类了，这一步，到底是一大步还是只是一小步呢？<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/funny-summer-day.html' title='不招惹人会死星人的暑期生活' rel='bookmark'>不招惹人会死星人的暑期生活</a></li><li class='rand_post'><a href='http://liunian.info/%e9%82%82%e9%80%85404.html' title='邂逅404' rel='bookmark'>邂逅404</a></li><li class='rand_post'><a href='http://liunian.info/%e5%a4%a7%e5%ad%a6%e4%b9%8b%e4%ba%8c.html' title='大学之二' rel='bookmark'>大学之二</a></li><li class='rand_post'><a href='http://liunian.info/math.html' title='数学' rel='bookmark'>数学</a></li><li class='rand_post'><a href='http://liunian.info/trim-for-ie.html' title='trim for IE' rel='bookmark'>trim for IE</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>在广州的道路上，基本上有垃圾桶的地方都有 2 个：可回收垃圾桶和不可回收垃圾桶。</p>
<p>这一步的迈出可以认为是环保观念的改善。</p>
<p>然而，我所存疑的是，究竟这个分类起到作用吗？</p>
<p>先不说那些可回收和不可回收共存只是中间挡板隔离的垃圾桶是如何达到分取垃圾的情况，姑且先看独立一桶的情况。</p>
<p>按理说，这样足以达到垃圾简单分类处理的目的，因为可以分别回收了。但就我平常的不经意观察来看，环保工人往往只是推了车过来，然后把可回收的、不可回收的都倒进车里。最终，和没有分类放置没有任何的区别。</p>
<p>在此之外，还有别的问题，在扔垃圾的时候有多少是有确定过手头的垃圾该扔那个垃圾桶？家庭垃圾又有多少是有分类带出去的呢？就我自己而言，前一点还好，后一点完全没做到。</p>
<p>垃圾分类，垃圾桶分类了，这一步，到底是一大步还是只是一小步呢？</p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/%e5%a4%a7%e5%ad%a6.html' title='大学' rel='bookmark'>大学</a></li><li class='rand_post'><a href='http://liunian.info/we-just-say.html' title='We Just Say' rel='bookmark'>We Just Say</a></li><li class='rand_post'><a href='http://liunian.info/somebodys-interview-of-cmcc.html' title='某人的移动面试' rel='bookmark'>某人的移动面试</a></li><li class='rand_post'><a href='http://liunian.info/cross-sns-and-forward-into-new-age-of-internet.html' title='【转载】迈过社会化网络：互联网的新时代' rel='bookmark'>【转载】迈过社会化网络：互联网的新时代</a></li><li class='rand_post'><a href='http://liunian.info/hard-to-a-new-blog.html' title='历尽艰辛搬新家' rel='bookmark'>历尽艰辛搬新家</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/%e4%b8%80%e5%a4%a7%e6%ad%a5%e8%bf%98%e6%98%af%e5%8f%aa%e6%98%af%e4%b8%80%e5%b0%8f%e6%ad%a5.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>ubuntu添加网络打印机</title>
		<link>http://liunian.info/ubuntu%e6%b7%bb%e5%8a%a0%e7%bd%91%e7%bb%9c%e6%89%93%e5%8d%b0%e6%9c%ba.html</link>
		<comments>http://liunian.info/ubuntu%e6%b7%bb%e5%8a%a0%e7%bd%91%e7%bb%9c%e6%89%93%e5%8d%b0%e6%9c%ba.html#comments</comments>
		<pubDate>Tue, 24 Apr 2012 10:00:19 +0000</pubDate>
		<dc:creator>流年</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[ubuntu 12.04]]></category>
		<category><![CDATA[打印机]]></category>

		<guid isPermaLink="false">http://liunian.info/?p=718</guid>
		<description><![CDATA[以前从没连过打印机，现在需要使用部门的打印机，但 System Settings -> Prints 有问题，无法添加网络打印机。 Google 了一下，直接终端运行命令 system-config-printer 来进行配置，一路顺风顺水，测试通过。<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/control-the-comments.html' title='掌控言论' rel='bookmark'>掌控言论</a></li><li class='rand_post'><a href='http://liunian.info/sql-server-user-login-grant-schema.html' title='SQL Server身份验证模式及用户权限' rel='bookmark'>SQL Server身份验证模式及用户权限</a></li><li class='rand_post'><a href='http://liunian.info/wordpress-object-cache.html' title='开启WordPress Object-cache缓存' rel='bookmark'>开启WordPress Object-cache缓存</a></li><li class='rand_post'><a href='http://liunian.info/gray-list.html' title='灰名单' rel='bookmark'>灰名单</a></li><li class='rand_post'><a href='http://liunian.info/skip-sensation.html' title='跳过煽情' rel='bookmark'>跳过煽情</a></li></ul>]]></description>
			<content:encoded><![CDATA[<p>以前从没连过打印机，现在需要使用部门的打印机，但 <strong>System Settings -> Prints</strong> 有问题，无法添加网络打印机。</p>
<p>Google 了一下，直接终端运行命令 <span class="code">system-config-printer</span> 来进行配置，一路顺风顺水，测试通过。</p>
<p><img src="http://img.liunian.info/images/2012/04/add-printer.png" width="602" height="474" alt="add printer in ubuntu 12.04" /></p>
<h4>相关文章</h4><ul id='releated_posts' class='postlist'><li class='releated_post'><a href='http://liunian.info/string-replace-in-javascript.html' title='JavaScript 之 String.replace' rel='bookmark'>JavaScript 之 String.replace</a></li><li class='releated_post'><a href='http://liunian.info/convert-fake-array-to-real-array-in-javascript.html' title='把JavaScript中的伪数组转换为真数组' rel='bookmark'>把JavaScript中的伪数组转换为真数组</a></li><li class='releated_post'><a href='http://liunian.info/%e7%9f%ad%e9%93%be%e5%85%ac%e5%85%b3.html' title='短链公关' rel='bookmark'>短链公关</a></li><li class='releated_post'><a href='http://liunian.info/%e4%bb%a5%e7%94%a8%e6%88%b7%e4%b9%8b%e5%90%8d.html' title='以用户之名' rel='bookmark'>以用户之名</a></li><li class='releated_post'><a href='http://liunian.info/ubuntu%e4%b8%8b2%e4%b8%aa%e6%8b%be%e8%89%b2%e5%99%a8.html' title='Ubuntu下2个拾色器' rel='bookmark'>Ubuntu下2个拾色器</a></li></ul><h4>随机文章</h4><ul id='rand_posts' class='postlist'><li class='rand_post'><a href='http://liunian.info/this-wall-that-wall.html' title='此墙，彼墙' rel='bookmark'>此墙，彼墙</a></li><li class='rand_post'><a href='http://liunian.info/%e4%b8%bagimp%e6%b7%bb%e5%8a%a0%e3%80%90%e4%bf%9d%e5%ad%98%e4%b8%baweb%e6%a0%bc%e5%bc%8f%e3%80%91%e5%8a%9f%e8%83%bd.html' title='为gimp添加【保存为web格式】功能' rel='bookmark'>为gimp添加【保存为web格式】功能</a></li><li class='rand_post'><a href='http://liunian.info/wordpress-boost-html5.html' title='WordPress 助力 HTML5' rel='bookmark'>WordPress 助力 HTML5</a></li><li class='rand_post'><a href='http://liunian.info/like-fireworks.html' title='烟花般破灭' rel='bookmark'>烟花般破灭</a></li><li class='rand_post'><a href='http://liunian.info/lingoes%e6%83%b9%e7%9a%84%e7%a5%b8.html' title='Lingoes惹的祸' rel='bookmark'>Lingoes惹的祸</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://liunian.info/ubuntu%e6%b7%bb%e5%8a%a0%e7%bd%91%e7%bb%9c%e6%89%93%e5%8d%b0%e6%9c%ba.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

