顯示具有 軟體(Software) 標籤的文章。 顯示所有文章
顯示具有 軟體(Software) 標籤的文章。 顯示所有文章

2016年1月14日 星期四

[eID] The short survey of electronic ID cards.

[Chinese]
根據新版台灣國民身分證的新聞報導[1],大部分人會擔心這類措施的相關問題。像是:
  1. 為什麼我們政府要遵循國際民航組織ICAO(International Civil Aviation Organization)的標準呢?
  2. 為什麼機讀碼這麼像中國政府的台胞證形式呢?
我在此做了一些關於電子身分證(electronic ID, eID)的研究:

ICAO的策略目標強烈地與United Nations Sustainable Development Goals (SDGs)做連結,滿足17項中的13項。包含了確保健康的生命、達到性別平等、建立彈性的基礎設施、確保可承受的消耗與產製樣式、降低國與國之間的不平等性等等。[2]
為了達到這些目標,其中的一個解決方案是推動可機讀旅行文件,稱為ICAO Doc 9303.[3]

為什麼ICAO Doc 9303這麼重要?因為它可讓機器容易讀取你的個人資訊,包含姓名、出生日期、出生地與其他欄位。為了保護這些隱私資料,一系列的安全措施也被採用 (請見[3] 的Part 11與Part 12)。

為了建立eID,德國的新版身分證也採用ICAO Doc 9303 [4]。(事實上,它採用其他方案 ISO/IEC standard 14443 [5],但也使用ICAO Doc 9303的部分標準[6])

這就是為何我們政府聲稱eID遵循ICAO的國際規範。

另一個問題:「為什麼機讀碼這麼像中國政府的台胞證形式呢?」
可機讀護照(Machine Readable Passport, MRP)採用可機讀區域(Machine Readable Zone)來讓機器輕易讀取[7][8],這樣的措施也被德國、義大利等國的身分證採用,新式身分證也採用類似的編碼方式。這就是為何新版台胞證有類似的機讀碼。

更多的eID趨勢,可以參見科技新報的報導[9]。

[English]
According to the news of electronic ID card for Taiwanese [1], most of people wonder the problems of this measure. Some problems arises:
  • Why does our government follow the standard of ICAO(International Civil Aviation Organization)?
  • Why is the machine readable code very similar to that of Taiwanese citizen card which China provided?
I make a short survey on the specification of electronic ID card (abbreviate eID).

ICAO's strategic objective strongly linked to 13 of the 17 United Nations Sustainable Development Goals (SDGs) proposed. Those include ensuring healthy lives, achieving gender equality, building resilient infrastructure, ensuring sustainable consumption and production patterns, reducing inequality among countries and so on.[2]
For achieving these goals, one of the solution is to promote Machine Readable Travel Documents, called ICAO Doc 9303.[3]

Why is the ICAO Doc 9303 important? Because it can let machines easily read your personal information including name, birthday, born town and other fields. For protecting the private data, a series of security measures are adopted. (See Parts 11 and 12 in [3].)

For creating eID cards, ICAO Doc 9303 is one of the solution for German new ID card [4]. (Actually, it adopts another solution called ISO/IEC standard 14443 [5] but also uses part of the specification of ICAO Doc 9303 [6]).

That's why our government say that the new ID card can be compatible with international specification - ICAO.

The other question: "Why is the machine readable code very similar to Taiwanese citizen card which China provided?"

The machine readable passport (MRP) should use a machine readable zone (MRZ) to let machine easily read the information [7][8] which is also adopted by multiple eID cards like German, Italian and so on. The Taiwanese citizen card provided by China use the similar encoding method. That's why the new Taiwanese use the MRZ for machines.
As aforementioned, the security is also ensured.
For further trend of eID, please refer to the post of TechNews.[9]

