Tuesday, December 8, 2015

Ada Lovelace, Charles Babbage and the First Computer Program

The 10th of December 2015 will be the 200th Anniversary of the birth of Ada Lovelace.

In 1842, in Italy, Charles Babbage gave his only public lecture on The Analytical Engine. The lecture was transcribed, in French, by an Italian military engineer. Ada translated the transcript into English, and subsequently Babbage suggested she add her own commentary on the transcript.

This she did, and in 1843 she published the translation of the lecture, along with a copious set of her own notes (that were twice as long as the translation of the lecture). In one of these notes is a diagram that is considered to be the earliest published computer program.

I was intrigued as to what this program looked like, and how we could run it today. So I explored this in the following three articles:

Part 1: Starting with the diagram, I wrote my own version of the algorithm in a modern programming language (Python). Then I wrote a transliteration of the diagram (also in Python) that could be run directly, and produced an "assembly language" listing that corresponds to the cards that would be used to program the Analytical Engine (if it had been built).

Part 2: I wrote an emulator for the Analytical Engine, which could run the assembly language program produced in Part 1.

Part 3: I code up an assembler that reads a mnemonic format corresponding directly to the diagram in Ada's note and produces the appropriate sequence of cards needed to program the Analytical Engine Emulator from Part 2. Finally we produce a program that corresponds directly to Ada's diagram and runs on the Analytical Engine Emulator.

The end result is an emulator for the Analytical Engine in Python that lets you run Ada's program to generate Bernoulli Numbers, or you can write your own programs for it.


Thursday, October 22, 2015

Downgrading a Package in MacPorts

MacPorts installed a new version of XEmacs and it broke things. So instead of fixing it I just went back to the previous version.

Here's how I did it:

  1. Create a local repository in ~/lib/macports/local:

    % mkdir ~/lib/macports/local

  2. Add the local repository to /opt/local/etc/macports/sources.conf:

    file:///Users/jim/lib/macports/local

  3. Find the previous revision of XEmacs:

    % svn log http://svn.macports.org/repository/macports/trunk/dports/editors/xemacs

    It's r141410.

  4. Check it out (into ~/lib/macports/local):

    % svn co --revision r141410 http://svn.macports.org/repository/macports/trunk/dports/editors/xemacs/ editors/xemacs/

  5. Run portindex on the local repository:

    % portindex ~/lib/macports/local

    It should report: "Ports successfully parsed: 1"

  6. Now port list xemacs shows both versions.

    xemacs  @21.4.22  editors/xemacs
    xemacs  @21.5.16  editors/xemacs


  7. Install the local version

    # port install xemacs @21.4.22

That's it.

Tuesday, December 16, 2014

Cabin Pressure Advent Calendar

Inspired by this site, I've been listening to an episode of Cabin Pressure every day since 28th November, so that I'm ready for the final episode ("Z├╝rich") to be broadcast in two parts on 23rd and 24th December (6:30pm, BBC Radio 4).

Of course there are many brilliant lines in each episode, but here are my particular favourites (to be updated each day):

Abu Dhabi

Douglas: Again, I fear you flatter my knowledge of cat pathology.

Boston

Martin: Where's Carolyn?
Douglas: Sharpening her teeth.
Arthur: Brushing.
Douglas: Brushing her teeth. Yes, sorry.
or:
Arthur: I didn’t know you for very long, Mr. Leeman, but I'll always remember you as ... as a shouty man. You loved to shout; shout and smoke – those were your twin passions. And so, in a way, I suppose you died doing what you loved: shouting and smoking, and covered in foam. I don't know if you liked that. You probably didn’t. 

Cremona

Arthur: The thing is, is it unprofessional to tell a passenger that you once made a collage of her face out of pasta shapes?
Douglas: Hmm, I really don’t know.
Arthur: You see, part of me thinks ...
Douglas: Oh, I’m sorry. Did I say "know"? I meant "care". I don’t really care.

Douz

Martin: Right. Well, I've made my point anyway.
Jutteau: You've made it. I 'ave disagreed with it. I'm going to do nothing about it.

