<?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>Kanru&#039;s 探險日誌 &#187; .NET</title>
	<atom:link href="http://blog.kanru.info/archives/tag/net/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.kanru.info</link>
	<description>當發現美好的事物時，所要做的第一件事，就是把它分享給所有人</description>
	<lastBuildDate>Sun, 23 May 2010 09:51:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Tomboy Plugin &#8211; CJKDisableSpell</title>
		<link>http://blog.kanru.info/archives/239</link>
		<comments>http://blog.kanru.info/archives/239#comments</comments>
		<pubDate>Mon, 10 Jul 2006 06:36:30 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[小工具]]></category>
		<category><![CDATA[爬網探險]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[tomboy]]></category>
		<category><![CDATA[中文]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/239</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>平常已經習慣使用 <a href="http://www.beatniksoftware.com/tomboy/">Tomboy</a> 來記東西，介面還算好用，隨時都可以開新 Note 或是搜尋舊的 Note。用到現在唯一不滿意的地方是 tomboy 會對文章做 spelling check，無論內容是什麼，結果就是中文的 Note 會變成滿江紅。</p>

<p>花了一點時間寫了這個 plugin，可以針對 CJK 的部份取消 spelling check，效果還滿不錯 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>使用前：</p>

<p><a href="http://www.flickr.com/photos/kanru/186207939/" title="Photo Sharing"><img src="http://static.flickr.com/48/186207939_bff3e94537_o.png" width="350" height="252" alt="Screenshot" /></a></p>

<p>使用後：</p>

<p><a href="http://www.flickr.com/photos/kanru/186207940/" title="Photo Sharing"><img src="http://static.flickr.com/74/186207940_828e2c7a3d_o.png" width="351" height="253" alt="Screenshot-1" /></a></p>

<p>使用方法，下載 <a href="http://people.debian.org.tw/~koster/misc/CJKDisableSpellPlugin.cs">CJKDisableSpellPlugin.cs</a> 後自己編譯：</p>

<pre><code>    mcs -t:library CJKDisableSpellPlugin.cs -r:/usr/lib/tomboy/Tomboy.exe -pkg:gtk-sharp-2.0
</code></pre>

<p>或是直接下載編譯好的 <a href="http://people.debian.org.tw/~koster/misc/CJKDisableSpellPlugin.dll">CJKDisableSpellPlugin.dll</a></p>

<p>將 dll 放置在 <code>~/.tomboy/Plugins/</code> 後，重新啟動 Tomboy 即可。</p>

<p>2008-12-08 Update:</p>

<p>tomboy 從 0.7 版以後改用 mono addin 架構，更新的程式在</p>

<p><a href="http://github.com/kanru/tomboy-cjk-disable-spellcheck/">http://github.com/kanru/tomboy-cjk-disable-spellcheck/</a></p>

<p>也可以直接下載 <a href="http://people.debian.org.tw/~koster/misc/CJKDisableSpellAddin.dll">CJKDisableSpellAddin.dll</a></p>

<p>不過我沒有仔細測試過，使用時可能會遇到問題。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/239/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MonoDevelop 0.10</title>
		<link>http://blog.kanru.info/archives/217</link>
		<comments>http://blog.kanru.info/archives/217#comments</comments>
		<pubDate>Sun, 16 Apr 2006 00:56:30 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/217</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.monodevelop.com/Release_notes_for_MonoDevelop_0.10">MonoDevelop 0.10</a> Release 了，裡面整合了最新的 GUI Designer &#8212; Stetic</p>

<p><a href="http://www.flickr.com/photos/kanru/129149014/" title="Photo Sharing"><img src="http://static.flickr.com/56/129149014_379cc54f4a_m.jpg" width="240" height="172" alt="Stetic-in-monodevelop" /></a></p>

<p>實際試用的感覺不錯，而且跟 IDE 整合在一起，是使用 auto generated code ，而不是用 .glade 檔。
很有潛力的開發環境。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/217/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bibot3 新功能</title>
		<link>http://blog.kanru.info/archives/215</link>
		<comments>http://blog.kanru.info/archives/215#comments</comments>
		<pubDate>Sat, 01 Apr 2006 17:21:56 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Hack]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/215</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>好吧，拖了很久才寫。</p>

<p>自從 bibot2 從 zion 人間蒸發之後[1]，就開始了用 mono 寫新的 bibot3 的計畫，但是對於到底要有什麼功能一直沒有什麼好點子。從 bibot2 的經驗來看，網址自動紀錄大概是最多人在用的功能，我從來沒想到 url.dot 掛掉之後會有那麼多人詢問&#8230;</p>

<p>某天跟 chihchun 閒聊，討論到把網址丟到某個 social bookmarks 服務(像是 del.icio.us) 的可能性，既然 del.icio.us 有公開 <a href="http://del.icio.us/help/api/">api</a>，那麼應該不難實做，甚至比自己刻資料庫還簡單。</p>

