Walk around a wordpress malfunction on net9

June 13th, 2009

wordpress will malfunction on net9.org because query on “SELECT FOUND_ROWS()” do not return the result as expected (always 0) (apparently it is because some part of php or mysql is not configured correctly or not upgraded to the latest version.). This makes wordpress working on net9 not be able to show “next posts” link. To walk around this problem, I make a patch on the wp-includes/query.php to avoid using “FOUND_ROWS()“; I query it once more. It works fine.

The patch is here:

2274,2275c2274,2276
< 			$found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' );
< 			$this->found_posts = $wpdb->get_var( $found_posts_query );
---
> 			$temp_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby";
> 			$found_posts_query = apply_filters('found_posts_query', $temp_request);
> 			$this->found_posts = count($wpdb->get_results( $found_posts_query ));

A better smartdimmer for Ubuntu 9.04

May 23rd, 2009

I said that when I upgraded to Ubuntu 9.04, the smartdimmer program changes. Originally, in 8.10, the value range is 1-15, while in 9.04, it is 15-100. The main problem is that when I set 1 in 8.10, the screen looks really dark, and when I set 15 in 9.04, the screen is not so dark as it is in 8.10, and will consume more battery of course. So I would like my smartdimmer in 8.10 back, and I find this, which works quite well. My laptop is Sony VAIO VGN-FE15C.

Reference: http://www.nvnews.net/vbulletin/showthread.php?t=53225

Enable home/end key for bbs under gnome-terminal

April 28th, 2009

I used to publish a post here. I used gnome-terminal for visiting bbs, but the home/end keys are not functioning correctly.

I have found a temporary solution now.

  • Modify file /usr/share/vte/termcap/xterm file, change line :kh=\EOH:@7=\EOF:\ to :kh=\E[1~:@7=\E[4~:\

I am sure it is just a sort of walkaround; it has some risk to change the default behavior of xterm emulation. I tried to add my own termcap, but it did not work exactly the same as xterm. I think perhaps there are some other config files outside the file /usr/share/vte/termcap/xterm for xterm emulation. Plus, gnome-terminal do not call vte_terminal_set_emulation at all, it is just using the default one. (Yeah, I have seen the source code.)

Anyway it is fine till now. Everything is cool.

By the way, navigating through codes is fun.

Play Warcraft 3 under Ubuntu

April 26th, 2009

Just use wine, nothing so special. There are many reference pages on the web, but mainly what I have done is:

  1. apt-get the latest wine.
  2. Get a Warcraft 3 copy. (You should know that Warcraft 3 is green.)
  3. DISABLE windows visual affects.
  4. wine your-installation-path/Frozen\ Throne.exe

Several additional concerns:

  1. It is not neccessary to use the -opengl option. I can support DirectX quite smoothly on my computer in Ubuntu.
  2. Movies will not be displayed correctly. I simply renamed the movie folder and it will skip all the movies.
  3. Alt key have some super function (windows moving, minimizing, etc.) in Ubuntu by default. Use System->Preference->Windows to change it. I changed it to Super(Win) Key.
  4. You can manually set nvidia driver to center your screen in low resolution instead of stretching it. I can find it in System->Administration->NVIDIA X Server Settings->GPU 0 – (Nvidia Default Flat Panel)->GPU Scaling Method. It is just so great that in linux you get control to everything so simple. The path is always straight and direct, if you can find the entrance of course…
  5. By default, you can not switch to other applications by pressing Alt-Tab. (Technically, maybe, you can, but you can not see it happening.) Now we use the Super key and right click on anywhere and a pop-up menu will show up. Deselect the “always on top” option, and you will get rid of this trap.
  6. You can even run it in a wine virtual desktop, but I do not enjoy that very much.

Additional Tip: Here is a script for automatically disable visual effects and turn it on again after playing.

metacity --replace &
wineconsole ~/warcraft/Frozen\ Throne.exe
compiz --replace &

Upgrade to Ubuntu 9.04

April 26th, 2009
  1. From 8.10. Manually modified sources.list, just replace all intre* to jaunty.
  2. sudo apt-get update
  3. sudo apt-get dist-upgrade
  4. All done quite smoothly, except:
    1. smartdimmer is different. I used to set smartdimmer -s 7 as a startup command line by default. But now the valid valuing range is 15-100, 7 is invalid. (Want a better smartdimmer? See here.)
    2. I reinstalled my nvidia driver for once.
    3. Auto-login is disabled. I re-enabled it.

By the way, the splash screen of ubuntu looks much better than the former version.

Enable ICBC on Linux

April 26th, 2009

Mainly referencing this page: http://www.callmeageek.com/linux/ies4linux-icbc.html

Several points:

  1. No need to set IE6 security level to low.
  2. ies4linux gui installer pygtk version will have some problem when downloading. It will have no response when the text rolls out of the textarea and triggers a scrollbar to emerge. It is basically triggered by a line of auto roll down code. You can modify the python script yourself by comment down that single line of auto scroll bar rolling and it will work fine. Or, run ./ies4linux -no-gui or ./ies4linux -nogui. (I am not sure about this no-gui parameter, see your README file.)
  3. The swf flash cab can not be extracted correctly. Don’t know why. Fortunately, ICBC uses no flash. So I just ignored it.
  4. The icbc plugin is moved to new location here: http://www.icbc.com.cn/icbc/html/download/dkq/icbc_netbank_client_controls.exe

Enable newsmth.net in gnome-terminal

April 16th, 2009

The command line is something like this.

LANG=zh_CN.GB18030 gnome-terminal --disable-factory --window-with-profile=bbs \
--hide-menubar --maximize --title=newsmth -x telnet newsmth.net

To enable this you need to install zh_CN.GB18030 locale, it is not installed correctly in ubuntu 8.10 by default even when you installed all Chinese support. Add a line like:

zh_CN.GB18030 GB18030

in file /var/lib/locales/supported.d/zh, and run:

sudo dpkg-reconfigure locales

You should also need add a profile named “bbs” to gnome-terminal. I use an English monospace font and it will switch to your default Chinese font when displaying Chinese characters. (English characters in Chinese fonts are usually ugly.) Please reference my .fonts.conf to see how to set a default Chinese font (.fonts.conf is located in your home directory, if there does not exist one, create one yourself.) You may also want to use a larger font size, and disable scrollbars. The coolest thing about this is that you can set a background image for it…

The only bad thing is that <home> key and <end> do not behave as expected in gnome-terminal. I have not found a good solution for that yet. The solution for this problem is here.

How to enable dual-screen in ubuntu?

April 14th, 2009

Add something like this into /etc/X11/xorg.conf:

Section "Device"
	Identifier	"Configured Video Device"
	Option 	"TwinView" 	"True"
	Option	"TwinViewOrientation"	"LeftOf"
	Driver	"nvidia"
	Option	"NoLogo"	"True"
EndSection

This works for my VGN-FE15C VAIO laptop, which is using an nvidia card.

How to add font to ubuntu?

April 14th, 2009

It is very simple.

  1. Create a .fonts folder in your home folder (if there does not exist one).
  2. Copy your font file(s) to that folder.
  3. Done, it is installed.

Skype Green Screen WebCam Problem in Ubuntu 8.10

April 4th, 2009

My Skype WebCam suffers from a green screen problem in Ubuntu 8.10:

  1. cheese works fine.
  2. skype WebCam Test shows a flashy green screen
  3. skype WebCam shows a flashy green screen when using

To fix this problem

  1. Install package libv4l-0
  2. Instead of use skype to start the program, use

    LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype

Reference: http://ubuntuforums.org/showthread.php?t=945803