« May 2006 | Main | July 2006 »
June 30, 2006
Tk - laying out your GUI with frames, pack and grid
Using Tk (in Tcl or in Perl), you create a number of components that you want to display as part of your GUI (Graphic User Interface) using commands such as button, label and canvas. These components are known as widgets.
Once you've created your widgets, you need to use a geometry manager to tell the program how to display them in relation to each other - and there are three such geometry managers.
pack allows you to place your widgets in a row or column
grid allows you to place your widgets in a matrix
place is rarely used, and gives you the ability to place widgets by pixel or by the proportion of the way across the window that you want them to appear.
Pack, grid and place don't on their own provide you with the full flexibility to lay out more complex windows. For a complex layout, you'll split the parent window into a series of frames which you will pack or grid, and then you'll pack or grid the individual widgets into the frames. If necessary, you can nest frames several layers deep.
If you're a designer laying out your GUI, where should you start? With a sketch on a sheet of paper (or a whiteboard). Look to see if the WHOLE layout can be achieved by using a single pack or grid ... if not, look for places where you can draw a line between widgets RIGHT ACROSS the window. These lines are the first level of splitting you GUI down into frames.
If you can draw lines RIGHT ACROSS, both horizontally and vertically, then you'll use the grid geometry manager for your root window. If you can draw ONLY horizontal or vertical lines, then you'll use pack.
Repeat the design process, frames within frames, until each of your remaining subframes is a simple grid or pack in its own right, or is a single widget.
Posted by gje at 06:37 AM | Comments (0)
More about Graham Ellis of Well House ConsultantsJune 29, 2006
First Light, Bootle Docks, Liverpool



Posted by gje at 04:20 PM | Comments (0)
Running external processes in Tcl and Tcl/Tk
If you want to run external processes from a Tcl based program (Tcl, Tcl/Tk, expect), there are various ways of doing it.
Firstly, the whole purpose of the Expect extension is to allow you to control other processes via its three major commands of spawn which starts another process, send which sends characters to that other process, and expect which causes your program to wait until it gets a particular response, or one of a series of possible responses.
If you don't need to go to these lengths, though, there are three other options at least.
You can use an exec command to run an external process and capture the result returned in a variable:
set ff [exec ls]
puts $ff
You can use the open command and open a process by preceeding it with a "pipe" character in place of its default behaviour which would be to open a file. This lets you handle a process that generates a lot of output line by line, and by using r+, w+ modes and flush you can also set it up for both read and write. Here's a simple example of opening a piped process for read:
set fh [open |df r]
while {[gets $fh line] >= 0} {
puts $line
}
Finally, you can talk to a remote process via the network, using socket to open a remote connection. Like the open command, the socket command opens a channel so once the channel is set up you can handle the data stream exactly as if it was a file or pipe. Again, don't forget flush. Example (getting a file off a web server):
# Through a socket - a remote process
set fh [socket 192.168.200.66 80]
puts $fh "GET /index.html HTTP/1.0\n"
flush $fh
while {[gets $fh line] >= 0} {
puts $line
}
Posted by gje at 11:06 AM | Comments (0)
Useful link: Tcl training
June 28, 2006
Which way to turn?
Do concrete mixers turn clockwise or anticlockwise? As I drove back to my hotel last night, I passed a line of three such vehicles, barrels zebra striped and clearly showing they were in action. And two turning one way, and one the other.
Perhaps two were mixing, and one was separating the ingredients?
Posted by gje at 08:39 AM | Comments (0)
Good follow up ... my thanks
My grateful thanks to our local police inspector for going well beyond the call of duty in explaining some of the law and the Wiltshire police policy in applying it with regard to the incident I reported here the other week. I've added an update quoting many of his words.
I appreciate that the police have an important safety role to play in preventing people from driving if they have been drinking, and that they have been given a legal right to stop and talk to any motorist on the road without needing to have any suspicion. But I can tell you that the manner in which they exercised their powers, even after they knew that I hadn't been drinking, may have been legal but did no good to police relations. Nor did it help save a single accident, injury or worse. Of course, you can't make an omelette without breaking eggs ...
Posted by gje at 07:23 AM | Comments (0)
Converting between Hex and Decimal in Tcl
Tcl is much used in the semiconductor industry, so there's a common requirement to use it to convert values back and forth between hexadecimal (base 16) and decimal (base 10).
Easily done! The format command can be used to convert from decimal to hexadecimal, and the expr command can be used to convert in the opposite direction ... Let's see an example:
set initial 157
# Decimal to hex using format
set inhex [format %x $initial]
# Hex to decimal using expr
set back_in_decimal [expr 0x$inhex]
# checking the results
puts "$initial ... $inhex ... $back_in_decimal"
When I run that, I get ...
157 ... 9d ... 157
Posted by gje at 12:12 AM | Comments (0)
Useful link: Tcl training
June 27, 2006
Tcl - lappend v concat
In Tcl, you can use the lappend command to add items on to a list, but it doesn't always do exactly what you wish it to. Let's say that I've got two lists - the first containing the early courses of a meal, and the second containing the latter courses. If I append the second list to the first, the second list gets added AS A SINGLE LIST ITEM to the first list ... in the following example, adding the list "also" with two items in it (Fruit and Coffee") to the list "lunch" with two items (Soup and Salad) results in a list of just three items - Soup, Salad and {Fruit Coffee} rather than the four I would have hoped for.
If you want to add each item in the second list on to the end of the first list, you can use the concat command instead of the lappend command. In the following example, concat produces a 4 item list - Soup, Salad, Fruit and Coffee.
set lunch "Soup Salad"
set also "Fruit Coffee"
set first $lunch
lappend first $also
set second $lunch
set rst [concat $second $also]
puts $first
puts $rst
When I runs that ... what do I get?
earth-wind-and-fire:~/jun06 grahamellis$ tclsh ccat
Soup Salad {Fruit Coffee}
Soup Salad Fruit Coffee
earth-wind-and-fire:~/jun06 grahamellis$
Posted by gje at 06:34 PM | Comments (0)
Useful link: Tcl training
Separation and Integration
With the smoking ban in enclosed public places here in Ireland now being old news, things have settled down to the new way, and you'll find two communities at pubs like the one that's attached to the Plaza Hotel in Tallaght where I'm staying this week. A deep break as you walk toward the pub from the outside and pass through the outside community, then in to the clean air of the bar. They say that contrary to expectations, in many ways business has improved with the sensitive non-smokers coming back to the pubs, and the smokers now with much more of a sense of community.
There's other areas of the hotel, too, that seem to be "club corners"; I was in 'Network World' this morning, where everyone takes their laptops to get on line. The hotels "Internet access available" on their web site has turned out to mean that they've got an Eircom hotspot in reception ... not that it's available in any of the rooms. Once you've worked the system out, it seems to work well enough and I'm delighted that a 7 day signup is just 30 Euros - none of that crazy "shall I sign up for 30 minutes at 3 pounds or 2 hours at 5 pounds" at the Travel Inns. Prices are getting reasonable ...
The "Olive Tree" restaurant is taken over by the coach parties ("if it's Tuesday it must be Dublin") and we're had German, Belgian and English coaches so far. There's a truely cosmopolitain look to the city too. Sunday night, Lisa and I (British) ate in this country (Ireland) at an American Diner. The waitress was from Poland and the cooks were Chinese. And it was a great diner too - I can understand why they were queueing for tables out the door.
Posted by gje at 08:27 AM | Comments (0)
June 26, 2006
The fragility of pancakes - and better structures
Have you ever hunted around a directory for a file ... you KNOW it's there, but you can't find it - can't see the wood for the trees, if you like, in a listing that spills over many pages?
I call such directory structures "pancakes" as they're thin and flat, and they tend not to be very easy to work with as they grow and grow. It's usually best to avoid a pancake if you can - either set up a directory structure if you require ad-hoc access to all the various different data pieces, or use a database such as MySQL to hold the data ... this is the technique we're using for images in our database, as described in the current edition of "Of Course".
The Authors of Tcl had an issue with a pancake of commands that could have been provided in the language, so that came us with a hierarchy of commands and subcommands. Within a top level around a hundred top level commands, you'll find commands that have subcommand in particular areas such as
string - most commands to do with string handling
file - most commands to do with file handling
array - all commands to do with array handling
clock - all commands to do with time handling
info - commands that provide information
Posted by gje at 06:09 PM | Comments (0)
Weekend in Ireland
Greetings from Ireland ... it feels almost like a regular trip, arriving at first light
on the boat at Dublin Docks.
This weekend's been a little different; rather that head all the way back from Liverpool to home late into Friday evening, just to set off again during Sunday (and perhaps via Liverpool!) for Dublin, I've followed on one course from the other. Lisa flew over on the Ryanair flight from Bristol on Saturday morning, and left again this morning - I dropped her off at the airport soon after 5; quiet roads yet a jam at departures as all of the weekly commuters from Dublin leave to work elsewhere in Europe.
Saturday, we toured a little, and Sunday was given over mainly to a series of work meetings; I won't bore with the latter, but I will show you a couple of pictures of the former.
Mellifont Abbey was an early Cistercian monastery in Ireland, founded in the 11th Century and dissolved by King Henry VIII. In those days, the monasteries had become very much one of the major powers of the land like, perhaps, we're seeing in other parts of the word today. Looking at maps showing such establishments in the British Isles, I was struck by the far greater concentration of them in Ireland that in the other parts of the islands, and indeed it does feel that there's an ancient ruin at every turn at times.
Trim Castle, overlooking the river Boyne. Yet another ancient ruin, and I fear that (after the others I have not pictured) its spectacular setting was rather lost on us in the grey day and the weather which is described here as a "soft" day. I understand that means that it's not really raining, more a mist, but you still get drenched and freezing. As Lisa commented, it was very different and a long way from the sunny morning she had left at Bristol. And she declined an invite for me to drive her on to Tipperary, citing that it would be a long way.
Posted by gje at 07:33 AM | Comments (0)
June 25, 2006
On Crosby sands
On Friday, I finished in Liverpool city centre at 17:00 and had a boat due to depart to Dublin at 22:00 from Bootle Docks just five miles up the road. This left me with time to look around at Crosby and Blundellsands, near the mouth of the Mersey. An old, quiet, clearly very affluent suburb of Liverpool with huge houses dating from a few years before and after the Great War, probably built as the residences of the managers who worked at such places as the Royal Liver and Cunard buildings I've pictured here in the last few days.
Signs pointed to parking for Anton Gormley's Other Place, and I wondered if I was going to see the 100 or so "statues on the beach" that one of my trainees had mentioned at Crosby. Curiously, though, the signs petered out towards the beach and I stopped a couple of times at a quiet park, and beside a boating lake and walked around in the immediate vicinity for a few minutes. The dog-walkers and joggers were all out on a pleasant evening; the beach was a good few hundred yards away - in these flat parts there's such a gentle shelf from town to sea that there's an interim of lagoons and sandhills much of the way.
Heading North again, expecting to leave Crosby, I found yet more signs to Anton Gormley's other place and , following, was directed right up into the top, beachside corner of the town where the signs petered again. Ah well .. I pulled into what looked like a regular seafront car park. With the traditional chip van and Ice cream van.
Families parked up; the more mature folks sitting in their cars watching the dipping sun, the boats coming in and out, and the other activities. The people of about our age taking a gentle walk on the front. Younger still, joggers and cyclers, and kids on the beach playing with balls and making sandcastles.
And, now that I look carefully, odd people just standing out there on the beach gazing to sea. Motionless. Scattered over the sands. And I come to realise ... these are the statues on the beach that I had been told about. One hundred life size casts of the artist, all facing out to sea and spread across the sands ... accepted as part of the natural life of the place by the locals, enjoying their beach that evening amongst the work.
As the tide came in, the sun dropped towards the horizon and the light became lower, the figures disappeared into the sea. A head sticking up there, a complete torso visible off to the left and what looked like a paddling figure a short distance to my right.
Anton Gormley is the creator of Gateshead's famous "Angel of the North", and his "Other Place" work will remain on display in Crosby until November, when it will be moved to a new location.
Container boats, ferries, high speed cats passed by, and in due course it was time for me to head down to the docks and my own ship ... the "Norbay" bound for Dublin, from where I'm posting today.

