Dec 11, 2009

I can leave, finally

After the past 2 years of working, the most important thing I learned is humanity. I learned that when facing the lure from the dark side of Force, who can stand up with it and who cannot. It's good to see most people choose the light side. Nevertheless, the Jedi are still out-numbered by the Sith. In order to succeed, I have to find more Jedi, so now I am leaving to start my journey. Wish me good luck.

Dec 8, 2009

The true meaning of "Organizational Change"

In M, there will be at least one "Organizational Change" for each year.

When I was young, I thought a programmer is cool because they are very professional and can produce many cool stuff (like computer games). Therefore, I chose computer science as my major at university. I hoped I could become as professional as them and produce many cool stuff as they do. After several year, I left school and joined Mediatek to start my career as a programmer.

Then I disappointed.

The reason why I disappointed is not due to the fact that what I did in the company is a completely useless junk. The true reason is that nobody in this company cares what they did are completely junk or not. All they care are nothing but power and money. The politics, as a result, is the most influential factor to what they care. That's why people care about politics. They like to talk who is going to be promoted and who is going to be f**ked. They share political information and form a small political group to fight against each other. One who spends most time on politics gets promotion while the hardest worker gets fired. The company rewards who conslidate their power and punishes who improve the quality of products.

Somebody called it "a process to become mature". One must know the differences between idealization and reality. One must understand the human society is very competitive and cruel. The mature people should know the rules of the society and the necessary political skills to get what they want. The mature people should adapt themselves to the society and stop complaining about it.

I disagree.

We shall not adapt. We must understand that we are still in the stone age of software industry. There are currently no effective tools to estimate the contribution of a programmer. There are also no ways to estimate who is capable to become the leader of a software team. It's very likely to choose a incapable leader. The incapable leader, as a result, is going to fire the most productive worker in his team due to the lack of software managerial skill. He will also hire many incapable workers because these incapable workers are the most similiar to the best employee in the world--himself. Several years later, the company will be full of incapable workers. Since they are incapable, they don't do any software product nor do them improve it. So what do they do in the company? One possible answer is, unsurprisingly, "Organizational Change". Period.

Dec 7, 2009

Tips on how to write a thesis

The most useful part of the handbook of UBC CS department is "Tips on how to write a thesis" by Bob Woodham. I keep reading it again and again while thinking what I was doing when I was in graduate school. Sometimes I invented a new technique to solve a known problem. Sometimes I applied the exsiting techniques to another problem. Which one is the "good research"?

Bob Woodham's article makes me think this question again. He stated that the third step of a research project is to discover new knowledge. Even so, most of recent computer vision research lack in this step. A popular trend of computer vision research is to transform a problem into statistical domain and apply new statistical methods. They consist only step 1, 2 and 4. Are they "good research"?

Another trend of vision research is to follow classical works and do some "tweak". For example, a one possible way to do image inpainting is to choose a different "filling algorithm" of the classical work "Region filling and object removal by exemplar-based image inpainting" by A. Criminisi, P. P´erez and K. Toyama. Since the filling algorithms are different, it's quite possible that we can find another set of images which the new algorithm can perform better. This kind of research consists all four steps. Are they "good research"?

He also stated a researcher should commit to a research problem, not a technology. However, all computer vision people commit themself to use camera to solve problems. Is it a kind of commitment to a technology? One of the most noticeable problem is to estimate image depth. Everyone knows that Laser Depth Micrometer(LDM) can outperform the stereo-based approache to several magnitude, but there are still many people try to estimate depth by stereo cameras. I know cameras are much cheaper than LMD. Nevertheless, shouldn't we just put our effort on cut down the production cost of LDM instead of researching another cheap and unreliable technology?

In the beginning, I thought a graduate school can help me understand what research is. I end up with much more questions when leaving.

Here is a excerpt from Bob's article.


The purpose of research is to contribute to knowledge. Selecting a problem is the major part of any thesis project. Avoid the Computer Science tendency to think only in terms of tools and techniques (and mindless programming tasks). There are four steps to a research project. Step 1 is for motivation and is done first. The thesis addresses steps 2 and 3. Step 4 typically occurs only after the thesis is completed. The four steps are:

