2009年9月16日 星期三

C# byte[] string Convert

byte[] → string

byte[] byteArr = new byte[]{1,0};
string s = System.Text.Encoding.ASCII.GetString(byteArr);

string → byte[]

System.Text.Encoding.ASCII.GetBytes(s);

2009年8月29日 星期六

2009/08/29 汐止←→五分山氣象站

去程:汐止→汐平公路→平溪→106縣道(十分、74.5公里處五分山氣象站入口)→五分山氣象站

回程:五分山氣象站→106縣道(十分、平溪)→汐平公路→汐止

總里程:74.99KM
總騎乘時間:5:28:44

行程圖片




2009年8月18日 星期二

Java HashMap VS C# Dictionary



Java Code:

HashMap< String , String > hm = new HashMap< String , String >();
hm.put("A", "A--Content");
hm.put("B", "B--Content");
//Get all value
for(Iterator< String > it = hm.keySet().iterator(); it.hasNext();){
String key = it.next();
System.out.println("Key: "+ key + ", value: "+hm.get(key));
}
//Get specific value
System.out.println(hm.get("A"));


C# Code:

Dictionary< string , string > dict = new Dictionary< string , string >();
try
{
dict.Add("A", "A--Content");
dict.Add("B", "B--Content");
//Get all value
foreach (KeyValuePair< string , string > kvp in dict)
{
Console.WriteLine("key: {0}, value: {1}", kvp.Key, kvp.Value);
}
//Get specific value
string val = "";
dict.TryGetValue("A", out val);
Console.WriteLine("value="+val);
//or
Console.WriteLine("value=" + dict["A"]);
}
catch (Exception)
{
//The method "Add" will throw exception if key already existed!!!
Console.WriteLine("Can't insert same key");
}

2009年8月2日 星期日

8/2 汐止 ←→ 冷水坑

去程:汐止→河濱自行車專用道(汐止→東湖→南港→松山→內湖→大直)→大直美麗華→劍南路至善路三段71巷平菁街(平等國小→台北奧萬大)→菁山路菁山路101巷→冷水坑

回程:原路折返

心得:冷水坑真的很不好騎,連續的超陡坡,不過從至善路三段71巷開始至終點冷水坑,不落地完成。


總騎乘距離:78.53 KM
總騎乘時間:5:45:26

2009年4月13日 星期一

jQuery AJAX on IE does not reflesh

If you use jQuery to implement the AJAX functionality, especially use the "get", "getJSON" and "load", would you encounter one problem on IE, "Ajax" does not really call backend link, but return value immediately".

The problem is the cache of IE. If we use "Get" method to get data from backend, and the parameters are the same, IE won't really get the data. In contrast, FF does not have this problem. The solution is to set cache to false.


$.ajaxSetup({cache: false});
$.get("xxx.jsp",{A=a,B=b},function(){

});


Or, add a parameter with date.

$.get("xxx.jsp",{timestamp:new Date().getTime()},function(){

});

Subversion on Win2000 Server

New subversion does not support Windows 2000. So we need to use the older version, 1.4.6.

After the installation of SVN, following the steps below:

  1. Create repository


  2. cd C:\Subversion\bin\
    svnadmin create D:\Repos

  3. Configuration

  4. svnserve.conf

    [general]
    anon-access = read #If you meet
    #"svn: Not authorized to open root of edit operation"
    #change read to none
    auth-access = write #write means read and write

    password-db = passwd #file "passwd"

    authz-db = authz #file "authz"

    realm = My Project #You could change this as you want.

    passwd

    [users]
    austin = austin
    ting = ting # userid = password

    authz

    [groups]
    matrix = austin,ting # group_name = group_members, ....

    [Repos:/] # The repository you create before.
    # or [/] for each repository
    @matrix = rw # @+group_name, rw => read and write

  5. Start the SVN Server


  6. cd C:\Subversion\bin\
    svnserve -d

2009年4月4日 星期六

汐止 ←→ 小油坑

去程:
汐止國泰醫院 → 大同路 → 中興路 → 自行車專用道 → 內湖出水門 → 基湖路 → 內湖路 → 明水路 → 自強隧道 → 至善路 → 仰德大道 → 陽金公路 → 小油坑

回程:
小油坑 → 陽金公路 → 仰德大道 → 至善路 → 劍南路 → 美麗華 → 自行車專用道 → 中興路 → 大同路 → 汐止國泰醫院


P.S 去程出錯水門,多繞了一下;回程繞劍南路,沒想到坡還頗硬,邊踩還邊怕抽筋。

路程 77.90 KM,實際騎乘時間 5:00:47

心得:
  1. 走了無意義的汐止到至善路,浪費一堆體力,有4+2會更好
  2. 上山體力耗損超快,就算早餐吃很飽也是無濟於事,路上一定要再吃點東西補充體力
  3. 變速線及煞車線外管保護套,很不牢固,裝三個,此行就掉兩個
  4. 我的安全帽不適合,回程頭痛欲裂 (這是一個敗家的好理由...)
  5. 下山的時候兩隻大腿同時抽筋,只要打直就會抽,也算是一個新鮮的體驗啦
  6. 肚子餓好解決,腿力不夠無解,即便是輕量化爬坡輪組也救不了你,看來練腿力才是王道