« June 2010 | Main | August 2010 »

July 30, 2010

LAMP - Linux, Apache, MySQL, PHP - install, configure, administer

Linux - Apache - MySQL - PHP. The "LAMP" combination that serves many web sites - including ours - these days.

Linux provides the underlying computer operating system on which the other elements are built

Apache (that's the Apache http web server / httpd) provides the service which listens for requests to the computer for web pages (and associated requests) from user's browsers, and answers those requests with the appropriate data content.

MySQL provides databases on the server in which much of the content is typically stored these days

PHP provides the programming layer which links the requests made to Apache httpd to the MySQL database and funnels the data from the database back to the user. Actually PHP does much, much more that this ...

Yesterday evening (and I do mean evening - a very keen group of delegates had me splitting sites between servers using mod_rewrite and mod_proxy), I completed a deploying LAMP training course. A typical company web site will run on just one or two servers, but will have thousands of users - so it's natural for all the complexity to be at the server side, and the client to be thin. And PHP, MySQL, Apache httpd and Linux are all Open Source ... like most open source products highly configurable. Roll those two characteristics together and LAMP deployment training is really worthwhile - it means that you know how to make the very best of your server, how it's set up, and where you can pull in extra options and configure it to do exactly what you want. It's not because Apache's free that it accounts for the majority of domains served on the internet - it's because it is good, flexible, secure, and resource light.

The diagram shown on the right here (click on it for a larger copy in a new window) shows the layout of the file system of a typical Linux box, with the various elements - Apache, MySQL and PHP shown, on the Linux tree - and with the parts of the Linux tree that you'll want to tailor when you set up accounts and do various other configuration jobs. The diagram was built up during the course - I've copied it here for the delegates who attended (and for anyone else who might find it useful), but this is one of those diagrams that can't but help be more useful if you see it being drawn rather than just looking at the final product.

Even on a diagram such as this, you see the scope for flexibility - there are a number of purple asterisks (*) which show various options we discussed for placing the web content - each a good choice in certain circumstanced. And there are a number of log locations noted which could be the best place for server logs.

One of the things that you'll want to be aware of if you're responsible for a LAMP server are where the main configuration files for each of the elements is located, and that's something we had on the board as well. Again - click on the image to see it much larger!

With many (most?) of the elements here, you'll find this is a simplified view - for within one configuration file you're able to refer on to another, or configuration files are nested. The nsswitch.conf file tells the Linux operating system's programs where to look for its tables of hosts, users, etc ... and it may refer onwards to the network information service (NIS) and the Domain Name Service (DNS). The httpd.conf file for the Apache httpd web server may include calls to subsiduary files for setting up features like virtual hosting, and access to the http server manual; there may also be a whole tree of files called .htaccess within the web site(s) being hosted. The php.ini file for PHP may be overridden by settings within the httpd.conf file and its tree, and in individual pieces of code. And /etc/my.cnf for MySQL will point to most of the setup data stored in tables within the engine itself.

It isn't always L-A-M-P either. It could be U-A-O-P, where U is Unix and O is Oracle, for example. And sometimes the P may change from PHP to Perl or Python. Yet most of the deployment issues remain the same.

For users of Java based web applications written to the JSP or Servlet standard, and extra server (Apache Tomcat) may be included in the deployment configuration, and there may be an extra language to install in the shape of Java too. That's covered on our deploying Apache httpd and Tomcat course - next scheduled at the end of next week.

I've added pictures of the delegates on this course to the blog - with their permission, of course. I'm always tired after a deployment course (for various reasons they require a more intensive presentation than a programming course) but I'm also exhilarated - and especially so with this bunch. The extra questions ... the addition of more content on mod_rewrite and on mod_proxy and the balancer, a deeper practical than usual on virtual hosting all made the four days that much more rewarding for me, and (I'm certain) the course much more relevant for them. I'm delighted that I'll be welcoming one back on a PHP course in the near future, and who knows I might end up learning how to write iPhone and iPad apps with another one over some quiet weekend in the autumn.

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


Related topics: via article database
More about Graham Ellis of Well House Consultants
Useful links: Linux training, PHP training, MySQL training

July 29, 2010

Global Computer Maintenance Department

A story that I felt worth sharing ... from a forum that I help with, and describing another practice which I feel is distinctly unethical and misleading ...

""As we're on a bit of a tech bent here in the FPC at the mo, I thought I'd share details of a call I just received. May serve as a warning to others.

  Caller (Asian accent - broken English) says he's from Global Computer Maintenance Department a partner of Microsoft. Now I'm always immediately suspicious of cold calls and this one sounds interesting.

  Caller says they've detected a problem on my computer and it is sending them messages informing them my hard drive is infected with a spyware virus. Hmmm..... this is definitely a scam, but I'm feeling devilish so I play along.

  "Oh god, is my computer safe?" I ask.

  "Don't worry sir, we can fix the problem by remotely accessing your computer."

  "OK, what do I need to do?"

  He then goes into the detail of what I need to do to set up remote access, how to download the software and then the clincher....

  "We charge a modest fee for this service of $29.99. So before I fix your problem I need credit card details to take payment."

  I explain that I don't have $29.99 as I do not live in a country where the dollar is currency. I ask lots more technical question and get lots of vague replies and eventually the guy begins to realise I'm not going to hand over personal information of any sort, or allow access to my computer. I finish by saying I've really enjoyed wasting 20 minutes of your time and then tell him to call UK number 0300 123 1212 as the people there are always looking for the sort of 'service' you offer.""

(Reproduced with permission. It's from a regular members area so I can't provide a link - but see also [here].)

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


Related topics: via article database

Sorting people by their names

Please sort into order:

Tom Pearce
Bill Brewer
Peter Gurney
Peter Davy
Daniel Whiddon
Harry Hawk
Uncle Tom Cobbley

What would you do?

Bill Brewer
Uncle Tom Cobbley
Peter Davy
Peter Gurney
Harry Hawk
Tom Pearce
Daniel Whiddon

That's not a standard sort order for strings of text ... and if you've got each complete name in a string (as opposed to separate forename and surname fields) you would need to sort it by the last space separated string on each line.

Sort routines in most of the language we teach default to sorting strings Asciibetically (i.e alphabetically, but with lower case after upper case), and allow callback routines to be used to alter this behavior. What that means is that you call the sort routine, but pass in as a parameter a piece of code which tells the sort routine how it should grade pairs of records - with the sort routine then working out which of the pairs it needs to compare and doing all the clever control and management of the sorting process.

There's a new example of this (sorting by surnames) [here] from last week's Python course. You'll note that - in Python - I've called the cmp function internally to order two records, as once I have extracted the surname, I'm back to a conventional sort in this case. cmp returns -1, 0 or +1 to indicate that the first parameter should come first, the two are equal in sort terms, or the first parameter should come second.

Some of our local characters at Widdicome (or should that be Widecombe?) Fair vary the spelling of their surnames - I've see Tom Cobleigh as well as Tom Cobbley, for example - and other issues arise to when sorting names ...

Where several members of the same family / with the same surname are involved, you'll want to sort by the name as a whole once you've grouped by surname - that can often be a default sort:

def bysurname(this, that) :
  sn1 = (author[this].split())[-1]
  sn2 = (author[that].split())[-1]
  vx = cmp(sn1,sn2)
  if vx:
    return vx
  return cmp(this,that)

And you have matters such as differing cases, and people who have entered just initials rather that their forenames or who have (as is case of our Tom above) abbreviated Thomas to Tom and added a Titular Mr, Mrs, Ms, or Uncle.

But a Royal visit to Widdicome Fair bringing some overseas dignitaries would give some interesting people to sort. Just imagine ...

Elizabeth the Second
HRH Prince Philip
Lord Kinnock of Bedwellty
George Bush Senior
Archbishop of Canterbury
Benedict XVI
Mel Stride, MP

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


Related topics: via article database

July 28, 2010

Exclamation marks and question marks on ruby method names

In ruby, you'll find some function/method names that are just a series of letters (a rather conventional sort of name for a function or a variable), and others that have a ! or ? on the end. What's the significance of these?

• A function with a ! on the end usually alters the incoming object rather than returning a new object
• A function with a ? on the end usually return a true or false value so would be used in a conditional
• A function with neither a ? nor a ! usually returns a new object.

Here's an example with chop ...

This will not alter stuff, but will return you a result object in less:
  less = stuff.chop
whereas this will alter the stuff object:
  stuff.chop!

There's a further example [here] - including sample output

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


Related topics: via article database

Useful link: Ruby training

Alternative loops and conditionals in Ruby and Perl

Ruby gets a lot from Perl - including its eclecticness in having a wide variety of alternative ways of doing similar things - and no more so than in loops and conditionals. Not only do you have an if but also an unless. Not only do you have a while but also an until. And not only can you write these as conditional blocks (with the conditional code after the condition) but also the other way round as conditional modifiers.

so if you don't like this:

if (n <= 4)
  c = c + 3
  end

try this:

c += 3 unless n > 4

Further examples [here] and something similar in Perl [here].

Is all this variety a good thing? If used with care, yes ... but if thrown about with gay abandon, leading to unmaintainable code, probably not ... which means that in both Ruby and Perl you really need to think about code quality and standards from day one. Or should I say from before day one ...

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


Related topics: via article database

Useful links: Ruby training, Perl training

July 27, 2010

Wiltshire Council ask how they can help businesses

There it was again ... "we have undertaken projects already in Salisbury, Trowbridge and Chippenham".

Yesterday evening, I attended an event hosted by Wiltshire Council and the Wiltshire Strategic Economic Partnership; a "consultation" where local businesses were being asked various questions about the support offered by the council to them, and how the council should / can help in the future in the changed political and financial environment. Very posh place ... Bowood Golf Club and Hotel, with drinks all around and food laid on afterwards for anyone who wanted to stay.

Seated at a table of ten people, to which we had been allocated by the hosts, we went round the table and introduced ourselves. Three out of the ten were from Wiltshire Council, and one from another public sector business service provider. Which left 6 business people. Me from Melksham. A chap from Devizes. A lady from Westbury. Another lady from Trowbridge. And a gentleman from near Malmesbury. (the final person was silent for the evening ... name only).

We really need to keep stressing to Wiltshire Council that there are other places in the County than Trowbridge, Chippenham and Salisbury. My understanding is that only 25% of the county's population lives in these three places, with a significantly higher proportion in or with the next ten towns - that's born out by our table's mix - just one out of ten was representing a private sector business in or with a town that Wiltshire Council was proudly supporting; 4 were representing businesses from the less favored parts.


One of the big questions of the evening was to ask which "Local Enterprise Partnership" Wiltshire should link with. I had better explain this ...

At the present time, the public sector is seeing huge changes - with the Regional Development Agencies going and a lot of simplification, with other things taking their place. Indeed, one of our pre-consultation speakers was talking of a meeting he had had with 20 participants representing various partnerships, and 14 our of 20 seriously doubted whether they would exist in a year. The new hierarchy of business organizations / government people who can provide support looks (as I read it) like this - written with our Melksham Town training centre as the base:

1. Melksham Town Council.
2. Melksham Area Board of Wiltshire Council.
3. Mid Wilts Economic Partnership.
4. Wiltshire Strategic Economic Partnership.
5. Local Enterprise Partnership.
6. Central Government.

... and the question is "which LEP do we want to link with" ... it's a choice of Hampshire / Dorset (to link us with the Solent area), Swindon / Gloucestershire, West of England (link with Bath and Bristol), Somerset, or Berkshire ... with the most likely two listed first.

There's something of an issue here ... Wiltshire is a county that's got links with bordering counties on all sides. Wootton Basset would go naturally with Swindon, Bradford-on-Avon with Bath, Westbury with Frome, and Salisbury with Andover, Romsey and Southampton. Marlborough might look to Hungerford and Newbury. So to say "which one should we link to" is absurd - it will provide a synergy for the lucky place(s) for which an appropriate decision is made, and it will leave other places in something of an Economic Partnership backwater. If I were cynical, I would suggest that the reason the businesses were asked is that the county knows there's no good answer, and it's looking to set up someone / some group to whom it can point when things don't go well for Chippenham is they link to Southampton, or for Salisbury if they link to Swindon.

I don't know what the answer will be - the meeting didn't come up with one - but I do know that someone needs to decide by September!


In all the talk of the evening, the one thing that struck all around in terms of what businesses would like the county to do was to improve accessibility for them. The speed of internet access in some remote areas came up a number of times, and the need to reduce "real" travel times too. There was talk of creating jobs closer to where people live, and for those who do need to travel making the travel better / easier / greener / quicker - especially North to South. It actually seems like a number of threads may be coming together here - at least at our table.

At the end, Councilor Jane Scott, leader of Wiltshire Council summarised. Based on her table, and on what "runners" from around the room had summarised.

I was pleasantly surprised to learn that all those businesses had - top priority - come down on making Transport top of their list - accessibility (and by that I mean for everyone, not just those with special needs) being top of the list. But I'm afraid that I was less that impressed by Jane's promise, as if in answer to this request, to lean on developers to provide good access as they continued to develop - and I really hope that was just a partial answer from her, good in its own right but to be followed by other enabling actions too, to meet what is clearly becoming a major issue for businesses.


But where Jane Scott is right - and right on the ball - is to shout out what a great place Wiltshire is to live and work - and to call for us to be ambassadors to tell everyone "this is a great place".

Jane - I agree with you, and I encourage you to prioritize making this great place accessible and integrated. So that if we end up "paired" with Swindon, it's going to be easy and quick to get there from Salisbury and Trowbridge, even without a car. And that if we end up paired with Southampton, it'll be easy to get there from Chippenham as well as from Salisbury.


Illustrations - (top) two pictures of Bowood Golf Club, where the consultation event took place. Then the missing link road from the A350 to Bowerhill - it ends at a fence, and it should run to that building in the background. Then people waiting at Melksham for the train from Westbury (07:02) to Swindon ... miss that one, and the next one doesn't come until 19:35. "Tell us where we can help you, and keep telling us" said Jane Scott. The bottom two pictures are telling you.

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


Related topics: via article database

Dates and times in Python

Python comes with a great variety of standard classes - including some very neat ones to handle dates and times. [Here] is a link to an example written on last week's Python course which took a couple of dates as strings, split them down and proceeded with date arithmetic. I always have to marvel at the beauty of Python when I can do things like subtract one date from another and get a difference - all with a simple minus sign!

So we know that Adam - one of my delegates - was 17407 days old on the day of the course (he didn't buy us a cake to celebrate that birthday, but he's a wonderful delegate to teach!), and that he's Saturday's child.

Posted by gje at 06:42 AM | Comments (0)


Related topics: via article database

Useful link: Python training

Should Python classes each be in their own file?

Should classes each be defined in a file of their own? In Java, unless you're making a use of inner classes, you're coerced into writing one class per file. In C++, you'll typically have the code for a class in one source file and the headers in another, as other schemes are impractical to use and maintain. But in many other languages - and the example I've chosen is Python - there's nothing stopping you defining multiple classes in the same file. You can ... but should you???

One of the big gains from using objects is that it allows you to compartmentalize your logic - putting everything that relates to a film into one class, and everything that relates to a cycle race in another. There's then no "leak" between the namespaces - no confusion when you say milkrace.getlength() or shrek3.getlength() as to which logic you're running. And there's the ability for you to have separate files, maintainance team and schedules for the various types of object / classes. But there is a bit of a "downer" it that it's pretty hard to work out what you can do with an object sometimes as it inherits through a web of classes that are based on other classes, picking up cascading code (bit like the problems with "where did THAT font come from" you may have if you're using CSS / Cascading style sheets)

Where you've got a group of classes which are (a) maintained by the same person, (b) maintained on the same schedule and (c) going to be used together ... then there's no good reason I can see that you should separate each of them out into a file of its own. Go ahead and combine them!. The small gains you might make will be a consistency of naming with all classes being in files of the same name, but having them in separate files would lead to a needless layer of files. You have only to look at Java to realise what an issue this can be in the Java world, where the files are often bundled up into another structure called a jar file ...

I have put a complete class structure into a single file in an example [here]. There are four classes with three layers of inheritance joining them - so they will naturally fall together into the same application (you can't use a taxi without a travel ... which you can't use without an event!).


If you want to find out what you can do on your object in Python, you can use the dir function. Using the code example above, I decided to find out what methods I could use on a taxi ... and here's how I did it:

wizard:python graham$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 15:47:53)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from teapot import *
>>> ap = taxi("Seend","13:15",5)
>>> dir(ap)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__',
'__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__',
'celebrate', 'destiny', 'getcapacity', 'getdestiny', 'gettime', 'seats', 'time']
>>> ^D
wizard:python graham$