1. Identify the research problem. Understand the state-of-the-art within a topic area well enough to determine fundamental obstacles to further success. You have identified a research problem when you can make clear where necessary new knowledge is needed.
2. Choose the research domain. Choose a domain that is rich enough to demonstrate the intended result yet simple enough to avoid wasteful diversions. Pragmatic considerations best determine the choice of domain. This best choice often is not the domain of the original problem. The link is simply that the necessary new knowledge required is the same. Choose the domain that supports the most rapid prototyping and testing of your ideas.
3. Discover the new knowledge. This is where you add your talent and creativity!
4. Apply the new knowledge to the original research problem. This will complete the research and will provide a foundation for future research by helping to identify the next set of obstacles.

Here are more suggestions to avoid common pitfalls:
1. Decide on the research problem before committing yourself to a particular domain. Bad way: I like to play chess and I need a thesis topic. Maybe if I implement a chess program I will discover something interesting. Good way (after P.H. Winston): Learning is difficult. Maybe there is power in noticing similarities and differences between symbolic descriptions. I can explore this easily in the context of the world of the blocks.
2. Does the research problem demand exploration. A lot of work in AI and computational vision is on non-problems. A demonstration that a tool or technique is sufficient for a given task is not a demonstration of necessity. Convince yourself that your research problem is necessary. What is to be learned? Who is likely to care about the result? Is the problem of fundamental importance? Without necessity, you can easily be scooped by a better tool or technique.
3. Examine your commitment to the research problem. Commitment to a problem means that you will accept a solution, regardless of the scientific discipline that gives rise to it. If you only accept solutions of a certain type, then your commitment is to a technology, not to scientific research.
4. Develop a detailed scenario to demonstrate your work. A scenario provides an organizing principle for your research. As much as possible, carefully work through the scenario by hand simulation. Identify critical components. Work hard to develop the new ideas required dealing with these components.

Nov 10, 2009

Evaluate Mr. O's abilities

Today, one of my colleague--Mr. O asked me to evaluate himself. The reason is that I will tell the truth since I am quitting my job. However, the truth is that I always tell the truth no matter I am quitting or not.

Let's see Mr. O's ability scores:
Social Skill:
One of the most remarkable skills of Mr. O. He knows how to joke with his boss and make his boss happy -- a very rare skill. He also knows how to maintain good relationship with his fellow engineers. Most important of all, he doesn't bully young engineers. He'll share knowledge and joyful work with them. Very remarkable.

Programming Skill:


Sexual appearance:
He is a handsome boy. Not only girls but also some guys are willing to sleep with him.
Nevertheless, he is not as handsome as myself, so he gets a score of 4.

Working Attitude:
He is one of the laziest workers in my team. He keeps chating with his friends on MSN  during working hours. He surfs the blogs and does little of this and little of that. I am always wondering what he is doing in the office.
His working attitude deserves the lowest score--1. If I were his boss, I would fire him.

Geek Level:
Honestly, he is not a geek. He is not ACG fans, not start wars fans, and know how to date beautiful girls. However, his passion to programming and vim raises his score to 3 -- a half geek.

Oct 17, 2009

How to prevent your OO program growing a GIANT INHERITANCE TREE

Object-Oriented programming is a paradigm for software engineers to seperate a computer program into discrete and reusable units, which are called "objects". One of its technique to resue the existing source codes is through "inheritance". That is, we find a common operation among objects, then we create a "parent class" to represent this operation.

"Inheitance" is an important technique to reuse source codes. However, we find it harmful in some cases.  One of download tools in our team faces suce a problem.
The functionality of the tool is to download binary images into the flash memory of a mobile phone. Since there are a wide range of mobile phones to support, the tool contains a lot of objects. Each objects represent a download process of a specific type of mobile phones. The problem is that the download processes are just slightly different with each other. One of the reasons why they are just slightly different is due to workarounds of hardware bugs. The "slightly different" codes then result in a tall and giant inheritance tree. Inheritance, generally, is a good technique. Nevertheless, when a object has too many ancestors, the operation of the object becomes obscure. The real implementation of a virtual function may be resided in any of the ancestors. It's hard to tell which one really takes effect from the source codes.

One of my colleagues wants to resolve this problem by refactoring the existing inheritance tree into a shorter one. He designs a common downloading procedure for all kinds of mobile phones. The procedure contains many but fixed steps, and each mobile can have its own step implementation if the its step is slighlty different than other mobiles phones. I am sure that he is going to succeed to reduce the height of the tree, but I doubt that he can prevent the tree from growing higher again.

