Search Google

Tuesday, July 31, 2007

感人肺腑的farewell letter -- From boss

Dear EOS members,



Today, I officially left the office and NTHU. I would like to thank you for your support and hard work in the past few years. Together we strived to build the EOS lab, in which many great work and students were developed. Looking back in the past 5 years, it is a wonderful journey that I will never feel regret. It is a path filled with tumbles, struggles, and getting-ups. I learned so much from you. Thank you for your tolerance with my impatience when I tried to do things good and right. I hope it is also a good journey to you all.



My next-step at Google starts next Monday. In this job, I will no longer advise students but lead engineers. I will no longer provide education but deliver products. The challenges and tests are tremendous to compete with the best engineers in the world. I would not be confident to take this job if it were 5 years ago. However, with the world-class research work we delivered together, I can confidently say that I am the best engineer in the world. You are.



The distance between Hsinchu (anywhere) and TPE seems a bit. But, thanks to technology, it is only a fingertip away. I am no longer a professor so I cannot offer any advise. But, as a friend, if you need any help or opinion, you know how to reach me. Good luck on your journey and best wishes.



Sincerely yours,

Tai-Yi

High tech... 如此不堪一擊~

今天終於把所有的東西都搬回家了。
回家的路上還添購了一台19"螢幕,孝順的我(絲毫不汗顏!)當然把新螢幕奉獻給爸爸,自己則接收了之前老爸在用的17"螢幕。
回到家後第一個整理的不是衣服,也不是書籍,而是電腦零件(果真是個宅男!)。
先把搬回家的$0 PC零件一一裝進家裏的主機殼',再將電源、螢幕線接上之後便興高采烈的按下電源鈕。。。沒想到螢幕上殘酷的顯示"kernel panic"字樣!
心想可能是搬運的過程中振動到硬碟造成資料毀損。
當下第一個反應便是"又要重灌了",拿出安裝光碟重新開機開到一半的時候又當機了!
還好見過大風大浪的我並沒有亂了方寸,再次開機的時候選擇了"Memory Test"的選項。
我的老天!
居然沒有一個address的狀態是PASS,抱著姑且一試的心情將所有的記憶體拔下來再重新插上之後沒想到就海闊天空,螢幕上顯示著登入畫面。

雖然這是$0 PC而且整件事情平安落幕,但是心中還是不免要發個牢騷,難道所謂的高科技產物就這麼不堪一擊嗎?!
搬運過程中的震盪就可以讓記憶體接觸不良,甚至對硬碟的穩定性讓人如此不放心。
難怪大家還是會將重要文件列印出來以hard copy的方式保存~

Friday, July 27, 2007

lpr -P destination

