Wednesday, May 27, 2009

Javascript - Calculating Elapsed Time

// using static methods
var start =;
// the event you'd like to time goes here:
var end =;
var elapsed = end - start; // time in milliseconds

// if you have Date objects
var start = new Date();
// the event you'd like to time goes here:
var end = new Date();
var elapsed = end.getTime() - start.getTime(); // time in milliseconds"

// About Date()
new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, date [, hour, minute, second, millisecond ])

today = new Date();
birthday = new Date("December 17, 1995 03:24:00");
birthday = new Date(1995,11,17);
birthday = new Date(1995,11,17,3,24,0);

Thursday, May 21, 2009

Linux Shell Script - Find Relative Path of Current Script

Linux Shell Script - Find Relative Path of Current Script:

"echo 'Path to $(basename $0) is $(readlink -f $0)'

CURRENTDIR=`dirname $0`
echo 'Path is: ${CURRENTDIR}'

reldir=`dirname $0`
echo 'RelDir $reldir'
cd $reldir
echo 'Directory is ${CURRENTDIR}'
sh ${reldir}/"

Wednesday, May 13, 2009

CSS Properties: Display vs. Visibility

CSS Properties: Display vs. Visibility: "CSS Properties: Display vs. Visibility
Browsers Targeted: Internet Explorer 3+

It's fairly easy to confuse the Cascading Style Sheets (CSS) properties display and visibility, because it would seem that they do much the same thing. However, the two properties are in fact quite different. The visibility property determines whether a given element is visible or not (visibility='visible|hidden'). However, when visibility is set to hidden, the element being hidden still occupies its same place in the layout of the page.

