Snippet IT IT News, Programming, Internet and Blogging

16Aug/100

Unix Shell Script: How to Receive Input Right After Echoing A Line

For example, say I echo a line of text in shell script and I want to receive user input just right after the text (not in the next line). The are several ways to do it:

Method 1

echo "Enter a value: \c"
read value

Method 2

echo -n "Enter a value: "
read value

Method 3

read -p "Enter a value: " value

30May/100

Database: CHAR and VARCHAR – What are the differences?

Most programmers may already know the main different between CHAR and VARCHAR - The first one supports fixed-length data and the second one supports variable-lengths of data.

Some people may think, since VARCHAR can do what CHAR does, then why we still need CHAR in our database design. I even have heard one of the very experienced Oracle database administrator say "Nowadays nobody is using CHAR anymore, you can forget about putting CHAR column in your database design".

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.

12Jan/100

100th Posts For Snippet IT

Finally, this blog has reached 100 posts! Yeah!

It really takes a long time for me to do this because I'm not blogging this site full timely. Second, sometime I'm just out of idea what to blog.

I will try work harder to share more information on programming and anything related to information technology in this new year. Thanks for reading!

5Jan/102

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.

21Dec/090

Happy Holidays from your Google team!

I just got a greeting card from Google Team. Do you have one?

Happy Holidays from Google - Card

Happy Holidays from Google - Earth

The email entitles  "Happy Holidays from your Google team!". Opps... when do I have a Google Team that works for me? Ha ha.

Anyway thank you Google! Happy Holiday too.

20Dec/0912

Google Wave Invitation Giveaway

I got my free Google Wave invitation from LiewCf, thanks for the invitation! Ok, now is my turn to give you guys, my blog readers, the free invitations.

Google Wave Invitation

19Dec/090

WordPress: Version 2.9

The latest WordPress version 2.9 is now available for download. The new WordPress has a new codename - Carmen - which is named in honor of magical jazz vocalist Carmen McRae (whom were added to the Last.fm WP release station).

Wordpress Version 2.9

18Dec/090

Adobe Acrobat Reader: Possible Security Vulnerability When Acrobat JavaScript Is Enabled

It is possible to have security vulnerability in Adobe's Acrobat Reader if the Acrobat Javascript option is enable.

When the option is enabled and you open a crafted PDF file with Adobe Reader that allows JavaScript execution, your computer will be exposed to security risk - hacker may able to access your valuable data from your hard disk.

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.