« August 2007 | Main | September 2007 »

August 31, 2007

Tktable - Laying out data in a matrix - Tcl/Tk

There's a very common requirement to tabulate data within a GUI, but neither Java (in awt) or Tcl (in Tk) had the facility built in from "day 1". In Java, you now have Jtable within Swing ([example]) and in Tcl you can use a Tktable.

Although Tktable isn't part of standard Tk, you'll find it as a part of most distributions these days, and if it's not in yours, you can download it f.o.c. from Sourceforge. Right - enough of the basics. Here'a an example

Which is displayed from a very simple sample program which we have written - full source code [here] and I then added data within the table as it's interactive. The output produced is as follows when we press the "Save as text" button.

earth-wind-and-fire:~/aug07/tkk grahamellis$ wish tkt
Data is 14 rows by 8 columns
{Melksham - London} 1,1 - 2
{Melksham - Reading} 1,2 - 2
{Melksham - Gloucester} 1,3 - 2
{Melksham - Swindon} 1,4 - 2
{Melksham - Bath} 1,5 - 4
{Melksham - Chippenham} 1,6 - 2
{Melksham - Melksham} 1,7 - -
{Frome - Swindon} 5,4 - Yes
earth-wind-and-fire:~/aug07/tkk grahamellis$

Here are the highlights from that sample program:

package require Tktable
We load in the Tktable optional package as required

array set cells {
0,1 London 0,2 Reading
0,3 Gloucester 0,4 Swindon ...

The cells are populated from a (sparse) array with the element names being row, column pairs

table .mytab -rows 14 -cols 8 -variable cells
pack .mytab

Create and pack a tktable widget. Lots of options can be used, but I've just put a minimal few important ones in here to keep the example short and sweet.

proc SaveTable {} {
global cells;
set Rows [lindex [.mytab configure -rows] end]
set Cols [lindex [.mytab configure -cols] end]

The action command when the "Save" button is pressed; it starts off by grabbing the number of rows and columns (which it then loops through) - and the number is slighly awkwardly on the end of a list returned by the configure option on the tktable widget.

for {set r 1} {$r < $Rows} {incr r} {
set rowname $cells($r,0)
for {set c 1} {$c < $Cols} {incr c} {
set colname $cells(0,$c)
set cellname "$r,$c"
if {![info exists cells($cellname)]} {continue}
puts "{$rowname - $colname} $cellname - $cells($cellname)"
}
}

This is a "classic" loop going through each row and each column and reading the data from the tktable back. You'll note that I used an info exists to ensure that my program didn't crash when I hit a cell that had not been completed.

We cover Tcl programming on our Tcl programming course and then Tk on our Tk Course. Tktable is one of many widgets we introduce you too - there's something of a pattern, so that once I've taught you one, you can learn the others vey easily from the documentation and the knowledge I have imparted. Oh - talking about documentation and further examples, you might like to have a look at a much fuller example published elsewhere

Posted by gje at 01:26 PM | Comments (0)


Related topics: via article database
More about Graham Ellis of Well House Consultants
Useful link: Tcl training

August 30, 2007

GUI design - Sketch it out first! (Java / Swing example)

"A picture paints a thousand words" ... and so it is when you're planning a graphic user interface, and implementing it. Yesterday, I picked up an old example of a dialer written in Java - you can see the actual window it generates on the right - and was looking to work out how it hung together.

A JFrame called Dialer has a Container called cp contains two Swing Jpanels called upper and lower, which are layed out with gridLayouts. Upper contains 3 components - Jlabels, one of which has no name and the other is called Result, and a JButton called OK,

The lower JPanel contains a further 12 JButtons, each of which has a temporary name of current assigned to it as its being defined ....

I did say that "A picture paints a Thousand words", didn't I? All this is shown in the diagram to the left. If you would like to see the source code, its available in full here

Posted by gje at 04:36 PM | Comments (0)


Related topics: via article database

Useful link: Java training

August 29, 2007

Java - Client side applet applications as well as server side

Java started off as being a client side language - and our first (1996) course concentrated on Applets and the awt - Abstract Windowing Toolkit - to which Swing was added quite soon. But Applets took off slowly, whereas Servlets - Java as a server side language - grew by leaps and bounds and our courses became much more focused on that market. "If you find a Java course that's covering Applets to the exclusion of Servlets, it's a fair bet that it is OLD" I have said.

However - there are exceptions. Applets have not gone away - they've been swamped by Servlets (and JSPs and Struts and Spring ...) but they're still around, and it was a pleasant change for these last couple of days to be back with a graphing applet that I wrote a long time ago ... but is still just as effective.

The HTML page of my demo is in a file called starling.html and the source of the Java class is in here. I've got it all compiled up / loaded on our server and if you have a Java Plugin that's reasonably recent, you can run it here.

Posted by gje at 06:32 PM | Comments (0)


Related topics: via article database

Useful link: Java training

August 28, 2007

Well House Manor appoints a General Manager

I'm delighted to announce the appointment of Chris Ellis to a new role as General Manager of our Well House Manor hotel ([Link]).

Chris joins us from Ladbrokes where he has worked for a number of years in customer-facing roles -- joining them as a rookie clerk, then rapidly rising to senior shop manager. His job there involved all the day-to-day responsibilities of running such an establishment, by looking after his customers, making the best use of his staff and keeping them working as a happy team. He not only managed the shops, but he rolled up his own sleeves to work side-by-side with his staff. Chris's role also included responsibility for the IT systems in store, and he was very much involved in the marketing by building up of the business in his locale, and recognised with an award for his efforts.

As General Manager of the hotel, Chris will look after the administration and operations of the hotel. We're a small business with only a limited number of staff sharing a lot of roles, and Chris will also be taking on work in a wide variety of other areas mainly (but not exclusively) associated with the hotel. The rapid growth of the hotel's trade since we opened for general bookings earlier this year, and the ongoing strength of our training business, has stetched the resources we have had available. I will personally be able to dedicate more time now to the training business, ensuring that both our courses and accommodation remain so good that they continue to sell themselves by word of mouth, with our customers being our ambassadors.

I'm sure you'll join me in wishing Chris a long and happy time with Well House Consultants.

Posted by gje at 11:34 AM | Comments (0)


Related topics: via article database

August 27, 2007

Easy handling of errors in PHP

How often have you written a piece of code that's a "spike solution" - it works well on good data - and then spent just as long as you took to do most of the work in fixing errors? I know I have!

These days, I plan my error strategy from minute 0 of hour 0 of day 0. "How to handle errors" is a critical part of application design and ... here's how I do a lot of it in PHP.

a) Set a variable (e.g. $error) to 0 at the start of the code.

b) Whenever an error is found, $error++ and perhaps add a message to $errstr, both of which are global variables declared in all functions that can throw an exception.

c) When the analysis logic is completed, decide whether to display the next screen or recycle the current one with a simple if ($error) test.

