« August 2007 | Main | October 2007 »
September 30, 2007
A taster PHP expression ...
I've been working on RSS feeds ... looking to get a page that combines various blogs so that I can have a quick look and see where we stand without having to hop and skip round each in turn. And with magpierss, it's turned out to be quite easy.
Yet some blogs give a summary in the their RSS feeds - a taster, if you like, which is exactly what I want and others spew out the full text, including tags too. How to eliminate the tags, and shorten the text? Well remember that in PHP, there's function to do it
$st = strip_tags($wehave[atom_content]);
$st = preg_replace('/(.{190,}?)\s.*/s','\1 ...',$st);
Can you work out my regular expression? It's returning just the first 190 characters of the incoming string ... or a few more up to the following space if it had to gieva good word bread ... followed by 3 dots. But if the incoming string is not as long as 190 characters, it's returned in its entirety.
You can see my work (so far) at http://www.wellho.net/web2/index.html
Posted by gje at 05:56 PM | Comments (0)
Related topics: via article database
More about Graham Ellis of Well House Consultants
Useful link: PHP training
September 29, 2007
Hotel in Melksham at Christmas
Well House Manor - Open at Christmas
Well House Manor in Melksham will be open as usual over the Christmas and New Year period. It's in a quiet location just five minute walk from the town centre, and ideal for you if you're visiting family in Melksham or West Wiltshire, but don't want to overcrowd their home.
All rooms are en suite, all rooms feature a 26" TV with over 50 channels available, and we include unlimited internet access and continental breakfast in our room rate of £80.00 (single occupancy) and £95.00 (double occupancy). All rooms have double or twin beds - no squashed singles here!
Behind the scenes
We're primarily a business hotel, and although we only opened for general hotel guests earlier this year, we're already sometimes full during the week. At weekends and holidays, we've started to build up a customer base of people who visit friends and relatives in the town, and are looking for a quiet and slightly luxurious setting in which to stay rather than cramming "in with the kids". I'm delighted to report a growing repeat business - people voting with their feet, saying "this is the place in Melksham that I want to stay".
We had a choice for our first full Christmas - to close for the period and take a break ourselves, to lay on something special and charge a higher price for it, to discount our rooms and look to fill the place from Christmas Eve right through to the new year, or to continue offering the quiet, relaxed, no fuss service that has been growing at weekends. And that's what we have decided to do. If you have stayed with us during the year, or if you feel this is what you're looking for, please let us know and we can book a room or rooms for you. Email to Lisa.Ellis@wellho.net, or phone us on 01225 709638, or via our freephone number, which is 0800 043 8225. The Hotel's web site is at www.wellhousemanor.co.uk
Posted by gje at 05:46 PM | Comments (0)
Related topics: via article database
Apache Tomcat Performance Tuning
Have you noticed what a lack of information there is in the printed material (or on the web too, come to that!) on performance tuning Apache Tomcat? The subject came up briefly during the course that I completed yesterday, when we looked at the changing the heap sizes and number of threads, and selecting either the client or server JVM. Really it's one of those areas where I can't give you hard and fast rules for these parameters, and sometimes an apparantly contradictory setting will work wonders. For example, reducing the number of threads may increase performance as Tomcat concentrates on giving fast and furious service to a few customers at a time, rather that having hordes of them in the pipeline at the same time.
"Increase your cpu power, increase the memory" one of the books told us - and with the modern low price of hardware, that could be exactly the right message for some people. So could "increase the bandwidth to the cpu" sometimes. But in each case, do check that you're pushing on the right bound. Looking at yesterday's case, the cpu was running at 100% and there was free memory available - so an extra few Gbytes would have sat idle; a move powerful cpu would have helped, as might pulling other tasks off the same cpu.
"Should I run multiple instances of Tomcat"? Maybe; on a single processor machine, it's going to be questionable whether you'll gain much. With multiple processors and one instance per processor, or with multiple hosts, then major throughput advances can be made. But once you have multiple instances of Tomcat running, you've got two extra complexites - how to share the load, and ensuring that the Tomcats stay syncronised in an appropriate way.
There's some general load balancing and clustering information and some more specific Apache load sharing information available via links. And whilst we don't run public Apache Tomcat tuning course, we have been known to cluster machines together, play with the settings, and bombard them with traffic to help a small group from a individual client understand the metrics of some of the factors I have mentioned. See here for commercial details.
Posted by gje at 05:24 AM | Comments (0)
Related topics: via article database
September 28, 2007
One business, four different angles!
I took a phone call on Wednesday from one of the Denton family at "Denton's Directory" - a local directory that's distributed free to households here in Melksham and has actually become something of a well-used institution. So although the call was a "cold call" looking to persuade me to go for a somewhat better entry than a line item, it wasn't unwelcome. And Robin was very professional in his approach too.
So what catergory should Well House Consultants / Well House Manor go under? Looking through the 2007 directory (which happens to be at hand in the hotel reception!) I came up with half a dozen distinct possibilities, which I whittled down to four. And then the challenge came in presenting a few words for each of those categories.
1. Hotels
Well House Manor
Quiet location close to town centre.
Tailored for business visitors.
Spacious, well equipped rooms.
Internet & plenty of parking.
48 Spa Road, Melksham Melksham 709638
Freephone 0800 043 8225
www.wellhousemanor.co.uk
2. Conference Facilities
Well House Manor
Business meetings, training and conferences.
Wide range of layouts and catering available.
Integral hotel accommodation for delegates.
48 Spa Road, Melksham Melksham 709638
Freephone 0800 043 8225
www.wellhousemanor.co.uk
3. Computer Training
Well House Consultants
Training courses in Web Technology -
Perl, PHP, Linux, Python, MySQL, etc
404 The Spa, Melksham. Melksham 708225
Freephone 0800 043 8225
www.wellho.net
4. Bed & Breakfast
Well House Manor
Quiet, yet close to the town centre.
All rooms en suite, superior standard.
26" TVs, internet access, minifridges, etc
48 Spa Road, Melksham Melksham 709638
Freephone 0800 043 8225
www.wellhousemanor.co.uk
Interesting, isn't it, how "hotel" and "bed and breakfast" turn out to be described differently. The major headings imply a whole different ball game - a whole different starting point and the feature sets say "What is different in our hotel to other hotels" and "why as a B&B is this different".
And on the training side, you'll note that I included some subjects and not others. Why my particular choice? The subjects mentioned are not necessarily our most popular - but rather they're the ones that are most likely to be bought locally rather than being niche subjects with delegates from all over the continent!
All comes down to fitting the advert, in each case, to the requirements of the reader of that section.
Posted by gje at 07:24 AM | Comments (0)
Related topics: via article database
September 26, 2007
Getting the local voice heard
I'm always a little bit amazed when a letter or a posting here actually gets noiced to the extent of generating a reaction back to me, and back to the community. So I was a little amazed to get a phone call from Asda this afternoon ... based on my posting of a few days ago, in which I expressed concern at some elements of their plans to bring a new store to the town, and how they had handled it.
I do appreciate at this early stage there are many questions yet to be answered. But it seems to me that there is a difference between a company that prioritises wanting to work with the local community, and a company that prioritises maximum short term return on investment at the expense of sucking that profit out of the locale in which they trade. And this difference is manifested and cultured from very early in their planning process.
See my original aricle and comments:
http://www.wellho.net/mouth/1360_Asda-in-Melksham-Welcome-or-not-.html
Posted by gje at 04:31 PM | Comments (0)
Related topics: via article database
September 25, 2007
korn tips - some useful korn shell techniques
1. If you set PS1 to a string that contains a "!" character, then you'll get the current history number reported as part of the prompt. If you want to rerun the same command number 246 later, all you then need to do is type
r 246
2. If you're debugging a Korn shell script and want to work out what it's doing in part of the script, add in
set -x
at the top of the section that you're especially interetsted in, and
set +x
at the end of that section. Then your script will give you a log of the lines as it runs them together with an indication of how the shell has expanded your shell variables and manipulated your other metacharactes
3. The Korn shell
whence -v
command will show you where the korn shell gets programs and instructions its to ru; unline the operating system's
where
command, whence will be able to tell you about functions, aliases, and builtins as well as the operating systems's stand alone programs
4. Global variables. In the korn shell, variables in the main code are, be dafualt, shared with variables of the same name within the functions. If you want a local variable in a function, you can create it with a
typedef var
command. We have an example of a shell script that defines a function and uses both a global and a local korn shell variable here
Posted by gje at 12:09 PM | Comments (0)
Related topics: via article database
awk - a powerful data extraction and manipulation tool
Unix and Linux come with a whole toolkit of utility programs for filtering, sorting and manipulating data. As a "one off" job, you can use them from the command line, and for repeated jobs you can save a series of instructions for these tools in a shell script. Yesterday, I ran a private shell scripting bootcamp course, and found myself enjoying working with
grep - the filtering tool
sort - the tool that re-orders data
awk - for pattern matching and data manipulation
sed - the stream editor
tr - for transforming characters
Awk is especially worthy of mention. With Awk, you can select rows of data based on what they contain, or what is in certain fields, and manipulate those lines. Instructions may be given to allow different instructions depending on how they're elected, and awk also includes integer and floating point arithmetic capabilities, and the ability to undertake actions before and after the processing of any of the data, in matching clauses called BEGIN and END.
I have added sample awk scripts here and here to our web site, and a slightly longer article on awk here. And, yes, I can deliver training on awk and shell scripting ;-) ... Linux/Unix Basics will get you started, and we can tailor to meet your needs from there!
Posted by gje at 11:53 AM | Comments (0)
Related topics: via article database
Korn Shell scripts on the web
I know that the Korn shell isn't exactly the most common language for web scripting ;-) .... but if you've got a load of Korn shell scripts and a heap of Korn shell experts ... why not?
"How would you do it" I was asked yesterday and I put together a tiny demo to show some of the first principles. You can run the example here and see all of my source code here.
Just to note - the code is very basic as a first demo, but never the less I have used tr to clean up the user's input so that anything other than input digits are washed out of the data entry box.
Posted by gje at 08:40 AM | Comments (0)
Related topics: via article database
September 24, 2007
Korn shell course - resources

