02 Dec 2011
When she was younger my wife wanted to be a meteorologist. That didn’t pan out, but our recent move found us
with a garden, which we’ve not had before. This gave me the opportunity to buy her
a weather station. I
didn’t just choose any old station though, I wanted one that did wind and rain as well as the usual
temperature, pressure and humidity. And, the deciding factor, a USB interface with Linux support. Fortunately
the excellent PyWWS supports a range of weather stations,
including the one I brought.
I’m not going to go into how I mounted the
system, or configured PyWWS. That’s all covered in the documentation. PyWWS can produce a static website,
but as someone who earns his living building websites I wanted something a bit better.
Continuing my experiments with CouchDB I decided to build the website as a
CouchApp.
As well as allowing you to query your data with Javascript, CouchDB lets you display webpages directly out of
your database. If you visit welwynweather.co.uk you’ll notice
that you’re redirected to a url that contains url arguments that look a lot like those used to
query a view. That’s because that’s
exactly what’s going on. Things become clearer when you discover that that
http://www.welwynweather.co.uk is an alias for
http://db.welwynweather.co.uk/_design/weather/_rewrite/.
Now you can see a more complete CouchDB URL, albeit without the database name.
db.welwynweather.co.uk points to an Apache reverse proxy that routes
requests through to CouchDB.
Read More...
25 Nov 2011
I’m a huge science and engineering documentary geek. I prefer watching documentaries over all other forms of
television. It doesn’t really matter what the documentary is about, I’ll usually watch it. After getting ready
for my wedding I had a bit of time before I had to walk down the aisle so I watched a documentary about pilots
learning to land Marine One at the White House. There
probably aren’t many people who would choose to spend that time that way.
Science documentaries have experienced a renaissance over the last few years, particularly on the BBC. The
long running Horizon series has been joined by a raft
of other mini-series presented by Brian Cox, Alice Roberts, Marcus Du Sutoy, Jim Al-Kalili and Michael Mosely.
These cover a large part of the sciences, including Chemistry, Biology and Physics. Physics in particular is
regularly on our screens. Whether it’s talking about quantum mechanics or astronomy or something else it seems
that Physics has never been more popular.
As someone who writes computer programmes for a living this makes me worry that your average man on the street
may end up with a better understanding of quantum mechanics than they do of the computer on their desk, or in
their pocket.
Read More...
18 Nov 2011
Recently I purchased a basic Sonos system, and after just a couple of
weeks I’m already in love with it and have more music playing in my house than ever before.
For those of you who haven’t come across Sonos before, Sonos produce a multi-room wireless music system. The
system consists of a number of devices that connect to each other using a proprietary mesh network. You can
buy Sonos devices that contain built in speakers, or ones that connect to your own as well as a device to link
your iPhone and to join your existing network to the Sonos wireless network.
I purchased a
Sonos Play:3, a Wireless
Dock and ZoneBridge (all three links contain an affiliate id) so that’s what I’m
reviewing here.
The Sonos Play:3 is as fairly small, unassuming, single speaker block. It contains three individual speakers
while it’s larger brother, the
Play:5 (affiliate link) contains five. The back has a
power socket and a network port. The top has a mute button, as well as a volumn up and down rocker. The other
devices are similarly spartan, yet stylish, in their design with minimal on device buttons.
Read More...
11 Nov 2011
Recently I posted about upgrading my old iPhone 3G to a 64GB 4S. One of the things I
was mostly looking forward to with the upgrade was the much improved camera and the ability to take video.
Last week I spent some time at the Giant’s Causeway in Northern
Ireland and I had plenty of opportunity to experiment with both the still and video camera.
Although it’ll never replace my DSLR the stills camera managed to take some really respectable shots. By far
the biggest issue is the lack of a zoom. The colours are great, the focus is sharp but you can’t use the zoom
to frame a shot. You need to move if you want to change what’s in your shot.
The video camera is also excellent. The pictures are bright, crisp and clear and it’s very easy to start
recording. The small size of the iPhone makes it very easy to move the camera around. Movement is not
something I’d had to think about before have previously only used a stills camera, but a static video shot
gets boring very quickly.
Read More...
02 Nov 2011
Recently I was taking part in a review of some Python code. One aspect of the code really stuck out to me.
It’s not a structural issue, but a minor change in programming style that can greatly improve the
maintainability of the code.
The code in general was quite good, but a code snippet similar to that given below jumped right to the top of
my list of things to be fixed. Why is this so bad? Let us first consider what exceptions are and why you might
use them in Python.
try:
// code
except Exception, e:
// error handling code
Exceptions are a way of breaking out the normal program flow when an ‘exceptional’ condition arises.
Typically this is used when errors occur, but exceptions can also be used as an easy way to break out of
normal flow during normal but unusual conditions. In a limited set of situations it can make program flow
clearer.
Read More...