Edinburgh

Birling: (To the tune of "Cwm Rhondda") Bread of heaven, bread of heaven, yum yum-yum-yum-yum-yum-yum! Bread of heaven, here I come!

Fitton

Martin: Well, we can sit in the plane, or we can sit in the rain.
Douglas: Can't we sit in the car or sit in a bar?
Martin: Douglas.
Douglas: I'm sorry, I thought we were staging an impromptu tribute to Dr. Seuss.

Gdansk

Carolyn: This is my son Arthur, and I promise you he couldn't hurt a fly...
Arthur: Thanks Mum!
Carolyn: ... because the fly would outwit him.

Helsinki

Carolyn: Oh, my goodness! Well, you certainly have surprised me with a cake.
Douglas: Thought we might.
Carolyn: Perhaps what's most surprising about it is that it's a fishcake.

Ipswich

Martin: I've had one. One is the correct dosage of quiche for the adult human male.

Johannesburg

Douglas: Carolyn, you're really not helping.
Carolyn: I know! I'm not trying to. 

Kuala Lumpur

Carolyn: (Pretending to be a passenger) It means I'm gluten-intolerant.
Arthur: Well, I'll, I'll try not to be too gluten annoying.

Limerick

Martin: Is this the famous Admiral's pie?
Arthur: Yep.
Douglas: The admiral's not a fussy eater, is he?

Molokai

Douglas: You took my Petrus '05, and you ... mulled it?

Newcastle

Martin: (cabin address) So, we should be taking off in ... about an hour.
Carolyn: (shouting from the cabin) Martin! What have you done now?
Martin: (cabin address) So sorry about the delay – which is not, incidentally, because of anything I've done now.

Ottery St Mary

Arthur: Well, I was the one who thought of putting an otter in the fridge!

Paris

Arthur: Can I tell you in my own words?
Douglas: Who else's words had you planned to use? Winston Churchill's?

Qikiqtarjuak

Arthur: Bears! Bears, bears, bears, bears! Polar bears! Look! On the ground.
Douglas: Of all places!

Rotterdam

Douglas: I'm not being childish, but if I can't go to the Grand Prix I'm not being in the film.

St Petersburg

Arthur: Here you are, Skip. Nice hot cup of coffee.
Martin: Oh. (takes a sip) Ugh! It's cold!
Arthur: Nice cup of coffee.
Martin: It's horrible!
Arthur: Cup of coffee.
Martin: I'm not even sure it is coffee.
Arthur: Cup. 

Timbuktu

Douglas: It's been a topsy-turvy sort of Birling Day, hasn't it? We flew away from the rugby; Mr. Birling got soberer and soberer; and Arthur ruined everything with his knowledge and erudition.

Uskerty

Arthur: You know, between the dames and the horses, sometimes I don't even know why I put my hat on.

Vaduz

Herc: I didn't realise you were in such thrall to royalty.
Carolyn: I don't give two hoots for royalty!
Herc: I think you give four or five hoots.
Carolyn: I do not.
Herc: And not just any old hoots: low and reverent hoots, like an owl at a Jubilee.

Wokingham

Arthur: I've brought Boggle, Guess Who?, Connect Four and Kerplunk.
Wendy: Are they ... rappers?

Xinzhou

Arthur: It's not "Have a banana", it's "'ave a banana!" - like the song!
Carolyn: What song?
Arthur: The "'ave a banana!" song. I don't really know it, except for one bit.
Douglas: (sings) Let's all go down the Strand.
Arthur: Are you alright, Douglas?

Yverdon-Les-Bains

Martin: ... but it's not brilliant for anyone else, is it?
Arthur: Oh, don't say that, Skip. The Swiss guys'll get used to you!
or:
Martin: I'm like a capsized duck. 

Zurich (Part 1)

Theresa: Was that the time Martin landed with one engine?
Carolyn: That's right.
Theresa: Yes, he's often told me that story.
Martin: Not that often.
Theresa: Quite often.

Zurich (Part 2)

