Creating a Digg This Button for Your WordPress Blog

Creating a Digg This button is very easy. Here's a non-plugin approach:

Copy and paste above script to anywhere between your WordPress' theloop:

Instead post specific Digg button, you can create a site wide button as well:

Continue reading

A Useful JavaScript Image Loader

I released a YUI implementation of image gallery script a month ago. While it was quite an enjoyable experience to explore the potential of YUI and JavaScript, I found I have created many userful code snips (for instance this Loading Panel) along the way.

Today I am going to show you another useful JavaScript code snip: Image Loader. What! You might ask. I admit that name is too generic, but it does what it does - it helps you to load images using JavaScript. Just give it an image URL, it will return a DOM image object that can be used for dynamic loading of images. This script provides a loading completion event, which is very useful for displaying preloader or extra information when the image is being loaded.

The original image loader I created relies on YUI, but I want to make it as portable as possible, so I created a standalone version.

Continue reading

How to Create a WordPress Theme Viewer

For WordPress veteran this might not be new, which is, let visitor preview multiple themes in one WordPress installation. It puzzled me quite a while before I figured out how to do it. The very reason for the need of this feature is that I want to allow regular users to view different themes on a WordPress powered website. I wasn't able to until I ran into this page. Yea right! A theme switcher. I installed this plugin and tested. It provides the exact function that I need. Fantastic.

Now here comes the interesting stuff. The official documentation documented the plugin is as follow, which outputs a list of links that can switch to a specific theme:

Continue reading

A YUI Loading Panel Widget

Probably needless to say, but here it is. A web page which is processing a lengthy Ajax request and doesn't provide a loading indicator of any kind will mostly mislead the user to think that the page has stopped responding. So the solution? Use a loading indicator of course. Here's a very handy loading indicator widget for Ajax programmers who use YUI.


How to Use

First, create a new instance of loading panel. After that, you can call show or hide method on the loading panel object.

The user can close the loading box by clicking on the cancel link. If you want to handle this situation, you can subscribe to the cancelEvent:

Continue reading

Apache Performance Problem on Vista

Just switch my operating system to Vista, and my biggest complaint about it is that it breaks my Apache HTTP server. The server still runs, but very slowly. The symptom is as follow: every time I reload a web page from the browser, there usually is a 2-3 seconds delay before the loading sequence starts. This shouldn't be happening because I serve all my files locally, so I expect no delay at all. Also, this behavior does not occur in XP.

After some excessive searches, I found a forum post (forgot the URL, will update this when I hit the site again) that suggests uninstalling Zone Alarm will resolve the problem. I gave it a try since I was in nowhere in solving the problem. Surprisingly the uninstallation did cure the delay issue of Apache. Beware that you HAVE TO restart Vista after uninstallation, otherwise you will not see the changes.

That's right, I uninstalled my firewall. So replacement? I like Zone Alarm and enjoy using it, but it doesn't seem to be very stable on Vista. However, I've found another great firewall product, Comodo Firewall Pro, which is a commercial grade firewall free of charge.