星期二, 12月 04, 2007
Intel Go Parallel Videos
http://www.devx.com/go-parallel/Door/36013
Concurrency Learning Curve:
http://www.oreillynet.com/windows/blog/2007/11/concurrency_learning_curve.html
星期六, 10月 06, 2007
使用SQL Server 2005執行遞迴查詢
;WITH MenuCTE(MenuKey, ParentMenuKey, MenuName) AS
(
-- Anchor Query
SELECT MenuKey, ParentMenuKey, MenuName FROM Menu WHERE MenuKey = 1
UNION ALL
-- Recursive Query
SELECT m.MenuKey, m.ParentMenuKey, m.MenuName FROM Menu m INNER JOIN MenuCTE r ON m.ParentMenuKey = r.MenuKey
)
SELECT MenuKey, ParentMenuKey, MenuName FROM MenuCTE
參考資料:http://www.infoq.com/news/2007/10/CTE
星期五, 9月 21, 2007
使用COUNTIF計算符合條件的資料個數
O | ||
X | ||
X個數 | 1 | COUNTIF(B1:B4, "X") |
O個數 | 1 | COUNTIF(B1:B4, "O") |
非X個數 | 3 | COUNTIF(B1:B4, "<>X") |
(錯誤)非X個數 | 4 | COUNTIF(B1:B4, "<> X") |
X或O個數 | 2 | COUNTIF(B1:B4, "O") + COUNTIF(B1:B4, "X") |
星期二, 9月 04, 2007
軟體專案成功率
根據StandishGroup的研究報告, 軟體專案的成功率甚低。
First CHAOS report 1994 16%
"Extreme CHAOS" 2001 28%
Most recent CHAOS 2003 31%
相關文件:
星期六, 8月 11, 2007
AB Split Testing
- 介紹與優缺點分析
- 使用AB Split Testing來測試該使用哪種Adsense格式
- AB TESTING A WEB AD – A CASE STUDY
- AB Testing: Too Little, Too Early?
星期四, 8月 02, 2007
星期三, 8月 01, 2007
星期一, 7月 30, 2007
星期六, 7月 28, 2007
WindowsXP 系統登陸原理及其驗證機制概述
- http://www.dgi.com.tw/polo/Forum/detail.asp?TitleID=20&tid=112&postname=admin
星期五, 7月 27, 2007
常見檔案、目錄操作
- 不錯的整理:http://silenceangelwaitingfor.spaces.live.com/blog/cns!47F284FC052C0DE0!442.entry
- 檢驗帳號是否對某個檔案有NTFS存取權限:
這個問題似乎沒有好的解答
https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1851064&SiteID=1
也許從這篇可以得到解答: http://www.codeproject.com/csharp/accessctrl3.asp?df=100&forumid=180919&exp=0&select=1350552#Accesscheck - 存取檔案、目錄ACL
FileSecurity fSecurity = File.GetAccessControl(@"c:\temp");
fSecurity.AddAccessRule(
new FileSystemAccessRule(
"DomainA/UserB",
FileSystemRights.AppendData | FileSystemRights.CreateFiles,
AccessControlType.Allow)
);
File.SetAccessControl(@"c:\temp", fSecurity); - 設定檔案成ReadOnly
FileInfo f = new FileInfo(@"c:\temp\1.txt");
f.Attributes |= FileAttributes.ReadOnly;
星期日, 7月 22, 2007
在命令列編譯Visual Studio C++專案
devenv MyProject.vcproj /rebuild debug
如果需要參照到額外的include檔案或library檔案,則使用以下格式
devenv MyProject.vcproj /rebuild debug /useenv
同時記得設定INCLUDE以及LIB環境變數
使用VS2005的XML IntelliSense
XML檔案
- 使用適當的xml namespace, 如:
<rootelement xmlns=http://mysite/oo/> - 指定該namespace所對應的XML Schema檔案, 如:
<rootelement
xsi:http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation="http://mysite/oo c:\temp\ooxx.xsd"/>
表示http://mysite/oo這個namespace的Schema描述在ooxx.xsd這個檔案中。
XML Schema檔案
- 指定Target namespace, 如:
<xs:schema
targetNamespace="http://mysite/oo"
xmlns:xs="http://www.w3.org/2001/XMLSchema"> - 增加一些微軟專有的功能
XML Editor Intellisense Features
星期一, 7月 16, 2007
砍掉Process
p.Kill();
p.WaitForExit();
不過在實際使用時,似乎還是有一些process還是沒有砍掉的狀況,需要再進一步地研究。
references:
* http://www.dotnet247.com/247reference/msgs/47/237175.aspx
星期四, 7月 12, 2007
Code Snippet for C++
http://www.microsoft.com/downloads/details.aspx?FamilyID=CD7C6E48-E41B-48E3-881E-A0E6E97F9534&displaylang=en
星期二, 7月 10, 2007
cout << string("str")為何能正確輸出結果
operator<<(const string& str)
之類的function。可見cout << string("str")能夠正確輸出結果依賴的是其他機制。
答案就在basic_string的header中:
basic_ostream<_elem,>& __CLRCALL_OR_CDECL operator<<(
basic_ostream<_elem,>& _Ostr,
const basic_string<_elem,>& _Str)
很棒的LINQ原理說明
LINQ's relationship to the new C#3 and VB9 features
星期日, 7月 08, 2007
取得其他Process的command line arguments
- 在DotNET中使用Process class來取得ProcessStartInfo: 會得到一個空字串
- 使用Windows API (如GetStartupInfo): 只能夠抓到目前Process的command line arguments
- 在DotNET中reference System.Management, 使用WMI
ManagementObjectSearcher query = new ManagementObjectSearcher
("SELECT * FROM Win32_Process WHERE ProcessID=2860");
ManagementObjectCollection queryCollection = query.Get();
foreach (ManagementObject mo in queryCollection)
{
Console.WriteLine("PID [ {0} ] started With commandline - '{1}'",
mo["ProcessID"].ToString(), mo["CommandLine"].ToString());
}
WMI介紹: http://www.csharphelp.com/archives2/archive334.html - 利用CreateRemoteThread來完成: http://win32.mvps.org/processes/remthread.html
- 開啟目標process
- 在目標process中分配兩塊記憶體。一塊存放程式碼,一塊存放資料。
- 複製程式碼到目標process
- 初始化目標process的資料記憶體區塊
- 呼叫CreateRemoteThread()執行先前複製到目標process的程式碼
- 等待remote thread結束
- 將執行結果從目標process的資料區塊複製回來
星期日, 7月 01, 2007
CruiseControl 1.3 Dashboard跑不起來
(在Server本機開啟DashBoard得到以下訊息)
=== Pre-bind state information === LOG: DisplayName = ThoughtWorks.CruiseControl.WebDashboard (Partial) LOG: Appbase = file:///C:/Program Files/CruiseControl.NET/webdashboard LOG: Initial PrivatePath = bin Calling assembly : (Unknown). === LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Post-policy reference: ThoughtWorks.CruiseControl.WebDashboard LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/ccnet/12b02713/c7918020/ThoughtWorks.CruiseControl.WebDashboard.DLL. LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/ccnet/12b02713/c7918020/ThoughtWorks.CruiseControl.WebDashboard/ThoughtWorks.CruiseControl.WebDashboard.DLL. LOG: Attempting download of new URL file:///C:/Program Files/CruiseControl.NET/webdashboard/bin/ThoughtWorks.CruiseControl.WebDashboard.DLL.
解決方法:
因為CruiseControl 1.3已經升級為.NET 2.0,所以必須在IIS上將ccnet改成以.NET 2.0運作
星期四, 6月 21, 2007
星期三, 6月 13, 2007
星期四, 6月 07, 2007
星期三, 6月 06, 2007
星期一, 6月 04, 2007
如何不被 TortoiseSVN 拖慢系統效率 [JeffHung.Blog]
* 如何不被 TortoiseSVN 拖慢系統效率 [JeffHung.Blog]
* Optimize Performance
星期四, 5月 03, 2007
星期三, 5月 02, 2007
C++ destructor與virtual destructor
非virtual destructor
class Base{
public: ~Base(){ cout << "base destructor" << endl; }
};class Derived: public Base{
public: ~Derived(){ cout << "derived constructor" << endl; }
};void main (int argc, _TCHAR* argv[])
{
{
Derived d;
}
cout << "=========" << endl;
Base *b = new Derived;
delete b;
}
執行結果
derived constructor
base destructor
=========
base destructor
virtual destructor
class Base{
public: virtual ~Base(){ cout << "base destructor" << endl; }
};class Derived: public Base{
public: ~Derived(){ cout << "derived constructor" << endl; }
};void main (int argc, _TCHAR* argv[])
{
{
Derived d;
}
cout << "=========" << endl;
Base *b = new Derived;
delete b;
}
執行結果
derived constructor
base destructor
=========
derived constructor
base destructor
星期三, 4月 25, 2007
星期二, 4月 24, 2007
星期一, 4月 23, 2007
星期三, 4月 18, 2007
在DOS Batch File中傳遞任意個數參數
- %0代表目前這個批次檔名
- 傳統上只有%1 ~ %9共九個參數可供使用,NT4之後新增了%*,用來代表包含%1之後的所有參數。
- 參考:http://www.robvanderwoude.com/parameters.html
星期二, 4月 17, 2007
以C#撰寫的Scott Hanselman Tiny OS
- Blog: http://www.hanselman.com/blog/RescuingTheTinyOSInC.aspx
- Tiny OS in C#
- Tiny OS in VB.NET
- PPT Slides on the Tiny OS presented at TechEd Malaysia 20
星期日, 4月 15, 2007
在Visual C++使用內建功能偵測memory leak
- 啟動偵測memory leak :
在任何一個檔案中,如下定義_CRTDBG_MAP_ALLOC並同時引入兩個header
#define _CRTDBG_MAP_ALLOC
#include
#include
在程式最後呼叫 _CrtDumpMemoryLeaks();
或在程式一開頭呼叫 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); - 只要發現memory leak,就算發生leak的原始碼檔案中沒有引入前述header,還是會傾印出該leak訊息
- 似乎只有使用malloc所造成的memory leak才會得到完整的錯誤訊息,如:
c:\temp\testmemoryleakdetection\testmemoryleakdetection.cpp(16) : {106} normal block at 0x003A9FB0, 2 bytes long.
Data: < > CD CD - 在無引入前述header的檔案中發生因new而導致的memory leak,其錯誤訊息如下:
c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1147) : {107} normal block at 0x003A3450, 4 bytes long.
Data: < > CD CD CD CD - 在無引入前述header的檔案中發生因malloc而導致的memory leak,其錯誤訊息如下:
{107} normal block at 0x003A3450, 2 bytes long.
Data: < > CD CD - 在有引入前述header的檔案中發生因new而導致的memory leak,其錯誤訊息如下:
c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1147) : {106} normal block at 0x003A9FB0, 4 bytes long.
Data: < > CD CD CD CD
這樣的訊息似乎沒有什麼作用,因為並沒有明確指出究竟是哪一部份的程式碼造成這個leak。也許有其他方法可以讓用new的錯誤也能產生完整的訊息。
MFC程式碼
- MFC程式碼似乎不需做任何設定,自動就有在debug模式下偵測memory leak的功能。可以產生如下的錯誤訊息:
{126} normal block at 0x003AE548, 4 bytes long.
Data: < > CD CD CD CD - 如果要產生完整的錯誤訊息,必須要在檔案前面加上
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
c:\temp\testmfcmemoryleak\testmfcmemoryleak.cpp(29) : {126} normal block at 0x003AE548, 4 bytes long.
Data: < > CD CD CD CD
星期日, 4月 08, 2007
Douglas Crockford的Javascript教學
投影片: http://yuiblog.com/assets/crockford/javascript.zip
影片
- http://video.yahoo.com/video/play?vid=111593
- http://video.yahoo.com/video/play?vid=111594
- http://video.yahoo.com/video/play?vid=111595
- http://video.yahoo.com/video/play?vid=111596
與C,C++,Java,C#等語言相較,Javascript的特殊之處有
- Javascript是一個Functional Language
- 只有一種浮點數字類別,沒有如int之類等其他數字類別。這個唯一的數字類別是
IEEE-754浮點數標準,其大小為64 bits。 - 雖然只有一種數字類別,但有一種特殊的數字「值」: NaN (Not a Number)。NaN與自己做等於、大於、小於運算的結果都是false。
- 在C中,整數0為false,非0整數則被當成true。在Javascript中,此概念被擴大成:
false, null, undefined, "" (空字串), 0, NaN 都被視為是false,不屬於這些的則都被視為true。 - + 的怪用法: +"42" 會將字串"42"轉換成數字42。這種用法方便是方便,但,會不會太怪了些。
- &&的怪用法,用來避免null reference:
return a &&amp; a.member;
等同於
if (a) {
return a.member;
} else {
return a;
} - 的怪用法,用來設定預設值:
var last = input nr_items;
上式在input為falsy value時,會指定nr_items給last。 - break到指定的階層(label)
loop: for (;;) {
...
if (...) {
break loop;
}
...
} - 有類似C#中foreach的描述,但有點怪怪的
for (var name in object) {
if (object.hasOwnProperty(name)) {
// within the loop,
// name is the key of current member
// object[name] is the current value
}
}
注意/建議事項
- 使用parseInt將字串轉換成數字時,最好使用有兩個參數的版本,明確指定字串所表達數字是幾進位的。否則的話會出現 parseInt("08") ==> 0,只有parseInt("08", 10)能正確轉換成8。
星期二, 4月 03, 2007
軟工大師Grady Booch
- Software Engineering Radio 專訪
- BCS/IET Turing Lecture Sides
- 關於軟體開發我們目前所知的原則有
基本原則:
* Craft crisp and resilient abstractions: 建立小而有彈性的抽象層
* Maintain a good separation of concerns: 適當的耦合
* Create a balance distribution of responsibilities: 平均分攤責任到各元件或模組
開發流程原則:
Grow a system’s architecture through the incremental and iterative release of testable executables
Peter Chen (陳品山) 與 ER Model
- http://bit.csc.lsu.edu/~chen/chen.html
台灣大學畢業 - Channel 9 Peter Chen的podcast:
Dr. Peter Chen on the Entity Relationship Model and ADO.NET Entity Framework
星期一, 4月 02, 2007
vc++ strncpy_s
const char* source = "0123456789abc";
//strncpy_s(buf, 10, source, 10); // 執行時會發生錯誤,因為Buffer 10太小,應該要有11才能夠放下之後的null
//strncpy_s(buf, 11, source, 10); // 會發生runtime check failure,因為已經11超過buf的大小10
strncpy_s(buf, 10, source, 9); // 012345678 會正確填入
星期六, 3月 24, 2007
星期日, 3月 11, 2007
星期四, 3月 08, 2007
星期五, 3月 02, 2007
星期三, 2月 28, 2007
Test Double
在Martin Fowler的網站上看到一篇文章,題中提到一些人對於Mock或Stub之類的物件有著各式各樣的說明。Gerard Meszaros試圖替這些相關的用詞訂出明確的定義,Gerard將這些類似用途的物件統稱為Double,然後又分成以下四類:
- Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
- Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an InMemoryDatabase is a good example).
- Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'.
- Mocks are pre-programmed with expectations which form a specification of the calls they are expected to receive. They can throw an exception if they receive a call they don't expect and are checked during verification to ensure they got all the calls they were expecting.
星期一, 2月 26, 2007
沒有NULL Iterator
參考資料:
- http://www.mip.ups-tlse.fr/~grundman/stl-tutorial/tutorial.html
Why doesn't STL have null iterator values? STL iterators are supposed to be generalized pointers, right? That phrase has been bandied about a great deal, but it is very misleading. STL iterators are generalizations of array pointers, that is, a pointer set to point into an array, and then incremented or decremented. It does not make sense to talk about such a pointer having a null value.
In C and C++, null pointers are used to indicate errors, or abnormal conditions. When you have a C++ iterator type, there is normally only one kind of error value it will return: one indicating "I fell off the end of the list". It is natural, therefore, for most iterator classes to use null as the "past-the-end" value. If you find yourself wanting a null STL iterator, you probably want the past-the-end value.
星期二, 2月 20, 2007
Agile之後是什麼
- What comes after usability: http://headrush.typepad.com/creating_passionate_users/2007/01/what_comes_afte.html
- Flow theory: http://www.jenovachen.com/flowingames/flowtheory.htm
Google, 微軟, Yahoo的人才培養
某人在這三大龍頭的工讀經驗: http://tastyresearch.wordpress.com/work-stories/
Google Summer of Code: http://code.google.com/soc/
- Google預計於今年(2007)舉辦第三屆GSoC。由一堆公司擔任指導者來指導加入GSoC的學生。指導者與學生都必須要提出相關計畫報告。GSoC為期約三個月,若每個評鑑點都通過評鑑,則指導者與學生都能獲得完整的薪資,否則就只能得到部分薪資。
星期一, 2月 19, 2007
Selenium Remote Control初體驗
- 問題一: 連不上Selenium Server
原本以為是被防火牆擋住了,弄了半天都沒辦法解決。後來才發現是VPN搞的鬼,關掉VPN就可以正常連線了。 - 問題二: 無法下達type指令
一直無法成功鍵入"cmd=type&1=question&2=This is a test&sessionId=1234"指令,總是回傳exception。開啟Selenium在瀏覽器端的log視窗也看不出什麼端倪。最後才發現原來是我耍白爛,在我所測試的網頁中,id question的控制項其實是個combo box,而我想測試的text box的id其實是txtquestion。因此只要將指令改成"cmd=type&1=txtquestion&2=This is a test&sessionId=1234"即可正常執行。 - 問題三: 無法利用type指令送出中文
直接送入中文, 如"cmd=type&1=txtquestion&2=馬英九", 會在瀏覽器端看到亂碼。如果將"馬英九"在utf8下編碼成url的%編碼 (%e9%a6%ac%e8%8b%b1%e4%b9%9d),就能在瀏覽器端正常收到"馬英九"三個字
星期日, 2月 18, 2007
Fusion
- Fusion簡介: http://en.wikipedia.org/wiki/.NET_assembly#Fusion
- 安裝與刪除Assembly到GAC: http://blogs.msdn.com/junfeng/archive/2005/10/24/484063.aspx
- Fusion uses the DEVPATH environment variable to search for assemblies in every path that is specified in the DEVPATH environment variable.
星期一, 2月 12, 2007
星期日, 2月 11, 2007
JavaScript的Memory Leak
- http://isaacschlueter.com/2006/10/msie-memory-leaks/
- 據說Yahoo! User Interface Library採用輪詢(polling)的方式來偵測http request物件的readystate,避免因為指定function給onreadystate而造成循環參照。
- http://keelypavan.blogspot.com/2006/03/reusing-xmlhttprequest-object-in-ie.html
- 另一種可能是重複使用同一個物件。不過這種方法似乎用在IE的http request物件上會有一些問題,上述page有提供解決方案:
req_fail_IE.open("GET", url, true);
req_fail_IE.onreadystatechange = processReqChange_fail_IE; //open後再設handler
req_fail_IE.send("");
星期六, 2月 10, 2007
AJAX除錯
- JSLog: http://earthcode.com/blog/tools/contents.html
- 整個site取消log:
在jslog.js中找到config_enabled,將之設定成false - 單頁啟用logger:
在該頁的url中加入「&enablejslog」如 http://localhost/mypage.do?foo=bar&enablejslog - log4javascript: http://www.timdown.co.uk/log4javascript
如果要將log資訊回傳伺服器,可以考慮使用log4javascript
瀏覽器端除錯工具
- DebugBar: http://www.debugbar.com/
可用來在IE上檢視dom資訊
星期一, 1月 01, 2007
軟體測試工具
- 商業軟體: Mercury, Rational
- 開放軟體:
- Abbot: 測試Java使用者介面
- jfcUnit
- HttpUnit: 測試Web使用者介面
- Selenium: ThoughtWorks的作品,用來錄製與測試web使用者介面
Dan Bunea的介紹: http://danbunea.blogspot.com/2007/01/test-first-web-applications-tdding.html - WatiN:
http://blogs.clearscreen.com/dtax/archive/2007/01/07.aspx
自動化Acceptance Test工具
- Fit: 讓客戶能夠以Word之類的表格來撰寫測試範例,同時又能夠讓開發者的程式自動測試這些範例
軟體測試的分類
- White-Box Test: 測試內容只與軟體介面有關
- Black-Box Test: 測試內容除了與軟體介面有關之外,還與特定實作有關
從測試的層級來區分(單一開發者-->多開發者-->專案-->客戶)
- Unit Test: 測試單一元件
- Integration Test: 測試多個元件
- System Test: 測試整個系統
- Acceptance Test: 測試客戶需求
- Alpha Test: 公司內部模擬客戶來測試需求
- Beta Test: 由實際客戶來進行測試
從目的來定義
- Regression Test:
根據Wikipedia: - 任何用來發掘regression bugs的測試都叫做regression test
(Regression testing is any type of software testing which seeks to uncover regression bugs) - 當原先正常功能後來被改壞掉時,我們稱之產生了一個regression bug
(Regression bugs occur whenever software functionality that previously worked as desired stops working or no longer works in the same way that was previously planned)