Wednesday, 27 April 2011

Oxfam Trailwalker 2011 Training Update

Earlier this month I posted about my participation in a team of 4 in the Oxfam Trailwalker 2011 endurance walk challenge on July 16th and 17th. My team, Blood Sweat & Beers will be attempting to walk 100 km (or approximately 62 miles) in under 30 hours (hopefully closer to 24) and are raising funds for Oxfam’s poverty relief work and to support ex-Gurkas.

This post is really just an update so you can see how our training is coming along as we work towards this test of stamina and self-belief.

Despite appearing to be ‘just a long walk’ you should be aware that walks of several hours are very demanding on legs, feet, and joints, and when you stretch this over a 24 hour period and 100 kilometres, this is going to be really tough. Each of us is likely to burn approximately 10,000 kCals, which is about what the average man should consume over a 4 day period.

On the walking front we have had a number of team training walks, which varying combinations of team members have taken part in. We are also doing our own training walks when we can fit them in, as we don’t all live in very close proximity.

The first team walk was in late January, with a modest 5 miles (8 km) around some hilly woods near Henley-on-Thames. That took us 1:53 to complete, including occasional stops here and there.

The second team walk was in early February and was just shy of 11 miles (just under 18 km) around the Ashridge Estate. This walk had a number of testing hills in and took 3:47, including the odd stop for a breather. My heart-rate monitor told me I burnt 1,480 kCals on this walk.

I wasn’t able to attend the third team training walk, but the fourth was in early March and covered the first 10% of the Trailwalker course, just south of Petersfield (6.5 miles or 10.5 km). This took just over 2 hours including stops and I burnt around 800 kCals during this time.

We’re working towards our next team walk, but in the mean time we have been putting in a lot of time walking wherever possible. I’ve done a couple of lengthier walks myself in the mean time. The first one was 14.6 (23.5 km) miles, around the hills south of Wendover, and took me 4:37 to complete, of which 4:06 I spent walking, the rest was stopping for a breather, or checking the map, or climbing over stiles. This walk cost me 2,340 kCals.

The most recent training walk, to the east of Princes Risborough, was a little more substantial at 18.3 miles (29.5 km). This took 5:54, of which 5:12 was spent walking, during which I burnt around 3,400 kCals.


I’ve already plotted out a number of additional routes around my local county area of between 15 and 20 miles and I’ll be walking these over the coming weeks to keep developing my walking strength. I’ll be sure to keep you posted on how it’s all going at a later point.

My training walks without the team have a reasonable pace going, but that’s just to exercise myself on what is a considerably shorter walk than the real event in July. The pace I am setting on these walks is certainly not maintainable by me on longer walks.

Whilst doing these training walks the team have been testing out various things that will be necessary on the Trailwalker. For example, finding which walking socks are comfortable over long distances and don’t appear to be likely to cause blisters. Also working out the size of backpack or rucksack to take the necessary supplies.

Supplies on a walk like this are quite numerous. Granted, there are a number of checkpoints on the main walk, providing toilet facilities, water and occasionally some light food, but for all those miles we need to carry many things along. Obvious things include the route maps/instructions, first aid necessities, blister plasters, sun screen, a compass, water bottles, a phone, a pocket camera, a rain jacket. But also, given the number of calories being burnt off, quite a lot of food is needed to be nibbled and grazed on throughout the hours. Several spare pairs of walking socks are also pretty vital, to give your feet a break every few hours. Also, since half the walk will be at night, a head torch is required. Warmer clothes are also needed, though they can be left in the support vehicle during the day and swapped into at one of the checkpoints.

There’s a lot to take into account with this kind of endurance event over and above just getting to a position where you are able to handle continuous exertion for 24 hours or so.

Last but by no means least is the business of fundraising. The whole purpose behind this challenge event is to raise funds for Oxfam and the ex-Gurkas. The team is entirely reliant on our generous friends and the donations they can make to encourage us to train all the harder and be confident of making it to the finishing line. We’ve already started to receive donations but we have a long way to go before we reach our fundraising target. We’ll really appreciate any amount you can sponsor us with.

Thank you!

Wednesday, 13 April 2011

Delphi 64-bit On The Horizon

When you want to build native Windows applications, Delphi is still a major tour de force in the world of development tools. But currently it can only generate 32-bit executables and so cannot take advantage of all the memory space available when running 64-bit versions of Windows. That will be changing very soon.