References
  1. 仝澤蓉, "新版身分證樣式曝光 將採中英對照,"  聯合財經網 [Online]. Available:  http://goo.gl/HHKvWx
  2. ICAO, "ICAO and the United Nations Sustainable Development Goals," ICAO [Online]. Available:http://www.icao.int/about-icao/aviation-development/Pages/SDG.aspx
  3. ICAO, "Machine Readable Travel Documents," ICAO [Online] Available: http://www.icao.int/publications/pages/publication.aspx?docnum=9303
  4. Moritz Horsch, Johannes Braun and Alex Wiesmaier, "Mobile eID application for the German identity card," Technische Universität Darmstadt, Technical Report [Online]. Available: https://www.cdc.informatik.tu-darmstadt.de/reports/TR/Mobile_eID_app_for_the_German_ID_card.pdf 
  5. "ISO/IEC 14443," Wikipedia [Online]. Available: https://en.wikipedia.org/wiki/ISO/IEC_14443
  6. "National identity cards in the European Economic Area," Wikipedia [Online]. Available: https://en.wikipedia.org/wiki/National_identity_cards_in_the_European_Economic_Area
  7. "Machine-readable passport," Wikipedia [Online] Available: https://en.wikipedia.org/wiki/Machine-readable_passport#Official_travel_documents 
  8. "可機讀護照," Wikiwand [Online] Available:http://goo.gl/iG87tf
  9. Sanada Yukimura, "台灣新版晶片身分證 2017 年上路? 看全球 eID 趨勢," 科技新報 [Online] Available: http://technews.tw/2015/05/11/taiwan-eid-2007/ 


2015年11月24日 星期二

Solve the problem of Causing IIS Express Slow Down

[Chinese/中文]
最近我的Visual Studio 2013內建的IIS Express 實在跑太慢了,而且常常回報無服務回應的錯誤。根據此條目,看起來像是logger元件出問題。
為了解決此一問題,我們可以嘗試以下步驟:
1. 用系統管理員權限開啟命令提示字元視窗 (cmd console)
2. 輸入以下指令
  (1) cd  %systemroot%\system32\inetsrv\
  (2) appcmd set config /section:urlCompression /doStaticCompression:True
  (3) appcmd set config /section:urlCompression /doDynamicCompression:False
  (4) appcmd set config /section:httpLogging /dontLog:True

[English]
Recently, my Visual Studio 2013's built-in IIS Express runs too slower and it often reports errors about no service response.
According to the thread, it seems logger component of IISExpress broken.
To fix the problem, we can try the following steps:
1. Open a cmd console with Administrator permission.
2. Type the subsequent commands:
  (1) cd  %systemroot%\system32\inetsrv\
  (2) appcmd set config /section:urlCompression /doStaticCompression:True
  (3) appcmd set config /section:urlCompression /doDynamicCompression:False
  (4) appcmd set config /section:httpLogging /dontLog:True

Reference

  1. Mike Volodarsky, "Getting Start with Appcmd.exe", Microsoft Developer Network. URL: http://www.iis.net/learn/get-started/getting-started-with-iis/getting-started-with-appcmdexe
  2. "VS 2013 Professional - Web Dev Server (IIS Express) is very slow", Microsoft Developer Network. URL: https://social.msdn.microsoft.com/Forums/en-US/8e42baa5-38c7-4fef-b120-b0dd22ba8228/vs-2013-professional-web-dev-server-iis-express-is-very-slow?forum=visualstudiogeneral

2014年2月6日 星期四

Lucene中文斷詞

如果要使用Lucene的斷詞程式,最好看一下

1. Lucene介紹投影片 (推薦)

2. Lucene簡介 (推薦)

3. 當前幾個主要的Lucene中文分詞器的比較

4.  Lucene 3.0的中文分詞系統 (推薦)

5. Lucene 最新版4.6.1 內建的Smart中文斷詞 (推薦)

6. IKAnalyzer for Lucene 4.x版本

目前的Lucene斷詞系統都以支援簡體中文為先,如果要用繁體的話,就是用繁體轉簡體的API來製作。

JCC: A Java Chinese Covertor

懶得研究這麼多的話,可以直接使用Solr (基於Lucene實現的一個production)

1. Apache Solr 介紹(有寫說怎麼設定使用Solr斷詞,但還是以簡體字為主)

2013年12月6日 星期五

I-List: Create Your Own Lists of Links

I-List is a very helpful links share platform to share your collected links.

It provides an user friendly interface to you for sharing some kind of links.

I’ve found that there are two collections which is very helpful for some people whose subjects are for studying and implementation in statistics, accounting and computer science.

1. List of Free Accounting Software : For business/accounting area.

2. List of Free Statistical Software : For statistics area.

2013年9月29日 星期日

收穫滿滿的Hadoop Taiwan 2013

