PHP Command Line Progress Bar

KarmaDude Jun 20, 2009 1 Comment

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 2 Comments

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

Apple’s Suggested Fix For iPhone 3G GPS Malfunction

blogswami Aug 8, 2008 4 Comments

My iPhone 3G GPS thinks I am in Minnesota even though I am in Utah. So I called up Apple support, and here is their simple set of steps to supposedly solve the GPS issue! Did not work for me though.

  • Go to Settings->General
  • Turn Location Services Off
  • Go to Home Screen
  • Go back to Settings
  • Turn Airplane mode on and wait 20 seconds
  • Turn Airplane mode off
  • Go to Home Screen and then back to Settings->General
  • Tap on Reset, and then Reset Network Settings (WARNING: You will lose all your network settings)
  • Go to Home and the Settings->General
  • Turn Location Services On

Seriously, is this a joke or some wizard at Apple sat and figured this sequence! Here is a suggestion, Settings->General->Reset->Reset GPS Settings, now that would have been an Apple like solution.

Stop-Loss (The Shady Military Policy)

Missy Jul 3, 2008 Add comment

I never had any interest in seeing the movie Stop-Loss.  I didn’t know what stop-loss meant and I wasn’t interested in finding out until I came across a newspaper article in the Ogden Standard Examiner a few weeks ago.  The article was about a serviceman who was in Iraq and his experiences.  To summarize in the best way I can remember, the serviceman was in a vehicle driving along with some others and they hit a mine.  The blast knocked him out and he had been hurt so badly that he was flown to a hospital in Germany.  While he was there he found out that one of his eardrums had been blown out and that he had some brain damage.  The doctor told him that he was not to be around any loud noises and that he was not going back to Iraq.

Days or weeks later another military doctor came to see him and signed him off to return to the fight.  He can’t hear out of one ear, he is brain damaged, and they are forcing him to go back into the war.  I thought this was horrible, but the article just got worse.  He was supposed to be done with his tour in August, but because he got hurt and had to have months of rehabilitation the government is sending him back, brain damaged and all, to make up for the time he was in the hospital.  Stop-loss is the most ridiculous policy I have ever heard of.  This is just one straw in the bale of corruption that our government lives by everyday.

Metros at rush hour

KarmaDude Jun 30, 2008 1 Comment

Tokyo, Japan

Mumbai, India

Moscow, Russia

Page 1 of 5912345...Last »