Tuesday, October 28, 2008

Simple Javascript Clock

<html>

<head>

<title>A Simple Page</title>

<script language="JavaScript">

<!--

function gettime() {

    
var date=  new Date();

    
var hr = date.getHours();

    
var m = date.getMinutes();

    
var s = date.getSeconds();

    
var ampm= "AM";

    
if (hr > 11)

    
{

        
ampm= "PM"

    
}

    
if (hr > 12)

    
{

        
hr -= 12

    
}

    
if(m < 10)

    
{

        
m =  "0" + m

    
}

    
if(s < 10)

    
{

        
s =  "0" + s

    
}

    
document.clockform.clock.value = hr +  ":" + m + ":" + s + " " +ampm;

    
setTimeout( "gettime()",100)

}

//  -->

</script>

</head>

<body onload="gettime()">

<form name="clockform">

<input type="text" name="clock">

</form>

</body>

</html>



Try it online before use

Simple Javascript Clock

<html>

<head>

<title>A Simple Page</title>

<script language="JavaScript">

<!--

function gettime() {

    
var date=  new Date();

    
var hr = date.getHours();

    
var m = date.getMinutes();

    
var s = date.getSeconds();

    
var ampm= "AM";

    
if (hr > 11)

    
{

        
ampm= "PM"

    
}

    
if (hr > 12)

    
{

        
hr -= 12

    
}

    
if(m < 10)

    
{

        
m =  "0" + m

    
}

    
if(s < 10)

    
{

        
s =  "0" + s

    
}

    
document.clockform.clock.value = hr +  ":" + m + ":" + s + " " +ampm;

    
setTimeout( "gettime()",100)

}

//  -->

</script>

</head>

<body onload="gettime()">

<form name="clockform">

<input type="text" name="clock">

</form>

</body>

</html>


Test online before use

Monday, October 6, 2008

Data leaks rank high on the list of IT security concerns

According to a study conducted by Trend Micro, a company that specializes in providing flexible and customizable Internet security solutions, data leaks are rapidly becoming a security threat similar to that of viruses and malware. The study was conducted on 1,600 corporate PC users and it shows that the most affected countries are the UK, US, Germany and Japan.

According to the study, computer viruses came in as the number one ranked security threat, while the loss of private, confidential data came in at number two, surpassing phishing attacks, spyware and spam. Most of the times an insider is responsible for the data leak; that person is either careless of the information or is simply unaware that sensitive data is being handled. But whenever a company loses such data, it results in bad media coverage, fines, litigation, and last but not least the corporate brand being irrevocably damaged.

Rik Ferguson, solutions architect with Trend Micro comments: "The survey highlights some key challenges, including user education, inadequate security policies and the broad brush access rights typical in many enterprises today. All too often employees simply do not know which information is confidential, within the remit of public domain or of restricted distribution. Even if the regulations were clear, employees are often unaware of the corporate policy around such information."

Out of the 1,600 people surveyed, only 6% admitted to having lost private corporate information. It seems that the Japanese are the least inclined to avow data leaking.

In regard to computer savvy, the Americans take the lead position with 74% of respondents claiming they are well aware which type of info is confidential and proprietary. On a personal note, the US respondents may be aware that the data is confidential, but about 12,000 laptops are lost in airports each week (most of the times the data on said laptops is not encrypted). The Japanese come last with only 40%, but the study shows that employees in large corporations are more aware of confidential data as opposed to those working in smaller companies.

The worrying part is that only 54% of companies have thought ahead and have come up with a data loss prevention policy; the remaining 46% of companies that took part in the study have no such preventive measure. Generally speaking, large corporations are more inclined to implement such a policy, as opposed to their smaller counterparts. Also, the study showed that UK based companies are the least preoccupied in coming up with and implementing such a security measure.

While at work, the study revealed that different nationalities have different surfing habits. The British for example are more inclined to do a spot of shopping or visit a social networking site; the Americans will watch or listen to streaming media; the Japanese will download .exe files. Statistics about the Germans were not in the study - presumably they just got on with their work.

Thursday, October 2, 2008

Wednesday, October 1, 2008

'onContextMenu' Example

 

    


<html>

<head>

<script language="JavaScript">

    
function function2() {

        
alert("This image is copyrighted") 

    
}

</script>

</head>

<body oncontextmenu="function2()">

    
<p>Right click in the image.</p>

    
<img oncontextmenu="function2()" 

         
src="http://www.navioo.com/style/logo.png" 

         
alt="www.navioo.com" 

         
width="99" 

         
height="76">

</body>

</html>

If you want to disable the context menu, 

add the following code to the <body>:

oncontextmenu="function2(); return false;"

      


      



Try it online

Friday, September 26, 2008

Keyczar, a Reliable Open Source Cryptography Tool

Cryptography has never been easier to handle
A Google-MIT team has just launched an open source encryption toolkit that can be used with both symmetric and asymmetric keys. In the first case, the same key helps both the encryption and decryption of a program. In order to decrypt the message, programmers must know what the secret key is. Decryption is usually made by a different user than the one who encrypts a program, so sharing the secret key must be made perfectly secure. Asymmetric keys are used to ensure a safe transport of the message from the sending programmer to the receiving one.

The features brought by the cryptography tool, namely Keyczar, make it of real help to coders in distress. One of these features is a simple Application Programming Interface that enables some applications use the services of another. Also, Keyczar brings a key rotation and versioning, which enables programmers with the possibility of assigning numbers to and keeping track of the latest versions of an application.

Safe default algorithms, modes (settings that enable user inputs to have more functions, depending on the settings provided by the coder) and key lengths are other features of the new Google open source product. Initialization vectors, used to produce different streams, by using the same encryption key, are automatically generated to give users a helpful hand. Ciphertext signatures are automatically generated, as well.

The tool can be used by both Java and Python programmers, while C fans have to wait a while, until the version to allow C implementation is developed. The team promises that this specific language will also be compatible with Keyczar in the near future. Java programmers are offered international support, which is expected for Python as soon as possible.

"Cryptography is easy to get wrong. Developers can choose improper cipher modes, use obsolete algorithms, compose primitives in an unsafe manner, or fail to anticipate the need for key rotation. Keyczar abstracts some of these details by choosing safe defaults, automatically tagging outputs with key version information, and providing a simple programming interface," says the team on the official webpage of the product.

Wednesday, September 24, 2008

Benchmarking AJAX ( JSON vs XML )

JSON produces smaller documents, and JSON is certainly easier to use in JavaScript. XMLHttpRequest parses XML documents for you whereas you have to manually parse JSON, but is parsing JSON slower than parsing XML?


Parsing JSON was 2 -10 times faster than parsing XML!

See the results Benchmarking AJAX ( JSON vs XML )