November 20, 2008

Adding A User In MySQL

Do you need to quickly add a specific user with access to only a certain table? Issue this command as a root or admin user:

GRANT ALL ON testdb.* TO 'testuser'@'localhost' IDENTIFIED BY 'pass1';

You can also limit user’s privileges to specific ip addresses or domains in case you need to access your databases from a different host.

GRANT ALL ON *.* TO 'testuser'@'remote.farmsoftstudios.com' IDENTIFIED BY 'pass1';

October 1, 2008

Pandora Music Application

I wrote a little application that allows you to play music from Pandora right from your dock. It does not take up a tab in your web browser, and it supports playing while minimized, which Safari does not. You can get it here: http://www.farmsoftstudios.com/pandora/

September 12, 2008

Alternating Table Backgrounds in PHP

If you like the alternating table backgrounds that are in applications like iTunes, and want them in your web application, there is a simple way to do so in PHP:

<table>
 <tr class=”title”>
  <td></td>
 </tr>
<?php
$i
=0;
foreach(
$row as $r){
   if(
$i&0){$alt=‘ class=”even”‘;}else{$alt=;}
   echo 
“<tr”.$alt.“>”;
   
//other table stuff in here
   
$i++;
   echo 
“</tr>”;
}
?>
</table>

September 8, 2008

Project Management

These days, I consider the failure to use version control a professional malpractice. I’m also a zealot when it comes to deleting dead code. In fact, I derive quite a bit of enjoyment out of deleting existing code. Unused code, old code, mockups, things that were started and never finished, things that someone thought they needed and never did—I’m delighted to delete them all.

Quoting from the latest PHP|Architect (August 2008) article, I found Jeff Moore’s writing insightful as well as helpful.  A strong contender for clean code, he suggests deleting stranded, dead, or depreciated codeblocks.  As far as his suggestion for version control, I would completely agree.  I maintained/wrote an entire project without version control (along with two other developers), and I sincerely hope that I never have to do that again.  It was a total disaster.  FTP overwrites, deleted code that had dependancies, and no way to roll back equalled extreme project management headaches.

 

My Advice: Use Version Control. Period.

May 1, 2008

DRY

Don’t Repeat Yourself.  It’s sort of a buzzword, but it carries a good deal of truth.  The fact is, computers are *built* to automate repetitive tasks - not create them.  If it takes a few hours more to program something so that it is easier to update later, by all means do it.  Think of the time savings that you would have if on your 300 page website, you wanted to make a simple change to your directory structure, and move your stylesheet.  If you designed your page with an included header, the task is trivial.  If you hard-coded all that, you’re in for a larger project.  How are you going to remember what you have updated and what you have to do still?  It’s going to be a real mess, I can assure you that much.  Think ahead.  Save time.