Monday, September 21, 2009

[QnA] memo: USB memory stick booting

  1. $ sudo umount /dev/sdX (if the USB stick has been mounted; X = a, ..., z)
  2. $ sudo mkdosfs /dev/sdX
  3. $ sudo su -c "zcat boot.img.gz > /dev/sdX"
  4. $ sudo mount /dev/sdX /media/mountPoint
  5. $ cp *.iso /media/mountPoint

Before the above steps, the capacity of my 8G USB stick was

After the above steps, it became only several MB

But I don't know what caused this.

Sunday, September 20, 2009

[SW] GHMM in Python: importing problem

In July, I installed a library of HMM called GHMM. When I had no experience about Python and therefore ignored the part of Python bindings. With the amazing capabilities of Python+SciPy, I began to notice the possibility to learm more about HMM using the Python bindings of GHMM. Therefore I followed the installation steps on GHMM webpage and got it worked on one of my PC.

Today, I tried to follow the same procedures to install GHMM in my another Ubuntu and Debian system on another two PCs, but got some problems.

After installing the GHMM as well as the Python bindings, I imported ghmm in iPython but got errors:

ImportError: cannot open shared object file: No such file or directory

I tried to find out whether was installed by using
$ sudo updatedb
$ locate

then got

The messages indicated that the had been in my system, but the Python somehow couldn't find it. So there must be some setting needed to make it work.

There have been some discussions in the mailing lists of GHMM as follows.
[Ghmm-list] cant find _ghmmwrapper
[Ghmm-list] ImportError: ...

With the above information, I add the LD_LIBRARY_PATH into .bashrc as
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

It works. :-)

Some information found during my solution-searching:
The 3rd and 4th links are beyond my knowledge, so I decide not to bother with them now... :-p

memo (090923): I found the file has been in the path of ``/usr/lib/'' instead of ``/usr/local/lib/'' in the first Ubuntu PC which has ghmm installed without any problem. Therefore I tried to cp the file into the path of /usr/lib/ for the other two PCs and everything is okay now.

Saturday, September 19, 2009

[QnA] SCIM setting in Debian

When I was installing the Debian, I chose the language environment as English. It always looks better in English environment, for me. This setting has a disadvantage, however, when I need to view or read articles and files in Chinese. Also, sometimes I need to type Chinese even Japanese for searching or composing text files. As a result, I have to make my system capable of showing Chinese characters and to let me input Chinese characters as well.

In Ubuntu, there is an easy way to add new language setting by using System --> Administration --> Language Support. When I tried to do the same thing, however, I found there was no Language Support in Debian. Then the how-to I found is ``Chinese Debian Mini Howto.'' Things were easy, until I installed SCIM and then had no idea how to active it.

Although I have two or three times of experience about SCIM installation in Ubuntu, I actually didn't remember what I had done. I just had the icon on the tray but didn't know how to activate it by pressing Ctrl+Space.

After referred to the following links, I tried to edit the content of ``/etc/X11/xinit/xinput.d/all_ALL'' and then got SCIM work as my expectation.

[SW] Debian installation

I have been planning to learn LFS for several weeks. Before dive into LFS, I need a PC with a host system installed. Fortunately, I got a (not very old) PC of the lab from where I graduated. Then I decided to chose Debian as the host system. The reason is that I want to try something new but meanwhile I don't want to go too far away from the path of Ubuntu. By using Debian, in my guess, I could benefit from what I've learnt in Ubuntu. So, I downloaded the image to be burned into the DVD then installed it.

(Actually, I've made a bootable USB stick with the image file, but the BIOS of the PC didn't support this kind of booting... :-p)

The installation was smooth and then I have a PC with Debian installed. It looks great, and I am typing this post with it. :-)

Friday, September 18, 2009

[QnA] Add fonts for

To add new fonts for the Ubuntu, just put font files in the path of ``/usr/share/fonts/truetype,'' then

$ fc-cache -f -v

With only these steps are not enough for the OO to use the new added fonts. Make sure that the new font files can be accessed by OO. In other words, change the mode of the new font files:

$ chmod 755 NewFontFiles

Thursday, September 17, 2009

[QnA] Test: USB stick mounting