列印檔案的時候通常不需要指定印表機,如果遇到admin沒有設定預設印表機的話就必須自行指定了。
印表機名稱可以從CUPS(http://localhost:631/)中的"Printers"得知。
要注意的是指定印表機名稱的時候,如果名稱中含有括號等跳脫字元就必須在前面加個"\",eg.
印表機名稱:LaserJet-4200-Series-Postscript-(recommended)
lpr指令:lpr -P LaserJet-4200-Series-Postscript-\(recommended\)

gnome-terminal的中文顯示

繼稍早設定完$0 PC後發現我在gnome-terminal透過ssh連線到server的時候中文全部變成亂碼,
檢查locale確定是zh_TW.Big5無誤,但是中文就是出不來。。。
後來才發現在gnome-terminal裡面的"terminal" --> "Set Character Encoding"中的設定是UTF-8!
將設定改為Big5之後中文顯示總算恢復正常~
難道UTF-8已經是不可避免的趨勢了嗎@@
要統一就快吧,不然老是為了不同的編碼一直調整也不符合經濟效益。

$0 PC

終於搞定我昨天利用殘骸拼湊出的$0 PC!
首先為了安裝Nvidia的driver重新編譯kernel,接著設定scim中文輸入法,
再來安裝&設定firefly字型,現在正在build vim71。。。
大部分的步驟都可以在google找到,eg.

設定字型:
http://kenshinn.wordpress.com/2005/11/11/%E5%AD%90%E5%87%8C%E7%9A%84linux%E7%AD%86%E8%A8%98-%E5%9C%A8ubuntu%E4%B8%AD%E4%BD%BF%E7%94%A8firefly-newsung%E5%AD%97%E5%9E%8B/
http://blochy.com/lancetw/blog/archives/2006/07/16/107/

安裝輸入法:
http://plog.longwin.com.tw/my_note-unix/2007/01/23/ubuntu_use_scim_2007

比要要注意的就是有在firefox中有可能無法輸入中文,google之後發現是因為scim-pingyin套件所造成的,
因此千萬要記得不要安裝scim-pingyin

呼~~
終於可以看到漂亮的中文字了!

Wednesday, July 25, 2007

實驗室解散前奏曲

隨著實驗室解散之日逼近,今天大家總動員,從下午兩點開始大掃除一直整理到晚上(剛才-11:00pm)。除了一袋袋的垃圾之外,我們還搜出了許多對社會有貢獻的東西,於是我們稍做整理之後便將這些物品堆放於實驗室外面贈與有緣人,為了達成"人人有功練,人人有飯吃"的大同境界,我們在物品旁邊擺放了捐獻箱。



另外還整理出一堆可以報廢的電腦,於是我們將每台電腦中可用的殘骸整理出來,將這些殘骸加以組裝之後又是一台堪用的PC了,雖然沒辦法跟現在的主流機相比,但是跟$100 PC相較之下應該是大勝。

Tuesday, July 24, 2007

計程車密度 v.s. 城市繁榮度

今天晚上到姨丈的診所檢查牙齒,去程非常順利,在學校門口就招到計程車。
經過檢查之後才確定原來以為剝落的補牙還好好的,疑似蛀牙的部分也只是虛驚一場。
診斷結束之後在馬路上居然沒看到半輛計程車 @@
於是只好沿著來的路往回走,最壞的打算就是一路走回學校!
走了四十分鐘之後終於招到一輛空車得以順利回到學校 >.<
原以為隨手招都有的計程車在竹北竟然是如此難招~
看來竹北還真是個荒涼的地方。

國小同學結婚了!

前天參加國小同學(林俊仁)的婚禮,他目前在台北榮總當神經內科的駐院醫師。
我們已經很久沒見面,前陣子忽然聽說他要結婚,他是我還有在聯絡的國小同學中最早結婚的一個。
他的這段姻緣也算是得來不易,兩個人戀愛了六年(OMFG!),婚禮中也聽他們互道在日常生活中被對方所感動的事情。
希望未來我的婚禮(如果有的話?!)上也能有足夠的浪漫事蹟能夠陳述。
Anyway,讓我們一起恭喜這對新人並祝福他們永浴愛河,白頭偕老~

以下是當天在宴會現場與國小同學+老師的合照:




Friday, July 20, 2007

王建民敗投的原因。。。

其實是因為我看了現場轉播~
從小只要我看現場轉播,我所支持的隊伍總是會落敗。
中職,NBA,Rugby,到前陣子的American Cup都是。
昨天的Chien-Ming Wang又再一次的證明我帶賽 @@
看來我以後還是乖乖看重播好了。

Final combo from HIM

It looks to me that Cheng-Han is the key person who will determine the fate of this paper.



Cheng-Han: if you take over this paper, I need your full commitment. It is like running for 5000m. Only when we publish this paper, all our efforts mean something. If you plan to quit anywhere before the finish line, I prefer we drop this paper now. 半吊子做不出什麼東西 為有專注與完全投入 這篇paper才可能生的出來



So, Cheng-Han, are you fully committed on this paper?

Thursday, July 19, 2007

這是在打太極拳的"雲手"嗎?

Thanks for the message. It is good to have you among us in the past couple of years. We won the first prize in 2006 ESDC only because of your hard work. I really appreciate that.



But, I am still not clear whether I should work on this paper. Are you or Cheng-Han responsible for working with me to publish this paper? If neither of you would like to take this responsibility, let us drop it and enjoy our summer. By taking responsibility, I mean doing exactly what I advise.



Thanks.

Wednesday, July 18, 2007

自認文情並茂的回信

Dear Sir,

I wanted to publish this paper.
After all, my CV would look better if there is a publication in it.
However, considering my schedule in August is totally unpredictable, and I don't want to give you an impression of taking military service as an excuse to quit the game.
I will keep in mind the rules and principles you have taught me and work on this paper during the periods I am available.
Sometimes I did not fulfill your requests or made mistakes, but I did not do it in purpose.

After being your student for 2.5 years, I have learnt and changed a lot.
I appreciate the knowledge and spirit that I learn from you.
Wish you the best luck in Google.

Sincerely,

Tuesday, July 17, 2007

在Visual Studio 2005中browse code

最近在使用VS2005的時候始終覺得不太方便,因為沒有發現code navigation/browsing的功能。
以前在Linux下寫程式的時候習慣使用vim + cscope,這樣的結合讓我可以很容易的在原始碼當中穿梭自如,於是興起了我替VS寫這麼一個plugin的念頭。
花費兩天研究VS extensibility,準備著手進行的時候,非常因緣際會的發現原來VS早就支援code browsing功能!
特此抓了兩張screenshots加以說明:
(1) 移至定義
在想看的function/variable上按右鍵便會出現下面的選單,點選移至定義就可以跳到function body code的位置,如果有兩個一樣的function name,則可以點選尋找所有參考

(2) 向後巡覽
當看完function body code之後可以使用toolbar上的向後巡覽回到原本正在看的程式碼。如果需要來回切換的話可以使用向後巡覽右邊的向前巡覽做快速切換。


讓我現在完全沒有寫plugin的理由了 @.@

Monday, July 16, 2007

Accessing MySql DB in .NET using ODBC

準備工作都詳細的陳列在MySql的網頁上。
要注意的是在使用(建立connection)的時後必須指定Driver,像是:
public OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;uid=root;pwd=root's pwd");
使用MySql connector時所使用的username也要改成uid
除此之外使用方法與MySql connector無異。

以下是這幾天測試時所寫的demo code(將圖片以binary格式加入db,將圖片由db取出並顯示在螢幕上,從db中刪除圖片),還不太會用parameter,因此透過datarow的方式insert data,

// button1 --> load a picture into db
// button2 --> exit program
// button3 --> file selector; openFileDialog
// button4 --> retrieve picture from db and show it in a pictureBox
// button5 --> delete an entry in db

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using MySql.Data.MySqlClient;
using System.Data.Odbc;
using System.IO;

namespace dryeh
{
public partial class dryeh_form_01 : Form
{
public OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;uid=root;pwd=root's pwd");

public dryeh_form_01()
{
InitializeComponent();
cn.Open();
UpdateNrEntry();
ChkFilePath();
ChkNrEntry();
}

private void button2_Click(object sender, EventArgs e)
{
cn.Close();
cn.Dispose();
this.Close();
}

private void button1_Click(object sender, EventArgs e)
{
Ex_InsertPicToDB();
ChkNrEntry();
}

private void button3_Click(object sender, EventArgs e)
{
Ex_RetrievePicFromDB();
}

private void button4_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
ChkFilePath();
}

private void button5_Click(object sender, EventArgs e)
{
DelEntry();
UpdateNrEntry();
ChkNrEntry();
}

private void ChkFilePath()
{
if (textBox1.Text.Length == 0)
{
button1.Enabled = false;
}
else
{
if (File.Exists(textBox1.Text))
{
button1.Enabled = true;
}
}
}

private void ChkNrEntry()
{
if (numericUpDown1.Maximum == 0)
{
button5.Enabled = button3.Enabled = false;
}
else
{
if (button3.Enabled == false)
{
button5.Enabled = button3.Enabled = true;
numericUpDown1.Value = numericUpDown1.Minimum = 1;
}
else
{
if (numericUpDown1.Value == 0)
{
numericUpDown1.Value = 1;
}
}
}
}

private void UpdateNrEntry()
{
OdbcDataAdapter da = new OdbcDataAdapter("select * from blobtest", cn);
OdbcCommandBuilder myCB = new OdbcCommandBuilder(da);
DataSet ds = new DataSet("blobtest");

da.Fill(ds, "blobtest");
numericUpDown1.Maximum = ds.Tables["blobtest"].Rows.Count;
label1.Text = " / " + numericUpDown1.Maximum;
}

private void Ex_MySqlQueryRow()
{
OdbcDataReader myReader;
OdbcCommand myCommand = new OdbcCommand("SELECT film_id, title FROM film", cn);

myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader.GetValue(0) + ", " + myReader.GetString(1));
}
myReader.Close();
myCommand.Dispose();
}