Posted by gje at 03:19 PM | Comments (0)
June 24, 2006
Naming Rooms
What should we number or name the two rooms that we'll have available for training, meetings, conferences as Well House Manor? Normally, I'm not a great fan of names (and indeed bedrooms will be numbered), but somehow "A" and "B" or "1" and "2" don't seem right, and "the training room" and "the meeting room" could be confusing on days when we've a small class in the meeting room, and a big meeting in the training room. The "Python" and "Perl" rooms would have similar issues.
Hansel and Gretel
Willow and Chestnut
Large and Small
Peaches and Cream.
Hmm ...
Victoria and Edward. A certain temptation - the Manor was built in Edwardian times to Victorian high standards. But which room is which? And we're not going to be doing Victorian decor in either of them.
Salisbury and Bath. I like local places, but would have trouble keeping a straight face when telling customers that their Python course is in the Bath room. But other possibilities such as Avebury and Silbury, or Lacock and Corsham, would be practical and more local too.
The local railway was known as the Wilts and Dorset when built, and the canal that's just to the South of Melksham is the Kennet and Avon named itself after two rivers. Even closer to hand, a hundred yards from our door the road rises up to cross over the old Wilts and Berks canal, which was abandoned less that 10 years after Well House Manor was built. There's a temptation to have the "Wilts" room and the "Berks" room.
I'm also tempted by local dignitaries ... I know that Brunel visited the town when building the Great Western Railway, and I suspect (and can check) that the Canal was engineered by Dadford or Rennie. Yet everything that moves is named after Brunel around these parts - at least that's sometimes how it feels. Choosing more recent people names might lead to controversey, or to room names that seem up-to-date today, but peculiar in a few years time. I'm reminded in this respect of an older part of Chippenham that's called "New Road".
Posted by gje at 07:56 AM | Comments (0)
June 23, 2006
Do not duplicate your code
If you've writing or maintaining a program and you find yourself cutting and pasting a chunk of code, STOP and think again.
By duplicating a block of code, you're duplicating your maintainance task from that point onwards - any fixes applied to the original much be applied to the copy too. And that's going to be very inefficient in time as you duplicate the duplicate and end up with a whole shed load of copies. There IS a better way!
Take the code that you would be duplicating, and put it somewhere separate. Give it a name (i.e. make it a named block of code) and call it up by name from both its original location, and from the location that you would have put the copy into. All modern languages support named blocks of code in this way:
• In Perl, they're known as subs which is short for subroutines
• In many other languages, they're known as functions or methods or macros
• In Tcl, they're known as procs which is short for procedures
"But I want to make a couple of changes to the block of code that I was going to duplicate" you might say. That's NOT a problem. The bits that you would change in the duplicated code are the bits that you'll pass in to your sub / function / method / procedure as parameters, and if you also change the variable that the result is going to be put into, that's the immediate clue as to what you'll be returning.
Where you want to share a named block of code between several programs, you can do so too. That's done through commands / calls such as import (Python, Java), source (Tcl), require (Perl, PHP), use (Perl), from (Python) and include (PHP). In C and C++, functions work across programs in a slightly different way - rather than including the reference in the source, you'll bring in prototypes in the source and then the full code in your link loader. But that's a story for another day ...
Posted by gje at 07:13 AM | Comments (0)
June 22, 2006
Bed and Breakfast, or Hotel?
To stay at a good small hotel, or at a good bed and breakfast?

We're in the process of setting up our business hotel in a grand old house that was formerly run as a Bed and Breakfast, and the changes are substantial. Here's a comparision / sanity check that I put together to highlight where the two types of establishment overlap, and where they differ.
| Bed and Breakfast | Hotel |
|---|---|
| Definition A Bed and Breakfast is primarily someone's home, where the owners let out a limited number of rooms for overnight and short term accommodation, and serve breakfasts to their guests. | Definition A Hotel is a business, run with the primary purpose of providing board and lodgings for overnight and short term guests |
| At a good B&B, you'll feel very much a welcome guest in someone's home and you'll be encouraged to mix socially with the owner and the owner's family. | At a good hotel, all the advertised services will be readilly available to you, but you shouldn't feel obliged to socialise with the owner / manager |
| Arriving at a B&B, you may need to co-ordinate your arrival time to suite the personal availabilty of the owner | You should be able to arrive at a hotel at any time after earliest checkin time, including arriving late into the evening. |
| You may or may not be able to park on the private property that's attached to your B&B. Personally, when staying at a B&B, I'll park on the road outside the property and check before I drive onto their land, and I'm quite happy to park in the road or a nearby car park for the duraion of my stay. | Except in a city centre, a hotel should offer parking on its own land for all guests, and guests should be able to drive into the car park by right as they arrive. In a city centre, parking is sometimes provided at a local car park, but you'll at least be able to drive up to reception to check in and unload. |
| A B&B will often require to you pay in cash or by cheque. Some take credit cards | A good hotel will accept payment by credit card and debit card, and may offer accounts for companies who book for their staff or customers regularly |
| At a B&B, you're unlikely to be provided with a great range of communications options - chances are that if you want to get in touch with anyone, you'll need to use your mobile phone, and that if anyone calls in for you, you'll have to take the call in the owner's room, perhaps with the owner within earshot | At a hotel, there should be good communications. These days, at business hotels that will include the availability of internet access. |
| The owner of a B&B is likely to be a great source of local knowledge and will usually be only too happy to tell you what there is out and about in the area, and what facilities he / she offers. | Each room in a good hotel will have an "FAQ" folder that will tell you about the faciities on offer, and the locality and services and attractions around. The staff and proprietor will be able to help you too (and will be happy to do so), but that's very much in addition to the information that's at hand if you don't want to trouble anyone |
| In a B&B, you're likely to find that your room's quite small, as it's designed very much with the intention of being primarily somewhere for you to sleep | In a good business hotel, rooms are more spacious - you should have facilities such as a desk area where you can place your laptop, write, organise your papers, etc |
| Not all B&Bs offer all their rooms en-suite - some have shared bathrooms and toilets. Where a B&B does offer "en suite" facilities, it may have been added later and be utilitarian and squeezed into a corner of the bedroom. Being on a domestic supply system, hot water may be limited if everyone tries to take a shower at the same time. | These days, most hotels offer en suite facilities in most or all rooms, and a good supply of hot water should be available at all times. |
| Reception room access may be limited or non-existant. You're buying a room to sleep in, and you'll have access to a breakfast room at breakfast time. Other access is welcome if provided, but should not be assumed. | Hotels will have at least one customer lounge area, and perhaps more. If they're set in their own grounds, you can also expect to have access to at least some of the gardens although the delivery area is probably "off limits". |
| As you're staying in someone's home and are an honorary member of the family, you'll be offered a limited breakfast menu (typically a full English breakfast) that will be available over a relatively short period. At some B&Bs, failure to eat a full breakfast can offend the owner. | Hotel breakfasts vary - most offer a wide range of continental and traditional full breakfast, served over a period of several hours, although some chains such as Holiday Inn Express are no longer offering the full breakfast option - a trend we see continuing in business hotels. |
| B&B room rates reflect the different level of services offered as compared to a hotel, and are usually good value for money. | Hotel rates can vary widely - usually they'll be somewhat higher than B&B rates, but then you're buying a service that fits in with your requirements and schedule rather than fitting in your schedule to meet the owner's timetable. |
Posted by gje at 05:49 PM | Comments (0)
Breaking bread
How can I take ONE thing, discard some of it, and end up with MANY things all of the same type as the original? Surely that doesn't make sense does it?
I could take a packet of half a dozen rolls from the supermarket, made (as they often are in the UK) as a single piece of bread with narrow "tear" points, and tear into six pieces. A few crumbs to be thrown away - and there you have it. Six things (of type "piece of bread") where the sum total is actually LESS that the one thing ("piece of bread") that I started with.
This action of breaking bread has a parallel in programming. In Perl (split), Python (split) and PHP (explode, split) amongst others, you can take a single string and break it down into a whole list (Perl, Python) / array (PHP) of smaller strings. You'll often want to do this if you have a string that's a line of data read from a file, and you want to break it down into a series of strings each of which is an individual field.
@pieces = split(/\s+/,$line); # Perl
Posted by gje at 07:17 AM | Comments (0)
June 21, 2006
Training in Liverpool