The reason why he is going to succeed is primary because all of the workarounds of previous phones are known, so he can devise a download procedure general enough to cover all of the workarounds. On the other hand, the workarounds of future phones are impossible to known. When a workaround happens, it might break the existing download procedure and require to refactor the existing codes or increase the height of the tree. He said to me that the new download procedure is so general that it's impossible to break.

I think otherwise.

In the software world, it's better to have less assumptions on your source code. The less you assume, the less you will rewrite when the assumption fails. From my point of view, it's not necessary to assume that there is a one general download process which can cover all kinds of mobiles phones. Why not just assume that the download processes of mobile phones are all different. The reason why we want to find common procedures in our codes is because we want to reuse our codes. We don't want to copy and paste the same code in every place. If we do so, the code will be very hard to maintain since we need to change the same codes in many different places.

For the download tool, it's not the case. The download tool is basically a one-time programing. We write the code for a specific mobile phone. If it works, the coding is done. There are no more maintainence effort on the code. We just need a working code to download the binary images. That's all. For most of the time, it's very dangerous to refactor the source code of the download tool, because it might break the existing code and make the download tool fail on older mobiles. To prevent such problem, we need to perform a lot of regression tests. So it's even better if we don't maintain the code and leave the working code unchanged. If we want the inheritance tree shorter, we need to refactor our existing codes, which might break them. Alternatively, if we avoid inheritance and treat each download process as a seperate script, assume different mobile phones have different download process, we can get a clear program architecture. The program will be easier to read, because the download script shows all operations and workarounds it performs. It also avoid changing the existing codes and therefore it does not require the tedious process to test all old mobile phones.


Sound great. Now, please prove I am wrong

Oct 15, 2009

Panasonic Let's Note CF-Y8EWJAJR

Centrino(Santa Rosa)
CPU: L7800 @ 2.0GHz Merom
CPU voltage: 0.96V
Intruction: SSE3
L2: 4MB

Display: GM965 (X3100)
IDE: ICH8M
Sound: AD 1884
Wifi: Intel 4965AG
Net: Marvell Yukon 88E8055
SD card: Ricoh RL5C822
Cardbus: Ricoh RL5C476

台灣之光時尚精品捷安特City Speed



台北購物節展出的台灣精品中,得到精品金質獎的捷安特City Speed是唯一的工業設計作品。



這款城市公路車由英國設計師Michael Yang操刀,極簡的外觀融合科技感及創新性,除了獲得第十七屆的台灣精品金質獎外,它也得到2008年IF EUROBIKE設計獎城市車類金獎的殊榮。



