It drives me nuts that the best practices with javascript that is not required for the initial rendering of your application is to be placed at the bottom of the document, yet frameworks (like Zend Framework) do not support that out of the box. (I recently found out that Joomla also shares this problem.) (more…)

I’m no sys admin, so I can’t be sure, but I’ve seen lots of issues with using things like MySQL Proxy to fully separate the write and read queries in an application. Maybe it works, I don’t know… but I do know that if I can separate the connections in my code, that saves my Admin time… it doesn’t appear to give that much of a hit to performance either! Do keep in mind that... (more…)

For a CMS I’ve been working on, there are a number of custom routes that are added statically in a loop. These point to specific ID’s of articles on on the default module’s page viewing controller/action. Sometimes these routes need to appear in the Zend_Navigation output. As you can probably guess, the logic used for this is similar to what you might experience when using the URL view helper. But, for some reason, I could... (more…)

So, often I have to show a masked credit card on the screen. However, I really want to go the extra mile and show the user a secure, fully masked credit card number that still reflects their original card. For example, if their credit card number is only 15 numbers long, I shouldn’t show a 16 character long string. So, I’ve developed this code snippet: $cc='1234123412341234'; $masked = str_pad(substr($cc, -4), strlen($cc), '*', STR_PAD_LEFT); (more…)

If I need to run PHPUnit on a remote system against a code suite, I will write a simple shell script like the following to do it for me. (Bonus points, you can even include this as an External Tool in eclipse to do it right from your project). ```bash #!/bin/bash (more…)

One of the under-utilized features of PHPUnit probably is the listeners interface. You can see the configuration options here: php.net/appendixes.configuration.html. So, I decided that I want to use this to know if a Unit Test takes longer than 2 seconds to run. That’s super over-kill in my opinion, but that’s my hard limit. If it takes longer than 2 seconds to run, something is wrong! So, I added the following to my configuration: (more…)

I’m not entirely certain why this escaped me for so long, but it’s remarkably easy to set terminal colors with PHP. Simply echo the escape/color character \033, followed by the bash color definition and your output. For reference, here is a listing of bash colors. So, for example, if we want to make something blue text, do the following: (more…)

I’ve always found it annoying when programmers create systems where you create your account and then you’re not logged in. Maybe I’m lazy? I decided to do a poll on a popular social networking site. The poll went like this: (more…)