Thursday, December 31, 2009

[QnA] SCIM setting in Debian.. again...

I installed the Debian in one of my PC, but then reinstalled it to give a disk space for the LFS. After the reinstallation, I forgot how to install and set up the SCIM... AGAIN... I even forgot I've had an article about this issue in my own blog HERE. Orz

This time, my procedures are the follows:
# apt-get install scim scim-chinese scim-tables-zh
# vim /etc/X11/Xsession.d/95xinput
/usr/bin/scim -d
XMODIFIERS="@im=SCIM"
export XMODIFIERS
And didn't get what I want, so I kept tring
# vim /etc/X11/xinit/xinput.d/all_ALL
XMODIFIERS="@im=SCIM"
GTK_IM_MODULE="scim"
QT_IM_MODULE="scim"
Then the SCIM setting had been completed.

Finally, I installed the Japanese and Chinese imput methods to which I used.
# aptitude install scim-anthy scim-chewing

(Later, I removed
/etc/X11/Xsession.d/95xinput, and everything works well so far.)

Saturday, November 14, 2009

[QnA] Taking screenshots of virtual consoles?

I am trying to find ways to take screenshots of virtual consoles. This article shows the method of taking screenshots from console using the ImageMagick. The author said that the method also works for consoles with the command as the follows

$ sudo chvt N; sleep T; import -display :0.0 -window root output.png; sudo chvt M

where N is the target console and T is the time in seconds. The last chvt command is just for returning the original working console.

After testing with the command, however, I found the png file was generated but the image itself is not what I expected. At the beginning I thought that might due to my framebuffer setting so I disabled the corresponding setting in the /boot/grub/menu.lst. Nothing has been improved and I still can only get the following useless image.

[QnA] FrameBuffer setting

Several months ago, I learned the way to view images in the virtual console. I happened to recall the framebuffer and want to know more about it, so I began to search related information again.

Here are several informative web pages:
  1. Images and Videos on the Command Line? YES!
  2. Using framebuffer devices on Intel platforms
  3. Ubuntu wiki: FrameBuffer
In the 2nd web page, there is a table showing the values for different resolution as follows:

Colours 640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
--------+--------------------------------------------------------------
4 bits | ? ? 0x302 ? ? ? ?
8 bits | 0x300 0x301 0x303 0x305 0x161 0x307 0x31C
15 bits | ? 0x310 0x313 0x316 0x162 0x319 0x31D
16 bits | ? 0x311 0x314 0x317 0x163 0x31A 0x31E
24 bits | ? 0x312 0x315 0x318 ? 0x31B 0x31F
32 bits | ? ? ? ? 0x164 ?
Furthermore, from the 3rd reference I found more useful setting such as
  • ``vga=normal'', or ``nofb'', disables the framebuffer
  • ``vga=ask'' will able you to set a value at each boot good for testing out the various modes.

Friday, November 13, 2009

[QnA] Sound volume control in command line

I've used wmii for several weeks, and it meets most of my need well. Sometimes, however, I want to control the volume but there is no the control panel as in the Gnome desktop environment.

Here is the solution: amixer (or alsamixer, which has the ncurses interface).

