Monday, August 23, 2010

Thursday, April 29, 2010

Small Tricks in LaTeX

  • Make a figure span two columns in LaTeX
\begin{figure*}
\end{figure*}
  • Change column spacing of a table
\begin{table}[t]
\setlength\tabcolsep{2pt}
...
\end{table}

Saturday, February 13, 2010

VNC server

x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

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>