Gone are the days of ....
if ($_POST[month] < 1 or $_POST[month] > 12 or $_POST[day] < 1 or $_POST[day] > 31 or (not eregi( '^[A-Z]{1,2}[0-9]{1,2}[[:space:]]+' ,$_POST[postcode])) or (not ereg( '[[:digit:]]{4}', $_POST[phone])) or (not ereg('@',$_POST[email)) or $startdate < time() ....
.... Thank Goodness!

Posted by gje at 06:49 PM | Comments (0)


Related topics: via article database

Useful link: PHP training

August 26, 2007

Flash - is it available to your web page?

We're "flash enabling" some of our web pages .... while at the same time retaining the default pages, seemlessly, for anyone who's not got Flash installed or has an old version. I've been doing some research on the subject and ... separating out the wood from the trees, I'll present you a link to the really vital stuff so you can do it yourself. The method is to use a piece of Javascript to sense which plugins you have; an extended method (link in my source) lets you try to do the same thing on boxes that don't have Javascript either ....

Links to a running demo and to the source code for that demo. It's early days of learning for us on this subject - the Flash demo reminds me somewhat of why the blink tag was removed from HTML as I write this article,, but I know I'll have another version of the movie available in a few hours which will be a "plug and play" replacement.

Posted by gje at 11:53 AM | Comments (0)


Related topics: via article database

Resetting session based tests in PHP

I was writing and testing a PHP session based application - one in which a series of pages are linked together to make up a complete system - yesterday. And as ever with testing, bugs were found in the code and other things had to be added that meant it needed to be changed.

But it's rather different changing a session based applicaion between pages - in essence, you are modifying an application while it is running and that means that variables you need may not be set, and variables may be set when they should not be. And it almost certainly won't start testing back at the beginning.

The first options to solve the issue is to clear out your session cookie - probably called PHPSESSID if the application is in PHP - and start again. But that can be a lot of fiddling with the browser, and can result in other cookies that you would rather retain being lost. Here's an alternative I came up with - my page has a $_SESSION[current] variable through which I remember where I am in the task. And I simply added the "reset line" to my mode below.

if (! $_SESSION[current]) {
  $current = 0;
} else {
  $current = $_SESSION[current];
}
if ($_REQUEST[reset]) $current = 0;

And I can now restart my application (subject to remembering that not all of the old variables may be cleared!) by adding &reset=1 or ?reset=1 onto the end of the test URL.

Posted by gje at 07:23 AM | Comments (0)


Related topics: via article database

Useful link: PHP training

August 25, 2007

Perl for Larger Projects - Object Oriented Perl

Perl is a powerful language for short utility scripts - AND a powerful object oriented language too, which is great if you're going to be writing longer applications and / or a suite of programs with shared code.

We run a general course that introduced Perl for everyone and also a more advanced course for those who will be using Perl for larger projects. And one of the important aspects of that latter course is to cover how you use objects and write your own classes in Perl.

If you've never written your own class before, even the concept can be a bit daunting ... and most of the examples that you'll see will be less than short - after all, OO programming is at its best on the larger applications. So that make it quite a challenge for me to teach, given that I don't have the luxury of the longer time scale that you would have as you're actually writing a larger project. So ... here is - perhaps - one of the shortest demonstrations of a class definition and use in Perl:

package animal; # Define a class
# This is a demo! Would usually be in a separate
# file so that it could be brought in to a whole
# lot of different programs!
 
sub new {
  my ($type,$breed,$weight,$cpk) = @_;
  my %beast;
  $beast{breed} = $breed;
  $beast{weight} = $weight;
  $beast{cpk} = $cpk;
  bless \%beast;
  }
 
sub getvalue{
  my %beast = %{$_[0]};
  return $beast{weight} * $beast{cpk} / 2.2;
  }
}
 
$ermintrude = new animal("cow",2000,4.75);
# What's happening inside is:
$pinky = animal::new("animal","pig",600,1.70);
 
$val_erm = $ermintrude->getvalue();
# That's the equivalent of
$val_pink = animal::getvalue($pinky);
# BUT the first syntax only works if Perl knows what
# type of object is in $ermintude via a "bless" call.
 
print "They are worth $val_erm and $val_pink\n";

The idea of an object is that we can have a variable containing not only a number or a string, but also a piece of data that we define ourselves - in this case an "animal". And then we can define the operations that can be performed on an animal - our simplest case just allows creation and a "getvalue" operation which tells us how much the animal is worth. When you think about it, you've probably used exactly the same principle in the past with a file handle - which can be created, then read, written and closed.

The actual definition of the object is in a "package" of the same name as the object type (an object type is called a class), and as you'll usually be using each type of object you create in many different programs, it's usual to put it in a file on its own and bring it in with a use. Also because you design objects once and use them many times, the class definition many appear a bit complicated (certainly beyond the scope of today's short article) but the use should be trivially simple - thus
$ermintrude = new animal("cow",2000,4.75);
says "create me an animal in the variable called $ermintrude" and
$val_erm = $ermintrude->getvalue();
says "get me the value of the object held in $ermintrude and save it to $val_erm.


Posted by gje at 03:16 PM | Comments (0)


Related topics: via article database

Useful link: Perl training

Customer feedback - lifeblood of a business

I'm going to share here a forum posting I just made in an obscure corner of the net concerning customer feedback, where a cynical poster (he may have been right to be cynical) was worried that his inputs were not being taken seriously. "But that doesn't mean it will do anything about them" he wrote.

My comment ....

True. Looking wider (beyond [company name]) I have come across a number of organstaions looking for customer feedback and consultation inputs over time. The range from the "crocodile tears" of "We didn't really want your input - but thank you". Through the "We have noted this and are sorry" which - sometimes - people just want to blow off. And - it seems all too rare - "Good idea, we'll do that".

I run a business. I solicit customer feedback - and I solicit constructive criticism.

Most of the reviews we get of our hotel and our training courses are positive - so positive that we call them "Torvill and Dean"s and they give a warm and fuzzy feeling, put a spring in the step and motivate. But they do NOT help us step forward; they give us nothing to work on.

Reviews that say "have you thought of doing xxx" are great - MUCH more useful. But very rarely do they give us new ideas; chances are that we have already heard in a number of times before, and that we have probably taken a careful look at the idea. Sometimes it will just be impractical. Other times it would cost too much. On further occasions we don't have the resources, or doing "xxx" would mean we would have to stop doing "yyy" and upset far more people. And yet ... frustrating thought it might be for contributors, and much though they might feel they're not being taken seriously ... this input is so valuable. We can and do pick up on fresh good ideas. We do continue to review based on the weight of various requests and a changing balance and market can lead to a change in what we do.

When I was running the technical end of a software company, writing standard software for multiple customers, we had what I called a "WIBNIF" list - "Wouldn't it be nice if". And onto that list we added ideas that came from ourselves and our customers. For sure, some things got deleted quite quickly but ongoing it formed a major reservoir of forward looking thoughts for each new release - not only allowing us to plan the next release, but also to look multiple releases ahead and not put something in place that closed doors that clearly were required to open in a year or two's time. I have always been very impressed by the [company name] communications systems - they seem to all speak from the same hymn sheet (or word processor?) and I would be suprised if they didn't have a WIBNIF list too.

Do we have a "WIBNIF" at Well House Consultants? Well - we keep ALL course reviews on file, and we enter them electronically as a valuable source of marketing. And we do look back at them. We do not - at the present time - have a specific "WIBNIF" list condensed from them and updated based on our own inside knowledge and judgement too - but that's more of a question of how we store that data rather than whether we collect it at all.

Posted by gje at 09:15 AM | Comments (0)


Related topics: via article database

August 24, 2007

Well House Manor - feature comparison against the old place!

It's now over a year since "The Old Manor" B&B, which used to operate from the same premises as Well House Manor, closed its doors and we bought the building for our new venture. Although we changed things very quickly and opened with new facilities and new everything else in just four months - upgrading from B&B to Hotel, from domestic to business standards, it seems that the previous owner's publicity has been tardy to the same degree we were prompt. (Click here to see if the site is still up as you read this article)

In order to answer "what has changed" I present you with these pictures (from the Old Manor and Well House Manor web sites):

And this checklist, going through the previously advertised features and how all but one of them has been updated to meet our business customer needs:
* Delightful B&B accommodation NOW Superior accommodation
* En-suite facilities available NOW all rooms, not just one
* TV in all rooms NOW all 26" flat screens with 50+ channels
* Tea and coffee making facilities NOW in all rooms
* Ironing and Hairdryer available NOW in all rooms
* Children welcome over 2 years old We cannot accept children under the age of 14; our insurance does not allow it, and business guests often prefer it that way
* Ample off road parking available Now plenty of space to turn, and cars do not block each other
* Non-smoking Unchanged inside. But we do have a sheltered area where you can smoke
* accommodation 12 miles from Bath There are some things we cannot change!

Features / facilities we have added - these are things for which no equivalent was even advertised:
* Broadband Internet access (wired and wireless) throughout
* We now also accept payment by credit and debit card
* Public access "Internet Cafe" machine and printer
* Meeting / conference rooms available
* Come and go anytime with secure key cards
* Complimentary collection from / return to Melksham station
* Minifridges in all rooms
* Personal safes in all rooms
* Central tea and fresh ground coffee in lounge
* Customer library
* Microwave oven, crockery and cutlery available for guests use
* Each room has umbrella, bottle opener, etc, for your use
* Breakfast from 07:00 daily / breakfast trays for early departures

Features / facilities which are amended:
* All rooms are now double or twin (but we will let as singles)
* Maximum room occupancy - 2 guests (no family room)
* We provide a superior cold buffet breakfast rather than traditional
* Our room rates are £80.00 for a single, £95.00 for a double
* Our rates include use of everything listed above except the conference facilities.
We do strongly dislike businesses who list a low price to tempt you in then start adding extra charges for things like Internet access which cost them very little.

Oh - and we have a freephone booking and enquiry line - it's 0800 043 8225. Calls to this number will cost the line owner nothing from a UK landline. Number available daytime, evenings, weekends ....

Posted by gje at 04:19 PM | Comments (0)


Related topics: via article database

August 23, 2007

2008 course schedule - Perl, Python, PHP, Linux, Java Deployment, Ruby and more

It's nearly the August Bank Holiday ... and the time of year when our minds turn to scheduling courses for the next year.

For 2008, I am proud to present:

Every 8 to 12 weeks:
Public courses in PHP, Python, Linux, Perl and Apache/Tomcat.

Three or four times in the year:
Advanced public Perl and PHP courses, MySQL, Ruby, C, C++ and Tcl/Tk.

For delegates who will be deploying Java based applications on a Linux Server, using Apache httpd and Apache Tomcat servers, we are offering our complete Deploying Java applications on Linux and Unix course three times through the year as a public course - covering the Linux/Unix introduction courses, a day on Java and Java tools, and then our popular httpd and Tomcat configuration course. You may arrive on Monday morning knowing little of no Linux and web server configuration ... but you'll leave o Friday evening having set up a complete server with all the components installed, and robustly linked together too.

Technologies move on. Our Perl course already looks ahead at Perl 6 as well as the Perl 5 that most users are sticking with at the moment, but that will drift over in due course. Tomcat, where we started training on Tomcat 4 is now at Tomcat 6, and Java has moved from 1.0 (which we were using in the last Millenium) through a whole series of releases and numbering schemes to Java 6. PHP has steppe d on - 4, to 5, now to PHP 6. All of our courses are updated as appropriate, although in reality Open Source programming languages change less quickly than some other technologies. So the descriptions you see are subject to change to keep them relevant, and indeed there could be more substantive changes by Autumn of 2008.

Prices for courses booked to be taken in 2008 will remain on sale at 2007 prices until the close of business at the end of 2007 - that's 350.00 for the first day and 250.00 for each subsequent day, with a hotel room at Well House Manor adding just 60 pounds per night if you're too far from our training / conference centre to commute daily. Other things remain unchanged too:
* A maximum of 8 delegates per course
* Course written and presented by our own staff
* Custom fitted, excellent facilities
* Bring along your own data and questions for practicals
* 1 delegate minimum. If you book, you know the course will run.

There's a full list of courses in the order they will run here ... or if you want so see a graphical calendar it's here for the rest of this year and here for next year. Look on these diaries for Green dates if you would like me to run a private tailored course for you on any of our subjects or combinations.

Posted by gje at 11:47 AM | Comments (0)


Related topics: via article database

Useful links: Python training, Linux training, Ruby training, Perl training, PHP training, Java training

Filtering and altering Perl lists with grep and map

In Perl, you can process whole lists (arrays) in single operations - and that's very efficient at run time as it avoids the needs for loops, and the needed for Perl's Virtual Machine to go back to the byte code (in effect source) for each member.

The map function applies an opertion to each member of a list, and returns a list of the same length, with each element duely mapped. The input to the transform function is $_ - so with embedded calls to functions like uc there's no need to specify it. But if you're going to take 1 off each member then you'll find $_ turn up in the code.

The grep function applies an operation to each member of a list, and returns the member unaltered for inclusion in the output list if the result is a true value. Otherwise, the input member is not included in the output list. So the output list from grep is going to be shorter than the incoming list, but the members themselves won't be modified.

@numbers = (10,30,40,33,45,32,43,22);
 
# Subtract 1 of each member of @numbers
@numbers = map($_-1,@numbers);
# Return a list of all numbers that are possible days of the month
@digit = grep( $_ <=31 ,@numbers);
 
print ("@digit\n");
 
@people = ("tim","steve","JASPER","DaVeY");
 
# Force all input members to lower case, then capitalise the first letter
@people = map(ucfirst lc,@people);
print "@people\n";

Posted by gje at 11:14 AM | Comments (0)


Related topics: via article database

Useful link: Perl training

August 22, 2007

Two years of campaigning for a train service

It's two years ago this month that I saw a letter in the local paper suggesting that the train service across Wiltshire was to be withdrawn at the end of December 2006 ... and felt (as a user of the service, and someone who's job heavily depended on other people arriving on it) that I should take a further look at the situation. At that stage, the jury was out as far as I was concerned as to whether or not the service justified being retained or enhanced, or whether the decision taken by whatever authority was the right one in the broad picture of things, in spite of the personal effect it would have on me.

What did I learn? Early on, I learned that the current service had been growing dramatically (I could have suggested that, based on what I had seen, but I was given figures by the Rail Regulator to back it up). I learned that the current service had been an unwelcome guest at its northern terminus at Swindon, with the operator of that station - the First group - doing little to help traffic on the line to salisbury and Southampton. And I learned that the operating company - Wessex Trains - had been so cash starved that publicity was sporadic. In fact I learned that it was something of a miracle, brought about by the necessity to travel the route and the abject unsuitability of other public transport alternatives, that it was growing as it was. That the growth was only a tiny, tiny proportion of what could have been achieved.

Was it worth an effort to have the case seriously looked at? Well - I personally came to the case after the Strategic rail authority's consultation (which few people in these parts were aware of at the time) had closed. And I was told that the case had been looked at, that it could not be re-opened, and that it was my fault that my inputs wouldn't be listened to because I had missed the deadline. Fair enough? No - not really. I spoke with others who HAD objected in time and had receive brush-offs too. I spoke with train users - regulars who were going to have their service cur from under their feet who hadn't been aware of the possibility. And I learned for the first time about many consultations - about how the end goal of the process was to gather views, and not to act in the light of those view. "Give 'em a chance to blow off steam then we'll go ahead with what was proposed in the first place". We even brought a smoking gun to light - thanks to Freedom of information, we learn how discussions had taken place in order to restrict customer's inputs to the minimum required, and how those inputs had been solicited in parallel with decisions that were being made, rather than before any decisions. Basically, the process stank so much that it convinced me that the case had not been seriously looked at, and that it deserved said consideration.

You'll notice that - at this point - I had still not concluded what an appropriate service would be. Just that a PROPER look was appropriate.

Flawed process can, sometimes, lead to a good decision. And there seemed little practical point in finding that a process was flawed, turning all the wheels to reveal that fact, only to have the wheel go full circle and come to the same findings based on a fine and upstanding re-worked process. So I found myself learning, and learning fast, all about trains - train services, train finances, train politics, train marketing, and train enthusiast and pressure groups. And in parallel learning about our home county of Wiltshire - the towns, the people, where they live, play and work and how they get between those venues. And there's a third strand too - looking forward to the future and seeing how populations, travel requirements, and facilities available would shrink and grow 1, 5, 10 and 20 years hence.

Where did this lead me?

It lead me to conclude that the 35% figure for growth supplied by the Rail regulator was unduly high - a fluke. But that the 0.8% figure used as the basis of the new service specification was unduly low - a distorted figure that forecast something different to rail growth. The growth figure that should best have been use was around 9% to 12%.

With an ongoing service at around the current level, would the growth also carry on at about 10%? Yes - it would. Based on journeys per head of population, based on surveys of potential passengers, we learned of a service that wouldn't "peak out" until it was carrying some 5 to 10 times the current passenger levels - a strong growth curve to continue. And a growth that would be accelerated with better station facilities, more reliable trains, better marketing all of which were relatively cheap options.

And so - the goals were set. (1) To get the TransWilts train service to a point where it was known about - no longer a footnote on a re-franchise of a great swathe of train services. (2) To get the future of the service seriously reviewed, with an objective of establishing what an appropriate service would be. (3) To achieve / regain, and retain, a service at that appropriate level.

Was I alone?

No. Absolutely NOT. Had I been alone in my quest, it would have fizzled out in the first few weeks. "It'll be a miracle if you can raise a meeting with 20 people" said the doubters. We raised 20. We raised 50. We packed out a 2 coach train with a three figure number last Christmas. And we raised 1700 signatures on a petition on the PM's web site - the biggest domestic public transport issue there at the time.

How was the new kid on the block received? Gosh - I was fearful of this one! I expected - and could have totally understood - a cool reception from folks who had been strong in there support for the service for many years. Yes, there were pockets of doubt and I can recall three specific cases locally; one telling me that I didn't know what I was about (true at first!!), one warning me that I didn't know what I was up against and that I would get burnt out getting nowhere, and a third intent on defending his own seat. Which I did not want anyway! That wasn't what it was about.

But in amongst those few doubters, there was the vast majority who were supporters. I dressed up in a mask and walked around the town. Advertising a Ball to raise funds in support of Cancer research - and with my train "stuff" as a sideline. No-one was very interested in the ball even though nearly every family has been touched. But everyone wanted to talk train.

I'm a bit of a WWW / Internet publicist, so I started off by registering a domain - I was surprised to get it - www.savethetrain.org.uk - putting up a site desribing the situation (and taking care not to over-sell) - and seeing what would happen. Well - today, over 37,500 different host computers have visited the site. That's over 1500 different NEW visitors every day.

I haven't - I couldn't possibly - have got to this stage on my own. There are many who have been supporting, and many who have been actively supporting. Including people who are greatly respected and in high places. And there are those who have been much more that just actively supportive too; there's such a great temptation to name names, but look around on our forums and you'll get a flavour and have a pretty good idea who some of them are. Others - "you know who you are" have also offered quite exceptional help without which the campaign wouldn't have progressed as it has done, but are readers and commenters in the background rather than direct contributors in the public space. And I'm delighted to see the team remain - with one sad exception; Gordon Dodge passed away a few months ago and is deeply missed.

Where are we now?

1. We HAVE got the service known about somewhat better. Locally with newspaper and local TV and radio exposure, local councillors and MPs and prospective MPs right along the line through Wiltshire have given (and continue to give) active support. Looking wider, the First Great Western and First Group directors, and civil servants at the Department for Transport are very much more aware of the service, the area, and its needs than they were 2 years ago when its proposed demise was a two line paragraph in a 100 page report.

2. The service HAS been looked at further. On one hand, I'm greatly impressed by some of the committment and effort that I'm told had been put in by various paties, and I'm certainly impressed by a number of individuals in important positions with the three key player organisations - First, the DfT and Wiltshire County Council. On the other hand, I'm depressed by the lack of any decent practical steps forward, and the provision of an even less appropriate service than that which was threatened upon us two years ago. It could be argued that the purpose of looking further at the service has been to "Manage our expectations" (a term used by one of the civil servants) in a downwards direction.

3. The service WAS slashed back in December 2006. Requests to run the remaining 2 trains at the most useful time of day came to nowt - with trains from Swindon at 06:19 and 18:42. 60% of trains removed. 95% of traffic lost. An act of gross vandalism. With - as you would expect from vandals - nothing done on the ground to put the wrongs right.

Strangely, there is some suggestion that even amongst the apparent lack of success quoted we have achieved something. I have heard it said that when the service was closed down for over a week last August, it might have returned in the form of a shuttle bus service between Trowbridge and Chippenham, to be integrated into First's 234 route in due course - the way certain services have been withdrawn in Staffordshire. And we are talking ...

Where do we go now?

What is an appropriate service? The case has been made - as the barest minimum - for a decent train to allow commuters from the rapidly expanding West Wiltshire area to reach Swindon for an 08:45 to 09:00 start to their day, and return after a finish at 17:00 to 17:15. That's NOT an "appropriate" service - but this additional train would be a first vital step in that direction.

An appropriate service would offer a minimum of a train every 2 hours throughought most of the day (3 hour gap at lunchtime OK) from Swindon to Westbury, either continuing on or with excellent and reliable connections to Frome, Warminster and Salisbury. And with this service increased to hourly, traffic would offer / grow such that each individual train would be busier than the individual trains on a 2-hourly service.

There are also two great myths that have been dispelled. The time the service takes is not critical to a few minutes - on this line, it really doesn't matter if it's 25 minutes or 30 minutes from Melksham to Swindon (heck - it's well over an hour by other public transport!). And the LOCAL fares, at a far lower "per mile" rate than peak main line ones, could stand an extra 2 pounds per journey on top of inflation rises ... on 120k journeys per year, that would being in an extra quarter of a million pounds - remarkably close to the extra income that the First group say they would need to make the service viable.

We have moved on in two years. It's no longer "the provision of such a service is not justified". It's now "It's not my responsibility, Guv - I support you but ask THEM". And that statement is made by Wiltshire County Council pointing at the First Group and at the Department for Transport. It is made by the First Group pointing at the Department for Transport and Wiltshire County Council. And it's made by the Department for Transport pointing at Wiltshire County Council and the First Group. So the case IS made - and admitted to be made.

---------

While I have been seated here, writing this update in the public area of the hotel in Melksham where I work when I'm in town, a retired gentleman popped in to return a computer book he had borrowed from me overnight. "Aren't you one of the chap's who's been involved in campaigning for a better train service for Melksham?" he asked me, and we got chatting.

Anthony used to use the train, but "it's only one a day now, and the timings don't suit me. I really need a train at around 10 O'Clock in the morning .... and to be able to get back late in the evening" he told me. He now uses the car. And what are Anthony's journeys? Melksham to London. He only goes a few times a year, but each trip in his "gas-guzzler" - his words - are a loss of not only a local but also a long distance fare to First Great Western.

Come on, everyone. Let's get our fingers out and let's get an appropriate service running, as soon as practical, for the thousands of Anthonys of this world who live in Wiltshire and the thousands who want to visit us. And ... that appropriate service would also be to the mutual benefit of the Dft, and First, and Wiltshire County Council too. I do love the opportunity to put a "win, win, win, win" case.

Posted by gje at 08:27 AM | Comments (0)


Related topics: via article database

Business travel by train in the USA

The choice of the train

The US is the land where the automobile is King ... and where businessmen fly from city to city, State to State from meeting to meeting. So why - when we visited the USA on what was primarily a business trip last week - did Lisa and I choose to get around by train? Because (even in the USA) it seemed to make logistical sense for this trip. And because I wanted to get an international comparison between rail travel in the UK and USA ... and what better trip to use. And because the price seemed economic / sensible.

Friday, 10th August

A Rude awakening

Transatlantic flights seem to run pretty well these days, with fewer major delays than I can remember in the past, so I'll put it down to pure bad luck that we arrived at the ticket / checkin counter at Newark Airport's Amtrak station about three hours late - which equated to about 15 minutes after our train had left. We weren't too bothered - after all, there are one or two trains every hour until late in the evening on this corridor and it wasn't yet 5 O'Clock.

But the desk was unmanned. "Back a 4 O'clock" said the handwritten sign. Hmm. Automated machines demanded a credit card which we were disinclined to give them, as we were picking up pre-bought tickets, but there was a help phone on the wall. Picked it up and spoke to control. "There should be someone there" we were told and, yes, we knew that. "I'll call him". An ongoing confusion (and a mixum concerning Newark Airport v Newark Penn Central) and a few minutes later an agent had been extracted from the back room to assist us.

Our "USA Rail Passes" were duely issued. Sold to me as the American equivalent of the BritRail pass, these tickets were to allow us to ride any train in the North East of the USA for up to 15 days - and at $299 each (150 pounds) that's something of a bargain compared to buy-as-you-ride. The same incredible value is offered to USA visitors to the UK on Britrail - or rather, we were just about to discover that we had been oversold on our tickets ...

"There's no space left for you to reserve on the rest of today's trains from here" says the agent. "This IS a Friday, you have to have a reservation, and there's only so many per train for these tickets". Wonderful - 5 p.m. in Newark, speaking with a "jobsworth" who isn't really interested in offering solutions but rather in stating problems ... and a hotel booked way down in Virginia. But fortunately, I had studied the maps / timetables a bit. "Any Space on the trains from Newark Penn Central to DC" I asked and, begrudgingly, he checked. "Only on the two minutes past seven". "WE'LL TAKE 'EM!"

Now - how can we get up to Penn Central - the next stop up the line, five or ten minutes away with plenty of suburban trains and some long distances services that call at both of them too. "I can't get you on to any of the long distance trains - they're full and you're US Rail pass doesn't cover the suburban trains" ... and so it was that we found oursleves starting our USA Train Adventure an hour late, heading away from where we wanted to go, and having had to pay $7 each extra over and above our "unlimited train travel" tickets.

Newark, Penn Central

I write computer software, I train people who write computer software. And I would LOVE to train the people who wrote the software for Amtrak's ticket agents to use as they sell tickets!

We took the opportunity of 90 minutes at Newark to make reservations for the following Sunday - New Carrolton to New York Penn Central, and then New York Penn Central to Albany for the following Sunday. What a good job we had 90 minutes - I have never seen such an incredibly long process as the one the agent took to issue me with a reservation for the train we wanted from New Carrolton, and then the huge trouble he had trying to locate the ongoing train in his system. It just wasn't showing up. "It must be fully booked" he concluded, leaving me with a three hour layover in New York (great with all that baggage!) and a scheduled arrival in Albany well in the evening on a train that left two hours after I wanted, and then took longer too.

And having booked MY reservation, he had to repeat all his keystokes (though, to be fair, he left out the section of trying for the 3:45) to make Lisa reservations on the same train.

All tickets have to be signed upon issue, ID provided just like an airline flight. But I was able to present him with Lisa's passport, point to her across the waiting hall, and promise that I would have her sign them straight away and ... we had our tickets for Sunday. I'm so relieved he took pity on us and didn't have me drag Lisa up there and loose our one valuable-in-the-rush hour seat. A human face, a guy trying to do his job within a frustrating system!

Tea with the homeless

Still an hour before our train, and no food eaten for a long while. Some interesting looking food places at the station. But wandering around in the great cavern under the tracks, they're all takeaways - no where to sit, and dragging our 49lb cases with us, we're not exactly going to be Mr and Mrs Popular as we stand in line and explore all the options with the foodsellers. Ah - one's a sit in cafe; "Waiter service only" but the waiters are packing up for the day, chairs propped against tables to indicate that they're no longer open for new customers. We find seats in the ticket office, labelled "for ticketed passenger only" and Lisa heads off to one of the stalls.

It starts to dawn on me ... the seat that we're on is one of the few labelled that it's for travellers, and the others are clearly occupied by people who are not there so much for the railway facilities, but because it's somewhere that's warm and dry. Some interesting character studies to be had, for sure ... but also care to be taken that the bags and cases remain in sight and in our control. And I wasn't sad as the clock ticked around and it was time to go up onto the platform.

Denied Boarding, but a nice train in the end

Some things are the same the world over ... the 5:02 was posted, was signed as being on time, but then just as it was due went "30 minutes late". The story of our journey! The 5:14 - also going down to DC rolled in on time. Very nice looking train ... but a quick word with the conductor elicits the response that even though we have an "unlimited" ticket, that's not really the case and we are limited to travelling on less glamorous and slower trains than his.

The 5:02 drags in at - what - around 5:30; busy, but we do get in, find room for our luggage, and find seats - sleeping much of the way on the now-dark Friday evening down through Philadelphia and Baltimore, train getting quieter all the way, and so on to Union Station in Washington DC where the remnants of the passengers alight. The Amtrak carriages all seem pretty well standardised - a similar livery, a similar look and feel, a comfortable ride, airline-style seating but reasobaly spacious; we'll be in other similar trains on subsequent legs of our journey.

Across Washington DC

We're met at DC with a blanket of hot air, even at 10 p.m. at night; past experience has lead us to travel in shirt sleeves and indeed my one pullover remained in the suitcase all week. Off the train, off the platform, and down into the DC metro having negotiated the ticket machine. At $2.75 (that's just under 1.50 in UK money) for a ride all the way out to the end of the line at Springfield Franconia, it's a bargain - a fifth of what it would cost in London - and the Metro is much smoother and more comfortable as the tube, although just as crowded.

Change from the Red line to the Yellow Line, then from the Yellow to the Blue ... and you'll be in Springfield in just half an hour. Except there's a section of the Yellow line that's closed from 10 p.m. this Friday night ... so we have to make a great horseshoe loop on the Blue. Up past Foggy Bottom, across through Roslyn, and back down past Pentagon and Crystal City (what a Misnoma for a concrete cavern of a station!) to Van Doorn and - eventually Springfield. The "Great Way Round" - now where have I heard those GWR letters before? A quick call to the hotel that we've prebooked to have their van pick us up (a common USA practise) brings the news that they don't do pickups after 10:45 and ... of course ... it's now after 10:45. A final 2 miles in a taxi, and a chance to check in and collapse for the night.

Sunday, 12th August

Springfield-Franconia to Troy, up state New York

The DC Metro

A transfer ride from our hotel (we WERE in their time frame today!) and a Metro ride from one extreme of the Metro system to the other brough us to New Carrelton.

Even here in the capital of the most powerful nation on earth, Sunday is engineering works day .... and our train clearly labelled "New Carrelton" all the way along was pulled up short two stations early in an interetsing suburb of what is also one of the most violent cities in the nation and we were all dumped out onto the platform.

But engineering works don't mean "bustitution" here - they mean single track working, and the service had been sensibly thinned out to alternate trains to the outer terminus. A service that ran every 15 minutes under normal circumstances was half-hourly; not causing a conjestion problem, efficient, clearly well practised. And it looked like the works were quite major ones too. And so, on to Carrolton still in good time for the Amtrak.

Amtrak to New York

You don't wait on the platform in the USA - you wait in the waiting room. You've heard me desribe the one at Newark earlier in this article; the one on Sunday Morning was much cleaner, quieter .... and with fewer facilities. To the extent that we were tempted up onto a bare, bare platform for a boring, boring wait - no seats at all - 20 minutes ahead of time. I have been in trains calling here before and wondered about the bareness, and now I know.


An on-time train, seating together, power points at the seats, for the 3 hour ride back up through New Jersey past Newark and under the Hudson river into New York's Penn Central station. A somewhat event-free journey, but a handful of things did strike me.

The ticket checking system. Above each seat is a clip rail, and the ticket inspectors - one for every 2 or 3 carriages - come along on each major leg of the journey, collect issued tickets, and put a smaller card in the clip rail above eash passenger's head. Some are near-plain, others have station names coded into them and in spite of a few minutes idly wondering, I wasn't able to suss out the system. But I do know that shortly before passengers are due to leave, the conductor can tell in an instance who's due to leave and he clears their card.

The buffet car. "Chicken Sandwich" request Lisa. Yeah - right - that's REALLY gonna be possible! But I find the menu panel offering a Ham and Cheese bagette, and a chicken summat bap. Pictures of both, but with a big cross through the chicken. Hmm - "no Chicken today" I ask. "Yes, we have" replies the lady on the counter and I'm thinking "is this the dry British hurmour come to the USA, or does she mean it". Turns out she meant it - she went on to explain that one of her colleagues previously operating the buffet car had run out and crossed though the item with a permanent marker; well - actually she wasn't that polite about it, in fact she expressed quite a low opinion of him!

Station stops. L-o-n-g-e-r than in the UK as passengers are encouraged, airline-like, to remain in there seats until the trtain has come to a complete halt. So plenty of time to admire the platform at BWI - Baltimore Washington International Airport - and at MetroPark, where we were watching a couple, probably waiting for a subsqeuent local train, handling a teddy bear in a way that would be quite inappropriate to handle a child. The initial clutches were very private and intimate indeed ... and then they moved on to swinging the poor beast by its ears.

And so to New York ...

Posted by gje at 01:13 AM | Comments (0)


Related topics: via article database

August 21, 2007

Tratum Technologies

Lisa writes: "Suresh from Tratum Technologies phoned; he is interested in a technical partnership. 07977 487 214. Please call him back.

I reply: "Hmm. Have done.

I got an answerphone message after a long ringout and left a message inviting him to email me. So that was followed a few seconds later by a callback ("I just missed a call from this number".)

Suresh's idea of a "technical partnership" is that his company writes software offshore for us in a country where labour is cheaper so that we don't actually have to employ programmers to cover our peaks and troughs .... much more of a cold sales call that a partnership if you ask me. I suggested that to make it truely a partnership, he should also consider using our services to have his people trained, but he seemed strangley disinterested in the idea.

When I suggested that his call was misleading - that this was really just a sales call - he sheepishly admitted it. Once I asked him for his credit card details so that I could charge him for our wasted time, he told me he had a call coming in on another line and hung up to take it."

We get a lot of telephone calls trying to sell us things and Lisa is excellent at weeding them out - but just occasionally one is sufficiently obscured for it to get through the net. We're in a business where companies we cooperate with and companies we compete with can be very hard to differentiate, so it pays to err on the side of safety occasionally and follow up on some questionable calls. But congratulations to Suresh from Tratum Technologies for getting me to return his offshore outsourcing misleading sales call!

Posted by gje at 04:34 PM | Comments (0)


Related topics: via article database

Some one line Perl tips and techniques

I'm running a Perl Course this week ... a small group, so we can look at some very interesting constructs that I wouldn't normally cover / consider on a public course.

Comment out a block of code with an impossible condition

if (1 == 0) { ....

This is a great way to temporarily comment out a whole block of your code if you want to supress it for a while.

Toggle a variable between two values

$n = 3 - $n;

If $n was one before the statement, it becomes 2, and vice versa. The constant you use (3 in this case) is simply the sum of the two values you wish to toggle between.

Output an integer in binary

printf ("%b",$value);

sprintf and printf in Perl support the "b" formatter for binary - in addition to the more common "o" for Octal, "d" for decimal and "x" for hexadecimal.

All of these techniques together ...

# Some Perl Tricks
$n = 1;
if (1 == 0) {
  print "This is a comment";
  print "And so is this"; }
for ($k=1;$k<20;$k+=3) {
  $n = 3 - $n;
  printf ("%05b %2d %2d\n",$k,$n,$k); }

And when we run that:

grahamellis$ perl ppa
00001 2 1
00100 1 4
00111 2 7
01010 1 10
01101 2 13
10000 1 16
10011 2 19
grahamellis$

Posted by gje at 01:52 PM | Comments (0)


Related topics: via article database

Useful link: Perl training

August 20, 2007

What do people look for on a hotel web site?

I was wondering which pages at the Well House Manor web site might be the most popular ... so took a long-overdue look at the log files. Top hits:

1. Home Page
2. The Rooms (26 accesses for every 100 to the home page)
3. The Rates (23 accesses for every 100 to the home page)

OK - not big surprise so far ... then

4. Room 3 (23 accesses per 100 to home)
5. Availability (19)
6. Amenities (16)
7. Room 1 (12)
8. Contact details (12)
9. Room 2 (11)
10. Room 5 (11)
11. Room 4 (11)

Now I wonder why room 3 should be the most popular on the web site? We're finding that guests who return routinely ask for the same room as on previous visits, which means (I think) that everyone likes the rooms ... but in practise room 1 has a more fervent fan base ....

Perhaps I had best do no more than wonder; I could read too much into this!

Posted by gje at 06:32 PM | Comments (0)


Related topics: via article database

August 19, 2007

Callbacks - a more complex code sandwich

When you write a piece of code, you're normally putting the filling into the sandwich; there's a built-in program in your computer that controls the loading and running of the code thst you've written, and there is a whole library of standard pieces of code that you call to perform the low level operations. So thus you provide the sandwich filling.

A program as simple as
print "Hello World"
(and that will work in Perl, Python or PHP amongst others) illustrates this - the operating systen runs it, and the built in function within the language chosen deals with the detail of output.

But there are a few occasions where the mechanism gets a bit more complex - where one of the functions itself calls BACK to your code. Let's say you're sorting, but you don't want to write your own sort algorithm. How will that work? Well - you can call the sort function but then how do you tell it whether record a comes before or after record b? The easiest answer is to pass the name of a function that you've written to answer just such a question into the language's sort routine and have it callback to your code.

During last week's course, I was describing this mechanism and in order to make it clearer, I wrote my own piece of code to do the sorting ... but then took that out to use Python's own sort routine. I've posted the example up to our longer Python examples - you can see both the version that uses the callback, and my example of what really happens inside.

Callbacks are used in most programming languages, but not usually all that often. Big uses are sorting, and for even handling on GUIs (Graphic User Interfaces).

Posted by gje at 03:23 PM | Comments (0)


Related topics: via article database

Dates for Easter - 2008 to 2015

Easter Day will fall on the following Sundays:

23rd March 2008
12th April 2009
4th April 2010
24th April 2011
8th April 2012
31st March 2013
20th April 2014
5th April 2015

In 325 A.D., the Council of Nicaea ruled that "Easter shall be celebrated on the first Sunday after the first full moon on or after the vernal equinox".

The above dates are for the UK / Western / Roman Catholic Church - Greek and Eastern Orthodox Churches celebrate Easter on different dates in some years.

Why am I looking this up in August 2007? Because I'm setting training course dates for 2008, and few delegates would wish me to break up their Easter weekends with a day of Perl or Python!

Link to a calculator ... here which is said to be written in Perl

Posted by gje at 01:44 PM | Comments (0)


Related topics: via article database

August 18, 2007

Good to be home

I love travelling - meeting people, seeing places in giving courses in another country or on another continent. And so much the better when we can catch up (much overdue) with relatives and friends there. But it's so good to be home.

We arrived at about quarter past 10 this morning, local time in the UK, having left our hotel in Troy, New York State at around 2 p.m. the previous afternoon (that's Bristish time too - it was 9 a.m. their time); a long journey via Amtrak and Continental which (perhaps) wasn't the quickest and easiest way, but was a further experience. So as you can imagine, my body clock is up the swanny.

I'm consciously NOT working / turning my head to anything online today (but can't resist the odd reply and of course writing here!) ... but I have - with help - taken down a 6 metre by 8 metre marquee (much easier than putting it up!) and caught up so much with things back in the UK. Pictures, and pieced on Python, to follow tomorrow.

Posted by gje at 09:06 PM | Comments (0)


Related topics: via article database

August 17, 2007

Troy, up state New York

I'm in Troy - upstate New York, at the tidal head of the Hudson river 150 miles from the Atlantic Ocean. Troy is proud to be named after Helen of Troy, with her beauty shown on the top of a tall pillar in the town square.

Troy is also proud to be the town of origin of Uncle Sam - someone else who's name I have oft heard, but about who's history I know very little. His fine statue stands in the Waterfront park, where a military band was playing last night in the bandstand to entertain rows of "Vets". About as American as they get!

But grand though the architechure is, the old town of Troy has clearly seen better times, with some elements of our hotel - the Best Western Rensselaer Inn - leaving something to be desired. On the first evening, the door of the list shaft was propped open and we could hear the sound of running water from within; on the second day, we were moved to another room as "we'll be digging up the floor outside your room and there may be a bit of dust". On the third day, we popped back to see what our old room looked like!

Let's be fair - we're well away from the works in the new room, we have a view of the pool rather than the car park, and now that we've learnt not to ask for a shuttle before 9 a.m., to order a taxi 20 minutes before we really need to travel, and to give the breakfast time to warm up by not going down soon after it starts, we're getting along just fine. Internet access is excellent in the middle of the night, but patchy with lots of dropped connections when all the business people need to be on line at the same time - 6 to 9 a.m. and 4 to 8 p.m. And we are within walking distance of the town.

Posted by gje at 01:21 AM | Comments (0)


Related topics: via article database

August 16, 2007

Python class rattling around

"Occupany Limit 230" says the room that I'm running my Python training course - for 8 delegates - in at the Watervliet Arsenal near Albany, New York State this week. Watervliet is being "demilitarised", which means that there's a whole lot of commercial companies - including the one I'm teaching - based there, but it's still very much a military based and I'm labelled with a bright yellow badge that says "Foreign National - Escort required", and the whole place is in a high wire fence with ladies and gents in full military fatigues all around.

Building 25 was built the best part of a century ago, and the conference room proudly boasts a picture of it in early days, standing beside the Erie Canal which is now a parking lot. Otherwise the room is glum - deep purple walls, and of course the obligatory Amereican flag on a golden floor stand near the podium. Power is provided around the edge of the room only, which means that my class of 8 is arranged, U shaped and as far flung from me at the front as is possible, and I'm able to keep fit AND provide the class by walking around to see each of them during the practical sessions.

Tom, on my course on day four of four, wonders that I haven't lost my voice - nah - I can keep going for six days if I have to and indeed there is some form of maveric enjoyment in using the extra space as a stage "in the round" and putting on what is probably a unique performance. Exhausting ... but fun. I'm going to sleep well tonight on our last night in Troy, but contented at a course well given and well received. The environment - any environment - can be turned to advantageous use. And I love doing so where I've got a bunch of interested delegates who have brought along their own data and programs and want to do some really practical learning.

Posted by gje at 08:51 PM | Comments (0)


Related topics: via article database

Useful link: Python training

Regular expressions made easy - building from components

There seems to be a certain macho desire in many programmer's minds to write a single complicated regular expression to match against an input line, ignorning the structured approach that everyone accepts quite cheerfully in almost every other case. Have a look at this Python line:

wholeline = r"\d\d-...-\d\d\d\d\s+(\d\d):(\d\d):(\d\d.\d\d),\s+(-?\d+\.\d+),\s+(-?\d+\.\d+),(-?\d+\.\d+),\s+(-?\d+\.\d+),(-?\d+\.\d+),\s+(-?\d+\.\d+)"

Impressive, isn't it?
Yes
Easy to follow, isn't it?
No!

Much better to build it up from a series of components:

date = r"\d\d-...-\d\d\d\d"
time = r"(\d\d):(\d\d):(\d\d.\d\d)"
whitespace = r"\s+"
floater = r"(-?\d+\.\d+)"
wholeline = date + whitespace + time + "," + whitespace + \
  floater + "," + whitespace + floater + "," + floater + \
  "," + whitespace + floater + "," + floater + "," + \
  whitespace + floater

These examples are from the Python Course I have just concluded - the full example is here - where a log file was to be analysed and a short report generated to highlight any changes in readings of over 1% from one line of the data to the next in any of the data columns.

Posted by gje at 08:25 PM | Comments (0)


Related topics: via article database

Last elements in a Perl or Python list

How do we refer to the elements of a list? By index number, starting at zero and stopping one short of the number of elements in the list. So a 20 element list has element numbers 0 to 19.

How can we refer to the last element, then? We could write an expression based on the length of the list - so
mylist[len(mylist)-1] in Python
$mylist[@mylist-1] or $mylist[$#mylist] in Perl.
That's going to get very messy if you want to do a lot of work on the end elements of a list, so (in both Perl and Python), you can refer to members of a list by a negative position number, meaning "number of positions from the end".

So:
mylist[-1] - last element of a list in Python
$mylist[-2] - next to last (penultimate) element of a list in Perl

Posted by gje at 10:45 AM | Comments (0)


Related topics: via article database

Useful links: Python training, Perl training

August 14, 2007

Heading Upstate New York


A bridge over the Hudson, from the Albany train

We met Linda - probably not her real name - on the railroad up from New York to Albany on Sunday. She boarded the crowded train behind us, and, looking for a seat, sat opposite us in one of the four seat bays, with a polite "may I sit here?". A quiet soul at first, wary of her fellow travellers, she fell into a slumber as we headed up the Hudson river; she woke a little more talkative, eager to tell someone - anyone - of her monumental trip.

She was returning from Virginia Beach, where she had been to meet up with her father. For the first time in 18 years. Raised by her mother, who had split from her father (describing him as a "good for nothing" and worse), Linda had only recently got hold of contact details for her dad ... and had just visited without her Mum's knowledge. Mum thought she had headed South to New York for the week - correct, except that she had carried on beyond.

Dad, it seems, was newly retired from the Navy and is now married as settled in Virginia. Linda is his only offspring, and I can only imagine what he must have felt to meet her. And stepmum, too, was very welcoming. The three of them went out horseriding - Dad and stepmum own four horses - another new experience for Linda. Yet it was her stepmum who had a bit of an accident and came away with a big black eye where the horse tossed his head and caught her. "We had to re-assure all the friends we met after that - that it was an accident and not something Dad did" said Linda, and I do wonder - just a little - about her dad.

So what did Linda make of him? Well - she concluded that he wasn't quite the sh** that her mother had described him as. And she loved Virginia Beach - it seems the weather was fantastic there (so much so that she was hurting and peeling all over, she told us) and she was going to move down there in a couple of weeks. And then sign up for the Navy. She seemed very excited about her new life, though a little concerned as to what her Mom would make of it. "She won't be pleased" said Linda, but making it sound like no big deal.

I wonder too what Linda's boyfriend will have made of her decision ... there he was as we got off at Albany, eager to greet her and about to be hit by her bombshell.

Posted by gje at 10:40 PM | Comments (0)


Related topics: via article database

August 13, 2007

Ruby, Ruby, Ruby. Rails, Rails, Rails.

We passed through New York on our way up from Washington DC to Albany, NY State; a 3-hour layover gave us a chance for a quick meal (there's no better city for a choice of foods), and a chance to look through a book store (there's no better country to look through the shelves for the next trend).

Our Ruby course has been quiet so far, but here in the shelves in Borders right beside Penn Central Station have blossomed with books on the subject while other subjects have shrunk. A sign, I believe, that we've picked the right subject with Ruby and we'll be busy with training in the subject in the next year or two. I recall a similar slow take off in the early days of our Python Course but now it's one of our "winners" - from Edinburgh to Melksham and from Helsinki to - this week - Albany.

Update, January 2010 with two successive Ruby courses running with just a couple of days between them, I felt it was time to come back and add an update to this old article. We now have three distinct and different public Ruby courses - Learning to program in Ruby which is a training course for newcomers to programming, Ruby Programming - a training course in Ruby for those who have programmed before, but in a different language, and Ruby on Rails - an optional extra day for those delegates who will be using Ruby on a server in the Rails framework.

Posted by gje at 02:51 AM | Comments (0)


Related topics: via article database

Useful link: Ruby training

August 12, 2007

Plastic or China

"Do you use Plastic or China?" A question asked by Lisa's brother who manages a major, lotta-stars, hotel in Roanoke, VA - the Hotel Roanoke. It's a good question, relating to the cups and glasses in the hotel's bedrooms.

We've stayed there, "Chez Phil" on a previous trip and, yes, it is a spectacular hotel. On this trip, we're much more down to earth at the Comfort in. Here, it's "plastic" and the staff are willing to help if asked, but seemingly reluctantly rather than going one step further and providing a memorable experience.

Do you prefer to drink from plastic or China? Which is better from an environmental and waste issue? "China, China" most will reply - so why to hotels such as the Comfort inn - and, it turns out, the Hotel Roanoke too - use plastic? Well - it seems that it's hard to get the staff and there's just too much risk in most hotels, even the quality ones, of china cups and glasses just being rinsed out rather than properly cleaned.

A discussion point for Lisa and I. Yes, we do use plastic for water, but China for hot drinks. To change, or not? No - we'll stick as we are. We have far, FAR higher quality staff, a system that's geared up to returning all cups to the kitchen and providing afresh when they're used, and a hotel that's small enough for this not to become a chore.

At Well House Manor, we pride ourselves in providing facilities that are better than you might expect ...


We look and observe at hotels we visit when we're away on training trips - we have perhaps the best opportunity of any hotel operators to see things from the customer's perspective. A number of good ideas, and a lot of "Ouch - we shouldn't do that ..."

How many "issues" can you spot in this picture?

Posted by gje at 12:57 PM | Comments (0)


Related topics: via article database

August 11, 2007

In the USA for a few days

A long day yesterday - 24 hours long - from Melksham to Franconia Springfield in Virginia, USA. There'a a long and somewhat negative report elsewhere on our site, which was written mid - journey; 01:15 UK time, and we still had an Amtrak journey, 2 metros and a taxi to negotiate!


At Bristol Airport


Weston from the air


South Wales - from the air


Arriving in Newark, New Jersey

Posted by gje at 01:38 PM | Comments (0)


Related topics: via article database

August 10, 2007

From Leeds

3 years back, Leeds was a City that I knew little of and had hardly even visited, but recently I've found myself up here several times and I'm almost getting to know my way around. I happen to be starting to the South of the major public transport interchange, and the city centre's to the North - so of course I had to take some pictures around the station ....

My hotel - Bewley's in the redeveloped South area - is ideal; indeed they might have stolen many ideas from us. Or rather, they too can see best practise. But their size is at the other end of the street to ours!

I have a lot of other pictures to hand, but couldn't help noticing this side effect of the inside smoking ban ...

Posted by gje at 01:02 AM | Comments (0)


Related topics: via article database

August 09, 2007

Stuffing content into a web page - easy maintainance

All the pages on the main section of this web site are generated by some sort of program - a Perl script that we call "mksite" for page which are essentially static and are generated in batches from a template each time we do an update, and PHP scripts for the more dynamic pages ... although actually it's rather more complex than that in that the Perl script generates PHP (and, yes, it is great fun to protect the $characters needed by PHP from the Perl and vice versa - I'm forever asking myself "is this to be expanded at build time or display time" when I work on this code!).

Before you ask - yes it is more complex than it needs to be; that's a result of the history of its development rather than any current design system. Never the less, it does work efficiently - for the most part, data and templates appear only once, so that a single change (once I find where to make it) will ripple right through the site.

The fashion is to call the whole thing a "Content Management System" - which it is - or a "Templating System" - which it also is. Not developed with those things in mind, but none the worse for that. And everywhere we want to insert content in a template, we use a place holder. For example: "This %topic% course starts on %date%" will appear in the original of the pages we maintain, but that will be filled in by the scripts an either level (Perl or PHP) to give something like "This Perl Programming course starts on 20th August".

I commonly used the placeholder %stuff% for the main content of a page that's to be cut in ... and I was most amused to learn from our student Sam on Tuesday that she also used "stuff" as a main variable name quite often - "a magnificent word" as she described it!

Posted by gje at 06:15 AM | Comments (1)


Related topics: via article database

August 08, 2007

An example of Java Inheritance from scratch

One of the most important topics for newcomers to OO (Object oriented) programming to learn is how to design their classes and make best use of inheritance, and I find myself writing new examples from first principles during our courses. That way, the delegates learn how to actually do the job - they're NOT just presented with a "here is one I wrote earlier" and left to struggle!

In order to let the delegates then refer to the code I wrote, I've put it up on our wiki ... the web formatting isn't very tidy, but it's a great "all in one place" reference for them when they come to do their own practical.

The first example is at http://www.wellho.net/share/javainherit.html. It's a base class called "Animal" with two subclasses called "Farm" and "Pet" with the whole thing being tested by "Anitest". The beauty of using inheritance in this way is that you can put the common code in "Animal" and then just the farm-specific or pet-specific stuff into the Farm and Pet classes - saves code duplication.

That first example isn't perfect, though. We want to extend it as follows:
a) To have an array of animals that we can loop through
b) To use a utility function to handle multiple similar methods
c) To provide static methods than work on the whole
d) To set up Animal such that we can force all extended classes to have specific enhancements ("abstract")
e) To provide functions to compare two or more objects in a way we define.
These extras are in my second example at http://www.wellho.net/share/javainherit2.html.