This should be a fundamental issue, but I've had no idea how to mount a USB stick manually. It's convenient to let the system auto-mount the USB stick, but it's also make me feel unsatisfied. I just want to mount the device by myself!

PART I. To Mount It

1.1 Identify the device

So I start to find some information and to test the manual mounting with my USB stick. The first thing needed is to find out which device stands for my Sony USB stick.

$ sudo fdisk -l

I used the fdisk command before and after I plugged the USB stick, then from the differences of output message I know the /dev/hdb1 stands for my USB stick. Then I tried to mount it by typing

$ sudo mount /dev/hdb1 /media/sonyusb

and got ``mount: mount point /media/sonyusb does not exist.'' I searched the reason and found that I have to create the /media/sonyusb before I mount anything to it. At the same time, I recalled that everything in Linux is treated as a file, including a device.

1.2 Make a folder for the mounting

$ sudo mkdir /media/sonyusb
$ sudo mount /dev/hdb1 /media/sonyusb

This time I mounted the USB stick, but when I listed the files inside it, some filenames contained Chinese characters showed question marks. I guess this was about unicode or something like that. To solve this problem, I found the option ``iocharset=ustf'' can make it.

1.3 Use iocharset to show unicode filenames correctly

$ sudo mount /dev/sdb1 /media/sonyusb/ -o iocharset=utf8

With the option, I can mount my Sony USB stick succesfully without any problem! :-)

PART II. Some More Tests

After knowing how to manually mount the USB stick, I continued to test something. Here are some results.

2.1 Unmount conflict between CLI and GUI

If the USB stick has been mounted by sudo command in the CLI, then an error message will pop up when you try to unmount the mounted device.

Therefore, if you mount the device via CLI manually, just unmount it also in command line.

2.2 Remove the folder after unmount

After the USB stick has been unmounted, the mounting point (i.e. the previously created folder) won't be removec automatically. If you want to delete the mounting point, it can be remove manually.

[QnA] Mount the USB device at fixed mount point

It's easy to use USB stick when the system can mount it automatically. But in my case, Ubuntu mounts my Sony USB stick with nonsense name such as ``/media/disk-1,'' so I wanted to know how to mount my Sony USB stick with fixed name (mount point), for example, ``/media/sonyusb.''

There is an easy way to do it via GUI setting. Right click on the device icon on the Desktop, then
Properties --> Volume --> Settings --> Mount Point

But WAIT!! Do NOT type absolute path name like ``/media/theNameYouWant.'' Simply give it ``theNameYouWant,'' or you will get error message with your USB stick unmounted.

If you've fallen into the strape, just as what I did, then here is also an easy way to recover it. Use gconf-editor. Type ``gconf-editor'' in the command line and it will give you a friendly GUI as the follows.

In my case, the wrong setting was found in the so-called key ``/system/storage/volumes/_org_freedesktop_Hal_devices_volume_uuid_0829_A0F0.'' The value was ``/media/sonyusb'' and it was not right.

Click on the value field then you can correct it.


Wednesday, September 16, 2009

[SW] Install Pidgin 2.6.1 in Ubuntu 8.04

The default version of Pidgin for Ubuntu 8.04 has had an annoying problem. When the user login, Pidgin gives many pop-up windows with error message: MSN Error: Friendly name changes too rapidly.

I don't know the causes nor solutions after Google searching, but they said the newer version has no such a problem. Therefore, I rushed into downloading the source and tried to install it. When I had no idea how complex this mission could be. There were too many dependency packages needed to install. After following the error message given by the configure script of Pidgin source package, I gave up.

Then I kept trying to find some other solutions.

There is deb packages for latest version of Pidgin. At the beginning, I thought it might be the most convenient way for installation. After run the deb package, however, it gave the dependency error message.

Finally, I found the best solution which is to add the PPA to the sources.list:


$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install pidgin

Tuesday, September 15, 2009

[Py] Python: array and list

When I tested some basic functions in iPython, I noticed the differences between array and list.

At the beginning, I thought that if there are two matrices matA and matB in the same dimension, then I can just add their corresponding elements with ``matA + matB.'' By doing some tests, however, I found it's not what I expected.

>>> matA = [[1, 2], [3, 4]]
>>> matA
[[1, 2], [3, 4]]
>>> matB = [[-1, -2], [-3, -4]]
>>> matB
[[-1, -2], [-3, -4]]
>>> matC = matA + matB
>>> matC
[[1, 2], [3, 4], [-1, -2], [-3, -4]]

