Hide or show hidden files quickly in OSX

How to setup some quick shortcuts to toggle visibility of hidden files in Finder

  • In Terminal type: sudo nano ~/.bash_profile
  • Append to the file the following: alias showFiles=’defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app’
  • In a new line type: alias hideFiles=’defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app’
  • Save the file
  • To make the aliases available in Terminal type: source ~/.bash_profile

Now you have two additional commands: showFiles and hideFiles to make things easier.

Hide or show hidden files quickly in OSX Read More »

CodeIgniter Cart class product name restrictions

codeigniter logo
The CodeIgniter cart class has a non immediately apparent feature regarding special characters in the Product Name. Within the Cart library the line
var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods will strip out any non defined special characters. While you could hack this line, the correct way to do this is to extend the library and create an over-ride.

Create a new file application/libraries/MY_Cart.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Cart extends CI_Cart {

function __construct() {

// Remove limitations in product names
$this->product_name_rules = '\d\D';

Note this will allow all characters, you may want to limit to specified special characters.

CodeIgniter Cart class product name restrictions Read More »

MySQL upgrade and planned outage announcement


MySQL v5.1 Upgrade

Our upstream provider is upgrading MySQL on your server from version 5.0 to version 5.1 as part of their commitment to web hosting security and performance.

This is an important change to ensure continued compatibility with current and future software and to ensure the stability and security of services for all customers.

For most users this change will have minimal impact on websites hosted with us and the latest releases of popular software such as Joomla and WordPress are already compatible with this upgrade.

This is a good time for you to ensure your software installations are current because you could experience problems if it has been designed around earlier versions of MySQL. We also ask that you check to make sure that any custom code is compatible with the newer version of MySQL.

For more detailed information about this upgrade please visit the official MySQL page Upgrading from MySQL 5.0 to 5.1

The upgrade is scheduled to start between the 30th and 31st of July 2013. The upgrades will begin after 21:00hrs GMT and shouldn’t take any longer than 60 minutes.

MySQL upgrade and planned outage announcement Read More »

Teensy powered Apple mechanical keyboard

I learned to type sometime in the 80’s on a manual typewriter and presumably this is why I am fixated on mechanical keyboards. If you’re not much of a touch typist (or keyboard geek) you’re probably not aware that modern (inexpensive) keyboards are an abomination unto typing.

The IBM Model M keyboard is perhaps the most famous clicky keyboard with manufacturing spanning 1984 until the late 90’s and a company purchased the manufacturing line and still produces a variant to this day. Their enduring popularity and sometimes surprising price tag on the second hand market is testimonial to their design and build quality.

Modern day mechanical keyboards are manufactured and popular with typists, gamers, and aficionados. Das Keyboard offer undeniable quality for Mac, PC and Linux. They even offer an uber-geeky blank keycap variant to totally confound your visual based two fingered typing coworkers. Due to their specialist and somewhat niche market however these keyboards cost twenty times that of a cheap membrane keyboard.

History lesson and personal typing preference aside however I’m also a fan of retro computers so when I learned of a project to modify a keyboard from the late Steve Jobs NeXT computer company into a modern functioning USB device I was more than interested.

As I didn’t have a somewhat rare NeXT keyboard in my junk box I tracked down an older Apple mechanical Extended Keyboard II for a tenth of the price of a second hand Model M.
NeXT used a proprietary communication protocol to link their keyboard and computer, and early Apple did exactly the same thing with Apple Desktop Bus (ADB) – an early ancestor to our modern day device independent USB protocol.
Whilst there have been various commercial ADB to USB adapters produced over the years building one from scratch proved to be a much more satisfying experience.

After purchasing a Teensy 2.0 USB development board I downloaded the necessary software

I cannot thank the Geekhack crew enough for providing this source code for others to utilise. They saved me hours of reverse engineering and hardware sniffing and made this project a breeze.

Unlike the super-friendly Arduino IDE I had to manually build and compile my own firmware from the command line before flashing it to the device using Teensy Loader. Presumably because I was using a newer version of the compiler than the author I received a build error:
make: *** [obj_adb_usb/common/xprintf.o] Error 1
which was rectified by modifying the code in config.h to include a new conditional
/* key combination for command */
#ifndef __ASSEMBLER__
#include "adb.h"
#include "matrix.h"
#define IS_COMMAND() ( \

Be sure to keep the original endif below the code block when pasting the patch.

Update 02/06/2014 Somehow I missed the Teensyduino extension which provides a more familiar GUI for those not wanting to experiment with the command line. Thanks Nantonos!

The Teensy board needed to be connected to the keyboard power 5v, ground, and signal. As I placed the board inside my keyboard case (now you see why size is important) I didn’t need any further modifications. Other people modifying this keyboard who placed a significant length of wire (such as an ADB cable) between the keyboard and Teensy needed a pullup resistor between the signal and power lines. I had to use a 1K resistor when testing using a breadboard and external cable, but after placing the Teensy inside the keyboard with virtually no wire length it became unnecessary.

Connect the keyboards ADB (data) pin 1 to Teensy pin F0, pin 3 to Teensy VCC (5v) and pin 4 to Teensy GND (ground). If you need a pullup resistor (in the 1-10k range, you may need to experiment) it will link ADB pins 1 and 3.

alps circuit board
High quality ALPS keyswitches are what make all the difference

alps circuit board
ADB socket removed, wires tapped in to the circuit board and heatshrunk ready to attach to the Teensy

Teensy installed
Teensy connected to USB and ready to be installed. I wrapped it in insulation and tucked it out of harms way.

Completed keyboard
47cm wide and weighing in at 1.7kg. Amusingly the MBP it is attached to weighs 2.02kg.

I love the coloured old apple logo top left and whilst it certainly creates the distinctive clacking sound of a mechanical keyboard it is not unbearably loud and coworker irritating. Perhaps Jethro Carr could have used one and avoided the banning of his beloved Model M’s.

If you would like to hear the sound of this keyboard head on over to Shawn Blanc’s article.

Edit 17/02/2014 I have just made another of these keyboards as I’ve become accustomed to using them and felt I was missing out at while I was at work. I had a bit of difficulty tracing the ADB pin outs this time as it was a slightly different keyboard (Apple Extended) A great reference is the ADB Apple Desktop Bus pinout

Teensy powered Apple mechanical keyboard Read More »

CodeIgniter routes and .htaccess

CodeIgniter has a robust routing module as part of its MVC architecture. A trap for the inexperienced arises when the default controller works (e.g. site.com) but anything else such as mysite.com/dashboard goes to a server based 404, not the CodeIgniter one.

Solution: in your config.php file ensure this line is present
$config['index_page'] = '';
and place the following code in an .htacess file
Options -Indexes
Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>

# activate URL rewriting
RewriteEngine on

# do not rewrite links to the documentation, assets and public files (your folders here)
RewriteCond $1 !^(images|assets|uploads|js)

# do not rewrite for php files in the document root, robots.txt or the maintenance page etc
RewriteCond $1 !^([^\..]+\.php|robots\.txt|maintenance\.html)

# rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule !mod_rewrite.c>

# If we don't have mod_rewrite installed, all 404's can be sent to index.php, and everything works as normal.

ErrorDocument 404 index.php


CodeIgniter routes and .htaccess Read More »

Raspberry Pi SD card setup

Whilst following the instructions available at enlinux I had repeated errors whilst attempting to move my OS image to the SD card for the Pi to use. Specifically this line:
sudo dd bs=1m if=~/Downloads/2012-10-28-wheezy-raspbian/2012-10-28-wheezy-raspbian.img of=/dev/rdisk3
What ended up solving the problem for me (after much hair pulling) was to not use the built in SD card reader of my MacBook Pro, and to use a cheap external USB dongle. Sometimes it is the most simple thing.

Raspberry Pi SD card setup Read More »

Derived Statistics

In a follow up to this post I thought I’d explain how I obtained the statistics used.

The first indicators were easy to obtain – No Avatar Picture, No Tweets and No Followers and are fairly self explanatory. Obtaining a figure for Inactive Accounts however was a little more difficult. Because Twitter does not return any information (other than a total) for a private accounts tweets, the last_tweet_date was not available for all users. To stop this from skewing the dataset I removed these accounts from the sample size.

  John Key Clare Curran Russel Norman Metiria Turei David Shearer Gareth Hughes
Private Accounts 4269 153 342 284 284 377
Percentage 8.5 6.3 8.7 8.3 8.9 8.9

As you can see the percentage of private accounts is roughly equivalent – and not enough to skew our sample.
This gave me a new followers total to calculate averages for tweet related metrics Inactive Accounts and “Real” Followers

  John Key Clare Curran Russel Norman Metiria Turei David Shearer Gareth Hughes
No Avatar 27% 8% 11% 10% 11% 6%
No Followers 17% 1% 4% 3% 4% 2%
Inactive 39% 17% 20% 19% 14% 14%
‘Real’ 43% 77% 72% 74% 74% 80%

I’ll leave it as an exercise for the reader to interpret accordingly.

NB: These accounts were selected as Leader of the Opposition, Leaders of the Greens, and Clare Curran and Gareth Hughes as they had respectable follower numbers of their own for comparison.

EDIT 18/06/2012

I located a site that can graph followers over time for a Twitter account, sadly the scale of the x-axis is not consistent which tends to cause spikes in growth that wouldn’t normally be visible.

John Key Followers vs Time

As you can see the growth is fairly consistent: the first dip is presumably a statistic gathering error and should be discarded.
As only an idiot would buy followers in large and obviously identifiable quantities (Rudd, Gingrich…Lady Gaga) steady organic looking growth doesn’t mean anything if you’re smart and feed them in gradually. The jump at the end of the graph actually indicates only 375 increased followers a day which could of course easily be attributed to a particularly good press release. (Although I can’t seem to recall any of late) and isn’t a smoking gun by any stretch.

A commenter elsewhere suggested comparing other politicians with 50,000 followers to see how they stack up. Their point may have been purely that we don’t have any…however we do have some celebs and sportspeople who match up. I’ve started the data collection process so we should have some comparisons late today or tomorrow.

UPDATE 21/06/2012 Obtaining additional data for comparison took a lot longer than expected due to unforeseen issues with the Twitter API.

  John Key Piri Weepu Corey Jane John Campbell Rhys Darby Helen Clark
Followers 50,000 50,000 50,000 32,04 88,396 18,392
No Avatar 27% 15% 20% 15% 14% 11%
No Followers 17% 10% 14% 8% 6% 4%
Inactive 39% 12% 22% 2% 22% 12%
‘Real’ 43% 67% 56% 67% 64% 79%

Interesting to see how ‘active’ @johnjcampbell‘s followers are, and that Piri and Corey’s followers are so different given that you would expect them to be followed by similar accounts.

Update 31/07/2012
There has been an application released that people can use to analyse their own accounts called Status People

The tool largely mirrors my own assumptions and subsequent results, but is much more user friendly than the tools I created for my own use.

More discussion in and around the subject is available in this National Business Review article

Derived Statistics Read More »

Twitter follower numbers

John Key
John Key – Less debt, more jobs…more ghost followers?

Chris Keall’s recent article in The National Business Review had John Key @johnkeypm as ‘top of the twits’ with over 50,000 subscribers. With Newt Gingrich and Kevin Rudd amongst others being accused of buying Twitter followers I thought it would be interesting to investigate some of John Key’s followers.

In the comments for the NBR article MikePSmith suggested most of the followers were spambots with CK replying “overall it looks like most are living breathing New Zealanders”. I cast my eye over the followers and decided exactly the opposite: most of the following accounts looked extremely fishy.

The @johnkeypm account is a managed account – that is the man himself does not update it personally. Much like the man it is decidedly bland and delivers the party line more like an RSS feed.

To make the account look as popular as possible accounts that regular users block and report for spam are kept as active followers. If the account isn’t actually being used in the traditional manner those annoying spam accounts aren’t interfering with everyday use.

So with the help of Twitter API I analysed the followers of the @johnkeypm account. The results confirmed almost exactly what my eyes had already told me: most of the accounts were spambots, zombies, or worse.

John Key (thumbnail) Zombie Horde
Click to enlarge Join the horde? courtesy Björn Söderqvist

With a very loose definition of an actual Twitter user as opposed to a spambot zombie (10 followers, 10 tweets, tweeted this year, have bothered to change the display picture from the default) the follower count falls to less than half at 22,000 accounts.
If you care to further refine the criteria to what most of us would consider regular active users the numbers just fall away. Limiting to accounts based in New Zealand (not fair to expats or those who choose not to disclose) then the numbers dwindle even further.

John Key probably remains New Zealand politician with the largest Twitter follower count but with a much smaller margin than the numbers suggest – if one is at all concerned about quality or real accounts.

UPDATE 15/06/2012
Other accounts will be analysed for comparison

Clare Curran @clarecurranmp
No avatar pic 8% (197 accounts)
No tweets 5% (115 accounts)
No followers 1% (15 accounts)
Inactives 17% (387 accounts) Corrected 17/06/2012
‘Real’ followers 77% (1764 accounts)

UPDATE 17/06/2012
A follow up post explaining how the numbers were determined will follow shortly

Twitter follower numbers Read More »