Tuesday, 5 March 2013

DataCalculatingExample

DataCalculatingExample -:
                           [1000 milliseconds = 1 second
             60 seconds = 1 minute                                                
             60 minutes = 1 hour
             24 hours = 1 day]
            import java.text.SimpleDateFormat;
                 import java.util.Date;
 public class DataCalculatingExample{
      public static void main(String[] args) {
               String dateStart = "01/14/2012 09:29:58";
               String dateStop = "01/15/2012 10:31:48";
               //HH converts hour in 24 hours format (0-23), day calculation
               SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy              HH:mm:ss");
                      Date d1 = null;
                      Date d2 = null;
try {
                       d1 = format.parse(dateStart);
                       d2 = format.parse(dateStop);      //in milliseconds
                       long diff = d2.getTime() - d1.getTime();
                       long diffSeconds = diff / 1000 % 60;
                       long diffMinutes = diff / (60 * 1000) % 60;
                       long diffHours = diff / (60 * 60 * 1000) % 24;
                       long diffDays = diff / (24 * 60 * 60 * 1000);
                       System.out.print(diffDays + " days, ");
                       System.out.print(diffHours + " hours, ");
                       System.out.print(diffMinutes + " minutes, ");
                       System.out.print(diffSeconds + " seconds.");
}  catch (Exception e) {
                         e.printStackTrace();
}}}
Result
1 days, 1 hours, 1 minutes, 50 seconds.

Wednesday, 27 February 2013

Login with FaceBook

How to set up Login with facebook tutorial 

                           
Database set up file
                 Database  users table columns id, email, oauth_uid, oauth_provider and username.

                                                              CREATE TABLE users

(
id INT PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(70), 
oauth_uid VARCHAR(200),
oauth_provider VARCHAR(200),
username VARCHAR(100), 
twitter_oauth_token VARCHAR(200), 
twitter_oauth_token_secret VARCHAR(200) 
);


The a folders called facebook and  config with PHP files.      
                                                                      index.php
                                                                      home.php
                                                                      login-facebook.php   

Setup Facebook
              You have to create a application. Facebook will provide you app id and app secret id, just modify following code .
fcconfig.php
                         <?php
              define('APP_ID', 'Facebook APP ID');
              define('APP_SECRET', 'Facebook Secret ID');
            ?>
databaseconfig.php
        An Database configuration file. 
                          <?php
               define('DB_SERVER', 'localhost');
               define('DB_USERNAME', 'User Name');
               define('DB_PASSWORD', 'Password');
               define('DB_DATABASE', 'DATABASE');
               $connection = mysql_connect(DB_SERVER,     DB_USERNAME, DB_PASSWORD)                       ordie(mysql_error());
               $database = mysql_select_db(DB_DATABASE) or die(mysql_error());
             ?>
index.php
If you want to modify your web project existing login or index pages, just use following code. 
                           <?php
              session_start();
              if (isset($_SESSION['id'])) {
              // Redirection to login page facebook
              header("location: home.php");
              }
              if (array_key_exists("login", $_GET)) 
               {
              $oauth_provider = $_GET['oauth_provider'];
              if ($oauth_provider == 'twitter')
               {
              header("Location: login-twitter.php");
               }
              else if ($oauth_provider == 'facebook')
                 {
              header("Location: login-facebook.php");
                 }
               }
             ?>
 //HTML Code
      
      <a href="?login&oauth_provider=facebook">Facebook_Login</a>



For Best practices please download complete code HERE



For any Query and Suggestion feel free to comment below to make our service better

Thanks and Best regards
Amit Sharma

Life Of PI

Life Of PI  Past & Future

Life of Pi is a fantasy adventure novel by Yann Martel published in 2000.  The protagonist, Piscine Molitor "Pi" Patel , an Indian boy from Pondicherry , explores issues of spirituality and practicality from an early age. He survives 227 days after a shipwreck while stranded on a boat in the Pacific Ocean with a Bengal tiger named Richard Parker.

Inspiration

                                                                                   
                         Life of Pi is divided into three sections. In the first section, the main character, Pi, an adult, reminisces about his childhood. He was named Piscine Molitor Patel after a swimming pool in France. He changes his name to "Pi" when he begins secondary school, because he is tired of being teased with the nickname "Pissing Patel". His father owns a zoo in Pondicherry, providing Pi with a relatively affluent lifestyle and some understanding of animal psychology.
Pi is raised a Hindu, but as a fourteen-year-old he exposes himself to Christianity and Islam, and starts to follow all three religions as he "just wants to love God." He tries to understand God through the lens of each religion and comes to recognize benefits in each one.
Martel also stated that his inspiration for the book's premise came from reading a book review of Brazilian author Moacyr Scliar's 1981 novella Max and the Cats, about a Jewish-German refugee who crossed the Atlantic Ocean while sharing his boat with a jaguar. Scliar said that he was perplexed that Martel "used the idea without consulting or even informing me," and indicated that he was reviewing the situation before deciding whether to take any action in response. After talking with Martel, Scliar elected not to pursue the matter. A dedication to Scliar "for the spark of life" appears in the author's note of Life of Pi.

About

Director:    Ang Lee

Writers:

 David Magee (screenplay), Yann Martel (novel)

Stars:   

 Suraj SharmaIrrfan KhanAdil Hussain