<script language='JavaScript'>
function toggleVisibility(me){
if ('hidden'){'visible';
else {'hidden';

<div onclick='toggleVisibility(this)' style='position:relative'>
This example displays text that toggles between a visibility of 'visible' and 'hidden'.
Note the behavior of the next line.</div><div>This second line shouldn't
move, since visibility retains its position in the flow</div>

This example displays text that toggles between a visibility of 'visible' and 'hidden'. Note the behavior of the next line.
This second line shouldn't move, since visibility retains its position in the flow

Note that when an item is hidden, it doesn't receive events. Thus in the sample code, the first sentence never detects that there has been a mouse click once the item is hidden, so you can't click the area to make it visible again. The display property, on the other hand, works a little differently. Where visibility hides the element but keeps its flow position, display actually sets the flow characteristic of the element. When display is set to block, for example, everything within the containing element is treated as a separate block and is dropped into the flow at that point as if it were a <DIV> element (you can actually set the display block of a <SPAN> element and it will act like a <DIV>. Setting the display to inline will make the element act as an inline element—it will be composed into the output flow as if it were a <SPAN>>, even if it were normally a block element such as a <DIV>. Finally, if the display property is set to none, then the element is actually removed from the flow completely, and any following elements move forward to compensate:

<script language='JavaScript'>
function toggleDisplay(me){
if ('block'){'inline';
alert('Text is now 'inline'.');
else {
if ('inline'){'none';
alert('Text is now 'none'. It will reappear in three seconds.');
else {'block';
alert('Text is now 'block'.');

<div>Click on the <span id='blueText' onclick='toggleDisplay(this)'
style='color:blue;position:relative;cursor:hand;'>blue text</span> to
see how it affects the flow.</div>

Click on the blue text to see how it affects the flow.

Notice that if the display property is not explicitly set, it defaults to the display type the element normally has. Of the two, the display property is definitely the more useful, as most instances of needing to hide text also involve shifting the surrounding HTML flow to accommodate it (think tree structures, as an example)."

Tuesday, May 12, 2009

ANT Task Sending Email to Multiple Receipients with attachments

ANT Task Sending Email to Multiple Receipients with attachments: <project name='SendMail' default='SendEmail'>

<target name='SendEmail'>
<property name='ToEmail' value=','/>
<mail mailhost='' mailport='465' subject='Test Mail from ANT' from='User.Name@gmailcom' tolist='${ToEmail}' user='' password='passwordhere' ssl='yes'>
<message>Hi, This is Test Mail. </message>
<fileset dir='${basedir}' includes='*.PDF'/>

ANT Task - Delete Files and Directories

ANT Task - Delete Files and Directories :
<project default='DeleteFilesDirectories' basedir='.'>

<!-- @Ref: -->

<target name='DeleteFilesDirectories'>
<!-- Deletes All Files and Directories (Including Empty Directory) -->
<delete includeemptydirs='true'>
<fileset dir='${basedir}/User' includes='**/*'/>

<!-- Deletes All Files and Directories (Excluding Empty Directory) -->
<delete includeemptydirs='true'>
<fileset dir='${basedir}/User' includes='**/*.*'/>

<!-- Deletes All Files and Directories (Including 'User' Directory itself) -->
<delete includeEmptyDirs='true'>
<fileset dir='User'/>


ANT Task [propertyregex] - String Replace

ANT Task [propertyregex] - String Replace:
<project name='PRJStringOperations' default='StringOperations' basedir='.'>

<!-- To Remove '' in EmailID's List -->
<typedef resource='./lib/' classpath='${basedir}/lib/ant-contrib-1.0b3.jar'/>

<property name='MailTo' value=''','''/>
<target name='StringOperations'>
<propertyregex property='prop.MailTo'

<echo message='${prop.MailTo}'/>


Thursday, May 7, 2009

Ant - Passing Argument in Command Line

Ant - Passing Argument in Command Line:

Case 1 : Using own bat file (ant.bat) for executing ant
Passing Arguments in Command Line
C:/ant/apache-ant-1.6.2/bin/ant.bat -DArg4First=SUN -DArg4Second=JAVA

In build.xml file
<project default='testAnt'>
<target name='First'>
<echo message='Input value is: ${Arg4First}' />

<target name='Second'>
<echo message='Input value is: ${Arg4Second}' />

Case 2 : Using another batch file(testCallAnt.bat) for calling ant.bat file
Inside testCallAnt.bat will be,
C:/ant/apache-ant-1.6.2/bin/ant.bat -buildfile testAnt.xml First Second -DArg4First=SUN -DArg4Second=JAVA

Call the Batch file like this,
c:\Ant\> testCallAnt.bat %1 %2

Eg: c:\Ant\> testCallAnt.bat SUN JAVA

Friday, May 1, 2009

10 reasons Why Cloud Computing is the Wave of the Future -

10 reasons Why Cloud Computing is the Wave of the Future - "10 reasons Why Cloud Computing is the Wave of the Future

April 29, 2009 at 10:04:35 AM, by Gilberto J. Perera Rating: 0 out of 5

What is all this Cloud computing mumbo jumbo about and why should I care? Our editor Gilberto J. Perera puts it to us straight.

Before we delve into the reasons why cloud computing is the wave of the future we must first understand what cloud computing is. According to Berkeley scientists, 'Cloud computing refers to both the applications delivered as services over the Internet and the hardware and systems software in the datacenters that provide those services. The services themselves have long been referred to as Software as a Service (SaaS), so we use that term. The datacenter hardware and software is what we will call a Cloud.'

So what does this mean? Simply put, companies (Google, Microsoft, Amazon) will provide users with software that resides on their servers in the 'cloud' or the 'grid' so that users can access that software and information from anywhere and on any computer attached to the internet. In other words software would cease to be just a tangible product that you buy and install on your computer. Software is evolving into a service that you access from your computer over the internet. Examples of cloud computing can be seen with services like Gmail, Google Docs, Office Live, SOHO, and other online platforms.

In the past couple of years software providers have been moving more and more applications to the 'cloud', this article discusses some of the reasons why cloud computing is the wave of the future in terms of delivering software as a service.

1. Software as a Subscription

In a cloud, software resides on a service providers servers external to a user’s computer. In a sense users would not have to buy software for their computers because the software is loaded per use while the user is online (via a browser or some kind of connector application). The only models that would support this type of software use would be a subscription based or pay as you go model. Instead of shelling $149 for Office Home & Student, a user may pay a set fee/month; say $5.95/month and the user can tailor their subscription to meet their needs. This will keep users from buying software that is bundled with applications the user may not care for. A perfect example of this is the Office Suite.

2. Reduced Software Maintenance

By keeping the software in the 'clouds' users can reduce the amount of maintenance on their computers. Nowadays essentially every program installed on a computer has an update function that searches for the latest software changes in order to patch security flaws, correct software issues, and/or introduce new functionality. When upgrades are made to software on the cloud it does not affect the user's computer, it would not require for the user to restart their computers, it would simply mean that unless the change affects functionality or visual elements, the user will be oblivious to those updates and their computers will never be affected by those updates. A reasonable reduction in systems maintenance would be expected as a result of this.

3. Increased Reliability

Increased reliability stems from the fact that the cloud runs on systems that are extremely reliable and provide some form of redundancy. Unless a user takes the time to setup a backup system for their files or sets up some kind of redundancy with offsite backups, etc. Users run the risk of losing valuable and sometime unrecoverable data on their computers. In the case of grid computing if a storage server on the cloud fails due to hardware or software issues, the service provider needs only to shift the load over to other servers or bring up a backup server in its place. If it occurred at a users premises with installed software a simple issue can turn to hours of technical support over the phone, costly downtime, and unhappy users and customers.

4. Increased Scalability

Running out of hard drive space at home? Looks like an additional hard drive along with a visit to a computer technician for installation will solve the problem. However in a cloud computing environment, storage is not an issue, as long as you can pay for it. Service providers need only to add servers or shift load from one server to another to accommodate for the additional use of space. The same goes for application use, instead of a small business adding additional servers to handle business transactions all they have to do is contact the service provider to let them know that they will need additional resources.

5. Cost Reduction

Costs are reduced in a number of ways. Capital expenditures are reduced because a lot of the load and storage will be shifted over to the service provider who can provide that service at a lower cost. Aside from decreased capital expenditures associated with hardware purchases, users would see the cost of software decrease due to the reduced cost of subscription software. IT staff at businesses would be reduced because the majority of the maintenance is performed at the service provider.

6. Environmentally Friendly

One of the greatest advantages of cloud computing is the increased longevity and use of older hardware used by datacenters. This in turn lessens the amount of electronic waste dumped because equipment is older and increased use of those resources. When businesses use current assets instead of purchasing additional hardware they reduce the size of their carbon footprint because it is one less server that is put into service, it is one less server that is consuming electricity .

7. Matches Current Computing Trends

The introduction of the netbooks has moved a lot of sales from computers and laptops with more powerful processors and extended capabilities to less powerful and more efficient platforms . This signals that users are looking for computers that meet their needs and are affordable. The advent of cloud computing will be able to match this trend because a lot of the processing overhead is performed at the servers and not the computer, so the need for an extremely powerful computer is muted. As cloud computing matures and more and more processing is shifted to the cloud, computers will require less processing power and will have basic functionality.

8. Portability/Accessibility

One the greatest advantages to grid computing is the availability of files and software anywhere that there is an active internet connection. This brings forth added accessibility and productivity for those that are on the road and require access to files and software. With a large number of companies looking for alternatives to employees working at the office and the increasing number of employees making up a mobile workforce. The reduction in application costs and technical support would easily continue to support this trend towards a mobile workforce that would utilize the computer grid.

9. Efficient Use of Computer Resources

The advent of virtualization has provided companies with ways to efficiently used their computer resources. Users no longer require separate servers for different applications. With virtualization multiple server technologies can run from a single server. This shift to virtualization supports the growth of cloud computing due to the increased capabilities of servers. Cloud computing would also simplify IT's role in computer management because computers would be software agnostic.

10. Versionless Software

Versionless software refers to the elimination of software upgrade projects. Changes and updates to software would be constant and version numbers would be transparent to the user, all the user would see is added functionality. It would also give users '...access to new technology early and often rather than forcing them to wait for a final, packaged product to be shipped. ' This concept will enable the enterprise to remain in the cutting edge of technology and would reduce training costs associated with new software releases.

As one can see the case for cloud computing is quite appealing. The shift towards cloud computing would enable businesses to save money while minimizing their impact on the environments. Users would have the flexibility of accessing information from anywhere on the planet where an internet connection exists. Everyone will benefit from the increased availability and affordability of applications that were beyond their reach due to cost and complexity with maintenance and installation. Lastly the need for additional training associated with new product releases would be eliminated to due to the nature of the applications constant changing state."