Wednesday 5 August 2015

The Great Taxi Rip-Off

Last night I travelled in a taxi.  Among the table of fares was the following:
First mile £3.00
Each subsequent 146 yards £0.10
I asked the driver how many yards were in a mile  (which I think is not an unreasonable question:  if it's on the sign in his cab, he ought to know),  and he did not know.  Therefore, there is a meaningless disconnect between the figures:  If I don't know how many yards there are in a mile, then I can't know how many 146-yard units there are in a mile, and therefore I can't work out how much I should be paying.

Now, if it had read something like
First kilometre £2.00
Each subsequent 100 metres £0.10
then the correlation between distance travelled and amount paid would have been nice and obvious.  Because there's a clue right in the name that tells you exactly how many metres are in a kilometre.   Even if it was something like "Each subsequent 114.3 metres £0.10", the sum would still be possible -- though I might need a calculator, if  needed better precision than "about 9p for 100 metres".

I am convinced that this is another example of rip-off Britain, if we are actively prevented from working out independently how much we should be paying for a journey and instead have to trust the meter.

Wednesday 22 July 2015

This time, it even looks like Perl!

I said before that my first attempt to get controlling the Raspberry Pi's GPIO pins from Perl looked ugly.  This time, I've added some methods to my JKLMwiringPi package, in an attempt to make the program look more like Perl.

Raspberry Pi Flavoured Shenanigans

The raspberry Pi folks make so much mention of Python that you might think support for other languages might be wanting.

I certainly had difficulty persuading Perl to control the GPIO pins.  I tried using the Perl bindings to WiringPi, but it seems that the underlying WiringPi library has changed since the Perl wrapper stuff was written, and now it either doesn't work, or segfaults.  The actual C library is fine, as I proved to myself during my testing phase; but I'm always a little bit wary of stuff going on fire when I try to program it in C.

I might redo it myself, if nobody else does, but I really wanted to get my Raspberry Pi up and running as quickly as possible.

Fortunately, there's a trick we can use:  Inline::C.  This is a Perl module that does some high-level magic and lets you call functions in a C library as though they were Perl functions.

Here's my version of a "Knight Rider" display using eight LEDs:

Easiest Raspberry Pi fix ever!

I thought I had killed my brand new Raspberry Pi 2, which was showing just a steady power light and that was it -- just like the state the machine is in after typing $ sudo poweroff and before disconnecting the power pack.  The mouse sensor was unlit, and the CAPS LOCK and num lock lights on the keyboard were dead.

However, it turned out to be a false alarm.

I disconnected the Internet, HDMI, keyboard and mouse cables, leaving only the GPIO connections  (which there were a lot of, and I really did not fancy disconnecting them unnecessarily).  Then, on a whim, I decided to try powering it up again -- and this time, I noticed the "disk" activity light flashing, and the lights on the Internet socket also flashed briefly.

Encouraged by this, I tried reconnecting just the keyboard, and noticed the caps lock and num lock lights were working. So I tried logging in blind  (it's not all that difficult, actually; remember that ctrl+U erases everything you typed since the last time you pressed Return, so you don't even have to remember how many times you need to press backspace)  and running my little test program.

And it worked!

So I shut it down cleanly; reconnected the mouse, Internet and TV; and powered it again.  And was back in business, just in time for Pi Day  (22/7)!

Sunday 8 March 2015

Putting Bigger Disks in a Server ..... Without Rebooting

Yes, you read that right.  It really is possible to swap the disks, in a running server, without rebooting.  I know, because I was that soldier.  This is how I did it.

What you will need:
  • A server with one or more RAID-1 arrays.
  • Enough RAM to run without a swap area.
  • Quick-release drive carriers, preferrably including one spare.
  • Enough new drives, preferrably identical, to replace the little ones.
  • Another computer with at least two SATA ports.
  • A USB stick with System Rescue CD installed.
  • The usual tools, spare parts &c.