Awesome + Xephyr + Devil’s Pie
Posted by on January 8, 2012
I do a lot of source code editing. Have multiple files opened is common. I used to open multiple gnome-terminals, each one with one file opened. In this way, a lot of screen
space was wasted by the gnome-terminal title bar and the window’s borders. Another way is to use split windows in vim. But still, some space was wasted (split window’s orders) and mouse selection (terminal mouse support, not the vim mouse support) does not work well. If you have vertical-split windows and try to select more than one line of text, you’ll end up selecting texts from both windows. Some time ago, I tried tmux. I didn’t use the session detach feature but the window spliting was great. The window borders were only one pixel, no space wasted. However, the terminal mouse selection problem remained.
Yesterday, I spent a few hours searching the internet and found a way to use gnome-terminal + vim without wasting precious screen space: Awesome + Xephyr + Devil’s Pie.
The concept is easy, I set up a second desktop (xserver) using Xephyr (my main xserver is running gnome desktop + metacity). In this second desktop, I run the Awesome
window manager. I run all the gnome-terminal + vim inside the second xserver. The Awesome window manager is really awesome. There’s no window decoration for gnome-terminal so, no space wasted. I can resize all gnome-terminal and swap their position on the screen easily. Terminal mouse selection is also working as desired. But then, the second xserver is running inside a window under metacity. Thus, It has a title bar and window borders. To remove the window decoration, I use Devil’s Pie.
Install all the software packages (as root):
# aptitude install awesome devilspie
Create a second xserver (as normal user):
$ DISPLAY=:0 Xephyr -keybd ephyr,,,xkbmodel=evdev -ac -screen 1280x776 -br -reset -terminate :1 2> /dev/null &
- You may want to change to screen size to your need.
- The second xserver will be using the DISPLAY=:1
- `-keybd ephyr,,,xkbmodel=evdev’ is required to workaround keymap bug. See links below:
Start the awesome window manager in the second xserver:
$ DISPLAY=:1 awesome &
- Now you should see the initially black window of the second xserver comes alive. The awesome window manager is quite different from the metacity, so a bit of learning how-to-use is needed.
Remove the title bar of the second xserver:
$ mkdir ~/.devilspie
$ cat >~/.devilspie/Xephyr.ds <<EOF
(if
(is (window_class) "Xephyr")
(begin
(undecorate)
(geometry "1280x776+0+24")
)
)
EOF
$ devilspie -a &
- The window containing the second xserver has the window_class “Xephyr”.
- You may want to change the geometry to fit the screen size when firing up the second xserver.
- The geometry “…+0+24″ is to reposition the window after removing the title bar.
So now, I’m using the following script to fire up my source code editing session:
#!/bin/bash killall devilspie devilspie ~/.devilspie/Xephyr.ds & DISPLAY=:0 Xephyr -keybd ephyr,,,xkbmodel=evdev -ac -screen 1280x776 -br -reset -terminate :1 2> /dev/null & sleep 2 # wait for the xserver to come up. DISPLAY=:1 awesome &
Witty and GWT
Posted by on December 20, 2011

I’ve been using GWT (http://code.google.com/webtoolkit/) for the past 2 years. Since a week ago, I started to try a new tool called Witty (http://www.webtoolkit.eu/wt/). I first heard of it a year ago I think but didn’t try it out at that time. Now, I’ve completed a small project with Witty and I feel good. Much like the GWT, Witty uses C++ as the programming language. The main difference between Witty and GWT (besides the programming language) is the way browser and server communicate. In GWT, I need to specifically initiate a call to the server, get the response and process
it, before displaying the result on the page. In Witty, I do not create any calls to the servers. I just need to code in the same way like coding a normal GUI application. Witty takes care of making calls to the server when needed. This can be a pros or cons depending on how you see it. In GWT, client and server are clearly separated. I can replace the server side Java classes with PHP/CGI if needed, as long as the PHP code can encode/decode the messages sent to/received from the browser. Not sure if Witty can do that. Anyway, for all my GWT projects, I’ve never used other languages for the server side processing. This advantage in GWT may not be really useful (for me at least).
One advantage for using Witty (besides C++ being my favourite programming language) is the built-in support for creating charts. Witty comes with classes for building simple and beautiful charts. Charting support is missing in GWT. I’ve been using the clientsidegchart or gchart (http://code.google.com/p/clientsidegchart/) for my GWT projects. It’s a very powerful library that allows you to create very sophisticated charts. Unfortunately, the latest release (v2.7) was in June 2010 and the last SVN activity was in the August 2010.
So far, I’m happy with Witty. Although my small Witty project is far less complex then the GWT’s, I think I’m ready to switch. Finally, back to the land of C++. Oops, I forgot to delete pointers in my source codes! Ughhh… It’s all Java’s fault.
火龙“花”?
Posted by on November 13, 2011
火龙果(也称龙珠果)的外形独特、果肉清甜,可它的花究竟长什么样?前两天,笨珍家里的火龙果树开花了,拍了几张相片让大家见识见识。

含苞待放的模样。单是花苞就和一般的花朵不同,气势十足。

午夜十二点左右,花瓣完全张开!好大一朵、纯白的花瓣、淡黄的花蕾。

来个侧拍。
火龙果树只在半夜才开花。峰、蝶应该都睡了,不晓得怎么传播花粉。花开多长的时间?不晓得。可是天亮后,它就成了下面的模样。

照片中的这一朵并不是上面三张照片中的同一朵。当晚有两朵一块儿绽开,但距离有些远,没法一块儿入镜。气势十足、外形独特的花苞,绽开后却是意外的纯白和淡黄。成熟后深红的果实、殷红的果肉,大自然用色真大胆。

Extra: 一旁的树上,看见吗?大概有30cm长哦…
Load-balancing Tomcats using Apache Web Server.
Posted by on November 2, 2011
My paid job required me to setup a load balanced system consisted of 2 tomcat servers and 1 Apache Web Server. The requirement was simple:
- There were 3 machines (1 for Apache and 2 for tomcat).
- Incoming traffic went to Apache and then forwarded to the tomcats.
- There were no need to maintain the sessions. Round robin could be used for load balancing.
- The setup should work as a HA: If one tomcat went down, all traffic should go to the working instance.
Make sure both Tomcats and Apache web servers are working fine and they can `talk’ to each other. Then, just add the following into the Apache web server’s configuration file:
# Load all required modules.
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
LoadModule status_module /usr/lib/apache2/modules/mod_status.so
# Tomcat must reply within 60 seconds or the connection will timeout.
# All incoming traffic with the URL ending with `/myservice' will be
# sent to one of the two tomcats.
ProxyTimeout 60
ProxyPass /myservice balancer://tomcatcluster
ProxyPassReverse /myservice balancer://tomcatcluster
# Apache talks to Tomcat using AJP (or commented HTTP) protocol.
# `loadfactor' determines the load distribution for the members.
# Use `ping' to test whether the member is up before sending the request.
<Proxy balancer://tomcatcluster>
BalancerMember ajp://tomcat1_ip:8009/myservice loadfactor=1 ping=100
BalancerMember ajp://tomcat2_ip:8009/myservice loadfactor=1 ping=100
# BalancerMember http://tomcat1_ip:8080/myservice loadfactor=1 ping=100
# BalancerMember http://tomcat2_ip:8080/myservice loadfactor=1 ping=100
</Proxy>
# Point your browser at http://localhost/balancer-manager from the machine
# running the Apache Web Server to access the load balancer manager.
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Allow from localhost ip6-localhost
</Location>
Restart the Apache Web Server and start sending traffic to it.
Using Logitech K400 wireless keyboard with Linux
Posted by on October 30, 2011