private void Ex_Bitmap()
{
Bitmap img = new Bitmap(@"D:\Document\James\Visual Studio 2005\Projects\dryeh\dryeh\pic\Winter.jpg", false);
pictureBox1.Image = img;
}

private void Ex_InsertPicToDB()
{
OdbcDataAdapter da = new OdbcDataAdapter("select * from blobtest", cn);
OdbcCommandBuilder myCB = new OdbcCommandBuilder(da);
DataSet ds = new DataSet("blobtest");
// 讀圖檔,也可以是CCD照進來的memory stream,只是後面的operation要跟著改用memory stream的ops
FileStream fs;
if (textBox1.Text.Length == 0)
{
MessageBox.Show("Please provide path to the file.");
}
else
{
fs = new FileStream(textBox1.Text, FileMode.OpenOrCreate, FileAccess.Read);
// FileStream fs = new FileStream(@"D:\Document\James\Visual Studio 2005\Projects\dryeh\dryeh\pic\Sunset.jpg",
// FileMode.OpenOrCreate, FileAccess.Read);

byte[] MyData = new byte[fs.Length];
// 將file stream讀進byte array (MyData)中
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
// 利用DataAdapter將blobtest table填入ds中
da.Fill(ds, "blobtest");

DataRow myRow;
// 在blobtest table中新增一個entry
myRow = ds.Tables["blobtest"].NewRow();
// 設定該entry的各項欄位
myRow["blobdesc"] = "test3";
myRow["blobdata"] = MyData;
// 將該entry加入blobtest table中
ds.Tables["blobtest"].Rows.Add(myRow);
// update blobtest table,讓改變發生
da.Update(ds, "blobtest");
UpdateNrEntry();
}
}