The Royal Liver building, completed in 1911, stands a few yards from the river Mersey near Liverpool's Pier Head, formerly the point from which ferries left for Birkenhead.
I'm training in Liverpool this week and I'm seeing huge development in the City; some of the older buildings converted from offices to luxury flats, and other new skyscrapers appearing on the skyline - some of them blocking other's views of the river (a bit of local controversy there, I understand). And I'm so close to the Liver building that the training room I'm in doesn't need a clock- I can just glance out of the window (see picture!) and see the time on the old landmark, where the clock face is said to be larger than that on the Houses of Parliament.
[Pictures taken on 19th and 20th June, Graham Ellis, and processed via Adobe Photoshop]
Posted by gje at 06:27 AM | Comments (0)
From cat breeder to Cobol to Perl
In my youth, I read the books written by Gerald Durrell ... starting off with the stories of his childhood on Corfu in "My family and other animals" where I learnt of his maveric background with unusual pets of all shapes and sizes. Followed him through animal collection trips to Africa and South America, trips to New Zealand and Australia on a more fact-finding mission and his own zoo on Jersey where he specialised in breeding rare animals and other conservation work.
So I was especially interested to find that one of my course delegates this week spent 8 years on the staff of a local zoo, looked after the smaller cats, and was very much into the breeding / conservation. Some very interesting tales over lunch; "I don't talk about it too much - I get carried away and bore people" to quote ... but no way was I bored, and I relished the enthusiasm. To hear that the "secret" to breeding one type of cat is to give them a steady 12 hours of light and 12 hours of dark every day to be like their native equator, and that another cat (the jaguarundi) is a social cat ... and how a clue in an obscure Victorian book about a trip to South America "I knocked a bush with my stick and a whole swarm of Jaguarundi ran out" lead him to put the zoo's whole stock into a single cage as it was a lightbulb moment that they're a social cat, and lead to a previously unseen breeding success.
Add the story of Nobby the Elephant, of visits to the Aspinall Zoo in Kent, and of Siberian tigers and there's a book in these stories, I'm sure ... now I wonder if I can persuade him.
Posted by gje at 06:14 AM | Comments (0)
Useful link: Perl training
June 20, 2006
Splash!
A Splash page is the ultimate home page. When I'm away (as I am this week) and I connect in via a hotel network, the first page that I'm offered is the hotel supplier's - no matter what URL I've asked for. Only when I complete a login form (which will involve giving an account and password number, or signing up via a credit card) am I allowed beyond the splash page / splash server.
On a company's intranet, there's often a splash page to give employees the company news when they first connect.
At the current training centre, we don't have a splash page but at Well House Manor, we WILL, even though we're going to offer inclusive internet access to all our guests.
1. It will allow us to broadcast to all users (via the splash page) a message of the day, and to give them easy links to our "FAQ" or "RTFM".
2. It will allow us to give users a password / login code so that they can connect in via an unsecured network, but anyone who's out in the street just passing by, and our neighbours, can't steal our bandwidth
3. It will give us a mechanism through which we can control access in case we need to; most people are trustworthy, but if we're alerted to network abuse the technology associated with the splash page will let up selectively switch a rogue user's access off.
I started searching for splash page software online and was surprised I didn't come up with very much ... something called nocat looks promising, but the dates on the software are all a couple of years old and it looks perhaps fading or dormant. Not something to start using for a medium to long term life. Then it stuck me that Linux's iptables and a router box will probably do the job admirably. No doubt there will be some techical articles and blog entries following, but I think that we'll end up running a Linux router / firewall with default masquarading of port 80 to the local web page, and rules that block all other outgoing ports. A user signs in and the tables will be updated to give them direct net access and will unblock other ports ... and a monitor daemon will clean up old rules from time to time.
Posted by gje at 06:29 PM | Comments (0)
King Edward VII - days of empire
Things that are so much of my daily life are novel to others, and things that are so much part of their daily life are new and novel to me. After all, everyone's got a different life, different tastes and different experiences. Wouldn't it be fearsome if that wasn't the case ... everyone in the world would turn up at London's Paddington station to catch the 17:15 to Slough and there would be no driver.
But celebrating the difference, I can spread what I hear, and learn, and do to others who are interested. And I seem to be fortunate it being able to find my words to do so, especially on technical matters. Hundreds of people a day visit pages such as the one I wrote explaining the difference between a join and a left join in MySQL, or the longer article on uploading images with PHP and storing them in a MySQL database.
I was chatting with someone the other day and talking about a "Splash page" for the Well House Manor network ... and realised that's a term that needs explanation. And chatting with someone else, I realise just how much of an experience a first airline flight can be, especially if your background's such that you happen to have never been airborne until after you're retired.