此次參加2013 Hadoop Taiwan Conference,收穫很多。(以下是手動隨便寫寫,請勿拘泥writing format)

業界方面的進展比學界又更加跨出一大步,也代表著我們之後如果要發表雲端相關運算的論文或是發展技術,

要特別小心注意這類工具。

由於Big Data時代的來臨,現在的雲端運算處理偏重於「即時」運算,而非「批次」運算。

我們目前所學的hadoop map/reduce只能算是非常基本而已。

對於即時運算的需求恐怕還不太夠(Hive/Pig 也不例外)。

Google先看到這個嚴重情形,繼2009年以來,陸續發表Google Caffeine (for indexing),

可繪製大量網路資訊彼此對應關係的圖表資料庫「Pregel」,

2010年7月發表Google Dremel (for real-time analysis),號稱可完全打敗Hadoop在即時運算處理上的不足。

Google在報告中明確指出,「過去MapReduce需要分多次查詢的資料,Dremel可同時處理,並大幅縮短運算時間」,

因此是為了real-time query而設計的。

此次參加Hadoop Taiwan,聽人家介紹才知道原來有這個強力的project可用。因此,Apache也仿照這個概念,

提出Drill platform.

為了real-time處理夠快,也會導入Message Queue System,例如:

Apache Kafaka: The message queue system for increasing the I/O performance but not provide transmission assurance.

Storm: The real-time message queuing system; but it consume too much more CPU time. (From the HBase initiator said…)

 

而Samza則是結合了Hadoop, Kafaka等技術整合而成的distributed stream processing framework (Hbase起草作者推薦的)。

Data Indexing: NGData project use much more hbase indexing to handle Big data problem.

Log collection for data auditing: Splunk is the recommended free project by Trend Micro.

In memory computing techniques: 柏克萊大學開發Spark/Shark Open Source Project來進行Machine Learning工作,由於所有計算工作都在Memory,號稱比Hadoop快20倍。

Impala:由Cloudra公司發表的Open source軟體,也是用Apache hadoop解即時處理的問題。

Graph Mining Tool : Pegasus

這套是因為資策會資安組跟卡內基美濃大學合作,CMU後來開發這個解決他們在graph-mining問題,

因為他們主要處理節點攻擊與病毒擴散模擬運算。他們資安組真的很強,mining工具用得很熟,

而不是只有寫寫數學式子發論文而已,是真的有拿這些Mining工具去做分群、分類、社群網路分析等。

此外,資安組也提到由於攻擊手法可能會長達每月或是每年才發動一次,

所以Rule based (主要偵測以分或者小時為單位的發動模式)可能無法運作。

註:

