September 25, 2007

Multiple Emacs Shell Buffers

Having my work changed a lot during the last year, from a Lunix developer to a half developer half support and now are purely support, I do not have many chance to use Emacs that often anymore, but I keep to use to it as much as possible. After all it's my first editor in my programmer career. One thing I like is its shell buffers. Unfortunately, It only support one shell as I thought before. Because if you type M-x shell to open a new shell buffer, if you already have one open that will just switch to the existing one.

Continue reading »

July 29, 2006

C++ training

4 days C++ training just finished yesterday. I was extremely impressed by the instructor’s deep insight and great knowledge of C++. As before I join Morgan Stanley, I thought I had a pretty good knowledge of C++. After this class, I find that still long way to go for me.

To be continued...

Continue reading »

April 20, 2006

My First MFC Application using COM

I am excited to tell you that I have built a simple MFC applcation using COM objects, which used to be somehow mysterious to me. The COM objects are created by ATL. Before reading this article, I assume that you have the basic knowledge of COM and be experienced programming in C++. One thing I should pointed out is that I am a newbie of COM and there may be some errors in this article. Still, The reason I write this article is to record my growth of my technical career and share it with you.

Continue reading »

April 17, 2006

COM COM COM

I thought I would stick on my Linux path and finally to be a Unix/Linux expert when I took the current job. But just like Groom said, “Life is like a box of chocolate, you never know what you’re going to get". I realize that there are some more interesting technologies there waiting for my exploring. I must confess that The Microsoft® COM (Component Object Model) has made a great effort on platform-independent and object-oriented software development. This technology is so popular that many large companies are using it to build complicated applications and also so many software job positions require knowledge of COM explicitly.

Continue reading »

April 13, 2006

Use Regular Expressions in Emacs

What is Regular Expression? A regular expression is a special text string for describing a certain amount of text. Generally, A regular expression contains a few special characters and ordinary characters. If you have used Linux/Windows systems, you will probably familiar with wildcard notations such as *.txt to find all text files in a folder. That's a simple regular expression example (Thanks for netcasper's correcting . The regex equivalent to ".txt" is .*\.txt). Nowadays, Most of the text editors support regular expression such as vi, emacs and Ultra Editor(not a free software). Today, I would like introduce some basic knowledge about regular expression and use it in Emacs to improve the efficiency of your coding work.

Continue reading »

April 11, 2006

A memory bug detector

This interesting tool valgrind is a debug tool and can been used to find memory bug, include memory leak. There is a rpm in Fedora Core 3 CD. You can get it from CD or download the source code from their website. Moreover, this tool is a Free Software, and is freely available under the GNU General Public License. You can use it to debug Linux programs and it's very easy to use.

Continue reading »

March 26, 2006

Notes of Introduction to Algorithm(B-Tree)

When I was a college student and took the course Data Structure and Algorithm, the B-Tree section was not included in the exam requirement. At that time the teacher just said little about it and therefore I knew little about it. It is ridiculous that I totally understand B-Tree until last month. So what is the B-Tree? B-Trees are balanced search trees designed to work well on magnetic disks or other direct-access secondary storage devices. B-Trees are similar to red-black trees. but they are better at minimizing disk I/O operations. Many database systems use B-Trees, or variants of B-Trees, to store information.

Continue reading »

March 11, 2006

Goodbye Internet Explorer

For years I’ve stick on my IE (Microsoft’s Internet Explorer) since I had my own personal computer. But my love for the past faded when I met Firefox. Thanks to my mentor Daniel who introduced Emacs and also Mozilla Firefox to me. But, I guess most of my friends and many people in China are still using IE or other IE core browsers such as Maxthon. But today I want to tell you that it’s time to say goodbye to IE because a much better browser is ready for you.

Continue reading »

March 07, 2006

Notes of Introduction to Algorithm(Red-Black Tree)

A red-black tree is a binary search tree with one extra bit of storage per node: its color, which can be either RED or BLACK.
A binary search tree is a red-black tree if it satisfies the following red-black properties:
1. Every node is either red or black.
2. The root is black.
3. Every leaf (NIL) is black.
4. If a node is red, then both its children are black.
5. For each node, all paths from the node to descendant leaves contain the same number of black nodes.

Continue reading »

February 13, 2006

A trick using #if pre-processor

I hit a small C++ grammar trick which I have never met before in my project. The problem is how to deal with the situation that two defined identifiers have the same compilation behavior. A simple solution to this is to write two same block code like this:

Continue reading »

February 02, 2006

Programming in the UNIX Environment

There are two books i have read when i begin my programming carrer.
One is <Advanced Programming in the UNIX Environment> written by W. Richard Stevens. The other is <Linux Device Drivers, 2nd Edition> written by Alessandro Rubini and Jonathan Corbet

Continue reading »

Thinking in C++

I have read the volume 1 of the book during the last month.
It is a very famous book about C++. When I was searching the way to master the C++ language, everyone recommend this book to me.

Continue reading »

January 27, 2006

IE And Firefox CSS Compatibility Problem

There are many differences between firefox and IE when they parsing CSS file. When I built this site, I often suffered the pain, that when I designed a HTML page with a CSS style, it looks pretty fine in Microsoft's IE but terrible in Firefox. Here is an example, people often use nested "<div>" tag in their HTML file and so do I. If you also want to do such things and hope people have a nice experience in your website using Firefox you should be careful with your CSS style design.

Continue reading »

January 24, 2006

Update my CSS style

It is really complicated, I think, at least for me! I havn't learnt CSS before, therefore, it took me much time to change the default CSS style to the current one.

Continue reading »

January 12, 2006

Notes of Introduction to Algorithm(Binary Search Tree)

