Pages

Wednesday, 25 July 2012

How to create dynamic tables in HTML using javascript at runtime?

In this tutorial, you will come to know how to create dynamic tables in HTML. There are some situations when you don't know the contents of the table at design time while creating the table. In this condition, you want to load and fill the table at run time. Here in this code we will write javascript code to create the table at runtime.

Code Snippet

<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">
function CreateTable()
{
    var tablecontents = "";
    tablecontents = "<table>";
    for (var i = 0; i < 5; i ++)
   {
      tablecontents += "<tr>";
      tablecontents += "<td>" + i + "</td>";
      tablecontents += "<td>" + i * 100 + "</td>";
      tablecontents += "<td>" + i * 1000 + "</td>";
      tablecontents += "</tr>";
   }
   tablecontents += "</table>";
   document.getElementById("tablespace").innerHTML = tablecontents;
}
</script>

</head>

<body onload="CreateTable()">
<h1>My First Web Page</h1>
<p id="tablespace"></p>
</body>
</html>


Explanation: Here in this code snippet, in the body of the html page, there is a <p> tag in which we want to place a table at runtime. So, we are calling a javascript function 'CreateTable' on the load of page. It will create table at runtine and will change the innerHTML of <p> tag at runtime.

Monday, 23 July 2012

How to make most of the To-Do list?

A recent LinkedIn survey studied 6500 professionals worldwide across 17 industries to understand how people tackle tasks for a given workday through the use of to-do lists. The result: Not everyone plans their day through a to-do list; those who do comprise 63 percent of all professionals surveyed. Further, only 11 percent admitted to being able to achieve all tasks they planned to do by the end of a given working day.
  
Tanuj Kapoor, manager – Talent management, in a leading retail brand, says “Sitting down first thing in the morning and making the list is the most difficult, especially when you are at maximum energy levels and want to just hit work!” However, once the list is in place, things are way simpler, he adds.
  
So, while the importance of a to-do list is universally acknowledged, how can one ensure its effectiveness in achieving work targets? A big challenge lies in its creation and the ability to follow it effectively.
  
Break it down. A list’s purpose is to keep you focused. However, if you get overwhelmed and panic by looking at the sheer volume of work to be done, it’s time to break the list down into smaller sections.
  
Getting overwhelmed will not get you going. Getting organised is the key. Rather than listing the complete project, which of course is the final goal, write down the smaller, individual aspects of the overall task. Visualisation is a great tool; when your list shows you exactly “where” to start and “how” to go about a big task, you would approach your day with more confidence in actually achieving the set targets.
  
Prioritise. Next, create an order of priority for task completion. According to Mindtools.com, a well known management and leadership training site, “Great time management means being effective as well as efficient. Managing time effectively, and achieving the things that you want to achieve, means spending your time on things that are important and not just urgent.”
  
Sure, everything needs to be done, but you need to decide “how” to tackle the list. This is important, as it will ultimately determine your efficiency. The popular ‘Urgent/Important Matrix’ is a useful tool for this. Place tasks under four sub-categories:
  • Urgent, important – Deadlines, emergencies, submissions (To be done now)
  • Important, not urgent – Planning, scheduling, research (To be scheduled)
  • Not important, urgent – Requests from others (Can be rejected or assessed later)
  • Not important, not urgent – Wasteful activities like excessive breaks, net surfing, etc. (To be minimised and avoided)
Eliminate procrastination from the list. Then there are those tasks we do not want to tackle, and these seem to linger forever in the to-do list. While it helps you stay focused by always having your tasks in sight, it kills the very purpose of the list if you don’t do anything about it. Tasks that are not immediately urgent run the risk of occupying the perennial slot under the “can be done later” category. Same is the case with tasks that seem tedious, or those you don’t particularly like. Or maybe you are being plain lazy about it.
  
Keep a daily check on the list. While you add new items, ensure that a given task is being accomplished in its stipulated time frame. Maintaining a “Start by” and an “End by” date for individual tasks proves extremely useful in keeping tab on the progress made.
  
Schedule work now, re-schedule distractions for later. LinkedIn’s survey showed that unplanned tasks like meetings, emails and phone calls are the primary cause of failing to complete all items on the to-do list. Such distractions not only break your train of thought, but also add extra minutes that you will require to shift focus back to the task at hand. 
  
While it is difficult to completely avoid meetings and emails on a typical working day at office, you can work towards achieving single-minded focus on one task. It’s about breaking compulsive habits like checking mail every few minutes or answering every call on your phone; even meetings can be timed around your work schedule, with a defined start and end time to prevent loss of focus from work as well as the overall day plan.

Tuesday, 17 July 2012

VPN Technology: Virtual Private Networks


What is VPN (Virtual Private Network)?

A virtual private network (VPN) is a private computer network that interconnects remote (and often geographically separate) networks through primarily public communication infrastructures such as the Internet.

 Types of VPN connections

1. Remote access VPN
2. Site-to-site VPN

1. Remote Access VPN

Remote access VPN connections enable users working at home or on the road to access a server on a private network using the infrastructure provided by a public network, such as the Internet. From the user’s perspective, the VPN is a point-to-point connection between the computer (the VPN client) and an organization’s server. The exact infrastructure of the shared or public network is irrelevant because it appears logically as if the data is sent over a dedicated private link.

2. Site-to-Site VPN

Site-to-site VPN connections (also known as router-to-router VPN connections) enable organizations to have routed connections between separate offices or with other organizations over a public network while helping to maintain secure communications.

VPN Protocols

There are a number of VPN protocols in use that secure the transport of data traffic over a public network infrastructure. Each protocol varies slightly in the way that data is kept secure.

1. IP security (IPSec)

