Adding an Application Specific Keyboard Shortcut to OS X

This is just a short post mainly so I can link to it for a friend who might want it.

We are going to set a keyboard shortcut to toggle automatic spelling checking in Safari. This is incredibly useful for people who sometimes write a bit in a foreign language as auto correct will keep “correcting” those foreign words.

To start open System Preferences and choose Keyboard. When that comes up select Shortcuts in the row near the top and you will see a pane like the figure below.


Now in the left window click on App Shortcuts and it will be just like the figure.

Now click on the + under the right hand window. A small dialog will open up similar to the figure below. Click on the pop up menu next to Application and you can select Safari. In the text box next to Menu Title type Check Spelling While Typing (the exact text of the menu item to which we want the keyboard shortcut to apply). Then click in the box next to Keyboard Shortcut and type Option-Command-T. Your dialog should look exactly like the figure below. Click on the Add button and our task is complete. If you want to know how I came up with the text ‘Check Spelling While Typing’ then go to Safari and under the Edit menu look at and under Spelling and Grammar you will see the text. This is what the Keyboard System Preference means by “Menu Text”, it’s just the text ofthe menu item you want to trigger when you type the shortcut.


When you want to type some foreign text in Safari type Option-Command-T to turn off auto spell checking and when you have finished type Option-Command-T again to turn it back on.

Using the same method you can easily build your own keyboard shortcuts. For more complex keyboard shortcuts you might want to look at Keyboard Maestro, my favourite keyboard shortcut tool.

Real keyboard dweebs, like me, also install Karabiner for really customizing the keyboard and on desktop Macs with third-party keyboards Seil, a utility for “the caps lock key and some international keys in PC keyboards” as they put it. This may be too much for you but I’m the sort of person who paid $150 for the keyboard I use on my desk at home, so I’m demonstrably not rational when it comes to keyboards and shortcuts.

IPython Install Made Easy for Macintosh

Great news for those that want to run IPython on any platform. Continuum Analytics offers a marvellous tool (for free) called Anaconda that will install Python and iPython in one swift step.

Not only can you install all the requirements in one swift step but you can even install them in your home folder if you don’t have administrator access to your Mac.

The icing on the cake is that Anaconda also takes over the task of virtualenv, allowing you to build specific environments with different sets of libraries or a different version of Python. They even offer a package install tool and package repository, all checked to see they work properly with the current version of Anaconda.

Anaconda installs a huge list of packages along with Python and IPython, if you want to install just a few packages they offer a tool, miniconda, that installs only the tools and Python so you can pick and choose what else gets installed.

This is a highly recommended set of tools for Python and IPython development. They even have installs for Windows and one for Linux that packs the installer in a bash script so it can be installed anywhere (once again you can easily install it in your home directory.)

Hacking The Philips Hue

Philips hue mot vanlig lampa...

Philips Hue (Photo credit: Patrick Strandberg)

A short time ago I bought myself a Philips Hue starter pack and installed the three globes in my lounge room.

I must say that I love the way you can set the colour and brightness of these things. Having installed and played with the iPhone app it came to me that I should have a bit of a hack and see what I could do.

My first need was to find a way to turn the lights down as the evening gets late. I thought that would be a nice way to remind myself it was getting late and to think about going to bed.

I decided Python was the way to go since I can run it on both my server, the iPhone and iPad. I discovered a nicely usable library for Python and quickly wrote the required script. Then I just installed it as an item in the root crontab so now the lights get turned down to half power at 10:30 every night. The script required is tiny:


from phue import Bridge
b = Bridge('')
b.set_light([1,2,3], 'bri', 127, transitiontime=300)

Next was to see if I could get the library installed on my iPad and working to do something there. Getting the library on the iPad is not obvious but is simple once you know how.

- Download the library
- Unzip
- Copy to Dropbox
- Open on iPad in text editor (Textastic)
- Copy entire file
- Open Pythonista and create new file
- Paste
- Change name to 'phue'

Once you’ve done that you now have the library available to import, though Pythonista appears not to support importing just part of a library.

The script I wrote for the iPad allows me to type a number in Drafts and then set the brightness of the Hue to that number:

# set the hue lights to a particular power or half

import phue, webbrowser, sys

    brightness = int(sys.argv[1]) 
  brightness = 127

b = phue.Bridge('')

b.set_light([1,2,3], 'bri', brightness)'Drafts://')

This works well. The script above is saved in Pythonista as ‘Hue’ and then I wrote a URL action for Drafts, “pythonista://Hue?action=run&args[[draft]]”. Then I just open a new note, type the number and select the custom action.

On the iPhone I use Launch Center Pro and it’s even neater. In the script above change the open at the end to “launchpro://” then create a URL action. Launch Center Pro knows about Pythonista so create a new action, find Pythonista in the Installed Apps, select “Run Script w/ Arguments”. Change the name to something like “Hue”, set the script name to ‘Hue’ and under Arguments you want an Input Prompt with the Number Pad. Now when you touch the icon in Launch Center Pro it will open up a window with the number pad, you enter a number between 1 (almost off) and 255 (full bright). If you leave it blank it sets the brightness to half power.

