Monday, December 5, 2011

Evolution of the Hard Disk !

1 comments

sshot4e94869984867_thumb%25255B2%25255D.jpg?imgmax=800


Monday, November 21, 2011

[video] - The Future of Energy Management

3 comments
Learn how to reduce energy costs by managing Power over Ethernet devices, and much more, with Cisco EnergyWise.




Please put your comments here.
Monday, October 24, 2011

[CODE] Java MCast Sender & Receiver

0 comments
Most people need to test multicast  sender and receiver in
their developments.  So I thought to present a Sample java
code for multicast sender and Receiver.

This MCast sender can send a File as the data of  the payload.
Multicast receiver will capture those data and save those data to a
file.



MCast Sender source code:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.SocketException;
import java.net.UnknownHostException;

public class MulticastSender {

  public static void main(String[] args) {

    InetAddress ia = null;
    int port = 0;
    String characters = "Here's some multicast data\n";
    byte[] data = null;
    
    try 
    {
  FileInputStream input = new FileInputStream(args[2]);
  System.out.println("Data File Size: " + input.available() + " Bytes");
  data = new byte[input.available()];
  input.read(data);
  System.out.println("Read buffer Size: " + data.length  + " Bytes");
 } catch (FileNotFoundException e1) {
  System.err.println(e1);
  e1.printStackTrace();
 } catch (IOException e) {
  System.err.println(e);
  e.printStackTrace();
 }
    
    
    
    // read the address from the command line
    try {
      try {
        ia = InetAddress.getByName(args[0]);
      } catch (UnknownHostException e) {
        //ia = InetAddressFactory.newInetAddress(args[0]);
      }
      port = Integer.parseInt(args[1]);
    } catch (Exception e) {
      System.err.println(e);
      System.err.println("Usage: java MulticastSender [MulticastAddress] [port]  [File]");
      System.exit(1);
    }

   
    DatagramPacket dp = new DatagramPacket(data, data.length, ia, port);

    try {
      MulticastSocket ms = new MulticastSocket();
      ms.joinGroup(ia);
      ms.send(dp);
      ms.leaveGroup(ia);
      ms.close();
      System.out.println("File send. Length:"+ dp.getLength()  + " Bytes"); 
    } catch (SocketException se) {
      System.err.println(se);
    } catch (IOException ie) {
      System.err.println(ie);
    }

  }


MCast Receiver Source Code: 

import java.net.*;  /* import networking package */
import java.io.*;   /* import input/output package */

public class mcreceive {

  public static final int MAX_LEN  = 1024;  /* max receive buffer */
  public static final int MIN_PORT = 1024;  /* min network port */
  public static final int MAX_PORT = 65535; /* max network port */

