<?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>JeffHung.Blog &#187; jeffhung</title>
	<atom:link href="http://www.jeffhung.net/blog/articles/author/jeffhung/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeffhung.net/blog</link>
	<description>(My smile insists of having nose. :-)</description>
	<lastBuildDate>Thu, 24 Nov 2011 07:25:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2-alpha</generator>
		<item>
		<title>徵 Web Front-end Developer</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3235/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3235/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 07:25:31 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3235</guid>
		<description><![CDATA[敝部門最近在徵 Web Front-end Developer，歡迎有興趣的人與我聯絡。 先介紹一下敝部門。我現在在趨勢科技 CoreTech Backend 的 SPN team 工作，這個部門的主要工作是構建趨勢雲端防毒的後端基礎建設，處理來自全世界各地反饋回來的各種資料，以 global scale 分析處理，以提出各種反制威脅的解決方案。由於資料量很大，因此敝 team 累積了相當多的 big data 處理經驗，而且面對的是真實的資料，實際的問題，做的絕非假雲端。我們的團隊裡有許多鬼才，信奉 hacker 精神，使用的 open source 技術五花八門，平日常常需要膜拜彼此，因為令人讚嘆的事蹟層出不窮。 不過由於敝 team 擅長的是後端，前端雖然還是能做，但總是不夠專業，因此需要 web front-end 的人才加入，以便真實呈現挖掘自巨量資料的寶貴資訊。為協助在最短的時間內驗證各種解決方案，這個工作會有一部分需要能夠快速建構各種 visualization demonstration。這是個 contractor 或 part-time 職缺，公司內部有專門的 HIE (Human Interface Engineering) 部門，有志於 front-end 專長的人，將不乏於此發展個人職涯的機會。 工作的地點在台北敦化南路，上班時間正常，不常加班。以下為正式的 job description： Overview: Software development for web front-end solution Develop UI [...]]]></description>
			<content:encoded><![CDATA[<p>敝部門最近在徵 Web Front-end Developer，歡迎有興趣的人與我聯絡。</p>
<p>先介紹一下敝部門。我現在在趨勢科技 CoreTech Backend 的 SPN team 工作，這個部門的主要工作是構建趨勢雲端防毒的後端基礎建設，處理來自全世界各地反饋回來的各種資料，以 global scale 分析處理，以提出各種反制威脅的解決方案。由於資料量很大，因此敝 team 累積了相當多的 big data 處理經驗，而且面對的是真實的資料，實際的問題，做的絕非假雲端。我們的團隊裡有許多鬼才，信奉 hacker 精神，使用的 open source 技術五花八門，平日常常需要膜拜彼此，因為令人讚嘆的事蹟層出不窮。</p>
<p>不過由於敝 team 擅長的是後端，前端雖然還是能做，但總是不夠專業，因此需要 web front-end 的人才加入，以便真實呈現挖掘自巨量資料的寶貴資訊。為協助在最短的時間內驗證各種解決方案，這個工作會有一部分需要能夠快速建構各種 visualization demonstration。這是個 contractor 或 part-time 職缺，公司內部有專門的 HIE (Human Interface Engineering) 部門，有志於 front-end 專長的人，將不乏於此發展個人職涯的機會。</p>
<p>工作的地點在台北敦化南路，上班時間正常，不常加班。以下為正式的 job description：</p>
<blockquote>
<p>Overview:</p>
<ul>
<li>Software development for web front-end solution</li>
<li>Develop UI prototypes to demonstrate concepts</li>
<li>Web application design, implementation, unit testing and trouble shooting</li>
</ul>
<p>Qualification/Requirement:</p>
<ul>
<li>3+ years experience of web front-end design and development</li>
<li>Solid JavaScript programming and familiar with DHTML, CSS, XML, JSON, AJAX, and Flex</li>
<li>Experienced in new web technologies, like Django, jQuery, Ruby and Structs</li>
<li>Experienced in server side scripting with PHP/ASP/JSP will be a plus</li>
<li>Good English communication skill</li>
<li>Self-motivated, good teamwork and problem solving skill</li>
</ul>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3235/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>有兒如此，夫復何求（更新）</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/1905/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/1905/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 14:58:09 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Baby]]></category>
		<category><![CDATA[son]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=1905</guid>
		<description><![CDATA[西元 2009 年底時，留了這篇 blog 文章草稿於後台： 最近這幾個月，基本上不需要鬧鐘，就可以準時起床。 現在是西元 2011 年底，發表文章前，不得不補上以下內容： 最近這幾個月，基本上一定要鬧鐘，才可以準時挖兒子起床。]]></description>
			<content:encoded><![CDATA[<p>西元 2009 年底時，留了這篇 blog 文章草稿於後台：</p>
<blockquote><p>最近這幾個月，基本上不需要鬧鐘，就可以準時起床。</p></blockquote>
<p>現在是西元 2011 年底，發表文章前，不得不補上以下內容：</p>
<blockquote><p>最近這幾個月，基本上一定要鬧鐘，才可以準時挖兒子起床。</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/1905/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[OSDC.tw 2011] The Path to Pass into PaaS</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3163/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3163/#comments</comments>
		<pubDate>Sun, 27 Mar 2011 15:43:38 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3163</guid>
		<description><![CDATA[今天在 OSDC.tw 2011 裡講了一場，介紹我們 team 做的東西...]]></description>
			<content:encoded><![CDATA[<p>今天在 OSDC.tw 2011 裡講了一場，介紹我們 team 做的東西，投影片如下：</p>
<div style="width:425px" id="__ss_7402138"> <strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/jeffhung/osdctw-2011-the-path-to-pass-into-paas" title="[OSDC.tw 2011] The Path to Pass into PaaS">[OSDC.tw 2011] The Path to Pass into PaaS</a></strong> <object id="__sse7402138" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=osdc-tw-2011-thepathtopassintopaas-110326213502-phpapp02&#038;stripped_title=osdctw-2011-the-path-to-pass-into-paas&#038;userName=jeffhung" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse7402138" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=osdc-tw-2011-thepathtopassintopaas-110326213502-phpapp02&#038;stripped_title=osdctw-2011-the-path-to-pass-into-paas&#038;userName=jeffhung" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object> </div>
<p>嗯，總算在 blog 上塞點有用的東西。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3163/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>來貼點連結吧 (2011-02-10)</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3143/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3143/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 16:30:20 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3143</guid>
		<description><![CDATA[貼點連結，列一下最近看到的有趣東西： SQLite, 64-bit integers, and the impossible number - 於 64-bit integer 裡存放比 64-bit integer 還大的值。 Your Patch Sucks - 對於收 patch 這件事，Cascading 作者的怒吼想法。節錄： Many companies get into open-source so they can monetize their Users. Smart companies create a Customer community and let the User community migrate naturally to it. So as a business, do [...]]]></description>
			<content:encoded><![CDATA[<p>貼點連結，列一下最近看到的有趣東西：</p>
<ul>
<li><a href="http://jakegoulding.posterous.com/sqlite-64-bit-integers-and-the-impossible-num">SQLite, 64-bit integers, and the impossible number</a> - 於 64-bit integer 裡存放比 64-bit integer 還大的值。</li>
<li><a href="http://www.manamplified.org/archives/2011/02/your-patch-sucks.html">Your Patch Sucks</a> - 對於收 patch 這件事，<a href="http://www.cascading.org/">Cascading</a> 作者的<span style="text-decoration: line-through;">怒吼</span>想法。節錄：
<ul>
<li>Many companies get into open-source so they can monetize their Users. Smart companies create a Customer community and let the User community migrate naturally to it.</li>
<li>So as a business, do you let your developers spend time writing a patch to add a feature that will trigger one or more of the above Patch criticisms, or do you just pay a Committer to do it the "right way"?</li>
</ul>
</li>
<li><a href="http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php?calc=chart&amp;gpp=on&amp;java=on&amp;ghc=on&amp;csharp=on&amp;sbcl=on&amp;v8=on&amp;racket=on&amp;hipe=on&amp;vw=on&amp;lua=on&amp;python3=on&amp;yarv=on&amp;perl=on&amp;php=on">Which programming languages are fastest?</a> - 我第一眼注意到的是：一般來說，C 跟 C++ 一樣快，而在較極端的例子裡，C 比 C++ 慢了一倍。</li>
<li><a href="http://www.boingboing.net/2011/01/25/eleven-years-worth-o.html">Eleven years' worth of Boing Boing posts in one file!</a> - 收！</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3143/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>醫生扮演組</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3132/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3132/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 04:38:42 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3132</guid>
		<description><![CDATA[拿著巧虎醫生扮演組，玩得不亦樂乎的紅蘿蔔，突然轉頭...]]></description>
			<content:encoded><![CDATA[<p>雖然已經<a href="http://www.plurk.com/p/9b0nkz">發了 plurk</a>，還是在 blog 裡記錄一下好了，免得紅蘿蔔長大後不認帳。:-p</p>
<p>拿著巧虎醫生扮演組，玩得不亦樂乎的紅蘿蔔，突然轉頭，拿瓶藥水給我，對我說：「把拔，這個毒藥給你喝。」</p>
<p>我：「........」</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3132/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>雜草叢生，換個 captcha 試試</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3124/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3124/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 04:47:31 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Blogging]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3124</guid>
		<description><![CDATA[有人在念，說我好久沒寫文章，所以... ]]></description>
			<content:encoded><![CDATA[<p>這裡雜草叢生，一堆 spam comments，清都清不完，看了就煩，所以好久都沒新文章，每次一進後台，心裡一厭煩，就直接關掉 browser 了。XD</p>
<p>可是有人在念，說我好久沒寫文章，所以就先換個 captcha 機制試試囉。這個新的 captcha 機制蠻有趣的，大家試試囉。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3124/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A 大師人帥真好</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3119/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3119/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 13:12:27 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3119</guid>
		<description><![CDATA[中午外出覓食時，A 大師人帥真好，左右逢緣，被 E 小妹和 Y 小弟分佔兩旁，各自問各自的問題。A 大師功力高深，一下頭轉左邊，向 E 小妹發表高深的言論，一下頭又轉右邊，為 Y 小弟解惑。我和 T 大在旁竊竊私語： T 大：「這樣一下左邊，一下右邊，是 TDMA。」 我：「那如果跟左邊講話用臺語，跟右邊講話用國語，就是 CDMA 了。」 T 大：「以此類推，若一下裝女聲，一下裝男聲，便是 FDMA。」 絕倒。]]></description>
			<content:encoded><![CDATA[<p>中午外出覓食時，A 大師人帥真好，左右逢緣，被 E 小妹和 Y 小弟分佔兩旁，各自問各自的問題。A 大師功力高深，一下頭轉左邊，向 E 小妹發表高深的言論，一下頭又轉右邊，為 Y 小弟解惑。我和 T 大在旁竊竊私語：</p>
<p>T 大：「這樣一下左邊，一下右邊，是 <a href="http://en.wikipedia.org/wiki/Time_division_multiple_access">TDMA</a>。」</p>
<p>我：「那如果跟左邊講話用臺語，跟右邊講話用國語，就是 <a href="http://en.wikipedia.org/wiki/Code_division_multiple_access">CDMA</a> 了。」</p>
<p>T 大：「以此類推，若一下裝女聲，一下裝男聲，便是 <a href="http://en.wikipedia.org/wiki/Frequency-division_multiple_access">FDMA</a>。」</p>
<p>絕倒。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3119/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>VimWiki</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3087/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3087/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 14:47:30 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Devel]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3087</guid>
		<description><![CDATA[一直想要弄個 Wiki 整理各種知識，本來有試著用 dokuwiki，可是在 browser 裡面編輯，還是不甚方便，而且不是任何時候，都有網路可以用。後來發現了 vimwiki 這個東西，驚為天人，這正是我需要的啊。最近 vimwiki 1.0 版正式推出，所以來跟各位介紹一番。]]></description>
			<content:encoded><![CDATA[<p>一直想要弄個 wiki 整理各種知識，本來有試著用 <a href="http://www.dokuwiki.org/dokuwiki">dokuwiki</a>，可是在 browser 裡面編輯，還是不甚方便，而且不是任何時候，都有網路可以用。後來發現了 <a href="http://code.google.com/p/vimwiki/">vimwiki</a> 這個東西，驚為天人，這正是我需要的啊。最近 vimwiki 1.0 版正式推出，所以來跟各位介紹一番。</p>
<p>Vimwiki，簡言之，就是在 Vim 裡面架一個 wiki。對於 programmer 來說，vim 想必不陌生，用慣 vim 的人，如果也能同樣用 vim 編輯 wiki，因為操作方法都一樣，更加地方便。Vim 從第 7 版開始支援 tab，寫程式時若要記筆記，根本不必離開 vim，方便極了。</p>
<p>到網站上抓下來解開安裝到 <code class="inline_code">~/.vim</code> 裡即可。Vimwiki 可設定多個 wiki，使用時，只要連打 <code class="inline_code">&lt;leader&gt;ww</code> (<code class="inline_code">&lt;leader&gt;</code> 鍵預設為「<code class="inline_code">\</code>」)，就可以開啟預設的 wiki，或從多個設定好的 wiki 中選擇要開啟那一個。另外也有支援 diary 模式，改按 <code class="inline_code">&lt;leader&gt;w&lt;leader&gt;w</code>，就可開啟一個以今天日期命名的 diary page，拿來記會議記錄超方便。Diary 模式亦可與 <a href="http://www.vim.org/scripts/script.php?script_id=52">Vim Calendar</a> 整合，打開 calendar，那一天有 diary 一清二楚，按 <code class="inline_code">&lt;enter&gt;</code> 鍵就可打開。</p>
<p>Wiki 裡的 <a href="http://en.wikipedia.org/wiki/CamelCase">CamelCase</a> 自動成為 link，按 <code class="inline_code">&lt;enter&gt;</code> 鍵進入該頁，按 <code class="inline_code">&lt;backspace&gt;</code> 鍵回到前一頁。如果你用的是 GUI 版的 vim 的話，vimwiki 也可支援滑鼠。Vimwiki 有指令可以將本頁或整個 wiki 的內容，轉成 HTML 檔。也可以設定成存檔時自動轉成 HTML，這樣就不必煩惱同步的問題了。</p>
<p>Vimwiki 有自己的 wiki syntax，不過很好學，與大部份的 wiki 語法類似。另外 vimwiki 也可以設定成使用 <a href="http://www.mediawiki.org/wiki/MediaWiki">mediawiki</a> 語法，只不過這樣就不支援轉出成 HTML 檔。我現在還在找方法，看看能不能直接開啟另外架設的 wiki 站，這樣就不用靠 <a href="https://addons.mozilla.org/en-US/firefox/addon/4125/">It's All Text!</a> 了。Vimwiki 支援表格編輯，並且會隨著 cell 的切換，自動將表格排列整齊，非常方便。另外，我們也可以在 vimwiki 裡建立 todo list，按 <code class="inline_code">&lt;C-space&gt;</code> 即可切換完成與否，並會自動更新上層進度。所以，我根本可以直接用 vimwiki 來做簡單的 <a href="http://en.wikipedia.org/wiki/Getting_Things_Done">GTD</a>，一般的 outline 軟體可以丟掉了。</p>
<p>因為 vimwiki 使用純文字檔格式，除了可以用其它編輯器開啟瀏覽之外，也可以用版本控制軟體管理，如 <a href="http://subversion.apache.org/">Subversion</a>、<a href="http://git-scm.com/">Git</a> 等。不過我覺得 wiki 還要記錄所有歷史編輯記錄，很沒必要。會想用版本控制軟體，其實是看上了其可有多個 working copies，方便彼此之間的同步。不過，使用版本控制軟體，使用時還是很繁瑣，因此，最後的大絕是，我直接拿 <a href="https://www.dropbox.com/referrals/NTMwOTA4MDA5">Dropbox</a> 來管理這些 wiki 檔了。如此一來，任何時候只要一存檔，我的 wiki 內容就可以備份到雲端，同時我還可以在多台機器裡，完全自動同步內容，再加上 vim 在 windows、linux 與 mac 上都能用，因此不管我在那台機器裡，只要設定妥當，我的 wiki 就可以跟著我走，完全無須浪費心思在管理。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3087/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>試用 iPhone 寫 blog</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3065/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3065/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 01:47:50 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3065</guid>
		<description><![CDATA[想說最近太忙沒空寫 blog，搭捷運也都沒位子坐，所以裝了個 BlogPress 試試用 iPhone 寫 blog，結果被 UI 耍了一道。XD]]></description>
			<content:encoded><![CDATA[<p>想說最近太忙沒空寫 blog，搭捷運也都沒位子坐，所以裝了個 BlogPress 試試用 iPhone 寫 blog，結果被 UI 耍了一道。XD</p>
<p>文章寫到一半，總想存個 draft，等到完成之後再發表。可是在 BlogPress 裡按「Save」然後點「Save Draft Only」只會把 draft 存在 iPhone 裡。</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/49902636@N00/4810881114/"><img height="281" border="0" width="187" style="margin: 5px;" src="http://farm5.static.flickr.com/4077/4810881114_a4c1b85b74_m.jpg" alt="" /></a></p>
<p>可是我想要的是能存在線上，這樣我回到電腦前才可以繼續編輯。試了幾次不得法後，最後我決定試試大大紅紅的「Publish Now!」按鈕。</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/49902636@N00/4810257059/"><img height="281" border="0" width="187" style="margin: 5px;" src="http://farm5.static.flickr.com/4122/4810257059_0971821385_m.jpg" alt="" /></a></p>
<p>結果跑出這個讓人哭笑不得的訊息：</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/49902636@N00/4810257665/"><img height="281" border="0" width="187" style="margin: 5px;" src="http://farm5.static.flickr.com/4073/4810257665_4ea56d605a_m.jpg" alt="" /></a></p>
<p>還好文章最後確實地存成了 online draft，雖然 UI 讓人搖頭，但還堪用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3065/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Location-based Advertising?</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3066/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3066/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 02:13:41 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3066</guid>
		<description><![CDATA[這個週末路過台北 101，就進去晃晃，就在搭乘往地下一樓的手扶梯的時候，收到下面這樣的簡訊： 敬邀您至台北101(B1)體驗最新iPad！呈現美國運通白金優惠：『墾丁福容渡假買一送一』還有機會獲得台北101購物中心電子禮券8000元 我承認我被某甜蜜點打中了，所以在地下一樓繞了一圈，真的發現這個攤位： 很好奇我的位置是怎麼被知道的？瞎貓碰到死耗子也沒這麼巧。Location-based advertising 真的成真了嗎？那我希望附近有內衣秀的時候能收到簡訊通知。XD]]></description>
			<content:encoded><![CDATA[<p>這個週末路過台北 101，就進去晃晃，就在搭乘往地下一樓的手扶梯的時候，收到下面這樣的簡訊：</p>
<blockquote><p> 敬邀您至台北101(B1)體驗最新iPad！呈現美國運通白金優惠：『墾丁福容渡假買一送一』還有機會獲得台北101購物中心電子禮券8000元 </p></blockquote>
<p>我承認我被某甜蜜點打中了，所以在地下一樓繞了一圈，真的發現這個攤位：</p>
<p><center><a href="http://www.flickr.com/photos/49902636@N00/4810170361/"><img height="281" width="210" border="0" style="margin: 5px;" src="http://farm5.static.flickr.com/4077/4810170361_f79987116a_m.jpg" alt="" /></a></center></p>
<p>
很好奇我的位置是怎麼被知道的？瞎貓碰到死耗子也沒這麼巧。Location-based advertising 真的成真了嗎？那我希望附近有內衣秀的時候能收到簡訊通知。XD</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3066/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Weekly Tweets on 2010-05-30</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3027/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3027/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 16:31:32 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Murmuring]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3027</guid>
		<description><![CDATA[前面有個持著 iPad 站著的老兄，沒位子坐不曉得會不會手酸？ # http://j.mp/9L5YJN # http://gezhi.org/blog/1930 物理学家观测到布朗运动的瞬时速度 # 昨天跟同事吃飯時聊到爛程式，現在想，其實爛程式很難描述耶。我還未夠班，無法清析地分析解釋，爛邏輯為什麼爛。(所以要多看 Code SOD。XD) #]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>前面有個持著 iPad 站著的老兄，沒位子坐不曉得會不會手酸？ <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/14801454954">#</a></li>
<li><a rel="nofollow" href="http://j.mp/9L5YJN">http://j.mp/9L5YJN</a> <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/14801708490">#</a></li>
<li><a rel="nofollow" href="http://gezhi.org/blog/1930">http://gezhi.org/blog/1930</a> 物理学家观测到布朗运动的瞬时速度 <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/14802672777">#</a></li>
<li>昨天跟同事吃飯時聊到爛程式，現在想，其實爛程式很難描述耶。我還未夠班，無法清析地分析解釋，爛邏輯為什麼爛。(所以要多看 Code SOD。XD) <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/14804869572">#</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3027/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>亂數兩三事</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3036/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3036/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 16:25:12 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3036</guid>
		<description><![CDATA[剛好在 Plurk 上聊到亂數的問題：我印象中 Standard C 的 srand()、rand() 函式，有大問題，所以在 Plurk 上亂放炮，引來眾家好手關切。還好最後把細節回憶清楚了，也再次提醒了自己，要小心不要讓寫程式的「習慣」埋下難解的地雷。]]></description>
			<content:encoded><![CDATA[<p>是亂數兩三事，也是亂述兩三事。剛好在 Plurk 上<a href="http://www.plurk.com/p/5nebqt">聊</a>到亂數的問題：我印象中 Standard C 的 <code class="inline_code">srand()</code>、<code class="inline_code">rand()</code> 函式，有大問題，所以在 Plurk 上亂放炮，引來眾家好手關切。還好最後把細節回憶清楚了，也再次提醒了自己，要小心不要讓寫程式的「習慣」埋下難解的地雷。</p>
<p>故事是這樣的，在之前開發某分散式系統時，為了避免系統啟動時，因為散布在多台機器的許多程式，一起同時運作而造成塞車，所以套用 <a href="http://en.wikipedia.org/wiki/Carrier_sense_multiple_access_with_collision_detection">CSMA/CD</a> 的招數，讓大家在啟動時，各自暫停若干時間，暫停的長度由亂數決定。</p>
<p>不過，因為 Standard C 的 <code class="inline_code">srand()</code>、<code class="inline_code">rand()</code> 係 pseudo random 的關係，只要給 <code class="inline_code">srand()</code> 的值一樣，之後大家所 <code class="inline_code">rand()</code> 得到的 sequence 都會一樣。大部份的教科書，在介紹這兩個函式的時候，大都是用 <code class="inline_code">time()</code> 取得當前 epoch 秒數喂進 <code class="inline_code">srand()</code>，所以如訓練有術的狗一般，我也很直覺的就用同一個方法設定亂數種子值。然後很不幸地，當所有程式同時啟動時，因為呼叫 <code class="inline_code">time()</code> 的時間非常接近，所以傳進 <code class="inline_code">srand()</code> 的數值，也幾乎一模一樣，導至這整招失效。而且因為 random sequence 一模一樣，所以後面的動作都非常「synchronize」，效率可想而知。</p>
<p>我那時的解法是，乾脆進而撰寫了 <code class="inline_code">device_random_generator</code> 與 <code class="inline_code">guid_random_generator</code> 來使用，前者直接利用硬體手法取得亂數值，後者仰賴了 GUID 的產生，有一部份是亂數的結果。</p>
<p>但若嫌麻煩，使用 avhacker 或 sorry 提的，用更精確的時間，或把 Process ID、Thread ID 等一起參作伙做撒尿魚丸，來得到亂數種子值，都是簡便但可行的好方法。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3036/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Weekly Tweets on 2010-06-20</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3044/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3044/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 06:00:00 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Murmuring]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/articles/jeffhung/3044/</guid>
		<description><![CDATA[1.5T HDD 的 C/P 值優勢越來越少了。 http://plurk.com/p/5vrz18 #]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>1.5T HDD 的 C/P 值優勢越來越少了。 <a href="http://plurk.com/p/5vrz18" rel="nofollow">http://plurk.com/p/5vrz18</a> <a href="http://twitter.com/jeffhung/statuses/16611574475" class="aktt_tweet_time">#</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3044/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Join 地獄</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3021/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3021/#comments</comments>
		<pubDate>Fri, 21 May 2010 09:18:25 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3021</guid>
		<description><![CDATA[標題有雙關。XD 我們小組所負責的某模組的 database schema，原本只有兩個 table，送出去與整個 team 所有模組的 database schema 整合後，事情變成： 模組裡最會被頻繁使用的 API，所需要下的 SQL query，需要 join 達 8 個 tables，才能拿到我們需要的資訊。若還要驗證輸入的參數是否正確，則還需要再多 join 一個，共 9 個 tables。 這個世界真是美妙啊。]]></description>
			<content:encoded><![CDATA[<p>標題有雙關。XD</p>
<p>我們小組所負責的某模組的 database schema，原本只有兩個 table，送出去與整個 team 所有模組的 database schema 整合後，事情變成：</p>
<p>模組裡最會被頻繁使用的 API，所需要下的 SQL query，需要 join 達 8 個 tables，才能拿到我們需要的資訊。若還要驗證輸入的參數是否正確，則還需要再多 join 一個，共 9 個 tables。</p>
<p>這個世界真是美妙啊。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3021/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>囧豆腐</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3014/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3014/#comments</comments>
		<pubDate>Fri, 07 May 2010 11:21:41 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3014</guid>
		<description><![CDATA[今天見識到了這個意外...]]></description>
			<content:encoded><![CDATA[<p>今天見識到了這個意外：</p>
<p><a href="http://www.flickr.com/photos/jeffhung/4586513912/"><img alt="" src="http://farm5.static.flickr.com/4033/4586513912_f73b1bfb52_m.jpg" /></a> <a href="http://www.flickr.com/photos/jeffhung/4586514294/"><img alt="" src="http://farm4.static.flickr.com/3311/4586514294_8433ab5d90_m.jpg" /></a></p>
<p>最後是拿螺絲起子把「囧豆腐」救出來的。XD</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3014/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ECFA 雙英辯論</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/3006/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/3006/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 14:48:06 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=3006</guid>
		<description><![CDATA[看了《ECFA 雙英辯論文字紀錄》仍然一頭霧水，搞不清楚 ECFA 是什麼。然後，看到《蔡英文大話專訪 SEMI 逐字稿》，雖然還是無法知道 ECFA 是什麼，但卻確實地明白了，ECFA 可能帶來的衝擊： 台灣和中國都是 WTO 的會員國。 身為 WTO 會員國，關稅須適用所有國家，也就是說，對所有其它會員國的關稅，須一致。 除非，兩國之間很「麻吉」，簽了「自由貿易協定」，才可有最惠國待遇，也就是雙方的關稅，可以比對其他會員國，要來得低。 依據 WTO 規定，兩國要能「麻吉」，條件是簽了「自由貿易協定」之後，在十年內，兩國必需在「所有產品」中，挑選 90%，將關稅降至「零」。 馬英九說的「早收名單」，可以讓台灣部份產業，在簽了 ECFA 的兩、三年間，擁有相對的關稅優勢，獲得短期的利益。 然而三、四年後，台灣與中國之間，必須逐步調降關稅，在十年內，達到 90% 出口產品類別裡，關稅為 0 的地步。 少了關稅保護，中國的廉價產品，將長驅直入，對台灣至少 2/3 人口，產生衝擊，造成財富重分配，與巨大的貧富差距。 十年的限制，亦限縮台灣進行產業轉型，人力資源升級的可能性，當關稅保護傘消失的速度太快時，因競爭劇烈導至失敗的企業，與其員工，將沒有能力，獲得再就業或轉業的機會，使失業率上升。預估可能影響至少四、五十萬人。 詳細內容，還是要看前列文字稿最好。]]></description>
			<content:encoded><![CDATA[<p>看了《<a href="http://talk.news.pts.org.tw/2010/04/ecfa-ecfa-ecfa-ecfaecfa-ecfa26950ecfa.html">ECFA 雙英辯論文字紀錄</a>》仍然一頭霧水，搞不清楚 ECFA 是什麼。然後，看到《<a href="http://docs.google.com/Doc?docid=0Aa51tWpDQAGHZGNiYjltbXdfMWc0bmNuNGNx&amp;hl=en">蔡英文大話專訪 SEMI 逐字稿</a>》，雖然還是無法知道 ECFA 是什麼，但卻確實地明白了，ECFA 可能帶來的衝擊：</p>
<ul>
<li>台灣和中國都是 WTO 的會員國。</li>
<li>身為 WTO 會員國，關稅須適用所有國家，也就是說，對所有其它會員國的關稅，須一致。</li>
<li>除非，兩國之間很「麻吉」，簽了「自由貿易協定」，才可有最惠國待遇，也就是雙方的關稅，可以比對其他會員國，要來得低。</li>
<li>依據 WTO 規定，兩國要能「麻吉」，條件是簽了「自由貿易協定」之後，在十年內，兩國必需在「所有產品」中，挑選 90%，將關稅降至「零」。</li>
<li>馬英九說的「早收名單」，可以讓台灣部份產業，在簽了 ECFA 的兩、三年間，擁有相對的關稅優勢，獲得短期的利益。</li>
<li>然而三、四年後，台灣與中國之間，必須逐步調降關稅，在十年內，達到 90% 出口產品類別裡，關稅為 0 的地步。</li>
<li>少了關稅保護，中國的廉價產品，將長驅直入，對台灣至少 2/3 人口，產生衝擊，造成財富重分配，與巨大的貧富差距。</li>
<li>十年的限制，亦限縮台灣進行產業轉型，人力資源升級的可能性，當關稅保護傘消失的速度太快時，因競爭劇烈導至失敗的企業，與其員工，將沒有能力，獲得再就業或轉業的機會，使失業率上升。預估可能影響至少四、五十萬人。</li>
</ul>
<p>詳細內容，還是要看前列文字稿最好。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/3006/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Tweets on 2010-04-04</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/2996/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/2996/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 07:19:01 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Murmuring]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=2996</guid>
		<description><![CDATA[原來其實 MacVim 是可以顯示 256 色的，只不過 #070707 相當於黑色，難怪看不到東西。XD # Google Wave 右上角多了個 Feedback 按鈕，剛猛一看想說怎麼跟 Facebook 合作了。 # 今天最後不曉得會不會有愚人節懶人包？:-p # RT @ddsakura: RT @miniroom549: 中華電信的VDSL吹噓為「光世代網路」，今天被公交會重罰100萬，可是被騙簽約裝機的人，中華電信又不會因此返還，應該要有人去按鈴控告中華電信，以刑法245條詐欺罪控訴。 # http://ping.fm/1THzP (占领) # 我的這一班的老師變漂亮了。 #]]></description>
			<content:encoded><![CDATA[<ul class="aktt_tweet_digest">
<li>原來其實 MacVim 是可以顯示 256 色的，只不過 #<a class="aktt_hashtag" href="http://search.twitter.com/search?q=%23070707">070707</a> 相當於黑色，難怪看不到東西。XD <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11230913065">#</a></li>
<li>Google Wave 右上角多了個 Feedback 按鈕，剛猛一看想說怎麼跟 Facebook 合作了。 <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11389537842">#</a></li>
<li>今天最後不曉得會不會有愚人節懶人包？:-p <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11389605618">#</a></li>
<li>RT @ddsakura: RT @miniroom549: 中華電信的VDSL吹噓為「光世代網路」，今天被公交會重罰100萬，可是被騙簽約裝機的人，中華電信又不會因此返還，應該要有人去按鈴控告中華電信，以刑法245條詐欺罪控訴。 <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11393888771">#</a></li>
<li><a rel="nofollow" href="http://ping.fm/1THzP">http://ping.fm/1THzP</a> (占领) <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11398631522">#</a></li>
<li>我的這一班的老師變漂亮了。 <a class="aktt_tweet_time" href="http://twitter.com/jeffhung/statuses/11519408833">#</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/2996/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>近照</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/2988/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/2988/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 02:03:01 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Baby]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=2988</guid>
		<description><![CDATA[換了一個 blog 的大頭照，越看越尬意。]]></description>
			<content:encoded><![CDATA[<div class="docbook-imageobject float-right"><a href="http://www.flickr.com/photos/jeffhung/4480332545/" target="_blank"><img width="240" height="237" alt="" src="http://farm5.static.flickr.com/4009/4480332545_c6864675ed_m.jpg" /></a></div>
<p>換了一個 blog 的大頭照，越看越尬意。紅蘿蔔不知道怎麼就學會了比「ㄚ」，不過卻是平舉，配上生平第一次戴的墨鏡，超酷的。</p>
<p>這次改用 Gravatar 來提供大頭照下載點，以後要換就方便多了。</p>
<p>最近玩起 <a href="http://www.theplayforge.com/home/zombie-farm">Zombie Farm</a>，可以種辛香植物，種僵屍，以及派僵屍攻打隔壁農莊，吃麥大爺的腦，遊戲平衡還不錯，殺時間，好玩。</p>
<p>另一款 We Rule 就不好玩了。常常連不上 server 不說，更無腦的是這個設定：菜長完一段時間沒採收就會「蔫去」等於做廢。問題是沒有人有辦法無時無刻注意著在對的時間採收，即使是有支援 Notification 也是一樣。所以玩的結果是，到現在我還沒有一次有機會採收到稍為高階的植物。失敗的遊戲。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/2988/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>「我們從那裡來啊？」</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/2983/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/2983/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 00:48:20 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[Baby]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=2983</guid>
		<description><![CDATA[記錄一下，昨晚睡前，紅蘿蔔突然問了這個問題：我們從那裡來啊？]]></description>
			<content:encoded><![CDATA[<p>記錄一下，昨晚睡前，紅蘿蔔突然問了這個問題：</p>
<blockquote>
<p>我們從那裡來啊？</p>
</blockquote>
<p>蘿蔔媽於是向紅蘿蔔解釋，紅蘿蔔是爸爸和媽媽生的，爸爸是阿公和阿媽生的，媽媽是外公和外婆生的。解釋了半天，也不曉得紅蘿蔔有沒有聽懂。</p>
<p>大哉問吶。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/2983/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Letting va_list re-entraint by va_copy()</title>
		<link>http://www.jeffhung.net/blog/articles/jeffhung/2954/</link>
		<comments>http://www.jeffhung.net/blog/articles/jeffhung/2954/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 15:38:01 +0000</pubDate>
		<dc:creator>jeffhung</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.jeffhung.net/blog/?p=2954</guid>
		<description><![CDATA[之前在這篇《Non-standard behavior of (v)snprintf, on Visual C++》探究過 strprintf() 的實作方法。那時我以為已經找到終極解法，僅需為每個不符合標準的平台，製作 work around 即可。不過最近將這些程式搬到 Mac OS X 上面，卻連連接到 Segment Fault，才知道其實我的 strprintf() 還有缺陷，導因於我的無知與疏忽。]]></description>
			<content:encoded><![CDATA[<p>之前在這篇《<a href="http://www.jeffhung.net/blog/articles/jeffhung/1064/">Non-standard behavior of (v)snprintf, on Visual C++</a>》探究過 <code class="inline_code">strprintf()</code> 的實作方法。那時我以為已經找到終極解法，僅需為每個不符合標準的平台，製作 work around 即可。不過最近將這些程式搬到 Mac OS X 上面，卻連連接到 <a href="http://en.wikipedia.org/wiki/Segmentation_fault">Segment Fault</a>，才知道其實我的 <code class="inline_code">strprintf()</code> 還有缺陷，導因於我的無知與疏忽。</p>
<p>拿該篇最後一個版本的程式，在 Mac OS X 10.6 (Snow Leopard) 上面編譯執行，會得到下列的輸出結果：</p>
<pre class="screen">
SHELL&gt; ./a.out
[DEBUG] pbuf_size == 16
[DEBUG] len == 13
[DEBUG] {13} Hello, sign!
Hello, sign!
[DEBUG] pbuf_size == 16
[DEBUG] len == 17
[DEBUG] pbuf_size == 18
[DEBUG] len == 26
[DEBUG] pbuf_size == 27
[DEBUG] len == 15
[DEBUG] {15} Hello, (null)!
[DEBUG] free pbuf
Hello, (null)!
[DEBUG] pbuf_size == 16
[DEBUG] len == 36
[DEBUG] pbuf_size == 37
[DEBUG] len == 9
[DEBUG] {9} Hello, !
[DEBUG] free pbuf
Hello, !
</pre>
<p>這個結果，很顯然地，並不正確。起先我以為是 Mac OS X 的 <code class="inline_code">vsnprintf()</code> 和 Windows 平台一樣，不符合 C99 標準。不過驗證的結果卻非如此。幾經波折，再加上空閒很少，拖了好久我才注意到，上列輸出裡，第二輪預期結果為 <code class="inline_code">&quot;Hello, jeffhung!&quot;</code> 的測試，其 <code class="inline_code">len</code> 值起先為正確的 <code class="inline_code">17</code>，後來卻變成了 <code class="inline_code">26</code> 與 <code class="inline_code">15</code>。這個差異，讓我注意到，我這段程式，居然只有一個 <code class="inline_code">va_start()</code>，而沒有 <code class="inline_code">va_end()</code>。</p>
<p>見鬼，真是見鬼！！居然犯這種低級錯誤，我羞愧到極點，想要鑽到土裡去。不過，還好趕緊檢查所有我寫的相關程式庫，都沒有這種少掉 <code class="inline_code">va_end()</code> 的錯誤，只能算是當初寫文章時，準備範例程式不夠嚴謹。</p>
<p>但是將 <code class="inline_code">va_end()</code> 補在函式後面後，卻仍然產生同樣的錯誤輸出，讓我百思不得其解。測試後發現，要將 <code class="inline_code">va_start()</code> 與 <code class="inline_code">va_end()</code> 包在 <code class="inline_code">vsnprintf()</code> 前後才行。也就是說，每次將 <code class="inline_code">va_list</code> 變數送進去給 <code class="inline_code">vsnprintf()</code> 用之前，都要重新用 <code class="inline_code">va_start()</code> 初始化一次。這不禁讓我懷疑，<code class="inline_code">va_list</code> 變數，是 non-reentraint 的。</p>
<p>翻查 C99 標準，在 7.15.3 節裡找到這句：</p>
<blockquote>
<p>The object <code class="inline_code">ap</code> may be passed as an argument to another function; if that function invokes the <code class="inline_code">va_arg</code> macro with parameter <code class="inline_code">ap</code>, the value of <code class="inline_code">ap</code> in the calling function is indeterminate and shall be passed to the <code class="inline_code">va_end</code> macro prior to any further reference to <code class="inline_code">ap</code>.<sup>212)</sup></p>
<p><small>212) It is permitted to create a pointer to a <code class="inline_code">va_list</code> and pass that pointer to another function, in which case the original function may make further use of the original list after the other function returns.</small></p>
</blockquote>
<p>這證實了我的想法。另外，原來還有 <code class="inline_code">va_copy()</code> 這個 macro，以便在自己寫的，直接收一個 <code class="inline_code">va_list</code> 變數而非 <code class="inline_code">...</code> 的 <code class="inline_code">v</code> 系列函式，複製 <code class="inline_code">va_list</code> 變數好重覆使用。再依據 C99 標準裡第 7.15.1.1 節的說法：</p>
<blockquote>
<p>Each invocation of the <code class="inline_code">va_start</code> and <code class="inline_code">va_copy</code> macros shall be matched by a corresponding invocation of the <code class="inline_code">va_end </code>macro in the same function.</p>
</blockquote>
<p>得知自製 <code class="inline_code">v</code> 系列函式時，若收到的 <code class="inline_code">va_list</code> 變數會不只用到一次，如再傳給 <code class="inline_code">vsnprintf()</code> 很多次，則最好每次都用 <code class="inline_code">va_copy()</code> 製作複本，使用這個複本，並馬上利用 <code class="inline_code">va_end()</code> 銷毀之。</p>
<p>雖然說我之前寫的相關程式庫，並沒有犯少了 <code class="inline_code">va_end()</code> 的低級錯誤，但一樣還是沒有注意到這個 reentraint 的問題。還好在所 target 的平台，實際上並不會造成影響，隨附的 test cases 的成功執行，也都確保了這點。不過，這種 non portable issue，還是地雷一枚。寫出這種程式，慚愧啊慚愧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeffhung.net/blog/articles/jeffhung/2954/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

