Fixing ñ characters in code-igniter

It seems this is one of the oldest issues of PHP develoment, right?. I’ve developed a PHP website, based on codeigniter framework (and a mysql database), and i ran into a lot of problems with the ñ, not showing up well in google.

Here’s what i’ve done to fix this problem:

  1. Set the database collation / columns to utf8_general_ci (by means of phpmyadmin).
  2. In codeigniter’s ‘config.php’ file.
    [cc lang=”php”]$config[‘charset’] = ‘UTF-8’;[/cc]
  3. In codeigniter’s ‘database.php’:
    [cc lang=”php”]$db[‘default’][‘char_set’] = ‘utf8’;
    $db[‘default’][‘dbcollat’] = ‘utf8_general_ci’;[/cc]
  4. In the ‘general’ html-rendering, before anything else gets echo’ed (beware, i’m using HTML5.. HTML4 is different):
    [cc lang=”html”][/cc]
  5. And finally… in my .htaccess file:
    [cc lang=”bash”]AddDefaultCharset UTF-8[/cc]

I hope this helps. I’ve spent many hours reading… testing… and a couple days waiting for Google’s update!.

Fixing ‘SAFE MODE Restriction in effect. The script whose uid is is not allowed to access /tmp’ error in WordPress

Long short story. If you wanna update, say, a plugin, or a theme.. using wordpress, and you get the following error:

SAFE MODE Restriction in effect. The script whose uid is  is not allowed to access /tmp

I’ve got news for you!. It’s caused by the php_safe_mode flag. If you’re on a shared hosting, and you cannot change that flag (or maybe you just don’t want to)… here’s what you need to do:

  1. Create a temporary folder, somewhere in your hosting, and set the permissions to 777.
  2. Open your wp-config.php file.
  3. Add this line: define(‘WP_TEMP_DIR’,’/absolute/path/to-a-tmp-folder/’);

That should do the trick.

Fixing WebKitLocalStorageDatabasePathPreferenceKey crash

I’ve been getting a lot of crashes with the following signature:

[cc lang=”objc”]Exception Type: SIGABRT
Exception Codes: #0 at 0x351be32c
Crashed Thread: 0

Application Specific Information:
*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenceKey)’
[/cc]

What is this?. It’s pretty well explained here.
My workaround?. Quite simple. Call this method as soon as your app launches:

[cc lang=”objc”]
-(void)fixWebkitCrash
{
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString* webkitPath = [defaults objectForKey:@”WebKitLocalStorageDatabasePathPreferenceKey”];
NSString* bundlePath = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];

if([webkitPath containsString:bundlePath] == NO)
{
[defaults removeObjectForKey:@”WebKitLocalStorageDatabasePathPreferenceKey”];
[defaults synchronize];
}
}
[/cc]

Hopefully, this will save you a couple hours!.

Fixing ‘Show in Finder’

I’ve been dealing with an annoying glitch in OSX 10.8.2. For some reason, ‘show in finder’ breaks down… on its own.

The workaround is…

[cc lang=”bash”]sudo killall -KILL appleeventsd[/cc]

Let’s just hope a real fix shows up, sooner rather than later.