<p>於是，在某天下課後查了一下 api 研究怎麼使用，然後就誕生了 <a href="http://del.icio.us/bibot">http://del.icio.us/bibot</a>。結果比想像中的有趣，因為 del.icio.us 有 tag 的功能，所以可以根據 tag 來判斷某網址是誰、在哪個 channel 提到的，也會自動紀錄時間和更新 title。</p>

<p>附帶一提，tinyurl.com 也有 api 可以呼叫，所以短網址的功能也可以輕鬆完成，不用再自己 parse 網頁的 output。</p>

<p>[1]: 某次停電之後，位在 zion 的 lvm 上的某 vserver 整個消失，只剩下 lost+found ，至今找不到原因。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/215/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Plugin</title>
		<link>http://blog.kanru.info/archives/70</link>
		<comments>http://blog.kanru.info/archives/70#comments</comments>
		<pubDate>Sat, 18 Feb 2006 14:11:14 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/70</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>我之前在 <a href="http://blog.kanru.info/archives/45">.NET &#8211; Load Plugins</a> 寫過如何實做簡單的 plugin interface，最近真正在用的時候才發現問題。</p>

<p>Assembly.Load* 雖然可以把 .dll 檔案動態載入，可是卻找不到任何方法可以 unload.. Assembly 在被載入之後是處於鎖定的狀態，如果這時候把檔案換掉的話，Assembly.Load 便無法再重新載入，會出現 Exception</p>

<p>這樣就沒辦法在後端偷偷換掉 backend 了 -_-</p>

<p>要實做動態的 load, unload 好像是要使用 System.AppDomain 來做（時際上是用 Remoting 的技術），看似簡單，可是我試到現在還沒成功過&#8230; 還變成好像 Assembly 被 Cache 起來的情況，怎麼 load, unload 都是用到舊的 Assembly&#8230; 天阿</p>

<p>參考：<a href="http://dlwang2002.cnblogs.com/archive/2005/10/18/257425.aspx">通过应用程序域AppDomain加载和卸载程序集之后，如何再返回原来的主程序域</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/70/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Short, Int, 加加減減</title>
		<link>http://blog.kanru.info/archives/68</link>
		<comments>http://blog.kanru.info/archives/68#comments</comments>
		<pubDate>Thu, 16 Feb 2006 04:26:42 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blog.kanru.info/archives/68</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<pre><code>short x = 32767;
x = x + 2;
</code></pre>

<p>在 C 裡面，我們可能不小心寫出這樣的 code 而不自覺會造成 overflow，但是在 C# 則會得到</p>

<p>error CS0266: Cannot implicitly convert type &#8216;int&#8217; to &#8216;short&#8217;. An explicit conversion exists (are you missing a cast?)</p>

<p>要改成</p>

<pre><code>x = (short)(x +2);
</code></pre>

<p>才行；
不過神奇的是，如果寫成</p>

<pre><code>x += 2;
</code></pre>

<p>則不會有任何問題的直接 overflow&#8230; 這究竟是什麼樣的設計考量呢？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/68/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET 2.0</title>
		<link>http://blog.kanru.info/archives/57</link>
		<comments>http://blog.kanru.info/archives/57#comments</comments>
		<pubDate>Fri, 20 Jan 2006 15:07:13 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Hack]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/57</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>今天下午心血來潮測試了一下 mono 的 ASP.NET 支援，mono 除了有 apache 用的 mod-mono 模組之外，還提供了一個 standalone 的簡單 webserver &#8212; xsp/xsp2 ，主要用來做開發測試用。</p>

<p>用 C# 來寫的程式都很正常，不管是 1.0 或 2.0 profile 都可以跑，可是後來想要測試 Nemerle 時卻不斷發生錯誤&#8230;</p>

<p>作 .NET compiler 的人應該要提供 Codedom 的 CodeCompiler，CodeGenerator 等等，供其他程式利用內部 DOM 結構動態產生程式碼，主要是用在 ASP.NET</p>

<p>原來 Nemerle 所實做的 Codedom 是從舊的 C# 版本移植的，後來沒有持續更新到 2.0 所以有些地方會出問題，像是沒有使用 partial class，不能把 aspx 與 codefile 分開等等，為了修正這些錯誤下午都在看 Codedom 與 System.Web.Compilation 的東西，現在已經可以正常的用 Nemerle 寫 ASP.NET 2.0 <img src='http://blog.kanru.info/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p>patch 在<a href="http://stu.csie.ncnu.edu.tw/~kanru.96/patches/nemerle-codedom-fix-addition-options.diff">這裡</a>。</p>

<p>Update: This patch has been applied.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/57/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Suffix Tree</title>
		<link>http://blog.kanru.info/archives/56</link>
		<comments>http://blog.kanru.info/archives/56#comments</comments>
		<pubDate>Sat, 14 Jan 2006 16:58:05 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/56</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Tree/Suffix/">Suffix Tree</a>，在字串處理上有非常多的應用，尤其是字串的搜尋、定位等等，利用這個資料結構很多都可以在 O(n) 也就是 linear time 做完。</p>

