Tuesday, March 27, 2012

A quick phone navigation tip

If you find yourself navigating from written instructions (either received in email, or given on paper) then a simple tip is to take a photograph of the email (or paper) and set it as the image on the lock screen.

Then when you are walking around there's no need to unlock your phone to read the directions.

Here, for example, is how to do that on the iPhone. Suppose you've received directions in an email (if you have a paper set of directions then just photograph them and jump ahead).

First, take a snapshot of the email containing the directions. You can do that by clicking the power button and home button at the same time. A screen shot will appear in Photos.

Find the image in Photos and click on the "Forward" button (bottom left hand corner). That button is used for photograph actions:

Then choose Use as Wallpaper and then position the image so that the directions are in the middle of the screen (which prevents them from being hidden by the clock). Once done choose Set Lock Screen:

And you're done. Now when you look at your locked phone the directions are there to see:

Monday, March 26, 2012

Hey, Twitter! Where's my hyphen gone?

So, I noticed this morning that the Twitter web client eats the hyphen in my name. Here's a picture of my Twitter settings:

There I've got a hyphen.

Here's what happens when I load my Twitter timeline; the hyphen is present and then about 1 second later it disappears:

Oddly this only happens in Safari and not in Google Chrome or Mozilla Firefox. The same thing happens with another hyphenated Twitter user. Here's how Duncan Graham-Rowe appears in a Google search:

And then I click through and his hyphen is lost:

A little bit of testing showed that it's not just in the name. The - gets eaten in the Bio field as well.

