Saturday 11 May 2013

Youtube Video Download

YouTube videos are viewed by a million of users everyday. However, at times we may want to view the video offline.There are a few ways of downloading videos from youtube. I am going to mention the one I find the most simplest & which requires minimal effort.


The following are the steps:

1. Type the URL "youtu.be" in the Address bar of the web browser.


                
             

2. Select the video you want to watch (I have selected "Introducing Samsung GALAXY S4 ").

                       
                        
3. Right click on the video and select "Pop out".




4. A pop up box with same video will open.
                         
                           

5. Wait for the video to load a little bit & select "Save Video As".

                       



6. Save the video with the name you want & click 'Save'.

                            





7. Video will start downloading.
                             

8. View your downloaded file with your desired media player.



Hope this was helpful!!

Sunday 28 April 2013

Nested For Loop Simplified

For Loop is used in programming languages almost in every code snippet. Moreover, if a program involves a multidimensional array , then the use of nested loop(inner loop)  is inevitable. The most simplest form of code of assigning a value to the multidimensional array using a For Loop is as follows:


PHP snippet                                                                            
                                                                              
$a = array();

for($l=0;$l<3;$l++){
    for($m=0;$m<3;$m++){
        $a[$l][$m] = 1;
        echo "Array:[".($l)."] [".($m)."]"." ";
         echo "Value: ".$a[$l][$m];
        echo "<br>";
       
    }
}

PHP Result

Array:[0] [0] Value: 1
Array:[0] [1] Value: 1
Array:[0] [2] Value: 1
Array:[1] [0] Value: 1
Array:[1] [1] Value: 1
Array:[1] [2] Value: 1
Array:[2] [0] Value: 1
Array:[2] [1] Value: 1
Array:[2] [2] Value: 1

However, if the same result is to be achieved with one loop rather than using nested loop, then the following code can prove to be useful:

PHP snippet

$l=3;     //Inner Loop
$m =3;   // Outer Loop
$a = array();
  
 for($i=$l;$i<(($m*$l)+$l); $i++){

    $j = $i % $l;
    $k = intval($i/$l);
    $a[$k-1][$j] = 1;
    echo "Array:[".($k-1)."] [".($j)."]"." ";
    echo "Value: ".$a[$k-1][$j];
    echo "<br>";
 }

PHP Result:

Array:[0] [0] Value: 1
Array:[0] [1] Value: 1
Array:[0] [2] Value: 1
Array:[1] [0] Value: 1
Array:[1] [1] Value: 1
Array:[1] [2] Value: 1
Array:[2] [0] Value: 1
Array:[2] [1] Value: 1
Array:[2] [2] Value: 1


This program is also used to reduce the Time Complexity to a certain extent.