2009年11月17日 星期二

Pattern Matching in ASP VBScript

str = "[b] aaa [b] bbb [/b] [/b]"

dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True

re.Pattern="\[b\](.*?)\[\/b\]"
do while re.test(str)
str = re.replace(str, "<b>$1</b>")
loop

return str -------------------------------------------- 其中 (.*?) 表示任一字元, 並切割入變數$n

2009年11月10日 星期二

雲中漫步——迎接雲計算時代的到來

這篇寫的淺顯易懂, 適合一般使用者說明.
===================================================

2008年5月9日 下午 06:32:00 發表者:谷歌全球副總裁大中華區總裁 李開複

隨著技術的發展,普通線民使用網路的方式也在悄悄地發生變革。如果你正要打開電腦,在一個文書處理軟體中寫下未來一周的旅行計畫,那麼你不妨試一試這樣一種 全新的文檔編輯方式:打開流覽器,進入 Google Docs 頁面,新建文檔,編輯內容,然後,直接將文檔的 URL 分享給你的朋友——沒錯,整個旅行計畫現在被濃縮成了一個 URL ,無論你的朋友在哪裡,他都可以直接打開流覽器訪問 URL 。無論你分享給多少朋友,他們都可以與你同時編輯、修訂那份誘人的旅行計畫……如果你喜歡上了這種新穎的編輯體驗,那麼恭喜你,你正在擁抱一個美麗的網路 應用模式——雲計算。

很難用一句話說清楚到底什麼才是真正的雲計算。單單是“雲計算”這個名字就已經足夠新潮,足夠浪漫了。其實,我們可 以簡單地把整個互聯網看成是一片美麗的雲彩,現在,連接到這片雲彩的線民在全世界已經有 12 億之多。線民們需要在“雲”中方便地連接任何設備,訪問任何資訊,需要自由地創建內容,與朋友分享。當然,這一切都要在一個安全、快速、便捷的前提下完 成。所謂“雲計算”,就是要以公開的標準和服務為基礎,以互聯網為中心,提供安全、快速、便捷的資料存儲和網路計算服務,讓互聯網這片“雲”成為每一個網 民的資料中心和計算中心。

舉個例子,如果你有一筆錢需要管理,那麼,最簡單易行的方式是把錢塞在自己的枕頭底下,然後在小本本上記下每一 筆入帳和花銷。這種管理方式的缺點顯而易見:你的帳本可能因為受潮而字跡模糊,你出門辦事時可能因為忘帶帳本而焦急萬分,放在枕頭底下的錢可能因為被梁上 君子盯上而夜半失竊……當然,你也可以自己買一個保險櫃,然後用個人電腦上的試算表軟體來管理帳目,但這需要有一定的經濟實力和比較深厚的電腦功底。其 實,最好也最安全的方式是把錢存進銀行,既不用擔心失竊,也可以隨時利用 ATM 機、電話銀行或網上銀行管理帳目,更有銀行裡的專業人士幫你理財。如果說把錢塞到枕頭下面或保險櫃裡類似於我們在單機時代用個人電腦來管理資訊,那麼,把 錢存進銀行就對應於我們在網路時代裡用雲計算來實現資料和應用的共用。

這也就是說,在雲計算的模式中,使用者所需的應用程式並不運行在使用者 的個人電腦、手機等終端設備上,而是運行在互聯網上大規模的伺服器集群中。使用者所處理的資料也並不存儲在本地,而是保存在互聯網上的資料中心裡。提供雲計 算服務的企業負責管理和維護這些資料中心的正常運轉,保證足夠強的計算能力和足夠大的存儲空間可供使用者使用。而用戶只需要在任何時間、任何地點,用任何可 以連接至互聯網的終端設備訪問這些服務即可。事實上,Google 提供的網路搜索功能本身,就是一種典型的雲計算。其他 Google 服務,諸如 Gmail,Google Docs,Google Picasa Web 等等,無不充分體現了雲計算的強大力量。

和傳統的單機或網路應用模式相比,雲計算有四個非常顯著的特點。

首 先,雲計算提供了最可靠、最安全的資料存儲中心,使用者不用再擔心資料丟失、病毒入侵等麻煩。很多人覺得資料只有保存在自己看得見、摸得著的電腦裡才最安 全,其實不然。你的電腦可能會因為自己不小心而被損壞,或者被病毒攻擊,導致硬碟上的資料無法恢復,而有機會接觸你的電腦的不法之徒則可能利用各種機會竊 取你的資料。此前轟動一時的“豔照門”事件據報導不也是因為電腦送修而造成個人資料外泄的嗎?反之,當你的文檔保存在類似 Google Docs 的網路服務上,當你把自己的照片上傳到類似 Google Picasa Web 的網路相冊裡,你就再也不用擔心資料的丟失或損壞。因為在“雲”的另一端,有全世界最專業的團隊來幫你管理資訊,有全世界最先進的資料中心來幫你保存數 據。同時,嚴格的許可權管理策略可以幫助你放心地與你指定的人共用資料。這樣,你不用花錢就可以享受到最好、最安全的服務,甚至比在銀行裡存錢還方便。