Earlier this month David Intersimone posted a 13.5 minute video showing how the pre-release 64-bit Delphi compiler is coming along - you can see it here.

Summary from the video is that most regular Delphi code will simply compile and run. The Delphi RTL (run-time library) and VCL (Visual Component Library) have been updated and reworked internally where appropriate to just work in 64-bit Windows without undue changes to their interface, in much the same way as occurred with Delphi 2 with the move from 16-bit to 32-bit.

Of course things aren’t as simple as that, and there are some key areas where attention must be paid to have smooth transition and have code work in 64-bit but most regular Delphi code will pass through untouched.

In order to get prepared for 64-bit Delphi (or Delphi/64) and to assess your code for areas where attention needs to be paid the slides in the video point out some key gotchas, which I’m listing here to make them easily locatable (much easier to find text on a web page than in a video):

Things that stay the same:

  • Shortint and Byte are still 8 bits.
  • Smallint and Word are still 16 bits.
  • Integer, Longint, Cardinal and LongWord are still 32 bits.
  • Int64 and UInt64 are still 64 bits.
  • UnicodeString, AnsiString, WideString.
  • The Delphi exception system.
  • The RTL (Run-Time Library), e.g. SysUtils, Classes, generics.Collections etc.
  • The VCL (Visual Component Library), e.g. Forms, Graphics, Controls, menus, etc.
  • Windows API

Things that are different:

  • NativeInt and NativeUint are now 64 bits, not 32.
  • Pointer and all pointer types are now 64 bits, not 32. That covers things such as String, AnsiString, WideString, UnicodeString, class instance, class reference, interface reference, procedure pointer, dynamic array, PAnsiChar, PWideChar, PChar. Remember that string variables are really pointers to reference-counted string data.
  • Dynamic arrays now use 64-bit indexing, not 32-bit.
  • Floating point math is done with type Double (the 64-bit float type) – 32-bit floating point math not supported (Single will map to Double).

Things to bear in mind:

  • The Tag property will be NativeInt, meaning you can still cast object instances and other pointers and store them in Tag at runtime. Note that Tag was originally added to allow unique identification of components which share events. Think: case (Sender as TComponent).Tag of ...
  • SizeOf(Pointer) <> SizeOf(Integer)
    • IntegerPointer casts will break in 64-bit
    • SizeOf(THandle) = SizeOf(Pointer)
    • All handles (HWND, HDC, etc.) are pointer-sized, i.e. they will be 64-bit in the 64-bit compiler

  • All code in the process must be 64-bit, including all dependent DLLs
  • There is only one calling convention (register, pascal, cdecl, stdcall will be ignored), although safecall is still handled as a special case
  • Old “pointer math” may break
    • This will work in 32-bit and 64-bit:
      MyPtr := PByte(P) + 10
  • Inline assembly
    • Only procedural level asm blocks are supported – asm blocks cannot be mixed with Pascal code
    • Stack must be 16-byte aligned at each call instruction
    • Define locals for temporary storage
    • Do not modify the RSP stack pointer
    • In the new unified calling convention the first 4 parameters are passed in registers: RCX, RDX, R8 & R9 (or XMM0-XMM3)

  • Exception unwinding
    • Pure Delphi code works as before
    • Inline assembly can cause exception unwinding to fail if not properly written

  • Windows API gotchas
    • SetWindowLong/GetWindowLong should be replaced with SetWindowLongPtr/GetWindowLongPtr for GWLP_HINSTANCE, GWLP_WNDPROC etc, because they return pointers and handles
      • Pointers passed to SetWindowLongPtr should cast to LONG_PTR rather than to Integer/Longint
    • SetWindowLong is mapped to SetWindowLongPtr in Windows.pas
      • calls to this mapped version are safe so long as they are cast correctly
    • Use explicit casts to WPARAM/LPARAM where appropriate
      • E.g. passing pointers through SendMessage:
        SendMessage(hWnd, WM_SETTEXT, 0, LPARAM(@MyCharArray));
    • Use LRESULT to cast message results
      • E.g. Message.Result := LRESULT(Self)
    • Message cracker record definitions (TWMxxx) have changed to accommodate altered alignment and field sizes

Things to do to your code today:

  • Find all IntegerPointer casts (including Integer ↔ instance casts)
  • Check for Pointer size assumptions
  • Ensure external dependencies are available in 64-bit
    • Image/bitmap libraries
    • Hardware interface libraries
    • ActiveX controls

  • Consider rewriting assembler code in pure Pascal
    • This offers better portability (think future ARM CPU support)
    • Rely more on algorithmic performance rather than raw assembly performance

