I've uploaded a PKGBUILD for ibus-unikey to the ArchLinux AUR. You can install it with yaourt like this:
yaourt -S ibus-unikey
If you don't want to build from the source, you have to install all the dependencies first:
pacman -Sy gcc gconf gtk2
And then download and install the binary package
Then add the following to your .bash_profile

export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus

PS: Ok, there is no spyware/malware/rootkit in this binary package! If you don't trust me, don't use this method and build the package yourself (this is the way I recommend)
I've just joined a project as a freelancer to customize a commercial e-commerce solution (so let called it EP). OOTB, the email sending of EP does not support authentication, which is a weird thing for such a cool product like that. Actually, EP does declare an JNDI mail session in the context, but in the code they don't use it. With the source code of EP in hand, things get much easier. First, we declare a JNDI resource in our application context (either in your context file in the conf/Catalina/localhost/ or in your context.xml under META-INF inside your war):
<context>
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"
username="my.smtp.user"
password="my-secret"
mail.debug="false"
mail.transport.protocol="smtp"
mail.smtp.host= "xxx.xxx.xxx.xxx"
mail.smtp.auth= "true"
mail.smtp.port= "25"
mail.smtp.starttls.enable="true"
description="Global E-Mail Resource"
/>
</context>
And put those in your web.xml file:
<resource-ref>
<description>Email Session</description>
<res-ref-name>mail/Session</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And now, in your Java code, you will use this email session like this:
Context initContext = new InitialContext();
Context context = (Context) initContext.lookup("java:comp/env");
Session mailSession = (Session) context.lookup("mail/Session");
//Your code to send the email goes here
If you get a java.lang.ClassCastException, don't worry, this is a known issue. It's because you have multiple Java Mail jar file and Java Activation Framework jar file in your CLASSPATH!
Hope that may help!

Moving to Wordpress

I've just imported all my post and comments from blogger.com to my wordpress.com account. So far so good! I've also cleaned up all of my posts on wordpress.com to make it *cleaner*. Wordpress.com does come with a cool code syntax highlighter as described here http://support.wordpress.com/code/ , the number of programming language it supports is quite impressive.
By the way, I've just found out some cool tricks to use the built-in code highlighter of wordpress. Instead of typing [sourcecode language='css'] code here [/sourcecode], you can use one of the following:
  • [source language='css']code here[/source]
  • [code language='css']code here[/code]
  • [sourcecode lang='css']code here[/sourcecode]
  • [source lang='css']code here[/source]
  • [code lang='css']code here[/code]
  • [sourcecode='css']code here[/sourcecode]
  • [source='css']code here[/source]
  • [code='css']code here[/code]
Enjoy!
I always use PostgreSQL for every project in my company, both in development and production. Recently, I have to use MySQL (version 5.1.36) in my new project because the client uses MySQL for deployment. The first step I have to do is to setup MySQL on my laptop for the project development, I'm using ArchLinux so the steps are straight-forward:
  • Install MySQL with the pacman: pacman -S mysql
  • Start it up: /etc/rc.d/mysqld start
  • Set the root password: /usr/bin/mysqladmin -u root password 's3cr3t'
  • Execute the recommended script to secure the new MySQL installation. Basically, the script will remove the test database, the anonymous users and only allow connection from localhost: /usr/bin/mysql_secure_installation