King Edward the Seventh was King of England for 10 years from 1901. By all accounts, a "bit of a lad" in his youth he came to the throne much later in life after the incredibly long reign of his mother, Queen Victoria. Those were the days of "Empire", when England ruled the world, controlling many large and distant lands from these shores, often with an incredibly small number of local troops and officials. My picture shows the statue of King Edward VII seated on his horse on the dock front at Liverpool Pier - looking out over the Mersey, where so many of the ships left for the colonies.
Why my interest in King Edward? Because Well House Manor was built in 1906, and part of our centenary restoration is taking some of the elements back to original. We've been looking round the local antique shops - hoping to find a tasteful picture of the King, for example, and we're opening up some of the old fire places.
The Edwardian era was, perhaps, halcyon days. World wars, the depression, and the end of empire were still a way forward over the distant horizon, and contruction standards were solid to put it mildly. We're finding that Well House Manor is a fine building, all be it in need of some works where maintainance has been skimped in the past couple of decades.
Posted by gje at 05:57 PM | Comments (0)
June 19, 2006
Our new .eu top level domain
I'm in the UK this week, then out of the country again for a few days at the start of the following week. With this business pattern, we've often faced the conundrum "which top level domain should we bs using" and years ago we fixed on .net, since we're providing services relevant to the internet and its use, and we didn't want to be seen as only a UK company that a .uk domain name would imply.
With the new .eu top level domain now generally available, we've registered that too as a central point for information about the services we can offer across the community - had this top level been available 15 years ago, it would probably have been THE one to go for as we do quite a substantial amount of training in Ireland, and also work to a greater or lesser extent in France, Germany, Sweden, Italy, Greece, and the Netherlands, and we've recently hosted delegates from Spain, Italy, Denmark and Austria as well ...
Link - http://www.wellho.eu
Posted by gje at 12:20 AM | Comments (0)
June 18, 2006
Finding the language preference of a web site visitor
I can (and do) identify the country of origin of over 98% of the visitors to our web site using the maxmind database. But does that tell me what their native language is? No - it only gives me a clue.
A further clue is available from the accept-language header that's returned by browsers, and is available in PHP in the variable $_SERVER[HTTP_ACCEPT_LANGUAGE]. With this variable, your web site can check if the user has expressed a language preference (and perhaps given a second and third choice too), and you can use the information to tailor your response as appropriate.
I've put up sample source code and a working demonstration on our web site. I've also added a page reporting language statistics for our own site ... only a very short data sample on there today, but as from tomoorow it will update daily with a 24 hour report.
Some surpises ... I would expect to find most major European countries choosing their own langauges, with Swiss visitors choosing between German, Italian and English. The first tests I ran, though, gave me a series of pages called up from the USA with a first choice language of Korean. Truly, the world is a global market.
Posted by gje at 07:17 AM | Comments (1)
June 17, 2006
Discounts and approved supplier lists
There are times when our "no discounts" policy can bite us in the bum.
In reality our policy is that we ALWAYS offer a discount off the sort of rates that you would pay elsewhere for a course on a similar subject and of a similar duration; I've just been comparing a five day Perl course that we provide at 1210.00 + VAT with another that's listed at 1575.00 + VAT. I see no point in us overpricing by 30% so that we can take some of that back off ... I know that if your push that other company, you'll be able to get them to knock 10% off (or 15% if you're really pushy). And at 15% off, you're still paying over a hundred quid more to them than you would to us.
So .. why do people get taken in by inflated prices and discounts?
People think that they're getting a great deal if there's something off. They'll notice a discount of 150 pounds much more than they'll notice a price difference between between 1500 pounds and 1200 pounds. And they'll feel special if they think they're being given a better-than-regular deal
And why is it a practise that I hate so much?
Because it's deceitful. Because it's unfair. Because it favours the pushiest of potential clients over and above those who are equally deserving but less "bolshy". And because I've stood in front of classes where everyone has paid a different price and had to answer "why did he get it for xxx pounds" asked by a furious delegate who paid 20% over xxx.
Yet, as I say, the policy can occsionally bite back at us. These days, many organisations are setting up centralised buying departments to flex their muscles and purchase from there, with a view to actually getting that 150 pounds ... or more ... off the 1500. "What special deal will you offer us" they ask on their invitation to be on their approved list. And a reply of "none" looks rather like a slap in the face. Even such outfits as the BBC have been through this loop ... but good for them, they can see the wood for the trees, they do have experience of the courses we provide, and we have just learned that we're on their list for the next two years.
Posted by gje at 04:05 PM | Comments (0)
Perl - turning seconds into days, hours, minutes and seconds
So often you'll be working within a program in seconds - elapsed times, delays, that sort of thing - but want to report times back to the user in terms of hours, minutes and seconds. The conventional programming way to do this is to do a series of divisions and grab the remainder, but in Perl you can use the gmtime function which converts a number of seconds from 1st January 1970 into a list of 9 elements of a date. Up to 365 days, you can simply take the days-into-year and hours, minutes and seconds value returned by gmtime.
# Convert seconds to days, hours, minutes, seconds
$seconds = 94054;
@parts = gmtime($seconds);
printf ("%4d %4d %4d %4d\n",@parts[7,2,1,0]);
When I run that:
earth-wind-and-fire:~/jun06 grahamellis$ perl ts
1 2 7 34
earth-wind-and-fire:~/jun06 grahamellis$
A conversion of 94.054 seconds into 1 day, 2 hours, 7 minutes and 34 seconds.
Posted by gje at 05:56 AM | Comments (0)
Useful link: Perl training
June 16, 2006
Journey planning - Xephos v Transport Direct
I looked up a journey from Melksham to Liverpool (I just entered "Melksham" and "Liverpool" without being any more specific) on the Transport Direct Web site yesterday ... and here's the start of what it suggested ...

It's very easy for travel sites to make silly suggestions that don't appear to be spatially aware. The route starts off at the Town Hall in Melksham at 17:34, takes me a mile out of the town and then has me walk back to the Market Square, right outside the Town Hall, to catch the following bus at 18:04. The Transport direct site, which is sponsored by the Department for Transport, was notorious at its launch for this sort of problem, and I regret to see that it's still up to its old tricks.
The Xephos web site (to which I have a 2 pounds a month subscription) is much better, though some of its timetables are out of date (it does, to its credit, warn you to check on the occasions where it's aware that it's not been given up to date information). Xephos suggested the 18:02 bus to Bath, and connected into the same train at Bath that TransportDirect suggested I catch at Chippenham - and that's far better since the interchange at Bath is just across the road, whereas it's quite a walk (especially with luggauge) across Chippenham.

