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:

#!/usr/bin/python

from phue import Bridge
b = Bridge('192.168.1.17')
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 phue.py to Dropbox
- Open phue.py 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

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

b = phue.Bridge('192.168.1.17')

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

webbrowser.open('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('192.168.1.17')
# 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)
    else:
        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 go.getpebble.com”.

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

Review: Real Racing 3

photo

Real Racing 3
(click to see image full size)

Since I am in Australia I get to play Real Racing 3 (RR3) before the general release on the 28th.

I enjoy racing games and I am a huge fan of the Real Racing franchise, I enjoyed both 1 and 2 enormously. I was looking forward to RR3 with bated breath.

I have to say at one level it doesn’t disappoint, the graphics, controls damage modelling and the addition of having to service a car make it better than RR2 and there are a wide range of tracks and cars to play. There are 27 different racing series to compete in and each series has three or four different cars that can compete in it. A given car can usually compete in several series and might find itself the best possible car in one series but seriously outgunned in another. The cars range from the old Nissan Silvia S15 all the way through US muscle cars and Italian sports cars such as the Lamborghini Aventador to European exotics such as the Bugatti Veyron and Pagani Huayra. Ferrari didn’t license any of their cars to the game and they and Mercedes and the most obvious holes in the supercar lineup.

The tracks are also varied from the almost impossibly tight and unforgiving Southbank track in Melbourne, Australia to the Indianapolis Speedway and more traditional tracks such as Silverstone or Brands Hatch to the wide open long straights of Hockenheim. Mount Panorama, better known as Bathurst, in Australia is even included. So far I’ve found 9 tracks but some have variations of layout so in total I’ve found 17 layouts.

The game play is good with excellent graphics, sound and realism. I love the way my Dodge gets light and skittish when it’s roaring down a long straight. There are a number of different sorts of race; a traditional motor race with a field of 22 called a Cup race, elimination races with a field of eight where the last car gets eliminated every 20 seconds, drag races comprising three rounds, autocross where you have to post the fastest time for a short stretch of track, speed snap where you have to hit the finish line at the highest possible speed, speed record where you have one lap to attain the highest possible speed, endurance where you have a certain amount of time to gain the longest distance with time bonuses for passing and finishing a lap and head to head where you race against one other car.

Continue reading