其 次,雲計算對使用者端的設備要求最低,使用起來也最方便。大家都有過維護個人電腦上種類繁多的應用軟體的經歷。為了使用某個最新的作業系統,或使用某個軟體 的最新版本,我們必須不斷升級自己的電腦硬體。為了打開朋友發來的某種格式的文檔,我們不得不瘋狂尋找並下載某個應用軟體。為了防止在下載時引入病毒,我 們不得不反復安裝殺毒和防火牆軟體。所有這些麻煩事加在一起,對於一個剛剛接觸電腦,剛剛接觸網絡的新手來說不啻一場噩夢!如果你再也無法忍受這樣的電 腦使用體驗,雲計算也許是你的最好選擇。你只要有一台可以上網的電腦,有一個你喜歡的流覽器,你要做的就是在流覽器中鍵入 URL ,然後盡情享受雲計算帶給你的無限樂趣。你可以在流覽器中直接編輯存儲在“雲”的另一端的文檔,你可以隨時與朋友分享資訊,再也不用擔心你的軟體是否是最 新版本,再也不用為軟體或文檔染上病毒而發愁。因為在“雲”的另一端,有專業的 IT 人員幫你維護硬體,幫你安裝和升級軟體,幫你防範病毒和各類網路攻擊,幫你做你以前在個人電腦上所做的一切。

此外,雲計算可以輕鬆實現不 同設備間的資料與應用共用。大家不妨回想一下,你自己的連絡人資訊是如何保存的。一個最常見的情形是,你的手機裡存儲了幾百個連絡人的電話號碼,你的個人 電腦或筆記型電腦裡則存儲了幾百個電子郵寄地址。為了方便在出差時發郵件,你不得不在個人電腦和筆記型電腦之間定期同步連絡人資訊。買了新的手機後,你不 得不在舊手機和新手機之間同步電話號碼。對了,還有你的 PDA 以及你辦公室裡的電腦。考慮到不同設備的資料同步方法種類繁多,操作複雜,要在這許多不同的設備之間保存和維護最新的一份連絡人資訊,你必須為此付出難以 計數的時間和精力。這時,你需要用雲計算來讓一切都變得更簡單。在雲計算的網路應用模式中,資料只有一份,保存在“雲”的另一端,你的所有電子設備只需要 連接互聯網,就可以同時訪問和使用同一份資料。仍然以連絡人資訊的管理為例,當你使用網路服務來管理所有連絡人的資訊後,你可以在任何地方用任何一台電腦 找到某個朋友的電子郵寄地址,可以在任何一部手機上直接撥通朋友的電話號碼,也可以把某個連絡人的電子名片快速分享給好幾個朋友。當然,這一切都是在嚴格 的安全管理機制下進行的,只有對資料擁有存取權限的人,才可以使用或與他人分享這份資料。

最後,雲計算為我們使用網路提供了幾乎無限多的 可能,為存儲和管理資料提供了幾乎無限多的空間,也為我們完成各類應用提供了幾乎無限強大的計算能力。想像一下,當你駕車出遊的時候,只要用手機連入網 絡,就可以直接看到自己所在地區的衛星地圖和即時的交通狀況,可以快速查詢自己預設的行車路線,可以請網路上的好友推薦附近最好的景區和餐館,可以快速預 訂目的地的賓館,還可以把自己剛剛拍攝的照片或視訊短片分享給遠方的親友……離開了雲計算,單單使用個人電腦或手機上的用戶端應用,我們是無法享受這些便 捷的。個人電腦或其他電子設備不可能提供無限量的存儲空間和計算能力,但在“雲”的另一端,由數千台、數萬台甚至更多伺服器組成的龐大的集群卻可以輕易地 做到這一點。個人和單個設備的能力是有限的,但雲計算的潛力卻幾乎是無限的。當你把最常用的資料和最重要的功能都放在“雲”上時,我們相信,你對電腦、應 用軟體乃至網路的認識會有翻天覆地的變化,你的生活也會因此而改變。

互聯網的精神實質是自由、平等和分享。作為一種最能體現互聯網精神的計算模型,雲計算必將在不遠的將來展示出強大的生命力,並將從多個方面改變我們的工作和生活。無論是普通網路使用者,還是企業員工,無論是IT管理者,還是軟體發展人員,他們都能親身體驗到這種改變。

如 果你是一名普通用戶,那麼,不妨和我們一起想像一下這樣的應用場景:為了準備週末的 Party,你在個人電腦上連接 Google Docs ,寫出被邀請人的名單,需要採購的物品等專案,然後直接將文檔共用給你的朋友,讓他們幫你參謀一下。你的朋友可以一邊與你線上聊天,一邊編輯文檔,直到你 們都滿意為止。然後,你用 Google Calendar 標出舉辦 Party 的時間地點,並直接將邀請發送到所有被邀請人的 Gmail 信箱中,其中還可以附上 Google Maps 繪製的行車路線圖。開 Party 當天,你和朋友們當然不會忘了用手機拍下照片和視頻作為美好回憶。這時,你可以直接將照片或視頻上傳到 Google Picasa Web 或 YouTube 網站上,讓更多的朋友分享美好時光……這一切,都只需要在流覽器中完成,所有資料都存儲在“雲”中,諸如文檔編輯、排程、照片處理等操作都由“雲”中 擁有強大計算能力的伺服器集群負責,作為普通用戶,你只需要盡情享受“雲中漫步”的浪漫與愜意。