Posted by gje at 08:32 AM | Comments (0)
June 15, 2006
Much more that the world cup
Who is that chap you stood behind in the queue for your train ticket this morning? He looks just like another commuter, but do you really know? And what about that woman who's just used the pedestrian crossing in front of your car? They may just be people who are living quiet lives and not greatly effecting others ... but you can find some massive surprises!
I've got a couple of delegates this week from a company concerned with mobile phones. Great blokes, and being World cup time, talk naturally turns to soccer and some of the other more regular subjects that come up during social breaks. But then ... there's an off-topic interest in web sites and design (this is a Perl data manipulation course!) and it turns out that Ollie is planning to drive a landrover all the way from the UK to Australia in 2009. See Jenny and Ollie's web site for more ...
Listening to Ollie talk, it's great to hear his enthusiasm - and his enthusiasm for the VSO (Voluntary Service Overseas) cause that he and Jenny are hoping to raise the profile for. "It's a charity that helps set people up for the future" he tells me. "Not one that just feeds people when they're starving, but one that gives them the tools and the seeds with which they can go on feeding themselves into the future".
Posted by gje at 06:25 AM | Comments (0)
Huge data files - what happened earlier?
When I'm programming a log file analysis in Perl, I'll often "slurp" the whole file into a list which I can then traverse efficiently as many times as I need. If I need to look backwards from some interesting event to see what happened in the immediate lead up to it, I can do so simply by looking at a few previous list elements.
This technique fails if my log file can be so massive that it won't fit into my computer memory, or if doing so produces severe swapping. Fortunately, there are other ways of dealing with this in Perl.
* Using a queue, each item that's read from the file and is a potential prior event is pushed (on unshift-ed) onto a list
* When an event that triggers a report is found, the prior events in the queue can be examimed and reported on
* The queue of prior events is kept trimmed to an appropriate length.
I've applied this technique to quotations for private courses in our log files ... when I find a quote request, I want to know the background.
Code to add all .html and .php requests to a queue just in case the user calls up a quote:
next unless (m!T \S+\.(php|html)!);
unshift @queue,$_; # Add to queue
$#queue = 20; # Trim queue
Code to report when a trigger event is found
if (m!GET /net/quote\.html!) { # is it a quote?
($host,$page) = (split)[0,6];
print "Host: $host\nQuote: $page\n";
foreach (@queue) { # If so, report on previous requests
($ohost,$opage) = (split)[0,6];
print "From: $opage\n" if ($host eq $ohost);
}
print "\n";
The code to keep the queue trimmed back is part of the "add to queue" code just above.
Here's an example of the results that I get from running my program ...
Host: cache2.uk.Ichangedthis.com
Quote: /net/quote.html?where=bs32+4tr
From: /course/otc.html
and this tells me that the person who was looking for a quotation for training in BS32 had previously visited the page of general information about on site training ...
Full source code of the example that I'm discussing here is available in our handling huge data resource, and is taught on our Perl for larger projects course.
Posted by gje at 05:44 AM | Comments (0)
June 14, 2006
Great new inventions
The Smelliphone on which you can not only talk to someone, but smell their breath too. An option for hands free phones lets you smell the rotting fruit they've forgotten on their office desk, or whatever else is around the handset.
The personalised car alarm tone which you can download via your internet connection and install in your car. Then you'll know that it's YOUR car that's irritating the hell out of all the others around you as it goes off when you're in the supermarket queue.
Posted by gje at 02:42 PM | Comments (0)
Self help in Perl
Perl's POD (Plain Old Documentation) system provides the programmer with the ability to add user documentation into his programs - allowing a single source file to include:
* The program itself
* Comments for future programmers who read the source
* Documentation for the user
Convertors such as pod2html and pod2man extract the POD documentation from a Perl program and produce HTML and manual pages as required ... and there are other convertors too supplied with Perl or available for download from the CPAN.
Here's an idea for using POD (and the text conversion of it) to provide a usage line and documentation for a perl program also using pod ... a program that generates its own documentation, just using the standard elements of the Perl distribution to do so.
#!/usr/bin/perl
$usage = @ARGV; # Modify this line to suit allowed command line parameters
if ($usage) {
print STDERR "\nUsage: $0 [-h]\n\n";
die `pod2text $0`;
}
print "normal operation\n";
__END__
=head1 A program that documents itself
Here's a program that gives you a full
scale usage report when you run it ...
=cut
Posted by gje at 08:13 AM | Comments (0)
Useful link: Perl training
June 13, 2006
Watch your Google profile
I've been cc'd into an argument on a forum (not our Opentalk) and I'm taking great care not to join in or read deeply into what looks like a feud between a couple of folks who, frankly, should agree to disagree. However, I did pick up: "Speaking for myself, I’ve never bothered Googling anyone -- my time is worth more to me than to indulge in such pointless activities." and felt it worthy of comment.
Googling people is, at times, a far from pointless activity. Just yesterday, I was answering a training query and I wasn't sure of the physical location of my correspondent; a quick Google search indicated a probable London location and that meant that my answer was tailored towards UK courses in the knowledge that my potential delegate could attend a course in Melksham. Had I turned up New Zealand, then my answer would have had a very different slant.
But there's two sides to a coin ... and information that's placed our there, labelled up with your name and public readable, can come back to "haunt" you. I could come up with examples, especially where people have placed what's supposed to be a personal message, a joke, or a thoughtless rant when they're upset. There's other examples around where person "x" has talked about person "y".
My Web content will be read by whom?
Whenever I post with my name (Graham Ellis of Melksham, Wiltshire, England) I do so with three eyes.
One eye is for my target audience - just WHO am I writing this entry for today?
The second eye is for Joe Public, coming here accidentally - perhaps as a new potential customer of our Well House Consultants training courses or wanting to stay at our hotel in Melksham, but more likely sent here by a search engine that feel that we're a good site for "Clock Image", where we're #2 on Google at the moment.
The third eye is for people researching us - they may be benign in the form of someone checking up on me / us before booking a course. They may be competitors (Hello, wwwalt, xxxirect and yyyyyingtree - you watching us?). And they just could be all sorts of people I would rather NOT have seeing any soft underbelly I might have - from people looking to rubbish my Save the Train campaign because they've a vested interest in killing the service before it gets too strong and takes passengers off their buses, through to snooping government agencies who at times seem to draw the net far too wide and wrongly assume the worst of people.
My main posting is - has to be - for my first and second eyes. For my target audience of regular readers and people who come, previously unknown to me, to our web site to look for and find tips and techniques on MySQL or some similar topic.
Fixing my web content
What if - like the person I originally quotes - I want to squash some web content that I regret putting up, or that someone else has written. Alas, just as building up a web profile is rather like starting an oil tanker (takes a long time to see much effect), so breaking one down can be like stopping an oil tanker. Search engines cache pages and some (such as the Way Back machine) make a point of keeping copies over the years.
Some tips:
a) Visit posts on forums that you wish you had not made, and where you can, edit them. Where you can't, a friendly message to the administrator - if still active - will help.
b) Alter pages that you control yourself to remove the problem content (and perhaps supply a graveyard page. That's far better than deleting the page, as anyone who searches for the page should be given the new copy (what you want) and not the cached copy (what you don't want). With a deleted page, all the search engine CAN offer is the cache.
c) Where you don't control a page, you may control or influence some links to it. Change these!
d) If you've access to the robots.txt file, tell the search engines to exclude pages that you no longer want indexed.
e) In an extreme case, you may wish to ask search engines to delist you; you should find details of how to request this on their web sites.
f) If you don't like content on a page that's NOT under your control, you should go through and ask the information provider, then the webmaster, then perhaps the hosting ISP to remove the content - but if your case is not compellling you may well be out of luck. Friendly is usually best, but if there are copyright or other legal issues involved pointing them out gently will usually help.
Posted by gje at 04:53 AM | Comments (0)
June 12, 2006
Very good for woodlice
I'm seated in 'The Cottage' at Well House Manor - here to start the week's work off before returning to '404' to give a course in a few minutes. The previous owner has left us a spray labelled "Ant and crawling insect killer", and there's a sticky label attached that says "Very Good for Woodlice".
Hmm. I would have thought it was very bad for Woodlice ;-)
Posted by gje at 08:47 AM | Comments (0)
Horse and Python training
Writing a blog called "the Horse's Mouth", and providing a training service, I suppose I should expect to be approached by horse trainers who would like to exchange links - such as Keith Hosman, who wrote to me today. OK - I do expect it ... I've had approaches like this before, and no doubt I'll have the same approach again some time in the future.
I see no harm in illustating this blog entry with a link to Keith's site (link) ... we're not exactly a "link farm" here, but I do like to illustrate my points with references to other sites. Perhaps he would be so kind as to add a link from his site to ours in some appropriate spot?
Update - Many thanks for the reverse link, Keith - that was fast! - Graham
I've had similar issues with Python in the past. There seem to be a lot of people out there who want to learn how to train their pythons (is it possible? I don't know) and come to our site looking for tips.
Posted by gje at 12:51 AM | Comments (0)
Useful link: Python training
June 11, 2006
Seeing the bricks for the trees
"The Old Manor" was a secluded house, set amongst trees that had become overgrown with time. In a few areas, what could only be described as a jungle comprising both beautiful classic trees and fast-growing pines had taken over and was making the property dark and gloomy, and wasn't best pleasing some of the neighbours either.
Although it's only just a week since we took over, we've already had a team pruning back some trees, and taking out a handful completely - no more than a few percent of the timber has gone, but the difference is astonishing.
"Well House Manor" in all its glory:


