Author Archives: Jim Lam

Check if the start of the month is in X days – PHP function

I was working on a project which required a daily cron to run and perform certain operations if it was a specific number of days before the start of the following month. I used this as a class method to … Continue reading

Posted in PHP | Comments Off

PHP Fatal error: Out of memory – Prevention better than Cure

While running a PHP script you may encounter the dreaded “Fatal error: Out of memory” message. It is usually be accompanied with a few long numbers which represent the number of bytes the script tried to allocate. The obvious fix … Continue reading

Posted in MySQL, Performance, PHP | Comments Off

Dynamic object property names in Javascript

Have ever needed to create a Javascript object with dynamic property names? You may have found that your dynamic variable name was actually used literally. eval() is your friend…

Posted in Javascript | Comments Off

Format price with 2 decimal places in PHP

Example usage:

Posted in PHP | Comments Off

Steve Jobs 1955-2011 

Posted in Apple Mac | Comments Off

Become the fastest programmer in the world

This post was influenced by the film Limitless. “An action-thriller about a writer who takes an experimental drug that allows him to use 100 percent of his mind. As one man evolves into the perfect version of himself, forces more … Continue reading

Posted in Performance, PHP, Project Management | 2 Comments

How to get Parent of Parent Post in WordPress

Posted in PHP, Wordpress | Comments Off

Timing is everything

The average internet user has a very short attention span and doesn’t like waiting, who does? A slow loading website will fustrate potential customers. It gives a poor first impression when compared with your rivals. A misconception may be formed … Continue reading

Posted in Performance | Comments Off

Facebook Like – small button, BIG marketing potential

When purchasing a product or deciding on a supplier for a service there is an inherent risk, especially online. This risk is reduced significantly if it is in the form of a personal recommendation. No where is the personal recommendation … Continue reading

Posted in Online Marketing | Comments Off

Generate array with x years before/after the current year

Wrote this PHP date function which can easily be used to populate a drop down in a form. e.g. credit card expiry, or date of birth. Example usage: What about months? It would be more efficient to have this as … Continue reading

Posted in PHP | Comments Off