在辦公室裡辛勤工作的白領們同樣可以體驗 到雲計算的樂趣。以往,如果用個人電腦上的電子演示文稿軟體來編輯一份有關市場行銷的幻燈片,在完成初稿後,你多半需要將存儲在電腦裡的幻燈片作為電子郵 件附件,發送給同事一起修改。每個同事可能都會在一份該幻燈片的獨立拷貝上單獨工作,然後再將修改後的結果匯總給你。這時,你需要同時打開若干份修改過的 幻燈片,然後小心翼翼地將每位同事的每一處修改合併到主文件中。這種類似手工勞動的方式效率低下,不容易理清楚文檔的版本演變過程,如果再加上經理審批等 流程,整個幻燈片編輯過程多半會讓你痛苦不堪。現在,你只要切換到雲計算的工作方式,利用類似 Google Docs 的線上文檔編輯工具,無論是幻燈片的編輯、分享、批註、審閱,還是版本或修訂管理,都可以在流覽器中輕鬆搞定。編輯和共用投影片就像上網流覽一樣簡單。更 加方便的是,在雲計算的説明下,傳統的幻燈片檔現在變成了一個簡單的 URL ,你在出差時甚至可以不用攜帶自己的筆記型電腦。到了演講現場,只要在任何一台電腦上通過流覽器連接該 URL ,幻燈片就會出現在聽眾面前。

企 業中的 IT 管理人員可能會更加感激雲計算為他們帶來的方便之處。對於每一位 IT 管理人員而言,搭建並長期維護企業的網站、電子郵件系統、排程系統、文檔共用系統都不是一件非常輕鬆的事情。現在,有了雲計算的平臺,IT 管理人員可以將這些繁雜的勞動都“外包”給雲計算服務的提供商。比如,利用 Google Sites 搭建網站,利用 Gmail 提供企業郵件服務,利用 Google Calendar 管理日程資訊,利用 Google Docs 分享企業內部文檔。IT 管理人員再也不用操心如何搭建和維護伺服器環境,如何採購和升級系統軟體、應用軟體乃至殺毒軟體,如何防範駭客入侵……無論是資料服務還是應用計算,一切 都從網路上直接獲得。這就像我們使用水和電一樣,終端使用者只需要打開開關或龍頭,就可以獲得並享受服務,而擁有龐大資源的電廠和自來水廠則負責在“雲”的 另一端提供最專業的生產和維護。一切都變得那麼簡單和自然,因為你的企業已經與“雲”相連。

對於軟體發展人員或電腦科學專業的學生來 說,雲計算的影響力可能更為深遠。此前,一個學生要成為合格的工程師,需要學習如何編寫程式,使其在一台電腦上運行以完成某個特定的任務。現在,為了更 充分地發揮雲計算的特長,大多數工程師都應該掌握分散式運算的基本原理和開發方法,有能力掌握用於分散式運算的協定或語言,開發出可以運行在幾百台、幾千 台甚至幾萬台電腦上的應用程式,並用該程式管理分佈在不同資料中心的海量存放裝置。也就是說,如果傳統的軟體工程師是和一台電腦以及有限的存儲容量一 起工作的話,雲計算時代的工程師就應該儘快適應與數量無法預期,存儲容量同樣無法預期的電腦集群一同工作。在這方面, Google 研發的 GFS(分散式檔案系統)、MapReduce(分散式運算系統)以及 BigTable(分散式存儲系統)起到了引領技術浪潮的作用,以這些系統為代表的分散式處理模型已經成為了軟體發展領域最先進也最具活力的技術。

雲 計算是在網路時代應運而生的技術制高點。只要把握住雲計算的脈搏,就能在網路時代看得更遠。希望中國電腦科學或相關專業的學生,以及廣大的軟體發展者能 更加透徹地認識雲計算,利用雲計算,開發出更新、更好的網路應用。希望廣大的企業用戶和個人用戶能親身體驗雲計算的優點,並在體驗的過程中熱愛雲計算,擁 抱雲計算。

在網路時代,每一次重大的技術變革都預示著互聯網產業格局未來的演變,至少也會促成主流網路企業的重新洗牌。中國互聯網產業經 曆過許多機會,也錯失過許多機會。也許,有戰略眼光的人可以在雲計算的興起過程中看到佔領市場制高點的絕佳時機。也許,更早擁抱雲計算的互聯網企業可以讓 使用者擁有不同尋常的網路應用體驗,並借此在市場上奪得先機。