To get a heads-up on some of the issues surrounding 64-bit programming on Windows you read:

Finally, if you are a Delphi XE user you get priority access to the Delphi 64-bit beta. Non-XE users can also get on the beta, but there will be limited places, and XE users will be given priority. More information about the beta program is available here.

Thursday, 7 April 2011

Olde English Criminals

Following on from the post about old English jobs that have faded away, I happened upon a list of terms for old specialist criminals from the eighteenth century, long since disused.

I found them in the 2008 QI Annual that covers the letter E, so all credit to QI for finding these. You can pick up the annual for a modest sum on Amazon.


However I’ve added to QI’s original list of 16 with a bundle of extra ones from The Lexicon of Thieves Cant (based on the 1811 Dictionary of the Vulgar Tongue. A Dictionary of Buckish Slang, University Wit and Pickpocket Eloquence and also Captain Grose's 1785 dictionary).

Criminal name Description
Adam Tiler a pickpocket's associate, who receives the stolen goods, and runs off with them.
Angler pilferer or petty thief who, with a stick having a hook at the end, steals goods out of shop windows, grates etc. Also someone who 'draws in' victims in order to rob them.
Autem Diver pickpocket who operates in churches and temples.
Autem Mort a female beggar who hires children in order to inspire charity.
Bawdy-Basket woman posing as sellers of pins and needles or pornographic books to disguise her real game, which was stealing linen clothes off hedges.
Bene Feaker counterfeiter.
Bene Feaker of Gybes counterfeiter of false passes.
Blue Pigeon thief who steals lead off houses and other buildings.
Bob shoplifter's assistant. One who receives stolen goods.
Bubber a thief who steals from taverns.
Buffer-Nabber professional dog-thief who killed the animal to sell its skin.
Bully-Huff hung round brothels, surprising and threatening the customers by claiming that the woman they were in bed with was their wife. In between times, they intercepted lucky gamblers as they left the casino to relieve them of their winnings.
Bung-Nipper stole the gold buttons from cloaks and the silver tassles from hatbands.
Clank Napper a silver tankard stealer.
Clapperdogeon professional vagabond, a varlet who wore a patched cloak and three hats, one on top of the other.
Dommerer beggar posing as an escaped slave who had had their tongues cut out by the Turks for refusing to accept Islam.
Glimmerer woman who went around in floods of tears claiming that her house had been burned down; alternatively she set other people's houses on fire, in order to loot them in the confusion.
Figure Dancer one who alters the numbers on notes of credit or other paper money.
Footpad a common thief.
Foyst a pickpocket.
Jack in a Box a card-sharp.
Lully Prigger thief who steals wet clothes off clothes lines
Mumper genteel beggar.
Napper of Naps a sheep stealer.
Pad Borrower a horse thief.
Poulterer a man who opens mail and steals the money enclosed within.
Prigger either a member of a three-man shoplifting team or a horse-thief.
Prigger of Prancers a horse thief.
Prigger of Cacklers a henhouse thief.
Rattling Mumper beggar who begs from coaches.
Reader Merchant a pickpocket.
Ruffler armed robber or beggar disguised as an out of work soldiers.
Rum Bob skilled apprentice thief.
Rum-Bubber specialised in stealing silver tankards from taverns.
Rum Diver skilled pickpocket.
Rum-Dubber skilled lock-picker.
Rum File skilled pickpocket.
Rum Padder skilled highwayman.
Swaddler not only stole from their victim but beat them up as well, sometimes murdering them into the bargain.
Swig-Man covered their roguery by pretending to be an itinerant haberdasher.
Strowler con man who convinced country gentlemen to 'lend' him money so he could go to London.
Tatmonger card-sharp.
Tayle drawer a thief who steals swords from a mans belt.
Wiper drawer a thief who steals handkerchiefs.

Olde English Jobs

I like reading about the English language. It fascinates me.

The grammar rules and syntax interest me, as does the way words fade in and out of the language and morph from form to form along their useful lives.

I was happy to recently bump into a colleague from University who I’d lost track of, all the more as he seems to have collected a lot of interesting language-related links and posts on his site.

In a recent local town council magazine Keith Turner & Daniel Parslow provided a good catalogue of old job titles that used to be common in market towns such as Aylesbury, where I live, that have fallen into disuse over the years.

All credit to Keith and Daniel for this list, which I am typing up to make more widely available.

Job title Description
Abigail Lady's maid
Ale-conner Official who tested the quality and measures served in pubs
Ankle beater Young person who helped drive cattle to market
Boot catcher Servant at an inn that removed travellers’ boots
Bozzler Parish Constable
Bridewell Keeper In charge of the lock-up or jail
Bunter Female rag and bone collector
Bog Iron Hunter Searched for Iron Ore in bogs and marshes
Cartomancer Fortune teller using cards
Chapeler Hat maker
Costermonger Peddler of fruits & vegetables
Clapman Town crier
Clod hopper Ploughman
Donkey Man Passenger carriage driver
Eyer Made holes in sewing needles
Feather wife Woman that cleans feathers for sale
Fagetter Firewood seller
Flauner Confectioner
Frobisher Cleaned and polished metal
Gabeler Tax collector
Gelder Animal castrator
Gong Farmer Emptied privies and cesspits
Greensmith Worker in copper
Hobbler Towed canal boats
Jongleur Travelling minstrel
Knocker Upper Woke people up
Knock Knobbler Dog catcher
Layer Paper mill worker
Leech collector Waded through rivers to collect the leeches which attached to him
Lungs Alchemist's assistant who fanned the fire
Mud lark River bed scavenger
Mule Scavenger Children who would crawl under fabric mills to collect cotton and fluff
Mountebank Seller of fake medicines
Night Soilman Emptied cesspits, ashpits and outside toilets
Nob Thatcher Wig maker
Osler Bird catcher
Ponderator Weights & measures inspector
Powder monkey Boys who supplied ship cannons with gunpowder below deck
Quarrel Picker Glazier
Ratoner Rat catcher
Resurrection Man Provided surgeons with fresh cadavers with which to learn their craft
Rodman Surveyor's assistant
Saltpetre man Collected urine and dung used in the manufacture of saltpetre
Searcher of the Dead Sought plague victims
Secret Springer Watch spring maker
Sexton Church caretaker - sometimes dug graves and rang the church bells
Smoke Doctor Specialist in the construction or repair of chimneys
Tapster Barman/woman
Town Husband Collected dues from the fathers of illegitimate children of the parish for their upkeep
Treadmill Operator Trudged atop a giant mill wheel treadmill to push it round
Upright Worker Chimney Sweep
Vamper Made the upper part of a boot or shoe covering the instep and sometimes extending over the toe
Webster Operator of looms
Yatman Gatekeeper

Wednesday, 6 April 2011

Parallel Programming Patterns

In a blog post I read this evening there was a reference to this handy PDF guide to Patterns for Parallel Programming, illustrating how .NET 4 parallel programming support and contrasting with how the same patterns are implemented without this new support.

The guide is written by Stephen Toub, a Microsoft Program Manager Lead on the Parallel Computing Team at Microsoft.

You can download the guide from Microsoft in either a C# version or a VB version.

Mono for Android 1.0 & MonoTouch 4.0 released

Today Novell released Mono for Android 1.0 and MonoTouch 4.0 (blog posts from Miguel de Icaza detailing the releases can be found here for Mono for Android and here for MonoTouch).
I’ve used MonoTouch quite a lot, hence the rather detailed tutorial I released, which was detailed here.
I’ve also been spending quite some time getting up to speed with Mono for Android. Indeed in February, I gave a talk on building apps with Mono for Android (or MonoDroid as it was referred to back then) in conjunction with Delphi Prism at a conference in Las Vegas. Also, today I spoke at a User Group meeting about building an Android app in C# using Mono for Android.
Over the next few weeks I’ll be working on a tutorial that shows the use of Mono for Android with C# and will post when it becomes available.
In addition, I’ve kept notes of various interesting things, such as issues, gotchas, solutions to problems I’ve encountered and so on. As I write up the tutorial I’ll be posting some of those tidbits as and when they crop up in the coverage.
One thing I learned today from Miguel’s release blog post, though, is that when you build an app for distribution the Mono linker is engaged. This generates a single binary containing only the items known to be used (and their dependencies) – everything else is stripped out. Smart linking in other words.
This is in contrast to how things work during development where you link against a shared runtime that is deployed to your emulator or device. The idea during development is that the executable generated will be smaller, thanks to linking against a shared runtime (well, two shared runtimes actually – there’s the main Mono runtime and a much smaller runtime specific to the version of Android you are targeting). With a smaller executable it takes less time to build and deploy to the emulator or device.
With a single executable generated for distribution this simplifies the question of how these separate entities are to be managed.

Update: This is an old post, and it should be noted that the current versions (at the time of writing this update in Jan 2012) are Mono for Android 4.0 and MonoTouch 5.0.

Sunday, 3 April 2011

Endurance Walk

I’m part of a team of 4 people who are currently training for an endurance walk on July 16th and 17th, 2011. Of course, we’ve probably all gone for long walks every now and again but this is something a little different to a regular long walk. This is a walk across England’s South Downs that will continue for 100 kilometres (or 62 miles) and it is going to be done in a one go, without any breaks for sneaky restorative naps.

The team is called Blood, Sweat and Beers and consists of Jim, Elaine, Gordon and myself. The endurance walk is organised by Oxfam and is raising money for Oxfam and for the Gurkha Welfare Trust in an event called Trailwalker UK 2011. There will be 550 teams doing the event and around 80% of the teams are expected to complete the full 100 kilometres.

Rest assured this is a real test of both physical endurance as well as mental fitness. Having heard from people who have previously entered the event, it is gruelling, painful, testing and punishing, but also rewarding and of course a massive personal challenge. It has been described as an ultra-marathon. Team Blood, Sweat and Beers are hoping to complete the challenge in under 25 hours.

As a team we are looking for sponsors to help bolster our motivation and training and to incentivise us to push ourselves to our maximum ability. Funds raised will be used by the Gurkha Welfare Trust to help reduce poverty for ex-Gurkhas and dependents and by Oxfam for their invaluable work in emergency relief in poverty-stricken areas around the world. Anything donated will be appreciated equally by Oxfam and the GWT, as well as by Team Blood Sweat & Beers.

Any donations by UK tax payers are eligible for Gift Aid, which immediately adds an extra 25% to the donation at no extra cost to yourself – it’s reclaimed from HMRC. Please agree to Gift Aid when asked.

The team has already completed a number of training walks, with the distances increasing as time goes by. We have a training plan and things are going well so far, but we need to raise £1500 in sponsorships to help us through the event.

For any donations you can offer, Team Blood Sweat & Beers appreciate your generosity and thoughtfulness.

Please visit the team page and make your donation now!.

Google Maps Data Files

The My Maps feature in Google Maps is really handy for planning out a quick route or just seeing how far it is from one place to another. You can also drop on various place markers, add text to them and also add photos as I’ve done, for example, with my City of London Boundary dragons map.

As well as storing all the maps in the My Maps section of Google Maps you can also download any of them as a .kml file, which contains XML describing the map features, waypoints, etc. in the Keyhole Markup Language. The download option is available when you are editing a map and is accessed via the option View in Google Earth, which becomes available on the toolbar on the right as soon as you start editing. Clicking the option downloads a KML file.

The problem is that the .kml file doesn’t really have much data in it. It has the name and the description of the map, and the name and description of any map lines but the map data is not downloaded in the file. Instead it is left in Google Maps and the .kml file contains the URL to the map data in a <link> node.

While this abbreviated, deferred content is quite suitable for Google Earth’s consumption, if you were hoping to upload the map to some other mapping application the chances are it won’t get you very far. Typically, mapping applications expect to find the data in the .kml file.

Fortunately we can resolve this little issue by looking at the URL that Google My Maps offers for downloading the .kml file in the first place. Let’s take a look at the links available, using that Boundary Dragon map as an example.

Firstly, looking at the link offered to you if you ignore the Google Earth viewing option, but just click the Link option on the toolbar. The link it offers to paste into IM or email looks like this (with various bits of not-strictly-necessary junk taken out, for brevity):

Now let’s compare with what link is executed when you click on the View in Google Earth toolbar option (again, sanitised for easy viewing):

As you can see, there’s an extra value added into the link specifying that the Google Maps server should output a file containing a network link (which appears to be what NL stands for). If you now look at the link contained in the .kml file it looks (after cleaning up) like this:

If you paste this link into your browser’s address bar it will download another .kml file with full data inside it.

So, the answer is to take the original URL in the View in Google Earth hyperlink and replace the =nl with =kml. Easy.

Alas this does not work if you try and use =gpx – Google Maps is not interested in supporting the GPX format, commonly used by many mapping sites, however Google Earth is happy enough to load up GPX files.