When the Twitter client first starts it requests at HTML page (with the URL #!) and it contains my name with its hyphen:
But something changes it (and, as it turns out, all the other names that appear in my timeline) so the hyphen has been eaten:

A further quick test showed that the following characters are all accepted as part of my name, but magically disappear when displayed (in the manner shown above): - ( ) * , . +.

And here's where the finger points away from Twitter and over to Apple: everything's fine on Version 5.1.2 (7534.52.7), but that list of characters is gone on Version 5.1.4 (7534.54.16), a release that included lots of Javascript optimization.

Hey, Apple. Where's my hyphen?

PS I'd be tempted to debug this but (a) figuring out which bit of Javascript changed a DOM element isn't trivial and (b) Twitter's templating system written in Javascript isn't exactly the most debuggable or followable piece of code I've seen.

Tuesday, March 20, 2012

Met Office and CRU argue for open data and open code

Regular readers of this blog will recall that back in 2009 I looked at data released by the Met Office and CRU and found some errors and software bugs in the land surface temperature record known as CRUTEM3.

That experience led to a collaboration between myself and two professors and a joint paper in Nature entitled The Case for Open Computer Programs which used my experience with the closed Met Office code as one example. Our paper argued for the open release of data and code with all academic papers.

Today comes the news of a new paper from the Met Office and CRU describing an update to CRUTEM3 (called CRUTEM4). The paper is Hemispheric and large-scale land surface air temperature variations: An extensive revision and an update to 2010. It contains a couple of pleasing, if slightly surprising, paragraphs (my emphasis):
Given the importance of the CRUTEM land temperature analysis for monitoring climate change (e.g. Trenberth et al. 2007), our preference is that the underlying station data, and software to produce the gridded data, be made openly available. This will enhance transparency, and also allow more rapid identification of possible errors or improvements that might be necessary (see e.g. the earlier discussion of homogeneity adjustments in the SH).
As a result of these efforts, we are able to make the station data for all the series in the CRUTEM4 network freely available, together with software to produce the gridded data (http://www.cru.uea.ac.uk/cru/data/temperature/ and http://www.metoffice.gov.uk/hadobs/).
The Met Office site says the following of the code release:
The code required to produce the CRUTEM4 fields and timeseries will soon be made available. Note that code previously released for CRUTEM3 cannot be used to exactly reproduce CRUTEM4 temperature series due to changes in processing methodology.

Let's hope that this becomes a trend in science.

Saturday, March 17, 2012

Ambient bus arrival monitor from hacked Linksys WRT54GL

London's Transport for London has a wonderful service called Countdown that can give live bus arrival times. For example, here's a page showing live buses passing No. 10 Downing St.

Underlying this is a simple JSON API that, while not public, seems to be usable by the average programmer as long as I'm not abusive. So with its details deciphered (hardly hard since the web site uses the API) I set about building an ambient bus monitor into a model London bus. The idea is that I can glance at the bus and see the times of up to the next two buses that I'm likely to want to catch and know when to leave the house.

Here's a picture of the completed unit:

To make that work I needed a computer of some kind and I'd originally planned on using a eRaspberry Pi. But with the delay in being able to buy one I switched to another host: a hacked Linksys WRT54GL. It's possible to reflash the Linksys with a custom Linux installation that lets me control the box completely (and still use it as a wireless router). There are various project, but I used OpenWRT.

With OpenWRT it's possible to SSH into the box and treat it as any Linux server (albeit a rather slow one). But there's plenty of power to grab bus times and update an LED display connected to the WRT54GL's serial port. Yes, there's a serial port inside the WRT54GL that uses TTL levels and can be easily accessed by soldering on three wires.

First you remove the cover of the router. It's easy because it simply pulls apart, but first you have to cut through a sticker warning you that your warranty is about to end.

The front part pulls away easily to reveal the circuit board:

And the back is just as easy to remove leaving you with the circuit board itself (you must remove the two antennas at the back):

The two serial ports are conveniently easy to access at the edge of the board:

The LED module I'm using is from SparkFun and accepts TTL levels and needs a 3.3V power supply.

Happily the WRT54GL's serial port is TTL and has Vcc and GND, so three wires supply all that's needed:

(Yes, those wires are rather large because I'm using up surplus wire from my homemade matrix display made from hacked Christmas lights).

A quick test with the multimeter showed that I was getting about the right voltage:

Next I used a standard three pin 'headphone' socket and drilled a hole in the front of the Linksys for it:

And put it all back together it makes a neat little unit that's got a serial port on the front:

To wire up the display I took an old sound card cable that came with a PC and cut one end off and soldered the wires to the display. The plug end goes into the Linksys. Here is it showing a number for the first time:

With the hardware half done (no bus yet for the display) it was time for software. The code for the project (written in Lua, which is installed by default as part of OpenWRT) is here.

It relies on STTY so install it with apt-get install coreutils-stty so that it can set the serial port up correctly. On my box that second serial port is /dev/ttyS1.

The program has three parameters: a comma separated list of bus routes, a bus stop number and a 'walking time'. For example, it's possible to do:
lua ambibus.lua 3,12 50906 2
Which means get the times for buses 3 and 12 arriving at stop 50906 (close to No. 10 Downing St.) and allow me two minutes to walk there. The program will find the buses, adjust the times by 2 minutes to allow you to arrive and once a minute update the display with the times of the next two buses.

Next up is a nice case for the display. What better than a London bus. I chose a Plaxton Pointer as it was the right size for LED display to show through the side windows.

If you collect model buses you may want to avert your eyes as I decapitate the bus, gut it, cut out some seats and then put it back together again.

I prised the top off using a screwdriver to reveal the plastic window piece:

Then I removed the windows themselves to reveal the seats:

And then removed the seats to get access to the 'engine' at the back which I removed to make a space for the cable to pass out of the bus.

Then I wired in the display with a small hole cut in the back seats to allow the cable to pass through:

The display was glued in (upside down because of the available clearance: a problem which is fixed in the code) and a few seats cut out to make space.

Then put it all back together and power on the display for a quick test:

And here it is running. The display is capable of showing two buses, but here there was only one bus coming in four minutes:

Wednesday, March 14, 2012

Teaching yourself Morse Code with iPhone's Accessibility options

The iPhone allows the user to create custom vibration patterns, they are considered part of the Accessibility options. (Side note: I've always found accessibility options to be interesting to an able-bodied person like me: there are often customization options there that are very handy).

These custom vibration patterns are created by selecting a contact and then by touching Vibration. You can use them to teach yourself a bit of Morse Code. On my phone I've made custom vibration patterns for people who call me frequently so I can tell without removing the phone from my pocket who's calling.

You make the pattern by tapping or holding on the screen to create short or long bursts of vibration. Here I've tapped out A I R and used it as the custom vibration pattern for Air France.

The other useful iPhone resource for Morse Code learning is this Koch Trainer.

Tuesday, March 13, 2012

Fun with Phenolphthalein

Phenolphthalein is an easily available chemical that is an acid/base indicator that turns purple/pink in the presence of bases. It's commonly used in construction to test whether concrete carbonation has happened and for children's toys to make parts change colour magically when they are sprayed with a special solution.

Another fun thing to do with phenolphthalein and some household chemicals is make disappearing ink: some caustic soda, some phenolphthalein, some ammonia and an acid like lemon juice or clear vinegar.

Note that some of those chemicals are very nasty if you splash them in your eye, inhale them or swallow them. If you do this experiment be careful and protect yourself.

To make disappearing ink you do the following:

1. Take 12g of caustic soda and dilute it in 100ml of water.

Since caustic soda is so nasty do this slowly and carefully and note that it's an exothermic reaction so the water will get hot. Here's my solution reading 50C:

2. Next take 10ml 1% phenolphthalein solution (which is typically dissolved in alcohol) and mix with 90ml of water.

3. Take drops of the caustic soda solution and drop them into the phenolphthalein. It will instantly change colour as the indicator reaction happens. Here's the result of a single drop of the caustic soda solution (top) dropped into the phenolphthalein (bottom).

And here it is with 20 drops of caustic soda.

You now have disappearing 'ink' which you can pour onto a piece of cloth. Here's a big splash of that ink on a piece of white cotton:

About 15 minutes later the ink has disappeared:

What's happened is that the water has reacted with carbon dioxide in the air to form carbonic acid, that in turns reacts with the caustic soda to produce sodium carbonate. The result is that the pH drops and the phenolphthalein returns to transparent.

If you now pour a little ammonia on the cloth the colour will reappear. Another experiment is to take the remaining phenolphthalein solution and add an acid (lemon juice, for example) and see the colour disappear. Add a little caustic soda back and the colour reappears.

PS. If you prefer to make blue 'ink' then use thymolphthalein.

Thursday, March 08, 2012

Home made iPhone scanner stand

Having a need to scan some documents while away from home I went looking for a solution that might make use of my iPhone's camera (and the lovely CamScanner+ app). I quickly came across a project to make one out of cardboard. You can now actually buy that stand but the person who created it won't ship to the UK. Boo hoo.

But they give away the plans for free. And so, after wandering around the streets of London looking for some home construction where I might find a very thick cardboard box being discarded by builders, I set to work printing, gluing and cutting.

Thick cardboard:

Cut out of one piece of the stand:

And with the middle cut out:

There are six pieces to cut out (the two large side pieces), two supports that go on the bottom so it doesn't fall over, the platter where you place the document to be photographed and the platter for the phone.

I made two modifications: since my iPhone has a flash I made the hole at the top a lot bigger so the flash can illuminate the document; I also cut into the sides at the bottom so that A4 (rather than 8.5" by 11") could be accommodated.

Here's the final stand:

And another view:

And, the obvious question is: "does it work?".

Here's a document scanned using ambient light (you'll see some shadows at the bottom and top as I made no effort to position this) with CamScanner+:

There are two shadows and the small mark at the top left is the staple holding the sheets together.

And here's another using the flash:

A bit of playing around with positioning to eliminate shadows and it looks very workable. I'll give it a paint job to make it look a bit more professional before taking it out into the field.