Skip to main content

Posts

Showing posts from June, 2016

Tutorial-formatting floating point numbers in javascript

How to formatting floating point numbers in javascript In jQuery or javascript when we add or multiple or any mathematical opertaion perform on floating point numbers it gives wrong output . For Example if we add 0.1+0.2 using javascript it gives  0.30000000000000004 instead of 0.3 . so here is the solution of perform mathematical operations on floating point numbers with javascript. We are using 2 js function for this 1. parseFloat   2. toPrecision javascript snippet to solve js floating point numbers wrong output problem. <script> function cal() {  var a=0.1;  var b=0.2;  var c=parseFloat((a+b).toPrecision(10)); //Calculate like this  alert("parseFloat((0.1 + 0.2).toPrecision(10)) = "+c); } </script>

Get your gmail emails using php

How to get your gmail emails using php here is the short n simple script to get your gmail inbox messages and you can store them into your database . $imapPath = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';  $username = 'your-mail@gmail.com'; $password = 'your-password'; // try to connect $inbox = imap_open($imapPath,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); $emails = imap_search($inbox,'UNSEEN'); $output = ''; foreach($emails as $mail) {         $headerInfo = imap_headerinfo($inbox,$mail);         $output .= $headerInfo->subject.'<br/>';     $output .= $headerInfo->toaddress.'<br/>';     $output .= $headerInfo->date.'<br/>';     $output .= $headerInfo->fromaddress.'<br/>';     $output .= $headerInfo->reply_toaddress.'<br/>';         $emailSt...