Thursday, September 30, 2010

[HOWTO] Change order of buttons on the menu bar

In Ubuntu 10.04, the default theme style looks like MacOS. Thus, the button on the menu bar follows the order of MacOS also which is "close", "minimize" and then "maximize" placed on the top right corner.


Some people might not like this arrangement and want to change back to traditional one.

To do so, open a terminal
$ gconftool-2 --set "/apps/metacity/general/button_layout" --type string "menu:minimize,maximize,close"


If you want to switch them back to the left corner
$ gconftool-2 --set "/apps/metacity/general/button_layout" --type string "close,minimize,maximize:"


In fact, you can play around with the order to suit your need. Have Fun!!

Wednesday, September 29, 2010

JS1k

I just know that there is a competition about javascript called JS1k. As the name self-explained, this is about to write a javascript program with 1k only. Unfortunately, when I know this event, the deadline passed. The rules are
  1. Create a fancy pancy Javascript demo
  2. Submissions may be up to 1k. (And not crash)
  3. Externals are strictly forbidden, unlike "some" contests. (Good luck minifying jQuery though!)
  4. Must work on current fx, sa, ch and o. (Let's level the playing field)
  5. Minification and hacks allowed. (Go nuts)
  6. Bonus points if your submission fits in one tweet ;)
  7. Last day to submit is 10 September 2010
If you are interested, you can visit JS1K home page. Here is the top one and the author shows his source code with comment in his website, http://marijn.haverbeke.nl/js1k.html

Tuesday, September 28, 2010

[HOWTO] Use IBus in Ubuntu

Since I don't know why I can't install fedora 13 in my computer, I installed Ubuntu 10.04 instead. The first thing I need to do after installation is to type Chinese. When I used Fedora 12, I used to use gcin as my favorite input method. So, now I have a chance to switch to IBus as the default input method in Ubuntu is IBus.

To start IBus
Click System >> Preferences >> IBus Preferences

You will see a message which reads:
IBus daemon is not started. Do you want to start it now?
Then simply click, "Yes"

After clicking yes, the following message shows:
IBus has been started! If you can not use IBus, please add below lines in $HOME/.bashrc, and relogin your desktop.
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
You can try to follow the message if you have any problem, but I skip it since I didn't have any.

IBus Preferences
In the general tab , you can check "Show input method name on language bar" (I suggest to do so).
In the input method tab, you can add any input method you want.
I use Cangjie(倉頡) as my main input method, and by default, there is a input method named cangjie(m17n) in the list. However, I don't like this one since it insert a space after every character.
I prefer to use cangjie3(倉三). The way to install it is to use apt-get
open a terminal and run
$ sudo apt-get install ibus-table-cangjie

After installation
you can find cangie3 under Chinese menu. Then click add.

Let IBus start automatically when restarting my computer
Go to System >> Preferences >> Startup Applications
Click "add" button and input following details
Name: IBus daemon
Command: /usr/bin/ibus-daemon -d
Comment: start IBus daemon when Gnome starts

To use IBus
press control + space to enable or disable the IBus

Friday, September 24, 2010

[HOWTO] Convert Simplified Chinese to Traditional Chinese and vice-versa (繁轉簡)

Now, I am implementing a program that need to have a database pre-stored some data. I grep the data from internet but those are simplified Chinese. I need to convert them into traditional Chinese. This can be done using one command

$ iconv simplified_chinese_input.txt -f utf8 -t gb2312 | iconv -f gb2312  -t big5 | iconv -f big5  -t utf8 -o traditional_chinese_output.txt


This involves three steps actually,
1. This first convert the text file from UTF8 to GB2312 (Simplied Chinese) 2. Then, convert the GB2312(Simplied Chinese) to Big5 Encoding (Traditional Chinese) 3. Finally, convert the Big5 to UTF8 text file

In fact, you can change the order so that it can convert traditional Chinese to simplified Chinese
$ iconv traditional_chinese_input.txt -f utf8 -t big5 | iconv -f big5 -t gb2312 | iconv -f gb2312 -t utf8 -o simplified_chinese_output.txt


If you need to do this many times, you can store it as a Shell Script named S2T.sh with following content.
#!/usr/bin/sh
iconv $1 -f utf8 -t gb2312 | iconv -f gb2312 -t big5 | iconv -f big5 -t utf8 -o $2


Then, set it to be executable
$ chmod u+x S2T.sh


Finally, use it with
$ ./S2T.sh input.txt output.txt


Hope it helps.

Communicate Google with Command

On Linux, we offer need to type command and I think using command is better than by clicking most time. This is because I need to control the mouse precisely to certain location. This is not convenient for me at all. In addition, I don't want to leave my hand out of the keyboard, so I remember some useful command such as using Ctrl+L in Firefox to type URL instead of using the mouse to click on the url field. I can navigate different web without leaving keyboard. If you are vim experienced user, I think you should like this firefox plugin - Vimperator which you can navigate webpage with your keyboard only.

Now, Google provides many web applications such as Gmail, Contact, Google Docs and this blog Blooger, etc. Fortunately, Google provides a command line tool for them also named GoogleCL http://code.google.com/p/googlecl/. This is a command line tools for the Google Data APIs.

You can do many things using this command tools just like

1. Blogger - create a new post
$ google blogger post --title "create post using GoogleCL" "I can create a new post in command line"


2. Picasa - upload new image to Picasa
$ google picasa create --title "GoogleCL Photos" *.jpg


3. YouTube - upload new video to YouTube
$ google youtube post --category Education linux_command.mpg


For more usage, you can visit the GoogleCL official website. You will find it is extremely useful and you can cooperate with Crontab with GoogleCL, you can do more such as creating a Calendar everyday.