Arthur: Don't worry Skip - Douglas always saves us. Like remembering the brake pads.
Martin: That was me!
Arthur: Well, yeah, but you were being Douglas. 


OK. Bye.

Friday, June 20, 2014

Raspberry Pi Time Machine

Backup is a good thing. And anything that makes making backups simpler is also a good thing. That's why I like Apple's Time Machine. But my 5 year old, 500GB Time Capsule is running a bit short on space, backing up two Macs.

So, I was thinking of upgrading to a funky new 5th generation Time Capsule, with 2 or 3TB of hard disk on-board. It's got exciting new technologies like "beamforming" and 802.11ac. It even looks like a TARDIS (with a white paint job).

But those probably won't make any difference to my existing kit, and the WiFi base station part of my current Time Capsule works fine. So, I thought, why not just hang a 2TB USB HDD of the Raspberry Pi and back-up to that?

Fortunately someone else had already had the same idea and written down how to set up the Raspberry Pi as a remote server for Time Machine, so I just followed that. And it works fine.

Bear in mind that neither the networking or USB on the Raspberry Pi is superfast, but neither was the external HDD I added to it. (Use a disk with a separate power supply). And the backups happen in the background anyway, so speed isn't really that much of an issue.

Note: I have since bought a Synology DiskStation so now I do my back-ups to that rather than using the Raspberry Pi.

Wednesday, June 11, 2014

Numbers and Letters

Inspired by this week's Only Connect, I thought I'd make a list of letters and the smallest number they appear in when written in English, starting from one (or zero):

A: one hundred and one (or one thousand, if you don't like using "and")
B: one billion
C: one octillion
D: one hundred
E: one (or zero)
F: four
G: eight
H: three
I: five
J: never happens
K: never happens
L: eleven
M: one million
N: one
O: one (or zero)
P: one septillion
Q: one quadrillion
R: three (or zero)
S: six
T: two
U: four
V: five
W: two
X: six
Y: twenty
Z: never happens, unless you get to "one zillion" (or zero)

Tuesday, April 15, 2014

How Do I Tell If My Bank Is Affected By HeartBleed?

Consider the following two scenarios:

Scenario 1:

You walk into a bank with a £10 note.

You: Can you change this £10 note for me?
Bank: Certainly, Sir. How would you like it?
You: Ten £1 coins please.
Bank: Certainly. There you go. Thank you.

You walk out of the bank with £10.

This is normal behaviour for a bank.



Scenario 2:

You walk into a bank with a £1 coin.

You: Can you change this £1 coin for me?
Bank: Certainly, Sir. How would you like it?
You: Erm.... Sixty-five thousand, five hundred and thirty five £1 coins please.
Bank: Certainly. There you go. Thank you.

You walk out of the bank with £65,535.

If this happens the bank has a bug in it.


Wednesday, August 21, 2013

A Grand Few Days Out

Gromit 5 ("Golden Gromit")
Gromit Unleashed
Although I don't live in Bristol any more I am back there every now and then, and this summer Bristol is home to 80 Gromit Statues as part of Gromit Unleashed.

Like Wow! Gorillas back in 2011 I've been steadily collecting photos of the Gromits on my visits to Bristol (assisted by my Dahon Speed P8).

Visit my Facebook Album to see my progress. Or view the iCloud photo stream.

So far I've photographed 68 out of 80, and I've got a couple of weeks to try and get the remaining ones, although I'll probably only manage to get 7 or 8 of them as the rest are too out of the way for casual visitors. (One of them is in Paddington Station in London!)

But they will all be in Bristol at the RWA from 18th to 22nd September for one final showing before being auctioned off, so there's a chance to mop up any stragglers.

Update 4th September 2013: I've collected 76 out of 80. The ones I have left are:

  • #77 "Bristol Bulldog", Bristol Airport, Lulsgate Bottom.
  • #78 "The Secret Garden", Lye Cross Farm, Lye Cross.
  • #79 "aMazing Gromit", Cheddar Gorge, Cheddar.
  • #80 "Gromit", Paddington Station, London.
None of which are conveniently located to be collected in the next few days, so I'll see them at the RWA, or not at all.