<?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>查理布朗的倒楣世界 &#187; Linux</title>
	<atom:link href="http://clyang.net/blog/category/tech/linux-tech/feed" rel="self" type="application/rss+xml" />
	<link>http://clyang.net/blog</link>
	<description>Clyang's Murmuring</description>
	<lastBuildDate>Tue, 27 Mar 2012 20:57:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>使用Cloudflare的迷思</title>
		<link>http://clyang.net/blog/2011/07/31/429</link>
		<comments>http://clyang.net/blog/2011/07/31/429#comments</comments>
		<pubDate>Sun, 31 Jul 2011 05:28:31 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Cloudflare]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[cloudflare]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=429</guid>
		<description><![CDATA[之前寫了一篇關於cloudflare的文章, 收到了一些朋網友的信件詢問, 很多人都誤以為Cloudflare是網站的萬靈丹, 不但可以加速網站的loading速度, 更可以大幅節省流量. 這些觀點其實都沒有太大的錯誤, 但是卻很容易忽略到隱藏在背後的危機. 手頭上有在幫忙維護某一個擁有大量靜態圖片的網站, 這個特性是非常符合cloudflare的使用情境, 所以在我接手後變幫忙把她弄上去cloudflare, 結果相當的顯著, 網站loading速度變快了許多, 使用者使用意願也大幅增加, 於是帶來了更多的使用者. 聽起來一切都非常美好, 但是卻在server端觀察到, 隨著使用者的成長, 整體的system loading也跟著增加, 才猛然想起cloudflare是不會cache動態產生的檔案(其實html他也不會cache, 所以用rewrite rule去欺騙是沒有用的), 所以當你的網站吸引越來越多的使用者, 需要動態產生的內容也隨之增加, 因此造成server的loading過重. 於是進去後端做了些參數的調整, 就搞定了問題. 此外, 另外一個迷思是, 只要套上cloudflare後, 網站的response time就會進步了, 事實上, "機器的實體位置"還是很重要的, 如同之前提到的, 只要是動態產生的內容, cloudflare就會去跟你的機器索取一次內容, 所以你的機器離cloudflare遍佈在全世界機器的距離還是對response time會有所影響. 簡單地挑選步驟為: 觀察你的使用者多數位在那個國家 使用traceroute.org觀察這些國家的使用者會被導到cloudflare在全球的那個機房 &#8230; <a href="http://clyang.net/blog/2011/07/31/429">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>之前寫了一篇關於<a href="http://www.cloudflare.com">cloudflare</a>的文章, 收到了一些朋網友的信件詢問, 很多人都誤以為Cloudflare是網站的萬靈丹, 不但可以加速網站的loading速度, 更可以大幅節省流量. 這些觀點其實都沒有太大的錯誤, 但是卻很容易忽略到隱藏在背後的危機.</p>
<p><span id="more-429"></span>
<p>手頭上有在幫忙維護某一個擁有大量靜態圖片的網站, 這個特性是非常符合<a href="http://www.cloudflare.com">cloudflare</a>的使用情境, 所以在我接手後變幫忙把她弄上去<a href="http://www.cloudflare.com">cloudflare</a>, 結果相當的顯著, 網站loading速度變快了許多, 使用者使用意願也大幅增加, 於是帶來了更多的使用者.</p>
<p>聽起來一切都非常美好, 但是卻在server端觀察到, 隨著使用者的成長, 整體的system loading也跟著增加, 才猛然想起<a href="http://www.cloudflare.com">cloudflare</a>是不會cache動態產生的檔案(其實html他也不會cache, 所以用rewrite rule去欺騙是沒有用的), 所以當你的網站吸引越來越多的使用者, 需要動態產生的內容也隨之增加, 因此造成server的loading過重. 於是進去後端做了些參數的調整, 就搞定了問題.</p>
<p>此外, 另外一個迷思是, 只要套上<a href="http://www.cloudflare.com">cloudflare</a>後, 網站的response time就會進步了, 事實上, "機器的實體位置"還是很重要的, 如同之前提到的, 只要是動態產生的內容, <a href="http://www.cloudflare.com">cloudflare</a>就會去跟你的機器索取一次內容, 所以你的機器離<a href="http://www.cloudflare.com">cloudflare</a>遍佈在全世界機器的距離還是對response time會有所影響. 簡單地挑選步驟為:</p>
<ol>
<li>觀察你的使用者多數位在那個國家</li>
<li>使用<a href="traceroute.org">traceroute.org</a>觀察這些國家的使用者會被導到<a href="http://www.cloudflare.com">cloudflare</a>在全球的那個機房</li>
<li>選擇離這些機房近的hosting provider</li>
</ol>
<p>以台灣使用者為例, 大多數都被導到<a href="http://www.cloudflare.com">cloudflare</a>為在香港或是美西的機房, 所以會建議選擇在美國西岸的provider, 以達到最好的效果.</p>
<p>最後, 這個故事教會了我們什麼? 1) 如果你後端的code寫得很爛, 使用<a href="http://www.cloudflare.com">cloudflare</a>只會加速你網站的死亡速度. 2) 透過<a href="http://www.cloudflare.com">cloudflare</a>可以快速地(這邊比較的基準是在國外的vps, 如果你是使用國內hosting的有錢大爺, 不在此列 XD)將網站的靜態內容傳遞給使用者, 沒有意外的話PV會隨之增加, 請在server端做好準備. 3) 請慎選機器的實體位置.</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2011/07/31/429/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>正式啓用CloudFlare + 簡單介紹</title>
		<link>http://clyang.net/blog/2011/05/29/378</link>
		<comments>http://clyang.net/blog/2011/05/29/378#comments</comments>
		<pubDate>Sun, 29 May 2011 08:38:51 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Cloudflare]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[cdn]]></category>
		<category><![CDATA[cloudflare]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=378</guid>
		<description><![CDATA[去年底出現了一個有趣的網路應用業者CloudFlare, 幾個月內採用的網站劇增, 其實這個網站的概念跟多年前Giga推出的WebAMP相同, 都是提供reverse proxy提供網站加速服務, 但CloudFlare更進一步的為網站擁有者解決了部屬jpg/js/css這類static file到CDN上的問題, 透過部屬在全球各大洲的cache server (詳細列表在此) , 提供高效率的服務. 我從網路上面找到兩張使用前以及使用後的示意圖, 使用前的狀況是: 而使用後是: CloudFlare除了幫忙把網頁的靜態檔案推到他的CDN上面外, 還提供詳細的網站流量報表, 網路攻擊基本的防禦, javascript/css自動minify以及其他許多方便的功能. 同時, 他還很佛心的提供免費方案, 跟pro方案對我而言最大的差別是在免費的只能等到24hr結束才能看到報表, 而pro方案則是每15分鐘就會有一次統計, 除此之外大概就是免費版本不支援ssl的連線, 但是免費的沒辦法要求太多, 所以就將就一下啦 申請的過程就不多加贅述, 唯一要注意的是妳必須把你的nameserver從本來的provider改指到CloudFlare的機器, 他提供很方便的匯入功能, 所以基本上就是到你現在使用的provdier匯出你的zone file後, 然後在CloudFlare的註冊過程中匯入, 此外, 你依舊可以透過CloudFlare提供的dns manager來管理你的domain, 介面設計的很容易上手, 應該不會有使用上的問題. 同時他會幫你多添加一筆"direct.你的domain"的A record, 如果妳本來是使用你的domain &#8230; <a href="http://clyang.net/blog/2011/05/29/378">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>去年底出現了一個有趣的網路應用業者<a href="http://cloudflare.com/">CloudFlare</a>, 幾個月內採用的網站劇增, 其實這個網站的概念跟多年前Giga推出的<a href="http://zh.wikipedia.org/wiki/WebAMP">WebAM</a>P相同, 都是提供reverse proxy提供網站加速服務, 但<a href="http://cloudflare.com/">CloudFlare</a>更進一步的為網站擁有者解決了部屬jpg/js/css這類static file到CDN上的問題, 透過部屬在全球各大洲的cache server (<a href="https://www.cloudflare.com/system-status.html">詳細列表在此</a>) , 提供高效率的服務.</p>
<p>我從網路上面找到兩張使用前以及使用後的示意圖, 使用前的狀況是:</p>
<p><img title="Speed-Up-and-Protect-Your-Blog-with-CloudFlare-01.jpg" src="http://designersdigest.co/wp-content/uploads/2010/11/Speed-Up-and-Protect-Your-Blog-with-CloudFlare-01.jpg" border="0" alt="Speed-Up-and-Protect-Your-Blog-with-CloudFlare-01.jpg" /></p>
<p><span id="more-378"></span>
<p>而使用後是:</p>
<p><img title="Speed-Up-and-Protect-Your-Blog-with-CloudFlare-02.jpg" src="http://designersdigest.co/wp-content/uploads/2010/11/Speed-Up-and-Protect-Your-Blog-with-CloudFlare-02.jpg" border="0" alt="Speed-Up-and-Protect-Your-Blog-with-CloudFlare-02.jpg" /></p>
<p><a href="http://cloudflare.com/">CloudFlare</a>除了幫忙把網頁的靜態檔案推到他的CDN上面外, 還提供詳細的網站流量報表, 網路攻擊基本的防禦, javascript/css自動minify以及其他許多方便的功能. 同時, 他還很佛心的提供免費方案, 跟pro方案對我而言最大的差別是在免費的只能等到24hr結束才能看到報表, 而pro方案則是每15分鐘就會有一次統計, 除此之外大概就是免費版本不支援ssl的連線, 但是免費的沒辦法要求太多, 所以就將就一下啦 <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>申請的過程就不多加贅述, 唯一要注意的是妳必須把你的nameserver從本來的provider改指到<a href="http://cloudflare.com/">CloudFlare</a>的機器, 他提供很方便的匯入功能, 所以基本上就是到你現在使用的provdier匯出你的zone file後, 然後在<a href="http://cloudflare.com/">CloudFlare</a>的註冊過程中匯入, 此外, 你依舊可以透過<a href="http://cloudflare.com/">CloudFlare</a>提供的dns manager來管理你的domain, 介面設計的很容易上手, 應該不會有使用上的問題. 同時他會幫你多添加一筆"<strong>direct.你的domain</strong>"的A record, 如果妳本來是使用你的domain name當作主要的website url, 因為這個A record會被改指到<a href="http://cloudflare.com/">CloudFlare</a>的機器上, 所以如果妳直接使用ssh/ftp這類軟體連接會連不上, 所以請改連"<strong>direct.你的domain</strong>" (如果妳不滿意direct, 可以自行更改)</p>
<p>此外, 妳可以隨時決定是不是要透過<a href="http://cloudflare.com/">CloudFlare</a>來serve你的user, 只需要透過<a href="http://cloudflare.com/">CloudFlare</a>的dns manager, 點擊妳不想透過<a href="http://cloudflare.com/">CloudFlare</a>服務的那個名稱右方的雲朵即可切換 (如下圖所示, 橘色為enable)</p>
<p><img title="螢幕快照 2011-05-29 上午8.48.34.png" src="http://clyang.net/blog/wp-content/uploads/2011/05/螢幕快照-2011-05-29-上午8.48.341.png" border="0" alt="螢幕快照 2011 05 29 上午8 48 34" width="1070" height="269" /></p>
<p>如果一切正常, 大概等個10分鐘讓設定生效, 可以隨便在你的站上選個靜態檔案, 透過curl -I測試一下, 如果有看到下列結果就表示成功啦(跑個兩次應該就可以看到HIT):</p>
<p><img title="cloudflare_test.png" src="http://clyang.net/blog/wp-content/uploads/2011/05/cloudflare_test1.png" border="0" alt="Cloudflare test" width="930" height="191" /></p>
<p>測試過後, Hinet會連往日本的機房, 而學術網路則是會連到美西去, 希望可以早日改連到香港或是日本, 減少更多的latency.</p>
<p>接下來就是漂亮的統計報告, 在一堆數據中, 還會告訴你使用<a href="http://cloudflare.com/">CloudFlare</a>後, 他幫你省下多少流量以及整體速度加速了多少, 詳細圖表如下:</p>
<p><img title="cloudflare.png" src="http://clyang.net/blog/wp-content/uploads/2011/05/cloudflare3.png" border="0" alt="Cloudflare" width="900" height="1180" /></p>
<p>當然, <a href="http://cloudflare.com/">CloudFlare</a>不是沒有缺點, 首先因為他其實就是reverse proxy, 所以從server log到上層application所看到的ip都會變成<a href="http://cloudflare.com/">CloudFlare</a>的機器, 如果你有網站機器的權限, 可以使用<a href="http://cloudflare.com/">CloudFlare</a>提供的apache/lighttpd的<a href="http://www.cloudflare.com/wiki/Log_Files">module</a>, 一旦安裝後他就會自動轉換正確的user ip給上層ap. 如果你沒有機器的管理權限, 那可以參考<a href="http://www.cloudflare.com/wiki/Log_Files">這邊</a>是否有列出你所使用的應用軟體套件可以使用 (常見的wordpress,VBulletin都有). 如果你是自行開發網站, 要取得user真實ip其實就是從http header中取出CF-Connecting-IP這個field即可. 第二, 你必須要擁有本來的DNS的控制權, 如果你沒辦法變更nameserver的設定, 那就一切免談啦 <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>最後, 幾天使用下來感覺還不錯用, 大家可以申請個免費帳號來玩玩看 <img src='http://clyang.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2011/05/29/378/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>推薦使用tmux &#8211; a &quot;terminal multiplexer&quot;</title>
		<link>http://clyang.net/blog/2009/09/26/356</link>
		<comments>http://clyang.net/blog/2009/09/26/356#comments</comments>
		<pubDate>Fri, 25 Sep 2009 18:11:32 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[tmux]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=356</guid>
		<description><![CDATA[tmux是一個類似常見的GNU Screen軟體，那作者為啥還開發呢，原因單純，他覺得Screen使用的Licence是GNU有些限制，所以就順手寫了一個類似功能但是卻是用BSD Licence，除了Screen常用的功能都有外，tmux還可以在單一一個window中處理多個不同的terminal，如果你常跟我之前一樣需要常常切換在Screen之間去做事情，你一定會愛死tmux的!! 首先，先來談談如何安裝，由於不是每種OS所提供的tmux package都是最新的1.0版，所以我會建議直接抓tarball回來編譯，快又簡單。安裝步驟如下: 下載最新的tmux tarball (目前是tmux-1.0.tar.gz) 解開tarball: tar zxf tmux-1.0.tar.gz 如果你不是FreeBSD uesr請跳過此步驟，編輯configure檔，移除第215行的"#define HAVE_TREE_H" ./configure &#38;&#38; make &#38;&#38; make install 大功告成 如果上述步驟一切順利，理論上就可以順利執行tmux了，但是tmux預設的command prefix是Ctrl+b而非Screen慣用的Ctrl+a，所以我會建議先編輯一份自己專屬的tmux設定檔(vim ~/.tmux.conf)，設定如下: 原始檔在此下載 # Written by clyang _AT_ clyang.net # General Setting set-option -g prefix C-a set-window-option &#8230; <a href="http://clyang.net/blog/2009/09/26/356">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>是一個類似常見的<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">GNU Screen</a>軟體，那作者為啥還開發呢，原因單純，他覺得<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">Screen</a>使用的Licence是GNU有些限制，所以就順手寫了一個類似功能但是卻是用BSD Licence，除了<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">Screen</a>常用的功能都有外，<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>還可以在單一一個window中處理多個不同的terminal，如果你常跟我之前一樣需要常常切換在<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">Screen</a>之間去做事情，你一定會愛死<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>的!!</p>
<p><span id="more-356"></span>首先，先來談談如何安裝，由於不是每種OS所提供的<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a> package都是最新的1.0版，所以我會建議直接抓tarball回來編譯，快又簡單。安裝步驟如下:</p>
<ol>
<li>下載最新的<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a> tarball (目前是tmux-1.0.tar.gz)</li>
<li>解開tarball: tar zxf tmux-1.0.tar.gz</li>
<li>如果你<strong><span style="text-decoration: underline;">不是</span></strong>FreeBSD uesr請<strong><span style="text-decoration: underline;">跳過</span></strong>此步驟，編輯configure檔，移除第215行的<strong>"#define HAVE_TREE_H"</strong></li>
<li>./configure &amp;&amp; make &amp;&amp; make install</li>
<li>大功告成</li>
</ol>
<p>如果上述步驟一切順利，理論上就可以順利執行<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>了，但是<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>預設的command prefix是Ctrl+b而非<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">Screen</a>慣用的Ctrl+a，所以我會建議先編輯一份自己專屬的<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a>設定檔(vim ~/.tmux.conf)，設定如下: <a title="clyang's tmux.conf" href="http://clyang.net/src/tmux.conf" target="_blank">原始檔在此下載</a></p>
<p style="padding-left: 30px;">
<pre class="brush: bash">
# Written by clyang _AT_ clyang.net
# General Setting
set-option -g prefix C-a
set-window-option -g automatic-rename off

# Statusbar properties.
set -g display-time 3000
set -g status-bg black
set -g status-fg cyan
set -g status-right &quot;#(uptime|awk &#039;{print $11}&#039;) #(date)&quot;

# Fix putty/pietty function key problem
set -g terminal-overrides &quot;xterm*:kf1=\e[11~:kf2=\e[12~:kf3=\e[13~:kf4=\e[14~:kf5=\e[15~:kf6=\e[17~:kf7=\e[18~:kf8=\e[19~&quot;

# Binding key
bind C-a send-prefix
bind s split-window
bind &#039;&quot;&#039; splitw\; selectl main-vertical
bind -n F1 lock
bind -n F2 up-pane
bind -n F3 down-pane
bind -n F9 resizep -U 1
bind -n F10 resizep -D 1
bind -n F11 resizep -L 1
bind -n F12 resizep -R 1

# Tmux lock setting
pass -c &#039;$1$A.n6u0qu$KwXA5FnUfkWJpVLoIY1D30&#039;
</pre>
<p>上述設定檔簡單來說，我把預設的send-prefix從Ctrl+b改成<a title="GNU Screen" href="http://www.gnu.org/software/screen/" target="_blank">Screen</a>習慣使用的Ctrl+a，然後定義一些快速鍵讓做事情更方便，列表如下:</p>
<ul>
<li>Ctrl+a後按 s : 將視窗切為左右兩個區塊</li>
<li>Ctrl+a後按 " : 將視窗切為上下兩個區塊</li>
<li>Ctrl+a後按 c : 產生新的window (跟screen一樣)</li>
<li>Ctrl+a後按 d : 將<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a> detch到背景 (呼叫回來請使用<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a> attach，就如同screen -r)</li>
<li>按下F1: 鎖定tmux，會顯示一個大型的數位時鐘，密碼預設在tmux.conf裡面, 請使用<strong><span style="text-decoration: underline;">"openssl passwd -1&#8243;</span></strong>產生，再將該字串填入pass -c後面那一串，<span style="text-decoration: underline;">別忘了前後都要加上單引號 </span><strong><span style="text-decoration: underline;">&#8216; </span></strong><span style="text-decoration: underline;">喔!!</span>當你必須暫時離開座位時，只需要按下F1馬上鎖定tmux</li>
<li>F2移動到單一畫面中的上一個pane</li>
<li>F3移動到單一畫面中的下一個pane</li>
<li>F9將目前這個pane的邊界往上增加一行</li>
<li>F10將目前這個pane的邊界往下增加一行</li>
<li>F11將目前這個pane的邊界往左增加一行</li>
<li>F12將目前這個pane的邊界往右增加一行</li>
</ul>
<p>其他的功能，大家多多摸索吧，建議趕快裝起來自己體驗一下<a title="tmux" href="http://tmux.sourceforge.net/" target="_blank">tmux</a> + 上述快速鍵好用的地方吧!!!</p>
<p><span style="background-color: #ffffff;">最後當然要有圖有真相(畫面左邊跟右邊那三個切割視窗就是稱之為pane，按F2、F3可以在各pane間切換，按F9~F12可以調整每個pane的大小):</span></p>
<p><span style="background-color: #ffffff;"><img class="alignnone size-large wp-image-360" title="tmux" src="http://clyang.net/blog/wp-content/uploads/2009/09/tmux-1024x798.PNG" alt="tmux" width="1024" height="798" /></span></p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/09/26/356/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>在Debian下快速合併多個tiff檔並轉成pdf格式</title>
		<link>http://clyang.net/blog/2009/06/19/329</link>
		<comments>http://clyang.net/blog/2009/06/19/329#comments</comments>
		<pubDate>Fri, 19 Jun 2009 11:11:26 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[ps2pdf]]></category>
		<category><![CDATA[tiff2pdf]]></category>
		<category><![CDATA[tiff2ps]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=329</guid>
		<description><![CDATA[前幾天朋友傳了一大個壓縮檔給我，打開後發現是一本極度實用的工具書，但是讓人困擾的是每一個頁面都是掃描後的tiff檔案，所以造成閱讀上的極度不便，而且也非常浪費磁碟空間，突然想起之前曾經將單一個tiff檔案轉換成pdf的經驗，所以稍微摸索了一下，總算研究出來作法。 轉換指令極為簡單，唯一要確定的是你的系統中有安裝libtiff-tools以及Ghostscript，如果缺少請先"apt-get install ghostscript libtiff-tools"安裝一下吧，一旦安裝完畢，只需將你要轉換的tiff檔案都放置在同樣的資料夾下，然後只用下列指令即可一次搞定: tiff2ps *.tif &#124; ps2pdf14 -sPAPERSIZE=a4 &#8211; &#62; output.pdf 請注意&#8217;-'跟&#8217;&#62;&#8217;中間是有個空白的!!!有兩個部份要稍微說明一下，第一個是關於ps2pdf14的部份，這地方是指定轉換出來的pdf檔案的相容性: ps2pdf12 轉換出來的檔案相容於Acobat 3以後的版本 ps2pdf13 轉換出來的檔案相容於Acobat 4以後的版本 ps2pdf14 轉換出來的檔案相容於Acobat 5以後的版本 而"-sPAPERSIZE"則是指定輸出的紙張大小，這邊我使用的是A4，其他詳細可以指定的紙張大小請參考這個超仔細的頁面。 最後，關於效率的部份，我轉換每個約8.1MB大小的110個tiff檔，耗時約20分20秒(CPU為Xeon E5405)，產出的pdf檔案約25MB，成果讓我相當滿意!]]></description>
			<content:encoded><![CDATA[<p>前幾天朋友傳了一大個壓縮檔給我，打開後發現是一本極度實用的工具書，但是讓人困擾的是每一個頁面都是掃描後的tiff檔案，所以造成閱讀上的極度不便，而且也非常浪費磁碟空間，突然想起之前曾經將單一個tiff檔案轉換成pdf的經驗，所以稍微摸索了一下，總算研究出來作法。</p>
<p><span id="more-329"></span></p>
<p>轉換指令極為簡單，唯一要確定的是你的系統中有安裝<a title="libtiff-tools" href="http://www.libtiff.org/tools.html" target="_blank">libtiff-tools</a>以及<a title="Ghostscript" href="http://pages.cs.wisc.edu/~ghost/" target="_blank">Ghostscript</a>，如果缺少請先"<strong>apt-get install ghostscript libtiff-tools</strong>"安裝一下吧，一旦安裝完畢，只需將你要轉換的tiff檔案都放置在同樣的資料夾下，然後只用下列指令即可一次搞定:</p>
<blockquote><p>tiff2ps *.tif | ps2pdf14 -sPAPERSIZE=a4 &#8211; &gt; output.pdf</p></blockquote>
<p><strong>請注意&#8217;-'跟&#8217;&gt;&#8217;中間是有個空白的</strong>!!!有兩個部份要稍微說明一下，第一個是關於ps2pdf14的部份，這地方是指定轉換出來的pdf檔案的相容性:</p>
<ol>
<li>ps2pdf12 轉換出來的檔案相容於Acobat 3以後的版本</li>
<li>ps2pdf13 轉換出來的檔案相容於Acobat 4以後的版本</li>
<li>ps2pdf14 轉換出來的檔案相容於Acobat 5以後的版本</li>
</ol>
<p>而"<strong>-sPAPERSIZE</strong>"則是指定輸出的紙張大小，這邊我使用的是<strong>A4</strong>，其他詳細可以指定的紙張大小請參考這個<a title="detail paper size code" href="http://pages.cs.wisc.edu/~ghost/doc/cvs/Use.htm#Known_paper_sizes" target="_blank">超仔細的頁面</a>。</p>
<p>最後，關於效率的部份，我轉換每個約8.1MB大小的110個tiff檔，耗時約20分20秒(CPU為Xeon E5405)，產出的pdf檔案約25MB，成果讓我相當滿意!</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/06/19/329/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linode磁碟空間大方送~33% up!</title>
		<link>http://clyang.net/blog/2009/05/11/311</link>
		<comments>http://clyang.net/blog/2009/05/11/311#comments</comments>
		<pubDate>Mon, 11 May 2009 14:28:53 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linode]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=311</guid>
		<description><![CDATA[今天登入我的linode後台，才發現這件事情，感謝linode照顧現有客戶啦，又多4G可以用了。詳細的調整可以在這邊找到。]]></description>
			<content:encoded><![CDATA[<p>今天登入我的linode後台，才發現這件事情，感謝linode照顧現有客戶啦，又多4G可以用了。詳細的調整<a title="linode upgrade disk space" href="http://blog.linode.com/2009/04/23/33-additional-disk-space/" target="_blank">可以在這邊找到</a>。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/05/11/311/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mencoder轉影片給IPod Touch觀賞之全攻略</title>
		<link>http://clyang.net/blog/2009/03/08/268</link>
		<comments>http://clyang.net/blog/2009/03/08/268#comments</comments>
		<pubDate>Sat, 07 Mar 2009 18:44:48 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[IPod Touch]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[mencoder]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=268</guid>
		<description><![CDATA[*** Note *** 本篇的作法轉出來的檔案也可以順利的在IPhone上面播放 IPod Touch除了聽歌功能強悍外，影音撥放的能力也是吸引我的重點，大小適中的螢幕適合在通勤或出門等朋友時拿出來看看影片打發時間，可惜IPod Touch承襲著Apple Inc.一貫的風格，只能撥放MPEG4以及x264的編碼，對於大多數的電影採取的xvid、DivX或是日劇常用的rmvb都不支援，必須經過轉換才可以正常撥放，Windows上面有一堆簡單方便且免費的軟體可以使用，但是我實在不想要浪費自己電腦的資源和電費來做這種浪費時間的事情，於是腦筋就動到某台身在遠方卻有8個核心可以使用的強大機器，用遠端的運算資源，電費也是別人家付，多划算阿!!! 畢竟在這經濟不景氣的年代，說要好好善用資源啊!!! XD 那台機器上面跑的是Linux，所以很自然的就想到mencoder這個好用的轉檔程式，支援市面上常見的各種格式。無奈我在該台機器上面沒有root的權限，所以花了很多工夫才弄好，於是在這邊跟大家分享一下，如果再沒有root權限的情況下，裝好mencoder，步驟非常繁複，但是一步一步跟著做應該可以成功編譯完成才是(God bless XD)。 cd /tmp ; mkdir convert ; cd convert ; mkdir x264 yasm faac 到這裡以及這裡抓取下列必要的檔案 (如果有更新的日期就抓最新的) source snapshot essential-20071007.tar.bz2 all-20071007.tar.bz2 windows-all-20071007.zip 解壓縮最新的source snapsot到/tmp/convert/mplayer_code 再把all-20071007.tar.bz2解壓縮到/tmp/convert/codecs 再將windows-all-20071007.zip解壓縮到/tmp/convert/win32 最後將all-20071007.tar.bz2分別解壓縮到/tmp/convert/codecs以及/tmp/convert/win32 (兩個目錄都要喔) 在這裡下載最新的x264原始碼並解壓縮到/tmp/convert/x264_code &#8230; <a href="http://clyang.net/blog/2009/03/08/268">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>*** Note *** 本篇的作法轉出來的檔案也可以順利的在<a title="IPhone" href="http://www.apple.com/iphone" target="_blank">IPhone</a>上面播放</strong></span></p>
<p><a title="IPod Touch" href="http://www.apple.com/ipodtouch/">IPod Touch</a>除了聽歌功能強悍外，影音撥放的能力也是吸引我的重點，大小適中的螢幕適合在通勤或出門等朋友時拿出來看看影片打發時間，可惜<a title="IPod Touch" href="http://www.apple.com/ipodtouch/">IPod Touch</a>承襲著<a title="Apple Inc." href="http://www.apple.com">Apple Inc.</a>一貫的風格，只能撥放MPEG4以及x264的編碼，對於大多數的電影採取的xvid、DivX或是日劇常用的rmvb都不支援，必須經過轉換才可以正常撥放，Windows上面有一堆簡單方便且免費的軟體可以使用，但是我實在不想要浪費自己電腦的資源和電費來做這種浪費時間的事情，於是腦筋就動到某台身在遠方卻有8個核心可以使用的強大機器，用遠端的運算資源，電費也是別人家付，多划算阿!!! 畢竟在這經濟不景氣的年代，說要好好善用資源啊!!! XD</p>
<p><span id="more-268"></span>那台機器上面跑的是Linux，所以很自然的就想到<a title="mencoder" href="http://www.mplayerhq.hu/design7/news.html" target="_blank">mencoder</a>這個好用的轉檔程式，支援市面上常見的各種格式。無奈我在該台機器上面沒有root的權限，所以花了很多工夫才弄好，於是在這邊跟大家分享一下，如果再沒有root權限的情況下，裝好<a title="mencoder" href="http://www.mplayerhq.hu/design7/news.html" target="_blank">mencoder</a>，步驟非常繁複，但是一步一步跟著做應該可以成功編譯完成才是(God bless XD)。</p>
<ol>
<li>cd /tmp ; mkdir convert ; cd convert ; mkdir x264 yasm faac</li>
<li>到<a title="mencoder src" href="http://www.mplayerhq.hu/design7/dload.html" target="_blank">這裡</a>以及<a title="mencoder codec" href="http://www.mplayerhq.hu/MPlayer/releases/codecs/" target="_blank">這裡</a>抓取下列必要的檔案 (如果有更新的日期就抓最新的)<br />
source snapshot<br />
essential-20071007.tar.bz2<br />
all-20071007.tar.bz2<br />
windows-all-20071007.zip</li>
<li>解壓縮最新的source snapsot到/tmp/convert/mplayer_code<br />
再把all-20071007.tar.bz2解壓縮到/tmp/convert/codecs<br />
再將windows-all-20071007.zip解壓縮到/tmp/convert/win32<br />
最後將all-20071007.tar.bz2分別解壓縮到/tmp/convert/codecs以及/tmp/convert/win32<br />
(<strong>兩個目錄都要喔</strong>)</li>
<li>在<a title="x264 latest source code" href="ftp://ftp.videolan.org/pub/videolan/x264/snapshots/" target="_blank">這裡</a>下載最新的x264原始碼並解壓縮到/tmp/convert/x264_code</li>
<li>取得<a title="libfaac" href="http://www.audiocoding.com/downloads.html" target="_blank">libfaac最新的原始碼</a>，目前是1.28，解壓縮放到/tmp/convert/faac_code</li>
<li>取得<a title="yasm" href="http://www.tortall.net/projects/yasm/wiki/Download" target="_blank">yasm最新的原始碼</a>，目前是0.7.2，解壓縮放到/tmp/convert/yasm_code</li>
<li>安裝<a title="yasm" href="http://www.tortall.net/projects/yasm/" target="_blank">yasm</a><br />
cd /tmp/convert/yasm_code<br />
./configure &#8211;prefix=/tmp/convert/yasm<br />
make &amp;&amp; make install</li>
<li>安裝<a title="x264 codec" href="http://www.videolan.org/developers/x264.html" target="_blank">x264 codec</a><br />
cd /tmp/convert/x264_code<br />
./configure &#8211;prefix=/tmp/convert/x264<br />
make &amp;&amp; make install</li>
<li>安裝<a title="libfaac" href="http://www.audiocoding.com/faac.html" target="_blank">libfaac</a><br />
cd /tmp/convert/faac_code<br />
./configure &#8211;prefix=/tmp/convert/faac<br />
make &amp;&amp; make install</li>
<li>終於進到重點了，開始正式安裝<a title="mencoder" href="http://www.mplayerhq.hu/design7/news.html" target="_blank">mencoder</a>，由於我們不需要mplayer播放器，所以就不用編譯了，省下一些等待時間。<br />
cd /tmp/convert/mplayer_code<br />
./configure &#8211;prefix=/tmp/convert &#8211;disable-mplayer &#8211;codecsdir=/tmp/convert/codecs &#8211;win32codecsdir=/tmp/convert/win32 &#8211;language=zh_TW &#8211;with-extraincdir=/tmp/convert/faac/include:/tmp/convert/x264/include &#8211;with-extralibdir=/tmp/convert/faac/lib:/tmp/convert/x264/lib<br />
make &amp;&amp; make install</li>
<li>如果一切順利，編譯好的<a title="mencoder" href="http://www.mplayerhq.hu/design7/news.html" target="_blank">mencoder</a>就會放置在/tmp/convert/bin的目錄下供您使用啦。</li>
<li>最後使用前，記得先額外指定LD Library Path到<a title="libfaac" href="http://www.audiocoding.com/faac.html" target="_blank">libfaac</a>的目錄:<br />
export LD_LIBRARY_PATH=/tmp/convert/faac/lib</li>
</ol>
<p>假設上面這複雜且費時的12大步驟都順完成了，就可以開始來轉換檔案給<a title="IPod Touch" href="http://www.apple.com/ipodtouch/">IPod Touch</a>用啦!轉檔前先研究了一下<a title="IPod Touch" href="http://www.apple.com/ipodtouch/">IPod Touch</a>對於影像最多可以支援道甚麼程度</p>
<blockquote><p>H.264 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Baseline Profile up to Level 3.0 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats</p></blockquote>
<p>瞭解了之後，才能針對規格去下轉換的參數，關於參數的部分我參考網路上一堆文章後，自己試用後，綜合起來推薦下列的指令 (<strong>別懷疑，那一堆是一整行的指令</strong>):</p>
<p style="padding-left: 30px;">/tmp/convert/bin/mencoder 輸入檔案名稱 -o 輸出檔名.mp4 -vf scale=480:-10,harddup \<br />
-lavfopts format=mp4 -faacopts mpeg=4:object=2:raw:br=128 -oac faac -ovc x264 \<br />
-sws 9 -x264encopts nocabac:level_idc=30:bframes=0:global_header:threads=auto:\<br />
subq=5:frameref=6:partitions=all:trellis=1:chroma_me:me=umh:bitrate=500 -of lavf</p>
<p>下了上面那長串的指令，轉出來的檔案便可以直接餵進去<a title="IPod Touch" href="http://www.apple.com/ipodtouch/">IPod Touch</a>來撥放啦。相信應該有人還是會好奇上面的指令用了一堆參數，到底都代表著甚麼意義呢?我挑幾個重要的出來說明一下，如果需要微調的話也有個依據:</p>
<ul>
<li>-sws 9 &#8212; 影像resampling使用Lanczos Algorithm來強化影像</li>
<li>-vf scale=480:-10 &#8212; 將轉出來的影像寬度設為480，高度自動調整，但是維持在16的倍數，為什麼是16的倍數呢?因為多數的codec在長寬都是16的倍數時壓縮效率最好。</li>
<li>-vf harddup &#8212; 為了維持frame rate，必要時插入重複的frame</li>
<li>-x264encopts nocabac:level_idc=30 &#8212; 因為IPod Touch只支援Baseline Profile Level 3.0</li>
<li>-x264encopts bframes=0 &#8212; 因為Baseline Profile不允許B-Frames</li>
<li>-x264encopts global_header &#8212; 使用單一的全域header，可以節省壓縮後的空間</li>
<li>-x264encopts threads=auto &#8212; <strong><span style="text-decoration: underline;">使用multithreading加快轉換速度</span>，</strong>但是<a title="x264 codes threads sideeffect" href="http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html" target="_blank">會損失一點點點點點的品質</a></li>
<li>-x264encopts subq=5:frameref=6 &#8212; quarterpixel精度作動作預測設定到最高，並且最多使用6個refernce frames</li>
<li>-x264encopts partitions=all &#8212; 使用全部的microblock size</li>
<li>-x264encopts trellis &#8212; 降低編碼的速度及品質，但是可以減少產生出來的檔案大小</li>
<li>-x264encopts me=umh &#8212; fullpixel的運動補償使用umh演算法</li>
</ul>
<p>我自己測試壓縮了rmvb、wmv及avi (xvid codec)的<span style="text-decoration: line-through;">謎</span>影片，在8 core (dual Xeon E5405 2GHz)的機器上的表現為</p>
<ul>
<li>avi 檔案處理效率約為 128 fps</li>
<li>rmvb 檔案處理效率約為 110 fps</li>
<li><strong>wmv 檔案處理效率約為11 fps</strong></li>
</ul>
<p>說真的，我也不知道為什麼轉換WMV的效率如此之爛，改天我再拿其他的檔案測測看吧。Anyway，這篇從安裝到轉檔到各項參數均完整說明，希望對有這樣需求的朋友們有所幫助啦。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/03/08/268/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>好用的curlftpfs</title>
		<link>http://clyang.net/blog/2009/03/02/262</link>
		<comments>http://clyang.net/blog/2009/03/02/262#comments</comments>
		<pubDate>Sun, 01 Mar 2009 16:07:43 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[curlftpfs]]></category>
		<category><![CDATA[debian]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=262</guid>
		<description><![CDATA[常常在開發網頁程式時，我們會在自己習慣的平台上面寫完及測試後後，再丟上去真正運轉的機器運行，最常見的方法便是用ftp client上傳，但如果更新較為頻繁，這個動作做多了還是會不太耐煩，總希望可以直接mount遠方的ftp目錄當作是自己的一個目錄來使用，如此一來，只需要使用常用的cp、rm這類的指令便可以達到操作遠端ftp目錄下的檔案的功能。 幸運的是，在Debian下面有個方便的套件叫做curlftpfs，這軟體使用的底層便是大名鼎鼎的FUSE，搭配著cURL Library組合而成，讓我們可以很方便的在Debian下直接mount遠方的ftp資料夾。 安裝及使用方法如下: apt-get install curlftpfs (安裝curlftpfs) curlftpfs -o iocharset=big5,codepage=utf8,ipv4,user=帳號:密碼 ftp://xxx.xxx.xxx.xxx 本地目錄 iocharset指的是本機端所使用的編碼 codepage指的是ftp那端所使用的編碼 密碼不可以包含空白 如果你不希望你的密碼暴露出來，可以僅使用user=帳號，如此一來程式會要求你輸入密碼後再繼續執行。最後，假若你希望能在每次開機後，自動mount遠端某個ftp目錄，請編輯/etc/fstab加上一行 curlftpfs#xxx.xxx.xxx.xxx /mount的目錄 fuse rw,iocharset=big5,codepage=utf8,ipv4,user=帳號:密碼,user,noauto 0 0 記得更改一下/etc/fstab的權限，否則就全部的人都可以看到你的帳號密碼了。]]></description>
			<content:encoded><![CDATA[<p>常常在開發網頁程式時，我們會在自己習慣的平台上面寫完及測試後後，再丟上去真正運轉的機器運行，最常見的方法便是用ftp client上傳，但如果更新較為頻繁，這個動作做多了還是會不太耐煩，總希望可以直接mount遠方的ftp目錄當作是自己的一個目錄來使用，如此一來，只需要使用常用的cp、rm這類的指令便可以達到操作遠端ftp目錄下的檔案的功能。</p>
<p>幸運的是，在<a title="Debian" href="http://www.debian.org/" target="_blank">Debian</a>下面有個方便的套件叫做<a title="curlftpfs" href="http://curlftpfs.sourceforge.net/" target="_blank">curlftpfs</a>，這軟體使用的底層便是大名鼎鼎的<a title="FUSE" href="http://fuse.sourceforge.net/" target="_blank">FUSE</a>，搭配著<a title="cURL" href="http://curl.haxx.se/" target="_blank">cURL Library</a>組合而成，讓我們可以很方便的在<a title="Debian" href="http://www.debian.org/" target="_blank">Debian</a>下直接mount遠方的ftp資料夾。</p>
<p>安裝及使用方法如下:</p>
<ol>
<li>apt-get install curlftpfs (安裝curlftpfs)</li>
<li>curlftpfs -o iocharset=big5,codepage=utf8,ipv4,user=帳號:密碼 ftp://xxx.xxx.xxx.xxx 本地目錄<br />
iocharset指的是本機端所使用的編碼<br />
codepage指的是ftp那端所使用的編碼<br />
密碼不可以包含空白</li>
</ol>
<p>如果你不希望你的密碼暴露出來，可以僅使用<strong>user=帳號</strong>，如此一來程式會要求你輸入密碼後再繼續執行。最後，假若你希望能在每次開機後，自動mount遠端某個ftp目錄，請編輯/etc/fstab加上一行</p>
<blockquote><p>curlftpfs#xxx.xxx.xxx.xxx /mount的目錄 fuse rw,iocharset=big5,codepage=utf8,ipv4,user=帳號:密碼,user,noauto 0 0</p></blockquote>
<p>記得更改一下/etc/fstab的權限，否則就全部的人都可以看到你的帳號密碼了。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/03/02/262/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>推薦中國反垃圾郵件聯盟(CASA)的RBL</title>
		<link>http://clyang.net/blog/2009/02/26/254</link>
		<comments>http://clyang.net/blog/2009/02/26/254#comments</comments>
		<pubDate>Thu, 26 Feb 2009 14:55:31 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[antispam]]></category>
		<category><![CDATA[casa]]></category>
		<category><![CDATA[cblless]]></category>
		<category><![CDATA[cblplus]]></category>
		<category><![CDATA[rbl]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=254</guid>
		<description><![CDATA[中國反垃圾郵件聯盟是一個非營利的由一群熱心的中國網友所建立的。從建立到現在已經建立了一定的公信力以及很低的誤擋率，大陸/香港地區有非常非常多的人採用他們所提供的RBL(Realtime Block List)。 為什麼需要他們的RBL? 因為語言的關係，台灣絕大多數的Spam都是從對岸送過來的，這個組織則是專門針對對岸發spam的ip去做蒐集的動作。所以實用價值非常高 :Q 他們目前提供的RBL有分為四種: CBL, CDL, CBL+, CBL- 說明如下: CBL -&#62;  中國地區的垃圾郵件ip sender黑名單 CDL -&#62;  中國地區所有的dynamic ip列表 CBL+ -&#62; 其實就是 CBL + CDL CBL- -&#62; 等於 CBL + CDL &#8211; CML 甚麼是CML? 其實就是Whitelist的概念，他讓大型的mail provider去註冊他所屬機器的網段，以免被列入進到了CBL。為了避免隨便任何人都可以註冊，他定的門檻還算高，門檻如下: mail account數目超過10,000個 所屬的機器在半年內都沒有被列進去CBL &#8230; <a href="http://clyang.net/blog/2009/02/26/254">繼續閱讀 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="CASA" href="http://www.anti-spam.org.cn/" target="_blank">中國反垃圾郵件聯盟</a>是一個非營利的由一群熱心的中國網友所建立的。從建立到現在已經建立了一定的公信力以及很低的誤擋率，大陸/香港地區有非常非常多的人採用他們所提供的RBL(Realtime Block List)。</p>
<p><span id="more-254"></span>為什麼需要他們的RBL? 因為語言的關係，台灣絕大多數的Spam都是從對岸送過來的，這個組織則是專門針對對岸發spam的ip去做蒐集的動作。所以實用價值非常高 :Q</p>
<p>他們目前提供的RBL有分為四種: CBL, CDL, CBL+, CBL- 說明如下:</p>
<ol>
<li><a title="CBL" href="http://www.anti-spam.org.cn/AID/7" target="_blank"><strong>CBL</strong> </a>-&gt;  中國地區的垃圾郵件ip sender黑名單</li>
<li><strong><a title="CDL" href="http://www.anti-spam.org.cn/AID/8" target="_blank">CDL</a> -</strong>&gt;  中國地區所有的dynamic ip列表</li>
<li><a title="CBL+" href="http://www.anti-spam.org.cn/AID/9" target="_blank"><strong>CBL+</strong></a> -&gt; 其實就是 CBL + CDL</li>
<li><a title="CBL-" href="http://www.anti-spam.org.cn/AID/10" target="_blank"><strong>CBL-</strong></a> -&gt; 等於 CBL + CDL &#8211; CML</li>
</ol>
<p>甚麼是CML? 其實就是Whitelist的概念，他讓大型的mail provider去註冊他所屬機器的網段，以免被列入進到了CBL。為了避免隨便任何人都可以註冊，他定的門檻還算高，門檻如下:</p>
<ol>
<li>mail account數目超過10,000個</li>
<li>所屬的機器在半年內都沒有被列進去<a title="CBL" href="http://www.anti-spam.org.cn/AID/7" target="_blank"><strong>CBL</strong></a><a title="CBL" href="http://www.anti-spam.org.cn/AID/7" target="_blank"> </a></li>
<li>所屬機器在三個月內沒有被國外知名的RBL(<a title="Spamcop" href="http://www.spamcop.net" target="_blank">spamcop</a>, <a title="Spamhamius" href="http://www.spamhaus.org" target="_blank">spamhamus</a>)列進去</li>
<li>登記的管理員必須跟<a title="APNIC" href="http://www.apnic.net" target="_blank">APNIC</a>註冊的相同</li>
</ol>
<p>這邊建議如果管的是大眾使用的mail server，採取<a title="CBL-" href="http://www.anti-spam.org.cn/AID/10" target="_blank"><strong>CBL-</strong></a>會是比較保守卻安全的做法。 如果是個人或是實驗室的mail server，不妨可以玩玩<a title="CBL+" href="http://www.anti-spam.org.cn/AID/9" target="_blank"><strong>CBL+</strong></a>會更有效。</p>
<p>手邊的幾台機器已經使用<a title="CBL-" href="http://www.anti-spam.org.cn/AID/10" target="_blank"><strong>CBL-</strong></a>一年多了，幾乎沒有問題，除了非常非常偶爾該組織會將Hinet、GMail的少數機器列入清單中，但是移除速度還蠻快的，但整體對於spam的阻擋率非常讓人滿意，算是瑕不掩瑜。</p>
<p>看到這邊，想要使用的管理者們大概有個疑問，這個RBL機器架設在對岸，反應速度會不會很緩慢而拖垮整個mail server的效率呢?答案是，<strong>不會的</strong>!因為<a title="中正資工" href="http://www.cs.ccu.edu.tw/" target="_blank"><strong>中正大學資工系/所</strong></a>有架設他們在台灣的Mirror Site，所以速度上完全不用擔心。</p>
<p>寫到這邊，該寫點技術的內容了，以免被罵騙稿費 XD. 如何在現有的mail server中使用這個好用的RBL呢?這裡以<a title="Postfix" href="http://www.postfix.org" target="_blank">postfix</a>使用<a title="CBL-" href="http://www.anti-spam.org.cn/AID/10" target="_blank"><strong>CBL-</strong></a>為例:</p>
<ol>
<li>編輯<a title="Postfix" href="http://www.postfix.org" target="_blank">postfix</a>的main.cf中的<strong>smtpd_recipient_restrictions</strong>的等號後加上一行<br />
<strong>reject_rbl_client cblless.anti-spam.org.cn=127.0.8.5</strong></p>
<p>若是使用其他的如<strong><a title="CDL" href="http://www.anti-spam.org.cn/AID/8" target="_blank">CDL</a></strong>,<a title="CBL+" href="http://www.anti-spam.org.cn/AID/9" target="_blank"><strong>CBL+</strong></a>,<a title="CBL" href="http://www.anti-spam.org.cn/AID/7" target="_blank"><strong>CBL</strong></a>請改用下列的選擇<br />
<a title="CBL" href="http://www.anti-spam.org.cn/AID/7" target="_blank"><strong>CBL</strong></a>:    <strong>reject_rbl_client cbl.anti-spam.org.cn=127.0.8.2</strong><br />
<strong><a title="CDL" href="http://www.anti-spam.org.cn/AID/8" target="_blank">CDL</a>:   reject_rbl_client cdl.anti-spam.org.cn=127.0.8.4</strong><br />
<a title="CBL+" href="http://www.anti-spam.org.cn/AID/9" target="_blank"><strong>CBL+</strong></a>: <strong>reject_rbl_client cblplus.anti-spam.org.cn=127.0.8.6</strong></li>
</ol>
<p>設定好後，存檔並且重新啟動或是reload postfix即可。要怎麼知道是否有成功使用呢?檢查你的maillog中是否出現下列類似的紀錄:</p>
<blockquote><p>NOQUEUE: reject: RCPT from abyo215.neoplus.adsl.tpnet.pl[83.9.34.215]: 554 5.7.1 Service unavailable; Client host [83.9.34.215] blocked using cblless.anti-spam.org.cn=127.0.8.5; Mail from 83.9.34.215 refused, see http://anti-spam.org.cn/Rbl/Query/Result?IP=83.9.34.215;</p></blockquote>
<p>有的話，恭喜你執行成功了，接下來幾個小時好好觀察貴單位的spam有沒有減少吧。</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/26/254/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL的wildcard character</title>
		<link>http://clyang.net/blog/2009/02/21/223</link>
		<comments>http://clyang.net/blog/2009/02/21/223#comments</comments>
		<pubDate>Sat, 21 Feb 2009 15:54:19 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[wildcard character]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=223</guid>
		<description><![CDATA[也許是因為我跟MySQL太不熟，長久以來我都以為MySQL裡面的wildcard character只有 % 跟 * (for host and table name)，所以我就被愚弄了 Orz 之前寫的一個的MySQL服務會自動的加上 "帳號_" 的prefix，昨天我在檢查MySQL的時候突然發現有個資料庫是 "帳號-" 的prefix，心中第一個想法就是"糟糕! 遇到高手，第一天就被人玩爛了"。後來看了一下log跟user的設定發現是先用系統建立一個 xxx_test的db，然後在程式端因為打錯字，打成了xxx-test，妙的是系統竟然也接受，即便這個user沒有create的權限!! 後來經過一番survey才發現原來"_"也是個wildcard character，所以一旦建立了xxx_test的資料庫以及其對應的權限，user就可以自由的建立 xxx*test(ex: xxx-test，xxxatest，xxxbtest)。所幸發現的早，一下就搞定這個因為我的無知而造成的bug Orz 結論，所有東西的refernece manual都應該乖乖的看阿 Orz]]></description>
			<content:encoded><![CDATA[<p>也許是因為我跟<a title="MySQL" href="http://www.mysql.com/" target="_blank">MySQL</a>太不熟，長久以來我都以為<a title="MySQL" href="http://www.mysql.com/" target="_blank">MySQL</a>裡面的wildcard character只有 % 跟 * (for host and table name)，所以我就被愚弄了 Orz</p>
<p>之前寫的一個的<a title="MySQL" href="http://www.mysql.com/" target="_blank">MySQL</a>服務會自動的加上 "帳號_" 的prefix，昨天我在檢查<a title="MySQL" href="http://www.mysql.com/" target="_blank">MySQL</a>的時候突然發現有個資料庫是 "帳號-" 的prefix，心中第一個想法就是"糟糕! 遇到高手，第一天就被人玩爛了"。後來看了一下log跟user的設定發現是先用系統建立一個<strong> xxx_test</strong>的db，然後在程式端因為打錯字，打成了<strong>xxx-test</strong>，妙的是系統竟然也接受，即便這個user沒有create的權限!!</p>
<p>後來經過一番survey才發現原來"<strong>_</strong>"也是個wildcard character，所以一旦建立了xxx_test的資料庫以及其對應的權限，user就可以自由的建立 xxx<span style="text-decoration: underline;"><strong>*</strong></span>test(ex: xxx<span style="text-decoration: underline;">-</span>test，xxx<strong><span style="text-decoration: underline;">a</span></strong>test，xxx<span style="text-decoration: underline;"><strong>b</strong></span>test)。所幸發現的早，一下就搞定這個因為我的無知而造成的bug Orz</p>
<p>結論，所有東西的refernece manual都應該乖乖的看阿 Orz</p>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/21/223/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>aria2c &#8211; Linux下的多線程下載軟體</title>
		<link>http://clyang.net/blog/2009/02/20/218</link>
		<comments>http://clyang.net/blog/2009/02/20/218#comments</comments>
		<pubDate>Fri, 20 Feb 2009 15:07:29 +0000</pubDate>
		<dc:creator>clyang</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[aria2c]]></category>
		<category><![CDATA[debian]]></category>

		<guid isPermaLink="false">http://clyang.net/blog/?p=218</guid>
		<description><![CDATA[很多朋友轉換到Linux下的時候，再下載大型檔案時，往往會遭遇到網路速度緩慢，想要使用在Windows上面像是flashget這類的多線程軟體，來加速下載。這裡推薦一個好用的小軟體 &#8211; aria2c，不但能夠多線程下載檔案，也能夠拿來下載bittorrent的檔案(有支援DHT)，不過下載bittorrent還是建議使用rtorrent比較威猛剛強一點，這邊介紹在Debian下面如何安裝使用aria2c。 在Debian下面安裝aria2c非常簡單: apt-get install aria2c 多線程下載使用方法如下: aira2c -s16 http://file.to.download/file.zip -s 後面接的數字是線程數目，限制是1~16，應該可以滿足大多數人的需求，如果需要更高的數目，可以透過 -j 來增加。 如果你需要使用aria2c來下載bittorrent檔案，使用方法如下: aria2c  &#8211;enable-dht  &#8211;listen-port=某個port &#8211;max-upload-limit=單一檔案上傳速度 &#8211;max-overall-upload-limit=全局上傳速度 &#8211;torrent-file=torrent檔案 上面簡單介紹了最常使用到的兩種功能，其他的細部設定請自行參酌aria2c的man page。]]></description>
			<content:encoded><![CDATA[<p>很多朋友轉換到Linux下的時候，再下載大型檔案時，往往會遭遇到網路速度緩慢，想要使用在Windows上面像是<a title="flashget" href="http://www.flashget.com" target="_blank">flashget</a>這類的多線程軟體，來加速下載。這裡推薦一個好用的小軟體 &#8211; <a title="aria2c" href="http://aria2.sourceforge.net/" target="_blank">aria2c</a>，不但能夠多線程下載檔案，也能夠拿來下載<a title="Bittorrent" href="http://www.bittorrent.com" target="_blank">bittorrent</a>的檔案(有支援<a title="DHT" href="http://zh.wikipedia.org/wiki/%E5%88%86%E6%95%A3%E5%BC%8F%E9%9B%9C%E6%B9%8A%E8%A1%A8" target="_blank">DHT</a>)，不過下載<a title="Bittorrent" href="http://www.bittorrent.com" target="_blank">bittorrent</a>還是建議使用<a title="rtorrent" href="http://libtorrent.rakshasa.no/browser" target="_blank">rtorrent</a>比較威猛剛強一點，這邊介紹在<a title="Debian" href="http://www.debian.org" target="_blank">Debian</a>下面如何安裝使用<a title="aria2c" href="http://aria2.sourceforge.net/" target="_blank">aria2c</a>。</p>
<p>在Debian下面安裝aria2c非常簡單:</p>
<blockquote><p>apt-get install aria2c</p></blockquote>
<p>多線程下載使用方法如下:</p>
<blockquote><p>aira2c <strong>-s16</strong> http://file.to.download/file.zip</p>
<p><strong>-s</strong> 後面接的數字是線程數目，限制是1~16，應該可以滿足大多數人的需求，如果需要更高的數目，可以透過 <strong>-j</strong> 來增加。</p></blockquote>
<p>如果你需要使用aria2c來下載<a title="Bittorrent" href="http://www.bittorrent.com" target="_blank">bittorrent</a>檔案，使用方法如下:</p>
<blockquote><p>aria2c  <strong>&#8211;enable-dht  &#8211;listen-port=</strong>某個port <strong>&#8211;max-upload-limit</strong>=單一檔案上傳速度 <strong>&#8211;max-overall-upload-limit</strong>=全局上傳速度 <strong>&#8211;torrent-file</strong>=torrent檔案</p></blockquote>
<p>上面簡單介紹了最常使用到的兩種功能，其他的細部設定請自行參酌aria2c的man page。</p>
<blockquote></blockquote>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><!-- Do not remove -->]]></content:encoded>
			<wfw:commentRss>http://clyang.net/blog/2009/02/20/218/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