To use alsamixer is easier due to the straightforward interface. If you get the following error message when you type ``alsamixer'' in the command
alsamixer: function snd_ctl_open failed for default: Connection refused
then do the following steps:
$ rm ~/.asoundrc and then do
$ asoundconf list
$ asoundconf set-default-card foo
where the foo is one of the sound cards listed by `asoundconf list.'

---
Ref:
http://ubuntuforums.org/showthread.php?t=597765
http://ubuntuforums.org/showpost.php?p=3631606&postcount=4

Thursday, November 12, 2009

[SW] Big5 and utf-8 in Vim

To make Vim open big5 files properly, just set the following
set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
set encoding=utf8
set tenc=utf8
---
Ref: http://wiki.debian.org.tw/index.php/Unicode#VIM

Thursday, November 05, 2009

[Py] Equal sign

Python: Careful with equal sign

I found this article when I was searching for the information about comparisons in Python.

When we assign a variable to another, for example, a = 1; b = a, Python just passes the reference (of variable a) to the new one (i.e., the variable b) but not creates a new copy with new memory address.

>>> a = 1
>>> b = a
>>> id(a) == id(b)
>>> True

But if we change the value of b, then a new memory block will be used to store the new assigned value.

>>> b = 2
>>> id(a) == id(b)
>>> False

[Py] Comparisons -- ``=='' vs. ``is''

In Python, there two operators which check whether things are the same. One is ``=='' and another is ``is.'' They may produce identical results but actually they have different meanings.

I found an article talked about this: is is not the same as equal in Python

The simple guideline has been given by Eric:
You should really only use 'is' to check for object identity, and for any kind of value comparison, == is the way to go.
And an interesting example has been given by Kevin:
>>> "peter" == "peter"
>>> True
>>> "peter" is "peter"
>>> True

>>> "peter" is "peter1"[:-1]
>>> False
>>> "peter" == "peter1"[:-1]

>>>True
---
ref: Python built-in types: comparison


[Py] Guidelines for Python coding style

Here are two links about the Python coding style:
One thing I've never noticed is the indentation problem. Python relies on consistent indentation of code blocks, so if the programmer mixed spaces and tabs in the code there could be problems when others open or edit the code with other editors with different tab setting.

The above links give many information that I cannot read throughly in limited time, but they have offered me some useful guidelines to follow in the future.

Tuesday, November 03, 2009

[QnA] Cannot mount disk -- you are not privileged to mount volume

One of my Windows XP disk partition happened to be unmountable and I totally didn't know why. I've set the auto mounting in /etc/fstab and it has worked well till today.

To solve this problem, use:
$sudo mount -t ntfs-3g /dev/yourdevice /media/yourfolder -o force

[QnA] GPG error -- the solution

When the Ubuntu users update and upgrade their system, there are, sometimes, GPG error messages shown in the GUI dialog or command line terminal.

Here are a solution I've found useful and easy (only two steps):

$ gpg --keyserver keyserver.ubuntu.com --recv put_the_last_8_digits_of_the_key_here
$ gpg --export --armor put_the_last_8_digits_of_the_key_here | sudo apt-key add -

---
Some other related links (for backup and reference):
https://answers.launchpad.net/easyubuntu/+question/73458
https://answers.launchpad.net/ubuntu/+question/73171
http://kovyrin.net/2006/11/28/debian-problem-apt-get-update/

Monday, October 26, 2009

[SW] Learning Lsip using Vim as the editor

I prefer Vim over Emacs. One day, I happened to be curious about Lisp, and then found the page ``Practical Common Lisp.'' The so-called ``programming environment'' confused me. Furthermore, Emacs seems to be the standard (or mainstream) editor/environment for the Lisp programming.

I've set the Emacs and SLIME for a try, but it's not easy for me to remember the key stroking in Emacs. So I also found some approaches to let me learning Lisp with my beloved Vim.

The first approach I found was: slime.vim, but I do neither understand the script nor the steps. After trying and trying, I gave it up.

The second approach is to install the Limp, a plugin for Vim. It does not work identically to what has shown on the web page, but it seems not bad and simple enough for me.

---
(Maybe my problems are due to my poor understanding of how Lisp works.)

[SW] Emacs and SLIME for Common Lisp

I am not familiar with Emacs, but I still tried to install Emacs as well as SLIME for trial.

Here are simple steps for setting all these up:
$ sudo apt-get install clisp emacs slime sbcl cl-asdf

Then, in the .emacs file:
(setq inferior-lisp-program "/usr/bin/sbcl")
(add-to-list 'load-path "/usr/share/common-lisp/source/slime/")
(require 'slime)
(slime-setup)

---
Ref: How to set up Emacs + SLIME + SBCL under GNU/Linux

[QnA] Using the terminal in Ubuntu -- simple but useful commands

Here is a web page for newbies: UseingTheTerminal. Most of the commands are simple but could be useful in daily operation.

Sunday, October 25, 2009

[SW] Taglist -- a Vim plugin for browsing the source code

To make Vim handier for programming, the taglist is a good choice. It works with Exuberant Ctags to make you browse the variables, functions, or classes of the source code easily.

Just make sure you have installed Exuberant Ctags:
$ sudo apt-get install exuberant-ctags

It's a good idea to set hot-key to toggle the TlistToggle function (use <F12> as the example):
nnoremap :TlistToggle
nnoremap <F12> :TlistToggle <CR>

[SW] Vimperator -- Let you use Firefox as in Vim

I read the article and it mentioned Vimperator, an add-on for Firefox. You would like it if you are a Vim fan. :-)

Tuesday, October 13, 2009

[QnA] Redirect the error message given by gcc compiler

I tried the redirect operator ``>'' to write the error and warning message to files, but it didn't work. There was nothing written into the files. Then, I found the solution:

$ gcc $> file

The ``$'' character is needed to make the redirection work.

Links:

[QnA] Mount smb folders from command line

Here are simple procedures to mount remote folders using command line interface.

$ sudo apt-get install smbfs
$ sudo mkdir /media/theFolderInYourPC
$ sudo mount -t smbfs -o username=theUsername,password=thePassword //theRemotePCsIP/theRemoteFolder /media/theFolderInYourPC

Links:

Monday, October 05, 2009

[Chat] Just write down what you've learned

When I was searching some solutions for data sorting in Python, I met this article: If you are in tech and don't have a blog.

This article has given two important reasons why we should have a blog to record something we've learned:
  1. For our own reference. We are human beings, and human beings are prone to forgetting things. This is why I write down things here.
  2. For someone else who needs the solutions you've just found or figured out. When someone else are trying to Google the solutions and you happen to have them in your blog, then people might have more chances to find these solutions. That's good!
Just blog it, for recording as well as sharing.

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. :-)

Monday, August 10, 2009

[QnA] Convert MOD to AVI using transcode

If you happen to have a JVC digital camera and it gives you MOD file, then you might need to convert the file into AVI format.

It's an easy task with the help of transcode:

transcode -i input.MOD -y xvid -o output.avi

Done. Happy. :-)

Friday, July 31, 2009

[QnA] Problems of NetworkManager in Ubuntu 8.04 (with unclear solutions)

Recently, I want to set up the wireless network of my PC in the ad-hoc mode. When I tried to follow the instruments found on internet, however, I found there is one thing strange of my NetworkManager. It had no ``create new'' option for me to add an ad-hoc setting. After some works, I realized that my NetworkManager's version was too old. It's necessary to use version 0.7 to have the ``create new'' function, but mine was version 0.6. So I started to find new version and began my hard works for the installation.

(Yes, I always have a question about this kind of situation: how can one install many needed packages via ``sudo apt-get install'' while he or she has no internet connection? Fortunately, I had connection to internet with an old wireless setting, and what I wanted to do was to create a new wireless setting in ad-hoc mode.)

With the complains given by the configure.sh, and the help of Google, I finally installed newer version of the NetworkManager.

(Later, on the internet, I found a much easier approach[1]. Just add two lines in the sources.list and update and upgrade, then restart the computer. After doing these steps, we can just use apt-get again to install the newer version NetworkManager. Although I did almost every steps, but I didn't know I should restart it. Maybe this was why I spent so many time and efforts for the installation. Anyway, I can't remember the details.)

Then, another problem followed. The icon of the newly installed NetworkManager showed ``disconnected'' state. The solution is pretty simple[2]. Just edit

/etc/network/interfaces

and keep only the first two lines.

Finally, I followed the instrument[3] and tried to set up the new connection in the ad-hoc mode. However, I didn't make it. What worst was every time I tried to create the ad-hoc connection, the original connection lost and I have to reboot my PC to make it come back.

Wait, ad-hoc host? Hmm, I noticed that what I have did was to creat an ad-hoc HOST? I don't want to create a host! There is already a ad-hoc host on another Windows PC, and what I want is just connect to the internet via the host!

Okay, I don't have enough knowledge about the network and related settings to find adequate solutions. I need to take a break. =__="



[1] How To: Network Manager 0.7 SVN (link)
[2] Ubuntu 8.10 Network Manager Doesn't Recognize Wired Network Device (link)
[3] Creating an adhoc host with Ubuntu (link)

Thursday, July 30, 2009

[SW] HMM source code/library

Two free source code/library of HMM:
I've installed it in my Ubuntu, but still have no time to play with it.
Written by Prof. Dekang Lin. The overall package looks not complex. I've compiled the source code with the included Makefile and the program works normally. I would dive into these code files to learn something about HMM's working principle and how to implement it.
I found this package when I was searching ``k-means HMM''. I've not tried it yet.

[Study] Useful websites for pattern recognition

I am learning pattern recognition and want to find useful information for PR beginners like me. Here are something I found and might be helpful:

This is a personal website with abundant content. Dr. Kardi Teknomo introduced some techniques used in PR or ML (machine learning) in a very friendly way. There are still many other topics which I don't know much, and may be also useful if you are searching them.

Lots of links. But the web page reads ``Due to a reorganisation we are not able anymore to maintain these files. They will be removed in the near future.'' I hope they keep maintaining these information if they have web space for it.

If you do read Taiwanese Han-characters (traditional Chinese), this website is another tutorial you could consult.

(The list might be extended when I find more.)

Sunday, June 14, 2009

[SW] ffmpeg: symbol lookup error

When I was trying to use ffmpeg to convert flv files into other format, it gave the ``symbol lookup error'' message. After searching solutions via Google, I found installing the latest version by compiling from the source code worked for me.

So, just remove the installed ffmpeg in Ubuntu, then go to ffmpeg website to download the latest source code. Follow the install procedure (./configure, make, and make install) then ffmpeg works well.

ffmpeg -i input_file.flv output_file.mpg

Wednesday, May 27, 2009

[SW] Ubuntu keyring... install then remove the libpam-keyring

Yesterday, I encountered a situation about which I really have no idea. When I attempted to open a remote directory of another Ubuntu PC, there came a dialog asking me for ``Unlock Keyring.''



Then I went to get some help from Google searching, and found the link. I followed the guidance, and didn't notice too many details in that article, and when I restart my Ubuntu today, I can't login into the desktop environment!

Fortunately, I have learned how to brows using elinks in virtual terminals, so I went back to the link just mentioned and found what I have done yesterday. Then I remove the setting did yesterday in the /etc/pam.d/gdm. Reboot, and everything was normal as usual.

I still don't know very well about the concept and related setting of the keyring. Listed below are some links I found might be useful for (my own) further reading.

Tuesday, May 26, 2009

[SW] Ekee -- LaTeX equation editor

Yes, another handy tool for people who knows how to edit equations in LaTeX. Ekee, was named eqe, is a equation editor let user produce pretty equations interactively. Furthermore, you can drag and drop the equation to some other supported applications such as OOo Impress.

You can save the result like this:







It is also possible for you to reopen this equation, even saved in png file, with ekee for further editing or modification.

Sunday, May 24, 2009

[QnA] How to increase the number of tty in Ubuntu

Because I like to work in virtual consoles (ttys), sometimes I feel only six ttys is not enough. But, how to increase more ttys than the default number, i.e. six, given by Ubuntu? I found there are many tty* in /dev, so I guessed there should be some way to ``enable'' these virtual consoles.

After searching on the internet, I got some information:
  • To open a tty, the file /etc/inittab is the key
  • Ubuntu has no inittab, which has been replaced by the files in /etc/event.d
So, I listed all the files in /etc/event.d and found there are files named from tty1 to tty6. Then I check the contents of these tty* files and found all of them have almost same setting inside, like the follows.

# tty1 - getty
#
# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc2
start on stopped rc3
start on stopped rc4
start on stopped rc5

stop on runlevel 0
stop on runlevel 1
stop on runlevel 6

respawn
exec /sbin/getty 38400 tty1

Ah, the rule emerged. I copied the tty6 to be tty8 to tty12 (tty7 is for the GUI desktop, as I know...), then replaces the string ``tty6'' in all the copies to their corresponding tty number. Finally, I have 11 virtual consoles, i.e., tty1 to tty6 and tty8 to tty12.

[Heli] Raquel Bellot -- Amazing Lady 3D Fly

Do you know how to perform 3D fly with the RC transmitter behind you or on your head? Raquel Bellot, a Spain RC helicopter flyer, showed you the way she did:

http://www.youtube.com/watch?v=II-V-561ro4

Some photos here: AHS 2008

[SW] Using templates of OpenOffice (Writer)

One important thing I have learned from using LaTeX might be the concept of ``separating the style and the content.'' This concept is actually universal in various works. For example, the CSS file for the HTML files. We can set all the styles needed in one file, and use this file with many different files which share the same style settings. This concept makes thing easier and more efficient as we dealing with more and more files.

The same concept is also true when we work with the WYSIWYG word processor. Most people use MS Office, but I preferred the OpenOffice due to its ``open'' nature. I am always looking ways which can help me use the word processor more efficient or more professional. I don't want to just utilize a powerful software with its maybe only 2% or 3% capability. If you can explore more deeper ways to use a software, it often means you can handle the software better and do more things with it. In addition, in my own opinion, to dig into the advanced function of a software is to respect the authors who worked hard to develop the software.

When using the OpenOffice Writer, a template could make things easier. With the help of the template, you can compose different files and all of them have the same style. You can change the style of every detail items by yourself, just as most word processor users as I know, but a better way to handle the style is to set up a template, then adopt it for further file editing.

There are many tutorials available. I listed some I found and regarded useful as the follows:
So far, the only inconvenient feature I found is the way of applying new template to an existing file. It seems no ``apply new template'' function in OOo Writer, so the user has to rebuild a new file from the new template, and then copy and paste all the content from the old file to the new one.

Friday, May 22, 2009

[SW] Install the newest Scilab on Ubuntu

Here is a clear guidance shows how to install the newest stable Scilab from the binary package. I have just remove the Scilab-4.1.2 installed via Synaptic Package Manager, and installed the Scilab-5.1.1 downloaded from the website.

Everything looks smooth so far. At least the GUI interface looks better.

[SW] Scilab -- reading a data file

To read data files we have generated by other means into Scilab, use ``read'' seems a convenient way.

Don't use ``load'', which looks like a function to load variables saved by Scilab using ``save'' that produces binary data files.

Take one of my data files as example, the data file consists of four columns: time, ax, ay, and az1

1.00000 0.139641 -0.139664 0.980796
1.03125 0.125245 -0.152101 0.975367
1.06250 0.143240 -0.153878 0.966317
1.09375 0.141441 -0.157431 0.964507
1.12500 0.127045 -0.139664 0.964507
1.15625 0.134243 -0.157431 0.968127
1.18750 0.137842 -0.148548 0.982606
1.21875 0.128844 -0.148548 0.975367
1.25000 0.127045 -0.144994 0.984416
1.28125 0.146839 -0.153878 0.971747
1.31250 0.150438 -0.148548 0.966317
.
.
.

Then use ``read'' to get the overall data as a matrix.

data = read('dataFileName',-1,4); // -1 means we don't know the data number of row
data_time = data(:,1); // assign the 1st column to the 1st variable
data_accx = data(:,2); // assign the 2nd column to the 2nd variable
data_accy = data(:,3);
data_accz = data(:,4);

For the convenience of future using or modification, we can save the above script as the fooFileName.sce file. Next time when we need the script, just use ``chdir'' to change the working directory where the sce file exists, then use ``exec fooFileName.sce'' to execute the script.

Wednesday, May 20, 2009

[Chat] The Linux Counter


Here is my registered number of The Linux Counter. The purpose of this ``counter'' is for fun, so I also registered for fun. :-)

Monday, May 04, 2009

[SW] CLI: playing the video in ASCII art

I am just a normal PC user, but I like working with command line or text mode very much. The reason might be I think text mode is ``pure'' and ``simple.'' Of course, the word ``simple'' never mean it is simple for the users, but means the way of appearance or presentation.

After learning something useful in command line, e.g., writing and debugging code (gcc and gdb), surfacing the internet (elinks or w3m), and play audio files (mp3blaster), I began to curious about how to play video in command line mode.

To play a video, there are also methods to do it with the command line.

For VLC, try:

vlc -I ncurses yourVideoFile

For Mplayer, try:

mplayer -vo aa yourVideoFile
mplayer -vo caca yourVideoFile

where -vo means video output driver. The drivers aa and caca are used for monochrome and color ASCII art video output, respectively.

The results are funny. When you look at the monitor at normal distance, you may hardly figure out what are you watching. There is only rapidly changed ASCII symbols! As you step back form the monitor, however, you will find all the dynamic images become clear and meaningful. You are watching video consists of many ASCII symbols!

Here is one screenshots captured on my monitor. Use mplayer with -vo caca:
(Original video can be viewed on YouTube: 元ちとせ-春のかたみ. By the way, I love songs of 元ちとせ [Hajime Chitose] very much.)















Of course, the above image was captured by playing the video using Terminal in the desktop environment (pty?). I don't know how to output the ``image'' in the real command line mode (tty?).

Also, there are still some problems I don't understand. The first one is when I invoke the vlc with -I ncurses option using pty, the video still be played via the GUI but not the expected ASCII way. Another problem is that the aa option of mplayer cannot paly the video properly. Only part of the image was shown, as the following scrrenshot:















The final problem is that, when invoked under the tty, the mplayer did not do these works as well as it did under the pty. The reverse is true for vlc, however. Maybe someday I will realize the underlying reason about all these problems... maybe. :-p

[SW] SoundConverter

I was searching a software to convert my ogg files to mp3 format (for my mp3 player, which doesn't know the ogg files). Several days ago, I found the SoundConverter, which is an application in GNOME environment.

If you have some sound or music files to convert the format, I think the SoundConverter is a good choice.
---
[edit: 2010/12/28]
To use the SoundConverter in the command line, here is an example to convert *.ogg to *.mp3.
(Why bother to convert ogg to mp3? Because I have an old music player which doesn't support ogg format! :-p )

Suppose you are in the folder containing ogg audio files:
$ soundconverter -b -m audio/mpeg -s .mp3 *.ogg

Tuesday, April 28, 2009

[SW] View images in text mode (CLI)

I was just wondering how to view images in command line interface (CLI). So, I typed keywords to Google and find there is a package named ``fbi'' for this kind of purpose.

After installation, however, the fbi did not work in my Ubuntu. I removed it, and reinstalled again when I found the solution.
sudo vim /boot/grub/menu.lst
Search for ``defoptions=''
add the ``vga=791'' under the line of ``# defoptions=quiet splash''
Then
search for ``/boot/vmlinuz''
add ``vga=791'' to the end of the line

That's funny, and that lets me do more works under text mode console. :-)

Monday, April 27, 2009

[SW] Change filenames, using: ls sed xargs, and mv

I found the instruction (in Chinese) and made some modification to meet my own needs.

For example, I have several png files named in the form of dataCounts_*_g.png, and I want to mv them into the form of *_g_f.png. All I have to do is to delete the ``dataCounts_'' part and insert ``_f'' into ``_g.png.''

Because I don't need to change all the filenames under the working directory, it is not necessary to use find. Using ls is enough.

Furthermore, I need to change more than one part of the original files, so I apply the substituting function of sed twice. Finally I have the commands as the follows.
ls *.png | sed -e p -e 's/dataCounts_//' -e 's/_g/_g_f/' | xargs -n2 mv

Friday, April 24, 2009

[SW] Grace -- a WYSIWYG 2D plotting tool

I tried to write a shell script to cooperate with the gnuplot, and encountered some problem when I wanted to modify my script to be more ``useful.'' After try and try, I decided to post my question on Google Groups for help (here is the thread). Then although I didn't get direct reply yet, the kind user gave some useful information, that is, the plotting tool Grace.

From the Grace's homepage, it looks really good at plotting and also analyzing data. I have not start to try and use it, but I will, later.

Thursday, April 23, 2009

[Chat] Security and open source software

Here is an article written by Robert Dewar, titled as ``Open Source Software for High Reliability Applications: Is it safe?.''

The author argued the benefit of making the software open sourced. He believed that, by doing so, the software could be safer and we could avoid using software containing bugs which no one can discover because the source code is kept privately.

Besides, the comment left by the reader jogafe also gave me some new opinions.

Friday, February 27, 2009

[SW] JabRef -- An easy-to-use reference manager

When I was a 100% Windows user and had no idea about application software out of the scope of Microsoft's, it was a nightmare to write a list of reference for my paper or report. It's possible for me to survey and gather lots of papers in electric forms (e.g. *.pdf files) and then store them in folders of the hard disk. When it's time to list them out or to recall what I've read from those papers, however, I always got lost in those files, especially after a period of time, say, one month or even longer.

Besides the difficult of managing the papers I have found, there is another problem when I was composing my paper. Writing the reference listed in the final part of paper had been a bit of cumbersome work, if you type every single terms by yourself, just as what I had done. Actually, I am not sure whether the MS Word has clever ways, I mean, really clever ways, for the user to add the reference list to his or her own articles, but I was always type all the words of the reference list directly. It's apparently not a smart approach. What worse is that you, just like me, probably don't master all the styles of the reference you cite. For example, how to abbreviate the author's name? Put the first name in front of the last name or exchange their orders? Where to insert the volume number of a journal? To use a comma or a period? All the details will consume your energy or at least bother you every time when listing the reference.

Let JabRef do these works for you.

JabRef can help us to manage the many papers we have. Assume that you have dozens of papers saved in folders of your computer, you can link files to the items of your JabRef list. It's easy for you to group the papers, and every single paper could be assigned to more than one group. This makes life easier, because you can find papers of certain group even they are saved in different locations in your computer.

Another nice feature of JabRef is it allows you to input the information of reference without caring the format. There are fields for you to key in necessary and optional information of the papers, then the JabRef will arrange these information into the bib file which is extremely useful for composing articles by using LaTeX.

The usage of JabRef is quite easy. I have never refered to its help documents seriously and I still can use it happily.

Here are some screenshots of JabRef. Just take a look at it, and download it for a try.

Tuesday, February 24, 2009

[SW] GSL -- GNU Scientific Library

God, the open source community always make me surprised!

About 2 or 3 days ago, when I was searching for some open source code to add Gaussian random noise to my artificial data, I found the GSL (GNU Scientific Library). It's amazing. Although I am not very good at programming, but after some trials and with the help of examples, I produced Gaussian distributed random noise successfully! And there is pdf (probability distribution function) function for me to check the Gaussian distribution data.

Big thanks to all the people contributing to the open source world!

Here is the source code I used to generate Gaussian distributed random noise (first image), and also the pdf of the generated random noise (second image).

/*
* gcc -Wall rngGussian.c -o rngGussian -lgsl -lgslcblas -lm
*/

#include <stdio.h>
#include <time.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>

int main(void){
const gsl_rng_type * T;
gsl_rng * r;

double randomNum;
double randomPdf;
int i;

gsl_rng_env_setup();
T = gsl_rng_default;
r = gsl_rng_alloc (T);

gsl_rng_set (r, time(NULL)); /* use time() to generate the seed */
for(i=0; i<1000; i++){
randomNum = gsl_ran_gaussian(r, 1.0);
randomPdf = gsl_ran_gaussian_pdf(randomNum, 1.0);
printf("%lf %lf\n", randomNum, randomPdf);
}

gsl_rng_free (r);
return 0;
}