To do a similar thing in Java, use the javap utility with the class file in which the object type you wish to examine available in your class path:

wizard:java graham$ javap gowdie/Isobel
Compiled from "Isobel.java"
public class gowdie.Isobel extends java.lang.Object{
  float age;
  float factor;
  public java.lang.String name;
  static int nanimals;
  public gowdie.Isobel(int, int);
  public gowdie.Isobel(java.lang.String, int, int);
  public gowdie.Isobel(java.lang.String, int);
  public float getEffAge();
  public static int getCount();
  static {};
}
 
wizard:java graham$

(See [here] for more about Isobel Gowdie!)

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


Related topics: via article database

Useful link: Python training

Recent Pictures

In each case, click on the link for a whole page of larger pictures!

Bath Spa University. Pictures of the University at Newton St Loe, taken at Kimberly's Graduation

Foxhangers, Kennet and Avon Canal. Pictures taken on a walk with the dog the other day!

Sway, near Lymington, Hampshire Taken when I stayed at a local hotel there while giving a Python course nearby last week.

Party in the Park, Melksham - King George's Field, Melksham

Preparing for Melksham Carnival - 17th July 2010, car park of Cooper Tires, Melksham

Posted by gje at 05:41 AM | Comments (0)


Related topics: via article database

July 26, 2010

Snow Leopard and Python (that is OS X 10.6 and wxPython)

I'm impressed by how few "issues" I have had in switching to the new Mac I an using for most courses, running Mac OS X 10.6.4 - that's "Snow Leopard". But I got a screen-full when I called up the wx GUI in Python:

wizard:python graham$ python food
Traceback (most recent call last):
File "food", line 1, in <module>
import wx
File "/var/tmp/wxWidgets/wxWidgets-13~231/2.6/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/__init__.py", line 45, in
File "/var/tmp/wxWidgets/wxWidgets-13~231/2.6/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core.py", line 4, in
ImportError: /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/_core_.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)
wizard:python graham$

That is - err - spectacular.

Analysis - Python is running 64 bit, but the wx module is compiled up for 32 bit only. For most of the time with a GUI, the 32 bit version will be perfectly adequate, and you can set up an environment variable to request that version:

wizard:python graham$ export VERSIONER_PYTHON_PREFER_32_BIT=yes
wizard:python graham$ python food
[program runs]
wizard:python graham$

Easy when when you know how!

Posted by gje at 05:58 AM | Comments (0)


Related topics: via article database

Useful link: Python training

July 25, 2010

Congratulations, Kimberly

Kimberly Jane Ellis Graduation at Bath Spa University on 24th July 2010Congratulations, Kimberly. Yesterday I was honored to attend the ceremony at Bath Spa University, where my daughter Kimberly was awarded an honours degree - a Bachelor of Arts, upper 2nd, in Educational Studies: Early Years. This after a number of years of hard work while holding down a full time job too which she held through her course and still holds. I'm very very proud of her.

As ever at such events, we listened to speeches about the university, and of encouragement to the new graduates to go out there even though it's hard and seek jobs. Ah - but Kimberly is rather ahead of the game there (but not resting on her laurels, I know - she's already doing her postgraduate EYP ...).

One of the speakers suggested that the graduates turn and that their families and supporters at the rear of the hall for all their support through their courses. Actually - I'm rather humbled on that one. The motivation was Kimberly's. the hard work was hers, and the planning of the finances of how to do it was hers too. Kimberly - you deserve double congratulations for not only getting that degree, but also for your single minded drive to getting there - Love, Dad.

---OOO---

Further pictures (open in new window): The University - Official Photos - With Grandad - Kimberly receives her degree - After the ceremony with Mum - I have the certificate!

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


Related topics: via article database

July 24, 2010

Twenty Questions

Twenty questions for our hotel team to ask themselves ...

1. Is our Internet access easy and obvious to find rather than having to search through a load of hubs called things like "netgear" that are around the place?

2. Are our power points easy to find and near the desk space, and is there enough desk space?

3. Do we ask our customers if they had a good day / good journey when they arrive?

4. Do we ask our customers if there's any other information they need or anything else we can do for them?

5. Do we take our customers to the room, or just take them to the bottom of the stairs and point up saying "it's up there"?

6. If asked for local directions, do we offer to sell our guests a local map, or do we have something we can give them with our compliments?

7. Picture question - Do the window frames in our bathrooms look like this?

8. Do we advertise something at £5.95 in the room, but then have a newer version of the same sheet in reception and offer it there at £7.25? Then tell our customers they must have misread the information in the room when they query it?

9. If we were to offer apple sauce, and the offer was taken up, would we provide a fresh pot or one that had clearly been nearly used up on another table?

10. Do we offer breakfast earlier than an 8 a.m. start?

11. Do we request payment the night before if guests are leaving before 8 (said in one place), 8:30 (in another) and 9 (in a third)

12. If we're going to have an argument between staff, do we do it where customers at breakfast can hear and appreciate the words being exchanged?

13. Do we vacuum clean the room next to the breakfast room at the height of breakfast service?

14. Do we seat single customers in the back seat without the good view at dinner, and by the kitchen door at breakfast, on a table that's only half set - short of salt, pepper, menu ...

15. Do we serve instant coffee in stylist stainless cafeterias with plungers to make it look as if it's real coffee?

16. Do we provide a leisurely breakfast - although it's an 8 O'Clock start, food isn't actually served until twenty past (half past if the staff aren't told it's urgent)

17. When guests check out, do we present them with a bill for one more day than they actually stayed (and with the total line well hidden) in the hope they won't notice and we'll get more income?

18. Picture question - Do our tables look like this?

19. Do we go round and check with people while they're eating, or leave them to finish their meal alone?

20. On check in, do we ask people to sign in on a form that's been amended and it's clear that the rooms have been shifted around - leaving them wondering what is wrong with room 17, or have we been put in the "dunce" room because a more important customer wanted 17.

I an happy with the answers that I can personally give for Well House Manor on each of these questions, which were inspired by a hotel that I stayed in very recently.

I'm very much aware that with some of the questions, there are arguments as to what is the correct action anyway. For example, there is a "staff will be seen and not heard" ethos in some places and it could be argued that asking "did you have a good journey" is getting overly familiar; for our accommodation - mostly for business travellers often on their own, I think that an opening of this sort should be (and it is) made, and a lead then taken from the guest as to whether a conversation follows or it shuts down.

I'm copying this list to our whole team - saying - "please think of how WE do on each of these issues". I always want to be reviewing, and my stays in lots of different places let me bring back the good and the bad experiences and thoughts and we can all gain from these. What reaction do I want from our team? If one or two things - not necessarily on the list, but brought up from wider thought - come up, that's tops. If we find nothing, we're being too smug. And if we get more than a handful, then we have some issues, I think!
Dorothy-2:jul10 grahamellis$

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


Related topics: via article database

July 23, 2010

Hotlinked images onto adult material sites

Looking through my web server logs earlier this week, I was surprised to see a considerable number of downloads of our images from sites that I had never heard of, and exploring those sites I found that they display - how shall I put it - material that we do not want to associate with. Our images - along with many, many others, are being (ab)used to provide a veil or respectability and to pump up link counts.

So I have updated our image system - and if these sites call up images from us as part of their content in the future, they'll simply be displaying this rather boring panel which I hope shows a degree of dis-assosiation and disapproval. I note that some of the big image sites have taken a similar action!

I found it very interesting, though, to see which pictures were being hotlinked from us (in contravention of copyright, it should be noted!) ... here are the most visited ones for the last two days.

Our Dog Gypsy

A display of food at a hotel exxhibition in London

Atherstone, in the West Midlands

Heaven's Gate, Longleat

View from Portland to Weymouth and the Chesil Beach

In spite of my discouraging this particular use of our images, I am very happy for them to be used quite widely with prior permission - see [here] for full details.


Technical note for anyone else who is looking to suppress use of their images on sites like dearcomputer and prarllolitas - our images are all served from a MySQL database and I have modified the script to replace the normal image with the "forbidden" one if the referrer site name includes these strings. If your iamges are served directly through the Apache http server, you could also use mod_rewrite to redirect the requests to your chosen replacement image.

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


Related topics: via article database

July 22, 2010

Melksham Oak - photos of the new community school

On Tuesday evening, we had a chance to look around Melksham's new school, built and equipped at a cost of some 32 million pounds. And very impressive it is too. Here are some pictures (taken with permission); I rather suspect working pictures will be hard to come by as the stipulation is "do not photograph pupils" and I expect there will be lots of pupils around - the school can take up to 1150 pupils in the main section, and 200 6th formers.

Click on any of the images to see them much larger, in another window. There are also earlier pictures [here].

Reception. There are actually three entrances - this is the visitor's entrance, then there is the pupil's entrance and round the back in the community entrance.

Entrance. It's good to see encouragement of cycling and walking to school, and I'm happy to hear talk of improvements of the public footpath that runs diagonally across to Snarleton lane too. I hope they have it right ... and don't find that there is too little encouragement for the healthier transport, and too little parking as well.

School Hall. This racking folds back, including the seats, in just three minutes. I presume that there are checks made to ensure there are no pupils underneath first!

Computer Suite There are - literally - hundreds of computers (do I recall someone saying 500) and all are brand new. That looks excellent at the moment - I hope that there's plans in place so that the computing facilities will remain modern and appropriate in 5 years and ten years too.

Resource Centre. Post name for library! More computers, of course. Here some of the books have been brought over from the old George Ward, and the shelves still look less that filled; I understand more books are yet to be inventoried and unpacked.

Green Lobby. The school is divided into five coloured areas, each with subject themes - Maths and English, Science, History and Geography, Music, etc. There's also a separate sixth form area.

Staff Room. This might be the picture the pupils want to see - the place they won't be. Actually very much an inside room, and probably not big enough if all teh staff are around at the same time.

Music Area. Now the music area is impressive - lots of new instruments, practise rooms, and a complete computer suite given over to the technology of music. I understand that the music staff are rather happy with what they have.

Class Room. Perhaps a typical classroom? But there are so many specialist rooms - from science labs and home economics through the computer labs, to smaller special needs rooms and a detention room which (perhaps I shouldn't say this) would be an ideal place to get away with a laptop and really concentrate on some coding.

Red Hallway. A further hallway. The school was eerily quiet as we looked around in the evening; there are plans for community use, but words like "eventually" and "possibly" were being bandied about, and we were told of strict access controls on nonpupils, so I really wonder if words will indeed turn to deeds on this one.

Pupils Canteen. Around 8% get free schoool meals at Melksham's scholl - but you can't tell who because it's all biometric and based on finger print recongnition at the till. I found myself wondering how they're going to keep the finger print readers clean and sanitised and stop flu racing through the school, but I'm sure they'll have thought of that one.

Sports Equipment. "They never had equipment like this when I was at school" ;-) But it's good to see excellent sports facilities. Public use in the evening, please ...

Sports Hall. What is there to say about this magnificent new sports hall ...

... and about the Astro Turf pitches outside?

Truly - a very impressive set of school buildings. Of course, a lot of the success of a school comes down to the quality of the teaching there, but let' hope that the new facilities can provide a helpful impetus to the teachers, and a pride in both the pupils and the staff, so that Melksham Oak is a huge success. I like what I see, and wish it well.

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


Related topics: via article database

July 21, 2010

Seeing Wiltshire - from a Melksham base

Last weekend was a busy one - we were running a training course for delegates from outside the UK, and as they didn't leave until Sunday we showed them around - "did the tourist thing" with them. Pictures follow.

Advert 1 - for delegates on courses who wish to stay an extra day or two - there's PLENTY to see and do. Returning delegates (with partners where relevant) also welcome to come and see Wiltshire at delegate rates.

Advert 2 - if you're looking for a quiet retreat from which to tour the area, we welcome "small hotel" guests too. We've not got all the services that can be offered in a 100 room hotel, but we do have superb rooms and make an excellent and friendly base. See [here]

In Lacock Church - 4 miles from Melksham where we're based. Lacock village shows you how a village would have been 200 years ago - most of the properties are owned by the National Trust, and there's Lacock Abbey, the Fox Talbot museum, a pretty stream, the old causeway bridge over the river Avon, the church and much much more. Four miles from Melksham.

There is a wide variety of palces to eat while you're touring in Wiltshire - the George and the Red Lion in Lacock are two possible choices. Personally, I really enjoy the Red Lion - one of Lacock's newer buildings; I remember going there one day in winter with a snow storm blowing outside, and just a few hardy souls eating excellent food in a friendly and convivial atmosphere! Four miles from Melksham.

There are may pretty little country churches and church yards - this one's less than a mile from the previous picture at Lacock, with beautiful views over the vale of the river Avon. Other churches - such as Sandy Lane - are even more interesting; that's a wooden, thatched (?) church which to my knowledge is unique. Four miles from Melksham.

The Kennet and Avon canal took boats from Bristol to London ... at at Caen Hill near Devizes it climbs the hill to go over the watershed with a flight of 29 locks - most of them in a daunting line right up the hill. Even when there are no boats passing through, visitors are welcome to wander around and marvel. Six miles from Melksham.

Also close to the canal near Semington you'll find "Freddie's Wood". Reachable from the path beside the canal, and also across open fields from Bowerhill (Melksham's outskirts). A lovely area of trees, of all different sorts - planted by a benefactor as a quiet and relaxing place - and we love it. Thank you, Freddie. Less than a mile from Bowerhill, less that 2 from the centre of Melksham.

Last Satruday was Melksham's Party in the Park - held each year with stalls and music and running in afternoon and evening sessions. The metrics are different; in the afternoon it's very much "family" and here is one on the stalls. In the evening it's much more concert and fireworks. A big gathering - I understand that up to 5000 people come in through the gate. A few hundred yards from the centre of Melksham.

Sandwiched between the two sessions of "Party in the Park" is the Melksham Carnival - and Kathryn and her committee did us proud. All the more remarkable as it was her first year at the helm. Our guests entered into the true spirit of Carnival, and joined me in the parade, walking with the float (OK - it was a car with sandwich boards!) of the Melksham Community Area Partnership. Right through the centre or Melksham.

Crowds lines the route of the carnival parade - here are the crowds outside the King's Arms pub, on the Market Square, as we walked past. On any day, Melksham is a friendly town - visitors (and there, perhaps, more on this day than any other) always get the warmest of welcomes, the opportunity to see some really interesting buildings, and to choose between plenty of eating places. Centre of Melksham.

"Carnival is the only day when a procession of heavy lorries is welcome through Melksham" someone said to me during the parade. And - thinking about it - they're right. The floats were decorated by local schools, leisure groups and other organizations and drove through the town, then looped around Spa Road and Warwick Crescent and Kenilworth Road. Here's the Manor School's float, taken just yards from our Well House Manor, and about 400 yards from Melksham Town Centre.

A familiar site in Melksham is Peter Dauncey - our town crier - who reminds us of how the news used to be spread before the days of newspaper, radio, TV and the Internet. Of course, even town criers have moved with the times - I think I see Peter with a digital camera, don't I? Near to Melksham Town Centre

Melksham is a market town set in a rural hinterland, and some of the floats in the parade used agricultural vehicles rather than HGVs as there base. Here's a float at the end of the parade in King's Street Car Park - a few hundred yards from Melksham Town Centre.

After the carnival and party in the park, we walked back to Well House Manor. This is where our visitors were staying - our business hotel which offers high quality rooms in a quiet setting, and is also suitable for some leisure groups. About 800 yards from Melksham Town Centre.