IP security (IPSec) is used to secure communications over the Internet. IPSec traffic can use either transport mode or tunneling to encrypt data traffic in a VPN. The difference between the two modes is that transport mode encrypts only the message within the data packet (also known as the payload) while tunneling encrypts the entire data packet. IPSec is often referred to as a "security overlay" because of its use as a security layer for other protocols.

2. Secure Sockets Layer (SSL) and Transport Layer Security (TLS)

Secure Sockets Layer (SSL) and Transport Layer Security (TLS) use cryptography to secure communications over the Internet. Both protocols use a "handshake" method of authentication that involves a negotiation of network parameters between the client and server machines. To successfully initiate a connection, an authentication process involving certificates is used. Certificates are cryptographic keys that are stored on both the server and client.

3. Point-To-Point Tunneling Protocol (PPTP)

Point-To-Point Tunneling Protocol (PPTP) is another tunneling protocol used to connect a remote client to a private server over the Internet. PPTP is one of the most widely used VPN protocols because of it's straightforward configuration and maintenance and also because it is included with the Windows operating system.

4. Layer 2 Tunneling Protocol (L2TP)

Layer 2 Tunneling Protocol (L2TP) is a protocol used to tunnel data communications traffic between two sites over the Internet. L2TP is often used in tandem with IPSec (which acts as a security layer) to secure the transfer of L2TP data packets over the Internet. Unlike PPTP, a VPN implementation using L2TP/IPSec requires a shared key or the use of certificates.

Where is VPN technology used?

VPN technology is used in large corporations, educational institutions, and government agencies to enable remote users to securely connect to a private network.

VPN vs Leased Lines / Dial-up connections

Leased lines, such as ISDN (integrated services digital network, 128 Kbps), are private network connections that a telecommunications company could lease to its customers. Leased lines provide a company with a way to expand its private network beyond its immediate geographic area. These connections form a single wide-area network (WAN) for the business. Though leased lines are reliable and secure, the leases are expensive, with costs rising as the distance between offices increases.

Today, the Internet is more accessible than ever before, and Internet service providers (ISPs) continue to develop faster and more reliable services at lower costs than leased lines. To take advantage of this, most businesses have replaced leased lines with new technologies that use Internet connections without sacrificing performance and security. Businesses started by establishing intranets, which are private internal networks designed for use only by company employees. Intranets enabled distant colleagues to work together through technologies such as desktop sharing. By adding a VPN, a business can extend all its intranet's resources to employees working from remote offices or their homes.

Advantages of VPN Technology

1. Use of internet as communication channel

A VPN is a inexpensive effective way of building a private network. The use of the Internet as the main communications channel between sites is a cost effective alternative to expensive leased private lines. The costs to a corporation include the network authentication hardware and software used to authenticate users and any additional mechanisms such as authentication tokens or other secure devices. The relative ease, speed, and flexibility of VPN provisioning in comparison to leased lines makes VPNs an ideal choice for corporations who require flexibility. For example, a company can adjust the number of sites in the VPN according to changing requirements.

2. VPNs enable file sharing, screen sharing, video conferencing and similar network services.

3. Allows you to be at home and access your company's computers in the same way as if you were sitting at work.

4. Almost impossible for someone to tap or interfer with data in the VPN tunnel.

5. If you have VPN client software on a laptop, you can connect to your company from anywhere in the world.

Disadvantages of VPN Technology

1. Lack of Quality of Service (QoS) management

There are several potential disadvantages with VPN use. The lack of Quality of Service (QoS) management over the Internet can cause packet loss and other performance issues. Adverse network conditions that occur outside of the private network is beyond the control of the VPN administrator. For this reason, many large corporations pay for the use of trusted VPNs that use a private network to guarantee QoS.

2. Vendor interoperability

Vendor interoperability is another potential disadvantage as VPN technologies from one vendor may not be compatible with VPN technologies from another vendor. Neither of these disadvantages have prevented the widespread acceptance and deployment of VPN technology.

3. Setup is more complicated than less secure methods. VPN works across different manufacturers' equipment, but connecting to a non-NETGEAR product will add to difficulty, since there may not documentation specific to your situation.

4. The company whose network you connect to may require you to follow the company's own policies on your home computers.

Wednesday, 11 July 2012

How to create Logfiles in Delphi?

Manytimes in your delphi project, you will require to print logfiles in order to track the flow of control. Here is a simple code snippet to print logfiles in delphi.

Code snippet

procedure TMyClass.CreateLogfile;
var
  aLine : string;
  aFileName : string;
  myFile : TextFile;
  aFilePath : string;
begin
  try
    aLine := 'The line which you want to print. You can change this line dynamically by passing   aLine as  parameter to CreateLogfile function';
    aFileName := 'MyLogfile_' + FormatDateTime('dd-mm-yyyy',Now)+'.log';
    aFilePath := 'C:\ProjectFolder\'+aFileName;
    AssignFile(myFile, aFilePath);
    if FileExists(aFilePath) then
      Append(myFile)
    else
      Rewrite(myFile);
    WriteLn(myFile, FormatDateTime('dd-mmm-yyyy hh:nn:ss.zzz',Now) + ': ' + ALine);
    Flush(myFile);
  finally
    CloseFile(myFile);
  end;
end;


Explanation: CreatLogfile function creates a logfile MyLogfile_TodaysDateTime.log at C:\ProjectFolder. If the logfile exists, it will append the line at the end otherwise it will create a new logfile and then writes to it. Logfile will be created new on everyday as the DateTime will get changed everyday. Thats why, DateTime is embedded with the name of logfiles. If you don't want to create a new logfile everyday, just remove the datetime field from the name of logfile and keep it simple like MyLogfile.log.

I think, you have understood my point. For any doubts, just inform me. I will be pleased to help you.

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.