Snippet IT IT News, Programming, Internet and Blogging

12Jan/100

Java: Use ByteBuffer As InputStream

Sometime, your program may need to read data from a ByteBuffer buffer into a InputStream object. There is no class in Java library that provide the facility to do the conversion.

Anyway, to use a ByteBuffer object as an InputStream is pretty simple. What you need to do is to write a class wrapper that inherit InputStream and override the read() function in InputStream.

5Jan/100

Java: Format Integer Into Fixed Width String

Sometime, you may want to format an integer or a long value into a fixed width String. You need to display the value in fixed width especially in reports where you want to keep the numbers in aligned (e.g. 3456 as 0003456 and 1234 as 0001234).

Other than that, you may also want to format the integer value for a better visibility. For example, to display integer value as a document number (e.g. 12345678 as 00-01234-5678), for example an account number.

The Java.format() is not flexible enough to solve my problem. At least it cannot be used to format a fixed length document number in the format I want: XX-XXXX-XXXX. Therefore I decide write my own format function.

17Dec/090

Java: Continuously Read Data From FileChannel Without MappedByteBuffer

When programmer writes a program to read data from a file continuously and sequentially with a fixed data type reading sequence (e.g. to read three integers then 2 doubles repeatedly), he or she may find the MappedByteBuffer from Java library is useful.

12Dec/090

Wordpress: Catch A Spam Comment With Statcounter

Sometime your Wordpress' anti spam software (e.g. Akismet) may not able to stop all the comment spam because the comment looks too real to it and to human too. In this case, you will need to identify the comment whether it is actually a real comment or it is automatically submitted by software.

Someone who made a comment must have visited your site. That's it, if he or she has not visited your site but his or her comment is posted on one of your post. Then it is very high possibility that the comment is a spam comment.

How do you ensure someone who left a comment on your blog actually visited your site? The best way to do it is by looking at the IP address where the computer submitted the comment.

26Nov/090

Wordpress: How To Add Table Into A Post

Wordpress' WYSIWYG post editor does not come with the functionality that allows user to create table when editing a post (like what you can do in Microsoft word).

19Nov/092

JavaScript: Overcome Slow Loading JavaScript On A Web Page

Sometime a web page may load slowly due to loading a third party JavaScript source file from other domain. Most of the time, a web site comes with advertisement scripts or scripts for keep tracking visitors and these scripts are normally provided by third parties like Google Adsense, Statcounter, Amazon and etc. When these scripts' loading speed is extremely slow, it blocks the whole page from loading.

18Nov/090

Wordpress: Rename Permalink URL with Ease in Administrator Page

It is quite troublesome every time when blogger wants to rename a post's permalink URL after he or she has renamed the post's title in Wordpress's administrator page. Blogger needs to click the Edit button next to the permalink URL and modify the text accordingly.

17Nov/090

Wordpress: Schedule to Publish a Post

To publish a post doesn't mean you always need to be in front in your computer. Using Wordpress, you can simply write a post, schedule it and forget it. Wordpress will then publish your scheduled post at the right time!
Schedule Wordpress to Publish a Post

6Sep/091

Youtube: Stop Youtube From Loading

Previously, I wrote a "how to" article on How to stop Youtube loading data from the Internet using Google Chrome. Now you can do it at any browser using this simple trick.

Stop Youtube From Loading

7Jul/090

BigDump: Alternative to phpMyAdmin to Import/Restore Large Database

Recently I was facing problem on restoring database with a lot of data into MYSQL using phpMyAdmin. The restoring process keeps interrupted due to the connection between browser and server time's timeout and also due to the timeout in PHP script. Only partial data is restored and I kept dropping the database, increase PHP timeout, increased memory limit, and tried to restore again. But it still failed.