Google voice search for PC

Google voice search for PC
After introducing a mobile app now Google has introduced the Search by voice feature for desktops as well. It’s easy to search out loud. All you need is Google Chrome and a built-in or attached microphone. To get started:
  1. Download and install Latest version of Google Chrome.
  2. Open Chrome and go to google.com.
  3. Just click the mic in the search bar and start talking.
Note:-
Right now Voice Search is available for Google Chrome and US English only.

Handy For

Hard-to-spell searches
Makes searching words you're not sure how to spell quicker and easier.


Searches that are just more fun to search out loud
Now you can ask your computer anything.

Longer searches
Search long queries, even longer queries, just by talking.

Searching without any typing
Use it in the kitchen, in the garage or anytime your hands might be full.

More Detail
Read more...

Countdown timer in javascript

In this programming tutorial you will learn how to develop the countdown timer in javascript. I have got the countdown timer code from internet but I have found lot of bugs in it during its testing process, after fixing those bugs I have decided to share it with you people. Following are the features of this countdown timer
  1. Cross browser compatibility.
  2. Doesn’t get unnecessary calls.
  3. Easy to implement.
  4. Work smoothly and perfectly.
Countdown timer in javascript
Just you have to do is to set a specific target date in the future, get the current date and then calculate the remaining time between them.

So let’s have a look over the example given below

Countdown timer in javascript