Posted by gje at 07:50 AM | Comments (1)
Using different URLs to navigate around a single script
1. I want my website to have different URLs for each of my content pages so that users can easily bookmark pages, pass them on to friends and contacts easily and with confidence, and search engines can register and handle each as its own distinct page
but
2. I want most of the pages on my website to be provided by the same script, so that I can maintain a single piece of code that brings in variable content as required.
Requirements (1) and (2) may appear to conflict at first, but in reality they don't. Multiple URLs can be mapped onto a single script using Apache httpd's mod_rewrite (guide, reference). And that way, you can get the best of both worlds.
Mod_rewrite is very powerful; we use it in many places on our web site and on client web sites, and the casual website visitor hasn't a clue that it's in use. Because it's very powerful and flexible, though, the documentation can be a bit longwinded to wade through and it's often hard to see the wood for the trees. So here's an example:
In the .htaccess file in a directory called /boutique
RewriteEngine On
RewriteRule ^([^/]*)/([^.]*)\.html$ demo.php?andy=$1&graham=$2
RewriteRule ^([^/]*)\.html$ demo.php?toplevel=$1
Any top level .html requests are mapped to the script with a "toplevel" parameter as if one box on a form had been completed (that's the second rule). And .html requests that appear to be in subdirectories are mapped to the same script with parameters called "andy" and "graham" as if each of those elements had been entered into a form.
I've put up a live script on
http://www.savethetrain.org.uk/boutique/clothing.html
http://www.savethetrain.org.uk/boutique/clothing/trousers.html
http://www.savethetrain.org.uk/boutique/clothing/hats.html
The script source code is available here, the .htaccess file source is here, and training is available here
Posted by gje at 07:07 AM | Comments (0)
June 10, 2006
tar, jar, war, ear, sar files
Have you ever wondered why that are so many file extensions ending in "a r"? It's because the "ar" stands for archive, and it's such a reasonable way of naming file that the original tar which stands for tape archive was picked up by Sun and the Java community and transmuted into other file formats.
tar - tape archive
jar - java archive
war - web application archive
ear - enterprise archive
sar - service archive
The original tar or tape archive files are / were used for software distribution and backups. The format they use is that the file is written as a series of units:
• file name
• file length
• file data
which means that the whole archive file has potentially to be scanned when an element is to be extracted. Furthermore, a tar file in its native form is NOT compressed in any way. This means that a tar file can be both big and inconvenient.
Jar or Java Archive files may also be used for software distribution and backups, and although the jat utility that's used to create and (usually) to unpack them is written in Java and most people use them to contain Java - related information, they can actually contain any file and directory structure. There IS a header (an index or MANIFEST) at the top of a jar file saying what's in the file and where it is, so things can be accessed quickly on a random access systems such as a disc drive, and the data is usually stored compressed (turn compression off with the 0 option when you create a jar). This means that a .jar file is an appropriate medium for extracting information on the fly within a live application, even one that's quite heavily used.
Other file types that I mentioned at the start, such as war and ear are also jar files, created with the jar utility. In fact, they're a subtype of jar files with the data they contain being in a specific file and directory stucture. In other words, the arrangment of files within a war is such that the file and its contents are suitable for deployment as a webapp under a container such as Apache Tomcat, and the arrangement of files within a ear is such that it's an Enterprise Archive such as you would use under JBoss, etc.
Posted by gje at 07:05 AM | Comments (0)
June 09, 2006
Python 3000 - the next generation
There is no definite schedule for Python 3 (a.k.a. Python 3000 or Py3K) but a Python Enhancement Proposal (PEP) that details plans exists. There's a guiding principle to reduce duplication by removing old ways of doing things which will break version 2 compatibility. (Heard it before ... Perl 5 to Perl 6 ... a story from or for another day).
Proposed changes include:
• moving map, filter and reduce out of the built-in namespace
• add support for optional type declarations
• unify the str/unicode types
• introduce a separate mutable bytes type
• convert built-ins to returning iterators not lists where appropriate
• remove backwards-compatibility features like classic classes and division, string exceptions, and implicit relative imports
Very VERY early days yet, so "watch this space" for news
Posted by gje at 05:56 AM | Comments (0)
Useful link: Python training
Over zealous police activity?
Is the very act of driving a car out of a pub car park sufficient grounds for a policeman to stop you on the basic that he suspects you might be drinking and driving? Apparently, the policemen of Wiltshire think it is.
The other day, I left the West End (Pub) after a lunch with customers. Not one of us had any alcohol at all - after all, the course was continuing through. That particular pub offers a good meal at its heavily advertised and used restaurant, and serves soft drinks as much as alcohol.
As we left the car park, we noticed a police car doing a wide "U" turn in a T junction opposite and wondered what he was up to, and he followed us back to our place, actually turning into our drive and onto our private property behind us, blocking my car in.
I walked back to the police car.
Graham "Can I help you?"
Police Officer: "We having a drink drive campaign and I couldn't help noticing you leaving the West End. Do you mind telling me how much alcohol you've had to drink? "
Graham "None at all. None of us has. We've an afternoon's work to do"
Police Office "May I smell your breath ..."
I was unsure, and suggested that it might not be especially pleasant, but the officer reassured me that he wasn't worried about that, and that he could tell straight off if I was indeed alcohol free from the test. Test due-ly done, "Thank you" he says, and he and his colleague who hasn't left their car or said anything leave.
I'm very much against driving under the influence of alcohol but I wonder:
a) Does a police officer have the right to follow and stop me just because he saw me driving out of a restaurant / pub car park?
b) Does he have the right to follow me onto private property and block me in this circumstance?
c) What's the basis for the "breath test" he undertook - should he have asked for that?
I felt unjustifiably accused in front of my business contacts. There was no suggestion what so ever that I had been behaving in any way to raise his suspicions - indeed, he specifically gave "leaving the West End car park" as his reason for following me, blocking me on my own driveway, and questioning and breath testing me in front of my clients.
[[UPDATE added 28th June 2006]]The following provided by the local police inspector ... many, many thanks to him for the time and trouble he has gone to research and provide answers:
The police are empowered to stop any motor vehicle on the road. We are not required to suspect that an offence has been committed. One assumes that this is to allow the police to be able to pro-actively deal with motorists and not have to suspect that an offence has taken place before they have the power to stop.
Random breath testing is not legal in this country. The police either have to suspect alcohol before requiring a breath test or a moving road traffic offence has to be committed. To my knowledge, neither applied in your case and that is why the officer asked you to breathe on him. Had he suspected alcohol then, he may have asked for you to provide a specimen of breath, but obviously he had no suspicion
[[Comment by Graham]] In other words he had no right to ask for a breath test as he had no suspicion, but never the less he in effect DID do a test by asking to smell my breath. Hmm.
[[I then wrote]]There is no reason why they cannot follow a motorist onto his private property, and there ask for an informal (as happened in my case) or formal test. The motorist asked for such a test does have a right to ask the officers to leave and they would do so. However, the officers are NOT obliged to tell the motorist of this right, and as I understand it for a motorist to invoke the right could imply a knowledge of the law and a lack of co-operation which would in itself raise further suspicion and probably lead them to make further enquiries.
[[Inspector's reply continues]] This is a more grey area. To my knowledge, and I have also taken advice in this respect, there is nothing to preclude officers from following the course of action that they did, however if the property owner were to request them to leave because they were on private property then they would become trespassers and potentially not be acting in the execution of their duty. However some Sections of the Road Traffic Act do allow officers the power to enter premises in they suspect impairment through drink or drugs. No they are not obliged to tell the public.
[snip]
It is clear from our correspondence and also the conversation that I had with your wife, that this incident has caused you some embarrassment in front of one of your clients and for that I apologise. In summary though, I believe that the officers acted reasonably from the description of the events, their motives were true and they acted proportionately in their dealings with you. Road Safety is one of the key objectives of the police service and given that excess alcohol is one of the major causes of all fatal and serious injury road traffic collisions, we do endeavour to deal with it pro-actively and robustly.
If I was embarrassed, I wouldn't be blogging this, would I ;-)
I do completely appreciate the need to act robustly in response to drink-driving. I also believe that the motives of the officers were true. However, I differ from the Inspector in my view of what is reasonable. To follow someone who has not raised any suspisions onto private land seems, to me, like one step beyond reasonable, To then block that person in seems a second step beyond reasonable. To sidestep the law about random breath tests by asking for an informal test, and not giving me full details of my rights as regards this, perhaps a third step. I could go on with other aspects, but I think three's enough.
I suspect that the police officers involved spend much of there time dealing with people who have broken the law or who are in danger of doing so. The Inspector wrote I have personally stopped vehicles as they have pulled away from the forecourts of licensed premises and immediately explained that the reason I am doing so is to ensure that they are not driving with excess alcohol in their bodies. Unsurprisingly I would hope, I have detected many offences by doing so.. Ah, yes indeed Inspector. But you're not saying that you've followed them all the way back to their places, nor than you've blockaded them, nor that you've failed to tell them their rights in questioning.
P.S. There's also a disagreement whether doing a U turn in a turning opposite the restaurant, pausing on that turn until a vehicle comes out of the pub, the following it could be regarded as "waiting ouside the restaurant". In any case, the indication is that such action IS within the policy of the police which is what I was asking.
Enough of this subject ... I offered to follow up, have done so, and will now let matters rest.
Posted by gje at 05:55 AM | Comments (3)
June 08, 2006
Want to be a technical trainer in the UK?
This is an overview written in answer to an email. I'm publishing it via the Horse's Mouth as it might be useful to others. Please bear in mind there are a lot of subjects that I have NOT touched on here such as the need to obtain an appropriate visa if, like my correspondent, you're not an EU citizen.
Typically, trainers in the UK are contractors, just like in the US; I worked in that way for about five years but it's a while back - indeed our current company - Well House Consultants Ltd- was set up as the administrative mechanism for that, but grew into a complete training provider with our own training center, etc. ((Note - changes in UK Tax law and something called IR35 men that initial setup advise would differ today))
There's a great tendency in the UK for courses to be advertised, but only run if there's enough delegates booked. For the contractor who's booked to give the courses, a last minute cancellation can mean a sudden vacant week with no income unless you have alternative non-time-critical work ("another string to the bow") such as web application programming with which to fill in.
Your field is, indeed, roughly the same as mine but not similar enough for me to realistically give you the sort of rates you might charge and the job market state. I will comment (although I'm sure you realise already) that the whole cost of living metrics in the UK differ greatly from those in the US, and when doing your sums there's much more to look at than just income.
Yes, you will find authorised training centers/courses over here ... they're a great way for the Microsofts and Novells to control the level of training that's given, to ensure there's appropriate sales pitches made on each course, and to syphon off some of the delegate's income. We've been invited to join some such schemes, but we've declined to do so after careful consideration. It does mean we're responsible for obtaining or writing our own material which for the niches we're in suits us well.
Much work is obtained through word of mouth / knowing people. One or two good contacts might be all you need to get started, but it can be a slow process building up and I rather suspect that by the time you're running on an economic footing, it might be time to go back to the USA when your partner has his visa. I've not come across too many listing agencies.
In the UK, you'll also find a lot of training resellers who match up training requirements to training organisations - middle men. We ourselves aren't keen on dealing with them - they typically request (or demand) a heavy fee from the trainer, they're a lot more hassle to set up and won't let you speak with the client to find out what he really needs from his course ahead of time, and they're slow payers. However, they may provide you with an "in". In a diverse world such as training, some big companies will use a single reseller to bring together all their training needs so that they (the big company) doesn't have to do a huge amount of research itself and can go to a single, all be it indirect, source.
Area wise ... you might find something in London (which you mention), but high tech stuff is spread all over the UK. In our own niche fields, we have a training centre that has access that's as reasonable as anywhere, but we have to be prepared to travel too. I was in Cambridge late last month, and I'm in Liverpool in a couple of weeks for example. In our particular fields, there's occasional opportunities further afield - I was in Saudi Arabia a couple of weeks back, and I'm in Ireland later this month.
Posted by gje at 07:01 AM | Comments (0)
June 07, 2006
Almost everyone loses
Contestant based shows on the TV always seem exciting and yet depressing as individual of teams compete against one another to get through to the next round, or to reach a prize or possible prize. For every jubilant winner, there's numerous others who have quietly slipped out of the back door ...
There's one contestant based show to end all contestant based shows. In this show, the whole audience in the studio, and most of the audience at home too, are contestants. And the winner-to-loser ratio is really dreadful. What a strange premise for a piece of entertainment - that everyone starts on a high thinking that their whole life could be changed and, twice a week, those high hopes are dashed on the rocks of reality.
You've probably gathered by now that I don't play the lottery. I pay quite enough money to the Government as it is, without paying extra lottery tax, and without paying for good causes which the government SHOULD often be funding as a matter of course.
For every pound spent on the UK lottery, 45p is returned in prizes, 28p is allocated to the distribution funds, 12p goes straight to the government as tax, 5p is kept by the operators, 5p by the retailers, and 5p is set aside as money to prime the pump of future scratch card games, etc.
Posted by gje at 09:57 AM | Comments (0)
Cottage industry or production line data handling methods
If you're running a cottage industry, for efficiency's sake you'll run the first process on each of your raw components first, and store the partially-completed elements in a basket as they're processed. When you've completed that first process, you'll then apply the second process to each element in turn, then the third process, and so on. For small scale production, that's a much MUCH better use of your time and resources that setting up all processes in what's probably a very small area and trying to take components through from end to end.
But if your level of throughput is to be several magnitudes greater, the cottage industry approach doesn't work and you'll want, in a bigger area, to set up a production line. You'll have more overheads, as each stage of the line will need someone to operate it, but you'll save on the need to store large numbers of intermediate components, and you'll save on the time spend putting down and picking up components at each stage too.
Data handling flows can resemble a cottage industry or a production line .... and it depends on how much data you have as to which approach will be the most effective.
In Shell Programming, using a series of operations each of which reads from a file, and saves out to a file with > style redirects, is your cottage industry approach. Using a pipe - | is more production line, with a buffer usually of 4k between the processes.
In Python, functions such as range and readlines return complete lists which you subsequently use - cottage industry. Alternatives such as xrange and xreadlines are generators which are running in parallel with their calling code and so are your production line. And you can write your own generator functions; you can spot them in existing code if you see the yield keyword.
As well as using the cottage industry / production line comparison, I also compare the one-at-a-time approach to being akin to filling up a reservoir from one process, then using the reservoir until it's empty from another. If you have a huge amount of data, then you're likely to overflow your reservoir and have your program fail. However, running the processes at the same time is rather like joining them with a pipe, with a tap that is turned on and off each time a new chunk of data is required. This is how I've successfully trained clients who have data files up to 10Gbytes in size to handle their data in easily written Python scripts.
Posted by gje at 06:20 AM | Comments (0)
June 06, 2006
Getting rid of variables after you have finished with them
If you've finished with a variable in your program, you can usually just leave it "in situe" and it will be destroyed and the memory it occupied will be released when you exit from your program. In many languages, variables within named blocks of code have an even shorter "shelf life" - by default, a PHP or Python variable used within a function will be lost once you leave the function, and in Perl any variable described as a "my" variable will be lost at the end of the block in which it is declared. There *are* exceptions - if a variable reference is copied (Perl or Python) and / or if a PHP variable is declared as being static to name just a couple of examples.
But what if I've got a long-running program and I want to release the memory that a variable occupies once I've finished with it? Most languages support TWO ways of getting rid of variables:
a) You can set the variable to being empty. In this case, the variable name still exists but it contains no data, so what might previously have been a memory hog is shrunk to virtually nothing
b) You can actually remove the variable name itself from the symbol table, so that the very name ceases to exist.
If you would a metaphor - if you consider that a variable is like a cage that contains animals, then setting the variable to empty is like getting rid of the animals, and removing the variable is like destroying the whole structure of the cage.
Python
To set a variable to empty, assign None to it:
queue = None
To destroy a variable, use the del keyword:
del queue
Perl
To set a variable to empty, undef it:
undef @queue;
To destroy a variable, you may be able to use delete (but this applies only to hash members and as from Perl 5.6 to list members too:
delete $queue{"X72"};
PHP
To set a variable to empty, assign 'nothing' to it, for example:
$?queue = NULL;
or $queue = "";
To destroy a variable, use unset:
unset($queue);
Tcl, Tcl/Tk, Expect
To set a variable to empty, assign an empty string to it:
set queue ""
To destroy a variable, use unset:
unset queue
Please note that under most operating systems, memory released by emptying or destroying variables will be available for re-use by the current process, but will NOT be released back to the operating system until the process terminates. This applies to all languages, not just the ones I've highlighted in this article, as most operating systems aren't built to handle memory returned to them by shrinking processes.
Posted by gje at 09:27 AM | Comments (0)
The Fag Packet Design Methodology
Old fashioned engineering - in the Midlands of England. Imagine the scene as some widget or other was designed at the turn on the last century. Chimneys belching smoke out over the "Black Country", and workers belching smoke out from their Players, Marlboro or Senior Service.
I've oft heard the term "it was designed on the back of a fag packet" used (American readers - please note that a "fag" is a cigarette here in the UK), and used with a degree of admiration ... often the complete phrase is "it was designed on the back of a fag packet and it's still in use, and working well, today". And there's good reason that a "fag packet" design should work well. Let me explain.
A cigarette packet is small - the clear space on the back is - what - 3.5" x 2"? And in that space, and diagram / design drawn could only be a simple, clean structure as there was no space for anything more. Smoke another pack of 20 (this post is NOT a serious suggestion that you smoke, as smoking can damage your health, that of your unborn baby, and that of those around you), and you can then take one of the components on your original design and expand that part of the design in a further level of simple, clean structure. Go on in the same way until your design is complete. The fag packet method is a great encourager of structured design ...
Posted by gje at 05:33 AM | Comments (0)
Domain Listing Center and Domain Registry of America
Have you ever received a letter from the Domain Registry of America, inviting you to renew your domain registration with them? Don't - it's a scam. They're just another registration agent, and an expensive one too, who try to trick you into signing up for their services with what looks like an urgent final demand. Much better to renew, when the time is right, via the folks who set your domain up in the first place and who, for most of us, will also be hosting that domain.
A new scam along similar lines hit my email box yesterday - this one from Domain Listing Center Inc, again based in Toronto, Canada. FINAL NOTICE it shouts at the top, and it looks like an invoice for $75. Tiny text at the bottom states "This is not a bill. This is a solicitation ..... In my opinion, it's another expensive scam - this time to get you to buy their search engine submission service. I'm not interested, and I suggest that you shouldn't be either.
Here's what the email looks like:

Personally, I always smell a rat when I see ... no telephone number ... no link to further details of the service being offered ... and the email comes from a Yahoo address. Come come, shouldn't a domain listing center have its own domain and website ;-) ??
Posted by gje at 03:59 AM | Comments (1)
June 05, 2006
Python modules. The distribution, The Cheese Shop and the Vaults of Parnassus.
What if Python doesn't include a class / method that you would like, but you've got that feeling that "surely someone's done this before"?
1. They probably have
2. They've probably made it an available 'Open Source'
3. It's just a question of you knowing where to look!
Where to look ...
a) The built in modules
There's a wide range of Python modules supplied with the standard download that need to be loaded using from or import statements. Start at the Global module Index for these.
b) The Cheese Shop
Contributes modules, not a part of the distribution as they're dealing with specialised or fast-changing technologies and subjects, but maintained on the Python site. See the Cheese Shop Index to start searching.
The Cheese Shop is so named because of the Monty Python Cheese Shop Sketch
c) The Vaults of Parnassus
Contributed modules were for many years maintained at the Vaults of Parnassus, and 'the Vaults' remain an excellent source of more mature modules.
"The Vaults" are named after Mount Parnassus in Greece .. in turn, named after Parnassos, the son of the nymph Kleodora and the man Kleopompous. Read all about the mountain and the mythological background at WikiPedia's Parnassus page
Posted by gje at 02:44 PM | Comments (0)
Useful link: Python training
We can offer a room, but we can't operate on a dog
Our first weekend, probably of many, working on "Well House Manor". The previous owner finally completed her move out on Thursday, 1st June, and we had vacant possession from that afternoon.
We wish her all the very best for the future, and appreciate her gestures such as the flowers left to wish us all the best. We also very much appreciate the paperwork that goes with the place.
What gems have we discovered from the new papers? More about the issues of neighbouring trees, planning applications for the conservatory and extra bedrooms, and also for the forbidding, view-blocking wall that fronts the main road (and goes under our planning application. That the place was formerly called "Linken" - which I'm pretty sure came from the first three letters of each of the owner's forenames, and that when sold in the late '70s by the vet who used to practise there, he added a stipulation to the sale that it should not be used as a veterinary practise by the new owners. I suspect that nothing was further from their thoughts; it's certainly not part of our thoughts, which makes the question of whether or not we would be bound by the condition to be pretty academic.
Well House Manor, pictured here just after we took over. A year or two back, plans were to knock the place down and build some 20+ housing units on the site. So although the gardens were being kept nice, there has been little investment in recent years in them, and they're looking tired and a bit scraggy ... slipping paving stones, rock plants growing out of crevices, and so on. Most of the trees are fine but in need of a little trimming back - several of the neighbours are less than happy with their effect and putting ourselves into their shoes, I quite get their point. And a tiny proportion of the trees are beyond their useful life or in the way of access off the road to the level required by the county (and endorsed by ourselves) to a level that's safe and appropriate for a small hotel.
Inside, the decor is dated too. Much was redone in 1979 and had become life expired. A major clean down and redecorate as a minimum is called for. I wondered whether or not I should post pictures here - they're hardly encouraging for future guests at the hotel but for history's sake, here are a couple to give you an idea. It seems incredible that this room, this bed was in use by paying guests up to the May Bank Holiday, 2006 - that's just a week ago. And our last delegate (under old managements) stayed just 3 weeks ago.
There's a huge potential here - perhaps you can already envisage, as we can, the use of this room pictured as the breakfast / dining room? It looks out over the back / onto a patio and will seat all of our guests comfortably. It's a bit of a shell at the moment, but I'll come back to here in months following and post update pictures.
Some 9 of us were working at Well House Manor this weekend ... and the place is so big we could easily have accommodated the same number more again. Wallpaper, carpets, and fitted cupboards have been stripped from six bedrooms. Kitchen and Utility Room have been partly stripped back, and some stud walls / coverings removed or peeled back to give us further insight into what needs to be done. In many areas, there's encouraging news that the scale of works may not be anything like as great as was expected, and seeing thing under the surface and on the ground without the landlady hovering has been enlightening. Well - actually the landlady HAS been hovering, but that's Lisa now ;-)
Posted by gje at 05:38 AM | Comments (0)
June 04, 2006
How to debug a Perl program
Have you every written a Perl program that doesn't perform as you would wish? Yes, everyone who's written a Perl program has done that. Once any syntax errors have been corrected, you run your program for the first time and you check - VERY carefully - the results. Any errors, and the patterns of errors, will often lead you quickly to coding errors and as you gain experience, you'll fix more and more bugs quicker and quicker this way.
But what about those 'reluctant' bugs - those things that have you scratching you head thinking "surely this cannot be happening". You need further clues, and Perl offers a number of facilities - some very simple - to help you.
1. You should run your code with the -w command line option, or with
use warnings;
specified at the top of your code. Both of these operations cause Perl to check at both compile and run time that you're not specifying something that's technically valid, but unlikely to be what you intended - it'll pick you up on uninitialised variables, variable names that only occur once, bare words that should probably have a $ in front of them, and so on.
2. The humble print statement can be very revealing - add in a few extra output statements for intermediate variables and you'll soon start to see where abouts in your code its behaviour starts to deviate from what you had intended.
3. The Data::Dumper module allows you to "pretty print" data structures if you want to go beyond the print statement - perhaps you have whole lists or hashes that you want to dump out? (Link - source example using Data::Dumper)
4. Perl comes with an interactive debugger - run Perl with the -d option if you want to run this way. There's a tutorial on this in the perl distribution - run perldoc perldebtut at the command line for more details.
If these initial four ideas don't cut it for you, there are other things to consider too.
Personally, if I'm writing a difficult piece of code I will start off with
$trace = 0;
at the top, and further down my code I'll add in statements such as
$trace and print "At point X, counter is $n, total $tot\n";
which form a report / debug facility if run; all I need to do is to switch my initial assignment to a true value, and I've turned on a tailored debugging mode. We use a similar technique on our web site pages under both PHP and Perl - where we accumulate reports using the .= operator and output them at the end of our web pages - users rarely notice and it's sometimes a huge help to us when we're looking to resolve browser specific issues or data driven problems.
Some advocates suggest that you should
use strict;
in all your code as a debug tool. I'm going to disagree. Rather, it is good practise to use the strict pragma in all .pm files that you'll be including but that should be as a matter of course and not just as a debugging aid. And I will typically omit the pragma from my main code / main program.
There's various CPAN modules to help you too - ptkdb and Devel::ebug provide a GUI to help debug, and programatic hooks for you to add your own debug facilities, if that's what you want.
And finally, there are commercial debuggers such as ActiveState's Komodo.
My own favourite toolkit - what I suggest to course delegates ...
a) Comment your code well, use sensible variable names to reduce bugs in the first place.
b) Think about your code - design it well (if informally) with appropriate UML diagrams to reduce design errors in the first place. (Link - .pdf training module on this)
c) Run with the -w command line option at least a few times.
d) use strict; within modules.
e) Add in print or Data::Dumper calls, perhaps under a $trace option, if you've got a piece of large / complex / reluctant code.
The other options? Great to have them available from time to time ...
Posted by gje at 07:37 AM | Comments (0)
Useful link: Perl training
June 03, 2006
A visit from the solicitor
Yesterday, finally, we took over vacant possession of "The Old Manor" - henceforth to be Well House Manor. Regular readers and friends will know that this has been a long time in arriving, and that we now have months of work to do converting a B&B with a backlog of upgrades and maintenance into a business hotel, fit for our training courses and delegates.
The first picture here is a "before" that I snapped yesterday. Not strictly a "before" as we already have communications in place - wireless broadband, phone and even TV in "The Cottage" that will become our luxury suite.
Our solicitor - who had helped smooth through the transaction - dropped by to see. Just a courtesy call as he's made a real connection with 'this one', and I have to say that I have been happy with how he has helped and advised - I would point others to Howard at Sylvester Mackett. It was very interesting to hear some of this comments / ideas / suggestions too - another idea and view on some of the elements.
The arrival of a skip to help up with some clearance emphasises how overgrown parts of the garden and the entrance driveway are, and how much we have to do. Indeed, the previous owner had been delayed in her move out by over 24 hours because the removal van couldn't get it. But our skip driver was made of stern stuff and drove within inches of the outbuildings in order to get around with minimal tree damage. Ah - but that all should get so much easier from Monday when some of the tree work starts.
Inside, our task is massive. We've started stripping back in a couple of rooms, and we're having a work party up there today. In this view, you see Lisa taking early steps in converting a kitchen area into a customer lounge. The paper on the walls is old, somewhat caked in grease in that room, and it's the first of many we need to tackle.
Indeed, I ought cut short my post and head for "The Manor" now ... updates to follow!
Posted by gje at 07:51 AM | Comments (0)
June 02, 2006
Last week - picture of the Perl course
Perhaps you've been reading my blog describing the two Perl courses that I ran in the Middle East over the past couple of weeks. A new part of the world for me - a whole new continent to add to those that I've already visited on business, so I prepared as best I could. I do wish to add a note of thanks to one of our customers who's become a friend for his guidance on Saudi protocols - Adam - THANK YOU SO MUCH.

