Skip navigation

If you’re using VMware Fusion and can’t get the keyboard layout right in your VM (especially if you can’t get backslash to show up), try my Happy Hacking UK layout. This gives me the correct layout on my MBP at least :)

My MBP has the \ key (shift-\ is |) above the return key and to the right of the ] key. Note that because this is the UK layout, it makes shift-2 generate double-quote ", and shift-single-quote generate @. For personal reasons, shift-3 generates hash #. To obtain the GBP Sterling currency symbol £, use right alt-3.

Please see my Alfred Extensions page for updates!

A quick and easy one for Alfred: a command which toggles AirPort on/off.

If you are using Alfred 0.9.9 (or better), you should be able to download this ZIP file and import it!

If you are using an earlier version of Alfred, follow these instructions:

AIRPORT=`networksetup -getairportpower AirPort | grep Off`; if [ "$?" = "0" ]; then networksetup -setairportpower AirPort on; MSG="AirPort enabled"; else networksetup -setairportpower Airport off; MSG="AirPort disabled"; fi; /usr/local/bin/growlnotify -m "$MSG" -a "/Applications/Utilities/Airport Utility.app" AirPort status

Create as a terminal script and configure it to be silent. I also borrowed the icon from AirPort utility for the script (Alfred for “airport” and then use Reveal in Finder on it; Get Info; click Icon and ⌘C; click the icon area in Alfred and ⌘V).

Script configuration screenshot

Please see my Alfred Extensions page for updates!

I wrote this little scriptlet to change network location in OS X using Alfred, but you could trigger it using whatever method you wanted.

If you’re using Alfred 0.9.9 or later, you should be able to download this ZIP file and import it!

if you using an earlier version, follow the instructions below:

/usr/sbin/scselect 2>&1 | /usr/bin/grep -i {query} | /usr/bin/cut -c 4-39 | /usr/bin/xargs /usr/sbin/scselect

UPDATE 2011-06-11: I have significantly improved the script to work around a bug caused by the 3Connect profile (3Connect is pants FYI), as well as use growlnotify to tell you if the change worked or not. It also allows substring matches (anchored at the start) so you can use “auto” for “Automatic”. If you have more than one profile that starts with a matching substring, the behaviour is currently undefined.

Growl showing network change notification

MSG=`/usr/sbin/scselect 2>&1 | /usr/bin/egrep -i "\({query}" | /usr/bin/cut -c 4- | /usr/bin/cut -f 1 | /usr/bin/head -n 1 | /usr/bin/xargs /usr/sbin/scselect | /usr/bin/sed -E 's/.+ \((.+)\)/Location changed to \1/'`; if [ "$MSG" = "" ]; then /usr/local/bin/growlnotify -a /System/Library/PreferencePanes/Network.prefPane -m "Unable to change location" Error; else /usr/local/bin/growlnotify -a /System/Library/PreferencePanes/Network.prefPane -m "$MSG" Location changed; fi;

If you want it without Growl notifications, use this version:

usr/sbin/scselect 2>&1 | /usr/bin/egrep -i "\({query}" | /usr/bin/cut -c 4- | /usr/bin/cut -f 1 | /usr/bin/head -n 1 | /usr/bin/xargs /usr/sbin/scselect

It’s slightly convoluted as it’s case-insensitive. To use it, create a Terminal/Shell script entry like this:

Alfred settings

Now you can just type “location work” or similar into Alfred to change network location. I’ll add Growl-confirmation support when the next version of Alfred is released :)

A while back I put some of my Xcode bits (i.e. the Random Recipe Generator) into my Dropbox to make it easier to stay up to date on my laptop and my desktop. (Yes, I know, source control blah blah blah :)

However, building the Distribution version of the app gave me this warning:

“The CodeResources file must be a symbolic link to _CodeSignature/CodeResources”

which I duly ignored. However, the Application Loader (used to push the new binary to the App Store) also complained about that and wouldn’t upload it.

It looks like Dropbox’s replication may have been to blame for the symlink stopping being a symlink, so the solution is to use the handy new selective sync option in Dropbox and not sync the build/ directory between my machines (which is pretty much pointless anyway and certainly generates a lot of network overhead when you build). Having done that and built a clean copy it worked fine.

Use this Mac OS X Hints tip and use the following URL for the “download” line:

http://b.oooom.net/shrink.php?api=1&url=

CDS Internal Error (3014)

Means: Can’t reach the HTTP proxy you have configured. Maybe you should turn it off.

To get tarsnap working under cygwin, here’s what you need to do:

  1. Install the following packages using the cygwin setup tool:
    • gcc4
    • make
    • openssl (needed for runtime, not for building)
    • openssl-devel
    • zlib-devel
  2. Download and extract the tarsnap code.
  3. Run ./configure (this seems to be much slower on cygwin than on other more UNIXy platforms)
  4. Run make all install clean

Tarsnap should now be installed and you can use it in the normal fashion – create a host key with tarsnap-keygen and then get backing up!

Edit 2009-12-16: checkers from #tarsnap on EFnet has written a post with scripts for Linux and Cygwin tarsnapping at http://www.bluebottle.net.au/blog/2009/tarsnap-backups-on-windows-and-linux

You may also wish at add --prefix=/ to the configure command line, as /usr/local isn’t in the default path.

Before you go any further, this isn’t about having gvim embedded in Outlook, or using it automatically as an external editor.

This method lets you use one keystroke to edit a mail in gvim and when you close gvim, it’s put back into the Outlook compose mail window.

Read More »

We use RiskDisk at work to see if a company we’re going to do business with is trustworthy, but recently it was complaining HTTP Error 417: Expectation Failed when it tried to do any online lookups.

I tracked this down to it sending Expect: 100-continue in the headers of the request it sent to its server. However, it was going via our web proxy at work, which is Squid. Recently I upgraded Squid to 2.7, and this seems to be the cause of the problems. Squid 2.7 is less forgiving about that particular header (which is apparently an RFC violation on the part of the client).

It’s easily fixed by adding ignore_expect_100 on to your Squid configuration.

If you ever want to grep the output of ccze and found it didn’t work right, here’s the magic incantation to do it:

tail somefile | ccze -A -o noscroll | grep ...

-A makes ccze output ASCII sequences, and -o noscroll turns off the scroll option – whatever that is exactly. The man page says it’s a good idea to turn it off if you’re redirecting the output. Omitting it seems to make the output appear in lumps :)

For example, keep an eye on squid logs omitting all MSN crap:

tail -F access.log | ccze -A -C -o noscroll | grep -v gateway.dll