22 January 2015

How To Invert Apple Magic Trackpad Orientation

Over the years, I've grown so fond of OSX trackpad gestures that I couldn't bear the thought of going back to a mouse when I bought my Freestyle2 keyboard. The solution was to buy a Magic Trackpad, which works exactly as expected. However, Jony Ive's people clearly ignored ergonomics when designing this product: in the default configuration, it's just a wrist killer.

I wonder if somebody knew about this, because OSX has a very easy way to turn the trackpad around, in what becomes a much better stance; a negative slope is much kinder on your wrists and hands. So, without further ado, here's how you revert your trackpad:

  1. Disconnect your trackpad, by pressing the power button until the green light goes off.
  2. Type the following command in your Terminal, all on one line: sudo defaults write com.apple.MultitouchSupport ForceAutoOrientation YES
  3. invert your trackpad, turn it on, then place five fingers on it, stretched enough that the device can recognise a hand shape. Congratulations, your trackpad is now inverted.
  4. If you want to go back to the previous orientation, just switch the trackpad off, turn it around, and again place five fingers on it on reconnect.

I suggest adding a padded rest for your wrist, or something to that effect. I'm currently using a couple of CD cases but I'll probably get something softer at some point. Now my wrist feels *much* better, even more relaxed than with a mouse.

Caveat: the trackpad has a significant inactive area where the battery is stored. This means that you have to keep your hand a bit further from the edge than before. It might take a few minutes to adapt, especially if you drag&drop with your thumb as I do. One alternative is to use three-fingers dragging instead, which also works very well.

08 January 2015

Kinesis Freestyle2 Multichannel Bluetooth for Mac - Review

As New Year Resolutions go, improving your ergonomics is an easy one to achieve for most programmers: just buy decent kit (proper chair, table, screen, keyboard, mouse), set it up once, et voilĂ . In this spirit, I've just bought the Kinesis Freestyle2 Multichannel Bluetooth, and this is a short review after just a few hours of usage.

Freestyle2 is the revised model of the (fairly successful) Freestyle keyboard. It's a split Bluetooth keyboard that can actually detach its two halves, so that it can suit your personal ergonomic stance rather than forcing you to adapt to an arbitrary keyboard position. Out of the box, it comes with a pivot tether keeping the halves together, but I personally removed it straight away and it felt immensely liberating.

Obviously, such a keyboard will pay great attention to ergonomics all over. It's flat, but keys are slightly counter-sloped in order to achieve a negative-slope feeling, which is nice. Still, the Freestyle2 is fairly thick, so you'll want to buy the optional padded armrests as well (I originally forgot and can clearly feel the strain - time for a top-up order).

I'm quite happy with overall build quality, including good key switches you don't have to bang onto and never get stuck. The Mac version comes with Command and Option keys in all the right places, and quite a few goodies I've missed since I moved to laptops (Delete, Home, End, PgUp, PgDwn). I'll likely need a few weeks to get fully used to a regular keyboard again, after two years exclusively spent on a MacBook, but that would have been inevitable with any keyboard.

I'm not entirely sold on the huge Esc key being so far away from the main rows, but if it's the price to pay for a big Delete just above regular Backspace, so be it; I'm not a big Vi user anyway! ;-) Note: the "Multichannel for Mac" version of the Freestyle2 is only available in US layout at the moment; this said, if you switch to UK layout in OSX, the keyboard will happily give you UK characters where they're supposed to be (except for slash, which is physically in a different place), so if you're not a "hunt & peck" person, you should have little trouble adapting. Considering the split layout, I wouldn't recommend this keyboard to any H&P friend anyway.

The multichannel concept is intriguing, and works smoothly. Basically, you can pair the keyboard to 3 different computers/phones/tablets, and switch between them as necessary. Getting a text message on your Android phone while you're working on your laptop? Just hit Fn-2 or Fn-3 to respond. Having several laptops (like me)? Just switch between them as necessary without having to buy a cumbersome KVM setup. I tested it switching between MBP and iPhone 5, and it worked great. This is seriously cool, now I wish I had a mouse/trackpad that could do it as well.

Talking of trackpads, there is a really nice coincidence: if you get an Apple Magic Trackpad, like I did, and put a simple cd case underneath to even it out (seriously, Apple: who thought sloping it was a good idea?), you'll find that trackpad surface sits perfectly even to the Freestyle2. If this effect was achieved on purpose, well done Kinesis! It makes it really easy to transition from keyboard to trackpad.

The only real "wtf moment" I had was that the key assigned to Mission Control seems to actually return F12. This is probably the result of some hackery I did in the past on my laptop, but I haven't been able to track it down yet. It's not a big deal anyway: I bought a trackpad exactly so that I could keep using gestures for this sort of activity.