private void Ex_RetrievePicFromDB()
{
OdbcDataAdapter da = new OdbcDataAdapter("select * from blobtest", cn);
OdbcCommandBuilder MyCB = new OdbcCommandBuilder(da);
DataSet ds = new DataSet("blobtest");

byte[] MyData = new byte[0];

// 將table填入ds中
da.Fill(ds, "blobtest");
DataRow myRow;
// 取table中的第二個row (第三個entry)
myRow = ds.Tables["blobtest"].Rows[System.Convert.ToInt32(numericUpDown1.Value-1)];
// 取出blobdata欄位中的資料放到byte陣列中(MyData)
MyData = (byte[])myRow["blobdata"];
// 將資料由raw binary轉換成memory stream再轉換成圖檔並顯示在picture box中(目前沒有處理resize to fit的部分)
MemoryStream stmBLOBData = new MemoryStream(MyData);
pictureBox1.Image = Image.FromStream(stmBLOBData);
}

private void DelEntry()
{
OdbcDataAdapter da = new OdbcDataAdapter("select * from blobtest", cn);
OdbcCommandBuilder MyCB = new OdbcCommandBuilder(da);
DataSet ds = new DataSet("blobtest");
DataRow myRow;
Int64 id;
da.Fill(ds, "blobtest");
myRow = ds.Tables["blobtest"].Rows[System.Convert.ToInt32(numericUpDown1.Value-1)];
id = System.Convert.ToInt64(myRow["blobid"]);
OdbcCommand myCommand = new OdbcCommand("delete from blobtest where blobid = " + id, cn);
myCommand.ExecuteReader();
myCommand.Dispose();
}
}
}

Thursday, July 05, 2007

How to "wait" in dos prompt while running a batch file ?

解答在這裡
In short, 就是用ping...

for example:
@ping 127.0.0.1 -n 2 -w 1000 > nul

另外還有一個說明batch的網頁也不錯。