• Enter Slide 1 Title Here

    This is slide 1 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 2 Title Here

    This is slide 2 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

  • Enter Slide 3 Title Here

    This is slide 3 description. Go to Edit HTML of your blogger blog. Find these sentences. You can replace these sentences with your own words.

Wednesday, August 27, 2008

Is Partitioning a hard disk into multiple drives bad?

Hard Disk drives partitioning and accessing speedHard disk partitioning is almost a must, according to what I have heard so far from my colleagues and other professionals (may be same for you). I am used to partition a hard disk at least to three drives; "C" for OS (Operating System), "D" for programs and "E for other files like documents, archives. But I got a chance to read some material on hard drive performance and it completely argued my partitioning practices.

When considering the speed in reading a file from hard drive following are two important points related to partitioning.

1. Files in outer tracks are readable much faster
It is a well known theory in hard disk read/writes that performance is much higher in outer tracks compared to inner tracks.

2. When partitioning a hard disk, the first partition is created in the outer tracks
In creating partitions, the first partition is created in the outer most tracks while each new partition is created in inner tracks than the previous. So the partitions in a hard disk would look as the above diagram.

These two are important point to consider. We are creating partitions in order to organize the files according to mentally created categories; like operating system in one partition while program files in another partition. But I did not organize the files in the frequency they are used (which I should have thought of). There are some files frequently used, but placed in different drives without knowing this speed factor. For example; some java projects are stored in drive "E" which I happened to use daily.

So what are the solutions we can think of, in order to achieve the best performance of the hard disk considering these facts? I can think of following two solutions.

1. Create only one partition
One option would be to refrain from creating more than one partition and storing all the files in there. Then we would have to store the most frequently used files in outer tracks while hardly used ones in inner tracks. However this is not that possible, since user is not deciding the location of a file when saving into hard drive. The only solution will be to use a defragmenting software to organize the files later according to the accessing frequency.

2. Store files on partitions according to the frequency of use
We would create a set of partitions same as we used to do earlier, but with a different intension. Files will not be saved in each drive depending on the type or categories, but according to the frequency. The most frequently used files will be stored in drive C while least used files in Drive E. But then again, memorizing the file locations will not be easy.

What is the method are you using in your computers? Do you have any experience in above mentioned suggestions? We welcome your ideas and experiences or any other suggestions.

Thursday, August 21, 2008

Cellspacing vs cellpadding - Table attributes comparison

In HTML Tables (<table>) there are two attributes named, cellpadding and cellspacing. What is the different between cellpadding and cellspacing? Both these are capable of creating some empty space inside a table.

cellspacing : space between cells
cellpadding : space between the cell border and it's content

Look at the diagram to clarify this further. As the word "cellspacing" suggests, it denotes the spacing between cells; it is something easy to remember. "cellpadding" keyword can be considered in relation to the "padding" attribute in HTML/CSS; padding is used to denote the space between the content and border of box type elements.

Following is a simple code example to demonstrate the difference.

<table cellspacing="15px" cellpadding="20px" bgcolor="#00EE00" width="300px">
<tr>
<td
bgcolor="#339966">
<div
style="background:#FFFFFF;">Cell 1 content</div>
</td>

<td bgcolor="#339966">
<div
style="background:#FFFFFF;">Cell 2</div>
</td>

</tr>
</table>

Cell 1
Cell 2

Check the difference. We have set the table background to light green color, so all the cellspacing is viewed in light green as it is the space between cells. The dark green sections are the spaces created with cellpadding; the space in white is available for the content in table cell.

Monday, August 18, 2008

If Michael Phelps is a country himself alone

What if Michael Phelps is a country himself alone rather than representing United States of America? Michael Phelps has already gathered 8 Gold medals in Beijing Olympics 2008 including 3 relays. Most of the participating countries happened to go back empty hand, so many players are participating knowing they are not up to the level of winning a medal. But consider this man, he's breaking world records in most appearances.

If he is playing himself alone as a separate country named "Phelps" he would still have 5 Gold medals and ranked as 11th country in Beijing Olympic medal table. Around 200 countries will be behind him. Medal table would look as follows.

RankCountryGold
1China35
2USA14 (19-Phelps)
3Australia11
.....
11Phelps5

He is creating new history with a set of world records and we are really proud to see such a person in this planet. We doubt any one living right now in this planet will be able to witness another performance like this in their lifetime. If they could, it will be again only by this big man. This is fabulous! one person winning 8 Olympic Gold medals while so many countries are trying at least to win one bronze medal for their country to mark their presence.

Now Michael Phelps has 14 Olympic Gold medals in three Olympics becoming the most Olympic Gold medal holder in the world. As he is only 23 years, this is going to be just the beginning in his career and all of us wish him to swim more than 10 years to create so many world records to raise the standards in this planet into a superior level.

