Online Booking Is Safe

Mahmoud al-Mabhouh, one of the founders of the Izz ad-Din al-Qassam Brigades, was recently found dead in his hotel room in Dubai. Dubai authorities stated they were ruling the death a homicide and according to BBC:

Investigators have also discovered that 14 of the suspects had used credit cards issued by MetaBank – a small bank based in the US state of Iowa – to book hotel rooms and pay for air travel.

Posted in Uncategorized | Leave a comment

In-Memory DB, H2 and Python

Our log data is sent to a log server which then saves it in a PostgreSQL database. To prevent the database from growing too large, we periodically remove data older than 24 hours from the database and save it for future query. However, queries on the remaining data is still not fast enough for realtime monitoring. Besides, the vacuum process of PostgreSQL fails to handle gracefully the large number of deletes and slows down our system significantly when it runs.

I’d like to replace the whole logging system with a Hadoop-based system. But right now, I need something that can be up and running in 2 to 3 days and has no or minimal impact on the rest of the system.

The log server would save all log data into log files. At the same time, it runs a embedded in-memory database that has the most recently log data for our realtime monitoring applications to query. Of the final choices of in-memory databases in H2, HSQLDB and Apache Derby, I decide to go with H2.

Since our monitoring applications are in Python, access to H2 from Python is important. There’s no direct support of H2 in Python, so H2 needs to be run in PostgreSQL mode.

When using H2’s default JDBC driver, the URL jdbc:h2:tcp:// works as expected. The prefix mem: before database name hc_log is necessary to connect to an in-memory database. The PostgreSQL equivalent jdbs:postgresql:// doesn’t work. Instead of mem:hc_log, only mem is passed to H2 as database name. The solution is to use mem@hc_log as database name, and apply a small patch to H2’s ConnectionInfo to restore the name back to mem:hc_log.

H2’s PostgreSQL mode doesn’t work with JDBC4 drivers; JDBC2 is required.

Posted in Database, Java, Python | Leave a comment

Setting up BandLuxe C179 on Karmic

I’ve recently signed up with Singtel’s mobile broadband, which uses a BandLuxe C179 HSDPA USB modem. Hers’s how I set it up on Ubuntu 9.10:

  • Download Linux driver from The file name of the download “” suggests it’s intended for C270.
  • The product id in bandluxe.fdi is wrong, change it to:
    <match key="usb.vendor_id" int="0x1a8d">
    <match key="usb.product_id" int="0x1009">
  • The kernel module option.ko that comes with the driver doesn’t work with 2.6.31 kernel. And we don’t need it anyway, so comment out its installation from
    #echo "Backup file option.ko"
    #cp -v ${MODDIR}/kernel/drivers/usb/serial/option.ko ./option-eeepc.ko
    #echo "Add support of Bandluxe Data Card"
    #cp -v option-bandluxe.ko ${MODDIR}/kernel/drivers/usb/serial/option.ko
  • Install the driver:
    $ sudo ./
    $ sudo modprobe option
  • Plug in the modem.
    $ lsusb
    Bus 001 Device 003: ID 1a8d:1009

    So the modem has been detected. Before installing the driver, we only had 1a8d:1000, which is the USB storage device. We also have some new devices now:

    $ ls /dev/ttyUSB*
    /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2
  • Update /etc/wvdial.conf:
    [Dialer Defaults]
    Modem = /dev/ttyUSB0
    Baud = 7200000
    Init1 = ATZ
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
    Init3 =
    Area Code =
    Phone = *99#
    Username = ppp
    Password = ppp
    Ask Password = 0
    Dial Command = ATDT
    Stupid Mode = 1
    Compuserve = 0
    Force Address =
    Idle Seconds = 0
    DialMessage1 =
    DialMessage2 =
    ISDN = 0
    Auto DNS = 1
  • Finally
    $ sudo wvdial
    $ ifconfig
    ppp0 Link encap:Point-to-Point Protocol
    inet addr: P-t-P: Mask:
    RX packets:4478 errors:0 dropped:0 overruns:0 frame:0
    TX packets:3518 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:3
    RX bytes:5261965 (5.2 MB) TX bytes:406613 (406.6 KB)
Posted in Uncategorized | Leave a comment

Use Relative Path in Free-form Netbeans Projects

For free-form projects, Netbeans uses absolute path for project directory in project.xml:

<property name="project.dir">/Users/yili/Work/homecamera/WowzaStreaming</property>
<property name="ant.script">${project.dir}/build.xml</property>

All paths in project.xml are relative to the project folder, which is the folder that contains the nbproject folder. Thus changing the above to the following makes my project works on all platforms regardless where the project is located:

<property name="project.dir">../../../WowzaStreaming</property>
<property name="ant.script">${project.dir}/build.xml</property>
Posted in Uncategorized | Leave a comment

The Best Farewell

It has always been my ambition to die in harness with my head face down on a keyboard and my nose caught between two of the keys — Isaac Asimov

Posted in Uncategorized | Leave a comment

Setup Audio for Windows 7 on MacBook Pro 13"

My brand new MacBook Pro 13″ dual-boots on Snow Leopard and Windows 7. I used the official Snow Leopard DVD to install device drivers for Windows 7. Everything worked fine except for audio, which had a very low volume for both playback and recording. Here’s how I fixed it. Run registry editor as administrator and go to:


Make sure the following entries are present:

Name Type Value
n0DInAmpCaps REG_DWORD 0x00270301
n02OutAmpCaps REG_DWORD 0x80017f73
n03OutAmpCaps REG_DWORD 0x80017f73
n04OutAmpCaps REG_DWORD 0x80017f73
Posted in Uncategorized | Leave a comment

OpenSSL and Windows Socket

A program I’m working on gives many compilation errors like this:

c:\Program Files\...\PlatformSDK\Include\WinSock2.h(108) :
error C20011: 'fd_set' : 'struct' type redefinition
c:\Program Files\...\PlatformSDK\Include\WinSock.h(54) :
see declaration of 'fd_set'

This occurs when both WinSock.h and WinSock2.h are included and WinSock.h is included before WinSock2.h. Since WinSock2.h guards against WinSock.h by defining _WINSOCKAPI_, including WinSock2.h before WinSock.h is not a problem. windows.h also includes WinSock.h, thus windows.h must come after WinSock2.h.

In my code, all the platform dependent stuff goes into platform.h, in which WinSock2.h is included before windows.h, so what is the problem? It turns out that my code uses OpenSSL and openssl/rand.h includes windows.h. Putting platform.h in front of openssl/rand.h solves the problem.

Posted in Uncategorized | Leave a comment