1. Google研究團隊及其合作學校(卡內基美濃大學、MIT等每年都到處發表論文,他們發表的論文都公告在 http://research.google.com/index.html

2. 這次來做presentation的廠商:Etu (精誠集團子公司),有真正專門處理Big Data問題的工程師到場,他們上述工具都非常嫻熟,

也提到每一版impala的技術細節,非常厲害。也有發表推薦系統產品,我有詢問他們一些推薦系統實做細節,
不過他們因商業機密,不告訴我就是了…。他們也有現場徵才,不過限制是擁有Hadoop/Linux等相關程式開發經驗2年以上。

2013年6月1日 星期六

淺談專案管理

     
  1. 需求分析(RA, Request Analysis):
  2. 系統分析(SA, System Analysis):
  3. 進行開發前所需的工作:
    1. 確認開發工具:IDE選擇,開發函式庫選擇,使用的程式語言。
    2. 版本控制:Git or SVN? 版本號命名規則?
    3. 程式開發準則:Coding Style、參數訂定
    4. 元件設計解析:Design Pattern
  4. 測試階段:
    1. 測試流程與測試策略訂定:黑箱測試或白箱測試?測試流程?
    2. 測試文件撰寫:測試狀況,是否為Bug?
    3. Bug回報採用Issue Tracker進行管理。
  5. 發布階段:
    1. 安裝包建立(需另外以子專案進行開發、測試):
    2. 防止反組譯工具:
  6. 文件撰寫:
    1. 授權書:GPL、MIT或其他授權
    2. 著作權聲明:
    3. 說明手冊:
  7. 正式釋出!

2013年4月15日 星期一

[Windows] AD Server 使用心得與注意事項

在台灣的中大型企業中,都會建立Windows AD Server來控管電腦使用者並且達到單一登入(Single Sign On)的要求。我最近在學著使用AD Server,因為某些需求,發現它也可以透過GPO來派送與佈署軟體給電腦或是使用者。

若是要我推薦AD Server入門書籍,我推薦「Windows Server 2008(或是2003) Active Directory建置實務」。

但是,在學著使用GPO進行操作時,要特別注意以下事項:

  1. 不要拿你自己的Domain Server兼AD Server來測試剛建立使用者的登入,因為預設的Domain Server 安全性原則是不允許剛建立使用者進行登入的。
  2. 不要拿VMWare的虛擬機器來模擬軟體派送。我曾經因為VMWare把軟體派送擋住,讓我白忙一整天的時間。
  3. 若是要派送msi 安裝檔,並設定該安裝檔為使用者登入時自動安裝。
    請確定該msi installer可以在靜默模式與背景模式下安裝,如果沒辦法登入安裝的話,可以參照以下方法解決。

    若該msi安裝檔是那種有GUI介面的,我們可以透過msiexec 這個指令,將你要安裝的檔案設定為背景模式與進度條模式安裝 。
    也就是直接輸入msiexec /i "你的msi安裝檔路徑" /qn,進行安裝 (msiexec的簡易教學可以看這篇)。

    在知道要怎麼使用msiexec的話,接著我們可以參考這篇GPO原則自動安裝印表機教學文,寫一個簡單的bat script,透過該篇教學,設定使用者登入後,執行你寫好的自動安裝script。

好了,注意事項撰寫完畢。再來推薦一個AD Server派送軟體的教學影片。



2013年4月12日 星期五

[Fixed] Don't make Bug Tracker's online editor convert your links into relative paths.

Bug Tracker is our excellent homemade issue tracker software. However, its TinyMCE editor converts all your links which are made by your host into relative paths.

For example, if your host is http://example.com and you have established your bug tracker on it. Then, you want to add one link e.g. http://example.com/some_information.html to your report in bug tracker. By default, its TinyMCE editor converts your link to be ./some_information.html 

It seems to be okay. But here's one problem: If you use its forwarding email service, it would forward the "converted urls" to the project manager and the project subscribers. Thus, they may confuse with your link which is represented by  http://./some_information.html not http://example.com/some_information.html !

The main cause of this strange phenomena is: "the default setting of its TinyMCE editor is relative_urls = true". To avoid this terrible event, you should follow these steps:
1. Find the files listed below in your Bug Tracker directory:
    (1) ./tinymce/tiny_mce_src.js
    (2) ./tinymce/tiny_mce.js
    (3) ./feedback_site/tinymce/tiny_mce_src.js
    (4) ./feedback_site/tinymce/tiny_mce.js

2. For each file of the above, use your text editor to open it and find the keyword "relative_urls". Then, set the attribute as below:
     _def("relative_urls", false);
3. Make sure you have edited the above four files. Then, enjoy it!

[Important] Be aware of the cache of your browser such as Chrome, Firefox. If you have modified the four .js files, but you also get the same results with relative urls. Try to cleanup the cache of your browser because it has cached your old javascript files for the speed reason.

[Chinese Translation]
Bug Tracker是我們傑出的國產Issue Tracker軟體。然而,它內建的TinyMCE編輯器,會轉換所有來自於你自家網站的連結成為相對路徑。

舉例來說,若你的自家網站為http://example.com,而且你已經在上面自行架設Bug Tracker。然後,你在上面想要發一個帶有連結網址為http://example.com/some_information.html的貼文。預設的情況下,TinyMCE會很貼心地將你的網址轉為./some_information.html。

這看起來很OK。但這有一個問題:當你啟用它內建的轉信服務時,它將轉寄「已轉換過的URL」給你的專案管理人員與訂閱者。因此,他們會對你的貼文感到困惑,因為上面的網址會是http://./some_information.html 而非 http://example.com/some_information.html 。

會造成這個怪現象的主因是「它內建TinyMCE的預設設定值為 relative_urls = true」。為了避免此一現象,請照著以下步驟施行:
1. 找到你的Bug Tracker資料夾下的四個檔案:
    (1) ./tinymce/tiny_mce_src.js
    (2) ./tinymce/tiny_mce.js
    (3) ./feedback_site/tinymce/tiny_mce_src.js
    (4) ./feedback_site/tinymce/tiny_mce.js
2. 依序對上述四個檔案,用文字編輯器打開並尋找relative_urls這個關鍵字,將它的設定值改為以下:
    _def("relative_urls", false);
3. 確定你已經修正完上述四個檔案,那就好好享受它吧!

【重要】請注意你的瀏覽器(Ex. Chrome, Firefox)的快取。若你確定已經修改好這些.js檔案,但還是出現自動轉成相對路徑的情形。請試著清除你的瀏覽器快取,因為它可能為了加速的原因,將你的舊的.js檔案給快取住了。

2013年3月18日 星期一

[Program] The Framework for Auto Updating Programs

I've made up of some frameworks for auto updating program. If you want to make your program with fashion of auto-updating, you can refer to the following table.


Table of Auto Update Program Framework

Name
Tutorials
Platform
License
Dev. Lang.
Click Once
WinFree

.Net Framework
Omaha
WinApache 2.0C/C++
WinSparkle
WinMITC/C++, C#
NETSparkle
WinMITC#
Sparkle
MacMITObject-C/Java
twinkle
N/A
AllLGPLJava

2013年3月16日 星期六

Trend Message Exchange(TME)


Trend Micro System has released its Trend Message Exchange(TME) source code with "Apache License".  If you are interested in this system, you can see the slides for introduction or go to the official web site.

As you see in the architecture, TME provides the features of horizontal scalability and stability. In the past years, if we want to develop this kind of system, we should consider the distributed system design, having to write a lot of codes and do much more testing for the stability reason. But now, we can take an easy way to establish the same kind of system without charge.

Are you anxious for constructing a distributed and scalable message system? Let's enjoy this new technology!  

2013年3月11日 星期一

[.NET] 防止反組譯工具

由於.NET程式為了跨平台,導入CLR(Common Language Run-time),讓所有.NET程式編成MSIL(Microsoft Intermediate Language)程式碼,使其在CLR上運作(簡單來說,就是MS版的JVM)。也正因如此,其編譯出來的程式碼,都有一定的規則可以做逆向工程,進行反組譯。

知名的反組譯工具有:.NET Reflector(要錢), ILSpy (筆者測試過,若程式碼不加以防護的話,用這套很容易把程式碼完全還原回來...) 以及Telerik的JustDecompiler

但是,在販賣軟體產品的開發人員,應該不想要讓自己的程式碼被輕易地破解吧?

就目前讀到的參考資料,可將防止反組譯方法分為以下:
1. 混淆保護(Obfuscating) :將程式碼變數命名或是方法做混淆,或是加入無意義的文字,使其無法輕易破解。
    此類工具較為知名的有微軟合作夥伴PreEmptive推出的Dotfuscastor (Community版本內建於Visual Studio,這個版本不用錢;但是Professional版要錢,此二版本功能差異請見此文章)
    若想要使用此工具進行軟體保護的話,可見以下兩篇教學:
    (1) Dotfucscator 使用者入門
    (2) Obfuscation with Dotfuscator with Visual Studio 2010
2. Kernel等級的加密保護:使其無法用MSIL去讀取。代表工具:MaxToCode
3. 硬體鎖:採用硬體鎖的方式,避免程式盜用。(貌似跟反組譯無關)

參考資料
1. .NET反組譯工具:ILSpy, Telerik JustDecompile
2. 使用SuppressIldasmAttribute防止MSIL反組譯工具對組件進行反組譯
3. [.NET Concept][Security].NET程式保護機制概述 (Recommended)
4. MaxToCode

2013年2月3日 星期日

[PHP] 國人自製的專案管理軟體:Bug Tracker

前幾個月聽從某強者的建議,試了許多專案管理軟體(像是Mantis),但是介面不是很友善。
在看了 保哥的推薦後,從善如流,使用國人王俊斌先生開發的Bug Tracker。
一用下去,發現真的很好用。優點如同保哥網頁推薦的,重點是它的說明超級清楚!這對於不太會使用專案管理軟體的人員,真的是一大福音。

特別的是,你可以搭配GMail,每次一有回報訊息,自動透過GMail發信到使用者信箱做為提醒。
建議各位可以去申請一個GMail信箱,然後利用Bug Tracker管理員進入,按照以下步驟進行設定:

系統設定→郵件通知設定:
勾選使用 Bug Tracker 的寄信函式
SMTP 伺服器:ssl://smtp.gmail.com
SMTP 通訊埠:465
勾選需要身份認證
SMTP 使用者:輸入你的GMail帳號
SMTP 密碼:請輸入你的GMail密碼
密碼確認:再次輸入你的GMail密碼

然後到你的專案管理頁面,選擇寄信通知人(很無奈的,只能轉寄最多6人)。

不過沒關係,可以要求參與該專案的組員,在專案頁面進行訂閱。只要訂閱成功,該專案有任何回報的話,系統都會自動寄信給訂閱人員。

如果擔心申請的GMail信箱有容量上限的規定,造成信箱空間不夠用。沒關係,只要在GMail信箱中設定好過濾規則,只要由Bug Tracker寄出的信件,都自動刪除就可以啦。

不過切記!如果回報頁面沒有指派給任一個使用者的話,系統寄出來的信件,收信人列表是空的,只有自動寄發信件列表中的使用者是採用副本的方式寄信,這樣子容易被某些系統誤認為垃圾信件。

要做資料庫備份的話,也可以參考我寫的這篇:[PHP] MySQL Backup by GMail


2013年1月27日 星期日

[PHP] MySQL Backup by GMail

[Chinese]
        先前已經介紹過有一個好用的MySQL資料庫備份工具(使用PHP):MySQLDump。但是預設的寄信函式,是透過SMTP伺服器寄信,這對於沒有SMTP伺服器的使用者而言,可就傷腦筋了。原先我有找到一篇教學,使用GMail的SMTP伺服器做備份,可惜連結已經失效了。
筆者只好自行撰寫,由於程式碼使用GPL授權,基於分享的精神下,便公開給各位。

        程式碼下載處:請按我。

[English]
I've introduced an useful backup tool for backuping MySQL databases (using PHP): MySQLDump. However,the default send mail function uses the SMTP server to send mails, and it may cause some problems for the users without SMTP servers. Initially, I've found one tutorial for teaching that how to backup MySQL databases by GMail SMTP server, but the link of source code is unavailable. Thus, I rewrite it by myself. Because the project uses GPL license, I share my project with all of you.

The download link: Click Here.

2013年1月7日 星期一

[DB] SQL Server 2005 can not be installed in AMD X3 (X6) platforms.

[Chinese/中文]
    起初,MS SQL Server 2005的開發人員並未考慮到奇數CPU核心的出現,而傻傻的認為所有的CPU核心都一定是偶數個且為2的冪次。但是這樣的天真想法,在AMD X3/X6 CPU出現後,就造成相容性以及無法成功安裝的問題,因為這些CPU都是使用奇數核心。

    SQL Server 2005在Service Pack 2後,可以支援奇數核心。但是,就先前提及的,都無法安裝成功了,哪來的更新可言。

    最直接的解決辦法是修改BIOS。使用者可以直接到BIOS選單,選擇"CPU configuration"->"Clock Calibrating",然後關閉一些核心,讓核心數量維持在2的冪次(也就是說,如果是使用AMD X3 CPU的話,只要關掉第3個核心。若是使用AMD X6,則關閉第5與第6個核心)。在這子調整過後,筆者相信您應該可以享受SQL Server 2005的安裝過程了。

[English]
    Initially, the developers of MS SQL Server 2005 didn't consider the appearance of odd CPU cores and they just thought that all the numbers of CPU cores are even and power of 2. But it resulted in the compatible problem and unsuccessful installation with AMD X3 or X6 CPUs because these CPUs used odd cores.

    The SQL Server 2005 can support odd CPU cores after patching MS SQL Server 2005 Service Pack 2. As the last paragraph mentioned, it can not be installed successfully, so it can not be updated. 
  
    The direct solution is modifying BIOS configuration. You can enter the BIOS menu and select "CPU configuration" -> "Clock Calibrating", then close some cores to maintain the number of cores is powered of 2. (i.e., if you use AMD X3 CPU, you can close the 3rd core. If you use AMD X6 CPU, you can close 5th and 6th cores.) After the adjustment, I believe you can enjoy the installation of SQL Server 2005. 

REFERENCE

2012年7月28日 星期六

[Flash] 摘錄:好用的Falsh開發工具 FlashDevelop

適合程式設計師的Flash開發工具,對於code可以自動補足,不用一個字一個字的打,可以加快撰碼的速度,提高生產力。FlashDevelop是免費的,所以不用買Flash IDE就可以寫Flash程式。
詳細的安裝與使用說明,請參見:Tony's Blog: 好用的Falsh開發工具 FlashDevelop 一文。

2012年4月22日 星期日

[Web Design] 用jQuery Mobile 開發Mobile Web Apps

方才筆者看到了jQuery 的手機版網頁開發:jQuery Mobile
號稱由jQuery 團隊支援的手機版網頁開發APIs,
有著以下特色:


  • 以 jQuery 為核心
  • 檔案極小 (重新製作過的核心壓縮過約80kb,加上css約48kb)
  • 支援HTML 5,且透過 HTML5 data-* tag 來達成種種 UI 的設定
  • 自動切換排版
  • 支援滑鼠與觸碰事件 (Event Driven)
  • WAI-ARIA (參見[4], [5], [6]  )
  • 強大的佈景主題系統
  • ASP.NET MVC 的支援 (特別支援 ASP.Net MVC 4 )
  • 支援市面上大部分行動裝置
  • 畫面一致
  • 多樣化的 UI
  • Progressive Enhancement & Graceful Degradation
讓對於手機程式開發不熟的網站工程師,能夠用既有的Web Design技術,開發Web Apps for Tablet or Smart Phone。
目前jQuery Mobile發展至1.1.0版,支援ToolBar, ListView, Button, Event等功能,有興趣的人可到官網看Demo。

其它相關的Mobile Web App開發libraries 有:
1. PhoneGap (目前版本 1.6.1 )

有興趣的讀者,不妨選擇一套來玩玩看吧。
身為jQuery愛用者的我,當然是選擇jQuery Mobile囉!

參考資料
15. [JS Group] Beginning Phonegap (有關PhoneGap的介紹)

2011年12月27日 星期二

[ASP.NET] MVC 3上,Session消失的問題與解決辦法

筆者因工作因素,不得不碰Microsoft MVC 3。雖然開發方便,不過他隱含的一些奇怪的Bug也不少。
身為一個網站開發人員,時常會用到Cookie與Session。奇怪的點就在於MS Visual Studio 2010在開發MVC 3時,有時候會為了某些奇怪因素,重新啟動你開發的Application。
目前普遍知道的重新啟動事件,可能會於以下情形發生:
  1. 從應用程式的 Bin 資料夾中加入、修改或刪除組件。
  2. 從 App_GlobalResources 或 App_LocalResources 資料夾中加入、修改或刪除當地語系化資源。
  3. 加入、修改或刪除應用程式的 Global.asax 檔。
  4. 在 App_Code 目錄中加入、修改或刪除原始程式碼檔。
  5. 加入、修改或刪除設定檔組態。
  6. 在 App_WebReferences 目錄中加入、修改或刪除 Web 服務參考。
  7. 加入、修改或刪除應用程式的 Web.config 檔。
  8. 防毒軟體剛好掃到Webconfig檔
然而,筆者最近發現兩個更奇怪的重新啟動狀況!
  1. Application restarts on directory delete in ASP.net
  2. 檔案上傳後,在該Action內直接return RedirectToAction() ;
開發MVC 3 or ASP.NET網站人員應該都知道,在SessionState為InProc的設定下,任何重新啟動( or Application_start函數的呼叫),將導致Session消失。
很不巧地,筆者剛好遇到上述第2種狀況,導致Session消失,Debug 10個小時才抓到此嚴重錯誤。
其實上面第 2種狀況,應該算是「 Bin 資料夾中加入、修改或刪除組件」,從下面程式碼便可知一二:
public ActionResult Access()
{
    // 取出剛剛上傳的檔名,這邊會發現取不到值
    string fileName = TempData["upfile"].ToString();
    /*                 
     *   處理的程式區段   
     */               
    return View();
}

[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
    //檢查是否有檔案上傳,有的話存檔
    if (file !=null && file.ContentLength > 0)
    {
        //放在執行檔目錄中Upload目錄底下
        string savedName = "./Upload/" + file.FileName;
        file.SaveAs(savedName);
        TempData["upfile"]=file.FileName;
    }            

    return RedirectToAction("Access");
}
從上述可知,由於我在檔案上傳時,"增加"了bin資料夾下的組件,導致Application_start()函數再次啟動,使得我的Session就這麼消失了。

為了避免這個錯誤一再重演,建議將Session State設定為StateServer或是SQL Server模式。
將Session State設定為State Server的方法,可看這篇「如何讓 ASP.NET 使用 Session 資料時不要再自動消失」,主要兩個步驟:
1. 啟動 aspnet_state.exe (ASP.NET State Service)
2. 在Web.config中,加入以下這段設定:

<configuration>
  <system.web>
    <sessionState mode="StateServer"
      stateConnectionString="tcpip=localhost:42424"
      cookieless="false"
      timeout="20"/>
  </system.web>
</configuration>

需要注意設定的Web.config檔案的出處。(不知道為什麼,筆者的View資料夾下剛好也有Web.config,若手誤設定到這個,執行會錯誤喔!)
為了追求開發出來的程式不因Application重新啟動而造成不穩定狀況 (例如:筆者遇到的檔案上傳導致無法儲存Session的問題,也是透過部署的方式,立刻解決!)。
我們通常會需要用到部署,至於設定部署功能,請跟著筆者這樣子做:
  1. 請先安裝好IIS  6/7
  2. 若是使用ASP.NET 4.0,ASP.NET 4.0的安裝程式,不會連同IIS一起設定,因此,請按照此方法設定。
  3. 從IIS中,設定好網站目錄 or 虛擬目錄。
  4. 設定單鍵發行功能,方法請看如何使用 Visual Studio 2010 的「單鍵發行」功能 (MsDeploy)
另一個可能發生的問題,則是在負載平衡的 Web 伺服陣列環境執行 ASP.NET Web 應用程式時,如果使用 SqlServer 或 StateServer 工作階段模式,工作階段狀態可能會遺失。
解決辦法在微軟的「PRB:如果您使用 SqlServer 或 StateServer 工作階段模式,Web 伺服陣列中的工作階段狀態會遺失」,剛好遇到這類問題的使用者,可以看一看。


Reference
  1. [.NET] ASP.NET 狀態管理(State Management):Session
  2. [ASP.NET] Session 遺失 / Session Timeout / Session 設定
  3. 如何讓 ASP.NET 使用 Session 資料時不要再自動消失
  4. IIS虛擬目錄設定
  5. ASP.NET IIS設定工具
  6. ASP.NET 應用程式生命週期概觀
  7. ASP.NET MVC Request Flow (推薦閱讀!)
  8. ASP.NET MVC 3概觀正體中文版 (推薦閱讀!)

2011年12月25日 星期日

[PHP] 多國語言網站設計

就筆者目前的整理,在設計多國語言網站時,有三種作法。
(1) 採用簡易的PHP專案設計模式,架構如下:

language/
|---> English/about.php
|---> Zh-TW/about.php
這種設計模式,最為簡單明瞭。若要用這種設計模式,可用的library有Wu-Boy設計的php-i18n,該作者寫了兩篇教學文,可以看一看:

  1. PHP 多國語系製作 i18n library 筆記 (一)
  2. PHP 多國語系製作 i18n library 筆記 (二)

(2). 透過PHP gettext套件,實現UTF-8實現多國語言。該套件需要讀取事先定義好的.po檔(.po檔常見的編輯器為GNU POEDITOR),gettext套件的教學文章筆者蒐集了兩篇,有興趣的讀者不妨看一看:

  1. 使用 gettext 來實做 PHP 多國語系支援(I18N)
  2. php gettext方式實現UTF-8國際化多語言(i18n)

(3). 透過新增資料庫欄位的方式,實作多國語言。最簡單的示意教學文在這邊。不過實作時仍有許多方面要考慮就是了。

2011年12月19日 星期一

XMPP

XMPP(Extensible Messaging and Presence Protocol,前稱Jabber)是一種以XML為基礎的開放式即時通訊協定,是經由網際網路工程工作小組(IETF)通過的網際網路標準。XMPP因為被Google Talk應用而被廣大網路使用者所接觸。

想要知道相關資料,請參考:

  1. Wikipedia: XMPP
  2. XMPP初探