Here come the gotchas!
I open up MySQL Administrator and connect to the new 'shiny' server with the user 'root', everything is fine. I create a new user, then a new catalog and grant all the neccessary permissions for the new user to use the new catalog. I fire up Tomcat which contains my web application (Spring + Hibernate), the application creates a connection pool (c3p0) at startup to improve performance, but it failed with the error message Connection refused". Hmm...strange! Googling for a while, I was suggested to put this into my /etc/hosts.allow the following line:
mysqld: 127.0.0.1:ALLOW
Restart my web application, now the error message is different Communications link failure .... Open up the configuration of MySQL (/etc/my.cnf), I found out that the skip-networking is on! Here is the documentation about this entry:
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
Comment that entry (by adding the # before it) and restart the mysql server. My web application now can startup properly!
Gotchas solved.
PS: I'm totally new to MySQL, this is my way I made my application work with MySQL, if you have a better setup, I'm glad to know :)
I'm a "fanboy" of OSS4 since I switched from Fedora to ArchLinux. OSS4 is a great sound module except for... its mixer program, ossxmix:
It's not a GUI, it's a GSDI or Graphical Sound Developer Interface :). I have no idea what the functionality it provides, so my approach to use this kind of application is try-and-see.
Recently, I've upgraded my kernel to 2.6.30.x and the sound on my laptop get distored. I googled for solution many hours without any luck, it's time to solve this by myself. Fire up ossxmix, try-and-see alot of settings and I found this:

Hope this may save you some time.
Google App Engine (GAE) has been around for some time. But I don't have time/chance to try it out. A couple of days ago, I registered and activated my account with the help of a close friend in the US because Google uses SMS for the activation process and Vietnam is not in the list of supported countries of GAE right now (or any Vietnamese carriers either).
So what is my first application? It's a IP lookup application. So why? A couple of days ago, my co-worker complained about site providing the same service because it contains too much distracted content. He just want a deadly simple alternative :). Here is my answer http://ip-bot.appspot.com
This is the first draft-unstable-alpha-0 version :), so don't expect to much. I will make it a *feature-rich* site but the simplicity is the top priority. So stay tuned.
I've switched to ArchLinux from Fedora a couple of months ago and I really miss the mirror of Fedora on FPT (my current ISP). A few days ago, I wrote an email to ask the FPT mirrors admin to add a mirror for ArchLinux to their mirror systems. Here is what I wrote (in Vietnamese):

Gởi Admin mirror của FPT.

Arch Linux (www.archlinux.org)
là một distro khá phổ biến hiện nay (Arch đang đứng trong top 20 distro
phổ biến theo Distrowatch.com). Nếu được, mình xin admin cài đặt một
mirror tại http://mirror-fpt-telecom.fpt.net/. Mình gởi bạn địa chỉ URL của ArchLinux repository: ftp://ftp.archlinux.org/

Hi vọng mình sớm được thấy ArchLinux repositories sẽ xuất hiện trong danh sách mirror của FPT.
Cám ơn Admin rất nhiều!

Basically, what I said is ArchLinux is a popular distro, it's in top 20 of DistroWatch (02 Mar 2009) and asking them to setup a mirror for ArchLinux.
And here is their reply (in Vietnamese):
Chào ,
Cám ơn về ý kiến đóng góp của bạn. Chúng tôi sẽ mirror archlinux trong thời gian sớm nhất.
Mong nhận được những ý kiến đóng góp tiếp theo của bạn.

Mr.Admin

What they said is: "Thanks for your suggestion. We will mirror ArchLinux ASAP. We hope to receive your suggestions in the future". I have changed my real name and the name of the author of the above email. It's great news for Arch lovers in Vietnam.
At the moment, FPT have mirrors for the following distros: CentOS, Debian, Fedora, Gentoo, Mandriva, openSUSE, Slackware and Ubuntu.
I've just made a PKGBUILD (including the source code) for scim-unikey version 0.2a~20090218 to the AUR. On the main page of the project, the latest stable version you could find is 0.1.2, which is quite old at the moment, and they don't have a public Subversion url right now. The author runs a thread on Ubuntu-vn forum (in Vietnamese) to call for testers for the next release (0.2) of the project. The packaging process is a little bit tricky, because the project does not have a valid url to fetch the source code during the build process, so what I've done is to set the 'source' of the PKGBUILD file to the source tarball of scim-unikey in the same directory like this:
source=($pkgname-$pkgver.tar.bz2)
You have to make sure that the file scim-unikey-20090218.tar.bz2 is located at the same directory as the PKGBUILD file.
Then run the command:
makepkg --allsource
This will create a file .src.tar.gz, upload that file to the AUR to share the fun with others!
To install this package, simply run the command:
yaourt -S scim-unikey
Follow the instructions (on screen) after you install the package to configure scim-unikey.
There is a small toolbar pop up every time a new application is executed, it's very annoying, to disable it, just Right-click on the Scim icon on the system tray, select Hide Toolbar.
Troubleshooting:
-If you are a Java developer and Eclipse is your IDE of choice, it's likely scim-unikey will not work properly with "vanilla" Eclipse setup. Here is the my bug report. Solution is simple, just right-click on your main editor, select Input Method --> Scim Input Method or Scim Bridge Input Method depending on which one you are using.
Update:
13th March 2009: update scim-unikey to version 20090313 to the AUR.
16th May 2009: update scim-unikey to version 0.2.0 to the AUR.
11th July 2009: update scim-unikey to version 0.3~r32 to the AUR to fix a problem with scim 1.4.8+ on Firefox and Epiphany
14th September 2009: update scim-unikey to version 0.3.1

