Monday, September 21, 2009

[QnA] memo: USB memory stick booting

Links:
Steps:
  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: libghmm.so.1: cannot open shared object file: No such file or directory

I tried to find out whether libghmm.so.1 was installed by using
$ sudo updatedb
$ locate libghmm.so.1

then got
~/ghmm/ghmm/.libs/libghmm.so.1
~/ghmm/ghmm/.libs/libghmm.so.1.0.0
/usr/local/lib/libghmm.so.1
/usr/local/lib/libghmm.so.1.0.0

The messages indicated that the libghmm.so.1 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: libghmm.so.1 ...

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 libghmm.so.1 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 libghmm.so.1 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 OpenOffice.org

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.

Ref: https://bugs.launchpad.net/ubuntu/+source/gnome-mount/+bug/88828

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:

deb http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main
deb-src http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu YOUR_UBUNTU_VERSION_HERE main

Then
$ 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 (path_patch_demo.py), 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.

---
Notes:
/usr/lib/python2.5/site-packages/matplotlib
/usr/lib/python2.5/site-packages/scipy
/usr/lib/python2.5/site-packages/numpy
Backend setting:
/usr/lib/python2.5/site-packages/matplotlib/mpl-data/matplotlibrc

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.

Monday, August 31, 2009

[SW] To make Windows can access Linux's ext2/ext3 filesystem

Here are two software I've found but not tried yet.
It seems that, however, only the Ext2Fsd is open-sourced. Therefore, I think I would try the Ext2Fsd first.

Ref:
ext2IFS vs. ext2FSD : which is better at assessing ext3 in windows?

Sunday, August 30, 2009

[SW] SCIM: How to restart?

Every time we change some settings or install/remove something of the SCIM, it told us to restart the SCIM. But how?

This is a tiny question but has resided in my brain for a long time. After getting the Japanese input method (scim-anthy) back, I faced to this question again. This time, I decide to find the solution, and here it is:

$ sudo pkill -9 scim
$ scim -d

This is my first time to know the pkill command, and it looks useful. Also, I finally know that the ``scim -d'' command is what I was looking for.

[SW] The Japanese input method disappeared from SCIM?!

Hmm... I might do something to cause this happened, but I am not sure. There has been an input method for Japanese in the SCIM of my Ubuntu till yesterday. I found it just disappeared. Even checking the setup of SCIM, I still cannot found the Japanese input method.

I tried to search some relevant items on the internet, and occasionally saw the term ``scim-anthy''. Oh, yes, I recalled that Anthy is the name of the disappeared input method. What needed to do is just install the scim-anthy again:

$ sudo apt-get install scim-anthy

And during the installation, there was no message showed that the scim-anthy has been in my system. So it's possible that I did something to let the scim-anthy disappear? I am just not sure. :-p

Friday, August 28, 2009

[QnA] Fast Dial went empty and Xmarks gave error message

Just two or three days ago, I surprisingly found my entities in the Fast Dial folder became empty. Later, The Xmarks icon set in the button right corner of the Firefox showed an error mark. I tried to update the Xmarks, but it just gave an unknown error message with nothing useful (to me). Knowing nothing to do, I chose one stupid approach: add the entities for the Fast Dial manually.

Why I was stupid? I didn't think about other possibilities. I even didn't think about looking for solutions on the internet!

Maybe I was just too tired after so many works. Today, I sat at the desk with the Firefox connected to the internet, and I think about searching the solution with Google immediately. Oh, there exists smart solution. What I needed to do is to login my Xmarks page and restore the old bookmarks.

Here is the solution: Xmarks, Fast Dial and Firefox 3.5
Step 1: Login into your Xmarks page, then my bookmarks -> Tools -> Explore and restore
Step 2: Delete the empty Fast Dial link in your bookmarks and let Xmarks "synchronize now". Note that you should download the bookmarks from the server, do NOT merge them.

I never know that the Xmarks keeps so many backups of one's bookmarks. That's a pretty consideration for users.

If you need to restore one of your old bookmarks, just click one of the radio button and then View it to see whether you've chosen the one you want.

Tuesday, August 25, 2009

[SW] GTK+ Menu Widget

Here is a web page I found. There are two example codes to illustrate two ways to create the menu bar with items.

That web page is written in Chinese, and if you don't read Chinese, here is another web page in English. I believe the English one is the original one and it contains more details in explanation.

The new version tutorial of the Gtk+ menu widget can also been found on the GNOME library website:
http://library.gnome.org/devel/gtk-tutorial/stable/c1501.html
You have to go through the following pages to complete that section.

[QnA] Ubuntu update problems...

I've been bothered by the so called ``GPG error'' for some days. There was an error message about the wine, which was installed for the IEs4Linux. My experience of using the IEs4Linux, however, had been not positive, so I decided to remove it as well as the wine package.

After removing the wine, the error message about it was gone, but there are some other errors. Then I searched solutions via Google, and followed several approaches including something like the follows.

$ cd /var/lib/apt
$ sudo apt-get clean
$ sudo mv lists lists.old
$ sudo mkdir -p lists/partial
$ sudo apt-get update
...

Also, I noticed that in the error messages, there are terms about ``hardy-security main'' and ``hardy-security universe'', so I found them in the sources.list and blocked those lines contain the terms. Then, I tried and tried, and finally I restored the old /var/lib/apt/lists and have the following error message:

W: GPG error: http://security.ubuntu.com hardy-security Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key <email address deleted>

I was totally missing in what I was doing because I have weak background in the update issue.

And just several minutes ago, I saw on the internet that someone suggest people who encounters such a problem could change the download server. So I also tried it. At the first try, it didn't work. I noticed a button read ``Select Best Server'' and tried it. Then reload it and problems gone. Actually I don't think I've not really solve the problem yet because I am not sure what I've done. But at least, I've learnt that servers could be related to the updating problems.

Thursday, August 13, 2009

[SW] Regexp substitution in VIM

Vim is my favorite text editor. I use vim for editing plain text or programming. It has many features which I've not been familiar with, and the substitution with regexp is on of them.

I had a little problem in one of my script file, which has been used to chop some data files into shorter segments for further usage. When editing the script, I need to delete some parts which are in the form of ``some digits, some digits''.

For example, I need to delete ``90,185'' or ``1455,2010'' in the script for composing a newer one. Because the digits have different length, my original substituting pattern ``[0-9],[0-9]'' didn't work. I had tried many different regexp patterns as I've known, but no one match my requirement. Then, I think I have to add some more knowledge about the regexp used in vim to improve my skill as well as the work efficiency, so I went to the help of Google and find the following website: Vim Regular Expressions 101.

Finally, I found what I needed. Some quantifiers can be used to set how many times certain part of the pattern should repeat. So my working pattern of regexp become ``[0-9]\+,[0-9]\+''. Learnt something new again. :-)