The tale of JSONModel and the type-hinted arrays

Lately, I've been working a lot with JSON (see Intro-to-jq), and this led me to the excellent Objective-C library, JSONModel.

One thing I couldn't find documented was how I could type-hint array properties so that I didn't need to manually cast them to the type I knew JSONModel was producing.

Read more…

Intro to jq

General usage

$ jq --help
jq - commandline JSON processor [version 1.4]
Usage: jq [options] <jq filter> [file...]
For a description of the command line options and
how to write jq filters (and why you might want to)
see the jq manpage, or the online documentation at

Try looking at raw json

cat data.json

Pretty ugly, right? Let's see if we can't make it more readable.

Read more…

Debugging SMTP with TLS encryption

Today I was struggling to diagnose an issue with a client's SMTP server, which appeared to be configured to only allow authentication once the STARTTLS command had been issued. I'd previously thought that this task would be impossible without a tool specifically made to talk SMTP over TLS, but I was thankfully wrong!

Read more…

Phalcon MVC Framework and Website Speed

Previously, this blog was written atop the excellent Kohana HMVC framework, and worked perfectly well. Recently, a colleague directed me to Phalcon, which states it is “The fastest PHP Framework”. Bold claims indeed! Since I didn't have any new projects on the horizon, I decided to rewrite my (admittedly very simplistic) blog using Phalcon to see how fast it would run, and also to see how easy Phalcon was to pick up.

Read more…

PHP 5.5 New Feature Demos

PHP 5.5 was released the other day, and I had a little repo set up to test out some of the new features. I thought I might as well share it, since it didn't take long and might help a few people out. You can view it on GitHub.

Read more…

MySQL error 22 (when using alter table to add an index)

Today, I have spent a couple of hours attempting to do some analysis on a large table. I say attempting, because every time I tried to add an index to the table after importing it, MySQL would crap out, and CHECK TABLE would report got error: 22 when reading datafile. Really weird stuff! Luckily for me, I managed to track down the cause, so I'm writing it down for the next time I run into this difficult to solve problem.

Read more…

Sendmail on Development Machines

Lately, I've been working a lot with mail scripts, which may use PHP's mail() function, or in some cases may even talk directly to sendmail. In order to make sure I don't accidentally email any customers, I use Rob Allen's script to reformat emails so they always go to my mailbox, and nowhere else.

Read more…

iOS Mail and Self-Signed Certificates

I've recently been getting warnings on my iPhone and iPad telling me that my email server is using a self-signed certificate. Now, normally this wouldn't be a problem, I'd just tap the button to "Trust" my certificate and carry on. Strangely, there is no longer an option to do this. I'm not sure when this changed, or if indeed it has changed.

There are a bunch of folks discussing it on the Apple Support Forums, with various fixes and workarounds, none of which worked for me. I did, however, find a way to fix my particular problem...

Read more…

Plex with multiple networks

I have two Macs, and I tend to store most of my video files on the Mac Pro as it has much more drive space available. I also use Plex to stream videos to my MacBook which gets connected to the TV. Plex is a rather elegant solution, sporting an automated media library with images, synopses and more. There's also a remote app for iOS devices, allowing you to browse the libraries and start shows/stream them to your iOS device. Very smart.

However, as my wireless router sucks (Netgear), and the Mac Pro has a cheapo USB adaptor (D-Link), its wireless performance is somewhat flaky at best. I've taken to turning off the wireless on the Mac Pro, and attaching a CAT5 cable between the two Macs, getting me way better reliability.

I can browse the Mac Pro's library directly on the Macbook (or using the remote control feature of the iOS app) just fine, but attempting to go to its Library on the iOS device whilst the app is connected to the Macbook causes it to lose connection. I think it's trying to connect directly to the Mac Pro's IP, which of course won't work as the only network available to the Mac Pro is the CAT5 cable.

I'm sending a link to this post to the developers of Plex in the hope that there's a way for me to either specify which network interface or IP to use when streaming between the two Macs (so that I can use the wireless to browse the library), or that it's a bug that can be fixed. I'll update the post as soon as I hear anything.

Read more…

Running MySQL (mysqld) as a user other than 'mysql' under Ubuntu 10.04 (Lucid Lynx)

On Monday afternoon, I upgraded my work machine's Linux install to Ubuntu 10.04 (Lucid Lynx). I've been working in Windows mostly for a the last few months, and keeping all my MySQL data in a TrueCrypt volume as sometimes I need to hold customer data, and we can't store it in plain text.

Read more…

Relative URLs in Javascript - A Solution

I've previously written about absolute and relative paths in web development, and this follow-up post is here to show the method I've been using to get around the problem.

The secret sauce is the old HTML <base> tag. Simply output this in the <head> section of your template, with the href attribute set to the full URL of your site's root, then you can use a simple helper function like the one below to build full URLs in your javascript!

Read more…

Relative and absolute paths in Web Development

I've been working on multiple computers for some time now, and there's one problem that keeps cropping up now and then, and sometimes when going from development to production, or when a folder changes name... Whatever.

The problem I'm talking about is relative/absolute paths in non-server-side processed files. For example, creating an AJAX loading image from a JavaScript file. What path should you use? /images/file.gif will point to the root, and file.gif will look in the current directory. The script doesn't always know the path relative to the current document, and it won't (easily) know what directory the images are in from the docroot. So what to do in this case?

What I've thought about doing today is creating the image in the server-side code, styling it to be invisible with CSS, and then using JavaScript to show/hide the image when I need it. Some basic jQuery-style psuedo-code follows.

var loader = $('img#loader_image').clone();

Does anyone have a better method for this type of thing? If so, get me on Twitter, at least until I enable comments on my blog.

Read more…