Countdown.html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script> 
<script language="javascript" type="text/javascript">
function countdown(yr, m, d) {
            var montharray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
            theyear = yr; themonth = m; theday = d
            var today = new Date()
            var todayy = today.getYear()
            if (todayy < 1000)
                todayy += 1900
            var todaym = today.getMonth()
            var todayd = today.getDate()
            var todayh = today.getHours()
            var todaymin = today.getMinutes()
            var todaysec = today.getSeconds()
            var todaystring = montharray[todaym] + " " + todayd + ", " + todayy + " " + todayh + ":" + todaymin + ":" + todaysec
            futurestring = montharray[m - 1] + " " + d + ", " + yr
            dd = Date.parse(futurestring) - Date.parse(todaystring)
            dday = Math.floor(dd / (60 * 60 * 1000 * 24) * 1)
            dhour = Math.floor((dd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1)
            dmin = Math.floor(((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1)
            dsec = Math.floor((((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1)
   if (dday == 0 && dhour == 0 && dmin == 0 && dsec == 1) {
   alert("12");
                document.getElementById('days1').innerHTML = "-";
                document.getElementById('days2').innerHTML = "-";
                document.getElementById('hrs1').innerHTML = "-";
                document.getElementById('hrs2').innerHTML = "-";
    document.getElementById('min1').innerHTML = "-";
                document.getElementById('min2').innerHTML = "-";
    document.getElementById('sec1').innerHTML = "-";
                document.getElementById('sec2').innerHTML = "-";
                return
            }
            else {
                if (dday > 0 || dhour > 0 || dmin > 0 || dsec > 0) 
    {//Some time remaining
                    if (dday <= 0) 
     {//If we have time of less than a day
                        document.getElementById('days1').innerHTML = "-";
                        document.getElementById('days2').innerHTML = "-";

                    }
                    if (dday > 0 && dday < 10) 
     {
                        //IF day is let's suppose 9
                        document.getElementById('days1').innerHTML = 0;
                        document.getElementById('days2').innerHTML = dday;
                    }
                    else 
     {
                        //IF day is let's suppose >=10
                        var numDays = new Number(dday);
                        numDays = numDays.toString();
                        if (numDays.length == 1) 
      {
                            document.getElementById('days1').innerHTML = 0;
                            document.getElementById('days2').innerHTML = numDays.substring(0, 1);
                        }
                        else 
      {
                            document.getElementById('days1').innerHTML = numDays.substring(0, 1);
                            document.getElementById('days2').innerHTML = numDays.substring(1, 2);
                        }
                    }
                    //Day region Ends Here

                    //Hour Region Starts Here
     if (dhour <= 0) 
     {
                        document.getElementById('hrs1').innerHTML = "-";
                        document.getElementById('hrs2').innerHTML = "-";

                    }
                    if (dhour > 0 && dhour < 10) 
     {
                        document.getElementById('hrs1').innerHTML = 0;
                        document.getElementById('hrs2').innerHTML = dhour;
                    }

                    else 
     {
                        var numHrs = new Number(dhour);
                        numHrs = numHrs.toString();
                        if (numHrs.length == 1) 
      {
                            document.getElementById('hrs1').innerHTML = 0;
                            document.getElementById('hrs2').innerHTML = numHrs.substring(0, 1);
                        }
                        else 
      {
                            document.getElementById('hrs1').innerHTML = numHrs.substring(0, 1);
                            document.getElementById('hrs2').innerHTML = numHrs.substring(1, 2);
                        }
                    }
     //Hour Region Ends Here
     
     //Minute Region Starts Here
     if (dmin <= 0) 
     {
                        document.getElementById('min1').innerHTML = "-";
                        document.getElementById('min2').innerHTML = "-";

                    }
                    if (dmin > 0 && dmin < 10) 
     {
                        document.getElementById('min1').innerHTML = 0;
                        document.getElementById('min2').innerHTML = dmin;
                    }

                    else 
     {
                        var numMins = new Number(dmin);
                        numMins = numMins.toString();
                        if (numMins.length == 1) 
      {
                            document.getElementById('min1').innerHTML = 0;
                            document.getElementById('min2').innerHTML = numMins.substring(0, 1);
                        }
                        else 
      {
                            document.getElementById('min1').innerHTML = numMins.substring(0, 1);
                            document.getElementById('min2').innerHTML = numMins.substring(1, 2);
                        }
                    }
     //Minute Region Ends Here
     
     //Second Region Starts Here
     if (dsec <= 0) 
     {
                        document.getElementById('sec1').innerHTML = "-";
                        document.getElementById('sec2').innerHTML = "-";

                    }
                    if (dsec > 0 && dsec < 10) 
     {
                        document.getElementById('sec1').innerHTML = 0;
                        document.getElementById('sec2').innerHTML = dsec;
                    }

                    else 
     {
                        var numSecs = new Number(dsec);
                        numSecs = numSecs.toString();
                        if (numSecs.length == 1) 
      {
                            document.getElementById('sec1').innerHTML = 0;
                            document.getElementById('sec2').innerHTML = numSecs.substring(0, 1);
                        }
                        else 
      {
                            document.getElementById('sec1').innerHTML = numSecs.substring(0, 1);
                            document.getElementById('sec2').innerHTML = numSecs.substring(1, 2);
                        }
                    }
     //Second Region Ends Here
     setTimeout("countdown(theyear,themonth,theday)", 1000)
                }
    //Don't comment this below mentioned else statement
    //This statement is very much helpful when you will perform testing of this code by providing old date
    //This else statement will only executed when you provide old date as compared to current date
                else {
                    document.getElementById('days1').innerHTML = "-";
                    document.getElementById('days2').innerHTML = "-";
                    document.getElementById('hrs1').innerHTML = "-";
                    document.getElementById('hrs2').innerHTML = "-";
     document.getElementById('min1').innerHTML = "-";
                    document.getElementById('min2').innerHTML = "-";
                    document.getElementById('sec1').innerHTML = "-";
                    document.getElementById('sec2').innerHTML = "-";

                }

            }
        }
    $(document).ready(function () {
            countdown(2011, 12, 25);
        });

</script>

And here's the html code of this example that you will copy and paste in your web page
<div style="border: medium none; padding: 12px; margin: 0px 0px 480px 27px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 20px;font-family:verdana;">Days</div>

  <div style="border: medium none; padding: 12px; margin: 0px 0px 480px 157px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 20px;font-family:verdana;">Hrs</div>

<div style="border: medium none; padding: 12px; margin: 0px 0px 480px 280px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 20px;font-family:verdana;">Mins</div>

<div style="border: medium none; padding: 12px; margin: 0px 0px 480px 400px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 20px;font-family:verdana;">Secs</div>

<div style="border: medium none; padding: 12px; margin: 0px 0px 400px 27px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 50px;"
        id="days1"> </div>
<div id="days2" style="border: medium none; padding: 12px; margin: 0px 0px 400px 80px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px;
        "> </div>
<div id="hrs1" style="border: medium none; padding: 12px; margin: 0px 0px 400px 157px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px;
       "> </div>
<div style="border: medium none; padding: 12px; margin: 0px 0px 400px 212px; position: absolute;
        z-index: 1000; bottom: 0px; left: 0px; font-size: 50px;"
        id="hrs2"> </div>
<div id="min1" style="border: medium none; padding: 12px; margin: 0px 0px 400px 280px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px; 
         "></div>
<div id="min2" style="border: medium none; padding: 12px; margin: 0px 0px 400px 330px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px; 
         "></div>
<div id="sec1" style="border: medium none; padding: 12px; margin: 0px 0px 400px 400px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px; 
         "></div>
<div id="sec2" style="border: medium none; padding: 12px; margin: 0px 0px 400px 450px;
        position: absolute; z-index: 1000; bottom: 0px; left: 0px; font-size: 50px; 
         "></div>

This countdown timer function will give you countdown between current date, that it will pick from your system date, and the date mentioned in calling of countdown timer function which is countdown(2011, 12, 25);

You just have to replace this date with the date you desire for countdown time. I have used jquery’s $(document).ready(function ()) event because I want to execute this function when every DOM is loaded. But if you don’t want to use jquery and its ready event then exclude the jquery file and its code from the example and copy/paste following code just before </html> tag

<script language="javascript" type="text/javascript">
countdown(2011, 12, 25);
</script>

This technique is equivalent to jquery’s document.ready event.

I have used two divs for showing days, two divs for showing hours, two divs for showing minutes and again two divs for showing seconds. For example if remaining days are 14 then 1 will be store in days1 div and 4 will be stored in days2 div. You can use one div for showing remaining days, hours, minutes and seconds.

Moreover, I have applied all the checks in javascript code so that function will not get any extra call if countdown is finished, I have seen lot of code in internet that work perfectly but when countdown is finished but its code is still in web page then the countdown function gets extra and totally unnecessary calls but in my example I have taken care of this issue and avoid extra calls to the countdown timer function.

So that’s it.
I love your feedback.

Read more...

Export to excel in php with jquery

In this programming tutorial we will learn how to perform export to excel in php. I have already written a post on same topic in asp.net as well. In php there are various methods for this purpose. In this tutorial I will discuss the very basic method that will export the plain data in table to excel. Let’s have a look over the example given below.
Export to excel in php with jquery
default.php
<html>
<head>
<title>Export to excel in php</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<style type="text/css">
.myClass
{
font-family:verdana;
font-size:11px;
}
</style>
</head>
<body>
<form action="exporttoexcel.php" method="post" 
onsubmit='$("#datatodisplay").val( $("<div>").append( $("#ReportTable").eq(0).clone() ).html() )'>
  <table id="ReportTable" width="600" cellpadding="2" cellspacing="2" class="myClass">
    <tr>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Country</th>
    </tr>
    <tr>
      <td><center>
          Adeel
        </center></td>
      <td><center>
          Fakhar
        </center></td>
      <td><center>
          Pakistan
        </center></td>
    </tr>
    <tr>
      <td><center>
          Zeeshan
        </center></td>
      <td><center>
          Butter
        </center></td>
      <td><center>
          England
        </center></td>
    </tr>
    <tr>
      <td><center>
          Neil
        </center></td>
      <td><center>
          Johnson
        </center></td>
      <td><center>
          United Kingdom
        </center></td>
    </tr>
    <tr>
      <td><center>
          Diala
        </center></td>
      <td><center>
          Katherine
        </center></td>
      <td><center>
          America
        </center></td>
    </tr>
  </table>
  <table width="600px" cellpadding="2" cellspacing="2" border="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><input type="hidden" id="datatodisplay" name="datatodisplay">
        <input type="submit" value="Export to Excel">
      </td>
    </tr>
  </table>
</form>
</body>
</html>
exporttoexcel.php
<?php
header('Content-Type: application/force-download');
header('Content-disposition: attachment; filename=export.xls');
// Fix for crappy IE bug in download.
header("Pragma: ");
header("Cache-Control: ");
echo $_REQUEST['datatodisplay'];
?>
In the onSubmit event of form, I am appending the div with ReportTable table. Using clone() method of jquery, I am making the clone of the ReportTable table that I wanted to export to excel, and in the end I am assigning the html of that cloned table to hidden field available in my form so that when form is posted then the data will be transferred to the exporttoexcel.php web page and in that web page I have all my logic for exporting data to excel in php.

Copy/paste this example, run the page and enjoy.

Note: - For this example to run properly, there must be no declaration of inline css in your table or div that you want to export. Whenever you use the style attribute to give inline css, the export to excel functionality will not be performed according to your expectations.

Later on, in this blog I will tell you other methods for this purpose; those methods will perform exporting with all the formatting that you have applied to the data of your table.

If you want to share your methods/techniques for export to excel in php then don’t hesitate to share with the rest of world through our blog.

So that’s it.
I love your feedback.

Update Note at 05-Oct-2011

Hay guys i really apologize that i miss an important line in the end of exporttoexcel.php page, the line is
echo $_REQUEST['datatodisplay'];
The above mentioned line of code will export the table data to excel. The absence of this line causing the generation of blank excel file that was also complained below by users in comments section . Now tutorial has been updated, I'm sorry for inconvenience.
Read more...

List all tables in a mysql database

In this programming tutorial we will learn how to list all tables in a mysql database. Sometimes you may want to get the table names of a mysql database; in that case the below mentioned show command will be very handy to you. It is as simple as reading a,b,c. Let’s have a look over it.

Show or List all tables in a mysql database
First of all you have to select the database whose tables you want to see.
Using this command, you will select the database.

use your_db_name

Replace your_db_name with the database name. And then use below mentioned command to get list of all tables in that database.

show tables

Yeah show tables command will do what you want.

So that’s it.
I love your feedback

Read more...

Change default Port of the ASP.NET Development Server

In this programming tutorial we will learn how to change default Port of the ASP.NET Development Server. Today one of my friend got alert message when he tried to view page in browser. He got this alert message. Unable to launch the asp.net development server because port '8080' is in use. We have solved this issue by changing the default port of the ASP.NET Development Server but there are two more ways to solve this issue as well. I will discuss those two ways as well in this tutorial. So lets start.

1) Change default Port of the ASP.NET Development Server

When you use the ASP.NET Development Server to run a file-system Web site, by default, the Web server is invoked on a randomly selected port for localhost. For instance, if you are testing a page called index.aspx and you run the page using the built-in ASP.NET Development Server also called Cassini Web Server, the URL of the page might be the following:
http://localhost:8080/index.aspx

Port is assigned according to project location as well.

You have the option to select which port is used when using the built-in development server. The steps to specify the port to be used are slightly different for a website project or for a web application project.

To specify a port for the ASP.NET Development Server - WebSite / WebServices project

  1. In Solution Explorer, right click the name of the application.
  2. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list. It will enable editing of the Port number property.
  3. In the Properties pane, click the text box beside Port number and type in a port number that you want.
  4. Click outside of the Properties pane. This saves the property settings.

Whenever you run a file-system Web site within Visual Web Developer or visual studio then the ASP.NET Development Server will listen on the specified port.

To specify a port for the ASP.NET Development Server - Web Application project

  1. Right click the Project in the Solution Explorer -> select Properties
  2. Click Web tab.
  3. Check Specific port rather than Auto-assign Port.

This was the one solution and it was also the topic of my tutorial. But the other two ways to fix the Unable to launch the asp.net development server because port '8080' is in use issue are quite simple.

2) Restart your system

Yeah in computer science restarting the system normally fix many issues :) . It is better to delete the temporary files by typing %temp% command in run before restarting the system.

3) Change the location of the folder

Change the location of the Folder contains all the files of your website, to some thing else. Load in project in visual studio or visual web developer whatever you have installed in your system and run the project again. and u have done it.

It will work because the ASP.NET Development Server chooses a new port number to run the project.

So that's it :)
I love your feedback.
Read more...