Last and probably least, the Freestyle2 features two additional key columns on the left-hand side, predefined for some supposedly-common actions: "back" and "forward" in browsers, "go to" beginning or end of the line, Cut/Copy/Paste, Undo, and Select All. In truth, I can see how Kinesis really needed just one column (for Fn and 1/2/3 switches to change channel); the second was probably added to get better symmetry with the right half of the keyboard. These keys would be more useful if they could be remapped, which can probably be achieved with some hackery but is not officially supported by Kinesis. "Forward" in particular seem particularly wasted -- there is a reason most browsers only emphasise Back these days.

Setup was easy, but make sure you read the instructions properly; I initially failed to notice that you have to explicitly select the channel before pairing, and overwrote my initial pairing a couple of times. It would be nice if the Freestyle2 were smart enough to default to a "free" channel when pairing, but it's a minor feature that you'll likely use only the first time you connect the keyboard anyway. Btw, make sure you download those instructions, because they are not actually included in the box.

If you'd like to buy a Freestyle2 and you are in the US, you can just order it from the Kinesis website (remember armrests!). I got mine in the UK thanks to official distributor Osmond Ergonomics, which very kindly got in touch as soon as I tweeted (between Christmas and New Year's Eve) and notified me when they received some stock -- they should have Multichannel models available on their webstore in a week or two; in the meantime just get in touch directly and they'll be happy to oblige (BTW, if you don't care about Multichannel features, you can order a regular Freestyle2 on the website right now).

23 December 2014

"Securing EPM" presentation at UKOUG Apps14

The slides for the "Securing EPM" presentation I've given at UKOUG Apps14 in Liverpool two weeks ago, are now available here. Merry Christmas!

19 November 2014

HOWTO Setup gunicorn on OpenBSD 5.6

As part of a silly web project of mine, I'm having fun getting reacquainted with OpenBSD.

Today I wanted to set up Gunicorn, a powerful webserver that will eventually run my Django application. It was not a straightforward process, so I decided to document it for my fellow geeks.

Preamble

This procedure assumes that you've already set up the following:
  • installed Python 3 (I tested with 3.4.1)
  • created a custom myuser account and logged on as such
  • created a virtualenv with pyvenv /home/myuser
  • installed Django in the above-mentioned virtualenv
  • created a Django project at /home/myuser/myproject

Let's go!

  1. activate the virtualenv: source bin/activate
  2. install Gunicorn: pip install gunicorn
  3. create /home/myuser/gunicorn_config.py with the following contents:
    command = '/home/myuser/bin/gunicorn'
    pythonpath = '/home/myuser/myproject'
    chdir = '/home/myuser'
    pidfile = '/home/myuser/.gunicorn_myproject.pid'
    user = 'nobody'
    worker_tmp_dir = '/tmp'
    errorlog = '/var/log/gunicorn_myproject'
    # tweak the following lines to suit your setup
    bind = 'localhost:8001'
    workers = 4
    You can add any further option as necessary, but it's important you keep pidfile and user.
  4. sudo to root (I'd recommend to do that from another account, i.e. don't add myuser to wheel) and create /etc/rc.d/gunicorn_myproject with the following contents:
    #!/bin/sh
    daemon="/home/myuser/bin/python"
    daemon_flags="/home/myuser/bin/gunicorn -c /home/myuser/gunicorn_config.py -D myproject.wsgi"
    
    rc_stop() {
        kill `cat /home/myuser/.gunicorn_myproject.pid`
    }
    
    . /etc/rc.d/rc.subr
    
    rc_cmd $1
    Note how we are specifying daemon to be the python executable. This is the only way I've found to keep the rest of the machinery in rc.subr working smoothly.
  5. chmod 555 /etc/rc.d/gunicorn_myproject
  6. now you can start and stop Gunicorn with standard OpenBSD 5.x commands: /etc/rc.d/gunicorn_myproject start
  7. Typically, you'd then set nginx to proxy and cache requests, and firewall gunicorn from the outside.
Note how gunicorn starts as root and then spawns processes as nobody; if I were to start it as myuser, it would not work. This is because gunicorn tries to change ownership of files and processes after startup, and OpenBSD doesn't seem to like it. This looks suboptimal to me, but I couldn't find a workaround.

Note also how we're writing the main process PID to file, and then using it to stop that same main process. Standard rc.subr machinery would expect me to specify a regex in the pexp variable, which would then be passed to pgrep to find the process; but this doesn't work with gunicorn because pgrep simply cannot distinguish between master and worker processes, since they appear to have the exact same command line.

If you know anything else I should do to further secure this setup, please let me know in comments!

07 November 2014

If you are interested in Oracle EPM infrastructure...

... then you might want to pop in at UKOUG Apps 14 in Liverpool, on 10 December, to hear me describe the sad state of security in our little niche and how we can improve it.

I promise that I won't bamboozle you with security nerdspeak; it will mostly be an overview of "things EPM customers should ask for but somehow never do". Remember to pack your tinfoil hat!