Posted by gje at 12:13 AM | Comments (0)


Related topics: via article database

Useful link: Java training

August 07, 2007

Weymouth - Sunny Summer Sunday afternoon

My thanks to Lisa for her pictures and presentation above (reproduced with permission). Makes my writing of the Horse's Mouth really simple with morning, and reminds me of a great day out!

Posted by gje at 07:52 AM | Comments (0)


Related topics: via article database

August 06, 2007

DHCP automatic IP address v Static IP

"My system chose its own IP address ... does it matter?" From Skype - a fresh server (a real "beast") is just being commissioned:

newsystem 06/08/2007 07:22
okay, this beastie has powers beyond my full comprehension. Firstly, it has two ethernet ports. secondly, it automatically chose an IP address. I did no setting up; just plug and play.

06/08/2007 07:23
naturally, it did not like the ip addy you gave it, so it chose 21

06/08/2007 07:23
I cannot see (at first look) how to change its mind on this

wellhograham 06/08/2007 07:24
I doubt whether IT chose 21. It's probably set up to "DHCP" which means it shouts on our network "who am I" and our router gave it that number. You need to say "manual IP" not "via DHCP" and the boxes in which it can be changed will be activated

If you have a DHCP server on your network, newly installed systems will shout out "please give me an address". A great system - works well for individual user's machines (client systems), but isn't recommended for servers. Client machines on our HQ network are allocated in the range 192.168.200.2x, and on the Well House Manor network 192.168.200.8x, with the next number in sequence being issued. As a pooling system where, over time, a lot of machines will connect for just a few days it's brilliant, but as a long term solution for servers it would be utterly impractical as clients had to search for "today's IP address" for the server.