The plus operator concentrated matA and matB, and this was not what I needed.

Importing the ``array'' module still cannot let me do things I wanted.

>>> import array
>>> matA = array.array("i", [1, 2, 3, 4])
>>> matA
array('i', [1, 2, 3, 4])
>>> matB = array.array("i", [-1, -2, -3, -4])
>>> matC = matA + matB
>>> matC
array('i', [1, 2, 3, 4, -1, -2, -3, -4])

The solution is ``to use SciPy.'' Yes, if you want to manipulate matrices with Python more intuitively, remember to import scipy.

>>> from scipy import *
>>> from pylab import *
>>> matA = array([[1, 2], [3, 4]])
>>> matA
array([[1, 2],
[3, 4]])
>>> matB = array([[-1, -2], [-3, -4]])
>>> matB
array([[-1, -2],
[-3, -4]])
>>> matC = matA + matB
>>> matC
array([[0, 0],
[0, 0]])

Thursday, September 10, 2009

[Study] Good Fourier Transform explanation

Fourier Transform has been a widely used technique for extracting frequency information from temporal data. But I always wonder how does it work? What makes the FT has such a magical capability?

I thought about FT again yesterday and searched for some online resources. Here is a straightforward explanation of the principle of FT:

The Wavelet Tutorial Part 2 by Robi Polikar

I have to say: The idea of FT is really brilliant. Maybe this is something called ``the beauty of mathematics?'' :-)

Other links:
DFT, FFT by Paul Bourke (with C code examples)
FFT in Python by Yukuan (in Chinese)
Discrete Fourier transform by Jang (some content presetnted in Chinese)

Tuesday, September 08, 2009

[SW] PyX

PyX, another data plotting package for Python.

Here is an article talking about the PyX and matplotlib:
PyX, matplotlib, 3D & LaTeX

[SW] Python+SciPy+Matplotlib (installation and test)

There are many ways to use open source software and libraries to accomplish works which have been done by using Matlab. Oactve and Scilab might be two of the most well-known choices. Actually, my works don't need them very often and hence I don't know them well.

When I was reading some discussions about which one is ``better'' (okay, I know this question might be a stupid one), there are many information indicate that Python+SciPy+Matplotlib is a good combination to replace MATLAB. What I knew was Python, which occupied my weekend days to play around with. SciPy and matplotlib were new to me. I never heard about them but some screenshots showing their working results impressed me very much, so I decide to give them a try.

But it cost me more time than I expected. Orz (It's my own fault, not matplotlib's)

At the beginning, I installed the python-scipy, python-numpy and python-matplotlib via Synaptic Package Manager, and everything went smoothly. I just downloaded the examples and use python to see the plots. Good quality! And many formats including eps are available. When I tried to see the result given by a downloaded example (, however, the python interpreter feedbacked error message said there was no so-called ``path'' module. I spent several minutes to figure out that the problem might caused by the version of my installations.

The newest version of the matplotlib is 0.99, and the one installed by Ubuntu was... 0.91.2! So I began to download newest version of matplotlib, SciPy and Numarray (Later, I found what I want to download is NumPy ,not Numarray, which is not supported anymore). Then, I followed the INSTALL files of the packages to find more other necessary packages. During the installation, I didn't follow all the instructions carefully and miss the libpng before installing the mataplotlib. Due to the mistake, the python interpreter said it cannot find TkAgg even the python-tk and tk8.4 have been installed (I'm not sure which one could be related to this problem).

Finally, I got new versions of the necessary libraries and can apply the examples with no problem.

Wow, it costed me several hours, but it's worth it because I learned more during the installing process.

Backend setting:

Saturday, September 05, 2009

[Chat] Sponsoring Vim

I have used Vim for many of my works, and it has gave me really good experience in editing or coding. Therefore, I decided to help the development of Vim: donate some money.

Thanks to the service like PayPal, which makes the sponsoring easier and quicker. I can only give a few money, though. I am happy to receive the reply from Vim:

Thank you very much for registering Vim! Your contribution will
motivate me to spend more time on improving Vim. The money will be used
to help needy children in Kibaale, Uganda.