  public static void main(String argv[]) {

    InetAddress mcAddress=null; /* multicast address */
    int mcPort=0;               /* multicast port */
    int ttl=1;                  /* time to live */
    boolean done=false;         /* variable for send loop */

     /* validate number of arguments */
    if (argv.length != 2) {
      System.out.println("Usage: mcreceive " +
                        "[Multicast IP] [Multicast Port] [Output File]");
      System.exit(1);
   }

    /* validate the multicast address argument */
    try {
      mcAddress = InetAddress.getByName(args[0]);
        System.out.println("MCast Group: " + group);
    } catch (UnknownHostException e) {
        e.printStackTrace();
      System.err.println(argv[0] + " is not a valid IP address"+ e);
      System.exit(1);
    }

    /* validate address argument is a multicast IP */
    if (! mcAddress.isMulticastAddress()) {
      System.err.println(mcAddress.getHostAddress() +
                         " is not a multicast IP address.");
      System.exit(1);
    }

    /* parse and validate port argument */
    try {
      mcPort = Integer.parseInt(args[1]);
    } catch (NumberFormatException nfe) {
      System.out.println("Invalid port number " + argv[1]);
      System.exit(1);
    }

    if ((mcPort < MIN_PORT) || (mcPort > MAX_PORT)) {
      System.out.println("Invalid port number " + mcPort);
      System.out.println("Port should be in range " + MIN_PORT
                         + " to " + MAX_PORT);
      System.exit(1);
    }

    try {

      /* instantiate a MulticastSocket */
      MulticastSocket sock = new MulticastSocket(mcPort);

      /* set the address reuse option */
      sock.setReuseAddress(true); // Java 1.4 and higher

      /* join the multicast group */
      sock.joinGroup(mcAddress);
     
      while (!done) {  /* loop forever */

        /* create a new DatagramPacket with an empty buffer */
        byte[] buf = new byte[MAX_LEN];
        DatagramPacket packet = new DatagramPacket(buf, buf.length);

        /* wait to receive packet into the DatagramPacket instance */
        sock.receive(packet);

        /* output the data from the packet received */
        System.out.println("Received " + packet.getLength() +
            " bytes from " + packet.getAddress() + ": "
            + new String(packet.getData(),0,packet.getLength()));
        FileOutputStream out = new FileOutputStream(args[2],true);
        byte[] bData = new byte[packet.getLength() + 10];

        for(int i=0;i < packet.getLength();i++)
             bData[i] = packet.getData()[i];
        
        out.write(bData);
        out.close();
      }
      
      sock.leaveGroup(mcAddress);
      sock.close();

    } catch (IOException e) {
      System.err.println(e.toString());
      System.exit(1);
    }
  }
}

Wednesday, October 5, 2011

[WEB] Shorten URL of your Blog or Web Site by Google Url Shortener

0 comments

Most of time we need to use an alias URL for out Blog. That is more use full to add to a different blog or while send to a friend. By our experience the google services are very reliable  and more clear. An other feature is the tracking the visitors. I used Google Url Shortener to create an alias for my blog. Here it is.

http://janaka077.blogsport.com  --->    http://goo.gl/Dmt5F

 http://img403.imageshack.us/img403/7336/46googleurl.jpg
Thursday, September 15, 2011

[ARTICLE] - Google Corporate Philosophy

0 comments

google_logo.gif

""The perfect search engine," says co-founder Larry Page, "would understand exactly what you mean and give back exactly what you want." When Google began, you would have been pleasantly surprised to enter a search query and immediately find the right answer. Google became successful precisely because we were better and faster at finding the right answer than other search engines at the time.
But technology has come a long way since then, and the face of the web has changed. Recognizing that search is a problem that will never be solved, we continue to push the limits of existing technology to provide a fast, accurate and easy-to-use service that anyone seeking information can access, whether they're at a desk in Boston or on a phone in Bangkok. We've also taken the lessons we've learned from search to tackle even more challenges."

Ten main points of Google's philosophy
  1. Focus on the user and all else will follow.
  2. It's best to do one thing really, really well.
  3. Fast is better than slow.
  4. Democracy on the web works.
  5. You don't need to be at your desk to need an answer.
  6. You can make money without doing evil.
  7. There's always more information out there.
  8. The need for information crosses all borders.
  9. You can be serious without a suit.
  10. Great just isn't good enough.
Visit to Read more : http://www.google.com/about/corporate/company/tenthings.html
Wednesday, September 14, 2011

[WEB] Download Youtube videos in selected file formats

0 comments
Most of Youtube download tools and sites are available in free. But It is very rear to find a tool for convert the video into other formats during the download. ClipConverter.cc site provide that facility.

First you need to enter youtube url in Media URL and select the appropriate file format. And you can adjust several parameters of video quality


Here you can set the output file name. If you didn’t set that it will use the original name of the video
Then it will download the video to web server. That will take some times. That time will depends on the size of video.

free image hosting


Finally you will get the link for converted video.

Monday, September 12, 2011

Java 7 introduced the support of String in switch-case statements [CODE]

2 comments
After 16 years of complaints, Java 7 has - at last! - introduced the support of String in switch-case statements.
 This allows us to code things such as:
boolean primary;
switch(color) {
case "red":
 primary=true;
 break;
case "green":
 primary=true;
 break;
case "blue":
 primary=true; 
 break; 
default:
 primary=false;
}
if (primary) System.out.println("This is a primary color");
Here is the issue ticket of that enhancement.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=1223179



This issue is logged in 02-OCT-1995. Hopefully now java developers able to use switch-case instead of if-else. 
 
That will increase the readability and the performance of the Code.
Refer the below WIKI page to understand the performance enhancement of switch-case statements.
http://en.wikipedia.org/wiki/Short-circuit_evaluation