I'm running a Korn shell course today and happened to take a "snap" of the resources set out ready for the course start.
* Sign in sheet
* One laptop computer, with appropriate software, per delegate
* One set of course notes, approx 80 pages per day, per delegate
* One regular expression mousemat per delegate
* Pen and notepad for each delegate
And ready for the course end
* Certificate of completion for each delegate
* Course review sheet for each delegate
* Follow up sheet for each delegate - "How to reach us after the course"
Posted by gje at 07:36 AM | Comments (0)
Related topics: via article database
September 23, 2007
One computer per delegate, or pair programming?
We provide one laptop computer per delegate during our courses, and we're proud to do so - such a scheme works well for the majority of most of our programming courses, with each individual from his / her own company having practical coding exprience during the course.
However - for certain exercises on certain courses, there's a lot to be gained from using the alternative approach of working in pairs - putting your heads together to explore options and consider the best solution to a practical. And in the right circumstances, I encourage such pair working.


Pictures from last week's PHP course. At this stage of the course, we were studying how the main application, the business logic, the web helper codes and the look and feel of the application can (and should) be divided up into separate areas of code, so that each can be developed and maintained by a team member who enjoys working in that particular part of the application, and is an expert on it. The graphic artist majors on the graphic art, and the rock climber on the business logic that deals with rock climbing calculations.
Posted by gje at 07:29 PM | Comments (0)
Related topics: via article database
No Thank You
"No Thank you". A polite response to an suggestion which is not being accepted. Not the greatest of responses, perhaps, to an offer, but oft understandable and accepted.
No "Thank You". Rude, At least in my culture; the lack of getting back to someone who's done you a favour over and above the call of their duty.
The contrast came to me this morning when reviewing posts on our Opentalk Forum; we offer free technical support there to the delagates who have been on our courses, ensuring that any little issues that arise after they've completed a quite intensive training session can be fixed in short measure, rather than leaving them to pull out their hair for hours or days when I (or someone else who posts there) can sort them out in seconds or minutes.
A policy decision, made early on, to allow "Open posting" to Opentalk. And by that I mean that we'll accept and give pointers to people who have not attended courses, and indeed who haven't bought any services at all off us. Occasionally - vey occasionally - that directly makes a new contact for us who may end up as a customer. But much more often, and very valuably, new questions from people froma very different background to mine trigger me and the people who help to answer the questions into writing a really good and clear new explanation of something, and into realising what extra topics should be covered on the web site or course.
But there are a number of "single question" posters who ask their question, read the reply (well - I GUESS they read the reply), but then don't bother to even say "Thank You" or "Yes that worked". Personally, I find that attitude to be presumptive and uncaring; in my personal case, it leads me to give rather less attention to any posts that may trigger my "single poster alert" (there are certain metrics from which I can guess who is likely to come back). And yet ... sometimes the lack of feedback can be put down to culture ... sometimes to a lack of enough intelligence and thought on the poster's part to appreciate how rude they are being ... and sometimes to a personal crisis; I've learned about one or two of these well after the event in the past, and in turn my wondering and slagging people off has turned out to be inappropriate.
There's the lady who went into labour early ... and came back on the forum 3 months later to announce the arrival of a daughter and apologise for her apparent rudeness.
There's the hotel "No Show" who reported a motorcycle accident to a close friend; somehow, the frustration of sitting around until after midnight just melted away.
And there's the "one shot" enquirer - with a very odd but interesting technical question - who turned out to be working in a university in a country that the Americans invaded a couple of years back; a real human being ... I don't know what happened, but somehow this is one lack of a "Thank You" with extenuating circumstances.
Why am I writing this? To post a link on a forum thread, explaining my background / approach to others who do huge work to help me. To say "Thank You" to them, but also to say "I share your frustrations sometimes; I know how it feels, but let it be". It would be a very sad world if we went around assuming the worst of everyone, wouldn't it?
Posted by gje at 10:25 AM | Comments (0)
Related topics: via article database
September 22, 2007
Korn shell course
It's been quite a while since I presented a course that majored on the Korn Shell - I know the subject right enough (having written a complete 2 day course that got rave if niche reviews during a previous lifetime), and I jumped at a chance to brush up on my old skills to day, to recall the differences between ksh and bash, and to put some notes together. Actually - I got rather carried away with some 1000 lines of new text uploaded in longer articles:
Korn Shell Basics
More Korn Shell facilities
Shell Scripting with the Korn Shell
and with over a dozen sample scripts all of which I have placed in a Korn Shell Resource Index
The Korn Shell is a great shell - developed like bash as a "sh compatible" shell, it took all the interactive ideas of the C Shell and implements them within the bounds of the original sh framework; it's a very popular shell in a Sun / SunOS / Solaris environment. Used in conjunction with utilities such as grep, sed, sort and awk ... well - the scripting world is your oyster.
Presentation on Monday and after a day's revision I feel comfortable. "Water off a duck's back" I think is the term. I'll let you know how I get on, and no doubt post some more snippets here during and after the course.
Dear Reader,
Do you need to learn the Korn shell? If so - please let me know. Although I won't be running a regular public course, we do have the material and knowledge and I can train groups either here at our Melksham training centre or elsewhere. And where there's a will, theres a way for individuals too.
-- Graham
Posted by gje at 08:29 PM | Comments (2)
Related topics: via article database
September 21, 2007
Asda in Melksham - Welcome or not?
Update - 26th September. I have just taken a phone call from one of the gentlemen we met, wishing to clarify a few points. He'll be writing a separate email to me, which I'll add to this thread, but in the meantime I would like to confirm:
1. Asda have publicised their plans, as far as they go at this early stage, and have listened to those reponses. Where I was doubtful was what would then happen to those responses; I have just learned that they will form a part of the planning submission. My actual comment was that I wasn't sure how much consideration would be given to point raised, and not that they weren't being gathered. Sorry to have suspicions sometimes, but I have come across situations where the fact that a consultation has been held is regarded as being the end objective and that's a very different matter to having a meaningful discussion as to whether to change you rplans based on inputs.
2. The requirement to undertake traffic surveys at a time when there are no road works, the schools are in, etc, is laid down by the Department for Transport, and the detail has to be agreed by the county council. I know that I used to dread travelling to Cornwall in high summer because of the traffic jams .... and perhaps this is why - the traffic surveys were only done at times of year when there were lower flows! In other words, it may be the system that says "no general survey covering all different types of day - just surveys on days deemed to be average" rather than Asda
3. Asda tell me thay have had hundreds of written representations, with over 90% stating they are in favour of the new store. I do not know how many of those are letters penned on blank sheets of paper, and how many are survey responses.
As an appropriate development, a new store such as Asda on the north western fringe of Melksham, hard beside the main communications arteries and with good links to them and to the town centre, could do wonders for this growing area. But an inappropriate development that only serves to suck its users into that area could lead to a hotspot of activity and jam in the hundred yards around and feeding arteries, with the rest of the area around, and perhaps the town centre, being bled dry. I am assured by the gentleman representing Asda that the former is their intent, and I look forward to seeing further details of this in actions as well as words.
My original blog
I have been passed a press release from Asda, who are going to be putting in a planning application for a big new store beside the railway, and been asked for my comment. I wrote:
It's a press release from Asda .... so the press will expect it to draw a glossy picture from the Asda viewpoint and skate quietly past any other side the story has ;-).
And I expanded:
Personal view:
I'm disappointed by the Asda representatives that I have spoken with. A company moving to the town has a choice of looking at it as a narrow commercial decision, based on their own needs with little regard for the needs of the town as a whole, or of taking a wider view as to what will benefit the town - how they can work with the town to everyone's mutual benefit. And I fear that I have seen the first, selfish, side predominating in Asda's bid. The press release says:
"""Allison Darling, ASDA Property Communications Manager said: "ASDA will fulfil an identified need for more food and clothing shops in Melksham and I"m confident that the new store will present a positive opportunity for existing traders in Melksham by encouraging more people to shop locally. ASDA is committed to working closely with its local communities and the response so far has been overwhelmingly positive. The consultation has allowed us to take account of local views and to fine tune our proposal to accommodate these as much as possible.?""""
but it appears to me that the company is only giving lip service to the town; they are confusing listening to local views (which they have done) with taking account of local views which they specifically stated they are not doing. "We are speaking with the county council and we will do what they tell us to do. That is how it works. And if they don't tell us about an issue then we won't take it into account""
On the access side, the Asda representatives told us that they have yet to do their research and traffic surveys - that they have been waiting for a specific set of circumstances (such as no roadworks nearby and a regular school week) to do that research. That tells me that they have no intention of doing a series of surveys to get an overall picture, but are looking instead only at road loading at a benign time - no holiday traffic, no diversions on to the road. And as they haven't done their surveys yet, their proposals on the traffic remain too woolly to be worth comment - they couldn't even tell me whether there would be just one of the two lanes of traffic currently available for through traffic left in place after their development (having taken a lane for store access) or whether they would provide an extra lane.
I note a level pedestrian crossing over the busy dual carriadgeway is proposed rather than a bridge. A separate light phase for pedestrians would restrict traffic further.
I note that no connection or link of any sort is considered with the nearby station. And that bus plans are either for just two bus laybays or roadside stops on the busy A350 / A365 combined section. They would accept buses coming in and turning, but provided no evidence of early negotiation with the bus companies.
The new store is sufficiently far from the town centre for it to NOT feed people naturally to other shops, in spite of Asda'a suggestion that it would. They confirm this fact themselves at times by talking about bus connections TO THE TOWN - my capitalisation.
With regards to trading, Asda spoke of the current stores in the town "Overtrading" and indeed it is their business plan to steal some of that trade in order to help reduce the business done by other local stores to a more average level. I didn't see any representatives from the town stores at the Asda meetings during the short period I was there, but I would be very surprised to find the store being given quite the golden welcome Allison describes in the press release, and no-one has commented to me personally in that direction.
One thing, though, that ASDA do have right - VERY right - is the bustling, expanding scenario in Melksham. And I hope that even at this 10th or 11th hour in their proposals they'll look at making a few changes in their stance so that they really DO work with the town and gain our support, rather than taking from the town and finding that - perhaps - their planning application meets all sorts of local objections.
Comment from Selwyn Rowley, one of the gentlement we spoke to, on behalf of Asda. Exceptionally I am cutting this into the regular article to give it more prominence ....
Hi Graham
I noted the comments in your blog and feel that it may be helpful to respond to a few of the points raised.
I agree with you about the potential for Melksham which is why ASDA would like a store there.
It is our intention to take full account of local views and we believe that it is in our interests to do so.
Having spoken to to literally thousands of people in Melksham and received hundreds of written representations a very positive view has emerged . Over 90 per cent of the people who have communicated with us want ASDA to come to Melksham.
While this support is very important to our case, we also need to meet the requirements of the District Council planners and satisfy the County Council on the transport aspects.
The guidance from the Department of Transport states that traffic data should reflect the normal traffic conditions on the network e.g. not school holidays. In addition prior to starting an assessment a Scope of Study has to be submitted and agreed with the relevant Highway Authority - in this case Wiltshire County Council.
With regard to trading, the key point is that the majority of the catchment population are currently not shopping in Melksham but are driving to do their shopping in the surrounding towns. If ASDA can help to redress this imbalance and encourage more people to shop locally that should create opportunities for other local traders and that is something we would encourage.
Selwyn
Posted by gje at 07:52 AM | Comments (1)
Related topics: via article database
September 20, 2007
Little Gems but not Lettuce
Two little gems that struck me today.
In the Art Café in Melksham, we sat and had our PHP course lunch. Everyone was chatty, except for Sean who kept looking over John's shoulder to the door behind. Then I spotted it; a steady succession of people were buying their food at the counter and bearing it out of the seating area, on China plates, through the door marked "Toilet".
In McDonald's where we had popped in for a quick (ha, ha!) burger before an evening meeeting, I picked up a piece of paper for children to complete for a competiton. The top part of the page was marked Head and then the section below was marked Body. Looks to me that we're into McWeb Design here. Then I noticed the third section marked Legs / Tail. Perhaps there's a new standard called Web 3.0 coming along, or perhaps I had missed something.
If you're wondering about the Art Café let me put you out of your misery. That door also leads to the offices of the Melksham Independent News, our good friends who are so supportive of our "Save the Train" campaign.
Posted by gje at 09:23 PM | Comments (0)
Related topics: via article database
September 19, 2007
Look forward with a new broom - Wiltshire Train Service
When the First group took over trains to our town of Melksham, population around 24,000 and growing, we were served by 10 trains a day and ticket sales for journeys that started or ended at Melksham were rocketing. That was 1st April 2006.
On 10th December 2006, First withdrew all 10 existing trains and provided 4 new services - leaving Swindon at 06:19 and 18:42, and leaving Westbury, Wiltshire at 07:00 and 19:35. Unsurprisingly (to us who live on the line, at least!) they lost most of their business - people cannot travel on the railway if there's no train running, and the timing meant that even the targeted customers for the new limited service - commuters to Swindon - found it inappropriate as their days were extended by 90 minutes.
We have been told, quite honestly I'm sure, that the new timings are pushed into "marginal time" to save the company the cost of hiring an extra train, and that schoolchildren travelling from Stroud need the train at the time that we used to have it.
Attempts to have an appropriate service provided from December 2006 failed. A consultation recognised the problem, but gave us no improvement. Attempts to provide an appropriate service from December 2007 look like they have failed. Draft timetables that have been release under Freedom of Information show an improved service on which a huge amount of work has been done, but it's all come to nowt at the last minute. And we're now told to try for 2008. We HAVE got somewhere - we have had the case taken much more seriously than it was in the past, where we were a footnote on an internal page of a Strategic Rail Authority document, but people cannot travel and the economy of West Wiltshire cannot thrive on the serious consideration of a case. We need real trains!
You would have thought, then, that I would welcome the news this morning that the Managing Director of First Great Western, who was instrumental in First's specification of the new service both before and after the award of the current franchise, has departed from that role in rather less than a blaze of plaudits and glory. I do welcome the news - a hopeful new beginning, perhaps - but I do wish her personally well for the future. To a very great extent she is simply one cog in a big machine, and as the machine moves and the cogs turn ...
But let's look forward. In spite of a repeated series of failures of the players to provide an appropriate service we HAVE moved forward quite a bit. Distant decision makers in London and Aberdeen now know where Wiltshire is, and have learned that the towns of Swindon, Chippenham, Melksham, Trowbridge, Westbury, Frome, Warminster and Salisbury are bustling places and going to be growing rapidly, with travel requirements between over the next few years.
Let's work with those decision makers, and with the team as now constitued at First Great Western, to provide an appropriate service as soon as it can be practically achieved
Posted by gje at 01:30 PM | Comments (0)
Related topics: via article database
September 18, 2007
Clean my plate, but keep my wine bottle. (PHP; Static)
On Monday morning, I served Colin's breakfast on a clean plate in the "Whitworth" ... one happy camper, judging by the crumbs and butter wrappers left on the plate, and the smile on Colin's face.
Never wanting to disturb a customer's property and space, I carefully preserved the plate as Colin left it on that morning and returned the plate to him, in that same crumby condition, on Tuesday morning. But Colin didn't appreciate the care I had taken to preserve his crumbs and would have much preferred a clean start.
On Wednesday, I'll make sure he has a clean, pristine new plate!
When you call a function in PHP, the internal variables within that function are freshly re-initialised each time. There is no debris left over from previous operations. And that's a good and sensible default - just like Colin on Tuesday and Wednesday morning, you don't want to be reminded about what happened on Monday.
Colin drank a glass of wine out of a bottle he brought with him on Tuesday night, and came looking for it to have another glass on Wednesday night. He was a little unhappy that we had cleaned up and thrown out his undrunk wine, even though he had requested a clean breakfast plate each morning. This is an exception to the "clean up fully every time" rule ... and in PHP terms, you would declare a variable within the function to be static to ensure that its value is held from one call to the next.
Posted by gje at 11:21 AM | Comments (0)
Related topics: via article database
Useful link: PHP training
Crystal Ball - How long do I need to be online?
There are times I feel that I need a crystal ball ... such as when I'm faced with that decision as to whether to buy 120 minutes of internet access at €14.95, or all day access as €19.95. Problem is ... until I check my email, I don't know how long I'm going to be online ... but I can't check my email until I have connected.
The more times I come into that situation, the more I realise than our bundling in of unlimied internet access with our hotel room charge is the right decision.
Posted by gje at 08:13 AM | Comments (0)
Related topics: via article database
September 17, 2007
.php or .html extension? Morally Static Pages
You'll find many pages on our web site with .php extensions, and many more with .html extensions. "So the .php files contain executable content and the .html files do not" you may think. No - not exactly; in practise almost every page actually contains some PHP / Script elements. So WHAT, WHY, HOW?
WHAT ... All pages which contain data which is essentially unchanging have extensions that end in .html, but pages which are essentially dynamic are classified as .php.
I describe the pages that are unchanging as Morally Static Pages, and examples might include /share/prisonbridge.html and /mouth/17_Differing-tastes.html, both of which are generated from databases; in essence they don't ever change a great deal unless I modify the content, but you will see small changes from time to time in the list of nearby places on the Prison Bridge page, or in the "see also" column of the Differing Tastes page.
We have a number of truly dynamic pages. For example our Site Map Page will change to give you a site map relative to your current location each time you call it up, and our Image Library Search will vary depending on what pictures have recently been added and what you're searching for.
WHY ... If you are looking for a page, then you'll feel confident that a .html file is one that you can bookmark, come back to - a simple soul that's going to vary little and you can rely on to stay the same until the site owner changes it. By contrast, if you find a page that's saying that it's dynamic, it probably is and you'll treat it with a degree more respect. You may bookmark it, but you'll be aware that results may change rather more frequently, and you'll treat it with rather more circumspection.
The same thing applies to the best search engine crawlers, I think. In amongst all the various factors they take into account, they'll look at how often a page changes / is likely to change and the extension offers a good clue. So the application of different extensions is an aid to them as they're indexing your page too, helping them to categorise as appropriate.
HOW ... We're using the .htaccess file and Apache httpd's mod_rewrite to provide the facilities that we need. At the very simplest, a line such as
AddType application/x-httpd-php .html
added to the httpd.conf (or appropriate .htaccess) file(s) will trigger the web server to parse all .html files in case they contain PHP. In a more extreme case, a directive such as
RewriteRule ^(.*)\.htm /share/index.php?pagename=$1
will take all .html and .htm requests and divert them to index.php, with a parameter called pagename being passed in. This is the basis under which a whole directory of Morally Static Pages can be generated on the run, without there being a single truly static page present at all.
Posted by gje at 07:07 PM | Comments (0)
Related topics: via article database
Useful link: PHP training
Match the Bedroom to the Hotel
Can you match these pairs of pictures - one in the left hand column to the one of the same hotel in the right hand column?
Picture 1![]() | Picture A![]() |
Picture 2![]() | Picture B![]() |
Picture 3![]() | Picture C![]() |
Picture 4![]() | Picture D![]() |
Picture 5![]() | Picture E![]() |
Posted by gje at 01:29 AM | Comments (0)
Related topics: via article database
September 16, 2007
Mood shots
I don't know if the term "mood shots" is right, but Lisa and I were talking yesterday as to whether factual photographs of our rooms, or more atmospheric shots, do us best justice. I've posted up a lot of pictures of specifics in the past, so here are a couple of more atmospheric pictures ....


