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
  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
    • root (hd0, 0)
    • kernel /boot/vmlinuz- 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: 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.