<?xml version="1.0" encoding="UTF-8"?>
<rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>笨頭哥的沒營養文章集</title>
	
	<link>http://blog.hubert.tw</link>
	<description>Hubert's Blog</description>
	<lastBuildDate>Sun, 22 Aug 2010 14:24:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/hubert" /><feedburner:info uri="hubert" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>以 boost type traits 在 compile time 檢查 function 的 prototype</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/k3FlUn9hC4g/</link>
		<comments>http://blog.hubert.tw/2010/08/22/%e4%bb%a5-boost-type-traits-%e5%9c%a8-compile-time-%e6%aa%a2%e6%9f%a5-function-%e7%9a%84-prototype/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 14:19:51 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[boost]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=592</guid>
		<description><![CDATA[在使用 Google C++ Mocking Framework 的時候很可能遇到一個情況，當原本的 virtual function 的 prototype 改變的時候，你所 mocking 的 prototype 很可能不是預期會被呼叫的那個。 舉例來說 #include &#60;gmock /gmock.h&#62; #include &#60;gtest /gtest.h&#62; class CA { protected: virtual void FuncB() { std::cout &#60; &#60; &#34;CA FuncB&#34; &#60;&#60; std::endl; } public: void &#8230; <a href="http://blog.hubert.tw/2010/08/22/%e4%bb%a5-boost-type-traits-%e5%9c%a8-compile-time-%e6%aa%a2%e6%9f%a5-function-%e7%9a%84-prototype/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>在使用 <a href="http://code.google.com/p/googlemock/">Google C++ Mocking Framework</a> 的時候很可能遇到一個情況，當原本的 virtual function 的 prototype 改變的時候，你所 mocking 的 prototype 很可能不是預期會被呼叫的那個。<br />
<span id="more-592"></span><br />
舉例來說</p>
<pre class="brush: cpp;">
#include &lt;gmock /gmock.h&gt;
#include &lt;gtest /gtest.h&gt;

class CA
{
protected:
    virtual void FuncB() {
        std::cout &lt; &lt; &quot;CA FuncB&quot; &lt;&lt; std::endl;
    }

public:
    void FuncA() {
        FuncB();
    }
};

class CAOverrider: public CA
{
public:
    MOCK_METHOD0(FuncB, void());
};

void OverrideFuncB(){
    std::cout &lt;&lt; &quot;Override FuncB&quot; &lt;&lt; std::endl;
}

TEST(CATest, ExtractAndOverrideFuncB)
{
    using ::testing::Invoke;

    CAOverrider ca;
    EXPECT_CALL(ca, FuncB())
        .WillOnce(Invoke(OverrideFuncB));

    ca.FuncA();
}
</pre>
<p>然而有一天，有一個新同事覺得他必須傳一個參數 int 進到 FuncB 當中，就直接對於宣告與實作動了手腳，所有的測試以及 production code 都沒有問題，直到跑了這個 unit test 才發現，原本預期被呼叫的 void (CA::*)() 沒有被呼叫，實際被呼叫的是 void (CA::*)(int) 這個版本。</p>
<p>那麼我們可不可以直接產生出 Google Mock Framework 所需的 function prototype 呢？一開始的腦袋先動到 <a href="http://www.boost.org/doc/html/typeof/tuto.html">BOOST_TYPEOF</a> 這個 macro，不過我馬上意識到，這樣所產生出的型別是帶有 CA::* 這樣的 member pointer，與 Google C++ Mocking Framework 所需的並不相同。</p>
<p>在翻過一些文章之後，我發現過去曾經有人在 boost type traits 當中加入 <a href="https://svn.boost.org/trac/boost/browser/sandbox/type_traits/boost/type_traits/remove_member_pointer.hpp ">remove_member_pointer.hpp</a> 這個檔案</p>
<p>於是關鍵的那行就可以改成</p>
<pre class="brush: cpp;">
class CAOverrider: public CA
{
public:
    MOCK_METHOD0(FuncB,  boost::remove_member_pointer&lt;boost_typeof (&amp;CA::FuncB)&gt;::type);
};
</pre>
<p>如此一來就能夠在編譯的時期意識到這個問題了。</p>
<p>回到問題的本質上，這個問題起因於 MOCK_METHOD0 並沒有辦法明確指出他有 override CA 的 FuncB。這個問題似乎也在 C++0x 的 <a href="http://www.open-std.org/Jtc1/sc22/WG21/docs/papers/2009/n2928.htm">Explicit Virtual Overrides</a> 提出解法了。</p>
<p>我想這個解決方法並不是相當優雅，但也讓我開始意識到 C++ 的 template, type 以及 trait 的多樣性，也驅使我由這點再開始閱讀 Boost MPL，雖然現在才剛剛開始，但或許之後也慢慢會有不同的思維吧！</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/k3FlUn9hC4g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/08/22/%e4%bb%a5-boost-type-traits-%e5%9c%a8-compile-time-%e6%aa%a2%e6%9f%a5-function-%e7%9a%84-prototype/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/08/22/%e4%bb%a5-boost-type-traits-%e5%9c%a8-compile-time-%e6%aa%a2%e6%9f%a5-function-%e7%9a%84-prototype/</feedburner:origLink></item>
		<item>
		<title>關於 Agile 我想說的是</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/ep4T0wT2JWs/</link>
		<comments>http://blog.hubert.tw/2010/07/19/%e9%97%9c%e6%96%bc-agile-%e6%88%91%e6%83%b3%e8%aa%aa%e7%9a%84%e6%98%af/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 16:09:23 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=587</guid>
		<description><![CDATA[坐在床上，老實說我沒想到在連續忙了好多天之後，還想打出這樣一篇混亂而隨性的文章。 有時候我覺得瘋狂，或是覺得難以想像，耳邊忽然冒出許多像是 Agile, Scrum 這樣嶄新的名詞，許多工程師、或是 Project Manager 開始上這些「認證」的課程。所以我身邊多了一些 Scrum Master，或是一些帶領工程師進入新 process 的人。 有人說 Agile 對軟體是有意義的，因為他讓每個人「必須」 溝通：讓所有人知道你在做什麼，是不是做對的事情。合乎 spec 嗎？有測試嗎？ 透明化：隨時公開專案的進度 （附註：我知道 Agile 的精神還有測試。） 如果單只是如此，那你的 Agile 可能並不是 Agile，而可能只是在傳統的執行面上，加上一層「看似溝通」的保護。容許我這樣說，如果在 Agile 的精神之外，每天的 daily stand up meeting，只是把 weekly report 變成 daily report 而已。即便如此，我覺得溝通絕對是有益處的。適度的回應讓專案進度變得透明，也能確保 design 與 &#8230; <a href="http://blog.hubert.tw/2010/07/19/%e9%97%9c%e6%96%bc-agile-%e6%88%91%e6%83%b3%e8%aa%aa%e7%9a%84%e6%98%af/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>坐在床上，老實說我沒想到在連續忙了好多天之後，還想打出這樣一篇混亂而隨性的文章。</p>
<p>有時候我覺得瘋狂，或是覺得難以想像，耳邊忽然冒出許多像是 Agile, Scrum 這樣嶄新的名詞，許多工程師、或是 Project Manager 開始上這些「認證」的課程。所以我身邊多了一些 Scrum Master，或是一些帶領工程師進入新 process 的人。<span id="more-587"></span></p>
<p>有人說 Agile 對軟體是有意義的，因為他讓每個人「必須」</p>
<ol>
<li>溝通：讓所有人知道你在做什麼，是不是做對的事情。合乎 spec 嗎？有測試嗎？</li>
<li>透明化：隨時公開專案的進度</li>
</ol>
<p>（附註：我知道 Agile 的精神還有測試。）</p>
<p>如果單只是如此，那你的 Agile 可能並不是 Agile，而可能只是在傳統的執行面上，加上一層「看似溝通」的保護。容許我這樣說，如果在 Agile 的精神之外，每天的 daily stand up meeting，只是把 weekly report 變成 daily report 而已。即便如此，我覺得溝通絕對是有益處的。適度的回應讓專案進度變得透明，也能確保 design 與 implementation 與 spec 是相同的（有種 BDD 的意味）。</p>
<p>回想起碩士班的時候，指導教授會回復你每一封 E-mail，如果沒有特別的 comment，可能就只是一封「Good, Y.B」這樣的回復。現在想起來，其實我覺得很安心，老師雖然不知道什麼是 Agile 或是 Scrum 這些近代的 process，但是我們之間有種默契，至少老師知道我做了什麼，對於我的 Weekly Report 有什麼想法。或是我也知道哪一件事情正在進行，老師可能之後還會再回覆我。</p>
<p>我想 Agile 會不會只是一種手段？即便還沒有 Agile，因著彼此的信任，卻達到某種 Agile 執行面的手法。</p>
<p>如果 Agile 和許多現今的 Software Engineering 是一種手段，但這些方法若不是建立在彼此的信任關係上，會是如何呢？舉例而言，如果公司上面說我們的精神是「Change」，也可以敞開心胸說「真心話」，但你不信任你的主管，總是私底下抱怨，也覺得 Change 是一種累贅。那麼，這樣的 slogan 就只是上面長官打高空的伎倆，沒有任何意義。</p>
<p>我想 Agile 與許多軟體開發的技巧相同，你不只仰賴傳遞「執行面」的事物，而是使人真正從內心信服，這些改變是有意義的，能夠真實幫助每天的工作。你當然可以透過每次舉辦的 Workshop 進行想法的傳遞，但更重要的是，這種信念必須透過一種類似「傳教士」的生命，每天切實地影響團隊當中的每個人。然後逐步使人信服，並且融入每天的生活與想法才行。</p>
<p>軟體開發除了軟體的本質之外，還是一門與人的學問，每個參與者都能察覺細微的氣氛轉變。而專案的帶領者是不是又能真實的關心每個人執行的狀況，並依照彼此的需要去做調整，再更深的推展出 process 面的技巧，因應改變，也「準時」交出「好的軟體」。</p>
<p>至於現在的我，我想我還只是一個初出茅廬的工程師，關於軟體工程，我還懂得太少。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/ep4T0wT2JWs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/07/19/%e9%97%9c%e6%96%bc-agile-%e6%88%91%e6%83%b3%e8%aa%aa%e7%9a%84%e6%98%af/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/07/19/%e9%97%9c%e6%96%bc-agile-%e6%88%91%e6%83%b3%e8%aa%aa%e7%9a%84%e6%98%af/</feedburner:origLink></item>
		<item>
		<title>去那更遙遠的地方</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/Q1BYSqLTAOU/</link>
		<comments>http://blog.hubert.tw/2010/05/30/%e5%8e%bb%e9%82%a3%e6%9b%b4%e9%81%99%e9%81%a0%e7%9a%84%e5%9c%b0%e6%96%b9/#comments</comments>
		<pubDate>Sun, 30 May 2010 00:41:00 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Murmuring]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=584</guid>
		<description><![CDATA[你在凝望些什麼？ 是那車水馬龍轉眼消逝的既視記憶， 又或者是內心底部那沈澱莫名的空靈感。 我說或許， 我（或者我們）都只是必須離開。 如果必須如此， 那我們絕對必須以極盡歡愉（甚至狂喜）的腳步跳躍著吧！ 因為， 我們將奔向另一個遙遠的國度。 於是我在你面前駐足， 以這張相片， 簽署我們遠行的約定（即使形式並不完全）。 Farewell，my friend 再會了，另一個旅人。]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/hub19/4651475670/"><img src="http://farm5.static.flickr.com/4019/4651475670_79928ce839.jpg" alt="遺忘之後，然後遠行" /></a></p>
<p>你在凝望些什麼？<br />
是那車水馬龍轉眼消逝的既視記憶，<br />
又或者是內心底部那沈澱莫名的空靈感。</p>
<p>我說或許，<br />
我（或者我們）都只是必須離開。<br />
如果必須如此，<br />
那我們絕對必須以極盡歡愉（甚至狂喜）的腳步跳躍著吧！<br />
因為，<br />
我們將奔向另一個遙遠的國度。</p>
<p>於是我在你面前駐足，<br />
以這張相片，<br />
簽署我們遠行的約定（即使形式並不完全）。</p>
<p>Farewell，my friend<br />
再會了，另一個旅人。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/Q1BYSqLTAOU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/05/30/%e5%8e%bb%e9%82%a3%e6%9b%b4%e9%81%99%e9%81%a0%e7%9a%84%e5%9c%b0%e6%96%b9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/05/30/%e5%8e%bb%e9%82%a3%e6%9b%b4%e9%81%99%e9%81%a0%e7%9a%84%e5%9c%b0%e6%96%b9/</feedburner:origLink></item>
		<item>
		<title>Use VERSIONER_PYTHON_PREFER_32_BIT=yes in Snow Leopard</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/gviIYpQ_toM/</link>
		<comments>http://blog.hubert.tw/2010/03/04/use-versioner_python_prefer_32_bityes-in-snow-leopard/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 08:21:00 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA["Snow Leopard"]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[VERSIONER_PYTHON_PREFER_32_BIT]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=574</guid>
		<description><![CDATA[In python, you can use ctype (dl is deprecated now) to load dynamic link library. In 10.4 and 10.5 it may work fine, but it may occur errors in 10.6, such as /Library/Frameworks/dummy.framework/dummy: no matching architecture in universal wrapper Since &#8230; <a href="http://blog.hubert.tw/2010/03/04/use-versioner_python_prefer_32_bityes-in-snow-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In python, you can use <a href="http://docs.python.org/library/ctypes.html">ctype</a> (<a href="http://docs.python.org/library/dl.html">dl</a> is deprecated now) to load dynamic link library. In 10.4 and 10.5 it may work fine, but it may occur errors in 10.6, such as</p>
<blockquote><p>
/Library/Frameworks/dummy.framework/dummy: no matching architecture in universal wrapper
</p></blockquote>
<p>Since the python in Snow Leopard is 64-bit in default, for those libraries which does not support 64-bit. You can test your library by</p>
<blockquote><p>% file /Library/Frameworks/dummy.framework/Versions/Current/dummy
</p></blockquote>
<p>If you library is i386 only, you may need to handle it in this way.</p>
<blockquote><p>
% export VERSIONER_PYTHON_PREFER_32_BIT=yes<br />
% python your_script.py
</p></blockquote>
<p><a href="http://blog.ericsk.org/">ericsk</a> has also mentioned this for <a href="http://www.wxpython.org/">wxPython</a> in <a href="http://www.plurk.com/p/3zg4c0">his plurk</a></p>
<p>For more information, you can read the man page in your Snow Leopard.</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/gviIYpQ_toM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/03/04/use-versioner_python_prefer_32_bityes-in-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/03/04/use-versioner_python_prefer_32_bityes-in-snow-leopard/</feedburner:origLink></item>
		<item>
		<title>黑白的風景</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/KCdUmuAw2mk/</link>
		<comments>http://blog.hubert.tw/2010/03/04/%e9%bb%91%e7%99%bd%e7%9a%84%e9%a2%a8%e6%99%af/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 16:52:58 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Murmuring]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/2010/03/04/%e9%bb%91%e7%99%bd%e7%9a%84%e9%a2%a8%e6%99%af/</guid>
		<description><![CDATA[可能因為我們用錯了模式，所以那看出去的風景才是黑色的。給自己，還有每個陷在情緒以及苦難中的人。 上帝必與我們同在。]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/hub19/4373219692/"><img alt="" src="http://farm3.static.flickr.com/2769/4373219692_98d2d84ea5.jpg" title="法善寺橫丁一隅" class="alignnone" width="500" height="333" /></a></p>
<p>可能因為我們用錯了模式，所以那看出去的風景才是黑色的。給自己，還有每個陷在情緒以及苦難中的人。</p>
<p>上帝必與我們同在。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/KCdUmuAw2mk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/03/04/%e9%bb%91%e7%99%bd%e7%9a%84%e9%a2%a8%e6%99%af/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/03/04/%e9%bb%91%e7%99%bd%e7%9a%84%e9%a2%a8%e6%99%af/</feedburner:origLink></item>
		<item>
		<title>Using minimock for Python unit testing</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/djnqx1bs3Jk/</link>
		<comments>http://blog.hubert.tw/2010/02/24/using-minimock-for-python-unit-testing/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 02:44:43 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA["unit test"]]></category>
		<category><![CDATA[minimock]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=568</guid>
		<description><![CDATA[我也忘了什麼時候開始習慣作 unit testing 了，可能是前一個專案在 Xcode 上就開始學著寫一點測試了。 這次在閱讀 Writing Testable Code 對於 6. Static methods: (or living in a procedural world)，格外有感覺。 尤其是修改別人的程式碼的時候，如果他總是直接呼叫 static method，不讓你用 mock object 把 implementation 換掉的話，這樣在測試起來就顯得麻煩的多。舉例來說，有一個 class method 會呼叫 SSHHelper.execute_ssh 這個指令去遠端執行一些東西，但這對 unit testing 而言就是一種外部的 dependency，你絕對不希望他真的在測試的時候跑出個 ssh 真的連過去執行些什麼吧。 剛好這次用 &#8230; <a href="http://blog.hubert.tw/2010/02/24/using-minimock-for-python-unit-testing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>我也忘了什麼時候開始習慣作 unit testing 了，可能是前一個專案在 Xcode 上就開始學著寫一點測試了。</p>
<p>這次在閱讀 <a href="http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html">Writing Testable Code</a> 對於 6. Static methods: (or living in a procedural world)，格外有感覺。</p>
<p>尤其是修改別人的程式碼的時候，如果他總是直接呼叫 static method，不讓你用 mock object 把 implementation 換掉的話，這樣在測試起來就顯得麻煩的多。舉例來說，有一個 class method 會呼叫 SSHHelper.execute_ssh 這個指令去遠端執行一些東西，但這對 unit testing 而言就是一種外部的 dependency，你絕對不希望他真的在測試的時候跑出個 ssh 真的連過去執行些什麼吧。</p>
<p>剛好這次用 <a href="http://pypi.python.org/pypi/MiniMock">MiniMock</a> 作我們的 mock library，因為他的因素，你就可以這樣作</p>
<pre class="brush: python;">
minimock.mock('SSHHelper.execute_ssh', returns=ssh_output)
</pre>
<p>如此一來，execute_ssh 這個 method 的結果就可以簡單的換成你預期的 ssh_output。</p>
<p>如果是本來就有比較好的設計的話，你也可以用 minimock.Mock (注意大小寫)，去產生一個 mock object 出來。</p>
<pre class="brush: python;">
mock_fs = minimock.Mock('MockFileSystem')
mock_fs.size.mock_returns = 1
mytools.fs_imp = mock_fs
</pre>
<p>如此一來 mock 就顯得簡單多了……</p>
<p>話說回來，之前想寫的 objective-c 跟 DTrace 的 topic 真的都忘的差不多了，算了，以後再說吧，也許之後把 python 的 <a href="http://www.python.org/dev/peps/pep-3134/">Exception Chaining and Embedded Tracebacks</a> 的想法整理一下再丟出來吧。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/djnqx1bs3Jk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/02/24/using-minimock-for-python-unit-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/02/24/using-minimock-for-python-unit-testing/</feedburner:origLink></item>
		<item>
		<title>Hide Menu Bar in Firefox 3.6</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/ieI8QW2vYuM/</link>
		<comments>http://blog.hubert.tw/2010/01/22/hide-menu-bar-in-firefox-3-6/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 15:36:18 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[Firefox HTML]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=565</guid>
		<description><![CDATA[Firefox 3.6 開始可以隱藏 Menu Bar 了，所以這樣再搭配上 Tree Style Tab，整個可視範圍就大了起來！不過，也因為這樣，這次主打的 Pesonas 在這種環境下就顯得很無奈了，能妝點的範圍太有限了……。 接著等著看，HTML 5 能改變世界多少，看什麼時候會真的有 File API 的服務出來。]]></description>
			<content:encoded><![CDATA[<p>Firefox 3.6 開始可以隱藏 Menu Bar 了，所以這樣再搭配上 <a href="https://addons.mozilla.org/en-US/firefox/addon/5890">Tree Style Tab</a>，整個可視範圍就大了起來！不過，也因為這樣，這次主打的 <a href="https://mozillalabs.com/personas/">Pesonas</a> 在這種環境下就顯得很無奈了，能妝點的範圍太有限了……。</p>
<p><a href="http://www.flickr.com/photos/hub19/4294893417/"><img src="http://farm3.static.flickr.com/2700/4294893417_549e2ed226.jpg" alt="My Firefox 3.6" /></a></p>
<p>接著等著看，HTML 5 能改變世界多少，看什麼時候會真的有 <a href="http://dev.w3.org/2006/webapi/FileAPI/">File API</a> 的服務出來。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/ieI8QW2vYuM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/01/22/hide-menu-bar-in-firefox-3-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/01/22/hide-menu-bar-in-firefox-3-6/</feedburner:origLink></item>
		<item>
		<title>如何讓 moodle 的 Certificate mod正確顯示中文</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/ZDdFT8Bb_QU/</link>
		<comments>http://blog.hubert.tw/2010/01/02/%e5%a6%82%e4%bd%95%e8%ae%93-moodle-%e7%9a%84-certificate-mod%e6%ad%a3%e7%a2%ba%e9%a1%af%e7%a4%ba%e4%b8%ad%e6%96%87/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 04:03:37 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[moodle certificate 中文 tcpdf]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=559</guid>
		<description><![CDATA[其實我的正職跟網頁一點關係都沒有（爆） moodle Certificate Module 是一個讓 moodle 可以做出結業證書的 module，不過以原本的狀況而言，沒辦法很正確的生出中文的 pdf，這時候就需要動一些手腳。 你可以從 type/unicode_landscape/certificate.php 知道他用的 tcpdf 是 moodle 本身的 include '../../lib/tcpdf/tcpdfprotection.php'; require_once('../../lib/tcpdf/config/lang/eng.php'); include '../../lib/tcpdf/tcpdf.php'; 然後我發現新版的 tcpdf 裡面有 CID-0 的支援，就索性照著 TCPDF Fonts 把一些字型丟進去跑跑看，像是文泉驛正黑體、王漢宗自由字型。 後來想想，似乎沒有不用這麼麻煩。直接用 arialunicid0 這個 tcpdf 有的設定就好，把他的設定改成我要的中文 $enc='UniCNS-UTF16-H'; $cidinfo=array('Registry'=&#62;'Adobe','Ordering'=&#62;'CNS1','Supplement'=&#62;0); include(dirname(__FILE__).'/uni2cid_ac15.php'); 再把 certificate 的字型稍微換一下就好，把原本的 &#8230; <a href="http://blog.hubert.tw/2010/01/02/%e5%a6%82%e4%bd%95%e8%ae%93-moodle-%e7%9a%84-certificate-mod%e6%ad%a3%e7%a2%ba%e9%a1%af%e7%a4%ba%e4%b8%ad%e6%96%87/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>其實我的正職跟網頁一點關係都沒有（爆）</p>
<p><a href="http://docs.moodle.org/en/Certificate_module">moodle Certificate Module</a> 是一個讓 <a href="http://moodle.org/">moodle</a> 可以做出結業證書的 module，不過以原本的狀況而言，沒辦法很正確的生出中文的 pdf，這時候就需要動一些手腳。<br />
<span id="more-559"></span><br />
你可以從 type/unicode_landscape/certificate.php 知道他用的 tcpdf 是 moodle 本身的</p>
<pre class="brush: php;">
include '../../lib/tcpdf/tcpdfprotection.php';
require_once('../../lib/tcpdf/config/lang/eng.php');
include '../../lib/tcpdf/tcpdf.php';
</pre>
<p>然後我發現新版的 tcpdf 裡面有 CID-0 的支援，就索性照著 <a href="http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_fonts">TCPDF Fonts</a> 把一些字型丟進去跑跑看，像是<a href="http://wenq.org/?ZenHei">文泉驛正黑體</a>、<a href="http://zh.wikipedia.org/wiki/%E7%8E%8B%E6%BC%A2%E5%AE%97%E8%87%AA%E7%94%B1%E5%AD%97%E5%9E%8B">王漢宗自由字型</a>。</p>
<p>後來想想，似乎沒有不用這麼麻煩。直接用 arialunicid0 這個 tcpdf 有的設定就好，把他的設定改成我要的中文</p>
<pre class="brush: php;">
$enc='UniCNS-UTF16-H';
$cidinfo=array('Registry'=&gt;'Adobe','Ordering'=&gt;'CNS1','Supplement'=&gt;0);
include(dirname(__FILE__).'/uni2cid_ac15.php');
</pre>
<p>再把 certificate 的字型稍微換一下就好，把原本的 FreeSerif 跟 FreeMono 換成 arialunicid0，再注意一下，新的 tcpdf 已經沒有 TCPDF_Protection 這個 class，直接 new TCPDF 就好。</p>
<p>這樣做出來的 pdf 也比直接嵌入wang ttf 的來的小，大概 22K 附近，效果也還不錯。在這邊備忘一下，要不然之後大概又忘記怎麼做了 XD</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/ZDdFT8Bb_QU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2010/01/02/%e5%a6%82%e4%bd%95%e8%ae%93-moodle-%e7%9a%84-certificate-mod%e6%ad%a3%e7%a2%ba%e9%a1%af%e7%a4%ba%e4%b8%ad%e6%96%87/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2010/01/02/%e5%a6%82%e4%bd%95%e8%ae%93-moodle-%e7%9a%84-certificate-mod%e6%ad%a3%e7%a2%ba%e9%a1%af%e7%a4%ba%e4%b8%ad%e6%96%87/</feedburner:origLink></item>
		<item>
		<title>Media Temple 小感想</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/DTgovuL_VHY/</link>
		<comments>http://blog.hubert.tw/2009/12/30/%e4%bd%bf%e7%94%a8-mediatemple-%e5%b0%8f%e6%84%9f%e6%83%b3/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:25:28 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA["Media Temple"]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=553</guid>
		<description><![CDATA[原本的網站（不是這個 blog）放在國內某家知名的主機商，因為每個月都在付超流費，再加上曾經傳出客戶資料外流的問題，所以我們就決定把現在的網站搬到 Media Temple。流量跟 storage 一次到 1000GB 跟 100GB，一年刷下來 200 美金，乾脆省事。 從 9 月底租到現在，大概也差不多三個月了，覺得他還算穩定，還可以讓我用 SSH 連進去，再用 rsync 去 deploy 一些東西（也方便用 rsnapshot 去備份）。再加上可以依照 domain 開不同的帳號，讓我們把 admin 帳號跟 domain 帳號隔開，對於現在的使用上其實也很方便。 不過最近爆出來的一些 security issue 讓人覺得很無言，像是官方 blog 的這兩個 issue #1047 Cluster.05 Storage Segment 1 &#8230; <a href="http://blog.hubert.tw/2009/12/30/%e4%bd%bf%e7%94%a8-mediatemple-%e5%b0%8f%e6%84%9f%e6%83%b3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>原本的網站（不是這個 blog）放在國內某家知名的主機商，因為每個月都在付超流費，再加上曾經傳出客戶資料外流的問題，所以我們就決定把現在的網站搬到 <a href="http://mediatemple.net/">Media Temple</a>。流量跟 storage 一次到 1000GB 跟 100GB，一年刷下來 200 美金，乾脆省事。</p>
<p>從 9 月底租到現在，大概也差不多三個月了，覺得他還算穩定，還可以讓我用 SSH 連進去，再用 rsync 去 deploy 一些東西（也方便用 rsnapshot 去備份）。再加上可以依照 domain 開不同的帳號，讓我們把 admin 帳號跟 domain 帳號隔開，對於現在的使用上其實也很方便。</p>
<p>不過最近爆出來的一些 security issue 讓人覺得很無言，像是官方 blog 的這兩個 issue<br />
<a href="http://weblog.mediatemple.net/weblog/category/system-incidents/1047-cluster05-storage-segment-1/">#1047 Cluster.05 Storage Segment 1</a><br />
<a href="http://weblog.mediatemple.net/weblog/category/system-incidents/1026-gs-security-advisory/">#1026 (gs) Security Advisory</a></p>
<p>Twitter 也有爆出來<br />
<a href="http://twitter.com/macgillavry/status/6497221013">http://twitter.com/macgillavry/status/6497221013</a><br />
<a href="http://twitter.com/mdravnieks/status/6491481100">http://twitter.com/mdravnieks/status/6491481100</a></p>
<p>然後因為放在美國的關係，過去大概也要 150ms，對於 response time 來說是蠻高的，就現在來說，我也只能對 <a href="http://developer.yahoo.com/yslow/">YSlow</a> 有的東西修一修，支援一下 deflate，把 expire 設定起來，然後 CMS 能做 cache 的先上一下，要 compress 的 js 跟 css 丟給 <a href="http://code.google.com/closure/">Closure</a> 看看會不會好一點。</p>
<p>不過最近 web 偶爾就給我連不上，不知道是怎麼樣，也許弄個 mtr 跟 httping 來監控看看吧。</p>
<p>現在我們把影音的流量也分一部分到 <a href="http://www.vimeo.com/">vimeo</a> 上，也許一年之後再評估看看，到底哪邊比較適合我們吧。</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/DTgovuL_VHY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2009/12/30/%e4%bd%bf%e7%94%a8-mediatemple-%e5%b0%8f%e6%84%9f%e6%83%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2009/12/30/%e4%bd%bf%e7%94%a8-mediatemple-%e5%b0%8f%e6%84%9f%e6%83%b3/</feedburner:origLink></item>
		<item>
		<title>節錄：《親愛的安德烈》：政府的手可以伸多長</title>
		<link>http://feedproxy.google.com/~r/hubert/~3/CW5eMVJsDEA/</link>
		<comments>http://blog.hubert.tw/2009/11/02/%e7%af%80%e9%8c%84%ef%bc%9a%e3%80%8a%e8%a6%aa%e6%84%9b%e7%9a%84%e5%ae%89%e5%be%b7%e7%83%88%e3%80%8b%ef%bc%9a%e6%94%bf%e5%ba%9c%e7%9a%84%e6%89%8b%e5%8f%af%e4%bb%a5%e4%bc%b8%e5%a4%9a%e9%95%b7/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 14:09:29 +0000</pubDate>
		<dc:creator>Hubert</dc:creator>
				<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://blog.hubert.tw/?p=545</guid>
		<description><![CDATA[沒多久，全德國都要在公共場所禁煙了。所以，在禁煙的做為上，香港和德國是一樣的。但是我注意到一個根本的差別，那就是，在德國，公共場所禁煙令下來之前，社會有歷時很長、翻天覆地的辯論。香港卻沒有，政府基本可以說做就做，而且，香港政府好像有一種特異功能，只要是它想做的事情，都可以把它塑造成「萬眾一心」的樣子。香港政府簡直是個所向無敵的鐵金剛。 最近開始讀龍應台這本《親愛的安德烈》，個人覺得這本書相當有意思，先不論親子間的互動性，他的主題總是有趣的、豐富的，也經常提醒我過去想過的一些問題，像是社會、自我價值、親子關係、文化差異等等。有幾個同事在 plurk 說這本書讀起來並不輕鬆，但我常常把他當成睡前讀物、廁所讀物，就把他跟村上春樹、田中芳樹，或者其他作品一起讀著。 只是，最近讀這本書的時候格外有感觸，安德烈所說的香港政府，讓我想起這些日子馬政府的種種作為。 某個週日，我爸氣急敗壞地說著「馬政府決議開放美國帶骨牛肉」的事情，那時我只是冷冷的說：「是不是有配套措施，或者已經証明美國牛肉能免除狂牛症的危險？」然後繼續我就繼續做著自己的事情，直到我發現這政策的草率與影響的嚴重性。 就算是這樣，這段時間我也只是專心工作，偶爾看著人來人往的言論，自己並沒有提出些什麼特別的意見。不過，我也很訝異居然會有這種言論 司徒文說：『去年台灣2300萬人口中，1034人因為機車事故死亡，你看風險性，從統計上來看，並沒有任何狂牛症引發的病例，或許民眾應停止騎摩托車，因為摩托車事故風險更高。』 那我是不是該說 「我騎日本機車跟國產機車可能會出車禍，但是為什麼我要騎一台可能會爆炸的美國機車？」 我想我是幸運的，至少生在這個時代，因為網路、報紙、民主，所有的政策與思維都能公開地攤在檯面下重新進行審視與質疑。先不論所謂開放之後「選擇的自由」吧！只是在這個當下，人民絕對有權質疑政策的「正當性」與其決策「過程」，並以言論去表達對於政策本身、或是其過程的不滿與爭議。撇開政黨不提，過去我們終於爭取到權益，能以站上街頭、報紙投書提出那理性的訴求。今日也許我們可以再次看看，台灣今日的民主，政府是像是「無敵鐵金剛」高舉鐵腕，還是能側耳傾聽，回到以民意為依歸的民主。 政府的手可以伸多長？現在我不知道了]]></description>
			<content:encoded><![CDATA[<blockquote><p>
沒多久，全德國都要在公共場所禁煙了。所以，在禁煙的做為上，香港和德國是一樣的。但是我注意到一個根本的差別，那就是，在德國，公共場所禁煙令下來之前，社會有歷時很長、翻天覆地的辯論。香港卻沒有，政府基本可以說做就做，而且，香港政府好像有一種特異功能，只要是它想做的事情，都可以把它塑造成「萬眾一心」的樣子。香港政府簡直是個所向無敵的鐵金剛。
</p></blockquote>
<p>最近開始讀龍應台這本《親愛的安德烈》，個人覺得這本書相當有意思，先不論親子間的互動性，他的主題總是有趣的、豐富的，也經常提醒我過去想過的一些問題，像是社會、自我價值、親子關係、文化差異等等。有幾個同事在 plurk 說這本書讀起來並不輕鬆，但我常常把他當成睡前讀物、廁所讀物，就把他跟村上春樹、田中芳樹，或者其他作品一起讀著。</p>
<p>只是，最近讀這本書的時候格外有感觸，安德烈所說的香港政府，讓我想起這些日子馬政府的種種作為。</p>
<p>某個週日，我爸氣急敗壞地說著「馬政府決議開放美國帶骨牛肉」的事情，那時我只是冷冷的說：「是不是有配套措施，或者已經証明美國牛肉能免除狂牛症的危險？」然後繼續我就繼續做著自己的事情，直到我發現這政策的草率與影響的嚴重性。</p>
<p>就算是這樣，這段時間我也只是專心工作，偶爾看著人來人往的言論，自己並沒有提出些什麼特別的意見。不過，我也很訝異居然會有這種言論</p>
<blockquote><p>
司徒文說：『去年台灣2300萬人口中，1034人因為機車事故死亡，你看風險性，從統計上來看，並沒有任何狂牛症引發的病例，或許民眾應停止騎摩托車，因為摩托車事故風險更高。』
</p></blockquote>
<p>那我是不是該說</p>
<blockquote><p>
「我騎日本機車跟國產機車可能會出車禍，但是為什麼我要騎一台可能會爆炸的美國機車？」
</p></blockquote>
<p>我想我是幸運的，至少生在這個時代，因為網路、報紙、民主，所有的政策與思維都能公開地攤在檯面下重新進行審視與質疑。先不論所謂開放之後「選擇的自由」吧！只是在這個當下，人民絕對有權質疑政策的「正當性」與其決策「過程」，並以言論去表達對於政策本身、或是其過程的不滿與爭議。撇開政黨不提，過去我們終於爭取到權益，能以站上街頭、報紙投書提出那理性的訴求。今日也許我們可以再次看看，台灣今日的民主，政府是像是「無敵鐵金剛」高舉鐵腕，還是能側耳傾聽，回到以民意為依歸的民主。</p>
<p>政府的手可以伸多長？現在我不知道了</p>
<img src="http://feeds.feedburner.com/~r/hubert/~4/CW5eMVJsDEA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.hubert.tw/2009/11/02/%e7%af%80%e9%8c%84%ef%bc%9a%e3%80%8a%e8%a6%aa%e6%84%9b%e7%9a%84%e5%ae%89%e5%be%b7%e7%83%88%e3%80%8b%ef%bc%9a%e6%94%bf%e5%ba%9c%e7%9a%84%e6%89%8b%e5%8f%af%e4%bb%a5%e4%bc%b8%e5%a4%9a%e9%95%b7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.hubert.tw/2009/11/02/%e7%af%80%e9%8c%84%ef%bc%9a%e3%80%8a%e8%a6%aa%e6%84%9b%e7%9a%84%e5%ae%89%e5%be%b7%e7%83%88%e3%80%8b%ef%bc%9a%e6%94%bf%e5%ba%9c%e7%9a%84%e6%89%8b%e5%8f%af%e4%bb%a5%e4%bc%b8%e5%a4%9a%e9%95%b7/</feedburner:origLink></item>
	</channel>
</rss>