IF EUROBIKE評審團給了這款車款極高的評價:
"The bike is very well designed from start to finish. All the components have been specially coordinated to work together perfectly. The front light, the stem and the handlebars, for example, from a single unit. Great."
(引用來源:捷安特http://www.giant-bicycles.com/zh-tw/news/12809/



這款車的設計概念是透過仿生的手法,以鯊魚的身體曲線,轉化為管件的外觀流線型曲線,從前端車首整體視覺的簡潔與平順,到車後警示燈視覺延續,增加速度感與流線意象。



整合式前警示燈、整體式後燈免除安裝、收納的麻煩,增加經濟效益。

外觀極簡,前後車燈都整合在龍頭及座管上,鋁合金車架,有2款,City Speed平把20速售價43800元,City Speed i8內變8段變速售價39800元。



在台北購物節新光三越信義店A11展出的是City Speed平把20速。

就外觀上看來,極簡外型確實適合都會雅痞生活模式,設計概念也呼應城市公路族的內在需求。可惜的是,雖然展場得見這款國內外獲獎爭光的台灣作品,卻沒有機會讓觀賞者親自觸摸這台精品的質感。

(本文圖片皆攝自2009台北購物節新光三越信義店A11展場內。)

Oct 13, 2009

The Greatest Nobody

As a nobody, I have a special interest in studying other nobody's life stories. Through their stories, I can learn more about the humanity, the society, and the possible endings of a nobody. I am always wondering, what a nobody can do in his/her negligible and pitiful life.

The definition of a nobody is simple:
1. His parents are not rich.
2. His look is not good.  (i.e. no handsome boys)
3. He is not smart.
4. He is located at the bottom of a social hierachy.

The first nobody comes into my mind is Michael Faraday.
His father was a blacksmith. His brother was a blacksmith. So what could he do?


The second nobody is Marie Curi.
Her family lost every property in a historical event. Her country was occupied by Russia. She hardly kept her life going in a nothing-left research facility.

The thrid nobody is Nikola Tesla.
He was too poor to pay tuition fees of the university. As a serbe, surely did he locate in the bottom of the society. In fact, serbes in 19th is equal to slaves. 

The last one is Albert Einstein.
Everyone around him thought he was a nobody. Indeed, he was a nobody. As a PhD, he could not get any teaching positions in universities. Finally, he got a work in a patent office, which is a significant failure in his career.


As a noboby, I feel I am more fortunate than the above nobodies.
My family has some properties. My career is more successful. My country is still alive.
 
Nevertheless, these nobodies are the greatest in human history. They made significant contribution to the human society despite the fact that the society had abandoned them before.

Could I do the same?

The Norns

Shortly after my girl friend went to USA, the Norns started to appear in my mind once in a while. I feel something is going to happen, but I don't know what it is.

They appeared in my mind in this way:












Strange enough, they are not girls, but a Wing Gundam(飛翼零式特裝型).
It didn't take me too much time to find this image on the Internet. It exaclty matched what I saw  in my mind. Wait...I am not a Gundam fan. Where did I see this?

I need a psychologist.

Sep 16, 2009

Application matters!
應用才重要

In "The Innovator's Dilemma", the arthur thinks when a company encounters a disruptive technology,

在創新的兩難中,作者認為一家公司在面對突破性科技時,最重要的不是改善突破性科技的效果,把突破性科技應用在現有的市場中。而是替突破性科技找到新的市場。

在Pattern Recognition的研究領域裡,研究人員一直在想辦法提升辨識的準確率,使得PR可以有效的被應用在人們的日常生活中。但是「創新的兩難」替我們指引出了另一個新的方向。 也許最重要的不是提升準確率,而是找到一個新的應用,而這個應用就算是準確率不高也沒有關係,因為有自動化的辨識,所以提供了和現有的技術不同的性質。

數位相機的人臉辨識就是一個例子。如果人臉有抓到,很好。但是如果沒抓到呢?也沒關係,反正相片還是拍的出來。

Sep 15, 2009

How to minimize the number of logging data

In the last week, I proposed an idea to my boss about minimizing logging data.

The idea is simple. Assume that we have a deterministic system. We want to debug the system, so we need some logging data to analyze the problem. Since the system is deterministic, if we give it the same input, it will respond the same output. So we only need to log the data coming into the system. If we made the system deterministic, we could avoid logging in the internal of the system. It can save a lot of logging bandwidth.

However, my boss thought it is impossible. He said, "It's impossible to log all incoming data of the system, because we cannot log all incoming electromagnetic waves. We can only log the data like the XOR of the electromagnetic waves." I tried to explain to him that we only care about digital systems, therefore we can focus on 0's and 1's, but he still very persisted that electromagnetic waves are impossible to log. It's near the lunch time, so I quickly ended this unpleasant conversation and went for my lunch.

After few days, I started to wonder "what is the XOR of electromagnetic waves?". XOR is a Boolean operation, how to apply it to continuous signals? Another thing I wondered is "what is the maximum input of a 3.5G mobile phone system ?" I thought the answer should be below 15Mb/s, because the maximum data rate of HSDPA is 7.2Mb/s. The HSDPA protocol overhead should not exceed the amount of data. If our system were deterministic, the minimum number of logging data rate should be below 15Mb/s. As a result, the data rate is ok to transfer by merely an USB cable, am I correct?

Sep 7, 2009

How to get WHQL certificate for your driver

If you need to get WHQL from Microsoft for your driver, you need to pass Windows Logo Test. First you need a PC with Windows Server 2003 installed.
Then follow the steps in DTMHowTo.

When you pass the logo test ( sometimes you need to the support from Microsoft ), see Winqual Faq to know how to submit your result to Microsoft.

Sep 3, 2009

Summary of MediaTek Inc.

todo
What my boss said today
1. Our product is good, because we are successful on the market, and our performance compared to competitors are good

2. We don't do unit test and code review unless we feel painful because of them

3. Unit test scale(on a module or multiple module or a function?)

4. Tools can have its innovation, not just support

The people in MediaTek thinks they can work here because they are superior than others. They think their job is the best in the world. One day, a colleague said to me that "If you leave this company, you will never get a better job. At that time, you have to beg to return."

I hardly agree with what he said. Indeed, thanks to the tax policy in Taiwan, MediaTek's compensation is considered the best in Taiwan. However, I don't think good compensation is the ONLY criteria for a good job. Of course, money is important, but it's more important to consider the money which you get and the money which you will get at the same time. I think it's better to judge a people's value by what he is going to be paid in his next job than what he is paid in his current job. When you are fired by your boss and want to find a new job, you cannot just put the number of your previous compensation on your resume and convince your future boss that you are worth that much. You have to prove it by what you have learned and what you have done in your previous jobs. These are more important than just good compensation.

For myself, I found my current job hardly add any eye-catching acheivements to my resume. I need to do something to differentiate myself from fellow engineers. In a competitive job market, the secret to succeed is not only do your job right, but also choose the right job to do.

Many people think that I quit a high compensation job is unrealistic, but most of time, I found myself very reasonable.

to summarize:
1. This article will become like Code Horror style
2. I am glad to leave

Aug 27, 2009

Summary of The Innovator's Dilemma by Clayton M. Christensen


Mr. Christensen tries to answer "why the best firms can fail" in this book. After the analysis from HDD industry, he concludes that the best firms can fail when they are unable to deal with disruptive technologies correctly. My quick summary is below:

A disruptive technology has three properties:
1. The performance of the technology is going to exceed the demands of certain market segments
2. The technology distinguish itself with some new features which appeal to a group of new customers.
3. The new market segments are too small to attract the attention of the leading companies of the existing technology.

What will happen when a disruptive technology emerges?
1. The startup who finds the new market for it has the "first mover advantage". Those who find have 30% survival rate.
2. The startup who focuses on improving the performance to meet the existing demands is going to be knock out of the market.
3. Existing companies will still focus on existing customers since they are more profitable.
4. The useful techniques like PDCA or Customer-Oriented Management help existing companies compete with one another, but they also prevent existing companies to enter the new market.

What should a existing company do?
1. A big company is managed by existing customers, process and values, not managers. Establish a new department to manage the disruptive technology if the required values and process are different from the existing one.
2. Do not try to improve the performance of a disruptive technology, but to find a new market for it. The new technology will grow itself with the new customers.
3. It's impossible to predict where the new market is. One has to try several times to find it. Don't put all resources in a single try.
4. When looking for new markets, don't hear what customers say, but see what they actually use the product.

Example:
1. YouTube: It's a example of a disruptive technology. The quality of its video hosting service exceed what people demands. It provides a new type of web service. In the beginning, the profit of such service is too small to attract attention of any existing companies. Nevertheless, it grows big enough to be acquired by Google. A good end.

2. Netbook: It's commercialized first by Asus. The performance of netbook will compete with notebooks in the future. However, Asus does not have any first mover advantages. The followers like Acer and HP got ahead of ASUS very quickly. Why?
Just think about property 2 and 3 above. The people who buy netbook also have notebooks. There are no new customers. The existing notebook manufacturers join the battlefield quickly. Therefore, there are no first mover advantages for ASUS. Netbook is not a disruptive technology but a sustaining one.

3. SSD: Compared with HDD, the capacity per dollar of SDD is very low. However, the value increases every year. When it hits the sweet point, HDD will be wiped out from personal computer market. The first mover advantage is very clear. No leading HDD manufactures have influence on SDD markets.

Aug 24, 2009

Clothes

1. 圓領條紋T單穿不會很單薄
2. 黑T可搭黑白格子衫
3. 黃T可搭黃衫
4. T + 衫的重點是協調,而非對比

todo:拍照

Jun 28, 2009

VIM Color Theme (Ayende)



Oren Eini made a great color theme for Visual Studio. I ported it to VIM. You can get it here


Here is a list of my previous VIM themes:
1. AF.vim


2.VividChalk.vim (it's specialized for Ruby)

Jun 27, 2009

Use Consolas font in Japanese VIM

Consolas is a font which is specialized to display source codes.
To use the font in Japanese VIM, add the following line in .vimrc

set guifont=Consolas:h11:cSHIFTJIS


Then import the following into your registry and reboot.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Consolas"=hex(7):4d,00,49,00,4e,00,47,00,4c,00,49,00,55,00,2e,00,54,00,54,00,\
43,00,2c,00,4d,00,69,00,6e,00,67,00,4c,00,69,00,55,00,00,00,53,00,49,00,4d,\
00,53,00,55,00,4e,00,2e,00,54,00,54,00,43,00,2c,00,53,00,69,00,6d,00,53,00,\
75,00,6e,00,00,00,42,00,41,00,54,00,41,00,4e,00,47,00,2e,00,54,00,54,00,43,\
00,2c,00,42,00,61,00,74,00,61,00,6e,00,67,00,00,00,00,00


Since Consolas supports English only. It's necessary to tell system how to display the words in other Languages or all Japanese words cannot be display normally.
The above registry setting assign
"MINGLIU.TTC,MingLiU
SIMSUN.TTC,SimSun
BATANG.TTC,Batang" to Consolas font to display both Japanese and Chinese words.

The result is here:



To get into the nutshell, see how font linking works

Just bought a Panasonic Notebook

I am fansinated by Panasonic Let's Note Y series. The 1400x1050 resolution with only 1.5kg weight is really amazing. I bought at Osaka and it took me ¥16,0000. It's a little pricy but still acceptable. I cannot think of a better mobile weapon of programmers than this one.



The Japanese keyboard:


The ugly look:

Jun 20, 2009

The VIM Settings to replace Visual Studio 2008

Just start to shift from Visual Sudio 2008 to VIM. I heard that keyboards can bring a lot of fun to programming, but I cannot live without Visual Studio 2008. There are too many great features of it, like completion, source code browsing, etc. All I need to do now is to being these features into VIM. (Why does no one make a power pack of VIM to beat Visual Studio?)
1. SnipMate
Provide a Textmate-like snippet functionality. It's a better substitude of snippetsEmu. However, snippetsEmu has more snippets. Perhaps I should port them to SnipMate, hmm...

2. SuperTab
3. FuzzyFinder
4. CTAGs
5. EnhancedCommentify
6. DoxygenToolkit
7. a.vim
8. visual_Studio.vim

Used plugins:
1. taglist
2. project
3. RltvNmbr

Jun 18, 2009

The last express in 2009

Just finished "The last express", a great adventure game produced by Smoking Car in 1997. I played the demo of this game when I was a child. I didn't play the full version since I found nowhere to buy this game at that time. Though it's been 12 years, I still cannot forget this game. So I downloaded the full version(thanks to the greatest invention of the 21st century) and played it. The feeling is like playing a game of 2009. Unlike many old games, its great visual quality makes me feel it's a new game.

The ending deserves an Oscar.

Jun 17, 2009

Abandon Textmate...Now!!!

Textmate hasn't release any new versions for several years. I don't think a software does have a future if it's not actively supported. Therefore, I decided to switch to the old good VIM. Perhaps I could master VIM this time.

*Update 2011/11/15: There will be Textmate 2 alpha release around Christmas.  After 2 years, it doesn't matter anymore. VIM FTW!

List of great games

A couple of games I cannot forget in my life

1. Fallout
2. Torment
3. Baldur's Gate
4. The last express
5. Crusader: No Remorse
6. Daggerfall
7. Strike Commander
8. Master of Magic
9. Civilization
10. GTA

May 23, 2009

I won a slurpee!!!

I just bought a slurpee and it took me just 1 NT dollars!!!
I have not won any prizes for quite a long time (actually, I cannot remember the last time I won a prize). How lucky I am ^_^
Sadly, after I I walked out 7-11, I remembered I catched a cold and the doctor told me don't eat anything cold. Now the slurpee become my mom's. OH~~my slurpee~~~

May 10, 2009

Simple gray area code test


void main(){
}

May 9, 2009

DockPanel Suite Installation Tutorial

DockPanel Suite add the docking functionlity to C# application. The effect is similiar to the
docking effect in Visual Studio 2008
.


Installation steps:
1. Download the dll at SourceForge.
2. Open Visual Studio, add reference to the dll
Step1

Step2


3. Add DockPanel to ToolBox

Step1


Step2


Step3


Step4


4. Drag DockPanel to Form 1

Step1


5. Change IsMdiContainer to true. Beware!!! This is crucial step, or your program will crash!!!

Step1


6. Add an new form (Form2)

Step1

May 3, 2009

Display image test







show image


Apr 3, 2009

The first bug of VS2008

Just saw a bug from Visual Studio 2008 compiler:






Can it prove I am a vertern VS2008 user?

Mar 27, 2009

boost asio for windows pipe bug -- ERROR_MORE_DATA

I encountered another asio bug today.
I created a pipe server and used a pipe client to send data to the server.
The server read 128 bytes for each read, but the client sends 65536 bytes for each write. When the server read the data, ::ReadFile returns ERROR_MORE_DATA.
Then it just crashed.

The root cause is at function "async_read_some_at" in the file "win_iocp_handle_service.hpp".


DWORD bytes_transferred = 0;
ptr.get()->Offset = offset & 0xFFFFFFFF;
ptr.get()->OffsetHigh = (offset >> 32) & 0xFFFFFFFF;
BOOL ok = ::ReadFile(impl.handle_,
boost::asio::buffer_cast(buffer),
static_cast(boost::asio::buffer_size(buffer)),
&bytes_transferred, ptr.get());
DWORD last_error = ::GetLastError();
if (!ok && last_error != ERROR_IO_PENDING)
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
{
ptr.release();
}
}


In the above code,

if (!ok && last_error != ERROR_IO_PENDING)
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}


