Aarambam — Chennai Parkour

KarmaDude Nov 7, 2011

Flash Mob in Dubai Airport

KarmaDude Nov 7, 2011

Restore frozen iPhone 3G after erasing all data

KarmaDude Oct 30, 2011

Yesterday, I reset and erased all data on my jailbroken iPhone 3G, and ended up with a phone that will not startup. After a little searching around I came across the following steps to restore the iPhone:

  1. Shutdown the phone by holding down the Power+Home button for 10 seconds. Let go of the buttons when the screen flashes and goes blank
  2. Connect the USB cable to the computer, but NOT to the phone.
  3. Connect the other end of the USB cable to the iPhone while holding down the Home button (5 to 10 seconds), till the iTunes connection screen is displayed on the phone.
  4. iTunes will now detect the iPhone, and you will be able to restore the phone.

Note: This seems to happen only with Jailbroken iPhone 3Gs which are reset and erased.

source

PHP Command Line Progress Bar

KarmaDude Jun 20, 2009

A simple progress bar function for php command line (CLI) scripts:

function progressBar($current, $total, $label="Progress: ", $interval=5) {
    if ($current == 0) {
         echo $label;

         // start the bar
         echo "| 0%";
     } else {
         $pos = ($current / $total * 100);
          if( fmod($pos, $interval) == 0 ) {
              if( $pos >= 10 ) echo "\010";
              if( $pos == 100 ) echo "\010";

               echo "\010\010\010";
               echo "| $pos%";
           }
       }

       // end progress with a new line
       if ($current == $total) echo "\n";
}

Reference code: PHP CLI Progress Indicator

WordPress Comment Stats Query

KarmaDude Jan 14, 2009

Here is a query you can run against your WordPress comments table to view total comments by year and month. If you use a different table name prefix, then substitute ‘wp’ with your table name prefix.

SELECT year(comment_date) as y, month(comment_date) as m, concat(substr(monthname(comment_date),1,3), " ", year(comment_date)) as month, count(*) as total
FROM wp_comments
GROUP BY y, m
ORDER BY m, y ASC