We love to see an amazing man like Michael Phelps in this planet.

Sunday, August 10, 2008

[Cricket] Most wickets in debut Test series - World record by Ajantha Mendis

Most wickets by a player in his debut 3-match Test series; a 60+ years old world record has been broken. By whom? By Sri Lankan newly found precious mystery spinner Ajantha Mendis. He produced this new world record yesterday, 2008-08-10 with the wicket of Sachin Tendulkar, another master of cricket. Up to now, he has got 25 wickets in this series, and he has passed the 24 wickets record held by English bawler named Alec Bedser.

Ajantha Mendis has so many variations, and so difficult to read from the hand. Most of the Indian batsmen are still struggling to play against him while he is improving with his variations and accuracy.

In the current India-Sri Lanka Test series he played in all 3 matches (and 6 innings) and performed fabulously. Still he is bawling in the 2nd inning of the last Test match and 5 more wickets are left in Indian team. So we wish Mendis to get some more wickets out of those and improve his record into an untouchable one in history.

Well done Menda.

Update:
Ajantha added another wicket to his record, now it's 26 wickets in a 3-match Test series. He is the man of the series in his debut.

Thursday, August 7, 2008

Verify calling Javascript function available to avoid runtime errors

Do you want to verify whether a Javascript function exists before calling it to avoid runtime errors? With Javascript we used to call Javascript functions. But sometimes our Javascript code tend to throw runtime errors and showing then on the browser. For this there can be several reasons including; incorrect function names or invalid .js file names causing some functions not loaded into your web page.

Javascript has the ability to check this. For that we can use the typeof keyword, and check whether that is of 'function' type or not.

Generally we will be calling a Javascript function without checking whether it exists. Following code shows how we would call a function.

function callClient(){
myTestFunction();
}

If the function named myTestFunction() is not available, the browser will show an error message at runtime. But we can check whether this method is available even before calling it, avoiding the errors. Following code snippet checks the existence before calling a function.

function callClient(){
if (typeof myTestFunction == 'function') {
myTestFunction();
} else {
alert("myTestFunction function not available");
}
}

In the above example, it checks the availability of the required function "myTestFunction" before calling it, and call it only if it exists. This will improve the user experience by avoiding unexpected error messages from the user.

Wednesday, August 6, 2008

Write Java with JDK 1.5 features and run on JRE 1.4

JavaHave you being writing your Java code on Java 1.5 (JDK 1.5) with new features like auto boxing, generics and enums? And suddenly realized that your customer's servers are still using Java 1.4 (JRE 1.4)? This is not a surprise since most of the customers are not in a position to take a risk and try the newer versions as they are running live/online businesses. But as professionals in the software development field, we have to move with the latest/stable versions available in the market. That's where the conflict occurs.

Now you must deploy your Java 1.5 codes into a 1.4 Java runtime environment (even may be 1.3 or 1.2). Even if the Java code has not used any of the new features of Java 1.5, you still can not run your code in 1.4 JRE as the runtime throws an error saying "java.lang.UnsupportedClassVersionError".

Compile 1.5 codes for 1.4 JVM

Java compiler provides an option to specify the target JVM of the generated classes like 1.5, 1.4, and 1.3 as follows.

public class MyClass {
public static void main(String args[]) {
System.out.println("Main Method");
}
}

> javac -source 1.4 -target 1.4 MyClass.java

Even if your JDK is of version 1.5, above command will compile your class so that it can run on a JRE 1.4. But the above option only works if your class does not use any of the new features in Java 1.5 (like auto boxing, enums etc).

Check the following class. Compiling it with "target" option will result in a compile time error.

public class MyClass {
public static void main(String args[]) {
Integer count = 1;
System.out.println("Main Method");
}
}

> javac -source 1.4 -target 1.4 MyClass.java

The compiler error is shown because auto boxing is not supported in 1.4.

This means that we can not use 1.5 features if we are going to run the programs on an older version. So this is not a real solution for our issue.

Can not run/deploy code with new features on 1.4 JVM?

Java retroweaver logoThere is an open source free solution to this issue. The tool is named "Retroweaver", and it can generate class files for older JREs using classes with new features of the 1.5 version. This is a nice tool and it supports most of the Java 1.5 features.

Retroweaver site says;

... supports most 1.5 features while running on 1.4.
  • generics
  • extended for loops
  • static imports
  • autoboxing/unboxing
  • varargs
  • enumerations
  • annotations

Also this has a good documentation (even though it's not up to date. Don't blame them; they are doing it for free).

This tool can convert .class files of 1.5 version to another older JRE version. Also it has the capability of converting a complete .jar file.