One of the elements that came prior to my trip was a caution about people not liking having their pictures taken, and so during the second week I was very tentative when I asked if I could picture the delegates during practicals.
Pictures don't catch the warmth of personality in people, do they? I look back and smile at each of the individual pictures that I took and know that here's someone whose company I would love to enjoy again.
I was surprised but delighted when a group picture was suggested at lunchtime. The lighting in the restaurant was more designed for eating than photography (as you might expect!), but here's a picture that did come out with me seated amongst a group of the delegates.

27th to 31st May, 2006
Perl Programming Course, Dhahran, Saudi Arabia
For delegates from Aramco
Posted by gje at 06:08 AM | Comments (0)
Useful link: Perl training
June 01, 2006
Finishing up in Dhahran
The end of a long two weeks ... I'm writing this blog in the reception area at the Dhahran International hotel, ready for posting after an overnight flight back to the UK. My car arrives in about 60 minutes ...
Today has been spent shrinking. Clothes and possessions gathered this morning and fitted back into suitcases - they fit easily, rattling around as I don't have ton of delegate folders and I'm hopeful to NOT get stung for being heavily over weight at Bahrain airport. But we'll see. And after the course, my laptops, backup CDS, books all shrunk back into my handluggage.
So what's my impression been of Saudi Arabia? A country where everyone is very polite and there are some lovely people; get to see the person (man) within the national dress and you've got some great people. But it's a culture that's very different to that which I'm used to. I feel myself overserved by wait staff; I went back to the training room to grab my camera at lunchtime today, leaving my half eaten dessert on the table. "I'm not done with that" I said to my delegates and the hover-waiter, hoping to come back to it. But, alas, another hover-waiter had cleared it when I got back and hover-waiter #1 was falling over himself in apology. Personally, I would have much preferred to have simply had them laugh it off.
Place wise? Can you believe that I've not strayed from the hotel? I'm told there are some interesting caves and geysers 150 km to the North, a nice beach at Half Moon Bay (but it's too hot there at this time of year), and some nice shopping malls ("if you like women's things and window shopping") not too far away. But I have been warned that I would probably be alright at the caves but a trip there with my wife, if she was in town, would not be recommended. And that the malls are frustrating as all the shops chuck you out for 30 minutes at prayer time - that's five times a day. Somehow, straying out into the 40 degrees (C) temperature in this arid land, alone, didn't tickle my fancy and I didn't fancy hiring myself a hover-driver to take me around.
Would I come back? Yes, I would. And there may be a chance of further groups for training, or for advanced course(s) for the same groups. The hotel's been fine for me but the group has been critical. Yes, it IS old and the AC in the room wasn't really coping with all the kit. The wireless internet connection turned into a useless internet connection for about 48 hours, and the buffet, though beautiful for a day or two, began to look too much of the same after ten or twelve.
It'll be good to be home in England in the morning.
One final thought - ladies, I've often wondered what it is you see in shoes. I've always felt that they're just foot coverings. But now I understand as I sit here in reception, watching all-black face-enclosed ladies passing by, the only sign of elegance being those high heeled, pointed toe, shinily polished shoes pointing out from underneath and clicking along the floor as they walk.
Posted by gje at 01:02 PM | Comments (1)