Snippet IT IT News, Programming, Internet and Blogging

22May/090

Java: Format Bytes Array into Hexadecimal String

Sometimes, we may want to format a bytes array into hexadecimal (base-16) format for debugging purpose or for better readability. One byte has 8 bits and one byte can be represent by two hexadecimal characters (0 - 15 and A - F).

14May/090

Get Paid to Be a Hacker!

Have you ever thought getting paid to be a hacker? I said a “hacker” but it is an ethical hacker. Many people misunderstand the word “hacker”. Unlike cracker, a hacker is always ethical.

So what does an ethical hacker do? An Ethical hacker (or the white hat hacker) is a computer expert with great knowledge in computer and network security. He or she attacks on systems on behalf of the system owner to seek for vulnerabilities that a cracker could exploit. The activity carried by a hacker is called Ethical Hacking.

Binary

14May/090

Java: Least Recently Used (LRU) Cache

Least Recently Used or in short LRU is an performance optimizing algorithm. LRU algorithm is widely used in software programming as well as in hardware instructions (e.g. CPU).

In many case, in programming, we may want to cache some data from physical disk, for example database and files, but we cannot load all the data into memory due to the memory limitation on the server or PC. In those cases, you may want to consider to use LRU algorithm to solve the memory limitation problem.

11May/090

JSP: How to Declare Methods and Inner Class in JSP

JSP itself is just a plaint text and will be translated into Java source file (actually a servlet), compiled into class file and only interpreted at the end during runtime. All these happen at the backend.

When the whole JSP is translated into Java source file, all the HTML codes will be translated and source lines in <% %> tag will be included in a function of the translated servlet source file.

8May/092

WordPress Theme: How to Enable Gravatar in WordPress Theme

Gravatars are Globally Recognized Avatars. An avatar or gravatar is an icon, or representation, of a user in a shared virtual reality, such as a forum, chat, website, or any other form of online community in which the user(s) wish to have something to distinguish themselves from other users. 

Gravatar 

6May/090

Java: Static Variables, Static Methods and Static Constructor

Java's static variables are variables or fields that are common to all object of a class. Unlike instance variables, objects of the same class have their own distinct copies of the variables and values. In other words, a static variable is shared among objects of the same class. You can declare static variables (or static fields or class variables) by adding static modifier to the variables declaration.

4May/090

PHP: How to Protect Password in Database – Password Hashing

If you are a programmer, you may have developed applications that store users or your customers' information in database. How to store users' or customers' sensitive data (especially password) might be an issues for most programmer. How do you ensure and convience that your users or customers'  password are actually secured?

Password 

25Apr/090

PHP: Format integer into number of decimal places

Previous I have written an article about formating interger into number of decimal places in Java. The main reason to store money value in integer in to prevent loss in precision. For example the actual value for 12.33 in float could be 12.3333333333...; while 1233 in integer is always 1233.

Today I will be showing you the same code but in PHP language. I know you can do the same thing with PHP's number_format(), but you will need to cast the integer into float first before past the money value into the number_format() function. Therefore there are possibles of lose in precision.

24Apr/090

PHP: session_start() – No such file or directory error

Have you encountered the following PHP error (or something similar) before in your Windows Vista?

Warning: session_start() [function.session-start]: open(C:\Users\YOURNAME\AppData\Local\Temp\php\session\sess_ficdel21e6lupsojqdk62ofts5, O_RDWR) failed: No such file or directory (2) in C:\webapp\folder\index.php on line 24

The solution to the above error is really simple. Simply re-create the folder C:\Users\YOURNAME\AppData\Local\Temp\php\session\. For some reason, you or your Windows Vista (e.g. during a disk cleanup) may deleted all the files and folder under C:\Users\YOURNAME\AppData\Local\Temp\ and this is the main reason PHP can't find the correct location to create its temporary file for new session.