Avebury is a stone circle that's bigger and older (but less famous) that Stonehenge. You can drive from Melksham to Avebury via Calne and Cherhill - stopping in Calne, and at Cherhill to see the White Horse - if you wish. And when you get to Avebury, there's also the Barn, the Alexander Keeler museum, and Avebury Manor all of which are oepn to you to see. About 10 miles from Melksham.

The West Kennett Long Barrow, the Sanctuary, and Silbury Hill are close to Avebury. This is Silbury Hill. But the ancient artifacts don't end there. There's Windmill Hill too, and many other lesser sites. About 10 miles from Melksham.

White Horses are cut into the chalk of the hillsides in a number of places in Wiltshire. The nearest to us in Melksham is at Devizes - a modern horse - and then there are others at Westbury, Cherhill, and the one we pictured here at Alton Barnes. The Marlborough horse, and the horse at Hackpen Hill, are also near. Alton Barnes is about 10 miles from Melksham.

People often think that I'm joking when I ask them about Woodhenge. But - yes - it does exist, and here it is. Of course, all the wood rotted away a very long time ago. You can see where the columns were, though, as they're marked with concrete pillars - and those pillars all have different coloured tops so that you can tell what's what from the interpretation boards. Woodhenge is just under 20 miles from Melksham.

And here's the last of the sites we took in over the weekend - and probably the most famous of the lot. It's Stonehenge. Always very busy - always a "must see" for our visitors - but although it's impressive, they end up impressed more by the variety that we have in our area. Stonhenge is the furthest point that I've shown you on this tour from Melksham - but it's still less than 20 miles from Melksham.

And so - on Sunday afternoon - to Salisbury station. Two of our delegates left by train for Woking and the transfer bus to Heathrow, and the third off to his next destination in the UK, as he's taking a few days holiday.

Thank you - "K", "G" and "K" - for coming to learn some advanced Perl stuff. And thank you for giving me the opportunity to show you around some of the sites and scenes of Wiltshire. The course was / is the important thing - but it's also so good to be able to look around and get the real feel of the place. And Wiltshire is such a lovely place to live, to tour, and to work.

Posted by gje at 02:13 PM | Comments (0)


Related topics: via article database

Tailoring of courses to meet customers needs - how it works

We can - and do - tailor private courses (i.e. courses that we run for a single organization) in fact, we insist on asking a few questions about what use is going to be made of the subject and the background of the delegates - so you could say that every course is tailored. It makes the course much more relevant for the delegates attending.

But .. how much can we tailor .. and how much to we do that ahead of time? And what does that mean about extra subjects that come up during the course, and the usefulness of the course resources later on?

I've answered an email addressing these issues this morning - and the generality is worth making more widely available for anyone who wants to read in a bit more deeply.


The course can be utterly flexible.

The notes will be based on standard note modules, but a proportion of new modules can be written / provided). We don't trim the existing note modules if they include subjects which you don't need along with ones you do need, but presentation can skip over the unrequired sections. We may also add note modules that you may not have requested to the folders provided, so that the folders include supporting material to make them worthwhile reference / reminder documents after the course. Such additions sometimes prove useful during the course too, where it turns out that the support material is - after all - something we need to dip into.

Presentation ... broadly planned ahead of time, broadly following the agreed notes, but adapted and tuned as we go. With certain topics (and OO programming is one of them!) it's not just a question of "how does this work", but also of "how do we decide to do it this way", and so I'll take a requirement - not necessarily one that's in the book, in fact I prefer to take something that the delegates can relate too very closely in their line of work - and work through that, describing the principles of OO and showing how they are applied for your use. There's even an element of role play in that, as I'll be asking the delegates to interpret what your data means, just as they'll ask the experts for whom they're writing the programs. It makes for a very interesting and relevant course.

During the course, I'll note questions and ensure they're all answered (or at least pointers given) before the end; the answers may not be given straight away ("I'll come back to that") if it would disturb the course flow / require lots of pre-explanation that was planned anyway, but I have a system in place to ensure that "I'll come back to that" isn't a way of forgetting something.

At the end of the course, I'll add any examples that are significantly new to our resource directories, and delegates will be able to access them later. And I can send a "tar" file of them all through to you (also a tar file of each delegate's work from our machines).


OK ... I was writing there about Python Courses; Python is a subject that lends itself very well to flexible and potentially dynamic tailoring. The same applies to Perl, Lua and Tcl. With PHP, C and C++ we have to be a little less flexible - there are certain steps that I'll describe as "mechanical" which really must be covered if the delegates don't know them, and covered broadly in order. And that applies very much more with non-programming topics (LAMP / Linux / Tomcat). Java, Ruby and MySQL are all huge subject area ...we can do very flexible, Python level, tailoring but within our particular areas.


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


Related topics: via article database

Getting in touch - Please allow me to see you when you are online

We're coming up to ten years of training in Melksham - and over those ten years, I have trained (literally) thousands of delegate here (Wow - what a lot of business for Melksham!). Add to that at least the same number of delegates trained on customer sites, and all the people I taught in the previous 10 years at Harwell ... and I know a lot of people. So please forgive me if you get back in touch and I don't remember whether it was Tomcat Deployment or Perl that I taught you ... actually, I do quite well with "I've come across that name" and recognizing faces as someone I know, but my correlation's a bit crap at times.

I'm happy(ish) to accept Skype connection requests from past delegates, and people who are looking to get in touch within our business areas - looking for hotel rooms, to book courses, or to ask questions about those things and what we teach. But I don't want to accept requests off topic - where an acceptance means that I'm then open to sales messages on anything from Viagra to having contract software written for me. If you are going to ask for a Skype link - PLEASE amend the "Please allow me to see when you are online" text to something that gives me a reminder or introduction. I was going to plead a gentle movement towards older age as I wrote this message - but looking at the numbers above, I'm going to plead weight of numbers. To which I should add 900 people who'll be known to me (by handle at least) via the First Great Western Coffee Shop, the 750 who are signed up on TransWilts railway matters and smaller numbers through the Chamber of Commerce, and so on. Yes - I am happy(ish) if those groups contact me by Skype too.

But why do I only say "happy(ish)" and not "delighted".

It's all to do with my day job.

I'm a teacher. I stand in front of a group of delegates, I talk to them, I answer their questions, I demonstrate things. And I can't be constantly disturbed by telephonic systems where the person getting in touch expects a response in a few seconds, or even minutes, and feels that I've slighted them if they don't get that response.

So - I'm delighted if people email me in my subject areas - my email address is all over the place, and there's a web page where you can get in touch - [here] - too. Most of the time, I'm online even during courses so a headline pops into my mailbox within a few minutes, and urgent requests can get dealt with. And - yes - I can (and do) phone back during course breaks, or arrange a time when I can take calls.

I'm always delighted to talk with people about their training and hotel needs. It makes for a far better course / stay than a generic / vanilla one. And by helping me make such a call at a time when I'm not called out from the current delegates, you're also ensuring a quality call when I can concentrate. As an added bonus, we end up paying for the call ;-)

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


Related topics: via article database

July 20, 2010

Night Porter and reception - 24 hours a day?

We're a "small hotel" and we don't have a member of staff on reception / service 24 hours a day, and seven days a week. We are available (on call) at the press of a button while you're staying with us, and will be with you within a few minutes if you need us. It would only be practical for us to go the extra mile if we were considerably larger, and charged considerably more - and that is just not the market we serve.

Actually, I think our service level / advertising is about right on this - as it's worked very well for four years, and we've only just had our first issue. But every customer is important, and I have checked back in review.

The AA guide to hotel rating would place us as a smaller hotel; here are extracts from their detailed paperwork:

* "Smaller hotels [have] a maximum of 20 bedrooms. They will be personally run by the proprietor and are likely to have limited function basis."

* Extra at four star: "A member of staff - possibly the night porter - on-duty and able to perform reception duties [24 hours a day] ...". Note that it's acceptable for a call bell to be have to used during the night to reach this person, even at a four star hotel.

As one should (and would want to), I have discussed the matter with the guests concerned, and looked to understand how they came to think there would be a member of staff available to help them at all times. And I am satisfied that the information we provide is correct; the quality of our rooms and web site, and experience of hotels in different countries where the mix of standards differ, may well have lead to an incorrect assumption of near-instant (and wide awake staff member) service levels.

The following hotels are within 12 miles of us, and offer 4 star hotel rating - so should provide the service that future potential guests in this category are looking for :
* Macdonald Bath Spa, from 147 pounds per night (breakfast extra).
* Barcelo Combe Grove Manor, from 166 to 266 pounds per night.
* Manor House Hotel, from 180 pounds per night.
* Bowood Hotel, advertised "from 180 pounds per night" but quoting 250 at present.

It's interesting to note that you'll pay at least 57 pounds per night per twin / double room more than our top 90 pound rate for the lowest rate room at the cheapest of these for your bed - and that's before you add breakfast (which we include) and perhaps other costs which we include too (internet, lots of TV channels, soft drinks ...). And to be fair, these hotels may provide many other extras within that extra 57 pounds or more.

