Archive for the ‘Uncategorized’ Category

Make your tmux look and work better

June 2, 2012 1 comment

I love using tmux. Besides the excellent scripting support (see my other post ), tmux is quite easy to customize to fit your need.

Here’s my tmux config:

The screenshot:

To use, follow

1. Credit goes to
2. I found using different color settings the most effect way to avoid accidental mistakes when working with test and production server, for example for production environment I use white on red (convenient color for caution?) for the current window tab color, for test environment I use black on yellow for the same element.

Feed-backs and comments are welcome!

[ UPDATE 6/6/2012 ] Finally I came up with the following status line that works on both Mac OSX and Linux regardless what the output of command uptime is:
set -g status-right '#[fg=yellow]#(uptime | egrep -o "[0-9]+ users?, +load.*"|perl -pe "s| averages?||"), %H:%M'

The challenge I found setting tmux status with command lines is that group capturing regex won’t work with tmux. For example, the following config set -g status-right '#[fg=yellow]#(uptime|perl -pe "s#.*,(\s+\d+ users.*)#\1#;s# averages?##"), %H:%M'
would end up 1saverages?#"), 23:44 showing in the status bar (right corner).

Categories: Uncategorized

How to swith back to classic menu in Ubuntu 11.04

May 13, 2011 1 comment

Ubuntu is trying too hard to be like Mac – with Unity as the default system menu in version 11.04. I for one doesn’t like the change at all, especially I mainly use Ubuntu on my 10″ Acer netbook. The way how Unity works makes it very hard to keep track of windows/applications that are opened, applications that don’t come with a high-resolution icons looks very ugly on the dock.

Fortunately it’s not that complicated to switch back to the “classic” Unbutu menu (which I can say the best menu in the history of Ubuntu), here are the steps with screenshots:

1) Click on the Ubuntu icon on the top left corner, type “login screen” and click on the “Login Screen” application

2) You will see the following

3) Click unlock, enter password and the window should become the following, choose “Ubuntu Classic” from the dropdown menu, click Close

4) Log out current session and log back in and the classic menu should be back

Categories: Tip, ubuntu, Uncategorized

Yet another awesome iPad app

April 20, 2011 Leave a comment

Just installed it and loving it.

[ yet this app failed to impress my love ss. ]

Categories: Uncategorized

My take on rounded corners in web development

April 10, 2011 1 comment

I am not a big fan of rounded corners, when it comes to web development. Yes I know a few ways of making rounded corners ( using 4 corner images and nest in a way that makes the whole div look like a rounded corner box; using a javascript way that doesn’t require images; using a whole image that suites situations when scaling is not required ) but none of the approaches provides a neat and sounding solution and my take  on rounded corners is very simple — avoid them if you don’t have to use them. [ I will be using rounded corners again when css3 are supported in all major web browsers as making rounded corners only requires one line of css code. ]

I have to agree that rounded corners make sites look smoother but let’s not forget there are sites that don’t use rounded corners at all and I haven’t heard anyone saying their sites suck because of the lack of rounded corners. Take a look at the following sites:

In my opinion, making rounded corners to appear the same on all browsers ( yes compatibility issue again ) takes  away too much precious time and effort which can be used to improve functionality of a site, and it also introduces extra complexity and unnecessary div, css, js code.



Perl study note: why using references in functions is the preferred way (mostly)

February 26, 2011 Leave a comment

Using references in Perl has a big advantage over the traditional passing-value way in performance. The reason is simple – no copying is performed when parameters are passed as references to functions. Below is the code I used to test on my Acer AOD 255 netbook:

use Time::Local;
use POSIX qw/strftime/;

sub d {
	my $msg=shift;
	print strftime("[%m/%d/%Y %H:%M:%S] ", localtime(time)).$msg."\n";

sub trim_ref {
	my $ref=shift;
	$$ref =~ s/(^\s+|\s+$)//g;

sub trim {
	my $str=shift;
	$str =~ s/(^\s+|\s+$)//g;
	return $str;

print "Purpose of this program is to illustrate the advantage of using
references in perl functions. Please note the traditional way might take a while
to finish.\n";

d('running traditional way');

my $str="   this   ";
my $dest;
for my $i (1..1_000_000) {
d('traditional way done');

my $str2="   that   ";
d('using reference method');
for my $j (1..1_000_000) {
d('ref. done');

[02/26/2011 18:37:43] running traditional way
[02/26/2011 18:37:59] traditional way done
[02/26/2011 18:37:59] using reference method
[02/26/2011 18:38:06] ref. done

The reference way (7 seconds) clearly beat the value-passed way (16 seconds). But this conclusion doesn’t mean passing by reference is always the best way especially when modifying the arguments passed is not desired.

jQuery 1.4.2 upgrade issue when doing json ajax calls

The format requirement for ‘json’ dataType has changed slightly in the new jQuery 1.4.2: Double quotation marks are now a must (for both keys and values) to make ajax calls when specifying dataType: ‘json’ as the return data format. For example, the following json objects are no longer considered to be valid in jQuery 1.4.2:


Attempting to use the above not-strictly-valid json data will result in success option (function) in the ajax() to give up quietly. [ My test result, which is different to what the $.ajax page ( states:

In jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See for more information on proper JSON formatting.)


It’s worth noting that 1.4.2 does not place a strict requirement on the json data being sent to the server, that is,
data: { userid: ‘Joe’, email: ‘’ }
can still be used without causing problems.

[ edit: actually I was not correct about the last paragraph above – the “json data” being sent to the server is javascript object whose key should not be quoted. ]

Categories: Uncategorized Tags: ,

Javascript: zero padding numbers

April 24, 2010 2 comments

There are many ways to accomplish this in js but the following is the one I found to be the best: Let’s say you need to pad a number with leading zeros so the total digits of the number will be 5, simply do a


n is the number to be padded.

[ credit goes to ]