So - an earlier request for a static IP address within our network, and the decision to have the new machine sidestep the default system set up to provide easy network numbering and go this something manual, is correct for the server.

Posted by gje at 07:34 AM | Comments (0)


Related topics: via article database

August 05, 2007

Day trip to Weymouth

What better than a day at the seaside - Weymouth is less that 2 hours from Melksham by train, and it was a beautiful day. Thanks to First Great Western's "Group Save" ticket, we can make the trip at a sensible price.

Of course - there was the small issue of the first train from Melksham being at 19:50 on Sunday ... so

.... Steve brought his coach up to the station and gave us a lift to Westbury, where we joined the 09:00 departure.

The 09:00 was a lovely train - 4 coaches long, clean, appropriate stock for our party, smart, fast ... and quiet. You might be suprised at me reporting is as "quiet" ... but then it starts from Westbury, a town just half the size of Melksham, and has no connections from anywhere!

... and here are the respectable crowds leaving the station at Weymouth for a great day on the beach.

On the return trip, an overcrowded 3 car train that started a few minutes late, got further delayed by extra time taken at stations due to the traffic volume, and yet more delays because of faulty doors that closed like snails on the rear coach lead to an arrival in Westbury AFTER our ongoing connection should have left. We kinda-know these thing can happen, so I already had the re-assurance that the connection would be held ... but a broken down train in one of the platforms at Westbury lead to a very interesting few minutes when the conductor was told by the folks at Westbury that they might be breaking that promise. Me thinks this should be on my train site!

