Category Archives: howto

Triggering the Source Code view of the current page using JavaScript

I was recently writing a demo to showcase the new Google Language API, and in my demo I did the usual thing of instructing users to View > Page Source in order to view the source code and comments. I know this is less than ideal, because it forces users to have to process the [...]

Recommended Mozilla Firefox add-ons (aka extensions, aka plugins)

This is a list of my "must-have" Mozilla Firefox add-ons. If you can recommend anything similar or better, be sure to drop me a comment. Page Analysis & SEO Minimise Nuisance Bookmark Management Download Management Productivity Web Development & Design Security Functional Extensions Tab Management Add-Ons Management Page Analysis & SEO About This Site Bookmarks [...]

scp Usage

Secure File Copy (scp) allows you to copy files between hosts using the SSH protocol. To copy from a remote host to your current host PLAIN TEXT PERL: scp -r user@remotehost:path/to/remotefiles localtarget   #-r recursive copy #you will be prompted for user's password @ remotehost To copy files from your current host across to the [...]

Selecting a random row using MySQL

There are many examples where you would need to retrieve a random record or more from a set of tables. For example your page template may be cycling through QOTDs, testimonials, offers, specials, and so forth. To retrieve a random row in MySQL, use the ORDER BY RAND() statement to randomly order the rows of [...]

PHP code snippet – Reorder items in a table

This snippet of code reorders items in a table based on the number of steps you want to move an item from its current position. It moves the item of interest to its new position and shifts all other items to their new shifted positions. PLAIN TEXT PHP: function moveItem ($n_steps) { if ($n_steps == [...]

svn – Ignore/exclude files from version control

In most projects there are going to be files that you wish to ignore in version control. These could be temporary files, log or debug files, and so forth. These are files that you can safely ignore when executing commands such as svn commit and svn st. The following shows how to configure your svn [...]

Class Inheritance in Javascript

My previous post showed how to create classes in Javascript. This addendum post shows how to create an inherited class from a parent class. The concept is simple. Declare and define your parent class Declare and define your child class without defining the parent-child relationship Add a new instance of your parent class to your [...]

Creating classes with Javascript

Javascript is a prototype-based language rather than a class-based language (e.g. Java). For an explanation of the difference, see Mozilla's comparison of class-based and prototype-based languages. In short, in a class-based language, objects are created by instantiating classes. The classes' list of properties and methods cannot be altered (e.g. added to) at runtime. A prototype-based [...]

Akismet and PHP for your site

A few sites I administer have recently had the misfortune of having spambots visit their enquiry and contact pages. These pages usually have a contact form, where an enquirer can leave their name, e-mail, and request or comment. When they submit the form, a copy of the message is e-mailed to the site owner. The [...]

Timezones and UTC in PHP

If you are dealing with multiple users in different timezones or simply want to display times in a timezone other than your server's settings, it is best to store timestamps as their UTC (~ GMT) equivalents. When you read those timestamps later, you can convert them to local time. Local time to UTC time PLAIN [...]