Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Initializing Variables in C++

  1. {} is more powerful than () and thus is preferred over (). You should use always use {} except for a few cases where () is necessary. For example, if you want to create a vector of length 1000, you have to use
    vector<int>(1000);
    

instead of

    vector<int> {1000};

which create a vector …

Install the GSL Library

GSL is an advance C/C++ library that is widely used. To install GSL, you can download the source file and following instruction in the included README and INSTALL document. For Unix/Linux users, the GSL library is often availabe in the repository. For example, you can use the following …

The Sum and Product Puzzle

I talked about an interesting problem in this post. I had onsite-inteviews from Wolfram at the end of April this year, and I decided to talk how to solve the problem using Mathematica. I did some research and realized that the problem is a well-known one which is called the …

Adjust Screen Brightness for Linux Desktops

For many computers and laptops installed with Linux desktops, you can use shortcuts (usually Fn + Brightness_keys) to adjust screen brightness. This does not work for some laptops. Another way to adjust screen brightness is to use the following command.

    sudo setpci -s 00:02.0 F4.B=brightness_value

The value …

A Secure Way to Use Vino in Debian

VNC on Linux is not secure. Most implementations of VNC servers for Linux allows password only up to 8 characters. Such a VNC server is very vulnerable to brute-force attack. This article discuss a secure way to use VNC. The VNC (vino) server is started only when needed, thus reduce …

Add an Entry into the Right-click Menu in Windows

To add an entry into the right-click menu in Windows, edit the registry following the steps below.

  1. Open the registry. You can search for regedit in Windows Start menu and run it.

  2. Navigate to the key HKEY_CLASSES_ROOT\Directory\Background\shell in the registry.

  3. Create another key with any name (e …