More pictures of Weymouth - see here

Posted by gje at 10:33 PM | Comments (0)


Related topics: via article database

August 04, 2007

Badges, Breakfasts and Trigger

"And who are YOU?". A question I could have asked of a number of people wandering around at a [name suppressed] venue that I was attending an event at recently. There was quite an art in looking at the people around and deciding whether or not they were staff on duty or visitors / customers. I know that I've been embarrassed in the past by asking for assistance from a bored looking individual just to find that he / she is waiting for their partner, and that I've stood waiting for service while an incognito member of staff daydreams.

All of our staff here at Well House Manor have badges, and it's one of the more stringent rules that they should be work at all times. Even when I'm giving a course and know my delegates well, I won't have a clue as to who may walk in through the door; I may walk across to the library to pick up some reference, and bump into a passer by who's dropped in to see our facilities.

Have you notices that breakfasts are getting smaller? Yesterday, at St Philip's Marsh in Bristol, Lisa and I stopped by a burger joint and had a snack for breakfast - sorry, I really can't call it a full breakfast - and camera at hand I recorded the little event. The pound coin is there for scale - and I have not been at this picture with photoshop!

Continuing on my small theme, here is "Trigger" [name changed to protect his identity because I don't know his real name] who lives near my son and daughter in law at the confusingly named Beach - confusing because it must be full 15 miles from the beach!

Posted by gje at 11:27 PM | Comments (0)


Related topics: via article database

August 03, 2007

Pure Perl

#!/usr/bin/perl -n
s/\<.*?>//g;
@fol = split;
if (/06:44/) {
  @op = @fol[1..$#fol -1];
  print "@op\n";
  }

I still enjoy - REALLY enjoy - filtering data and grabbing stats out of it. And what better than Perl - the Practical Extraction and Reporting Language. See example above.

* Read in a file line by line
* Delete out all HTML tags
* Find all references to the 06:44 train
* Output certain data about the running of the train from each reference

And that formed the basis of a charming little report shown here.

Want to learn Perl? We have a Perl Course running from 20th August 2007 ... and it's repeated every couple of months if you come to this thread in September or October.

Posted by gje at 07:45 AM | Comments (0)


Related topics: via article database

Useful link: Perl training

Linux run states, shell special commands, and directory structures

Some useful notes from the board ...

Run states of Unix and Linux systems:
0 - Halted
1 - Single User
2 - Multiuser
3 - Full Multiuser (inc servers)
5 - Same + X Windows
6 - transient reboot


Install Order for LAMP
Linux ...
... then Apache httpd
... then MySQL
... then PHP.
PHP must be after MySQL if you want to load in the drivers from the MySQL distribution within the PHP!


Lots of bin directories
bin directories contain (or originally contained) binary programs.
/bin - needed at boot time
/usr/bin - regular part of the operating system
/usr/local/bin - local additions to the OS
/usr/local/java/bin - Java binaries
/sbin - system admin binaries needed at boot
/usr/sbin - systenm admin binaries not needed at boot


Shell Special Characters
$ - Shell variable substitution
' - protect string from shell
" - protect string from shell (not $)
\ - protect next char from shell
` - run embedded command first
* - match any characters in file name
? - match any one character in file name
[] - match any listed character in file name
> - redirect stdout (output)
< - redirect stdin (input)
| - pipe output in to next command
space - separate parameters
c/r - command terminator
; - multiple commands on one line
& - run command in background

Posted by gje at 12:20 AM | Comments (0)


Related topics: via article database

Useful link: Linux training

August 02, 2007

Work and play at Well House Manor - Football and Shell Shortcuts

We're running a Linux and LAMP course this week - great group and I'm going to be sorry when it's the end of the course.

Yesterday we had a cold buffet lunch for a change, and made the best of the lovely weather and spacious garden to relax for a while - we do a long day, and so a good break at lunch is so helpful.

After lunch we looked at shell short cuts - for bash or csh - and as I've not got them all listed in one place I thought I would put them up here

Examples of C and bash shell shortcuts

!47 - Rerun command number 47
!! - Rerun the last command
!c - Rerun the last command that started "c"
!man - Rerun the last command that started "man"
!$ - last parameter previous line
!-3 - Rerun the third command ago
!?etc - Rerun the last command that included "etc"
!* - all parameters from previous command
!grep:s/ice/water/ - Rerun the last grep, changing ice to water

and if you want to see the history tree, it's the history command.

Posted by gje at 01:39 AM | Comments (0)


Related topics: via article database

August 01, 2007

A wasted evening?

It's when a meeting has trouble agreeing the minutes of the previous meeting of the same committee that you know that it's not pulling as a single body. And it took a whole hour at last night's FSB regional committee meeting to get past that item on the agenda.

It's when the HQ representative is seated at the table, correcting the meeting on procedural points throughout the evening, at the expense of getting the business through, that you realise that a committee has lost its direction.

And it's when you sit with a dozen other supposedly busy people around a table for over three hours and come away thinking "and what have we really achieved" that you come to realise that this is probably not the best use of your time and efforts.

I'm not making any personal or issue specific comments here - they are best left behind closed doors - but I do feel that this commitee, this organisation, may be something I don't want to be involved with for too much longer!

Posted by gje at 08:39 AM | Comments (0)


Related topics: via article database