雲計算是一幅美麗的圖景,雲計算是我們身邊正在發生的變革。雲計算可以讓互聯網用戶更加輕鬆和快樂,可以讓企業更好地運行,讓工程師更多地發揮潛力,讓中國公司和工程師有機會進入全球大舞臺。還等什麼?讓我們一起來迎接雲計算時代的到來,體驗“雲中漫步”的樂趣!

http://googlechinablog.com/2008/05/blog-post_09.html

Windows 2008 Server 停用密碼複雜度

若已建立AD則無法使用此功能(2003可以),AD預設會啟用此功能,但未建立AD則可用;不知有什麼方法是可行的。

Start→Run→gpedit.msc→Computer Configuration→Windows Settings→Security Settings→Password Policy→Password must mett complexity requirements→Disable

安裝Windows Server 2008

Windows Server 的設計是越來越嚴謹了,在 Windows Server 2008 預設就會開啟密碼複雜性原則:
  1. 密碼長度至少為 6
  2. 至少包含下列 4 種字元類型中的 3 種:
    • 大寫英文字(A ~ Z)
    • 小寫英文字(a ~ z)
    • 數字(0 ~ 9)
    • 特殊字元 (例如: !、$、#、% 等)
  3. 不能包含使用者帳號的某一部分字元(超過 2 個字元)

2009年10月25日 星期日

Open Flash Chart

對於折線圖,只需要給予XY軸序列 <OBJECT id=BuyingTrendOfc classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=720 height="100%"><PARAM NAME="_cx" VALUE="5080"><PARAM NAME="_cy" VALUE="5080"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="/ibank/html/javascript/js/util/openFlashChart/open-flash-chart.swf"><PARAM NAME="Src" VALUE="/ibank/html/javascript/js/util/openFlashChart/open-flash-chart.swf"><PARAM NAME="WMode" VALUE="Window"><PARAM NAME="Play" VALUE="0"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE="LT"><PARAM NAME="Menu" VALUE="-1"><PARAM NAME="Base" VALUE=""><PARAM NAME="AllowScriptAccess" VALUE="always"><PARAM NAME="Scale" VALUE="NoScale"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE="FFFFFF"><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="AllowNetworking" VALUE="all"><PARAM NAME="AllowFullScreen" VALUE="false"></OBJECT></DIV> <SCRIPT type=text/javascript> var x = new SWFObject("/ibank/html/javascript/js/util/openFlashChart/open-flash-chart.swf","BuyingTrendOfc","720px","100%","9","#FFFFFF"); x.addParam("quality","high"); x.addParam("allowScriptAccess","always"); x.addVariable("variables","true"); x.addVariable("bg_colour","#FFFFD7"); x.addVariable("x_axis_colour","#C77DAA"); x.addVariable("x_grid_colour","#F0F0F0"); x.addVariable("y_axis_colour","#C77DAA"); x.addVariable("y_grid_colour","#F0F0F0"); x.addVariable("inner_background","#FFFFDD,#FFFFDD,90"); x.addVariable("num_decimals","4"); x.addVariable("is_fixed_num_decimals_forced","true"); x.addVariable("y_ticks","5,8,10"); x.addVariable("x_label_style","9,#303030,1"); x.addVariable("x_legend","DATE,12,#736AFF"); x.addVariable("y_legend","RATE,12,#736AFF"); x.addVariable("y_label_size","9"); x.addVariable("x_axis_steps","1"); x.addVariable("y_axis_steps","1"); x.addVariable("line","3,#FC7298,紐西蘭幣(NZD),12,0"); x.addVariable("values","22.4757,22.2819,22.4484,22.3486,22.2883,22.0687,22.1735,22.3106,22.6414,22.6813,22.6126,22.4877,22.8178,22.6708,22.6967,23.0123,22.9627,22.9244,22.6673,23.2632,23.3329,23.2893,23.1995,23.0162,23.0634,23.0792,23.1544,22.9107,23.0539,23.5050,23.6104,23.6161,23.6274,23.5248,23.6931,23.8077,23.8832,23.8418,24.0313,24.1822,24.2129,24.2503,24.3686"); x.addVariable("x_labels","98/08/26,98/08/27,98/08/28,98/08/31,98/09/01,98/09/02,98/09/03,98/09/04,98/09/07,98/09/08,98/09/09,98/09/10,98/09/11,98/09/14,98/09/15,98/09/16,98/09/17,98/09/18,98/09/21,98/09/22,98/09/23,98/09/24,98/09/25,98/09/28,98/09/29,98/09/30,98/10/01,98/10/02,98/10/05,98/10/06,98/10/07,98/10/08,98/10/09,98/10/12,98/10/13,98/10/14,98/10/15,98/10/16,98/10/19,98/10/20,98/10/21,98/10/22,98/10/23"); x.addVariable("y_min","22.0687"); x.addVariable("y_max","24.3686"); x.addVariable("tool_tip","#x_label#<br>#key# #val#"); x.write("BuyingTrendChart"); </SCRIPT> http://teethgrinder.co.uk/open-flash-chart/

2009年10月2日 星期五

Using regular expression in MSSQL/TSQL

User Define Function:
CREATE FUNCTION dbo.find_regular_expression
(
@source varchar(5000),
@regexp varchar(1000),
@ignorecase bit = 0
)
RETURNS bit
AS
BEGIN
DECLARE @hr integer
DECLARE @objRegExp integer
DECLARE @objMatches integer
DECLARE @objMatch integer
DECLARE @count integer
DECLARE @results bit

EXEC @hr = sp_OACreate 'VBScript.RegExp', @objRegExp OUTPUT
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
EXEC @hr = sp_OASetProperty @objRegExp, 'Pattern', @regexp
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
EXEC @hr = sp_OASetProperty @objRegExp, 'Global', false
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
EXEC @hr = sp_OASetProperty @objRegExp, 'IgnoreCase', @ignorecase
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
EXEC @hr = sp_OAMethod @objRegExp, 'Test', @results OUTPUT, @source
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
EXEC @hr = sp_OADestroy @objRegExp
IF @hr <> 0 BEGIN
SET @results = 0
RETURN @results
END
RETURN @results
END

2009年9月29日 星期二

Config the GuestOS's resolution in the VMware

To automatically fit the host os's resolution at full screen mode: the vxm file to add the entries: svga.maxWidth = "1280" svga.maxHeight = "800"

2009年9月28日 星期一

Sorting maps in Java based on it’s values

public class MapValueSort {

/** inner class to do soring of the map **/
private static class ValueComparer implements Comparator {
private Map  _data = null;
public ValueComparer (Map data){
super();
_data = data;
}

    public int compare(Object o1, Object o2) {
     String e1 = (String) _data.get(o1);
        String e2 = (String) _data.get(o2);
        return e1.compareTo(e2);
    }
}

public static void main(String[] args){

Map unsortedData = new HashMap();
unsortedData.put("2", "DEF");
unsortedData.put("1", "ABC");
unsortedData.put("4", "ZXY");
unsortedData.put("3", "BCD");

SortedMap sortedData = new TreeMap(new MapValueSort.ValueComparer(unsortedData));

printMap(unsortedData);

sortedData.putAll(unsortedData);
System.out.println();
printMap(sortedData);
}

private static void printMap(Map data) {
for (Iterator iter = data.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
System.out.println("Value/key:"+data.get(key)+"/"+key);
}
}

}

This should output something of the lines of:

Value/key:BCD/3
Value/key:DEF/2
Value/key:ZXY/4
Value/key:ABC/1

Value/key:ABC/1
Value/key:BCD/3
Value/key:DEF/2
Value/key:ZXY/4

Where the bottom last four lines obviously is sorted on the map’s values and not it’s keys.

Ref: http://paaloliver.wordpress.com/2006/01/24/sorting-maps-in-java/ by paaloliver

jQuery Floating Layer Plugin

It can fix one layer(div) at the fixed position on the page.
https://nettuts.s3.amazonaws.com/018_Floating_Menu/demo/dhtml_float_menu_final_nettut.html
http://www.phpletter.com/Demo/Jquery-Floating-Box-Plugin/

2009年9月23日 星期三

C# 中的Map: Dictionary 的使用

We can use the statement, DicObj[keyObj] = valObject, to set/get the value corresponding to the key.
using System;
using System.Collections.Generic;

public class Example
{
public static void Main()
{
  // Create a new dictionary of strings, with string keys.
  //
  Dictionary<string, string> openWith =
      new Dictionary<string, string>();

  // Add some elements to the dictionary. There are no 
  // duplicate keys, but some of the values are duplicates.
  openWith.Add("txt", "notepad.exe");
  openWith.Add("bmp", "paint.exe");
  openWith.Add("dib", "paint.exe");
  openWith.Add("rtf", "wordpad.exe");

  // The Add method throws an exception if the new key is 
  // already in the dictionary.
  try
  {
      openWith.Add("txt", "winword.exe");
  }
  catch (ArgumentException)
  {
      Console.WriteLine("An element with Key = \"txt\" already exists.");
  }

  // The Item property is another name for the indexer, so you 
  // can omit its name when accessing elements. 
  Console.WriteLine("For key = \"rtf\", value = {0}.",
      openWith["rtf"]);

  // The indexer can be used to change the value associated
  // with a key.
  openWith["rtf"] = "winword.exe";
  Console.WriteLine("For key = \"rtf\", value = {0}.",
      openWith["rtf"]);

  // If a key does not exist, setting the indexer for that key
  // adds a new key/value pair.
  openWith["doc"] = "winword.exe";

  // The indexer throws an exception if the requested key is
  // not in the dictionary.
  try
  {
      Console.WriteLine("For key = \"tif\", value = {0}.",
          openWith["tif"]);
  }
  catch (KeyNotFoundException)
  {
      Console.WriteLine("Key = \"tif\" is not found.");
  }

  // When a program often has to try keys that turn out not to
  // be in the dictionary, TryGetValue can be a more efficient 
  // way to retrieve values.
  string value = "";
  if (openWith.TryGetValue("tif", out value))
  {
      Console.WriteLine("For key = \"tif\", value = {0}.", value);
  }
  else
  {
      Console.WriteLine("Key = \"tif\" is not found.");
  }

  // ContainsKey can be used to test keys before inserting 
  // them.
  if (!openWith.ContainsKey("ht"))
  {
      openWith.Add("ht", "hypertrm.exe");
      Console.WriteLine("Value added for key = \"ht\": {0}",
          openWith["ht"]);
  }

  // When you use foreach to enumerate dictionary elements,
  // the elements are retrieved as KeyValuePair objects.
  Console.WriteLine();
  foreach( KeyValuePair<string, string> kvp in openWith )
  {
      Console.WriteLine("Key = {0}, Value = {1}",
          kvp.Key, kvp.Value);
  }

  // To get the values alone, use the Values property.
  Dictionary<string, string>.ValueCollection valueColl =
      openWith.Values;

  // The elements of the ValueCollection are strongly typed
  // with the type that was specified for dictionary values.
  Console.WriteLine();
  foreach( string s in valueColl )
  {
      Console.WriteLine("Value = {0}", s);
  }

  // To get the keys alone, use the Keys property.
  Dictionary<string, string>.KeyCollection keyColl =
      openWith.Keys;

  // The elements of the KeyCollection are strongly typed
  // with the type that was specified for dictionary keys.
  Console.WriteLine();
  foreach( string s in keyColl )
  {
      Console.WriteLine("Key = {0}", s);
  }

  // Use the Remove method to remove a key/value pair.
  Console.WriteLine("\nRemove(\"doc\")");
  openWith.Remove("doc");

  if (!openWith.ContainsKey("doc"))
  {
      Console.WriteLine("Key \"doc\" is not found.");
  }
}
}

/* This code example produces the following output:

An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Key = "tif" is not found.
Key = "tif" is not found.
Value added for key = "ht": hypertrm.exe

Key = txt, Value = notepad.exe
Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = rtf, Value = winword.exe
Key = doc, Value = winword.exe
Key = ht, Value = hypertrm.exe

Value = notepad.exe
Value = paint.exe
Value = paint.exe
Value = winword.exe
Value = winword.exe
Value = hypertrm.exe

Key = txt
Key = bmp
Key = dib
Key = rtf
Key = doc
Key = ht

Remove("doc")
Key "doc" is not found.
*/

2009年9月8日 星期二

Barcode Image Generation Library

It's the best solution without font supporting and free. Using the ashx, we can take various methods to generate / draw the barcode bitmap. In this library, barcode is drawed as thin line. In the other library, Code39, barcode is drawed as a little fat hence it's blurred while we print it out.

Code 39 barcodes in C#

A class to generate Barcode39 without font supporting.

An ASP.NET .ashx HTTP handler for Code 39 barcode generation

It's convenient. Using the C#.NET 2.0

http://www.codeproject.com/KB/aspnet/AspBarCodes.aspx

Barcodes in ASP.NET applications

It does not work!!

Advanced Barcode Generation System for Code 39 Standards

2009年9月4日 星期五

jQuery Time Entry

jQuery Timers

Google Map Cursor

Cursor styles

http://www.worldtimzone.com/mozilla/testcase/css3cursors.html

Supported Browser:

http://www.quirksmode.org/css/cursor.html

usage: {cursor: url(../images/openhand.cur), move;}

http://www.google.com/intl/zh-CN_ALL/mapfiles/openhand.cur http://www.google.com/intl/zh-CN_ALL/mapfiles/closedhand.cur

2009年8月31日 星期一

JQuery Color Animation

It allows to use the color description 'backgroundColor' instead of css description

2009年8月21日 星期五

JQuery Selector

jquery 提供一個很 fancy selector幫助我們很容易的找到要控制的 dom 元件。例如:當我相找出 nextSign… 開頭的欄位時,過去作法需要把 form1 下所有elements找出再走訪每個element,判斷名稱才能找出。

<form name=”form1”>

<input type=”text” name=”nextSignEmpNo” value=””>

<input type=”text” name=”nextSignDeptNo” value=””>

<input type=”text” name=”docNo” value=””>

</form>

<script>

for(var i=0;i<form1.elements.length; i++) {

  if ( form1.elements(i).name.indexOf(”nextSign”)==0) {

        alert( form1.elements(i).value );

  }

}

</script>

jquery 做法:

$(“input[name^=’nextSign’]).each(function(){

  alert( $(this).val() );

})

$(“input[name^=’nextSign’]) 是指所有inputname只要是 nextSign 開頭的都抓出來,若然有1form以上,並且不同form有相同欄位名稱時,這樣抓可能會出錯,所以需要再把 form考量進來。

$(“form[name=’form1’] input[name^=’nextSign’]).each(function(){

  alert( $(this).val() );

})

jquery selector 有個特色,可以將不同的 selector 組合使用,這樣幾乎沒有找不到的DOM物件。

attribute 抓物件方式還有

[attribute*=value] 只要出現value關鍵字

[attribute$=value] value關鍵字結尾

[attribute!=value] value關鍵字不能出現

像如果要抓出下面這兩個欄位

<input type=”text” name=”nextSignEmpNo_v1” value=””>

<input type=”text” name=”nextSignDeptNo_v1” value=””>

可以用

$(“input[name$=’_v1’]).each(function(){

  alert( $(this).val() );

})

2009年7月24日 星期五

Install and Enable Remote Desktop in Windows XP Home Edition

The Terminal Service is not installed in Windows XP Edition. The trick is the service installing without OS reintsalling.

Convert and Upgrade Windows XP Home to Professional Without Reinstalling

To use Remote Desktop Service (Terminal Service) at Windows XP Home Edition, it's must be changed the edition code. Then install the service.

Tabbed Remote Desktop

A tabbed viewer with RDP(Windows Remote Desktop), VNC, ...etc, like firefox to manager multiple remote desktop simultaneously. Terminals http://www.codeplex.com/Terminals/Release/ProjectReleases.aspx?ReleaseId=21809 http://www.howtogeek.com/howto/windows/tabbed-remote-desktop-vnc-client-for-windows/ XwRDP http://xwega.com/tools/xwrdp/xwrdpimg.aspx

Tabbed Putty

A tabbed viewer like firefox to manager multiple ssh connection simultaneously. Putty Tabs: http://www.raisin.de/putty-tabs/putty-tabs.html Putty Connection Manager: http://www.howtogeek.com/howto/the-geek-blog/get-tabs-for-your-putty/

2009年7月23日 星期四

Top, HTop

How to use “top” effectively on Linux as a DBA http://coskan.wordpress.com/2008/12/22/how-to-use-top-effectivelly-on-linux-as-a-dba/ HTop http://portable.easylife.tw/1513

2009年7月21日 星期二

使用 net use 指令登入及刪除網芳帳號(適用 XP、2003)

net use \\hostname password /USER:domain\username to display list: net use

Retrieving Auto Generated Key from DB

Set oConn.Execute("INSERT INTO yourTable (field1, field2) VALUES ('Hello','World');") Set oRs = oConn.Execute("SELECT @@IDENTITY FROM yourTable") iAutoGeneratedID = oRs(0) ---- Set rs = dbCon.Execute(strSQL) Dim newID newID = rs.Fields("NewID").value

2009年7月20日 星期一

Java: How To Get Auto Increment Values After SQL Insert

// // Insert one row that will generate an AUTO INCREMENT // key in the primary key field // stmt.executeUpdate( "INSERT INTO autoIncTest (comment) " + "values ('How can I get the auto increment field value?')", Statement.RETURN_GENERATED_KEYS); // // Use Statement.getGeneratedKeys() // to retrieve the value(s) //

2009年5月5日 星期二

How to Search Mail in Gmail: search expression

Use the following operators: subject: - Search the Subject line.
Example: "subject:bahamas" finds all messages with "bahamas" in the Subject.
from: - Search for sender name and email address. Partial addresses are okay. Example: "from:heinz" finds all messages from "heinz@about.com", but also all messages from "your.heinz@tqn.com".
to: - Search the To line for names and addresses. Example: "to:quertyuiop@gmail.com" finds all messages sent directly (not via Cc: or Bcc:) to quertyuiop@gmail.com.
cc: - Search recipients in the Cc field. Example: "cc:quertyuiop@gmail.com" finds all messages that were sent to quertyuiop@gmail.com as a carbon copy.
bcc: - Search for addresses and names in the Bcc field. Note this only works with emails you sent to Bcc recipients from Gmail. Example: "bcc:heinz" finds all messages that you sent with, for example, "hein@example.com" in the Bcc field.
label: - Search for messages assigned a label. (Replace whitespace characters in label names with hyphens.) Example: "label:toodoo-doll" finds all messages labeled "toodoo doll". is:starred - Search for messages that are starred. is:unread - Search for new and unread messages. is:read - Search for messages that have already been opened. has:attachment - Search for messages that have files attached to them. filename: - Search within file names of attachments. You can also search for file name extensions to restrict your search to certain file types. Example: "filename:.doc" finds all messages with word processing attachments. lang: - Search for messages in a particular language. (Specify the language in English; "Chinese" works, but "中文", "Putonghua" or "Mandarin" do not, for example.) Example: "lang:French" returns all emails that contain at least un peu de Français.
in: - Search in a standard "folder". You can search in Drafts, Inbox, Chats, Sent, Spam, Trash and All (for everything, including Spam and Trash). Example: "in:drafts" finds all messages in your Drafts folder.
after: - Search for messages sent after a date. The date must given in YYYY/MM/DD format. Example: "after:2005/05/05" finds all messages sent or received after (and not including) May 5, 2005. before: - Search for messages sent before a date. Example: "before:2005/05/05" finds all messages sent or received on May 4, 2005 and earlier. Operators and search terms can be combined with the following modifiers: By default, terms are combined with (an invisible) "AND". Example: "shepherd macaroni" finds all messages that contain both "shepherd" and "macaroni".
"" - Search for a phrase. Case is disregarded. Examples: "shepherd's macaroni" finds all messages containing the phrase "shepherd's macaroni"; 'subject:"shepherd's macaroni' finds all messages that have "shepherd's macaroni" in the Subject field.
OR - Search for messages containing at least one of two terms or expressions. Examples: "shepherd or macaroni" finds messages that contain either "shepherd" or "macaroni" or both; "from:heinz or label:toodoo-doll" finds messages that either come from a sender that contains "email.guide" or appear under the label "toodoo doll".
- - Search for messages that do not contain a term or expression. Examples: "-macaroni" finds all messages that do not contain the word "macaroni"; "shepherd -macaroni" finds all messages that contain the word "shepherd" but not "macaroni"; 'subject:"shepherd's macaroni" -from:heinz' finds all messages with "shepherd's macaroni" in the subject that were not sent from an email address or name containing "heinz".
() - Group search terms or expressions. Examples: "subject:(shepherd macaroni)" finds messages that have both "shepherd" and "macaroni" somewhere in the Subject line (but not necessarily as a phrase); "from:heinz (subject:(shepherd OR macaroni) OR label:toodoo-doll)" finds all messages from a sender who has "email.guide" in their name that either have "shepherd" or "macaroni" (or both) in the Subject line or appear under the label "toodoo doll". ref from http://email.about.com/od/gmailtips/qt/et_find_mail.htm

2009年2月2日 星期一

CSS 清單

http://css.1keydata.com/tw/list.php

JavaScript:Array:splice

改變陣列的內容, 可以在移除舊元素的同時, 加進新的元素. http://summerwxy.blogspot.com/2008/07/javascriptarraysplice.html

Using jQuery for Background Image Animations

Fig. 1 Figure 1 is a little more elaborate. The amount of visible space in the normal and hover states are at the very top and bottom of the image. The large gradient in the middle generates a fade-in/out effect when animated over time. The larger the gradient, the less it'll feel like it's moving in from the bottom and feel more like it's actually fading in and out. Fig. 2 In Figure 2, the before and after states are on the left and right but a simple slant can create an interesting effect. http://snook.ca/archives/javascript/jquery-bg-image-animations/

Move Table Row by Javascript

http://my.opera.com/jlake/blog/2007/06/04/javascript

Table Pager

http://doublekai.org/demo/jquery/tablepager/

2009年1月24日 星期六

Table Drag and Drop JQuery plugin

http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

2009年1月19日 星期一

Mount Samba at Fedora Core 5

mount -t cifs -o unicode,username='clotho',password='',iocharset='utf8',codepage='unicode' '\\140.109.18.190\d$' spdvd/

2009年1月10日 星期六

Control HTML cache

<META HTTP-EQUIV="Cache-Control", CONTENT="no-store, no-cache, must-revalidate">
<META HTTP-EQUIV="Cache-Control", CONTENT="no-Cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

2009年1月7日 星期三

Get Controller's offset values using JQuery

var left = $(obj).offset().left;
var top = $(obj).offset().top;
http://docs.jquery.com/CSS/offset

Drag and Sort

JQueryの公式サイトはUIに関していろんなpluginも提供する。 たどえばマウスについてのエフェクト:Drag, Drop, Sortなど。 書類のサイトはこちら http://docs.jquery.com/UI ダウンロードはこちら http://ui.jquery.com/download ダウンロードのサイトはとてもやさしくて いろんな功能に関して人々のほうしいものによって ライブラリを添ってダウンロードすることができる。 ここで sortableを紹介するわ~ <script>
$(document).ready(function(){
$('#imgList').sortable({stop: idrop, cursor: 'move'});
});
</script>
.
.
<ul id="myList">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
このsortableライブラリのいいところは serializeすることも用意してくれる。 <script>
function serialize(){
alert($('#imgList').sortable('serialize'));
}
</script>
<script>
function idrop(){
var str = '';
var result = $('#imgList').sortable('toArray');
for(var i in result){
str += result[i];
if( i < result.length-1 ) str += ',';
}
document.getElementById('sorted').value = str;
//alert(str);
}
</script>
最後に物件をdragしたりdropしたりした後、stopのpropertyを指定すれば、順番はどうやって変わられたのは分かる。 $('#imgList').sortable({stop: idrop, cursor: 'move'}); こういうpluginはすばらしいと思う、プログラマーにとって使いやすいよ~

2009年1月6日 星期二

2009年1月5日 星期一

Get CheckBox values with ASP Upload

使用了asp upload即無法使用request.form等方法, 必須使用upload.form代替
但是aspupload.form卻沒有跟request.form完全依樣
在於checkbox, select multiple的帶有多值的html control
request.form -> request.form("chk")可以獲得"A, B, C"型式的value
upload.form -> 把同一個name的不同control都是分別獨立的item value
upload.form("chk") = "A"
upload.form("chk") = "B"
upload.form("chk") = "C"
必須使用
for each item in upload.form
  if LCASE(item.name) = "chk" then
    'get value
    item.value
  end if
next
一個非常重要的重點
明明vbscript 是none case-sensitive, 這邊卻要用LCASE才能比對成功!!

網誌存檔