• Post syntax highlighted code in Drupal

    Posted on: Sat, 11/17/2007 - 10:45 By: Huahai

    You may have seen that I sometimes post code here. Wouldn't it be nice if all the code are syntax highlighted, like what we see in a text editor? Well, with the help of Vim, it's easy. Vim is bundled with a "2html" script, that can turn whatever shown in Vim into a HTML file, with all it's color and format. To invoke this command, simply issue ":so \$VIMRUNTIME/syntax/2html.vim" command in Vim to run the script, or more simply ":TOhtml". No, you don't have to type this many characters, autocompletion should do most of the typing for you. Vim will then open up a window that contains the newly converted HTML file.

    (Update: for newer version of vim, need to :let g:html_use_css=0 first)

  • Set mailto handler in Firefox

    Posted on: Fri, 11/16/2007 - 22:25 By: Huahai

    In order to click "mailto:" links on Web pages to launch an email program, Firefox (or Iceweasel on Debian) needs to be told which email program to use. To do this, type "about:config" in Firefox's address bar, type in "mailto" in filter, look if "network.protocol-handler.external.mailto" preference has value "true". By default, it's true. If not, set it to be true. Then check if "network-protocol-handler.app.mailto" exists or not. By default it's not.

  • Dual head with xrandr 1.2 revisited

    Posted on: Fri, 11/16/2007 - 04:04 By: Huahai

    In this post, I discussed "clone" mode of dual head with xrandr 1.2. Now I got an extra monitor, and would like to use "xinerama" mode, wherein the built-in laptop LCD and the external monitor share a single virtual screen. To set this up, I changed my /etc/X11/xorg.conf to add a monitor section for the external monitor:


    Section "Device"
    Identifier "Intel 965GM"
    Driver "intel"
    BusID "PCI:0:2:0"
    Screen 0
    Option "XAANoOffscreenPixmaps" "true"

  • Regular Web sites coexist with Drupal sites

    Posted on: Fri, 11/16/2007 - 01:31 By: Huahai

    This site is primarily powered by Drupal, i.e. it is a PHP site. However, we have a few Web directories that serves regular HTML pages. Since I installed Drupal in document root, access to these directories becomes an issue. The main problem is that directory index file resolution is broken, because Drupal changed the default directory index file from index.html to index.php. So a Web request to these regular HTML directories results in an error. What's more, this error is very misleading, instead of saying "404 Page not found", it says "403 Access denied".

  • Complete OpenSSH Client Public Key Solution on Debian

    Posted on: Mon, 11/12/2007 - 10:14 By: Huahai

    My work requires me to connect to many different SSH servers, and I have different passwords for each server. It's a pain in the neck trying to type in many different passwords everyday. The obvious solution is to use OpenSSH's public key login solution, so passwords are no longer needed to connect to SSH servers from a single client (e.g. my office desktop).

    Key Generation and Distribution

    To use public key authentication, it is necessary to generate a pair of keys on your client machine. Do the following as normal user:


    mkdir ~/.ssh

  • Backup Linux Laptop with USB Hard-disk Enclosure: a Lightweight Solution

    Posted on: Mon, 11/12/2007 - 00:00 By: Huahai

    Most of Linux laptop users have done some customizations on the system so it works the way we wanted. Now we want to save the fruit of our hard labor in case bad things happen. We want to backup not just the /home directory, but the whole / directory, minus some runtime generated files. In the past I have used some heavy-weight applications such as unison and backuppc. These worked well, but they required setting up servers that run all the time.

  • Use Vim to read manual page

    Posted on: Fri, 11/09/2007 - 22:10 By: Huahai

    Command line manual page is an indispensable tool for working with Linux system.If you forget how to use a command, just type man followed by the name of the command. One thing I don't like about the manual system on my Debian sid is that it uses most to display the manual. The key bindings of most feel awkward for me since I am used to vim. Of course, there are many "vimers" like me, and they've found ways to fix this.

  • Running Windows Vista on Debian Linux with VirtualBox

    Posted on: Sun, 11/04/2007 - 00:26 By: Huahai

    All of my laptops are now running Debian based Linux. It works great. Linux handles all my daily works well. However, there are occasions where I need a Windows machine. For example, I recently need to deliver a lecture on a system that runs only on Windows. Also, in the past, we developed a system that works only on Windows, and I still need to demonstrate it from time to time. Of course, the solution is to run Windows on a virtual machine on top of Linux. In the last couple of years, I have been using VMware for this purpose. However, I was not very impressed by its performance. I remember last year during a presentation, the virtual machine was so slow that my demonstration was negatively impacted by it.

    Open source edition

  • 介绍娇娇

    Posted on: Wed, 10/31/2007 - 04:31 By: Huahai

    姓名:娇娇

    性别:小美女。

    品种: 巧克力点的巴利猫(Balinese, chocolate-point)

    性情:哼,你们嫌我脸上有花,可我知道我是个美女~_~。我感情特细腻,特丰富的。隔一小会儿没见着巴巴麻麻,见着了我就特激动,一边使劲咕噜咕噜,一边还要使劲蹭他们。我最喜欢被抱在肩膀上了,站得高,看得远。每天早上7点钟我都要把他们给咕噜咕噜醒,这是我的工作嘛。我高兴了还会给麻麻按摸呢,我的技术好极了。对了,我特好养,人吃啥我就吃啥,玉米和waffle是我的最爱,每次都让我高兴得要发疯了(不要意思,这时候我总会忘了我是个淑女的)。我很聪明的,唐唐会的我都会,他不会的我也会,比如上桌子找东西吃啥的。

    进门的经历:麻麻在网上看见我的玉照就喜欢我了,把我领回了家,他们都很爱我。我也爱麻麻和巴巴。嗯,我也喜欢唐唐。他这个傻大个,我老欺负他,他也不生气,嘻嘻。当然了,我对他也不错,经常给他舔毛的,他就是不愿意我也要舔。哼,我可不想和一个脏脏的男生整天呆一块儿。

Subscribe to Huahai's Blog