Checks for any error. When last_error != ERROR_IO_PENDING, the function assumes that the call to ::ReadFile is failed, so it release ptr immediately. But when last_error is ERROR_MORE_DATA, the call is successful and the ReadComplete event will still be put in the complete queue. Since the ptr has been released, the LPOVERLAPPED returned by ::GetQueuedCompletionStatus points to invalid location and is causes crash.

The fix is simple, just change the code to

if (!ok && (last_error != ERROR_IO_PENDING && last_error != ERROR_MORE_DATA) )
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}

Mar 24, 2009

Microsoft Usbser.sys hot fix

Here is the list of Microsoft Hotfix of the notorious usbser.sys.

5.1.2600.3226: When you use a USB-to-Serial converter to connect a device to a Windows XP-based computer, the data transfer from the computer to the device is slower than expected. (KB943198)

5.1.2600.2930: The Usbser.sys driver may not load when a USB device uses an IAD to define a function that has multiple interfaces, and this function uses the Usbser.sys driver file in Windows XP. (KB918365)

5.1.2600.1330: A memory leak may occur when you repeatedly start and stop the Usbser.sys driver on a Windows XP-based computer. (KB831480)

Mar 11, 2009

Useful USB status code

Some useful USB status code which you may see when dealing with USB monitor

1.target stalled
USBD_STATUS_STALL_PID 0xC0000004