Besides the camera, I also bought a very basic computer yesterday equipped with the Logitech K400 wireless keyboard. It will be placed at home beside the LCD TV and be used as a media player and for some light-weight computing tasks. Linux is my favorite OS but I’m not sure whether the Logitech K400 can be used. The Logitech website only specify it supports MS Windows. This post is to confirm that K400 does work with Debian and Ubuntu. It works out-of-the-box with no configurations required.
Sony DSC-HX7V
Posted by on October 29, 2011

今天恨下心给自己买了个不便宜的生日礼物,Sony DSC-HX7V。一直想要有个好相机,一度还想买个防水机,可是都没买下手。一直到 Sony DSC-HX9V 的出现,Photography Blog 给了它极高的评价,终于我有个目标了。HX9V 在大马没卖,本来是打算到新加坡买的,可是大马的 Sony 却给 HX7V 打了 RM200 的折扣。本来 HX9V 只贵了 RM55,可现在却变成 RM255。没办法,价钱太诱人了,所以我选择 HX7V,售价是 RM1099。花这么多钱买个 point-and-shoot 好想有点白痴,不过就当作是辛勤工作了一年,犒赏犒赏自己吧!这么想,罪恶感好像就少了点儿
La La La Love Song
Posted by on September 25, 2011
《悠长假期》的主题曲,前几天在电台听到。听着那轻快的旋律,我也要放假!
まわれ まわれ メリーゴーラウンド もう けして止まらないように
动き出したメロディ LA LA LA LA LA LOVE SONG
Wanna Make Love
Wanna Make Love Song, Hey Baby
Wanna Make Love
Wanna Make Love Song, Hey Baby
ドシャ降りの午后を待って 街にとび出そう
心に降る雨に 伞をくれた君と
“まっぴら!”と横向いて 本音はウラハラ
でも そのままでいい お互いさまだから
めぐり会えた奇迹が
You Make Me Feel Brand New
涙の色を変えた
And I Wanna Love That’s Brand New
息がとまるくらいの 甘いくちづけをしようよ
ひと言もいらないさ とびきりの今を
勇気をくれた君に 照れてる场合じゃないから
言叶よりも 本気な LA LA LA LA LA LOVE SONG
Wanna Make Love
Wanna Make Love Song, Hey Baby
Wanna Make Love
Wanna Make Love Song, Hey Baby
知らぬ间に落としてた 小さなかけらを
隙间なく抱きよせ 肌でたしかめあう
宇宙の见えない夜
You Are My Shinin’ Star
かまわない 君が见える
And I Wanna Be Your Shinin’ Star
まわれ まわれ メリーゴーラウンド もう けして止まらないように
动き出したメロディ LA LA LA LA LA LOVE SONG
とめどなく楽しくて やるせないほど 切なくて
そんな朝に生まれる 仆なりのLOVE SONG
ためいきの前に ここにおいでよ
息がとまるくらいの 甘いくちづけをしようよ
ひと言もいらないさ とびきりの今を
勇気をくれた君に 照れてる场合じゃないから
言叶よりも 本気な LA LA LA LA LA LOVE SONG
LA LA LA LA…
(Wanna Make Love)
(Wanna Make Love Song)
LA LA LA LA LA LA LA LA…
(Wanna Make Love)
(Wanna Make Love Song)
LA LA LA LA LA LA…
(Wanna Make Love)
(Wanna Make Love Song)
LA LA LA LA LA LA LA LA
(Wanna Make Love)
(Wanna Make Love Song)
中文翻译:
转啊转 旋转木马
就像源源不绝 跃动而出的旋律
LA.LA.LA LOVE SONG
Wanna Make Love
Wanna Make Love Song,Hey Baby….
等待倾盆大雨的午后 飞奔到大街上吧
偕同为我阴雨心灵撑起伞的你
「门都没有!」你别开脸 其实却是口是心非
不过这样就好了 毕竟我们都半斤八两
相逢的奇迹
You Make Me Feel Brand New
改变了泪水的颜色
And I Wanna Love That`s Brand New
*让我们甜蜜热吻如将窒息 什麼都不用多说
在这无以言谕的时刻 对给我勇气的你
现在不是害羞的时候
天花乱坠不如出自内心的LA.LA.LA LOVE SONG
Wanna Make Love
Wanna Make Love Song,Hey Baby….
将不知不觉之间遗落的小细节
不留空隙紧紧抱住 用身体去感觉
看不见宇宙的夜
You Are My Shinin Star
无所谓 我看见你的存在
And I Wanna Be Your Shinin Star
转啊转 旋转木马
就像源源不绝 跃动而出的旋律
LA.LA.LA LOVE SONG
快乐的无法抑制 悲伤得近几无法排遣
诞生於这样一个早晨的是 我独特的Love Song
叹息之前 到这儿来吧
*Repeat
LA.LA.LA….
Wanna Make Love
Wanna Make Love Song,Hey Baby….
《我是一只小小鸟》
Posted by on September 8, 2011
难过的时候总是喜欢听这首歌吧…
《我是一只小小鸟》
作词:李宗盛 作曲:李宗盛 演唱:赵传
有时后我觉得自己像一只小小鸟
想要飞 却怎么样也飞不高
也许有一天我栖上枝头 却成为猎人的目标
我飞上了青天才发现自己 从此无依无靠
每次到了夜深人静的时后我总是睡不着
我怀疑是不是只有我的明天会有变得更好
未来会怎样究竟有谁会知道
幸福是否只是一种传说 我永远都找不到
#我是一只小小小小鸟
想要飞呀飞却飞也飞不高
我寻寻觅觅寻寻觅觅一个温暖的怀抱
这样的要求算不算太高
Repeat #
所有知道我的名字的人啊 你们好不好
世界是如此的小 我们注定无处可逃
当我尝尽人情冷暖 当你决定为了你的理想燃烧
生活的压力与生命的尊严哪一个重要
CyanogenMod on my HTC Desire (finally)
Posted by on August 30, 2011

Today is a public holiday, got nothing to do, so I decided to install the famous custom rom CyanogenMod http://www.cyanogenmod.com/ on my one-year-old HTC Desire. There are 4 steps to install it:
- Install a custom recovery image.
- Install rom manager.
- Create a full backup (nandroid backup).
- Download and install the CyanogenMod custom rom.
1. Install a custom recovery image
To install a custom recovery image, I used unrevoked3 http://www.unrevoked.com/recovery/. Read the instructions on the website, but basic steps are:
- Download a shell script (I’m using the linux version).
- Run it with root user.
- Enable USB debugging on the phone.
- Connect the phone to the computer.
- Wait patiently.
For my case, the phone rebooted twice if not mistaken (i did this several months ago to gain root access but not flashing any custom rom). I succeeded in the first try. Some people will have to try a few times before flashing it successfully.
2. Install rom manager
Use the Market app to install an application called Rom Manager. First running it, it will ask you to install the ClockworkMod Recovery Image. Install it.
3. Create a full backup (nandroid backup)
Use the Rom Manager to create a full backup (nandroid backup). This backup is important. In case of something goes wrong, you’ll need this to restore your phone to its current state (running official HTC Desire rom). The backup process will actually reboot your phone into recovery mode and create the backup in your SD card. So, make sure you have some free space there. Once done, your phone will be rebooted normally. Now, I’ll copy the nandroid backup (/sdcard/clockworkmod/backup/) to my computer just in case something bad happen to my SD card later.
4. Download and install the CyanogenMod custom rom
Use the Rom Manager to download the custom rom. There is list of popular roms for you to choose from. I selected the CyanogenMod 7.0.3 (current stable). The app will download the rom and once completed, it will prompt you to:
- Backup existing ROM (not selected)
- Wipe Data and Cache (not selected)
- Wipe Dalvik Cache (selected)
We have created a full backup, so the first option is not needed. If this is the first time you install this custom rom, you must select the second option (wipe data and cache)*. You phone will then rebooted into recovery mode and the flashing process will be started. Wait for a while and you should have your HTC Desire running Gingerbread
I’ve been playing with the new rom for the last couple of hours. Many things are much better than froyo but unfortunately, I lost all Google apps. I manage to install the Market by installing Google Apps add-on in the Rom Manager, but there were no Gmail, GoogleMaps and some other Google apps in the Market. GoogleMaps is the most useful Google apps so I installed the Brut version http://forum.xda-developers.com/showthread.php?t=630887 which allows me to use the navigation in my country. Another missing part was the Chinese keyboard. The default Android keyboard does not support Chinese input. Luckily, someone created a wonderfully keyboard app called MultiLing Keyboard and it is available in the Market. It has a lot of plugins. To support Chinese input via Pinyin, you’ll have to install Plugin.Chinese.Pinyin.拼音 To support hand-writing input, Plugin HanWriting is required. It is such a wonderful application. So much better than the official HTC IME keyboard (which also support pinyin and hand-writing inputs).
* I didn’t select the second option during my installation and my phone simply failed to start up after completing the whole flashing process. It kept looping at the splash screen and I had to pull the battery to stop it. Luckily, I was able to get back into the recovery mode**, wipe out all the data/cache and reflash the rom. Don’t make the same mistake I did.
** To get into the recovery mode, turn off the phone and then turn it on by holding down the volume down button. You’ll see a bootloader screen. Use volume up/down button to select recovery mode, then press the power button to activate it. The recovery mode is actually the ClockworkMod recovery image installed in step 1 or 2. With it, you can create nandroid backup, restore from a nandroid backup, install custom rom, wipe out caches and many more.
Send cronjob output to multiple email addresses.
Posted by on August 18, 2011
By default, cronjob will send the output of the command to the owner’s system mail box. In Linux, you can route the mail using
MAILTO=user@server.com * * * * * /some/command.sh
in the crontab.
Some how, if I did that in Solaris, I got the following error:
MAILTO=user@server.com crontab: error on previous line; unexpected character found in line. crontab: errors detected in input, no crontab file generated.
So, I have to use mail aliases. First, I’ll have to edit the file
vi /etc/mail/aliases
Assume the cronjob owner is called user1 and I need to leave the cronjob result in the owner’s inbox, forward a copy to user2 and another copy to an external email address user@server.com, I’ll add the following lines to the end of the file.
user1:user1,user2,user@server.com
Then, I’ll refresh the mail system’s alias database with the following command:
newaliases
That’s all.