... which we coud use to advertise the Well House Manor hotel, and the Well House Consultants training courses in Perl, Python, PHP .....
Posted by gje at 10:30 AM | Comments (0)
Related topics: via article database
September 15, 2007
Actionscript / Flash / Flex (IAQ/FAQ)
An IAQ (Infrequently Answered Questions) document?
You may feel that some the basics about Actionscript, Flash and Flex are well known - but I didn't really understand some of it until recently and I've had one doooozie of a time trying to find the wood from the trees. So I think there's a need for some questions to be answered.
* What are the components of a Flash / Flex / Actionscript System?
* How do they work together?
From Adobe, you have the Flash Player - a piece of software that's a free download to run within your web site visitor's browser. And you have a product for the developer to use which is used to produce the Flash movie in some way. In this setup, nothing which Adobe supply is directly loaded on the server; it's only the developer (and then if he chooses the full Flash development environment) who has to pay license fees.
The Developer uses either the Adobe development environment or their no charge command line based tools to convert files such as .as file (actionscript) and .mxml files (xxxx) into flash movies in .swf files. These files are then loaded onto the client's web as a part of the web site. This web site will also include a .html file that refers to the .swf file, and may also call up all the other "usual suspects" for a web page, such as .jpg .gif, .js, .css and so on. The development of these files is unrelated to Flash.
When the visitor to the web site calls up a Flash movie / Flash content, he loads first the HTML page by browsing to its URL. The HTML then calls up the ancilliary files it needs, such as the .swf file containing the flash movie, and style sheets, images, etc. Javascript may be used to check whether or not the visitor has an appropriate version of the Flash player, and so take alternative action (such as providing an alternative or suggesting a download) if necessary.
During the playing of the Flash movie, and user interaction with it, server data may be required and the Flash can make further requests back to the server - submitting information and receiving data back from (example) a database, which in turn can be displayed within the continuing movie. I've uses PHP as an example of this in the following diagram, although in practise you could user .net, PHP, Perl, Java / Servlets / JSPs or more or less any other technology you wanted.
Here's a diagram ... click on the diagram to open a larger version in another window.
* What is Actionscript
Action script is an Object Oriented programming language with a similar look and feel to Java and Javascript, but with major improvements / enhancements to handle the development, animation and interaction with Graphics, Images and Graphic User Interfaces within Flash movies. As it looks so similar to those other languages, many of the standard programming methods and techniques used in Java / Javascript coding can be applied to ActionScript, but there are extra considerations as well. It's not trivial to learn the techniques, but it's great fun.
* What are the flash., fl. and ml. imports
Standard componets are in packages / classes just as they are in Java. The flash. classes are part of the basics, fl. classes come with the commercial Flash CS3 from Adobe, and the ml. classes are broadly the equivalent of the fl. classes for use with the flex compiler.
* How do I get a piece of action scripts to interact with data held on the server?
Best way to show you that is to do a little demo. It's at http://www.wellho.net/ascript/button.html
The HTML page that we used to load the Flash movie is here. The main ActionScript code here, and the button interaction class here. Finally, our token PHP script is here.
The demo changes the colour of the button (to represent a local state change) when you press it, and tells the server if the button is now black or white. The server responds by echoing a "1" or "0" for the current state, and also telling the Flash movie the IP address of the machine the browser is running on. This information, which is just a hint at what the server could do, is echoed back onto a label.
* How do I tell whether a user's browser has action script loaded?
See an earlier article I wrote; includes source code links, etc.
Posted by gje at 11:09 PM | Comments (0)
Related topics: via article database
September 14, 2007
Compressing web pages sent out from server. Is it worth it?
Web servers can compress .html and similar files before they send them out - a great way to keep traffic volume down where bandwidth is more of a consideration than processor power. But what proportion of browsers can accept compressed data? That's a darned good question which I was asked on today's Tomcat Deployment course.
Adding in a few lines on the end of a PHP script that encapsulates all our web pages, I kep a log file for a short while. And out of a sample of 1380 hits on our web site ...
1035 (75%) could accept gzip compression
822 (60%) could accept deflate compression
166 (12%) could accept x-gzip compression
Only 245 requests (18%) did not include any notice that they could receive compressed responses.
Here's the PHP code I used ...
$fho = fopen("$_SERVER[DOCUMENT_ROOT]/../compress.dat","a");
fputs($fho,"$_SERVER[HTTP_ACCEPT_ENCODING]\n");
fclose($fho);
Remember that images are already compressed (part of the format of a.jpg, for example), so there's little point in trying to have the server compress them ... but for a busy, bandwidth limited setup at server and/or browser, I conclude that compression IS worthwhile.
Posted by gje at 04:57 PM | Comments (0)
Related topics: via article database
September 13, 2007
FSB (Federation of Small Businesses) Western Region
Until this Spring, the local branch and region of the Federation of Small Businesses (FSB) ran a series of well attended events for their members - we attended networking events and informative sessions of various sorts, meeting a wide variety of people; a real benefit to our business.
But in the last couple of months, these activities have dried right up. I can find at least six that have been cancelled, some very close to the time they were due to run. We were informed of one event that wasn't happening with less that 48 hours to go before it ran, and I understand that some attendees actually turned up at the "Vision for Trowbridge" venue to learn more about the plans for the town's development ...
"The FSB is a member led organisation" says the organisation's web site, and six months ago you would have found a list of the local and regional committees and members on there. But now [written 9.07 / page now changed] you'll find that the regional page just gives you a contact number of a person in Blackpool (that's where the FSB has its headquarters) and a local contact for the Regional Organiser - a paid employee who takes direction from Blackpool as to how to provide local assistance. "Please remember that there is only me and my 40 hours each week, and there are 8 branches and nearly 8,000 members in our region" she wrote to me recently. Yes - it would be impossible for any one person to run the whole region that was formerly run by an active and keen committee, delegating to branches and all working together. And it would be doubly hard for one person who's very new to the job, and triple hard when you consider that there's likely to be a lot of unhappy people and politics effecting the changes through which the regional officer has to try and work.
So what has happened? I only know part of the story, and indeed the FSB's secrecy rules would limit what I could say if I knew the full Monty. I can tell you that we all supported our dynamic regional Chair when she stood for the election to the role of National Vice Chairman, but as a first time candidate she was less known than others who have been around longer. "Building bases" is how I would describe it. I can tell you that it is that same person who won the Vice Chair that is now in charge of the whole areas, with the regional commitee suspended and the AGM, I have just learned, cancelled. I am unable to tell you whether or not this is all above board, or whether it's a conflict of interest, or a case of the Victor rubbing the nose of the vanquished in the victory, but I know what it looks like to me personally.
Really it's very sad. In just a handful of short months, a dynamic region has been closed down. The member's money wasted for events that have been cancelled, and that is a shame. The committee member time wasted on things other than the membership is sickening. The lack of regard shown by the people now in charge for their member is ... well, at this point words start to fail me.
I was taught that a manager's role is to facilitate the operation of his staff - to provide a helping hand and an oiling of the wheels of systems so that they can do their job, and in turn service their customers. And that's a good lesson. In my view, the board members should be helping and assisting the regionally elected committees, who in turn should be helping and providing services for their members, each of whom pays a considerable sum each year to "The Fed".
Personally, my time is limited. I have served on the local branch commitee for the last year and we certainly managed some wonderful events for members - at no cost to the central coffers either in most cases - early in the year. But I don't have the time to "play politics" on this scale and won't be offering myself for the committee for the next year. If you're an FSB member reading this, and want to ask your local officers what's going on, here are the contacts listed on the web site. If you would like to ask the local active members, have a look back at some of the older materials you may have for their details ... or if you drop me an email, I can forward for you.
This is, perhaps, a good post for me to post an "addendum" on to, reminding my readers that although I speak here officially for my own work / company / employer, I do not speak in any officlal capacity for others. So in the post above you're reading purely my own views EXCEPT in my comment that the FSB's local events have been of great benefit to the company. That's official
P.S. To complete the record - here's a link to my open letter explaining why I'm not standing for the FSB local commitee elections again.
Update - November 2009. This article has recently been brought to my attention as being potentially biased, incomplete or in error. I am happy to make necessary additions to complete the story or reflect other views, and to correct any error of fact. See here
Posted by gje at 07:08 PM | Comments (0)
Related topics: via article database
Cash is not an acceptable way of paying

Is it just me, or do you also feel it's the end of an era when a pay phone no longer lets you pay in cash?
The coin slot in the phone box is sealed with a plate that says "see sign", and there's a sign telling you how to make a reverse charge call.
Heavily vandalized inner city area? No - this is the village of Broughton Gifford in the Wiltshire countryside just a few miles from Melksham.
Posted by gje at 08:39 AM | Comments (0)
Related topics: via article database
September 12, 2007
Screw it or Glue it? Access to Object variables - a warning
If you screw two pieces of material together, you have the opportunity, later on, to unscrew them ... resuse them differently, install a waterproof membrane between them, and so on. But if you glue them together, later modification will be much harder or perhaps impossible. And in a similar way, if you're connecting two pieced of software together it's better to screw them than to glue them. What am I getting at?
If you access a member variable within an object directly from your main calling code, then you don't leave yourself the opportunity to intersperse some extra check or twist later on, whereas if you access all member variables via methods - even if they are really just empty wrappers, you leave yourself the flexibility for later. Let's see an example.
Here is a (Python) class:
class pidgeon:
def __init__(self, name, value):
self.name=name
self.value=value
def getvalue(self):
return self.value
which I can use like this:
george = pidgeon("John Smith",200)
gina = pidgeon("Jenny Smith",50)
print "Value of George is",george.getvalue();
print "Value of Gina is",gina.getvalue();
and it will print out 200 and 50. Here is an alternative class:
class woodpecker:
def __init__(self, name, value):
self.name=name
self.value=value
and I can access the data, more simply, as follows:
print "Value of Gerry is",gerry.value;
print "Value of Graeme is",graeme.value;
I now want to set a mimimum value of 75 pounds on all birds - pidgeons and woodpeckers. With pidgeons, it's easy - I just modify the getvalue method as follows:
def getvalue(self):
if self.value < 75: return 75
return self.value
but with my woodpecker class I'm stuck.
Pidgeons are like screws, and woodpeckers stick like glue!
Posted by gje at 08:44 AM | Comments (0)
Related topics: via article database
Wireless Internet Access at hotels - an update and some pitfalls
If your hotel has wireless access, then there's not much to choose between modern wifi cards / built in facilities these days. But its much more questionable as to how your hotel will be set up for their wifi to operate. I travel - a lot - as part of my job; away last week and I stayed at three hotels all of whom claimed wifi access but ...
First Hotel - wifi just disappeared and it sounds like it's not the first time. Not fixed when reported.
Second Hotel - wifi was through t-mobile and seems to block Skype
Third Hotel- turns out that claimed wireless access is in the adjacent 24 hour service area not in the room at all.
Best comments? Know your computer well. Check ahead with the hotel. Have a "webmail" style service so that you can check from an internet cafe / shared system if need be. Take an ethernet cable in case it turns out to be wired access. Check for other wifi hotspots in the area. Even a modem cable and an a roaming account can be useful. And you may be able to check via your mobile phone.
Actually, it gets easier. At least in most parts I travel to, there are nearby alternatives if the hotel system fails me and it's more an inconvnience than anything else to find an alternative.
An answer written for more "local" use .... which I felt was worth sharing!
Posted by gje at 07:03 AM | Comments (0)
Related topics: via article database
September 11, 2007
Evening, Devizes and Sells Green
Three pictures - taken by Lisa yesterday evening in an all-too-rare snatched couple of hours out.

On the Kennet and Avon Canal below Prison Bridge, Devizes

Moored outside the Black Horse, near the top of the Cane Hill flight of locks

"The Three Magpies" at Sells Green - just 2 miles up the road from us in Melksham. We consider "The Three Magpies" to be our local.
Posted by gje at 08:54 AM | Comments (0)
Related topics: via article database
Perl and Shell coding standards / costs of an IT project
There are three major staff costs in the life of an IT project - the specification and development of the system, the maintainance and upgrading of the system though its life, and the investment that's made in data entry and integrity through the life of the system. And although there's a lot of thought put into the cost of developing a new system, that element is actually the smallest of the three. Ongoing upgrade / repair / maintainaince ends up costing more that the initial development. And the user's work on the data will end up being a bigger investment than the other two elements put together.
So it is important - REALLY important - to write the initial code in such a way that it can easily be amended through its life, and in such a way that it puts the user experience and efficiency as high priorities in the implementation. And to assist with that, a coding standards document is an excellent starting point and set of guidelines.
We have such a set of standards for Perl on our web site (here). And haveing such standards is particularly important for Perl - you'll see why on the standards description.
A correspondent writes:
"I am an employee in a CMM level5 company and I am asked to create a document regarding PERL and UNIX(shell scripts) coding standard.I found your site very useful to draft a document regarding PERL coding standards. Can you please provide similar help for preparing UNIX(shell scripts)."
And my reply:
I'm glad you found our site useful with regards to setting of Perl standards; it's a language in which programmers can write code that is utterly unmaintainable, as well as really clear and clean code, and a good set of standards should be at the core of any organisation's Perl strategy.
With regards to Shell programming, we don't have a similar set of documents available. Shell programs are typically much shorter and the issues of maintaining medium size to large scripts are far less common. In addition, the number of overlapping facilities and ability to shorten code in shell to the point it becomes hard to understand is far less. There are also numerous different shells, with each really needing its own set.
I'm afraid I don't have the free time to simply sit down and draw up a standard document, but I would be happy to put a day aside under our "extra" training scheme that would allow you and me to draw up a set of such standards together. The cost of such a day is 350.00 pounds + UK VAT at 17.5%. There are further notes on these days at (here).
The offer of mine is a real bargain - an astonishing offer in fact. But that's because I really want to help encourage quality coding. Here at Well House Consultants, we'll train you on not only how to program in Perl / PHP / Python / Ruby / Tcl, but also how to make the very best of those languages in writing maintainable code, with reusable modules / packages to save recoding, and with major thought to the user experience too.
Posted by gje at 08:16 AM | Comments (0)
Related topics: via article database
Useful link: Perl training
September 10, 2007
Catching up on indexing our resources
The amount of material that gets added to this site in each month is incredible, and if I let it go much longer that that before catching up on indexing my blog articles, images, and forum posts the task can become almost unmanagable. A hectic time left me wonding how I would manage to get all these updated, important but rarely urgent, done; my car distaster and missed Pycon weekend gave me an unexpected window.
The illustration here - and over 100 others - have been labelled up in our image database. You can see those images in six pages ... here, here, here, here, here and here. Source code examples - the bread and butter of our training business - have expanded to nearly 1800 examples (that's an increase of nearly 50), and the web site as a whole comprises 8994 pages - just another couple of days of blogging and we'll be over the 9000.
Is it important to have all these resources? And to index them? Yes and no; there are pages here that are rarely read and are forgotten in the mists of time within hours of being posted - lost never to be viewed by anyone as a useful tool. But them there are pages that are accessed hundreds of times a day, from all over the world ... and I can't predict which pages those will be. A frankly flippant piece on Bratton and Edington New Town has been picked up as a significant warning about getting the future development of this area correct, but a following piece on the security issues of hotel room keys appears to have sank without trace. It would be really great if I knew which way any particular post would go ahead of time!
But there's not only the question of having the resources there for people to find, but also having the other associated pages / examples / resources all indexed under the same banner too. And that's a lot of this current indexing job - helping people who land in almost the right place to take one or two steps and find all of exactly what they need. And this means that I look back at all my posts here and decide what topic they relate to. You may call the system old (it is), and crude (it is) ... but it's also effective. For example - you'll find all reources about Tcl's packages and resources indexed in a single location whether they were written in October 2004 or yesterday (9th September), and you'll find that the index page also links you to other associated Tcl/Tk pages such as those that deal with Geometry Managers.
For none technical readers, the same strategy applies too .. you'll find an around Melksham group of resources, and another bundle labelled Business accommodation in Melksham. You'll even find behind the scenes if you want to go back over some of my more revealing posts.
Posted by gje at 12:51 AM | Comments (0)
Related topics: via article database
September 09, 2007
Melksham Laundrette
It always amazes me to find all the things we have close at hand here in Melksham. After looking up several directories and searching around - calling a place in Trowbridge that couldn't accommodate our customer today and trying one in Westbury that wasn't answering their phone we found what we were looking for - a Laundrette - up in Melksham Forest!
The Launderette
Church Lane, Melksham, Wiltshire, SN12 7EE
Tel: 01225 356188
Helpful owner, plenty of machines ... and my customers who are on an extended stay have just come back similing an happy. Melksham's like that - you need almost anything and you can find it, quietly lurking, somewhere!
Oh - he's open 7 days a week from 08:30 to after 19:00 ... I may have got that an hour out at either end of the day, but certainly all day, every day ... and after work for a while too.
Posted by gje at 05:42 PM | Comments (0)
Related topics: via article database
Google, wwmdirectory, Freshwater, ATP - new scam?
While I was away last week, Lisa received two invoices in the post with the Goole logo on them - for 79.99 each - and wondered what I had been ordering. Nothing - I believe they are a SCAM. Having used the esteemed Google search engine itself to look into these and draing a blank, we have taken it up with Google who are looking into it. Me thinks if it was genuine, they would have known / put us right in touch with the correct department.


Let me give you some key words / text so that you can see if you get a similar invoice.
Google TTP - www.wwmdirectory.com
77 Brambles Chine, Monk Lane, Freshwater, Isle of Wight, PO40 9SU
Advertising subject to adherence to our credit terms. This Pro-forma invoice is a special offer and can be cancelled on request or non-payment without obligation or recourse. More sales or money back offer
I think that latter says - "This isn't an invoice you requested so it's up to you whether you pay or not. And if you don't pay, there's nothing we can do about it". Ah ... I don't think I'll pay. So glad that Lisa has the presence of mind not to be taken in by quite a cleverly worded scam.
I've put an item on the Opentalk forum on this - Please follow up or update me if you know more!
An Update. It looks like we're not the only one to have received these invoices. Lisa writes:
Phil Brierley of York House Leisure received an invoice from ATP (Google Adwords) and googled for more information and came across your blog.
He [phoned] wanted to discuss your experience...I relayed the fact we've reported them to Google. He actually phoned ATP to query the invoice and was hung up on...the chappy being very evasive.
He's very much against this type of scamming and wondered if he could help, or if a combine effort would help, etc. give him a call to discuss if you are interested.
I've been in touch with Phil, and he has posted a follow up on the forum too. We've been in touch with Google and I'm updating this page / item as I hear more so that it becomes prominent. Would love more stories ....
An update - a year later - 12th September 2008.
This Spring, the Advertising Standards Agency upheld a complaint against the wwmdirectory mailing - see here and here. And the wwmdirectory website is no more ...
I had heard, last year, of another site called "tradeorlando" which was - I think - the previous scheme coming from the same team. It appears that in the last few months there's yet another appearance from the same team at Honeytrapagency - that's www . honeytrapagency . com , which I'm not making linkable. But you might want to look at other forums - here and here.

Tradeorlando ... gone ...

Wwmdirectory ... gone ...

Honeytrapagency ... current ... Top links are "Directory Pages", "Order / Cancel Advertising" and "Advertising Rates" ... which seem a very odd choice indeed for a detective agency!
Posted by gje at 03:22 PM | Comments (1)
Related topics: via article database
Moving to Melksham? Househunting map.
Do you know your Snowberry Lanes from your Shurnolds, or your Snarleton Lanes from your Spas? If you're a long time resident of Melksham you might, but those of us who have only lived here for a few years sometimes overlook some areas of the town, and newcomers moving here - looking to rent or buy - need to find some information that's wider than a town cenre map, and less wide than a map that shows Melksham in relation to Chippenham, Trowbridge, Devizes and Bath.
As operators of a business hotel in Melksham, we're finding that new employees to local companies are staying with us in their early days in their new role - using our hotel as a home from home for a few days or weeks while they sort out where to rent or buy. And - ever wishing to be helpful - I've drawn up the map you see alongside this paragraph to show the different parts of the town.
LINK HERE to a larger version and key
Under the Regional Spatial Strategy, Melksham will probably grow some 50% over the next 20 years, with land to the East (around Snarelton Lane - number 21 and south to Snowberry Lane - number 13) already earmarked for the growth. The secondary School - George Ward - is currently situated in the Shurnold area (number 15) to the North West, but will probably be relocated to a new site just to the north of the Magister Road area of Bowerhill (number 18) in the next few years, with the old school site providing a further 200+ accommodation units.
Posted by gje at 10:20 AM | Comments (0)
Related topics: via article database
Tk locks up - 100% c.p.u. on a simple program (Tcl, Perl, Python)
Fighting packs and grids - Tk under Tcl, Perl, Python
You'll use pack OR grid to place components into your frame in a Tcl/Tk application. You may use both pack and grid within the same program, but NOT within the same frame. If you do, not only will you be writing code that has no clear meaning, but you'll also invoke the pack and grid handlers at the same time and may cause them to fight. Have a look at this code:
button .ouch -text "do NOT press this button" -command exit
label .more -text "This is a label"
button .wow -text "This is a button you may press" -command exit
label .contd -text "Another BORING! label"
grid .more .ouch
pack .ouch .more
pack .contd .wow
grid .wow .contd
When I ran that, my prompt was lost, no wish window appeared, and my c.p.u. utilisation rocketed to 99% ... and stayed there. I guess when you have two individuals fighting, they don't show any regard at all for others around them.
Footnote I've often contended that the way to get a user to select a button is to label it "Do not push this under any circumstances" ... which is what I have put in the example above. Some may say that I have a warped sense of humour, or that I have watched too much "Trigger Happy TV".
Posted by gje at 07:13 AM | Comments (0)
Related topics: via article database
Useful links: Python training, Perl training, Tcl training
Packages and Namespaces are like Suitcases and Aircraft
Are Suitcases and Aircraft the same things? No, clearly they're not, but you'll often use them in close assocoation with one another. When I was in Albany, New York State, the other week ... I travelled there from Melksham with a suitcase of luggage, and I used an Aircraft for my journey. Taking each item of luggage separately, or going by boat, would both have been changes that would have made my trip impractical. And so it is with packages and namespaces in Tcl. They are separate facilities, but they are naturally used together.
A package is a bundle of pieces of code - usually procs - which are held in a separate file in a separate directory. They're loaded in as required with a package require statement, which looks in the various directorys that are in your auto_path varaible for a file called pkgIndex.tcl.
The command pkg_mkIndex (that's a Tcl command!) is used to automatically index and create each of your directories of packages, and in your main program you can use lappend to add extra directories onto the auto_path.
Finally, notes: All packages must be provided with a version number - it cannot be left out. Packages are only actually loaded when their first proc is called and not at the point you say you require them.
Sample files:
twice - program that calls in a package
toes.tcl - the package it loads
Namespaces are a way to allow you to zone your variables - give separate names to procs and variables that are called the same thing within their own areas of code. So you can do a namespace eval shapes { and the block of code down to the } would all be evaluated it it own private area. If you defines a proc called rectangle within shapes then you would refer to it at the upper level as shapes::rectangle or - in absolute terms - ""shapes::rectangle.
Notes. It's usual to have your package name, your namespace name and your file name all the same so that you and your maintainance programmer can easily see what goes with what later on. Procs can be exported from namespaces and imported to others if you wish to reduce the amount of "::" notation you're using, but shouldn't be used too much as they somewhat nullify the whole point of separate namespaces.
Sample files:
2wice - program that uses a namespaced package
doubler.tcl - that namespaced package
Used together, Packages and Namespaces provide an excellent mechanism for you to split up code between a number of developers and share code between a number of applications in Tcl, without any serious issue of conflicts bewteen the people and the areas. The use of namespaces further provides some built in self-documentation which is a huge help in knowing what's where in a large system.
We cover Packages and Namespaces on our public Tcl programming course, as they're an integral and important part of most larger Tcl applications these days. For newcomers to programming who start to learn Tcl on a Monday, this subject on Wednesday will be more of a demonstration than something they'll do a long practical on, but for experienced programmers there's a very useful exercise to be done. And for nearly everyone who has existing code to maintain, there's a lightbulb moment where they see how the colon-colon (::) notation comes together.
The example that you're looking at here was written within the last few days to illustrate some points I was making while running a private Tcl course in the Netherlands; such courses can be (and are) tailored to suit customer needs. We can also run tailored private course at our own training centre.
Posted by gje at 06:45 AM | Comments (0)
Related topics: via article database
Handling Binary data in Tcl (with a note on C)
In Tcl, all variables are held as strings, and most of the commands will split / divide strings at new line or space characters by default. However, there are a few commands that do NOT make that distinction and since a Tcl string (Unlike a C string) may contain any bit pattern at all, they provide a very useful tool for binary data handling. Here they are:
read. Read in a certain number of bytes from a file handle (up to agiven maximum or to the end of file, irrespective of the characters read).
Example: set header [read $stuff 10]
binary scan. Divide a string into a series of separate variables, using a format string that's given as a parameter.
Example: binary scan $header a3a3ss type version ecs why
Takes 3 chars from $header into the variable called type, the next three into the variable called version, the next two (as a 16 bit integer) into ecs and the next two as another 16 bit integer into why. Formats can include 16 and 32 bit, big and little endian, etc
binary format. Take a series of values and save them into a single string. This is the opposite of binary scan in many ways, but there are a few more differenced in the format, the inputs are given with $s (as you would expect) and the output is returned.
Example: binary format ss $hilda $stan
Returns a 4 character string having packed in the two decimal numbers in the Stan and Hilda variables as 16 bit integers
puts. Puts will output any string; remember to use the -nonewline option if you don't want to an extra c/r added. Then remember than you might need flush or fconfigure.
Putting it all together - code that reads the start of a .gif file and tells the user how tall and wide a clickable image in a web page would be, assuming a default 1 pixel border:
set stuff [open tongue.gif r]
set header [read $stuff 10]
binary scan $header a3a3ss type version ecs why
close $stuff
incr ecs 2
incr why 2
puts "It is a $type file version $version size $ecs by $why"
puts -nonewline "(Size allows 2 extra pixels for a clickable "
puts "border in this demo"
Fill code with comments: Here
Note on Strings in C. In C, you may store any bit pattern that you like in An array oc Chars. However, if you use the built in string handlers to manipulate that array of chars, you'll find that they all assume a null character (\0 or 0x00) as the end of string and will truncate at that point, or overrun if you char array doesn't contain a null.
Posted by gje at 06:14 AM | Comments (0)
Related topics: via article database
Useful link: Tcl training
September 08, 2007
A series of tyre damages
Warwick, 11 a.m., Saturday, for later posting. I left Maastricht yesterday evening at quarter past four, was at my overnight stop in Kent from 11 p.m. to 5:30 a.m., and should have reached Birmingham at around 08:00 ready for the Python Conference - Pycon.
So want went wrong? Debris on the motorway! The feeling that the road's a bit rough, followed by a distinct pulling to one side. Roughness on the inside lane too; me thinks I have lost pressure in a tyre and indeed that's proven to be the case when I stop and check. But I have a spare - so no issue? Right, until I discover that the locking nuts are on too tight for me and I have to call in the AA ... who seem to take a remarkably long time even at this quiet stage in the morning. But quick enough once the guy turns up with his tool; only 90 minutes of delay.
A brief stop at the service area north of Banbury to clean up (appearing at Pycon covered in tyre black didn't seem appropriate - a handshake that would have left my mark) and I notice that the other front tyre is looking low. A fill up from the free air, and I notice a hissing sound that tells me that it's coming out almost as quick as it's going in. So let's see ... no good spare any more, no ability to hold air for more than a few miles, and the service area has none of those emergency "squirt it in" cans for sale. "We used to sell them" they tell me helpfully. "They used to be THERE" pointing at a gap in the shelves.
So I put in enough air to limp into Warwick. I got directions to a tyre place, and here I sit at the modern equivalent of the Blacksmith's, having my horse re-shod. Bit of an effort to locate the right tyres / parts, but as I'm writing this a transfer seems to have come in from another store. Best estimate is that I could be away - if lucky - between four and five hours after I intended to pass the road end.
A management decision. To carry on, or to skip Pycon? I'll have missed, and well missed, the early sessions; the meat of Saturday morning, the lunch, and part of the time into the afternoon. I would be in time, for sure, for the "lightening talks", and for the evening meal. And of course for the gentler Sunday agenda - but even there I'm on a timescale as I've got to set up for Monday's Python Course that I'm presenting - which includes being in Melksham in time to greet people off the Sunday evening train.
It's been finely balanced, but I have "bought" myself the time - from Warwick I'll, eventually, head down the Fosse Way and home. I am not committed to giving any talks at Pycon (that would have changed the decision), and I probably wouldn't get the best out of it the way I feel at the moment. Nor would I come across giving the best impression. The wasted spend is regrettable, but isn't great. And - I confess - it will be lovely to be back in my own bed tonight.
Addendum .... I'm here - home - and running, 4 p.m.; so I might have made - just - the lightening talks today, and I'm sure my disshevled, rushedin, state would have been worthy of comment!
Posted by gje at 04:03 PM | Comments (0)
Related topics: via article database
Ignore case in Regular Expression
Do you want to ignore case in a regular expression? There are a variety of ways of doing it ... depending on the language you're writing. Here are some hints:
/abcd/i Perl - an i after the regular expression
eregi PHP - use eregi rather than ereg
re.I or re.IGNORECASE Python - extra parameters to the compile method
-nocase Tcl - this option is available on regexes in Tcl
But there are times yo want to apply the "ignore case" to only part of a regular expression, or use it in some other circumstances such as within Tcl's array names command. And here you can use the embedded notation of the form (?i). Here's an example - in Tcl, but this technique works for most languages these days!
set results [array names table -regexp (?i)$where]
Posted by gje at 01:23 AM | Comments (0)
Related topics: via article database
September 07, 2007
Expanding a grid - Tcl/Tk
Have you ever tried to fill or expand a grid in Tcl/Tk to fill the available space left by wider or taller widgets to the die, or when the window expands, and got results like those I have posted here? Disappointing results, aren't they? And I appear to have done all that I should in the source too:
label .title -text "This is a label" -relief ridge
frame .boxes
label .boxes.tl -text A -relief sunken
label .boxes.tr -text B -relief raised
label .boxes.bl -text C -relief flat
button .boxes.br -text D -relief groove -command exit
pack .title .boxes -fill both -expand yes
grid .boxes.tl .boxes.tr -sticky news
grid .boxes.bl .boxes.br -sticky news
The problem lies in the fact that Tk doesn't know HOW to expand the grid.
This is the improved - filled - version; I have used rowconfigure and columnconfigure on the grid command to specify how the extra space is to be distributes - evenly on the verticals and unevenly on the horizontals, as a demonstration.
Here are the extra 3 lines of code:
grid rowconfigure .boxes {0 1} -weight 1
grid columnconfigure .boxes 0 -weight 3
grid columnconfigure .boxes 1 -weight 1
This example is also useful to illustrate some of the different decoration types - "reliefs" - that can be applied to widgets. In a production piece of code, you would use only one or two of them - this training example is illustrative but will make the "look and feel" team shudder!
Posted by gje at 05:42 AM | Comments (0)
Related topics: via article database
Useful link: Tcl training
September 06, 2007
Stable sorting - Tcl, Perl and others
Have you come across a STABLE sort? A Stable sort is one in which all the incoming elements which evaluate to an equal value when tested for sorting purposes remain in the same order in the output as they were in the input. Perhaps I had better give you an example.
I have a log file and there's a date in every line, but the lines are NOT in date order. And I want to sort my lines so that every line for each day is grouped together, by ascending date order. However, within any particular day I want my output records to remain in the same order that they were in in the input file.
Input data:
20070903 John Smith etc
20070901 Bill Jones
20070902 Arthur Clark
20070903 George Hill
20070902 Arthur Dent
20070903 Petal Honour-Flower
Stable sort output required:
20070901 Bill Jones
20070902 Arthur Clark
20070902 Arthur Dent
20070903 John Smith etc
20070903 George Hill
20070903 Petal Honour-Flower
As compared to output from a standard (default) sort:
20070901 Bill Jones
20070902 Arthur Clark
20070902 Arthur Dent
20070903 George Hill
20070903 John Smith etc
20070903 Petal Honour-Flower
Sorting in Tcl
Here is the sample code to demonstrate those various sorts in Tcl:
proc first {this that} {
set one [lindex $this 0]
set two [lindex $that 0]
return [string compare $one $two]
}
lappend mystuff {20070903 John Smith etc}
lappend mystuff {20070901 Bill Jones}
lappend mystuff {20070902 Arthur Clark}
lappend mystuff {20070903 George Hill}
lappend mystuff {20070902 Arthur Dent}
lappend mystuff {20070903 Petal Honour-Flower}
puts "Report in initial order"
puts [join $mystuff \n]
puts "-------------------------"
puts "Sorts by Forename within date"
set newstuff [lsort $mystuff]
puts [join $newstuff \n]
puts "-------------------------"
puts "Sorts ONLY by date."
# Appears to keep identically ranked records in ORIGINAL order
set newstuff [lsort -command first $mystuff]
puts [join $newstuff \n]
The lsort command sorts a list, returning a new list, and lsort -command does the same thing but allows the user to specify a proc which returns a negative, zero or positive value to indicate which of the records comes first (negative = no swap, positive = swap, zero = don't care). You'll note that it appears that Tcl provides a naturally stable sort in these circumstances, with and zero returns causing the output records to remain in their original order. I have seen no proof of this - the comment is empirical, but I have swapped by data lines around, and added and taken a few away, and it appears to hold.
Sorting in Perl
Here is the sample code to demonstrate those various sorts in Perl:
@mystuff = ("20070903 John Smith etc",
"20070901 Bill Jones",
"20070902 Arthur Clark",
"20070903 George Hill",
"20070902 Arthur Dent",
"20070903 Petal Honour-Flower");
print "Initial order\n";
print (join("\n",@mystuff),"\n");
print "-------------------------\n";
print "Sort by Forename within date\n";
@newstuff = sort(@mystuff);
print (join("\n",@newstuff),"\n");
print "-------------------------\n";
print "Sort by date ONLY\n";
@newstuff = sort bydate (@mystuff);
print (join("\n",@newstuff),"\n");
print "-------------------------\n";
sub bydate {
@a = split(/\s+/,$a);
@b = split(/\s+/,$b);
return $a[0] <=> $b[0];
}
The principles are very similar to those of Tcl, but the langauge is very different. Again, this appears to be a stable sort automatically.
Posted by gje at 05:16 PM | Comments (0)
Related topics: via article database
Useful links: Perl training, Tcl training
September 05, 2007
Kasteel Elsloo - Michelin rated hotel.

Monday and Tuesday nights, I stayed at that Kasteel Elsloo, near Maastricht in the Netherlands where I'm working this week (Tcl/Tk. A beautiful place, with a superb restaurant; couldn't fault the food, service exquisite, pricing ridiculously reasonable.
So I would stay there again if I was here on business again, then? Regrettably, I would have to give it a second and third thought. I woke up this morning ... with the wireless internet out. At 7 went down to ask. "We don't know. Can't help. Ask reception where there will be someone at 7:30". So I stand in the checking line at 7:30 and I'm told - "Oh yes - we know all about that. Sometimes unplugging and replugging the box sorts it out, but we've already tried that". A further enquiry told me this is a regular problem, and that it wasn't being fixed as a matter of urgency.
It shows how criticial to us internet access is ... I couldn't risk it again on a business future trip (as it happens, they're full tonight, so perhaps don't need my business anyway!) but I might well stop there again on a leisure trip. Oh that fooood!
I'm in the Mercure at Maastricht / Aachen Airport tonight. Looks (frankly) dreadful from the outside. More expensive. But less haughty more friendly staff, I'm online ... and I'm not negotiating car loads of equipment over cobbled streets and gravelled car parks.
Posted by gje at 06:28 PM | Comments (0)
Related topics: via article database
September 04, 2007
Melksham Hotel - Five Star Kitchen!
I'm delighted to be able to report that the catering facilities at our Well House Manor have been awarded five stars by the food hygiene team of the local district council in their "Scores on Doors" campaign. That's top score, and is only achieved by a small proportion of establishments - needless to say we're delighted and my thanks go to everyone on our team who has worked so hard to bring us up to this standard. And we have a kitchen and system that was designed to not only reach these high standards, but to remain there too.
A little more background - the local District Council's food hygeine team has a legal mandate to inspect all food premises, and has powers to require changes to meet minimum standards. In order to help publicise food safety standards, and in order to encourage businesses to provide far better that a legal minimum, they have introduced this standard - a kite mark for restaurants, if you like. And I know that as a customer, I would far prefer a kite marked product to one that isn't so marked.
We plan to reach and remain at other high standards too. Having only opened as a general hotel, taking non-course guests, at the start of this year, we haven't applied for other (optional) rankings. Yet? But some of them aren't necessarily applicable - we clearly cannot meet standards that require hotels to have a minimum of 6 rooms as we only have five, for example.
What picture should I use to accompany this article? I'm currently in Maastricht in the Netherlands ... so I can't just pop into the hotel (which is in Melksham in Wiltshire!) and take a picture. But I do happen to have "one I took earlier". Not of the kitchen, but of what proved to be the most popular components of last Sunday's breakfast buffet. Last Sunday, it was the croissants (which we cook on site), the roquefort cheese, the strawberries and the orange juice (which customers squeeze for themselves) that proved to be the biggest hits. It does vary - sometimes we find that we have a hotel full of the toast and marmalade generation, and they're equally catered for.
Posted by gje at 06:45 PM | Comments (0)
Related topics: via article database
September 03, 2007
MySQL joins revisited
Sameer writes:
"Nobody can clear JOINS as this manual has done. It is SUPERB.. Thanks. It helped me a lot to understand. I will appreciate if you can make much clear to the INNER AND SELF JOINS."
in his review of a previous "Horse's Mouth" posting I made [here], which gets hundreds of hits every day, mainly search engine arrivals, and a sprinkling of "wow - that page was great" responses with no - as yet - contrary negatives. It's fantastic to get such feedback from time to time and it's all the more special when I think about just how many web pages I visit, and how very rarely I write to the page provider to compliment him.
We provide MySQL training. So, naturally, I should be able to explain things like the different join types very well, shouldn't I? Yes and no - the printed explanation as you see in books and on websites is often different to the more interactive demonstration which we do in class ... that can be even more effective!
Sameer goes on to ask for more information on other subjects such as self joins. With around 8000 pages on our site, there are plenty of answers here but we haven't yet got an indexing and search system that's as effective as we would like. So, Sameer, can I point you to:
• Our forum archive for an answer on SELF JOIN
• A previous blog entry for our MySQL IAQ (infrequently answered questions) page.
Posted by gje at 07:42 AM | Comments (0)
Related topics: via article database
Useful link: MySQL training
September 02, 2007
While waiting for Melksham Post Office
"That's the longest queue I've ever seen here" said the chap outside Melkshm Post Office yesterday. It was the first of the month, it was Saturday, and it was within about an hour of lunchtime to I suppose it was no wonder that the crowd control lines were full and then the line headed out through the door and onto the street. All of which gave me an excellent opportunity to take a few pictures to update my library while I waited for my visitor to get through the queue.
The Church of St Michael and All Angels sits just behind the town, and dates back many hundreds of years. I chuckle when I see they've added "All Angels" to St Michael, as if to have an insurance policy in case Michael himself should fail them.
Melksham is proud of its Public Loos, which have won "best in the county" prizes for a number of years. Those of us who live locally probably don't know them very well - indeed, I can't recall ever being caught so short that I can't get back to the hotel or home. I suppose I should try them out sometime for the experience.
Cannon Square, again just off the town centre, is a quiet and beautiful historic triangle (but they call it "SQUARE" for some reason!) with the war memorial set in a small garden in the middle - beautifully tended as you'll find of so much of Melksham; we're a thriving town with much beauty, but a handful of eyesores too which I have chosen to miss out of this post.
Beyond the Church, you can walk through the Church Yard and on down to the Conigre Mead Nature Reserve and the Riverside walk. Although not navigable at present, the Wilts and Berks Canal Society plan to bring boats through the town - in my view, a plan to be commended but certainly a plan which has divided local opinion. To be fair, the plans are in the early days and need to be refined a little through a committee stage.
In 1800, Melksham was the largest town for many miles - much larger than Chippenham or Swindon, for example - and that means that there are many old properties. It was a Wool and Milk town in Medieval times ("Melk-Sham" = "Milk-Town") ((but see footnote below)) and there's still much to see. Here is Church Walk, still just within a hundred yards of the post office.
Melksham's a hidden gem - well worth an overnight stop on your way to the West Country ... and you may even decide to stop for the whole weekend. Here's Well House Manor - just five minutes walk from the centre, where you can stay in 3/4 acre of grounds in what are probably the best hotel rooms for miles.
Footnote. I have been challenged with regard to my comment "It was a Wool and Milk town in Medieval times ("Melk-Sham" = "Milk-Town")", and it's probable that the challenge is correct, even though the Melk DOES come from Milk. I am asked "I think it was just a wool town, with the river running through so valuable to trade that they called it their 'milk'...that was my interpretation."
My thoughts: In hindsight, it's unlikely that there was much milk export from the area at the time the name came about. Milk was probably produced locally in all areas and consumed without transport due to the perishable nature. Only when the railways came, long after place names were established, did milk become a commodity that it was practical to ship around over great distances, and that's long after place names were established. At that time, Melksham did come to have a big connection with the milk industry. Have a look at this history of Melksham page. Here's a short quote from it
.... The 20th century reversed the decline of the weaving trade as new industries developed. Engineering and tyre manufacture became increasingly important by the turn of the 20th century as did milk and dairy produce production.
Melksham is one of the larger Wiltshire towns and an excellent base from which to explore the Wiltshire countryside and beyond ....
Posted by gje at 10:16 AM | Comments (0)
Related topics: via article database
Subway Restaurant in Melksham, Wiltshire
I'm delighted to see that a branch of Subway has opened close to Melksham, and wish the enterprise all the very best. They're on the A350 just north of the Town, and open from 7 a.m. (9 a.m. on Sunday) to 10 p.m. Yes - I am giving them a "plug", even though I'm personally not a Subway fan; Lisa is and you should have heard her cry of delight as we drove past the other day and found that the empty building, formely occupied by "The Little Chef" then "Savannah's" is now a Subway Franchise (well - I guess it's a franchised store). We shouldn't be surprised ... they have around 1000 in the UK at present and are aiming for 2010 stores by the year 2010. [Subway's U.K. Site]
Inside, the store is spacious, and the location has plenty of parking; at the moment it's hidden behind an A350 traffic jam, and so a bit of an effort to reach from the town centre - I understand that Leekes are also suffering from a loss of business at the moment. Never the less, the location is a big vote of confidence in the store and travel corridor - this is very much an out of town store so significant for travellers. See here and here
They've got a lot of tricks, but not yet got all the tricks right. I popped in yesterday to pick up a menu (that we we could have chosen at home or at the hotel and then one of us driven in to pick up), but they had none. And when I went to their online store location, the nearest it gave me was 12 miles away in Bath ... you may say "But Graham, it's early days". I agree - but it's in the early days that people need to learn about things like opening hours and menus ....
Pictures taken with permission of a staff member ... my intent was to have the menu boards in a form that could be read, but I shook the camera. Oh well.
Posted by gje at 06:28 AM | Comments (0)
Related topics: via article database
September 01, 2007
Oliver says ....
Oliver Says ... "Please sir, I want some more"
Saturday morning ... three rooms, 5 guests, and a much more relaxed breakfast service than the more rushed one during the week. And I do like those mornings where the fresh croissants - cooked just before the guests come in run out and we cook a further batch. Oliver Twist got into trouble for looking for additional food - but here we encourage it. It's a great feeling to have a lot of food eaten.
Posted by gje at 08:53 AM | Comments (0)
Related topics: via article database