<p>這是在這學期的 字串學(stringology) 學到的，作業就是實做 suffix tree，我用的是 Ukkonen 的演算法，可以用 on-line construction 的方法建構 suffix tree。</p>

<p>我是用 <a href="http://nemerle.org/Main_Page">Nemerle</a> 寫的（因為在練習），後來也有用 C# 改了另外的版本，但是還是 Nemerle 的版本比較完整。原本是用 System.Collections.Generic.Dictionary 來存每個 State 裡面的 transitions，可是非常的吃記憶體，用 mono &#8211;profile 可以很容易看出來一個 500kb 的檔案，在建構的時候光 Dictionary 就可以吃掉近 150mb 的記憶體；後來改用自己的 linked list 來做，節省了很多資源，2mb 的測試檔可以在 9 秒內建完樹並回報內部節點個數。</p>

<p>整個程式應該還有多可以改進的地方，但是目前的效率作為作業已經可以接受了，先放上來。在<a href="http://stu.csie.ncnu.edu.tw/~kanru.96/program/suffix.n">這裡</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/56/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System.Text.UTF8Encoding</title>
		<link>http://blog.kanru.info/archives/49</link>
		<comments>http://blog.kanru.info/archives/49#comments</comments>
		<pubDate>Wed, 28 Dec 2005 18:25:03 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Hack]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/49</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>在用 <a href="http://smartirc4net.meebey.net/" title="SmartIRC4Net">SmartIRC4Net</a> 寫 irc 程式的時候發現，如果把 encoding 設成 System.Text.Encoding.UTF8 會導致無法連上 irc server。</p>

<p>很好奇的看了 SmartIRC4Net 的 code 結果沒什麼收穫，用的是一般的 StreamWriter 的初始化方法；如果改用 System.Text.UTF8Encoding 就可以正確連上了，而且這是 StreamWriter 預設的 encoding。</p>

<p>到底 Encoding.UTF8 和 UTF8Encoding 兩個有什麼不一樣呢？看了一下 mono 的實做方法，使用上這兩個都是 用 UTF8Encoding 的 instance，只是 Encoding.UTF8 是有 BOM 的，UTF8Encoding 則預設沒有。</p>

<p>就是因為那個多出來的 BOM 導致 irc server 無法認出正確的指令（因為不是 vaild ascii code），在一般使用上也要注意這兩者的差別。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/49/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nemerle &#8211; Redefining symbols</title>
		<link>http://blog.kanru.info/archives/47</link>
		<comments>http://blog.kanru.info/archives/47#comments</comments>
		<pubDate>Wed, 28 Dec 2005 14:57:51 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/47</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>在 nemerle 裡面，可以用</p>

<pre><code>def a = 123;
</code></pre>

<p>這樣的格式來定義一個 immutable 的變數</p>

<p>然而，這樣的寫法也是 vaild 的</p>

<pre><code>def a = 123;
def a = "123";
</code></pre>

<p>雖然看起來像是給 immutable 的 a assign 了兩次不同的值，實際上兩者有完全不同的意義，所以</p>

<pre><code>def (x, y) = (1, 3);
def (x, y) = (y, x);
</code></pre>

<p>也都是被接受的語法。</p>

<p>詳細：<a href="http://nemerle.org/Nemerle_for_OOP_Programmers_Week_4#Side_note:_redefining_symbols">Side  note: redefining symbols</a><span style="font-weight: bold" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/47/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET &#8211; Program Glue</title>
		<link>http://blog.kanru.info/archives/46</link>
		<comments>http://blog.kanru.info/archives/46#comments</comments>
		<pubDate>Sun, 25 Dec 2005 11:55:29 +0000</pubDate>
		<dc:creator>kanru</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[讀書心得]]></category>

		<guid isPermaLink="false">http://kanru.info/~kanru/blog/archives/46</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>C 的 stdio.h 有 popen/pclose 可以用，python 有 popen/popen2&#8230; ，perl 可以把程式當作檔案代號直接開啟執行，這些都可以做到程式間黏合、互動，那 .NET 要怎麼作呢？</p>

<p>可以用 System.Diagnostics.Process 來做到一樣的功能：</p>

<pre><code>using System;
using System.Diagnostics;

public module T {
    public Main (args: array[string]) : void
    {
        def proc = Process ();
        def proc_info = ProcessStartInfo (args[0]);

        proc_info.CreateNoWindow = true;
        proc_info.UseShellExecute = false;
        proc_info.RedirectStandardInput = true;
        proc_info.RedirectStandardOutput = true;
        proc_info.RedirectStandardError = true;
        proc.StartInfo = proc_info;

        proc.Start ();
        while (true) {
            proc.StandardInput.WriteLine (Console.ReadLine ());
            Console.WriteLine (proc.StandardOutput.ReadLine ());
        }
    }
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.kanru.info/archives/46/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
