Ubuntu Netbeans 7

Day-to-day I use Gedit with a ton of plug-ins to do my PHP development but a friend of mine suggested I gave Netbeans 7 a go. I last tried Netbeans at version 6 and wanted to know if it had fixed the problems it had. However after installing it on linux it just looked awful, [...]

Moving from Drupal 6 to WordPress 3.1

I thought it was about time I updated my site as it was running as a Drupal 6 install. I wanted to concentrate on the blogging aspect of the site and thought that WordPress might be closer to what I needed from a CMS. So here is how to convert a drupal site to wordpress. [...]

CodeIgniter Hack Form_Validation Callbacks

When im writting a Codeigniter 2 application I prefer to have most of my code in the libraries and leave the controller as blank as possible. This allows me to reuse code like forms in other sections of the site. eg you want the login for to be in 2 different places. However Codeigniter’s Form_valiation class does not allow for custom validation callbacks in a library. The only way to fix this is to hack the Form_validation class. I have created a modification that allows you to call a validation callback from any class.

Best Espresso Colour Theme

My editor of choice is the Espresso IDE and I recently found an awesome colour theme called quiet light over at one crayon. Check it out.

Getting a Codeigniter Query Source

Using CodeIgniter’s framework for query binding is great but can make it hard to debug problems in your SQL statement. The solutions I have come up with is to use the compile_binds function. This will output your SQL statement after the parameters have been cleaned and added.

var_dump($this->db->compile_binds($sql, array($param1, $param2)));

CodeIgniter Extending Form_Validation

You can add generic validation functions to codeigniter by extending the Form_Validation. You do this by creating a file called /application/library/MY_Form_Validation.php.

If you load the Form_Validation library it will pick-up this class and use it instead. Because it extends the original class CI_Form_validation you still have access to all the normal functions.

Here is an example that adds 2 validation functions:

svn: warning: cannot set LC_CTYPE locale

After settings up a new Ubuntu 10.10 webserver I started getting these messages while using subversion.

svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LANG is en_GB.UTF-8
svn: warning: please check that your locale name is correct

They seemed not to affect the subversion commands i was runnng but are just a bit annoying. After the normal google skills download I came across the Ubuntu page on locales. https://help.ubuntu.com/community/Locale.

I used the local -a command to list the installed locales which gave me.

Subversion Ignore tutuorial

Ignoring files in subversion I think is totally un-user friendly so I have written a tutorial to try and explain how it works.

Firstly you need to set the default text editor for subversion. To do this you need to set the SVN_EDITOR enviroment variable which is just a one liner in terminal. I am a nano fan so mine was:

export SVN_EDITOR=nano

PHP Reference Widget

Found this awesome little OS X widget that gives you a complete PHP reference. Really handy to just have your dashboard key and have all the functions and classes there.

PHP Function Reference

Mysql hourly backup using cron

I wanted a cron job to run that would backup my Mysql database each hour. But I also wanted the command to create a new file each time preserving the history.

This is the command I came up with:

mysqldump --opt -u [username] [dbname] > /path/to/backups/database-`date +%Y-%m-%d-%k:%M:%S`.sql