Saturday, June 09, 2007

n choose k = ((n - 1) choose k) + ((n - 1) choose (k - 1))

Thursday, May 03, 2007

Treap Data Structure

http://www.ibr.cs.tu-bs.de/courses/ss98/audii/applets/BST/Treap-Example.html
Viewing the Contents of a JAR File

http://java.sun.com/developer/Books/javaprogramming/JAR/basics/view.html

Monday, April 30, 2007

VIM tips

Seven habits of VIM

Habit 1: Moving around quickly

/argc n, n, n ... => : set hlsearch *
=> Put :set hlsearch in .vimrc; use * again again

Habit 2: Don't type it twice.
type XpmCreatePixmapFromData() => type CTRL-N on word (word completion)

Habit 3: Fix it when it is wrong.
mis-spell => :iabbrev teh the
:syntax keyword WordError teh

Habit 4: A file seldom comes alone.
:!ctags -R
:tag init
:tnext
:grep "\" **/*.h <- search
:cnext

or gf => Go to file on header file names (work for http)
=> make sure the path option is set correctly.

[I => find the word under cursor to include files.
[ => Jump there.

Habit 5: Let's work together
Working with MsWord
=> set Vim with :set tw=0; wrap linebreak

Copy the text between app and Vim through clipboard.

Monday, April 16, 2007

Useful and powerful replace commands in vim

:.,X s/^/\/\/ comment them
:.,X s/^\/\// uncomment them


This does exactly the same thing but looks cleaner.
:.,X s_^_// comment them
:.,X s_^//_ uncomment them

Thursday, April 05, 2007

If we have a following block,

{
int i = 20;
int j = 40;
...
int k = i * j;
printf("k = %d, i = %d, j = %d\n", k, i, j);
}

Then the compiler would optimize this block in a way that i, j, and k variables never exist, since the block only uses values of them. Also, these values are within the scope of the block too. Thus, the compiler simply replaces the variables with constants. However, if the block ever uses reference or addresses, then it is illegal for compiler to optimize them. In this case, the compiler wouldn't optimize those variables away.

Saturday, March 31, 2007

Domain-based email: http://www.stubmail.com

Amdahl's law: http://en.wikipedia.org/wiki/Amdahl's_law
Good site for web-based messenger site: http://www.meebo.com

Good site for listening to music: http://www.pandora.com
When you include a header file, you introduce a dependency that will
cause your code to be recompiled whenever the header file changes.
If your header file includes other header files, any changes
to those files will cause any code that includes your header to
be recompiled.
class Foo {
public:
Foo() : bar_("foo_bar") {}

private:
const string bar_;
};


In this C++ code, you should not declare bar_ as
const string& because the initializer creates an instance
of string with "foo_bar" char* and it will be destroyed
immediately after it is out of scope if it is referenced.

Monday, March 26, 2007

Ruby tutorial: http://www.ruby-lang.org/en/

Program to convert epoch integer following "epoch_time" to human-readable string.

if __FILE__ == $0
IO.foreach("querylog.txt") {
|x|
print "" + (x[0,10] == "epoch_time" ?
x[0,10] + ": " + (Time.at(x[11..x.size].to_i)).to_s + "\n" :
x)
}
end

Wednesday, March 21, 2007

Law of Demeter

When I refactor a class and feel that this class is doing too much,

then I have to say that there might be a better way of dealing with this.



http://en.wikipedia.org/wiki/Law_of_Demeter





powered by performancing firefox

Monday, February 26, 2007

Print with long-edge double-sided option.

/usr/bin/lpr -P -o Duplex=DuplexNoTumble
Combine multiple pdfs into one pdf

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=chem120_assnt1.pdf -dBATCH ./1638_001.pdf ./1638_002.pdf ./1638_003.pdf ./1638_004.pdf ./1638_005.pdf ./1638_006.pdf ./1638_007.pdf ./1638_008.pdf ./1638_009.pdf ./1638_010.pdf ./1638_011.pdf ./1638_012.pdf ./1638_013.pdf ./1638_014.pdf ./1638_015.pdf ./1638_016.pdf
Advantage of Const Reference over Const Pointer
- It eliminates any question of memory ownership.
- It is Non-NULL.