This was copied from a Stackoverflow answer
Things to consider in PHP/MySQL/UTF-8

The database tables and text columns should be set to UTF-8
HTML page Content-Type should be set to UTF-8

PHP should send a header informing the browser to expect UTF-8

header('Content-Type: text/html; charset=utf-8' );

The PHP-MySQL connection should be set to UTF-8

mysqli_query("SET CHARACTER_SET_CLIENT='utf8'",$conn);

mysqli_query("SET CHARACTER_SET_RESULTS='utf8'",$conn);

mysqli_query("SET CHARACTER_SET_CONNECTION='utf8'",$conn);

PHP ini has default_charset setting it should be utf-8 if you do not have access to it use ini_set('default_charset', 'utf-8');

The linux command find has a very handy option -exec which lets you execute any linux command on the files returned by a find operation. Think of it as pipping|if you may.

cd /path/to/folder/with/svn/folders
find . -name ".svn" -type d -exec rm -rf {} \;

That should do it. Also next time just do a svn export instead of an svn checkout, that’ll leave all the .svn stuff out.

A while back i wrote a tutorial on how to remove duplicate rows in a mysql database. That solution worked fine BUT it was ametuarish :)

Here’s a better one without a temporary table using the power of self joins.

DELETE u1 FROM users u1, users u2 WHERE < AND =

This will delete all the rows from users and leave the one with the lowest id (The first one).

To check if there are still duplicates use this query:

SELECT count(*) as Count, email FROM users u group by email having Count > 1

Should return no rows.

FYI. It’s usually a good idea to add a unique key on email 98% of the time.

ALTER TABLE users ADD UNIQUE email ( email )

