New Wordpress Plugin

I just released SToken Console – a Wordpress plugin that puts a console-like widget into your Wordpress site. You can use an admin tool to edit the commands the console will accept. This all sounds kind of abstract but the idea is that you can use it to allow some of your site’s readers access to specific content. This is useful, say for example, if you want to provide access to a file for download, but only if the person has the correct code.

Check it out!

Posted in SToken Console | Tagged | Leave a comment

Zend_Mail attachments not recognised in MS Outlook

Here’s an annoying little problem with a simple fix. If you are creating emails with Zend_Mail and you find that MS Outlook just can’t recognise the attachment, try setting the attachment’s filename property. This forces Outlook to see the file extension and therefore make the attachment openable. Mail.app on the Mac is smart enough to extrapolate what it needs from the Mime Type, but Outlook seems to depend on the filename. Your milage may vary but this should ensure the attachment works in most other email clients too.

Posted in Uncategorized | Tagged , , | Leave a comment

Remove old .svn files in an orphaned checked out project

I recently found myself with a checked out Subversion project that was orphaned from its repository. I wanted to create a new repository and import the files there to start from scratch, but was stuck with thousands of .svn folders, all through the project.

This is the best way I’ve found to remove all the .svn folders and their contents. Once this is done the project should be just like a freshly-exported one. Obviously this works well for me on Mac OS 10.6 but use caution: operate on a copy first and check the results.

Note: This should be blindingly obvious, but just to be totally clear, you will not be able to check this project into the repository it was checked out from after you do this.

Just run this in Terminal.app:

cd [/path/to/my_orphaned_project]
find ./ -name .svn -exec rm -rf {} \;

Hopefully this is of use to someone!

Posted in Subversion | Tagged , , | Leave a comment

How to prevent weird characters after MySQL export and import

When you export from a MySQL Database to a .sql file, then import that into a new Database, you may find a bunch of weird characters. This post is not an exhaustive explanation of why the problem happens, more a note on how to avoid the issue when exporting and importing in MySQL.

The issue is essentially tied up with a mismatch between default collation in MySQL and the collation / character sets specified in the .sql file. To fix the issue, make sure they all match. If you’re using MySQL 4+, the default collation is probably UTF-8, so just make sure that the file has a default colltion set too. Putting the following line at the top of the .sql seems to do the trick:

/*!40101 SET NAMES utf8 */;

The reason seems to be with the importer: even though there is a default collation set on the database and on the tables, if there’s no default for the whole file each insert gets misinterpreted as a UTF-8 table that must be encapsulated in as latin1. Also check that the table creation statements in the .sql file are UTF-8 too, like this:

CREATE TABLE `wp_comments` (
...
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

For more detailed information, and info on how to fix existing databases, check out http://www.orthogonalthought.com/blog/index.php/2007/05/mysql-database-migration-and-special-characters/. There is a plugin for Wordpress that will convert the database, but this didn’t work for me.

Posted in MySQL | Tagged , , | Leave a comment