November 16th, 2008
Filed under:
Code
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
Stopping:
do shell script "/sw/sbin/apachectl stop" password "MY_PASSWORD" with administrator privileges do shell script "/usr/local/mysql/bin/mysqladmin -u root -pROOT_MYSQL_PASSWORD shutdown" password "MY_PASSWORD" with administrator privileges
You will obviously need to change MY_PASSWORD to your admin password. You need to change ROOT_MYSQL_PASSWORD to your root MySQL password, or another user name/password combo with shutdown privileges. Note: there should not be a space between -p and ROOT_MYSQL_PASSWORD.
Also, the path to apache/mysql might need changing. You can find out where they are by running which apachectl and which mysqld_safe in the terminal.
Just paste the code into Script Editor, and save how/wherever you like. I save mine as run-only executables which show up nicely in Quicksilver.
Can’t remember where this code originally came from, but it’s pretty handy, so thanks whoever pointed me at this.
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.
You are responsible for exiting after calling this method. Not exiting will result in CakePHP trying to render a page after sending the file data, causing (possibly invisible) errors. I have also removed error checking code responsible for checking the file path and download name as it is very app-specific. You will probably want to add your own.
Note: I have not tested this on a Windows-based machine. I don’t see why it shouldn’t work, but you have been told.
Usage
var $components = array('ForceDownload')
...
$this->ForceDownload->forceDownload('/path/to/file.php', 'MyPHPFile.php');
exit();
Download
ForceDownload.zip
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.
By using this controller within<img> tags, favicons can be used as images anywhere within your site, without knowing their specific address. It is currently in use on this blog and favicons will appear next to post comments.
Instructions for use are included in the download. I can no longer offer support for this code.
Favatars.zip
December 15th, 2006
Filed under:
Code
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!
I’d love to hear back from anyone who uses this. If you send changes, I’ll merge them into the download.
Download:
PHP iCal Parser