Archive for October, 2008

Anonymous Function in PHP

Saturday, October 25th, 2008

In Lisp or Scheme language, the anonymous function (which is called lambda-style function) is common used. These functions are special because it doesn’t have a name. So it can be only used once. Usually, these functions are very small and simple. (more…)

Trying reCAPTCHA Plugin

Saturday, October 25th, 2008

It is very strange that my post Function Overloading in PHP 5 brought many spam comments. I enabled Akismet plugin that has caught about 150 spam comments. However, somtimes Akismet can’t prevent all the spam comments and it just doesn’t allow the spam comments to show, the spams are still stored in the database.

Several days ago I read this article in Google Webmaster Central Blog. It shows some method to avoid comment spam. The first thing is using a captcha. Also, it gives a free script which is called “reCAPTCHA“. For WordPress users, reCAPTCHA provides a plugin, so that it is very easy to integrate with WordPress.

I don’t think the captcha code is a good solution to comment spam. It will make difficult to visitors who want to leave some meaningful comments. However, the comment spam is so serious, I have to do so.

What is JAVA_HOME in Ubuntu?

Tuesday, October 21st, 2008

Some Java programs need the environment variable JAVA_HOME, such as Tomcat. In Windows operating system, JAVA_HOME is the directory that the JDK is located. However, in Ubuntu if you install JDK with “sudo apt-get install sun-java6-jdk”, the JDK’s files are extracted to many directories like /usr/bin, /usr/lib, etc. What is JAVA_HOME?

Some people thought it should be /usr because in Windows the Java compiler “javac” is in JAVA_HOMEbinjavac. So in Linux it should be JAVA_HOMEbinjavac and JAVA_HOME=/usr. I don’t think it is the best sulotion. Because I found /usr/bin/javac is not the real Java compiler, it is just a link. I used “ls -l /usr/bin/javac” to see what it links to:

/usr/bin/javac -> /etc/alternatives/javac

And /etc/alternatives/javac is also a link. It links to /usr/lib/jvm/java-6-sun/bin/javac. This is the real Java compiler. And the path is similar to that in Windows. So I think JAVA_HOME should be /usr/lib/jvm/java-6-sun in Ubuntu Linux.

The Keyboard doesn't Work in Virtualbox on Ubuntu 8.04.1

Sunday, October 19th, 2008

I installed Ubuntu Linux 8.04.1 yesterday and removed Windows. But sometimes I need to use Windows, so I have to install VirtualBox.

I used “sudo apt-get install virtualbox-ose virtualbox-ose-modules-generic” to install VirtualBox. Its version is 1.5.6. However, I found a serious problem. My keyboard doesn’t work in VirtualBox. If a virtual machine is running and I click the window, the mouse is captured by the virtual machine. When I press the right Ctrl key the mouse should be released. However, it doesn’t work. I have to press Ctrl+Alt+Backspace to restart X. Some people said that the problem can be solved by disabling support to complex characters. But I need the multi-language support so that this method is unuseful for me.

Finally I found a good solution. I used “sudo apt-get install scim-bridge-client-qt” to install the scim-bridge-client-qt package and reboot my computer. Then the keyboard can work in VirtualBox. Although the solution is very simple, I don’t know why. It may be a bug in Ubuntu 8.04.1.

Sending AJAX Requests with Prototype

Saturday, October 11th, 2008

Several days ago I tried to learn a little about Javascript language and AJAX. Implementing AJAX with pure Javascript is not an easy work. It is not cross-browser so that I have to detect which browser sent the AJAX request. I think some frameworks can solve the problem in a better way and finally I found a Javascript framework — Prototype. (more…)

Working with an Old Computer

Wednesday, October 8th, 2008

Last month my friend and I exchanged our computers. Unfortunately, her computer’s memory is 256MB, only a half of mine. The operating system is Windows XP but mine is Ubuntu Linux. I like writing some programmes for fun but with a low memory I can not install some softwares. Eclipse, NetBeans, Visual Studio (Express Edition) are not fit for me any more. So I have to learn to use some lightweight softwares. (more…)

Testing Web Page with Firebug

Tuesday, October 7th, 2008

Firebug is an excellent Firefox extension. With its help you can change the appearance of a web page without modifying the HTML or CSS sourcecode. Moreover, you can see what looks like after your change the web page immediately. I made a video demo. (more…)

Protecting Your Computer with PowerShadow

Wednesday, October 1st, 2008

PowerShadow is an excellent software. While it is running, it seems that your hard drive is covered with a piece of transparent glass. You can see, change or delete the files, but all the changes will be lost after the computer starts up in the next time. So it is much like the hard driver recovery card, except for it is a software, not a hardware. (more…)