2.operation is cancelled by application
USBD_STATUS_CANCELED 0xC0010000

Mar 1, 2009

PDF management

Recently I tried to manage the pdf I have got so far. It's very handy if I had a tool like iPhoto which can automatically add all of my pdfs to a large library with automatic indexs, comments or description.

Delicious library on MAC can find book description, but it cannot import pdfs automatically. Yep on MAC is a good way to go, but I just wonder that if there is a similiar software on PC?

Feb 21, 2009

Javascript code prettifier test

Here is my small expriment on the Javascript code prettifier.


void main(){
}

Deletion Test

deleteme

SyntaxHighlighter Test

I am testing in SyntaxHighlighter 1.5.1.The SyntaxHighlighter 2.0 is hard to be compatible with blogspot, so I decide to postpone to use the new version. But 1.5.1 still shows some strangeness. (Do you see that?)

--Update 2009/05/10
I have updated the SyntaxHighlighter to 2.0.3. Everything seems fine now.


void main(){
printf("hello world!);
}

Feb 5, 2009

VIM

I am trying to adapt VIM in recent days. Still fill painful, though.

Here is my plugin list:
a.vim
include_complete.vim
supertab.vim
omnicppcomplete.vim
taglist.vim
visualmark.vim

 
TEMPLATE HACKS AND TWEAKS BY [ METAMUSE ] BLACKCAT 1.1
/scripts/shBrushJScript.js'/>