Sunday, November 29, 2009

Install CDT in Eclipse Galileo

Installing CDT was always simple: download the zip file from its website, and extract to the plug-in directory. But, I don't know why this download-and-extract method does not work on Eclipse Galileo.

Here's a more complicated way to install CDT in Eclipse Galileo:
  1. Download the CDT zip file from http://www.eclipse.org/cdt/.
  2. Open Eclipse, and select Help -> Install New Software.
  3. Press "Add" next to the "work with".
  4. Press "Archive", and select the zip file you downloaded in Step 1.
  5. Install the features you want, and restart Eclipse.

Saturday, November 14, 2009

A Fast Way to Build Linux Kernel

  1. apt-get source linux-image-`uname -r`. This command downloads the Linux kernel source code of your current version.
  2. make defconfig. Default configuration is much more compact than the old configuration used in Ubuntu or other Linux distributions. Because I only need to change the scheduler, this compact configuration is more than enough for me.
  3. Usually, the default configuration allows you to boot into the system. If it doesn't, the most likely reason is lack of device drivers in the kernel. The drivers you need to compile depends on the hardware system you are using. For example, I need to enable CONFIG_FUSION for my virtual machine. "lscpi" servers as a good clue to figure out which drivers are needed.
  4. make menuconfig, and enable the network device driver. Check your Ethernet controller using lspci, and enable the corresponding configuration option in the kernel configuration. For example, my controller is PCnet32 LANCE, so I need to enable CONFIG_PCNET32. Another way to figure out which option to enable is to view the file /etc/udev/rules.d/70-persistent-net.rules. Again in my case, I can see "pcnet32" at the end of the device description. My desktop has the device type e1000e, so I would enable CONFIG_E1000E instead. You can find these configurations in the path Device driver -> Network device support in menuconfig. For instance, Ethernet (10 or 100Mbit) -> AMD PCnet32 PCI support is for CONFIG_PCNET32, and Ethernet (1000 Mbit) -> Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support is for CONFIG_E1000E.
  5. Refine your kernel configuration (optional). You can disable unnecessary modules further in "make menuconfig", such as support for Mac devices.
  6. Pick a name for your new kernel (optional). Also in menuconfig, General setup -> Local version.
  7. make -j?. ? is one plus the number of cores your machine has. It takes only 4 minutes on my virtual machine.
  8. sudo make modules_install
  9. sudo make install
  10. Update your GRUB menu list (/boot/grub/menu.lst). e.g:
    • title Ubuntu 8.04.1, kernel 2.6.24.6-custom
    • root (hd0, 0)
    • kernel /boot/vmlinuz-2.6.24.6-custom root=/dev/sda1 ro
  11. sudo reboot

Monday, November 9, 2009

Small Tricks in VIM

  • Format the current paragraph: gqap
  • View hex files
    1. Use "vim -b" or "set binary" after opening
    2. %!xxd
  • Disable the beep (including the visual beep): set visualbell t_vb=
  • Replace texts in a range: Select a range in the visual mode, and then press ":". The range will be automatically generated. Then type s/<to be replaced>/<replacement>/<options>

Friday, November 6, 2009

Convert vsd to eps

  1. Download and install the PS printer driver for Windows: http://www.adobe.com/support/downloads/product.jsp?platform=win&product=pdrv. During the setup, select "Local Printer" as how the printer is connected, and select FILE as the printer port. After installation, you would be able to see this virtual printer in the printer list.
  2. Open your Visio document, and select what you want to print. Goto File->Print. Select the virtual printer in the name list, select "Selection" as the page range since we do not want to include the margin in the page, and check "Print to file".
  3. Press "OK", and select the path of the output file. The file name should end with .ps.
  4. Open the generated PS file using GSview. Goto File->"PS to EPS" to compress PS into EPS. An alternative method is to set the printer option and print .vsd to .eps directly, however I found the quality was not so good.

Monday, September 14, 2009

VIM's Backspace Problem

On clic machines, when I type [BACKSPACE] trying to delete the character to the left of the cursor, I get a ^? inserted. This is caused by a wrong mapping from ^H to ``erase character'' in ~/.bashrc.

Two solutions:
  • Remove the mapping in your ~/.bashrc file. In my case, that line is ``stty erase ^H''.
  • Add to your ~/.vimrc file this line: set t_kb=[press CTRL+V][press BACKSPACE]. [press CTRL+V] and [press BACKSPACE] mean you must press the two keys in this order.

Sunday, September 6, 2009

Install Vista Ultimate w/o SP1 on Machines with AHCI Enabled

The Advanced Host Controller Interface (AHCI) is a programming-specification which defines the operation of Serial ATA host-controllers (also known as host bus adapters) in a non implementation-specific manner. The specification describes a system memory structure for computer hardware vendors to exchange data between host system memory and attached storage-devices. (excerpt from wikipedia)

Vista Ultimate w/o SP1 cannot be installed directly on a machine with AHCI enabled. You'll probably get a bluescreen crash during boot. However, you can do a trick to work around this problem. Here are the steps:

  1. Disable AHCI in BIOS. You may have to disable Flash Cache Module as well.
  2. Install Vista Ultimate (w/o SP1).
  3. Start the registry editor, and set the value of "Start" to 0 in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Msahci.
  4. Install AHCI driver. After that, you should be able to see msahci.sys under C:\windows\system32\drivers.
  5. Restart your computer, and enable AHCI in BIOS.

Sunday, July 19, 2009

Dual Monitor on Ubuntu

The dual-monitor problem bothered me from time to time on my office desktop. The maximum screen resolutions are different: one is 1280x1024, and the other is 1600x1200. There is only one dual-monitor option in screen resolution setting, which is 3200x1200, however the monitor with the resolution of 1280x1024 does not support that.

Later, I figured out the reason might be that I selected the one of 1600x1200 as the primary monitor, so that the dual-monitor resolution was based on that. Finally, it worked again after I changed the primary monitor by switching the two cables.

Hacking xorg.conf also helps. I need to add a line in Section "Device" saying:
Option "ParisModes" "1280x1024+1280x1024"

Disable IPv6 for Firefox

I find it pretty slow connecting to python.org. Actually this is why I asked my advisor for a Programming Python book. However, this problem does not show up on my laptop at home, so I guess it is a network configuration problem.

When doing a `telnet www.python.org 80', i saw telnet trying connecting to the IPv6 address of that website, and eventually timed out. Then, it tried the IPv4 address and got succeed immediately.

I disabled IPv6 for Firefox by changing the preference named `network.dns.disableIPv6', and everything went well. The problem may be caused by the router does not support IPv6. I'll shoot Daisy an email asking about this.