My next hack is to come up with a system to set the colour and brightness. There are three modes for defining the colour, hue and saturation, colour temperature and the x and y of a point in the CIE colourspace. After doing some testing it seems that if a bulb is in one mode it will ignore a setting in one of the other two colour modes. This means that you must set the colour mode of the bulb before setting the colour to make sure that it works.

The iPhone app allows you to have a number of presets it calls “scenes” and I would like to do the same thing in Python. To this end I wrote a script to discover the current settings and write them out.

import phue
b = phue.Bridge('')
# range over the three lights
for i in range(1, 4):
    print "Light: " + str(i)
    # Get the color mode of the light [hs|xy|ct]
    mode = b.get_light(i, 'colormode')
    bri = b.get_light(i, 'bri')
    if mode == 'hs':
        hue = b.get_light(i, 'hue')
        sat = b.get_light(i, 'sat')
        print "Mode: " + mode + " Hue: " + str(hue) + " Sat: " + str(sat) + " Bright: " + str(bri)
    elif mode == 'ct' :
        colortemp = b.get_light(i, 'ct')
        print "Mode: " + mode + " ColorTemp: " + str(colortemp) + " Bright: " + str(bri)
        xy = b.get_light(i, 'xy') 
        print "Mode: " + mode + " XY: " + str(xy) + " Bright: " + str(bri)

I’m going to keep on playing and see what more I can discover.

Keyboard Maestro Updated To 6

Keyboard Maestro 6 has just arrived and this already marvellous utility has just improved a bunch. I could tell you about the new features or you could read the press release from Stairways.

The two big gee whizz new features for me are browser actions and the ability to write my own actions. I will have more on it when I have some time to rejig all my existing macros and work on adding some more.

It’s not a huge reworking of the entire application but it is a decent improvement so if you haven’t tried then visit the website for more details and download a free trial.

Unix As A Second Language — Great New Blog

I’ve just discovered an excellent bog on IT World, a site I usually avoid as it is quite “corporate”. Unix As A Second Language by Sandra Henry-Stocker is, however an excellent source of Unix information and tips from anybody just starting out like her Unix Commands And Tools You Just Can’t Live Without to those on the edge of real expertise So You Want To Be A Unix Sysadmin and some for everyone Unix: Cheat Sheets — everything you wanted to know about everything … almost which pointed me to the excellent site OverAPI.

It hasn’t been there long but I suspect it’s going to be a great blog to follow for Unix users and those who delve into the command line of OS X.

The Pebble Watch

Pebble Watch


I often support interesting projects on KickStarter and one I supported was the Pebble watch. Mine arrived a few days ago.

First impressions were good, it arrived in a nice custom cardboard box and the watch and charge cable were in a custom cardboard holder. All made from recycled and recyclable cardboard. There were no instructions beyond a note to “Get started at”.

The introduction page you end up on needs some work but I managed to get the watch hooked up to power and talking to my iPhone without too much trouble. It hooks up to power with a custom USB cable with a magnetic latch and two power dots. This is so that the watch can be totally waterproof – you can swim or shower with it on.

I then updated the software on the watch and added a couple of watch faces using the iPhone app.

The appearance of the Pebble is acceptable, for me it is a fraction too large but it is certainly no larger than a lot of mens watches. I really like the “Text Watch” face that tell you the time in words. I may have to change the band as I prefer a metal or leather band to plastic in Sydney’s warm weather.

The screen is a low power LCD with a backlight – in dark conditions you can turn on the backlight by touching a button, tapping the phone or even giving it a shake – a quick rotate of my wrist works fine. The screen is 144 by 168 pixels – large enough for a decent watch face or to show an SMS. The screen is easily seen in most daylight and office conditions though the white is more a light blue-grey.

Inside is an ARM processor, an accelerometer, a light sensor, a BlueTooth radio and a small vibration motor (easily felt when it’s on your wrist).

Once connected to my phone it worked fairly well. Due to some problems with iOS 6 it has trouble showing notifications from a lot of apps but it does fine showing an SMS, caller ID or details of a song when you use your watch to control your music.

At the moment that pretty much sums up all the functionality of the watch, there is promise of more to come with Pebble promising more software updates to add more apps and more functions to the current software.

Every so often the iPhone pops up a dialog asking of it’s OK for the app to communicate with the watch and hitting OK runs the app. When it does this is totally mysterious.

At the moment I have to say that the Pebble is a great start and a perfect addition to my network of things. I think the people at Pebble have been a little overwhelmed by the demand they’ve seen. I hope in the weeks to come we get some of the promised apps. I’m waiting for the cycle computer or Run Keeper apps in particular.

Some Notes On Real Racing 3

After a few more days with Real Racing I’ve made a few notes.

Race Types

Autocross is certainly the hardest of the race types – there are a few I’ve come across that seem impossible. I’ve raced in one where I had the best car in the series with all upgrades and my time was over 50 seconds when the time for first was 36 seconds. This is currently my biggest complaint about Real Racing 3.

Drag races are by far the easiest. You don’t have to worry about your steering since the car will always go straight, just concentrate on the tachometer and hit the gear up paddle when it hits the red.

There appears to be a couple of bugs in the endurance races, sometimes I see what looks like a ghost car and sometimes my car suddenly brakes as if it’s avoiding an invisible car. It has to be said that I often get an incredible result in endurance once 2nd was 6.4km and I managed 43.4km.

Continue reading