We had a site that we hosted with a third party and they never gave us ssh access to the box. So Deploying was a bit of a bi*(h. So i wrote this little one liner to get the files and zip em. We’d then email the zip file and have files deployed.

Obviously we would have to cd in to the project directory first. After that run this command:

svn diff -r REV:HEAD --summarize | sed 's/[A-Za-z][ ]\+//' | xargs zip

Don’t forget to replace REV with your starting revision number. This might be when you started working on the project.


Just a quick wget command to fetch a page and all its dependent assets even if they sit on another domain.

wget -E -H -k -K -p

This will fetch all the css, js, images and other files used on the page

Quick JQuery plugin i wrote to clear textboxes when mouse is focused on them. And restore previous value on blur.

jQuery.fn.defValue = function(){
    return this.each(function(){
            var defVal = this.defaultValue;
            if($(this).val() == defVal){
                $(this).val('');/* Clear box if it hasnt changed */
            var defVal = this.defaultValue;
            if($(this).val() == ''){

NOTE: This will work on text boxes only not Text area. With some tweeking it can work on text area. I’m just too lazy :) sorry…This is the part where you say challenge accepted!

I recent resigned from, by recently i mean a month ago :)
I’ve since started a new adventure as a Seniour Developer at Liquorice in Cape Town. Joburg to Cape Town, yeah big move. But it was time for a change. Change is good.
I had a great time at Got to do a lot of crazy stuff on the website. I still say to this point that that’s the nest job i’ve had in my entire career.

At i learnt that i can always get better if i pushed my self.  Got to play with a lot of cool technology like sphinx. Got to deal with MySQL scaling issues, Optimisation issues. I became a better developer. Made lots of awesome friends. But the time comes to move on.

Anywho, two weeks at Liquorice and I think i’m gonna love it here. Not too sure about Cape Town, but the company, Definitely. The team is great, everyone seems to love their job, Gung-ho, suspiciosly so :)
This is the first time i’ve worked in such a streamlined production process. It takes some getting used. Updating tickets, Branch that repo, merge that repo, update Active Collab. Which by the way is a great Project management application. Worth the licence. I’ve learnt it can mean the difference between a project being on time or a month late.

Have a look at my first project here -> Its both web and mobile. Depending on your device.

Will keep you posted on any new developments.


About a month or two ago I took on the task of developing the mobile( For those of you that don’t know. I work for A Job Portal like no other. We do a lot of cool stuff. A topic for a whole ‘nother post. With the barrage of mobile web frameworks out there it was easy to make a decision on which one to use. Non of them. I’m a fan of mobile frameworks but I believe they have their place on the mobile web. They are perfect for “mobile web applications” where your target is more likely smart phone users(iPhone, Androids). But we decided to target your everyday Tom, Dick and Harry. Or is it Thabo, Pule and Jabu. Whatever your school of thought. But at the same time you don’t want to compromise your high end user’s experience.


No Javascript(Zero, Non)
Well except for the registration page. We used javascript to try and get your current location(From your GPS) so you don’t have to go and search through the drop down for your location. Works pretty well especially if your GPS is enabled.

No device capability detection
There is no device capability detection libraries like Wurfl or Device Atlas. These are really awesome tools. I’ve only ever used Wurfl in the past. It gives you all kinds of details from screen width to supported images. But I personally think if you can do it without them then do it. So the approach I took was to develop an “adaptive site”. So instead of trying to get the device’s width and adjust time the web pages width, I simple gave it a width of 100%. Which means it will grow and shrink with the device.

Geolocation API

The Geolocation API can be used to locate devices. But obviously it will request permission from the user. This was used in the registration page to automatically select your location. Of-cause this assumes you are currently in the area where you live. Which is probably untrue. But any excuse to play with the API. :) This is the only javascript that was used on the site.

Relative measures
There are no absolute measures like px, pt and so forth. The problem with these measures is that 1px to a Nokia’s screen will not look the same as 1px on an iPhone’s screen. So all dimensions are defined using the em unit of measurement. This means that the font-size will be defined in relation to the device its being viewed on. 1em the default size. For example, most web browsers(firefox, ie) default to 16px=1em

Tried our best to avoid images unless absolutely necessary, opting to use CSS creatively instead. On the home page only 2 images load. The logo, and rounded navigation bar, even that is a 1px wide images repeated using CSS(338bytes). The image dimensions are also defined using ems.
NOTE: Also playing around with DATA-URIs to reduce the number of requests on the home page from 4 to 2. This would result in a significant reduction in loading time but possibly an increase on the page size. The problem at the moment is that some phones just don’t support them.

UX Design
User experience is a HUGE thing for me. I love websites where as soon as hit the page, I know what the current state of the system is, what other states can be achieved and how these states can be achieved. I think we managed to achieve simplicity and didn’t compromise too much on functionality.

No Mobile frameworks
Firstly let me just clarify, I love Jquery mobile, its brilliant. But its also Beta. Beta 2 at the time of writing. My biggest issue is that it doesn’t degrade as gracefully as it should. So your non smart phone users are loosing out on the experience. So the one solution is to have multiple sites. Which Facebook did for a long time, until they realised some of the flaws in that architecture. With one code base you can roll out new features to all devices. Which enables you to be more creative.

So go ahead and play around on

This is a very draft post. Will be adding more stuff soon. Just wanted to get it out of the way or else I’d never write it :)

Wow, good golly me. My uncle’s dead? And my poor cousins. Oh my dear Aunt. How can I carry on. I love these scams. They are getting really creative with them too. And the fact that they keep sending them means people do fall for it.  Thought it’d make for some good laughs.


Barrister Serge P. SOUZA

01 BP 4452Cotonou-Benin
Tel: (+229) 98967503

ATTN: Luvhengo

I’mBarrister Serge P. SOUZA, Private lawyer to Late Michael Luvhengo ,a national of your country, who used to work as the Director of petroliers (TOTAL BENIN) in Benin Republic West Africa Here in after shall be Referred to as my client.

On 27th of May 2008 my client also His wife and their three Children were involved in a car accident Along Grossi express-road. All occupants of the vehicle Unfortunately lost their lives. Since then I have made several enquiries to your embassy to locate any of my clients extended relatives this has also proved Unsuccessful.

After these several unsuccessful attempts, I decided to track His Surname over the Internet, to locate any member of the Family with the last name, that is why I contacted you. I have contacted you to assist in Repatriating the money and property left behind by my client before they get confiscated or declared unserviceable by the bank here. These huge deposits were lodged particularly, with the “BANQUE ATLANTIQUE DU BENIN (BAB)” An affiliate of Commercial Bank of Africa where the Deceased had an account valued at about $9.7 million dollars.

The Bank has issued me a notice to provide the next of kin or have the account confiscated. Since I have been unsuccessful in Locating the relatives for over four years now I seek your consent To present you as the next of kin of the deceased since you have The same last name so that the proceeds of this account valued at $9.7 million dollars can be paid to you and then you and me can Share the money.50% to me and 50% to you I will procure all Necessary legal documents that can be used to back up any claim we may make. All I require is your honest cooperation to enable us seeing this Deal through.

I guarantee that this will be executed under a legitimate arrangement that will protect you from any breach of the law. And the way we are going to achieve this is.
I will need the following important information from you,
Your Full Name……………………..……………….
Your Address…………………..……………………..
Your Age……………………………………………….
Your Occupation………………..……………………
Your Position………………….………………………
Your Telephone and Mobile…………………….
For Communication Purpose.
I await your reply ASAP.

Best Regards.

Barrister Serge P. SOUZA


I’m just putting this up so I don’t forget, if someone finds it useful awesome. When i upgraded to PHP5.3 a lot of thing that were enabled by default in previous version were disabled. When I install XDebug I expect to see my pretty orange tables with errors and a stack trace. That feature has also been disabled.

To enable it just find the the line


and change it to