Leading Story

TUANZ Innovation Awards, 2008

I won a TUANZ award for innovation in Local & Central Government services. This was for the Accessware validator.

Read Complete Story »

Import OS X Mail into another Mail account

Posted on May 19, 2010 by Geoff

This one is easy.  I wanted to move all my existing email, including folders, filters, signatures – the whole lot, from OS X 10.5, to OS X 10.6, which was a fresh installation.  I had been using Time Machine for ages, so all the necessary files were on an external disk.

TIP:  Don’t load Mail before doing this.  We don’t want existing preferences and accounts getting in the way.

Step 1.

Copy the directory ~/Library/Mail from the Time Machine to the same location on the new installation.

Step 2.

Copy the file com.apple.mail.plist from ~/Library/Preferences on the Time Machine to the same location on the new installation.

Done!

Load up Mail, and you’ll be prompted to complete the importation process.  When that’s done, all your email will be sitting there.

Getting QRCodes to work with PHP (and OS X)

Posted on May 9, 2010 by Geoff

QR Codes are pretty cool replacements for standard bar codes.  The big question though, is how can we generate them from within a PHP page?

First, download the QR Code 3.1.1 library: http://megaui.net/fukuchi/works/qrencode/index.en.html .

You might also need to install PKG-config ( http://pkg-config.freedesktop.org/ ).  You’ll know if you need to do this because when you install the QR Code library, it will tell you that it needs the pkg-config files.

So the steps are:

Install QR Code library:

  • cd /path/to/qrencode-3.1.1
  • ./configure
  • make
  • make install

If you have any issues with pkg-config, install it with a standad ./configure && make && make install command.

NOTE:  I have already installed ImageMagick and the libpng, libjpeg etc libraries, as part of my PHP installation (see an earlier post).

Now you can create QR Codes from the command line like this:

qrencode -o /path/to/the/image/you/want/to/create “Text you want to encode”

In PHP, you can access this by a command like so:

passthru(“/usr/local/bin/qrencode -o /path/to/image.jpg \”Text to encode\”");

That will create a QR Code image at the specified location, which you can then reference in PHP.

Easy!


Udon Noodles

Posted on May 5, 2010 by Geoff

‘U’ was tough.  There are very few recipes out there for ‘U’ that meet our requirements.

Luckily, this alphabet challenge has given us a great deal of experience in cooking, and with that, confidence in what we like and how to cook things, so we decided to make up our own recipe.

This meal has no name, but it results in a spicy meat dish served on udon noodles.

So here’s how to do it (some measurements are more of a guess than anything):

  • 2 packets of udon noodles
  • Some fillet steak (as much as you’d like)
  • 1 tsp chilli oil
  • 4 T teriyaki sauce
  • 2 T rice wine
  • a splash of white wine (sav blanc for example)
  • 1 lime, juiced
  • 1/4 cup of peanut butter
  • 1 T of ginger
  • 1 T of crushed garlic
  • some carrots, sliced
  • some cabbage, sliced
  • some bean sprouts

Mix the chilli oil, teriyaki sauce, wine, rice wine, peanut butter, ginger and garlic together.

Chop the meat into chunks and marinade in the sauce for a few hours.

Stir fry the meat until nearly done, and then add the noodles (udon noodles do not need to be thoroughly cooked), and then add the carrot, cabbage, and bean sprouts.

The vegetables only need a minute or so to warm them up a bit, but essentially they will be raw and crunchy.

Serve!  This might be a bit hot due to the chilli oil, but it adds a nice zing.

How to install Apache, MySQL, PHP & Postgres on OS X 10.6

Posted on May 4, 2010 by Geoff

Here are step-by-step instructions on how to install Apache, MySQL, PHP & Postgres on OS X 10.6.  There are plenty of places providing pretty much the same details, but sometimes their instructions don’t work terribly well.

First off, here are our objectives:

  • Apache 2.2.15
  • MySQL 5.1.46
  • PHP 5.3.2
  • Postgres 9.0 alpha5
  • Microsoft SQL Server connection support

This is on a Macbook Pro, running OS X 10.6.2

I have two additional requirements too; Apache must replace the existing OS X version, and support virtual directory user configurations, so I can have multiple sites running on the same instance.

NOTE: these steps are based largely on what you can find here: http://adylitica.com/2009/11/24/installing-amp-apache-mysql-php-on-mac-os-x-10-6-snow-leopard/

Another note: All of these instructions assume that you’re comfortable with using the Terminal and the ./configure, make etc commands.
Also, you’ll have to manually navigate to the appropriate directories to run each of these commands.

Last note: All of the necessary files have their version number included. You will probably find that these have since been updated. That’s fine, but I can only guarantee that the versions I’ve named will work.

Step 1: Software update.

Make sure your new OS X 10.6.x installation is completely up-to-date.  Run a ‘software update’ check first. You’ll also need to install the Xcode tools if you haven’t already.

Step 2: MySQL

I could not get MySQL working with the version explicitly labelled for OS X 10.6. PHP would completely fail to recognise it.  So make sure you download the x86_64bit version for 10.5.  Perhaps this issue will be fixed in the future.

Download: MySQL 5.1.46-osx10.5-x86_64.dmg

Installation: This is a handy installer application, so no worries here.

Step 3: Memcache

Memcache is pretty handy to make websites work faster.  It’s worth installing, but optional.

Download:

Installation:

Libmemcached:

./configure && make && make install

Libevent:

./configure && make && make install

Memcached:

./configure && make && make install

Step 4: OpenSSL

OpenSSL has been updated to version 1.0.  OS X already has OpenSSL included, but you can upgrade it if you want.

Download: OpenSSL 1.0.0

Installation:

./config && make && make install

Step 5: cURL

cURL is a pretty handy interface, which if you do any serious PHP development, you’ll probably need at some point.

Download: cURL 7.20.1

Installation:

./configure –with-ssl=/usr/local/ssl –enable-thread

make && make install

Step 6: ImageMagick and GD Support

ImageMagick is pretty cool, and GD support is something you’ll probably need too, so we’ll install all the necessary files now.

Download:

Installation:

Imagemagick: The Imagemagick page has instructions on how to get the binaries working.  Just copy the files to a location of your choice, and run the tests they give.

Freetype:

./configure && make && make install

Libpng:

cp scripts/makefile.darwin Makefile

make && make install

Jpegsrc:

./configure && make && make install

Tiff:

./configure && make && make install

Step 7: LibSSH2

This will let PHP communicate with SSH servers.

Download: LibSSH 1.2.5

Installation:

./configure && make && make install

Step 8: Apache

You have Apache on OS X, but we’ll be upgrading it. This will replace the existing Apple installation, and allow you to use the user configuration .conf files.

Download: Apache 2.2.15

Installation:

./configure –enable-layout=Darwin –enable-mods-shared=all

NOTE: –enable-mods-shared=all is probably overkill.  You could also try –enable-mods-shared=most for a reduced set.

Check that you have user .conf files, at a location like this: /etc/apach2/users/geoff.conf.  If you do, and you plan on using virtual hosts, make sure that this line is in the .conf files:

NameVirtualHost *:80

You can set up a virtual host like this:

<virtualhost *:80>

DocumentRoot /Users/yourname/Sites/yoursite
ServerName yoursite.local

</virtualhost>

Edit the /etc/hosts file to include this line:

127.0.0.1 yoursite.local

Step 9: Postgres

We’ll be installing Postgres, ‘cos I like it better than MySQL.  If you don’t do this bit, then you’ll need to modify the PHP configuration string to exclude the Postgres includes.

Download: PostgreSQL 9.0alpha5

Installation: You’ll need to create a ‘postgres’ user via ‘Accounts’ in the System Preferences panel of OS X.  Then follow the instructions which are included in the Postgres readme file.

Add the Postgres path to the shell:

export PATH=$PATH:/usr/local/pgsql/bin

Step 10: FreeTDS

This is required for MSSQL connection support.  If you don’t think you’ll be connection to SQL Server, then you can skip this step.

Download: FreeTDS 0.8.2

Installation:

./configure –enable-msdblib

This will install FreeTDS into /usr/local.  You need to provide this location in the PHP configuration settings if you’re using MSSQL.

Step 11: PHP

We will be creating a PHP installation with support for:

  • APC (code caching)
  • ImageMagick
  • SOAP (better than using PEAR)
  • Memcache
  • Zlib (file compression)
  • OpenSSL
  • Multibyte string support (mbstring)
  • mbregex
  • cURL (ability to retrieve web requests)
  • SSH2
  • PEAR
  • MySQL
  • Postgres (pgsql)
  • SQL Server support (mssql)
  • PDO (a better database connection method)
  • GD (a graphics manipulation library)

First, go to pecl.php.net and download the following:

Download: PHP 5.3.2

Now we need to patch the iconv function.  OS X 10.6 is a bit strange in how this works.

Create a file called ‘patch’, with the following content:

— php-5.3.0/ext/iconv/iconv.c 2009-03-16 22:31:04.000000000 -0700
+++ php/ext/iconv/iconv.c 2009-07-15 14:40:09.000000000 -0700
@@ -51,9 +51,6 @@
#include
#endif

-#ifdef HAVE_LIBICONV
-#undef iconv
-#endif

#include “ext/standard/php_smart_str.h”
#include “ext/standard/base64.h”
@@ -182,9 +179,6 @@
}
/* }}} */

-#ifdef HAVE_LIBICONV
-#define iconv libiconv
-#endif

/* {{{ typedef enum php_iconv_enc_scheme_t */
typedef enum _php_iconv_enc_scheme_t {

Patch the inconv file, by finding the iconv directory, usually inside the PHP source directory at /ext/iconv.

Run this command:

patch -p1 < /path/to/patch_file

When it asks you what file to patch, type ‘iconv.c’.

Rename the PECL extension directories by dropping the version details.  So ‘APC-3.1.3p1′ becomes ‘APC’ for instance.

Move all of these directories into the ‘/ext’ directory of the PHP source code.

Delete the existing ./configure file:

rm ./configure

Now rebuild it (ignore the warnings):

./buildconf –force

Now run this configuration script:

./configure \
–prefix=/usr/local/php5 \
–with-apxs2 \
–enable-imagick \
–enable-apc \
–enable-soap \
–enable-memcache \
–with-zlib \
–with-openssl=/usr \
–enable-mbstring \
–enable-mbregex \
–with-curl \
–enable-memcached \
–enable-ssh2 \
–with-pear \
–with-mssql=/usr/local \
–with-mysql=/usr/local/mysql \
–with-mysql-sock=/tmp \
–with-pgsql=/usr/local/pgsql \
–with-pdo-pgsql=/usr/local/pgsql/ \
–with-pdo-mysql=/usr/local/mysql \
–with-gd

make
make install

Copy /etc/php.ini.default to /etc/php.ini

NOTE: if it makes a mention about changing your include_path, then you should do it.  PHP Unit requires it.

Edit /etc/php.ini, and find this line:

include_path = “.:/usr/lib/php”

And change it to (your prefix value in the configuration string):

include_path = “.:/usr/local/php5/lib/php”

Step 12: PHPUnit

PHPUnit is a handy unit testing tool that we’ll be installing.

Download: PHPUnit 3.4

Installation: Follow the instructions at the website.  You’ll need to have installed PEAR in the PHP configuration for this to work.

Step 13: XCache

XCache is good for speeding up slow websites, it can make development work much more tolerable!

Download: Xcache 1.3

Installation:

Move the xcache files into a directory you’d like to install them in (I couldn’t figure out the flags to make it install to a particular destination).  So I put them in /usr/local/xcache.

Run the phpize & ./configure commands as detailed in the installation documentation.

Xcache has probably been installed in /usr/lib/php/extensions/no-debug-non-zts-20090626/xcache.so .

Fire up /etc/php.ini and do a search for xcache.  There is a reference to the xcache.so where the precise details are incomplete.  Change the path to the correct location of xcache.so.

You can also change the size of the cache by changing the value of xcache.size.

You can also change the value of xcache.count to the actual number of processors on your machine.

Move the admin folder into your ~/Sites folder and make a site for it.  You can then see what xCache is doing.

Starting things

To start MySQL:

/usr/local/mysql/support-files/mysql.server start

To start Apache

apachectl start

Apache should already be running, so you can also use ‘stop’ and ‘graceful’ to restart it.

To start Postgres

/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l ~/logfile start

This will put a logfile in the postgres user directory

Install OS X 10.6 without a DVD

Posted on April 4, 2010 by Geoff

Here’s my challenge. I wanted to install 10.6 on a spare laptop as a test to see how well it would work, before I format my dev machine and install it there.

The problem is that the spare laptop has a broken screen, thanks to a faulty graphics chip that Apple decided they didn’t want to fix (I’ll get over it any day now, I promise).

This laptop also has a broken DVD drive… nothing except some CDs seem to work in it these days. It is however, set up with remote desktop access, so I can still use it via ‘screen sharing’. It’s mostly an iTunes server these days.

Just to add to the fun, my dev machine doesn’t like double layer DVDs. I suspect it also might be faulty.

So the question is “How do I install OS X on a computer with no screen and no DVD drive, using another computer with no DVD drive?

Terminology:

  • The laptop I want to install OS X on is called the ‘destination’ laptop.
  • The laptop I am using as a host is called the ‘source’ laptop.

The answer:

Step 1.

You’ll need access to a computer with a working DVD drive initially. Using the Disk Utility and a 8GB or more USB stick, click on the ‘Restore’ tab and copy the OS X installation DVD onto the USB stick. This will take about 40 minutes.

Step 2:

First of all, you need to restart the broken laptop (the ‘destination’) in ‘target disk mode’. To do this, go to ‘System Preferences’ and click on ‘Startup disk’. Click on ‘Target Disk Mode’.

Step 3:

Connect the destination laptop to the the (mostly) working laptop (the ‘source’) with a Firewire cable.
Now go to ‘System Preferences’ and click on ‘Startup Disk’. The destination laptop should appear as an option in the start up items. Click ‘Restart’, with the destination laptop selected.
NOTE: make sure you have the USB stick with the OS X installation files plugged into the source laptop.

Step 4:

Hold down the ‘option’ key while it’s rebooting. You should be presented with a list of all the possible sources to load from, one of which will be the USB stick. Select that option.

Finished!

It should take about 40 minutes to install. When it’s done, set up the remote desktop functionality again, and you’re in action!

Moroccan Lamb

Posted on January 31, 2010 by Geoff

This is a really tasty and simple meal.  We used standard Moroccan seasoning from the supermarket, plus a bit of salt and pepper.  The lamb was the usual backstraps (nom nom nom).

To be honest, the sauce is almost optional.  It’s nice, but most of the flavour comes from the seasoning.

If you want something simple and nice, then give this a shot.

http://allrecipes.com/Recipe/Moroccan-Lamb-with-Shiraz-Honey-Sauce/Detail.aspx?prop31=3

Walnut-crusted lamb

Posted on January 10, 2010 by Geoff

Walnut-crusted lamb was our ‘W’ meal, and one of our favourites.  We’ve had this many times, and it’s up there with our favourite steak and lamb meals.

We used lamb backstraps rather than rack of lamb, and we also halved the amount of sauce.

Additionally, we were extremely careful to not cook the lamb for one second longer than 10 minutes initially, and then 15 minutes after that (as the recipe suggests).  Slightly underdone lamb is vastly preferable to overcooked lamb.

We also forgot to get cream for the sauce, but it hasn’t seemed to matter.  The last modification to the recipe was the use of Brie cheese, rather than goats cheese.  We melted the cheese in the microwave immediately before use, and then mixed it into the walnut mix.

Don’t bother spreading the walnut mix on both sides of the lamb, just pile it up on top.  It should come out lightly grilled.

This meal is best served with a Mount Difficulty Pinot Noir.

5 out of 5 noms!

Raan Lamb

Posted on July 19, 2009 by Geoff

Our ‘R’ meal was Raan lamb. This is essentially spiced lamb in yoghurt.

We didn’t follow the recipe in several key ways. We used lamb back straps, and didn’t marinade it for 48 hours. We justified the quicker marinade time on the grounds that we were using much better quality lamb.

Also, because it was a thin cut of lamb, we fried it so that it would still be pink in the middle.

What we got was…. nice. A bit unusual… flavoursome, but probably not what we expected.

3 noms out of 5

Quesadilla meal

Posted on July 19, 2009 by Geoff

For our ‘Q’ meal, we had quesadillas. I don’t like quiche, so that made life very hard for our ‘q’ meal. Quesadillas are pretty simple…. you can buy a packet of all the necessary bits and peices from the supermarket, which is what we did, but we knocked it up a notch with some tobasco sauce and heaps of cheese.

This is about as close to cheating as we’ve come so far…. Q is a very hard meal to make.

Pakistani Pot Roast Beef Fillets

Posted on June 14, 2009 by Geoff

After a few not-so-good meals, it was a real pleasure to have something very nice. Our ‘P’ meal comes from Pakistan.

We pegged back the chilli since 3 grams of dried chilli flakes is heaps! We also used a flat teaspoon of cloves and cumin, and half a teaspoon of turmeric – most of which I ended up wearing – since .5 of a gram is an impossible amount to measure.

As the beef was simmering, it started to look and smell really really nice.

We served it up on toasted pita bread pockets which we’d sliced open and briefly baked.

This meal seems to have a great deal of potential for alterations, and we’re definitely having it again.

4.5 noms out of 5.


Older Posts »