Parsing With Lemon

Lemon is a parser generator - a tool which takes a context-free grammar and converts it into code which can parse a file using that grammar. It’s a very useful tool, but can be a bit fiddly to get set up when building an app with Xcode. It’s fiddly because it’s not the grammar file which gets compiled into your app, but the code generated from it.

Read More

Applescript for starting and stopping Apache and MySQL

Got a couple of pieces of AppleScript for starting and stopping Apache and MySQL which are too small to be worth posting as downloads. I don’t use these any more, but they were handy for custom installs of Apache/MySQL.

Starting: do shell script “/sw/sbin/apachectl start” password “MY_PASSWORD” with administrator privileges do shell script “/usr/local/mysql/bin/mysqld_safe > /dev/null 2>&1 &” password “MY_PASSWORD” with administrator privileges

Read More

CakePHP ForceDownload Component

Important! This is old code. I’ve not used it for a long time. It might still be useful. Be careful.

 

This snippet is a CakePHP component which can be used to force a users browser to download a specified file instead of attempting to display it. It will happily deal with any file your scripts have read access to. When provided with an absolute file location and filename for the downloaded file, it will attempt to look up an appropriate mime-type for the file, output some HTTP headers followed by the file data itself.

Read More

CakePHP Favatar Controller

Important! This is old code. I’ve not used it for a long time. It might still be useful. Be careful.

 

Favatars is a Wordpress plugin for displaying favicons as avatars next to blog post comments. This code is an adaptation of the original work to turn it into a CakePHP Controller. When given a URL, it will attempt to locate a favicon for that site. If one is found, it is cached and displayed. If not, it will display a default image.

Read More

PHP iCal Parser

 

Important! This is old code. I’ve not used it for a long time. It might still be useful. Be careful.

This code parses iCalendar  (RFC 2445) compliant files into nested associative arrays. It doesn’t do the full iCal specification, as I only needed a subset of it, but the code is easily extended and should just ignore anything it doesn’t understand. It’s old and currently unused by me, but should still work!

Read More