Xvnkb is now in AUR

I just submitted my first package to the AUR, it's xvnkb-0.2.9a. If you are using Yaourt, you can install it by entering the command:
yaourt -S xvnkb
After installing, you have to put this to your .bashrc:
export LD_PRELOAD=/usr/lib/xvnkb.so
That's it! Don't forget to vote for it after the installation :).
I have an annoying problem with xvnkb on Arch, it uses CPU a little higher than normal, I've never experienced this before on Fedora or Ubuntu.
Another thing need to mention is GIMP give me a segmentation fault at start up with the above LD_PRELOAD. This is expected as many people experienced this before. A quick and dirty workaround is to unset the LD_PRELOAD right before launching GIMP. In the terminal, do this:
unset LD_PRELOAD;gimp &
If you don't prefer the "command-line", create a small executable bash script file and put it in your PATH, I called it gimp-launcher.sh with the following content:
unset LD_PRELOAD;gimp $1 &
Next, find the .desktop file of GIMP (I'm using Arch and it's located at /usr/share/applications/gimp.desktop, your distro may put it in a different place), replace the line Exec and TryExec with:
Exec=gimp-launcher.sh %U
TryExec=gimp-launcher.sh
And now, you can use GIMP as normal.
I've filed a bug report about this, hopefully the GIMP developers will fix this in the next release.
Sound system on Linux is confusing, both for end users and developers. When I was using Fedora, I used Alsa for all of my sound needs, from listening to music, filming and gaming. Recently, I've switched to Arch Linux and installed OSS4 for my sound. The sound quanlity is quite better than Alsa but I've got an annoying problem: all the gstreamer-based music player uses CPU too much, about 40%-60% (rhythmbox, totem, exaile) when playing mp3 files. After googling, I found this, try this on my system:
/usr/sbin/vmixctl detach /dev/dsp
/usr/sbin/vmixctl attach -r /dev/dsp
What it does is to detach the virtual mixer and reattach without recording setting. The CPU usage down to 6-10%, cool!
But after reboot, the CPU usage of gstreamer-based music player still high. It seems that our hack is not persisted. So I have to edit the /etc/rc.d/oss to detach and reattach without recording ability, here is my /etc/rc.d/oss:
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
start)
     stat_busy 'Starting Open Sound System'
     if /usr/sbin/soundon
     then
             add_daemon oss
             /usr/sbin/vmixctl detach /dev/dsp
             /usr/sbin/vmixctl attach -r /dev/dsp
             stat_done
     else
             stat_fail
     fi
     ;;
stop)
     stat_busy 'Stopping Open Sound System'
     if /usr/sbin/soundoff
     then
             rm_daemon oss
             stat_done
     else
             stat_fail
     fi
     ;;
restart)
     $0 stop
     $0 start
     ;;
*)
     echo "Usage: $0 {start|stop|restart}"
esac
Now, all the gstreamer-based applications are now playing nice with my CPU, but my box lost the ability to record sound :(. If you have a better solution, please share with me.