Binary search tree is a binary tree in which each internal node x stores an element such that the elements stored in the left subtree of x are less than or equal to x and elements stored in the right subtree are greater than or equal to x. The following code is the class of binary search tree designed by me. I use a function pointer m_visit to construct the tree and visit the nodes of the tree. Most operations are implemented below.

Continue reading »

January 10, 2006

Notes of Introduction to Algorithm(Order Statistics)

The ith order statistic of a set of n elements is the ith smallest element. For example, the minimum of a set of elements is the first order statistic (i = 1), and the maximum is the nth order statistic (i = n). The asymptotic running time of the simple problem of finding a minimum or maximum is Θ(n). Yet select the ith smallest element appears more difficult but it also only need Θ(n) time.

Continue reading »

Basic Operations on Binary Tree

Binary Tree is the most often used Data type in the programming world and is also the basis of other complex data structures. So it is very important to understand it, however it is also very easy to implement in C/C++. The follow paragraph is quoted by Standford Univ.'s Website explaining Binary Tree:
A binary tree is made of nodes, where each node contains a "left" pointer, a "right" pointer, and a data element. The "root" pointer points to the topmost node in the tree. The left and right pointers recursively point to smaller "subtrees" on either side. A null pointer represents a binary tree with no elements -- the empty tree. The formal recursive definition is: a binary tree is either empty (represented by a null pointer), or is made of a single node, where the left and right pointers (recursive definition ahead) each point to a binary tree.

Continue reading »

December 19, 2005

Notes of Introduction to Algorithm(Exercise 2.3.7)

The problem is:
Describe a Θ(n lg n)-time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S whose sum is exactly x.
Solution:
1.Sort the elements in S using merge sort.
2.Remove the last element from S. Let y be the value of the removed element.
3.If S is nonempty, look for z= x - y in S using binary search.
4.If S contains such an element z, then STOP, since we have found y and z such that x= y+ z. Otherwise, repeat Step 2.
5.If S is empty, then no two elements in S sum to x.
Step 1 takesΘ(n lg n) time. Step 2 takes Θ(1) time. Step 3 requires at most lg n time. Steps 2–4 are repeated at most n times. Thus, the total running time of this algorithm isΘ(n lg n). The following is my implement code:

Continue reading »

December 16, 2005

Select maximum and minimum using 3*(n/2) comparisons

It is not difficult to devise an algorithm that can find both the minimum and the maximum of n elements using Θ(n) comparisons. Simply find the minimum and maximum independently, using n - 1 comparisons for each, for a total of 2n - 2 comparisons.In fact, at most 3(n/2) comparisons are sufficient to find both the minimum and the maximum in the array of size n.We compare pairs of elements from the input first with each other, and then we compare the smaller to the current minimum and the larger to the current maximum, at a cost of 3 comparisons for every 2 elements.

Continue reading »

December 15, 2005

Notes of Introduction to Algorithm(Counting Sort)

Counting sort assumes that each of the n input elements is an integer in the range 0 to k, for some integer k. When k = O(n), the sort runs in Θ(n) time. Seems so fast? The answer is no. It just uses extra space to cut down the runtime. However I have extended the range to -k to k in the following implementation.

Continue reading »

December 14, 2005

Introduction to Algorithms

Recently I am reading the book CLRS Introduction to Algorithms, Second Edition. I find that I really hook on it! It's a great book about the Algorithm and I think I will wirte some notes about reading the book and write some C/C++ code for the pseudo code on this book.

Continue reading »

Notes of Introduction to Algorithm(Quick Sort)

Quicksort is a sorting algorithm whose worst-case running time is Θ(n^2) on an input array of n numbers. In spite of this slow worst-case running time, quicksort is often the best practical choice for sorting because it is remarkably efficient on the average: its expected running time is Θ(n lg n). Quicksort, like merge sort, is based on the divide-and-conquer method.

Continue reading »

November 21, 2005

C++ Tips from Thinking in C++(4)

This entry is continued from C++ Tips from Thinking in C++(3)

Continue reading »

November 18, 2005

C++ Tips from Thinking in C++(3)

This entry is continued from C++ Tips from Thinking in C++(2)

Continue reading »

November 13, 2005

C++ Tips from Thinking in C++(2)

As I posted the previous entry C++ Tips from Thinking in C++(1), I should keep on my working. Thinking in C++ is a great book. It attracts me to continue to explore the miracle C++ world.

Continue reading »

October 15, 2005

C++ Tips from Thinking in C++(1)

The following C++ grammar items are extracted from the book Thinking in C++. Most of them are often forgotten by myself. I will record here for my future quick reference.

Continue reading »

August 26, 2005

Makefile.am's assignment

This is la qucik reference of Makefile.am's assignment.

Continue reading »

August 24, 2005

GNU Automake tools Quick Reference(Autoconf)

Because of the diversity of the Unix system, the famous 'configure' script should be runned before compiling the source code on the system. The script check your system environment such as where your library locate and help you decide which part of the source code should be complied. This small simple qucik refrence is made by myself when I started to work as Software Engineer.

Continue reading »

August 23, 2005

Autoconf Macro Reference

This is an alphabetical list of each Autoconf macro used in this book, along with a description of what each does.
The documents is not made by me. I just extract it from the e-book written by Gary V. Vaughan.

Continue reading »

August 18, 2005

Some commands I often use in Emacs

Before the end of June, 2005. I was completely know nothing about `Emacs'. Thanks to Daniel told me such an excellent Editor and taught me lots of skills of using this great tool. It can perfectly help me do something that I cannot image before. So I will record some useful commands' keyboard shortcuts for myself to refer. Notice that, all the keyboard shortcuts' real command names could be found through C-h-k + 'your keyboard shortcut'.

Continue reading »