The following hotels are also well known local establishments but fall below the 24 x 7 manned reception standard according to their rating (but check with them - they may be above standard in an area that's critical to you):
* Woolley Grange, Shaw Country Hotel, Angel (Chippenham), Beechfield, Leigh Park - two or three star.
* Pear Tree (Whitley) - "Guest Accommodation" rather than hotel, so limited services.
* Conigre Farm, King's Arms - "Guest Accom" and I'm unsure of their ratings

We want our guests to be happy - so we do not seek bookings from people who require services that we cannot offer. I am providing the list above, and going to suggest that for their next stay in the area, our guests consider staying at one of the four hotel listed, which say they are staffed and run to meet their needs; they should check that they're goig to get what they need direct with the hotel as they book.

I am happy with the level of service we provide. We rank highly, it's very rare for a customer to be unhappy with what we provide, and a very great deal of our business is returning guests and recommendations - customers who arrive not knowing us leave as our ambassadors, even if they won't have the need to travel to our area again in the future.

P.S. - we don't have a "last checkin time" - we offer accommodation for business travelers and we will cheerfully show you to your room and help you settle down in the middle of the night if that's when you arrive. And we'll help with any other matters that arise too. But you may have had to wait for five minutes if you hadn't given us an estimated arrival time, or if you're already checked in and call us for further help

Posted by gje at 06:05 AM | Comments (0)


Related topics: via article database

July 19, 2010

Program for reliability and efficiency - do not duplicate, but rather share and re-use

When you're writing a new piece of code - especially if you're also quite new to programming - you'll be concentrating so much on getting it to work that you may not be giving too much thought to making it easy look after your code later on (maintainance), nor to sharing a piece of code between programs. But in the medium and longterm, if you can avoid duplicating code you'll be saving yourself and you colleagues a lot of time and effort!

• If you find yourself copying and pasting a block of code, there's probably an easier way!

• If you duplicate a block of code, but then alter a few elements, don't say "that's not a duplicate" - say "I have identified which values will be parameters to a function"

I have an example here from a Python course at the start of last week. Look at this code:

while True:
        him = int(raw_input("How many years old is he? "))
        if him < 0 or him > 119:
                continue
        break
 
while True:
        her = int(raw_input("How many years old is she? "))
        if her < 0 or her > 119:
                continue
        break

It's almost exactly the same block of code - just the prompt and the result variable are changed, and a good case to make a named block of code. This is Python, so we used "def" but it could have been sub in Perl, function in PHP, or proc in Tcl.

The function code has to be defined before it is called - here's my example:

def getage(person_word):
    while True:
        question = "How many years old is " + person_word + "? "
        age = int(raw_input(question))
        if age < 0 or age > 119:
            continue
        break
    return age

That does not run the code - it just defines it. You then call it by name, passing in the string that contains the person_word, and returning the result to another variable:

him = getage("he")
her = getage("she")

Taking that a step further, you'll want to share the code between programs. You can do that by putting your defined function into a shared file (usually alongside other functions that are to be shared) which you will then pull in as required in some way. In Perl, that would be a use or a require, in Tcl it would be a source, and in Python it would be a from or an import.

Structure your code well using these techniques - not only will you find you're making huge time savings in the long term, but you'll find that you're also wring more consistent and reliable programs - and that the benefits come in the short term too. Did I tell you that by naming a block of code, you provide a unit of code that's much easier to test and debug ... with a built in test routine and documentation too!

Full source code links:

Control case with repeated code
Re-use within the same source file
Separated out for sharing with other programs and the shared file

Illustrations - delegates on last week's Python Course

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


Related topics: via article database

Further more advanced Perl examples

I've uploaded a further batch of new examples (that makes around 40 in total!) from the private Perl course that I ran from Wednesday through Saturday last week - many of them adding a new twist on to previous examples. If you read a comment below and thing "that's what I'm looking for an example of", then simply click on the code sample name just above, and you'll find a complete source program.

grepplus in module P208

Perl's grep function isn't just a regular expression processor - it puts each value into $_ and lets you perform other tests too. And $_ is set as a pointer, so if you alter it you're changing the incoming list. Although it may be regarded as clever, this changing of the incoming variable can be very confusing to the reader and is not recommended!

iiw in module P301

Variables default global in Perl 5.

If you declare a variable as my, it is then lexcially scoped to the block in which it occurs - i.e. only available under that name within the block, and lost at the end (unless a reference to it is used elsewhere).

If you declare a variable as local, any old global variable of the same name is saved away until the end of the current block and a new one created.

Since a local variable is not lexically scoped, it can be used within a sub under its original name, whereas a my variable cannot.

Strong recommendation is to use my rather than local, though there are times you'll want to use local in order to save and restore special variables such as $".

lili2 in module P217

You don't have two dimensional arrays in Perl - but you can have "lists of ists". And these are much more flexible!

At first glance, the syntax is complex ... but you'll soon learn that Perl, ever practical, lets you use a shorthand that's the same as you might use to address them as if they were 2 dimensional arrays anyway!

need1 in module P213
need2 in module P213
needbr in module P218
teacup.pm in module P218

You can use a bare word as a function call name provided that you've defined the function (i.e. sub) prior to the compiler finding the word. That means it has to be defined higher in the code, or in a module that's loaded with a use (a require will not suffice!)

You can force a bare word to be a sub call by adding () onto the end of the name, or by adding & before the name.

Perl's warnings (-w) will tell you of any bare words that occur in your code which are not run as subs - "Useless use of a constant in void context".

If you want conditional loading, then use require. It pulls in code at run time rather than compile time ... our example loads one of two different modules depending on whether the second number is odd or even!

protodemo in module P303

You don't usually declare a Perl sub with bracketed parameters - but you CAN use a function prototype if you wish. That lets you specify the number and type of parameters that it's called with, and you'll be rejected at compile time if you get the calling code wrong.

runner.pm in module P218
runtest in module P218

runner.pm is a pair of classes, both descended off a parent class, and with errors reported via the Carp module to make them useful to the calling program. It's a short but heavily featured demo showing polymorphism, inheritance, multiple packages (classes) in a file, and a common AUTOLOADer

slurpex in module P212

You can read an entire file into a string by undef-ing $/, or with the read function. And you can then do regular expression matches against the whole string - sometimes that's better than splitting it into a list. Remember not to use $' $` and $& if you want it to be efficient, and remember the m modifier on the regular expression so that ^ and $ will match at embedded new lines!

sting in module P212
stuff in module P212

Single and double quotes strings ... qw, q and qq ... here documents. You have plenty of choice in defining strings!

Using qr, you can compile a regular expression into a variable, and that's going to be very efficient if it contains variables that change just a few times as you program runs.

waw in module P303

Some interest functionality:
* caller - tells you about your callin code
* wantarray - tells you if you're in a list context
* ref - tells you whether a variable is a reference, and is so to what sort of collection (or maybe "SCALAR"

Posted by gje at 05:58 AM | Comments (0)


Related topics: via article database

Useful link: Perl training

July 18, 2010

Different perl examples - some corners I rarely explore

The private Perl course that I ran on Wednesday through Friday of last week was a little out of the ordinary as we were concentrating far more that usual on a wide variety of practices that may be found - either in legacy code or advanced recent code. Great fun for me, and plenty of new examples.

Here are some notes (part 1 or 2) which I wrote up for the delegates - if something in the summary notes has attracted your attention to this page, follow the program name link just above it, and you'll find the full source code I am talking about.

about albert in module P224
about victoria in module P224

1. Set up a SIMPLE signal handler under signals. Nothing complex as this happened asynchronously and there's a danger of actions at the wrong moment - far better to set a flag and process at a specified time in the main program loop

2. Two ^C presses in 3 seconds cause the code to exit; a single ^C just gives a message

3. You can fork a process to give a parent and child, each of which goes off to do its own thing. Fork returns "0" to the child, and the pid of the new process to the child - that's how you tell them apart and have them each go their on way

4. Processes can talk to each other through a pipe; open the pipe before you fork, and when you fork you end up with two pipes - the write handle on each process sending to the read handle on the other. Processes can be told to read from each other via a signal (not illustrated in this example)

about assume in module P203

Perl assues that variables start with an empty string, which when used in a numeric context gets converted into a zero.

It is doubtful if it is good practise to make use of this default initialization, and if you run perl with the -w option you'll get a warning message to let you know about the potential problem

about biggest in module P602

Opendir, readdir and closedir are the recommended way of going through a lot of files on the file system - they don't start a fresh shell and they don't waste time sorting the entries into order. So they run quickly and are not operating system dependent.

You'll get back all file names and directory names - including "." (the current directory) and .. (the parent) and if you're descending into child directories, you must eliminate these!

about bip in module P206
about tae in module P206

There are multiple ways of doing most things in Perl - this example shows five different ways of writing an "if" (and it doesn't even start with the unless conditionals!), and four different forms of comparator - eq == =~ and ~~.

The do ... while loop is a great way to check user input and to reprompt as often as necessary to get a valid response. Ideally, wrap it in a sub ...

about cafe3 in module P218
about dish.pm in module P218
about cafe in module P218

The Exporter module supplied with Perl lets you offer variables that are within your package in the parent namespace too. i.e. it lets you refer to them by simple names such as $n_dishes rather than (in my example) $dish::ndishes.

When your use has no parameters, you'll import automatically everything in the @EXPORT list. Empty parameter brackets specify there are to be no imports at all, and brackets with specified names call up those names - which must have been listed within the class in @EXPORT or @EXPORT_OK lists.

about chopin in module P103

Don't get caught by
  print (chop($line));
which will alter $line and just print a new line, or
  print (chomp($line));
which will alter $new line and print out the value "1" or "0".

If you want to print out $line with the new line removed, do the chop or chomp in a separate line before the print!

about ctx in module P208

If you refer to a list in your Perl program, it will work with the whole list. But if you refer to it where only a scalar makes any senses, it will assume you mean the length of the list ... and if you refer to a list within double quotes, all the elements will be joined with a space between them.

There's an example of the various formats in this example, and it also shows how you can refer to individual list elements, the index number of the last element (one less than the number of elements in the list!) and list slices. Finally, it shows you how you can split a line of text into pieces and then name each of the pieces in a scalar al in one line!

about dadu in module P219

A demonstration of the Data::Dumper module supplied with Perl which lets you prin out the contents of a data structure (actually, the Dumper method returns a string so that you can be much more flexible!)

I've also added a $debug variable in my demo which you can comment out to remove tracing from your program - a useful trick in code that needs testing and analysis from time to time, under the programmer's control.

about delay in module P210
about johnny.vegas in module P210
about kbcheck in module P305

Perl's built in select function, without arguments, tells you where the default output from print is currently directed. With a file handle as an argument, it sets that default output to the specified handle.

With multiple parameters, select lets you check whether input is waiting on any input channel, and whether an output channel is open and available. This uses bit masked parameters and vec - so it's an "interesting" piece of code - but very useful if you need to do background work while waiting for the user to answer a question. See also fork and signal ;-)

about dend in module P215

If you add data to a Perl program after the __END__ marker, you can read it from the DATA file handle using at run time. DATA is open and available to you when you run your program, as are STDIN, STDOUT and STDERR. Other file handles must be opened.

about dotty in module P215

If you read from a file handle that contains * or ? characters, Perl assumes that you mean to return file names that match the pattern given. So
  while () {
will report on all files with a "." in their name (remember this is not regular expressions - it's file name globbing!)

about evx in module P303

If you run code in an "eval", and it hits a condition which would normally cause perl program to halt with an error, you'll get back the error message in $@ and the calling code will continue to run. In effect, this is exception handling - try and catch - in Perl.

If you pass a block to eval using { ... }, the block wil be compiled with the main program. But if you pass the block in using " ... ", the block will be compiled just prior to each execution - more flexible, but slower!

about file in module P215

Operations such as -e to check if a file exists usually run on a named file, passed in as a string. But there are two special cases:

1. If you do not specify any parameter, the file who's name is the current contents of the $_ variable will be used

2. If you specify _ (no $ in front of it), then Perl will simply return you more information about the last file you asked about. This is useful and efficient - internally, the operators like -e and -s return a full stat report which is buffered in case you want to ask more about the same file!

about funcall in module P209

=> can be used to replace , in the definition of a hash - it's useful as it helps you tell the keys and values apart, and it allows you to drop the quotes of the key if the key is a bare word with no other meaning in that context and scope.

But you can go further - you can use the => in a sub call in place of a comma, and it gives the effect of named parameters. It's common practise for module authors to collect parameters in this way, and also to accept the bare words with a leading minus sign, so that the issue of them having another meaning in this scope goes away.

This example shows the minus sign and =>in use in the calling of a sub, and also an example of how the sub would be written.

about gawd in module P301

A Perl variable name starting with "*" is a typeglob - that's one each of a sclar, list, hash and file handle. They're used / useful in handline (in effect) lists of file handles through soft references.

Note that a typeglob is in fact a reference - so if you assign a typeglob and then change the data via the original name, you're also changing the data pointed to by the new name.

about goflavours in module P303
about gogo in module P303
about pmg in module P303

Perl has a goto statement (3 flavours actually), and you can also use the last command to jump out of a block, which some people also consider to be a form of the goto statement.

As well as giving a label to the goto statement, you may give a variable of expressing, and Perl will jump to the label named in that string.

Finally, if you pass a named piece of code (a sub) to Perl's goto, it will jump to that sub and fix its stack so that it look like the original was never called.

Only the final type - the "magic goto" - should really be used these days, and that for the specific case of the dynamic loading of code. Bring in code through a require, then goto it!

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


Related topics: via article database

Useful link: Perl training

July 17, 2010

A long day in Melksham ...

After breakfast, I started early (yes - I know it's Saturday!) reviewing Perl code (you can see here a sample piece of code which I projected and looked for 'issues' in with the group.)

The on to the Party in the Park - you can see here the stand that was set up and run by Chris and Miriam, Colin and others.

The on to the Carnival Parade - here is the group beforehand.

After the parade, back to Well House Manor for an Indian meal with the course delegates-come-walkers, to whom I owe a huge "Thank You". More on all of these things in the next day or two.

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


Related topics: via article database

July 16, 2010

Unpacking a Perl string into a list

In Perl, you can extract data from a string in a lot of different ways. You can split the string if you want to use a uniform separator, you can use a regular expression if you want to grab out bits that match a pattern, and you can use substr to extract data based on specific character positions.

Which should I use?

Whichever is most appropriate. If the data is always in the same columns numbers (character positions), then substr may be longer code but faster than the alternatives. And don't forget csv (comma separated variables) and XML modules too.

But rather than have many lines of substr, you may prefer to use unpack. Unpack lets you specify a list of destinations, and a number of columns and series of type conversions. So one line of unpack can replace many lines of substr and at no noticeable loss of efficiency. You can also use unpack if you have binary data held in your string.

I've added an example of unpack in use - [here] - from the current course. And I've also added in an example going the other way - taking a whole load of variables in a list and formatting them up into a string with pack


Perl's functions are documented [here]. The format converters for unpack (and pack) are documented [here]. We cover these functions - briefly - on our fundamental public Perl Programming Courses and in more detail if required on advanced and private courses.

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


Related topics: via article database

Useful link: Perl training

Another toot of the trumpet

Just occasionally, I'll indulge myself and post a customer accolade - with the customer's permission, of course.

Hi,

I was looking for current happenings in bathtubs industry whilst I came to know about your site, Horse Mouth has had impressive content to read that I spent nearly an hour and kept reading, informative posts and very useful blog and sweet horse mouth :)

Regards,
Jasmine

Not quite our target industry, but still happy that someone's found an hour of enjoyment from some of these random articles ;-)

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


Related topics: via article database

July 15, 2010

Moved - Melksham Lorry Park

It was last month that a public meeting in Melksham decided that the Lorry section that's been in King Street Card Park for many years should be closed to all HGVs and PSVs as soon as possible, and the signage for "temporary" closure has now arrived. [article]. Here it is ... and the fully published intent is that it should be made a permanent closure as soon as possible

Somewhat confusingly, the signage from the times that the powers that be were much more accepting of the need for long distance lorry drivers to stop somewhere in the area are still in place

I have two questions to ask the people who decided to close the lorry park:

1. What are you going to go with that big empty space you've left in the town?

2. Where can the heavy vehicles that don't have a base in the town park instead?

All pictures taken yesterday evening.

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


Related topics: via article database

July 14, 2010

Moving from Python 2.6 to Python 3

When should you move your development to Python 3? When you're good and ready and you're certain that you'll not need to run your code on Python 2 again. Up to that point, the 2to3 utility will convert code for you.

Here's an example where I converted a short example script called "london" - using the -w option to write the file back, moving the old file to a .bak file. You can see in the reports the changes that have been made.

wizard:python graham$ 2to3 -w london
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
--- london (original)
+++ london (refactored)
@@ -2,7 +2,7 @@
 
 vatrates = (15,17.5,20) ;
 
-paid = float(raw_input("Whatdya pay furit? "))
+paid = float(input("Whatdya pay furit? "))
 
 for vatrate in vatrates:
  factor = 100.0 / (100.0 + vatrate)
@@ -10,6 +10,6 @@
  shopkeeper = paid * factor
  osborne = paid - shopkeeper
 
- print "Vat rate",vatrate,", Storeman ",shopkeeper,", Chancellor ",osborne
+ print("Vat rate",vatrate,", Storeman ",shopkeeper,", Chancellor ",osborne)
 
- print "izedone"
+ print("izedone")
RefactoringTool: Files that were modified:
RefactoringTool: london
wizard:python graham$

See [unconverted] and [converted] code.

Picture - delegate on a Python Course earlier this week. (You learn a lot on our courses - and we make them fun! as well.

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


Related topics: via article database

Useful link: Python training

Old prices - what would the equivalent price have been in 1966?

What did a cup of tea in a café cost 10 years ago? 20 years ago?

What was the rail fare from London to Manchester in 1966, 1976, 1986, 1996 and 2006?

Such questions prove to be very hard to research and find answers for on the Internet. I suspect that's partly because the Internet wasn't around in those days, partly because suppliers want their current prices to prevail so that customers aren't confused, and partly because suppliers want to have you forget as quickly as possible when they have put their prices up. It's called suppressing history!

I did manage to find that the rail fare from London to Manchester was 5 pounds in 1966 - I'm not sure if that was single or return. How does that compare value-wise to today's standard return fare of 262 pounds?

I HAVE managed to find an inflation file for - I'm guessing - retail prices, and I used the question I've asked above as an exercise on the Python course I started on Monday and Tuesday (and will conclude at the end of next week - delegates want time to try things out, and need time to do their other work!). The source code is [here] and the inflation rate file [here]

Let's see how that works for the train fare:

wizard:python graham$ python inflate
What does it cost now? 262.00
When do you want to go back to? 1966
In 2009 it would have cost 263.32
In 2008 it would have cost 253.19
In 2007 it would have cost 242.75
In 2006 it would have cost 235.22
In 2005 it would have cost 228.82
[snip]
In 2000 it would have cost 202.46
[snip]
In 1995 it would have cost 176.54
[snip]
In 1990 it would have cost 141.11
[snip]
In 1985 it would have cost 109.16
[snip]
In 1980 it would have cost 69.31
[snip]
In 1975 it would have cost 33.68
[snip]
In 1970 it would have cost 21.33
In 1969 it would have cost 20.24
In 1968 it would have cost 19.33
In 1967 it would have cost 18.86
In 1966 it would have cost 18.15
wizard:python graham$

So that means that today's 262 return would have been 18.15 return in 1966. Hmm - that makes the 5.00 look excellent value whether it's single or return. It's also a bit of a headscratcher ... with more efficient systems, higher passenger numbers giving the benefits of scale, why on earth has the cost risen so much in real terms?

I don't know the answer ...


Illustration - on the Python Course


Comment from Anon - 15th July

You may find the data on inflation and prices you were seeking at www.data.gov.uk or maybe at least a pointer of where it might be stored.

An inflation measure that I find interesting is that here in Wiltshire for every £100 of community charge, charged in 1993/4 by the then West Wiltshire District Council (at the time when the community Charge was first introduced) the charge made by Wiltshire Council in 2010/11 is £279.06 and that for every £100 paid in state pension in 1993/4 the payment is now £163.25. A difference of £115.81.

I know that it is argued that the pressures on local authority inflation and the numerous changes in government funding to local authorities accounts for a lot of the increases and is very different from the RPI or CPI that faces the individual. However, it is little wonder that some elderly people in some locations have felt strongly enough to object to the point of being sent to prison for non payment of their community charge. A local authority can set its community charge within certain central government guidelines and the local residents have little choice but to pay, unlike seeking a service from the private sector where there are usually opportunities to seek alternative suppliers offering competitive prices and providing the service the buyer really wants.

I think you were searching back as far as 1966 - I cannot go back that far but from 1984 the general rate charged by the then newly formed WWDC through to community charge and council tax now charged by Wiltshire Council has increased has been almost 758%.

Further comment from me

All this makes me realise just how complex inflation figures are - and how relative values change over the years. What I was really looking for was how many miles you can travel by train for the price of a cup of tea in at various key times.

Looking at the detail, I guess a lot of it comes down to how service based a product is, and how much methods and technologies have moved forward - the computer I'm typing at has come down in price ...

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


Related topics: via article database

July 13, 2010

Contact Information for Melksham Oak Community School

Yesterday, 449 people arrived at our web site searching for "Melksham Oak" or similar terms ... not bad going, except we're not in the business of selling Melksham Oaks!

Almost undoubtedly they were looking for the new Melksham Oak Community School which is just up the road from us, and opened yesterday ... but doesn't yet have a good web presence. So Lisa was busy handing out their phone number (01225 792700) and address (Melksham Oak Community School, Bowerhill, SN12 6QZ) and I have found their web site (http://www.melkshamoak.wilts.sch.uk/).

It seems we're not the only ones who are being found by people looking for the school ... as I was walking the dog the other day, I learned where the school's early mail deliveries might have been going ;-)

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


Related topics: via article database

July 12, 2010

A move towards the family

Over the weekend, Chris and Delene moved - from Calne to Melksham, from a shorter term home to one where they hope to settle down for many years, and from one which was just a house to one which has some very specific features and prospects that can make it truly their home.

With a short move, and a limited amount to bring over, it was "white van" time rather than a full removal company job - and I spent Saturday (between checking out guests, changing a room, and checking new arrivals in) driving said van. Pictured here - Chris. I do enjoy - for a change - driving a vehicle that really needs driving!

Their new place is a bungalow - set amongst bungalows and overlooking a green; here's the view from their front window. They've got a big back garden too, a shop within 100 yards, and it's very much a community that they're moving in to - the sort of place where they'll know the neighbors rather than a dormitory area.

On Friday, it was a shell with walls and services. The flooring folks were waiting outside as Chris and Delene arrived with the keys. And within a couple of hours, we could start shifting - an empty canvas into which to pour and construct a new life.

Over the weekend, the house has gone from empty shell to box store impersonation, and back towards that happy middle ground as critical first items are unpacked and set up, and the start is made on a new life in Melksham. I won't post any intermediate pictures, but I do hope to be able to come back and add an "after" to the "before" picture that's above.

Being about five minutes walk from our place, we expect to be seeing a lot more of Delene than we have; a little more of Chris too (as he works with us, we see him quite a bit anyway), and of course our grandchild when she arrives. But at the same time, I hope that the "seeing" will be a chance to practically help too (that they won't feel they have to be tidying because grandparents are coming!), and that Lisa and I will be sensitive enough to give them plenty of space and not overstep our welcome. Actually, I feel happy that they can gently nudge me if I'm headed that way.

Delene and Chris, welcome to Melksham. I hope you'll enjoy it here and find the town as good and appropriate for you as we find it.

Posted by gje at 05:26 AM | Comments (0)


Related topics: via article database

July 11, 2010

Cycling in Melksham, and looking forward

At the West of England partnership meeting last Tuesday, I attended one session that was looking towards healthier and greener transport; to a very great extent, that session had been taken over by the advocates of cycling - and indeed they had the most dramatic increases in cycling to report, and it's very likely to continue to be a big growth area, with official targets being set and handsomely achieved, and talk of more radical ones to be set for the future. And at the Melksham Climate Friendly Group meeting last Wednesday, we saw proposals for a cycle route through back streets and paths from the south to the north of the town - to cut out the main road routing of cycles through the town at present.

But success of cycling campaigns and a dramatic increase in numbers is leading to conflicts between cyclists and walkers in places. I listen to the talk on the new route of a couple of "pinch points", I look at the recently painted markings on the pavement just 100 yards up the road from us, and I'm a little worried. Health and safety has (in my mind) been overdone at times - but this work which appears to designate a cycle path in the middle and two tiny walkways to the side - one in the bushes, the other beside the A365 with cars and heavy lorries whizzing past within inches - strikes me as an accident waiting to happen. I do hope that time proves me uninformed and wrong on this.

But why is that pavement looking so clean and new? Because is is new - newly widened, and extended further out of the town to the new Melksham Oak school. It's the main walking and cycle route to the school from the town, so in the morning before school starts, and in the afternoon when school breaks for the day, it should be rather busy. It's certainly expected by "the powers that be" to have significant traffic, judging by all the investment they've made in it - and the three new light controlled pedestrian crossings installed off it.

A letter to the editor in the most recent edition of the Melksham Independent News is headlined "An Apology to the people of Seend". Written by a resident from near to the old George Ward school - at the other end of town (resident withheld name), it's a song of joy that the school is moving away, taking its litter problems, children who answer back on their way to school, etc, away from that end of the town. Now I know that we'll have to be a lot more careful as we pull out of our driveway, that there probably will be more litter, that the dog will have to be on our lead more ... when the school is open for pupils just a few hundred yards from us. And the letter to the press gives us cause for concern - asking "what do we have coming to us?". But then I look at the care home for younger people that arrived in our street, quietly, a year or so back, I look at the huge extra building program in Bowerhill since we arrived and see much more foot traffic, I look at the groups that I've seen before going to and from the old George Ward, and I wonder "can it really be that bad?". The answer has to be "I don't know", but I have grounds for optimism as well as caution; the correspondent to the paper seems to have his/her facts wrong - the school's over a mile through the countryside from Seend, and much of the text reads as if it's from a person who was perhaps a little frightened by the groups of younger people that a school inevitably brings. And who met that fright by an aggressive and somewhat overloaded response which only served to make small matters into big ones.

I know we'll have small matters with the new school, as we have elsewhere as the town develops / changes / grows. But I look forward to those changes as a positive move for the future, and I'm sure the community can and will work to resolve those tiny matters.

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


Related topics: via article database

Ruby - how does it compare and where is it the right language?

I heard Ruby described as "Perl Five and a Half" - and I thought "how apt".

Perl is an excellent programming language - it's especially excellent as glueware or middleware, where it melds together differing technologies, protocols, utilities and other programs to provide a total solution. But Perl's features largely date back to its eclectic origins 20 years ago, and whilst it remains excellent - perhaps the best tool in many cases - it also need a major refresh; that's the Perl 6 project, and a story for another day.

Ruby is ... what the next version of Perl (after Perl 5) might have been, but removing those shackles of the requirement for compatibility with old code which make it difficult for Perl to move seamlessly, and without kludges and complications, not the new world. So what does this mean if we compare their uses, now and into the future?

Ruby is "Object Oriented from the start". So - uncompilable by history - you can write your code for each type of data that you'll be using just once, and share it between a number of associated programs. Ruby isn't constrained by slower processor speeds from when it was specified, so the language is packed with features which give you maximum power for minimum coding effort (rather than minimal processor cycles and memory)

Of course, if you have an established code base of routines in another language, a change would lead to some major rewrites and be a major investment, so the movement to the adoption of a new language can be quite slow, and you'll find that early movement might lead to one or two "killer apps" - applications which are so predominant that they drown out the publicity that other budding uses get. The killer app for Ruby is Rails - as in "Ruby on Rails" - and it's taken scripting onto the web, using a "Model - View - Controller" architecture which allows the look and feel of a web application to be separates from the calculation / data storage / business logic. That way, you can change your algorithms without having to redesign your web site, or you can give your website a fresh coast of paint without having to renew all the wiring and plumbing at the same time!

Let me add another language to the mix - Python. I love working with Python; it's a superb Computer Scientist's language, it's got a simple elegance and it's right for the researcher. Like Ruby, Python has taken over areas from Perl, and indeed I'll say that Python's often a good choice. But - as with Ruby - there would also be applications where it would be less than ideal.

This is a Ruby-based post - I'm writing it to position Ruby. So let me conclude by giving thoughts of where Ruby would high amongst the factors that I considered for an application:

• Areas where quick coding to meet specific one-off tasks, but mostly on the same types of data, is required

• Areas where some of those one off tasks expand to become more complex and regular in how they run

• Areas where interaction with other programs (be they operating system commands or applications) is important

• Where code is being written by staff who's primary job is perhaps not "programmer"

• Where there is already a base of Ruby objects, or where there's no existing codebase in another language that yuo would need to rewrite. "Green Field" rather than "Brown Field" sites.

So where would I choose something else?

a) Where the coding was likely to turn into a major project, along the manmonths to manyears of programming lines, with the need for many programmers to be interacting and sharing coding. I would be looking at Python before Ruby, and I might also take a glance across to languages such as Java

b) With a strong existing Perl base, with a need for very quick one-liners as my predominant application, I would still use Perl. That's a pragmatic decision to a very great extent; there's nothing wrong with Ruby for oneliners, but a oneliner is often a line that calls in already written code, and if that's in Perl ...

c) If performance speed and cpu usage is critical, and development time less so, I would be looking at C or C++. There's no point in writing a piece of weather forecasting that runs slower than the weather happens, except for research purposes. And if you have an application that's going to run resource-critically on thousands of computers (search engine, programmable device such as iPad or iPhone) ...

d) Where a tiny runtime footprint is required, a good mix of coding speed and running speed, and a license that lets your code be widely distributed without payment / licensing issues, nor "viral licensing" which forces your code to be open source too if you distribute it. Such applications are prime candidates for Lua.

And of course I'm unable to run Ruby in a browser (Flash, JavaScript, Java Applets etc are possible choices here) or if my management has specified that all system software much be Commercial Products.

I mentioned earlier that Ruby's predominant application is Rails - so you'll find a number of "Ruby on Rails" training course available that are designed for that application. You'll find far fewer vanilla Ruby courses - but if you're going to be using Ruby as a scripting language for systems admin, as a powerful data analysis language, in Selenium or Watir, etc ... they it's the more vanilla course that will be the one you need. But Rails is predominant, so those other courses are "niche" - which is where we specialize.

If you're new to programming - Learning to program in Ruby. If you've already got programming experience, Ruby Programming. Both of those courses cover all the various bits and pieces of the core language. If you want to have an overview of Ruby's use on the web, through Rails, then stay on for another day - Introduction to Rails - which will give you that overview. You may be thinking that you're a systems administrator and not a web page writer, but the ability to call up you server information through a browser, and to run common admin tasks from that interface, and from any computer, is a capability not to be sneezed at!


This article is illustrated with pictures of our training centre, and a course that's taking part there. We're situated about 100 miles to the west of London, in secluded grounds just a few minutes walk from the town centre of Melksham, Wiltshire. The quiet environment in designed for concentrated study and effective learning - you won't hear the phone ring (our HQ and offices are on a different site in the town), and you'll have plenty of space on the course to work - for a computer (or even two), for your course materials, and for taking notes.

As a provider of niche courses, delegates come from far and wide - and at well as training rooms, we also offer hotel (four to five star standard) rooms. You can book a room inclusive with the course, or if your company procedures insist on it being a separate booking, that's fine too. By staying on site and with other delegates, you get the opportunity to extend your practical sessions into the evening, and to spend time with other delegates learning more about them and their use of the subject being taught - ruby in the case of this article. Our rooms and hotel are designed with the technical business guest in mind - from a very broad broadband connection, through desks and plenty of power points in all rooms and bean-to-cup coffee on self service 24 hours a day, to large double beds in all rooms, a minimum age for guests of 14, and a key card and staffing system that lets you check in early or late, come and go as you please, and pay as a part of your course on a company account, or when you're with us.

The majority of delegates stay with us - but some don't; if you live within 30 minutes drive, have friends or relatives in the area, or a company policy that insists on a certain chain, or for any other reason, we're happy for you to attend the course at a rate that's 60 pounds per day (+VAT) lower.

There's a full schedule of all of our upcoming public courses [here], and at other times we're available for private courses at our centre, or on your site.

Posted by gje at 05:17 AM | Comments (0)


Related topics: via article database

Useful link: Ruby training

July 10, 2010

Relationships between Java classes - inheritance, packaging and others

When you're designing classes in Java, you need to consider their relationship with one another in various ways.

• You need to consider class INHERITANCE - which classes are based on which other classes. For example, a Pet could be based on (i.e. extended from) an Animal.

• You need to consider which INTERFACES your class implements - for that lets you define commonly named methods across a series of classes, and call those classes with the same code, even if they don't use inheritance.

• You need to consider which other classes objects in you class CONTAIN. For example, a Pet object will contain an address object, to hold information about where the pet lives.

• And you may wish to PACKAGE your classes - group them together under a name / named directory so that you can distibute them and handle them as a unit, and so that you can give them more permissions within the group than they would have outside.

Although there are similarities between these relationships, I wouldn't go so far as to sat they're the same, and indeed you need to consider all of them in your design.

On our recent Java Bootcamp Course, I wrote a new complete example of package. There's a "control" example - all in the one class - at Geraldine.java. I then took the object code and put it into a class called Isobel in a package called gowdie. See Isobel.java for that code, and if you want to see how it's called, there are examples in Hattie.java where we're specifying gowdie.Isobel in full every time we refer to it, and in Hilda.java. These new examples all include much more extensive comments - please follow the links if you want to read more programming detail, and to see sample output

Older examples (listed here for completeness, and to provide a link back to this article for delegates with old note sets) are axford.java - calling a class in the current package, sopworth.java - calling a class in a subpackage, sherston.java - importing a class from a package and finally pack.java - the class that's being used by the other examples. The older examples were all about a pack of cards - thus the class name "pack". In training use, the pack-of-cards examples are usually good ones, but in this case I'll admit it was a dumb idea as delegates used to get awfully confuser betwen "pack" - not a reserved word and "package" which has a specific Java meaning.


Footnote ... in case you wonder about the "gowdie.Isobel" class name ... on last week's course, we used names of ladies for classes, then we added famous surnames for associated data. A bit 'silly' / a bit of fun, if you like, and not recommended for production code. But by going through the alphabet, delegates can look back in the future and see the order of the examples just by going up the alphabet.

It turns out that "Isobel" with an "O" is a slightly unusual Scottish spelling of "Isabel" with an "A", and the most famous Isobel was Isobel Gowdie, a Scottish Witch. News to me - I'm not into that sort of thing, but seeing as the class was all about animals, it looks appropriate. Apparently, our Isobel Gowdie claimed that she could take on animal form ...

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


Related topics: via article database

Useful link: Java training

Changing with weather and seasons

In relation to attractions in Melksham. Here's an admission. I've been down to the Conigre Mead Nature Reserve in Melksham a number of times, and quite frankly found it difficult to understand what all the fuss is about. As a wild area, I hadn't expected "post card pretty", but never the less I searched hard for inspiration there, with the continual roar of traffic on one side, and the view of the cemetry on the other.

Then Lisa and I went back - high summer Saturday afternoon - a week or two ago. And I have to say it looked very much more attractive in its wildness. A pretty river frontage, nettles taller than us, with dragonflies and all sort of other insects darting around, young couples enjoying the afternoon, linking up; a surprising tranquillity. Even the neighbouring road was less intrusive - we could have been in the middle of the countryside.


At the Local Transport Planning event last week ....And very nice it looked too ... the artist's impression on the right of the projected slide, showing how a boulevard in the centre of Bristol would look if and when a suggested transit system or some sort is put in, and with cycleways too, and trees, replacing cars. The current set - looking superficially very much less attractive, was shown on the left.

But wait a moment. I can't deny there was a lot of improvement bewtween the pictures ... but much of it was down to the weather and season. An artists impression with trees in full leaf, fluffy white clouds in a blue sky, and the crisp boundary between light and shade where the people (hansome and pretty ones, of course), trees, and bus/tram cast their shadows. And a photograph taken on what looked like a blustery, dull day off season. Grey sky ...

I do hope the scheme that was being shown will deliver perpetual summer weather, a class of people who we'll be proud to have around, and a public transit system that's so frequent that they'll always be a service in each direction somewhere in site. If it doesn't, I might feel just a tiny bit mislead ;-)


Illustrations show Well House Manor and the fields behind Melksham Spa in winter and in summer - a reminder of just hom much the seasons, nature and use change the look of a place during the year.

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


Related topics: via article database

July 09, 2010

Writing a server in Java

My standard recommendation these days is that you don't write your own low level network code - but rather you use standard protocols and classes - i.e. that you use tried and tested ways of exchanging data. And on that basis, you'll find that our public training courses cover things like talking to web servers and services, using SQL servers from your programs, and so on.

But just occasionally, there's still a niche requirement to do something in low level code - perhaps because you're required to work with a protocol that's non-standard, or even because you need your own protocol for some reason. So, yesterday, I found myself doing a public Java course but out of hours also updating an old example that used packages such as java.net to write our very own server - a talker in a single file in Java. I've posting the example to our web site - [source code here] with updates including extra comments. There is also an older article that descibes it more fully [here].


If you came to this page looking for an article on running a Java Server such as Tomcat (a much more common requirement that writing your own), start [here]; that page is our short course description, and we would welcome you for training - however, you'll find links to many of the examples and a great deal of material from that page, even if you can't make it to Melksham, nor do you have enugh people to justify me coming along and giving a course at your office.

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


Related topics: via article database

Useful link: Java training

Fail Safe Error Handling in Java via Exceptions

"What could possibly go wrong?" ... The usual answer from a cynic is "anything, and usually at the most inconvenient time, and in the most unexpected way!". So checking for routine errors in your program code is a good start, but it doesn't go far enough; you need to be able to handle errors which are not routine, and are not anticipated - and that's where the "exception" system comes in.

Exceptions work like this ... you put the section of code that you want to "mop up" any problems from in a try block, and you then provide one or more catch blocks as safety nets - they'll be run only if a certain class of exception is thrown. Multiple safety nets (i.e catch blocks) allow you to trap very specific and narrowly defined issues first, then have further more general nets available if the first ones don't work.

On most exception systems (including Java, who's terminology I've been using so far) you also have the ability to define a clean up block that is always run - a finally block - irrespective of whether or not an excpetion you've caught has cause the code to exit prematurely rather than carry on below (fall through).

There's an example showing the code that relates to each of these concepts [here] from yesterday's Java Bootcamp. It goes little further in that it also illustrates how a method can pass back an exception to the code that called it (rather like a chid asking its mother for help!), and it even defines its own special class of exception, showing how the mechanism can be used to pick up run time problems in your code, as well as in the standard library calls that you make. The source of the extra class that defines your own exception is [here]

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


Related topics: via article database

Useful link: Java training

MySQL and Java - connectivity past, present, and future thoughts

MySQL has migrated from MySQL AB (1995 to 2008) to Sun (2008 to 2010) to Oracle (from 27 Jan 2010)

wizard:java graham$ /usr/local/mysql/bin/mysql -uwellho -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.48 MySQL Community Server (GPL)
 
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>

Java - originated by Sun and release in 1995, is now owned by Oracle too as part of its acquisition of Sun. When I visited the web service page at http://java.sun.com/webservices/ yesterday, I noted the following text at the base of the page:

Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
 
© 2010, Oracle Corporation and/or its affiliates

What does this all mean?

On one hand, the brining together of MySQL and Java under a single ownership has enhanced the strength of the line between them. JDBC (the way that Java connects to all flavours of databases) ships as a set of manager classes only, and you need to download / install the actual drivers youself. In much earlier days, those were from a third party site and the class was loaded as follows into a Java application:
  Class.forName("org.gjt.mm.mysql.Driver").newInstance();
but the the support was taken up by the MySQL folks, and now that's a part of Oracle - I downloaded the drivers from dev.mysql.com yesterday, and now load them as follows into my Java appliaction:
  Class.forName("com.mysql.jdbc.Driver").newInstance();

But on the other hand, I have no crystal ball and I cannot tell you where the Java and MySQL products will be taken; all I can do is to reproduce (for your own review) the text above and suggest that you follow through Oracle's communications if you wish, and that you factor in - as you feel appropriate - all of this information in any decision making with regard to future projects.

You may see my updated "Hello MySQL and Java World" example - which selects data from a database and displays it to the screen - [here]. I've added a whole load of annotation to that example, including test runs and an analysis of standard error messages (and possible solutions) such as:
  java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
and
  com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The original example (but I have modernised the class load call) is [here] and for comparison we have a similar example that connects to an Oracle database [here].

[If you're looking to use MySQL from within Java from within a JSP (Java Server Page), there's a source code example of the class that we use on our Deploying Apache httpd and Tomcat training course [here] (we also cover programming Java Server Pages on some of our Java Courses).]

Posted by gje at 06:33 AM | Comments (0)


Related topics: via article database

Useful links: Java training, MySQL training

July 08, 2010

What methods are available on this Java object?

Q: "What can I do with an ArrayIndexOutOfBoundsException?" for example ...

A: Use the javap utility to ask what methods are available on the class ... and descent into its base class structure too, using further javap calls:

wizard:java graham$ javap java.lang.ArrayIndexOutOfBoundsException
Compiled from "ArrayIndexOutOfBoundsException.java"
public class java.lang.ArrayIndexOutOfBoundsException extends java.lang.IndexOutOfBoundsException{
public java.lang.ArrayIndexOutOfBoundsException();
public java.lang.ArrayIndexOutOfBoundsException(int);
public java.lang.ArrayIndexOutOfBoundsException(java.lang.String);
}
 
wizard:java graham$ javap java.lang.IndexOutOfBoundsException
Compiled from "IndexOutOfBoundsException.java"
public class java.lang.IndexOutOfBoundsException extends java.lang.RuntimeException{
public java.lang.IndexOutOfBoundsException();
public java.lang.IndexOutOfBoundsException(java.lang.String);
}
 
wizard:java graham$ javap java.lang.RuntimeException
Compiled from "RuntimeException.java"
public class java.lang.RuntimeException extends java.lang.Exception{
static final long serialVersionUID;
public java.lang.RuntimeException();
public java.lang.RuntimeException(java.lang.String);
public java.lang.RuntimeException(java.lang.String, java.lang.Throwable);
public java.lang.RuntimeException(java.lang.Throwable);
}
 
wizard:java graham$ javap java.lang.Exception
Compiled from "Exception.java"
public class java.lang.Exception extends java.lang.Throwable{
static final long serialVersionUID;
public java.lang.Exception();
public java.lang.Exception(java.lang.String);
public java.lang.Exception(java.lang.String, java.lang.Throwable);
public java.lang.Exception(java.lang.Throwable);
}
 
wizard:java graham$ javap java.lang.Throwable
Compiled from "Throwable.java"
public class java.lang.Throwable extends java.lang.Object implements java.io.Serializable{
public java.lang.Throwable();
public java.lang.Throwable(java.lang.String);
public java.lang.Throwable(java.lang.String, java.lang.Throwable);
public java.lang.Throwable(java.lang.Throwable);
public java.lang.String getMessage();
public java.lang.String getLocalizedMessage();
public java.lang.Throwable getCause();
public synchronized java.lang.Throwable initCause(java.lang.Throwable);
public java.lang.String toString();
public void printStackTrace();
public void printStackTrace(java.io.PrintStream);
public void printStackTrace(java.io.PrintWriter);
public synchronized native java.lang.Throwable fillInStackTrace();
public java.lang.StackTraceElement[] getStackTrace();
public void setStackTrace(java.lang.StackTraceElement[]);
}
 
wizard:java graham$ javap java.lang.Object
Compiled from "Object.java"
public class java.lang.Object{
public java.lang.Object();
public final native java.lang.Class getClass();
public native int hashCode();
public boolean equals(java.lang.Object);
protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
public java.lang.String toString();
public final native void notify();
public final native void notifyAll();
public final native void wait(long) throws java.lang.InterruptedException;
public final void wait(long, int) throws java.lang.InterruptedException;
public final void wait() throws java.lang.InterruptedException;
protected void finalize() throws java.lang.Throwable;
static {};
}

I can feel a bit of scripting coming on (Jython would seem appropriate!) if I wanted to do that sort of thing on a regular basis!

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


Related topics: via article database

Useful link: Java training

July 07, 2010

Using java, javac, jar, and CLASSPATH - a simple example

What Version of Java am I running? How do I edit, compile and run a Java program? What does this error message mean? How do I puts lots of classes into a single file, then run them from that file? How do I see what's in that file? How do I get Java to look for a class it needs in a series of places?

All good questions asked early on a Java course. And I answered them all earlier today. I have annotated the log [here], and you'll find the source code of my sample classes too - Annie, Bella, Chloe and Debbie.

From a Java Bootcamp Course, but taught on some other courses too!

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


Related topics: via article database

Useful link: Java training

The healthy option - away from the private car

"I used to take the train from school." No - that's a simplification. I walked to the station (Sydenham Hill until the age of 11, Sevenoaks until 17), took my train, then walked a mile home in Petts Wood. Every half hour, the 161A bus connected there with the train (ah those days of proper co-ordination!) but personally I walked.

These days, pupils are more likely to be driven, door to door, to school. "Safer" they say. Hmm - but far less healthy. We're becoming an obese generation ourselves, and we're bringing up a new more-obese generation too. Incredibly, I understand that the average brit now consumes 20% less calories than they did 40 years ago [year figure may be wrong], but we burn so much less as we live so much less of an active life style. Sedetory jobs, a bit of a waddle to sit in the car, and a waddle to the sofa in front of the TV.

So I'm encouraged when I see rail ridership figures rising dramatically, bus figures drifting gently up, and hear of people saying how hard it is becoming to find space in cycle racks and on trains for their cycles. And I rejoice when I see the foot flow out of somewhere like Temple Meads in the morning.

A new school opens at Melksham Oak - just up the road from us - soon. The full term there starts in September. And the road past our front gate is the only walking route from the main town to the school. It's the cycle way too. We've already got to be careful as we "nose" a car out on those mornings that we do drive somewhere, and I actually look forward to having to be even more careful - to seeing the next generation getting their 30 minutes of exercise per day and helping to prevent the next generation becoming the obese generation.


The top picture is a public domain one ... and I haven't a clue who is pictured. The second picture is one of mine - see our copyright and shows a random selection of people unknown to me.


Comment from Anon ...

I am not sure that our new government is that bothered about the population remaining fit and well. I noted in the Blue Pool, Melksham this morning there is a notice stating that the concession brought in by the last government in April 2009 for the under 16s and the over 60s to go swimming without charge will be withdrawn from the 31st July 2010 and from the 1st August will be required to pay.

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


Related topics: via article database

July 06, 2010

Park and Ride at Batheaston - will it solve Wiltshires Ills?

What's the point of having a Park and Ride on the outskirts or a large town of city?

I hadn't really given it too much thought until today, when I visited the West of England Partnership and listened to their Joint Local Transport Plan 3 presentation. They look after North Somerset, South Gloucestershire, BaNES and Bristol.

Travel plans need to consider a complete travel to work area - and not expire at political boundaries. There's no real need to consider people who live 12 miles west of Weston-super-mare; there are none, as that puts you in the middle of the Bristol Channel. But you do need to consider people who live 12 miles east (or south east) of Bath as they're in towns like Box, Corsham, Melksham, Chippenham and Bradford-on-Avon. We learned today that 26000 people commute into Bath and that 76% do so by private car; not all from the Wiltshire toens I have mentioned, but for sure a significant number.

What's the point of providing a park and ride at Batheaston for these people? Aren't you simply replacing one car park in the centre of the City with another on the outskirts, and adding in the complexity of a transfer system? And just for the saving of having people drive that last four miles? There's a lot of talk about choice, and people who don't or can't have a car but when you think about it, the park and ride does nothing for them, does it?

Let me offer you another approach. If you've got a car and want to go into Bath from Wiltshire, why not park it at home and ride from there? The need for exercise was highlighted today - and that's a walk to the bus stop, or a cycle ride. Perhaps feeder buses to the trains at Chippenham, Melksham or Bradford-on-Avon, of indeed feeder buses to other buses.

I presented this in "just a minute" (I'm a fast talker - I took less!) and I know that one Bath Residents chap was huffing and puffing - got up after me and said emphatically "I am in favour of the park and ride". Well actually so am I - but scaled down to provide for those it should provide for - the people from Wraxall and Biddestone and Gastard who don't support a regular bus, for example.

If we're going to cut Co2, let's cut it all the way. If we're going to cut private cars, let's cut them all the way too. Lisa and I have mentioned / thought of the possibility of reducing from a 2 car to a 1 car family. Not easy if she's got to run a business errand while I'm away, but I would certainly like to. I'm taking to more trips by public transport, but the carrot's not big enough yet ... and it doesn't matter how much you beat us with a stick, if we cannot do it by public tranport we can't take a juicy orange bite!

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


Related topics: via article database

Two sides of the coin

If you want to know a whole story - look at both sides of a coin. And if you want to know more than what you're being told, listen to what other people are being told.

The A350 / Westbury Bypass enquiry is water under the bridge now - so this is purely academic interest - but I was told (and frankly doubted) by the traffic modellers that their work showed that there would be no significant change in traffic levels on the A350 once you got north of Semington. And yet today, Peter Dawson from Bath and North East Somerset was telling the residents of Bath that they had hoped to ban lorries from the A36 and send them up to the motorway via the Westbury Bypass and A350, but now that they bypass had been rejected their plans were in tatters and they would have to find another way.

So do I now know the whole story? No - I don't think I do - I don't understand how the heavy lorries could have been sent via the A350, and yet the A350 have no significant change in traffic levels. Is there a missing piece to this jigsaw, or was someone being less than honest in what they were having us believe?

As I say - just academic interest. But a tale to learn from.

You'll also learn a lot if you look at what a Train Operating Company tells its passengers ... and also look at what they tell their shareholders at the AGM


14th July - And (but known to me) writes:

The plan to close Bath as a through route between the A46 to the A36 for commercial vehicles was something that concerned me from when it was first mentioned many years ago. At one time I regularly drove between Bath and Warminster and saw the A36 as cluttered with lorries as the A350. However in recent years the number of lorries using the A36 has become less and less. I think that many drivers transferred to the A350 (by leaving the motorway at junction17 instead of 18) at the time the Chippenham bypass was opened making the route to Warminster an easier option than driving through Bath and then a couple of years ago there were two very long periods when the A36 was closed at Limpley Stoke for road works and I think the remaining drivers transferred to the A350 never to return to the A36.

I have not put this in your comment section of your Horse’s Mouth (Permission given - Graham) because whenever I suggest this to local councillors and transport experts I am told that I am not correct and that at least 75% of commercial vehicles on the A350 from junction 17 to Warminster are local traffic in that they are delivering to the local area.

More recently you may have read that there have been moves by the Marlborough Area Board to close Marlborough to commercial through traffic although I think the main closure bids came from people living in the villages along A346 and A338. I noted that this has now been put forward to Wiltshire Council for consideration, even though I was told only months ago that the proposal would go nowhere. I understand that lorries joining the A346 at junction 16 of the M4 will now drive on to J13 and use the A34. I suspect many of these vehicles come to J16 via the A417 / A419 and so looking to the future I suspect that they will they find staying on the M5 to join the M4 to leave at J17 and use the A350 to the A303 a better option. Of course their return journey would be the reverse. Again I am told my guess assumption is not correct but I raised the query with a transport manager from outside the area recently and he supported my view but added drivers have their individual preferences routes, for stopping places and so one could not be sure. I guess only time will tell.

On to another subject and following the Government’s recent request for details of laws that could be modified or even abandoned to improve daily life I wrote to Duncan Hames drawing his attention to the duplication of bus services running just minutes apart locally and in other parts of the country and suggested that the logic of the law was correct to bring about competition but now needs to be redrafted to ensure buses run over similar routes by competitors are equally spaced in time interval throughout the journey route to provide a better service to the public. Last Friday morning in Melksham there as a 234 an X34 and a few minutes later an X31 and 231 all following one another nose to tail. [See [here] - G]

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


Related topics: via article database

July 05, 2010

Train Services - Melksham to Bath and Bristol (and airport)

One of the most popular journeys from Melksham is to Bath (about 12 miles away) and Bristol (around 25 miles). Here's a complete timetable for Melksham to Bath Spa and Bristol Temple Meads for Summer, 2010 (probably unchanged to December 2010, but please check)

Monday to Friday

Melksham06:4107:1719:1119:47
Change atTrowbridgeChippenhamTrowbridgeChippenham
Bath07:2507:5920:1120:30
Bristol Temple Meads07:4508:1720:2920:44


Bristol Temple Meads06:0018:3018:49
Bath06:1118:4119:06
Change atChippenhamChippenham Trowbridge
Melksham06:4119:1019:47

Saturday

Melksham09:2015:2115:4621:34
Change atChippenhamChippenhamTrowbridgeTrowbridge
Bath10:0016:0016:3622:36
Bristol Temple Meads10:1516:1516:4822:44

Bristol Temple Meads08:2314:2315:0020:33
Bath08:3514:3515:1120:44
Change atTrowbridgeTrowbridgeChippenhamChippenham
Melksham09:2015:2115:4521:33

Sunday

Melksham17:2518:4519:52
Change atChippenhamTrowbridgeChippenham
Bath18:3919:2720:39
Bristol Temple Meads18:5319:3920:54


Bristol Temple Meads16:1318:0018:50
Bath16:2718:1219:01
Change atTrowbridgeChippenhamTrowbridge
Melksham17:2518:4419:52

Why am I providing this information here - because it's hard to find elsewhere. You have to correlate several timetables if you use paper, you have to make multiple enquiries to work it out on line. And you have to know how to do it!

Melksham is on the TransWilts line - see [here] for the railway campaign group for the line area, and [here] for the new TransWilts Community Rail Partnership. Wider rail issues in the South West are discussed in the Coffee Shop.

The journey from Bath to Bristol is also possible by bus - roughly once an hour during the day. Example - Melksham 10:08, Bath (change buses) 10:54 to 11:12, Bristol 12:08. In reverse, Bristol 08:45, Bath (change buses) 09:42 to 10:00, Melksham 10:40. Last connection back from Bristol if off the 22:00 bus, 23:08 from Bath, arrives Melksham 23:43. Services 271, 272 and 273 Melksham to Bath, and X39 and 339 Bath to Bristol.

Check train times and prices with First Great Western. Check bus times with First Bus, Bristol. This page is provided to the best of my ability to read their timetables, but I can't be held responsible for errors, nor the consequences thereof ... and certainly not for late running, cancellations, and traffic jams making a complete mockery of the timetables in bad weather or when there's a major something going on!


Going to Bristol Airport? Connecting buses - the Bristol Flyer - run every 10 minutes (every 20 minutes in the evening) from Temple Meads Station to the Airport. Example journey, Monday to Friday:

17:45 leave Bristol Airport
18:10 to 18:30 changing at Bristol Temple Meads (bus to train)
18:53 to 19:01 changing at Chippenham (other side of the platform)
19:11 arrive Melksham Station

07:17 leave Melksham
07:30 to 07:45 changing at Chippenham (other side of platform)
08:17 to 08:40 changing at Bristol Temple Meads (train to bus)
09:05 arrive at Bristol Airport

Connections shown are official connections from the First Great Western Timetable planner.

If you're not using a bus timetable, plan to be at the bus stop at Bristol Airport 60 minutes before you train leaves Temple Meads, and to arrive at Temple Meads at least 60 minutes before you want to arrive at the airport.

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


Related topics: via article database

July 04, 2010

Melksham Food and Drink Fair and Town Crier Competition

Sunday, 4th July. American Independence day. Melksham Food and Drink Festival Fair. Town Crier's competition in Melksham. T4 on the beach in Weston-super-mare. Heddington Steam Festival. Bristol Wine and Food Fair ... so much happens on summer weekends, in so few days. And that follows on from Atworth and Semington Village Fetes the day before too.

Can you guess which two celebrations we attended this lunch time and afternoon? The Town Crier competition is an easy guess - the criers (pictured here) and their escorts making a coloruful show in the Market Place, and even away fromthe Market Place as we walked towards Well House Manor, we could here them long past "The Limes" and almost to "The Regency". See further pictures and information [here], and read and see last year's event [here].

The other event we attended will be slightly harder to work out - but only slightly harder. It was the fair that was the last event in the Melksham Food and Drink Festival. I was "off duty" today in that I had no booth to man, no official function - but very much on duty wearing various hats. It was good to see various Community Area Partnership Steering Group members mingling amongst the crowds, excellent to catch up with a clutch of town concillors, and marevellous to see everyone mixing and having a good time.

But in reallity "off duty" isn't the full story at the Fair. One of the things that we are particularly on th elookout for is local suppliers of products for us to use at the hotel for our guests. We want - we REALLY want - to supply fresh local produce where we can, but to do so in line with the taste of our customers, at a price that doesn't make our operations expensive and drive people away, and at a supply level where we're not going to suffer major wastage. We would also prefer not to have too many suppliers, and to have suppliers who can consistently provide a product or range so that we can reliably tell our customers what to expect, and be sure that we can indeed do so. We also have to watch out for that "local" supplier who turns out to be little more than "pass through" agent for some products ... "we grow all our own xxxx in yyyy in Wiltshire" say some, and indeed they do - but order "zzzz" from them and it's marked on the delivery as Republic of South Africa or Brazil. Not necessarily a problem, except if we've already sold customers on local produce ... or if we're using that supplier for their local produce then only buying "remote" products from them.

I digress. We did find a couple of good potential suppliers - make contact with one company who we've intended to talk with for a while, and found another who have a product made in the local Melksham area and sold from a Bowerhill address. And "a couple" is good, bearing in mind the stable and long term relationships that we want and have with our suppliers. More picture, and a little more commentary, on the food festival [here].

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


Related topics: via article database

Transport in Wessex - today and into the future

Yesterday, we drove to Chippenham and back - three of us in a five seat car. The three of us then drove to Atworth, and two drove back to Melksham. One returned to Atworth, and then three of us from Atworth to Potterne, two of us on into Devizes, and two back from Devizes.

Look at all that fresh air we carried around during the day ...

2 seats, Melksham to Chippenham
2 seats, Chippenham to Melksham
6 seats, Melksham to Atworth
3 seats, Atworth to Melksham
2 seats, Atworth to Potterne
3 seats, Potterne to Devizes
3 seats, Devizes to Melksham

And - believe it or not - we were being more efficient than many. For only one of these journeys was there just one person in the car. And two out of the five people who were in the vehicle during the day used some other form of public transport as part of their journeys - and that saved the need for more vehicle mileage for pickup runs.


Last Monday, I had to pick up something at a shop in the centre of Bath - at short notice and they couldn't/wouldn't ship. So I thought I would go on the bus that leaves Melksham Market Place at ten past four, getting to Bath at four fifty, then getting my precious package and coming back on the train - to arrive at Melksham station at 19:11 - the same time that a customer was arriving, so I could give him a lift to the hotel. So I parked, a couple of minutes after 4, at Melksham Station.

I walked up the station approach, crossed the road, and crossed the railway bridge heading for the nearest bus stop (the buses pass the station approach, but no-one has actually provided a bus stop there!!) ... and as I headed across the bridge, the bus I was going for went past me. I looked at my phone (clock synced to a satellite) and it confirmed that the bus was running early - it should only just have been pulling away from the town centre, several stops previous. Of course, I should have known better - some of our buses are notorious for running early [link]. Anyway - I carried on to the bus stop to see when the next service was.

Well - there's a bus stop sign there. But there's no shelter. And there's certainly not one of those nice "next bus due" signs that you'll see in smaller but posher towns like Bradford-on-Avon. And, more critically, there isn't even a printed timetable. I'm trying to remember if the stop sign even had routes or destinations on it.

Always the optimist, I crossed the road to the bus stop where people get off if they're coming from Bath. It of course has a shelter. It also has a timetable board, which contains the current 271/272/273 time - but ONLY in the direction out of Bath. There's a nice area of blank space where it would be so easy for someone to have put a timetable for the other direction too. But no-one has actually done that.

Hmm ... I suppose I should simply take the car into Bath ...

But, no, there's a bus at half past each hour to Chippenham, and I can get the train into Bath from there with enough time to shop before the 6 p.m. shop closing, then get back for 19:11. So I walked over the station bridge, onto the next fork of the road (my goodness - no-one has provided a footpath along the side of this road from the station to the bus stop) and up to the stop outside Aldi. For route 234.

You'll probably guess ... no shelter (nice day, not worried), no electronic "next bus sign". (not suprised - after all, this is Melksham not B-o-A) and no printed timetable. Oh - never mind - I know they're at half past the hour or so.

16:30 comes. 16:40 comes. No bus. Plenty of cars with plenty of empty seats. A couple of private buses running empty, and lots of private coaches passing on this trunk route from Glastonbury to places north. But no service 234.

A horrid though, and a scramble to look up the bus times on my mobile phone (big struggle - I'm tempted to say that no-one has actually put bus running information into an easy app, but I may be being very unfair - it may be there, but not to my knowledge). And - guess what - there isn't actually a bus at 16:30. 13:30, 14:30, 15:30 ... yes - but as we get to the time of day that people are going home, there's a gap of an hour and a half in what's a "clock face" service through the day. I'm sure it makes sense to someone, but it sure as heck leaves a gap in provision at just the time that provision would be reaching its peak usefullness!)

Hmm ... I'll simply have to take the car into Bath ...

And I did. The sad thing is just how quick and easy it was. I know Bath a bit and where the traffic jams, so I went through the back of Bradford-on-Avon, up Brassknocker Hill and back down Widcombe Hill, and parked roadside in Widcombe. Free parking for an hour, spaces available at that time of day, and a pleasant walk over the river and under the railway. Package collected, back to the car and back home (down Claverton Hill to avoid the jams at that time on Brassknocker) ... and I was early enough to be home in time for an hour's break before goong back to the station to collect my visitor.


I'm told that - almost alone amongst British Counties - that the CO2 footprint of Wiltshire, at the core of Wessex, got worse last year. And I'm told that one of the possible solutions being looked at is to try to reduce the amount of travelling that people have to do. I've been asked what my opinion is of that - bearing in mind that I'm pressing for an improved train service, and that removing people's need to travel could reduce the case for said service.

For many people, time spend travelling is time wasted. If you're driving a car you are allowed to listen to the radio, you can think (no law against that!) but you can't write / make notes. On a bus, writing and making notes is often impractical. So cutting people's needs to travel using these modes has big advantages over and above the CO2 advantage, and it makes big sense. I've always felt there's an irony at holiday times when lots of people from London go to Devon and Cornwall - places around Exeter and Plymouth, and people from Exeter and Plymouth go to London for a holiday; it's ironic but understandable as it broadens people in a way that staying at home would not. But less understandable / justified is the daily commute by of many miles and several hours. If the "several hours" average commute time can be reduced, if more could be done during that commute time, and if the CO2 of the journey can be reduced at the same time, that'll be excellent news. The actual mileage is, I think, pretty irellevant.

So how do we do it? Well - yes - we should plan and move towards jobs closer to home. That's not to say everyone should work from home; there get to be balance points. Communities too small and you don't get the benefit of size. Too large and your logisitical problems grow. The British Government spend twice as much per head of population subsidising pubic transport in and around London than in the rest of the country - that's partly because the unit cost per head of population is higher as journeys have to be longer, but also (I suspect) because the civil servants who advise on the decisions are mostly London based, and that their political masters are in London at least during the week.

But planning jobs closer to home is only a part of it. We can help reduce the travel time too, and we can help people who wish too make travel time more useful. Let's say I've got an appointment that neds my physical presence in Swindon. I could drive - 60 minutes. I could take the bus - 100 minutes. I should be able to take the train - 25 minutes and useful time too because the train is far more suitable to be a mobile office. Just think about that last case - get on a train into London and see how many people are working at their laptops. And think how many would be using their laptops driving up the M4.

Rail use has grown - in spite of escalating prices - and that's a case of people putting their mouth with their money. Truely, a railway can suit current and future requirements. It's far better, CO2 wise, to run a train with 200 seats, even if 100 of them are empty, than it is to run 3 buses, or 50 cars. And that's 100 people making better use of their travel time, and furthermore that travel time is reduced.

In fact - rail growth has grown so much that in places the system is running at or near capacity, and that presents investment problems based on the need for extra infrastructure and the way the system is structured because of previous political decisions. But there are some places where you've got the line capacity, you've got parallel roads clogging up, and you've got people who are tearing their hair out on those roads wishing they could use a train that ... doesn't run at the time they need it.

The prime example here is, of course, the "TransWilts". Trains from Swindon to Salisbury at 06:16 and 18:45, and NOTHING in between. A return service that doesn't even start from Salisbury - the 06:04 from Salisbury gives you a 30 minute wait for a connection at Westbury, and the second train of the day drags into Swindon at 20:20.


The question I was asked was "should we reduce the amount of travelling people have to do?".

Yes - especially if we interpret that to mean reduce the CO2, reduce the time taken, and especially reduce the time WASTED. How?

* Reduce numbers and needs for journeys.
* Provide proper INTEGRATED transport, with good information and running on time not early.
* Provide transport that provide a QUALITY of use for travel time.

There are some cheap but radical options here. In Utopia, rail and bus services run hourly, and connect with one another, with the bus service being used for the legs of jouneys too and from the stations. Information about the times that service run is easily to hand, and there's an system that keeps people informed of any disruptions, and advises on alternatives. Where a car journey is necessary (and sometimes they are!), drivers put a destination board and number of empty seats in their window, and other travellers can flag them down and get a lift. For short journeys, and short transfers to and from pubic transport hubs, a good network of footpaths, cycleways, and indeed cycles and mopeds are available for hire.

What is surprising, if you look around, is that you see some embronic shoots - some locally, some far away - towards Utopia. It isn't THAT radical - but it's a long way off at the moment. Yet now - with a squeeze on money and on CO2 - is the best time to take us there.

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


Related topics: via article database

Atworth Village Fete - on the Melksham Community Area Partnership stand

"Would you like to buy some fairy cakes for tea?" - "How should Atworth village and the areas around develop up to the year 2026?"

"Toss the wellie, sir? How far can you throw it?" - "What are your major unitary controlled concerns about living in this area at the moment?"

"Can I have 30p please Dad for racing car" ...


View and facts expressed in this article are as presented to me, and do not necessarily reflect the views of other members of the community, nor of the community area partnership, nor do they imply any endoresement. See update at base of article for further details

Yesterday, I helped with the Melksham Community Area Partnership display at Atworth Village Fete, held in the grounds of Churchfields School, Atworth. On a hot summer's day, people's attention is very much on having fun and the last thing on their mind is the serious business of whether there should be more housing in Villages such as Atworth - either at a level for the village to gently regenerates, or to become the hub of a new local town ... or whether it should be stagnated and become a faded dormitory. But these matters will effect them, and their children, long after the fairy cakes have been eaten.

Why village fetes? Last weekend was Poulshot, and I'm doing Melksham in 2 weeks time. Because they're the one occasion on the year when many difficult-to-reach members of the community are out there and can be reached. So these village fetes are hard work, but never the less it was two hours spend talking and listening and learning. A couple of us on the MCAP now have a better understanding of Atworth - some of its concerns, etc. Still not a good picture - the majority of visitors to the fete didn't visit our stand - but we have a toe in the water and we're much better informed.

So - what are Atworth's issues / uniquenesses? (Illustration - the MCAP stand, with Miriam talking to fete visitors) Talk of housing and housing growth lead us to quickly learn that a single (Fuller) family owns virtually the whole village and surrounding area, and so the metrics are different here on that score. It's much more a question of what "The Estate" wants and allows rather than just what county and / or the people who live here would like. There are questions of traffic speed through the village - a fast hill down from the Bath direction comes into a street that was built in horse and cart days, and there's concern at the lack of even occasional police speed cameras. They ARE used in the next village on the same road in Shaw, it seems (I was once caught there - my only time - and it appears that Atworth visitors have too!). Want to see a doctor? The Melksham surgeries are all at the far end of that town, and the secondary school which was at George Ward on the Atworth side of Melksham is also moving to the Seend / Devizes side - a couple of miles further, and serious concern even from Atworth residents about traffic congestion in Melksham and delays in getting to the doctors and in future to school. They were also very concerned about the closure of Melksham Hospital - especially the minor injuries unit. Public transport? The bus runs once an hour, but is largely discounted. Frustration was expressed (and without my prompting) at the lack of an accessible train station with a decent service - it's a real fight thorough traffic into Chippenham, and if you're going to Swindon or London, Bath is a illogical dogleg - quite apart from it too being an awkward station to get to. The people I spoke with were saying how useful a connection of the bus at Melksham station to Swindon would be ...

The fast road in, and the many accessible places have, it seems, attracted a criminal element to Atworth, and neighborhood watch is being set up. The question of the canal in the Melksham area is watched with a sort of interest at a distance. It won't directly effect the people of Atworth, but the couple of people I spoke with about it were asking "could it really happen" and were of the feeling that - if it could - it would really do something for the town [of Melksham] which is seen at times (and even this close) as something that's much more of a "sink" that perhaps Devizes, Malmesbury or Marlborough.

Atworth is set in the countryside. To the north is Corsham. To the northeast, Chippehnam. To the west, Bradford-on-Avon. To the south, Trowbridge. To the east, Melksham. A village the size of Atworth cannot have all the facilities people need or want - a village shop, maybe, but not a cinema, nor a leisure center, a doctor, a dentist. So where does it look to? A little bit of many, it seems. Bath got mentioned as a major point, and they feel somewhat linked with Melksham - far more that the other towns that I mentioned. That's a stark contrast to Poulshot, from the previous weekend, which is part of the Melksham area, yet looks towards Devizes more that Melksham. Ah - there will always be these awkward questions as areas are clumped together.

I was impressed - very impressed - by the thoughfulness and knowledge of the people who have put together the village plan (picture of display) , by the gentleman who I spoke with who was around and party to the installation of the Melksham Gate on the Avon (I won't say more of his more mainstream knowledge to protect his identity), and by the friendlyness of the village. True, Gypsy was asked to leave ("it's a school field - we can't have dogs even today"), yet there were at least a couple of other dogs there throughout the afternoon, so I do spot a bit of dual standards and lack of welcome for people from outside the village.

It's the nature of the CAP that the issued raised are problems / negative ones. The questions asked are "what concerns you" and "what would you like to change", and not "what is right with the community and what would you like left alone". So reports and feedback will tend to point a darker picture than the reality is. But then things that ain't bust don't need fixing, so time need to be spent understanding and keeping the good, but then much more time on learning about, evaluating and fixing the areas of real concern.

See [here] for more pictures that I took at Atworth Village Fete (including the ones above at larger scale). See also [here] for considerations areas for the Melksham Community Area.



Update - 28th July, 2010, 10 p.m.. I'm just back from this evening's area board meeting - attended by (I estimate) around 150 people, and four Unitary Authority councillors. To my surprise, this blog article was raised by a member of the audience as a follow up to the Community Area Partnership report (which I did not present) - with the audience member saying it contains factual inaccuracies, and that he wished it to be corrected.

Let me immediatley clarify something - this personal blog describes discussions on that day, and information told to me as I understand it. Views of people at an event may be logical or illogical, and they may get facts wrong - but what I've written is to the best of my knowledge a fair translation of what was said. It's not an unusual problem to have when canvassing views. For example, only last night, I was at a consultation meeting in Melksham and a lady stated "we have no public transport from Melksham to Trowbridge on a Sunday". That's an error of fact - there's a train (hard won by our campaign!) at 18:45, and a National Express coach at about 21:00. It's a pretty useless service for a day out, but she didn't say "we have no useful public transport ..." so she had the right story, but wrong facts to back it up. So please read the text above as reporting the spirit of the view, which came across loud and clear that day.

It was suggested that I should have got the blog checked and approved by the Atworth Parish Council, and corrected any errors of fact they reported to me before telling you how that day was. I'm afraid I don't agree; my role was to listen to what people were saying, and to feed that back - not to come up with a post describing what others feel they should have said. But I am - as always - more than happy to add comments, different views, corrections to facts I have got wrong, and so forth. I made myself know to the gentlemen at the meeting ... we spoke afterwards i what I think were very friendly ways (and I'm pretty sure we both want the best for our area, so it should be such!)

I offered to bring back with me a copy of the marked up blog that the gentleman had so that I could consider and update you forthwith. I offered to sit down there and then and look at the matters (you know me - I'm always online ;-) ). I offered to update as appropriate on receipt of an email. The first two offers were declined. I do hope he takes up the third offer and gives me the opportunity to add his views into the discussion, and the facts as he understands them. That will make up a much stronger group of communities, understanding each other that much more and working for the common good.

If you should happen to be reading this as a general part of my blog ... please feel free to get in touch about any of the articles. I'm always very willing indeed to add sections - and go back and make limited amendments too at times to clarify and correct. But please email me at the address that's on this page - that's likely to get it changed much quicker (and perhaps more favourably to your views if they differ from mine) than raising it on the floor of a big public meeting where I happen to be in the audience.

Update - 30th July 2010 ... An answer from the Clerk to Atworth Parish Council (unabridged) which I received late yesterday evening:

Dear Mr Ellis, thank you for your response to the comments I made last night. I should like to make it clear that I was not criticising you but rather that there was no check in the system to ensure that what was being reported and broadcast was factually correct. What is opinion one minute, once in print, can very quickly be taken as fact. It is that I wish to guard against. Whether you wish to modify your report is a matter for you and, perhaps, MCAP.

I would confirm that Atworth Parish Council supports MCAP, indeed it has 2 representatives ( our Chairman and a Councillor) who regularly attend its meeting.

As to the detail the facts are as follows:
• The Neston Estate sold off almost all of its housing within the village after the Second World War. It still owns most of the agricultural land in the Parish
• Few, if any currently, of the children of the Parish attend George Ward. Secondary education is provided by St Lawrence in B-o-A.
• Atworth Village already has a Neighbourhood Watch in being.
• The Parish Plan has highlighted that Melksham is only one of several towns in the area (B-o-A, Corsham) from which residents draw services and entertainment.

You could argue that this apparent discord indicates that the Parish Council is not getting its message across. We have a website, a village magazine both of which regularly report on Council/Parish activities and deliberations. We have an annual Parish Assembly and occasional public meeting, the next is in September. We will shortly, by October, have A Parish Plan; a copy of which will go to every residence and business in the Parish. But we can always do better!

I sorry your dog wasn't welcome especially if there was a double standard in operation. We aren't too bad really but we do value our separate identity. Atworth has no desire to become part of a greater melksham.

Comment ...

What was told to me at the start of this month remains what was told to me - some of the comments may have been inaccurate, or may have related just to a part of the community, but they were telling of how people feel (or rather felt on that day). I welcome the opportunity here to publish the alternative, and what I feel is "official", view.

I'm utterly aware that words published on a web page tend to take on more authority than if they're just spoken at a meeting. But words on a blog such as this, clearly written as an anecdotal (not sure if that's exactly the right word) report on what was said on the day, are well know these days to be just views. My correspondent wants to guard against opinion being taken as fact, and (I suspect) the concerns of small group being taken as the concerns of the village as a whole, and I'm delighted to have been able to provide him space on this blog to put on record things as he sees them.

Alas - if I were being pedantic (oops - I am), I would take issue with "Few, if any currently, of the children of the Parish attend George Ward." Technically that statement is correct, but it's misleading ... George Ward school has closed down. And I understand (unverified) that Wiltshire Council used taxis go get pupils to school from Atworth to the new Melksham Oak School for the last couple of weeks of term, having realised that Atworth is outside the limits for which children should be expected to walk to school. The fact that it's taxis rather implies the number involved wasn't / isn't huge.

Yes - I did (and do) find the people in all the communities around here a great bunch for the most part ... and I know that the MCAP is going out of its way to be inclusive. Indeed - it sometimes feels to me that the CAP and the Area Board are putting far more effort per head of population in for the areas surrounding Melksham than for Melksham Town itself. From what I hear, that's not common across all the area boards - yesterday evening I met with someone with whom I'm working on something in a Westbury area village, and his comment was that the Area Board will welcome this project as it will let them do something for the villages, which has been lacking so far.

Looking wider, I'm aware (and I think I can talk for other members of the MCAP steering group here) that the bunching of villages with a specific nearby market town is imperfect; how and why it was done the way it wasn't (to my knowledge) planned by looking at villages and asking them "who would you like to work with?" but rather was done by clumping councillor's seats. It has resulted in some strange things - Holt and Lacock, both about 3 miles from the centre of Melksham, are not in its community area, but Steeple Ashton and Poulshot, both of which are about twice that distance away, are included. But certainly the MCAP welcomes anyone with an interest in the Melksham area (even if they don't live in the area), and encourages people living within the area to make contact with the Devizes, Trowbridge, Bradford-on-Avon, Chippenham, Corsham areas too.

But Area Board funding is likely to be available geographically for the area in which a project's taking place - so it does us all good to be working together to make the best of this pot for our area as a whole, even if we feel thrown together.

P.S. I note that Atworth has a new "Zig Zag" bus service starting on Monday. As well as the sevices to Bath and Melksham / Devizes, there are now services through the day to and from Corsham, Bradford-on-Avon and Trowbridge, and journeys to and from Chippenham too. The devil may be in the detail, but it looks rather good to me!

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


Related topics: via article database

Further C++ material - view new or old

I've taken out the old header <iostream.h> and replaced it by the current <iostream>. I've adding in using namespace std; where I've need to, in order to allow me access to cin and cout without a need to prefix then with std:: under the new header file (and to save me loads of errors at load time when other standard stuff is loaded!). And I've commented out the supressions of deprecated warnings from my makefile - # COPTS = -Wno-deprecated

I've taken the opportunity to add in to many of the main programs ... adding samples of how they compile and run, so that you can see what the programs do. Nothing to do with the way they work - everything to do with making them better examples when delegates come back and look and see how programs on their courses worked.

An update log for the basic defining and using classes in C++ module:

All in one first demo [here] replaces previous all in one demo [here].

Separating that into two files - the new main program [here] replaces the previous [here], but the included functions are unaltered [here]. I have added a few comments to the latter file, but as none of the executable statements nor C preprocessor directives has been changed, I have not provided a duplicate file on this site.

Use of a header (include) file and methods held in a separate file - main program of the demo [here] replaces previous version [here]. The include file [here] and functions [here] are unchanged.

An example with a specific contructor and destructor. The new class code is [here] and the previously used class code [here]. The new main program is [here] and the previous version [here]. Note that the only reason that I've had to change the class code at all is that I have added uses of cout in the constructor and destructor - as a demonstration so that the user / person running the code can see when they're called. You would certainly not want to do this in production code.

For completeness, the new makefile is [here] replacing the previous one [here].

Posted by gje at 05:55 AM | Comments (0)


Related topics: via article database

July 03, 2010

Fresh Paint for course presentation - including C++

During courses, I project from (and sit at) an Apple Mac laptop - I have done for a number of years. But then I'll access / use other machines from the Mac laptop. That allows me to have the graphic power and strengths of the Mac, the Unix operating system and it's environment, and access to Linux servers all on a single box - and our Windows machines are accessible too. For open source training courses, this is the best of both worlds - we're providing each delegate with the operating system they're familiar with (or will be using), so that they don't have to get involved with the complexities of a new environment. And at the same time they can learn about / see / gain practical experience of portability issues.

To some extent, in the storm of new products and changes and developments - Windows 7, Ipad, Iphone 4 ... open source languages are the eye. The calm at the centre of the storm, where things remain quite surprisingly still for quite a while. And that's because you want to develop code that you know wont need replacing in six or nine months, but rather will last for many years. But never the less, changes do crop up.

Last week's course was the first presented on a new Apple Mac - a MacBook Pro 17" screen i7 with 500Gbytes of disc if you want the technical spec. It replaces a previous Mac with the same size screen, but only a quarter of the memory, a fifth of the disc, and what feels like a tenth of the compute power. And I have taken the opportunity to download the Mac Developer's environment so that I can locally run the Os X / Unix / Linux and other open source Gcc and G++ compilers. For sure, I had backups there but the course ran smoothly - with no need to make updates.

But I have chosen to make a few updates. On C++, I am fading away from the deprecated methods and headers which you're no longer encouraged to write into your code, but not fading them out completely. There's a lot of old code out there, and we're in the business of training people to help with and take over the maintainaince of that code, and the older techniques it uses.

So there's an updated first C++ application - gone are the deprecated headers - at [here]. The header file that it includes for our own extra functions is [here] and the source of those functions [here]. A Makefile to show how the elements are compiled together is [here].

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


Related topics: via article database

July 02, 2010

What are C++ references? Why use them?

C++ References let you give variables alternative names. For example, if you write
  int & jones = flossie;
then "jones" becomes an alternative name for flossie in the current scope. If you assign something new to jones, you're not going to make the variable into an alternative name for something else - you're actually going to change the value that's being held under (both) names. You can see a worked example in [source code here].

Why do you want to give variables alternative names in this way?

One reason is that you're wanting to loop through every member of an array - perhaps an array of objects too, where the variable names to describe a memory location are complex. Rather than repeat the complexity time after time in your code, a reference is a lighweight alternative to a pointer to simplify it. For example, you might write:
  for (int i=1; i<length; i++) {
    Shape * ¤t = candidates[i];
    sofar = current->heavier(sofar);

and you can then keep making further references to current rather than the more complex candidates[i] for the rest of the loop too.

There's a further example that compares and contrasts references and pointers [here], and one that uses both reference and pointers to array members [here]

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


Related topics: via article database

C course - final course example puts it all together

"Yes - but how do we put all of those things together?" ... delegate question on many programming courses. As a trainer, I have to take our students through each of the main features of a language - to ensure they understand the fundamentals and perhaps more. But the it's just as important to take time before the course ends to pull all the threads together and ahow a complete, practical, maintainable and robust piece of code.

So here I am, on a Friday evening. Delegates have headed off to places as wide ranging as Norwich and Exeter, and I'm wring up the example that I completed just before they left. [source code link].

The example program reads one of our recent log file - they're currently around 40 Mbytes per day - and uses regular expressions to filter out all of those accesses which were arrivals from a well know search engine.

We have no way of knowing how long search strings will be, nor how many arrivals we'll have, so the memory management needs to be dynamic and use the heap ... so our example's got to include things like malloc calloc and realloc. And we have various string manipulation functions in use to find, extract and save on the heap the elements we need from each line.

Why would people use C for an application such as this? Perhaps because they knew the language already, or perhaps because they needed to run it so often and on so much material that it had to be FAST. And so you'll notice that in order to get the speed, we've compiled our regular expressions outside our main data reading loop, and we've also extended our heap memory block in chunks of 10 records at a time. The simplest coding would have been to extend the capacity one at a time, but this would have been very slow. 100 at a time would probably be better!

If you want to learn C next time I teach the course, have a look [here] if you've never programmed before and [here] if you'll be converting from another language. I'm not promising you'll be able to quickly write code like my example by the end of the course - that requires a bit more practice - but I can promise you that you'll understand what's going on, you'll be able to fathom out some previously unfathomable code, and you'll be well on the way to becoming a C programmer.

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


Related topics: via article database

Local information for Melksham Hotel Guests

If you're visiting a new part of the country, what better than to have a selection of magazines and newspapers that cover the area available, so that you can browse and see what's going on? So we leave a copy of the current edition of the monthly Wiltshire Life in each of our rooms, and the previous couple of editions are available in the library too - together with The Week and Time Magazine. In the breakfast room, you'll find one or more daily papers, and we also have the Wiltshire Times there. There are plenty of leaflets advertising local tourist attractions and events (we have regular deliveries, so we're kept up to date), and every bedroom also has a copy of the current edition of the Melksham Independent News.

"Final Checking" rooms before guests check in earlier today, I found that The Melksham Independent News had blown open in one of the rooms ... and an advertising stuffer that had been inserted for parallel distribution had fluttered onto the floor by the door. Such stuffers are usually for local takeaways, but sometimes for other services ... but what would have been sold to of guest if I hadn't gone around to check? ... "The Independent Way. A funeral plan created for you by X X Bxxxxx Funeral Directors"

Posted by gje at 05:31 PM | Comments (0)


Related topics: via article database

July 01, 2010

Catching up with an old friend

It was good - really good - to grab a lunch yesterday with a good friend and former work colleague I hadn't seen in 30 years. I met Paula when I was assigned to the Civil Service Department - see [here] for some of the technical stuff we did there. By the time I came to get a job at the end of my course, Paula's new employer - Tektronix - was looking for a technical support specialist, and the connection was made with the help of Dr G.K. (not sure if I can name him, but is he's still around and happens upon it - THANK YOU).

In this industry, we all move on ... and Paula returned to her native Canada, while I moved from Tektronix (more on Tektronix) in Harpenden to other roles in the company, to Compugrafic Design Ltd, and to CGL Ltd, where we wrote CAD software and sold it OEM through companies like Florida Computer Graphics and Orcatech who were Ottawa based. And - ah yes - I was able to tell 'em what an excellent Graphics software technical expert lived in Toronto.

But this was half a lifetime ago ... since then, I've been with Megatek, SAIC, First Alternative, Connectware, and last and longest with Well House Consultants. Paula has been with IBM, and with the University of Toronto, and is now teaching Java Enterprise in a college in the city.

There are some people you come across several times in your career - paths keep crossing - and they're good colleagues. Just a few of them - and Paula is one (Dick - are you reading - you're here too!) - are rather more. I can never forget the great kindness and help when I move away from home to take the Tektronix job. To the welcome when I visited in Toronto. And it was fantastic to see Paula again over lunch, to catch up on old times, to introduce her to Lisa. There are some people that you just feel back at ease with after all the years! And it was so good to be able to say "thank you - I remember and appreciate".

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


Related topics: via article database

Objects and Inheritance in C++ - an easy start

We can end up with a lot of files when we do even a simple C++ example to show inheritance - a file for the main program, a file each for the base class and subclass, and a header file for the prototypes for each of the base class and subclass too.

So it's much easier to do it all as one file - but suggest to the delegates that the code should be split across multiple files once it's functioning. And I have added an example - [here] - to our web site to show the fundamentals all in one, to give newcomers to objects and inheritance in C++ an easy start.

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


Related topics: via article database