« November 2007 | Main | January 2008 »

December 31, 2007

Software to record day to day events and keep an action list

Well House Consultants is a diverse company with a small team - operating a hotel and training centre and presenting courses there too - and a such we have a need for efficient communications between us.

"Thank goodness for email" is a cry often heard, with messages being passed back and forth between our two offices that way, and everyone checking their inbox each morning. But email can be over-used; there's a temptation to stop what you're doing to read an incoming email that may be no more that a note of something that needs attention in due course or should be added to a database. And emails to "all" can end up with us virtually spamming ourselves at times.

So as from 1st January, we're going to be using a new online Incident Book. Available to all staff members, entries can be made from any of our systems through a browser, with a note of which member of staff is asked to take actions. Records can be sorted in various ways, updated, selected, and outstanding emails emailed through to each of us on a regular basis. I really liked Chris's idea of a book like this when he joined us - but a physical book that was located close to some staff members but half a mile from the other's didn't work out! Now I can log equipment issues when I'm on site if I need to!


The main display (as seen by staff) of the incident book

The Incident book software is based on my four layer model template that I talked about a few days ago (link) and has a facility for public records - so you can see a demonstration of the facilities via the front page even if you're not a staff member. Help pages are available too - here for the help on the main navigation and data entry page and here for an overview and login details.


The public view of the incident book

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

More about Graham Ellis of Well House Consultants

December 30, 2007

Pictures of December

Some December '07 pictures ... the tail end of the year and it's amazing what the modern digital cameras and photoshop can do with limited light ...

Each image is clickable to enlarge it in a separate window.

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

New trainee laptop fleet for our Open Source courses

"The average age of our fleet is less than 3 years" - so said EasyJet when we flew with them earlier this month. In our business model too we keep our equipment right up to date - our training centre and business hotel was completely refitted less than 18 months ago, and we have just replaced our entire fleet of trainee laptops ...


... if you come on a course with us during January 2008, your machine will be less that a month old!

The new systems came with Windows Vista, and we'll be leaving that on them all and available for delegates who want to use a Microsoft operating system. We're also installing the latest Cygwin there so that all the Gnu utilities (such as C Compilers!) are available for Windows users during courses. And we're making them dual bootable to Linux too ...

What version(s) of software should we be using for our 2008 courses? We're downloading fresh versions and installing them over this slightly quieter few days, going with the latest stable or release candidate versions - nothing too old, and nothing that's Alpha or Beta release or "bleeding edge". So that means:
Perl 5.10.0, Python 2.5.1, Tcl 8.5.0, Java JDK SE6, httpd 2.2.6, Tomcat 6.0.14, MySQL 5.1.22 with connector-J 5.1.1, PHP 5.2.5, Gcc 3.4.4, Ruby 1.8.6, Cygwin 1.5.24.

Not everyone will be running such recent versions on their work systems, of course, and we'll be happy for people to experiment with Apache httpd 2.0 (for example) if they need to learn how to build jk connectors (Easy under 2.2 - provided with the distribution!) and we'll retain some other heritage versions too such as PHP 4.4 to allow people to check script compatibility. And I think I have a Python 2.2 somewhere ;-)

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

December 28, 2007

Efficient PHP applications - framework and example

There are many elements to your on line application - there's the "look" (1), the "feel" (2), the algorithms behind it (3), and the way the whole thing is bolted together (4).

1. The look may be shared across all the pages of your web site.

2. The feel you choose to use may be shared across all your online applications, perhaps numerous web sites, but not be applicable to "flat" pages.

3. The algorithms are likely to be shared by a selection of applications, some of which may run in a batch (crontab) type environment that don't share the look and feel.

4. The controlling logic that ties the whole application together will be unique, but will aways be based on the following steps as it moves from one page to the next:
• read in any "session" or "shopping cart" information
• read and validate form fields from the form JUST COMPLETED and in the process work out which page is to be displayed next
• perform any general calculation and logging tasks needed for each page processed
• prepare for the next page / form that's to be displayed
• save away and shopping cart / session data that's to be retained
• send out the next page.

A couple of years ago, I had the pleasure of spending a little time listening to Rasmus Lerdorf - the author of PHP - as he gave an advanced tutorial session; he was talking of a similar 4 layer model to my description at the beginning of this piece, and I have used similar for numerous applications since - indeed I have my own standard "feel" file that's used pretty much all over the place. It's wonderful in that I can employ techniques such as sticky fields, and do all my handling of characters such as &, <, ", ' and > in a single place which has been fully tested and should be fairly bullet proof.

I awoke early on Christmas morn. Perhaps you did too? The sound of reindeer in the distance as Santa rode past from one good child's house to the next? No - it was the rain against the window and a feeling that I really ought to provide a good, updated example of the four layer model. And I got the inspiration!

The Top Layer - in which the whole is tied together - is a PHP file in which you can see all the steps laid down can be seen (source code) here. This is element "4" in my description.

The Business Logic - also in PHP contains the meat of the calculations and application-specific validation. In a demonstration, there's very little to this, but you can see the code here - element 3 in my description.

The Web Helpers - again in PHP - are the functions that provide form support, sticky fields, secure handling of nasty characters - element 2 in my description and available for my demonstration here in source code.

The Feel of the page - written in HTML, but with Javascript, CSS and other bits too - is the final element. It's in the form of a template where I have used placeholders of the form '%[[:alnum:]]%' [Regular expression] to signify where the template is to be completed by the web helpers, using results generated by the business logic in an order controlled by the top layer. See the template here.

I have that code running on our web site - link here - so that you can see how it works.

But this code is - just a demonstration; the power comes in the re-use of the formula. Come the 26th, I was testing a new incident book system for our internal use for reporting anything from scuff marks that need repainting, to making notes of special dietary requirements or letting everyone know that we're running out of Moroccan Chicken. Really was written rather quickly. And you're welcome to look through the public records too ... see a practical (in terms of use) and practical (in terms or writing speed) and practical (in terms of maintainability) system too. Perhaps I should wait until later in the year to show you a secure booking system? I know I've only got a couple of days, but that's plenty isn't it?

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


Useful link: PHP training

December 27, 2007

Does anyone understand Lithuanian?

After yesterday when I found mountains and molehills from Wiltshire supporting a right wing USA political website, I added a few lines into my image scripts and they're all coming out of the woodwork! I think this page is an artistic / critical review - in Lithuanian - of one of my pictures. Does anyone understand Lithuanian? Translations gratefully received!

Here are some of the pictures that I have found in some surprising places. In a way I'm flattered!

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

December 26, 2007

Copyright and theft of images, bandwidth and members.

Some poor home school kid in the USA just got the sharp end of my tongue .. I had just signed up to a political forum and so had he (he said) and he wrote:

Also I was wondering if you would join my political forum at http://www.xxx.org .(I know this is an advert but it's really hard to get a new board going, and) it's new, and is actually for a senior year homeschool project ... I'm afraid I take a dim view of anyone attempting to steal members in this way. But it's no big deal and I'm more amused that upset.

But there's an irony. Why on earth did I sign up to the Conservative Forum in the first place? Because I found it in a Google search when looking for something on my own site - and I was taken there by one of my own images in use there.

I recognise Silbury Hill. The guy who used the image is a moderator who hadn't even bothered to seek permission, or to copy the file onto his own site - so I'm paying for bandwidth as people view his pages.

I had a theory. By using a MySQL database to hold images and a PHP script to access them, I could add a degree of control to who views my images - a grand theory, but one I have never put to the test; this sort of thing goes on all the time after all. But this is a cheeky violation by someone who should know better. Well ... I've tested it now. The following lines appear in my image script:

if (eregi("conservativesforum",$_SERVER[HTTP_REFERER])) {
  $error = 1;
  $msgs = array("Image STOLEN","From www.wellho.net");
  }

And all the images look fine when viewed from almost anywhere ... but that site on the conservative web site looks like this:

You think I lack charity at Christmas? Perhaps I do, but I really don't see why I should put up with attempted theft of my membership, theft of my copyright material, and theft of my bandwidth. And perhaps I am making a mountain out of a molehill. But I would like to thank both the people involved for giving me an excellent tale to tell today!

Edit to add I seem to have hit a raw nerve - one measure of apology, three measures of vitriol, and I have been banned from the Conservative Forum ... oops! It seems they're having trouble with a troll and don't believe that I found their site by searching for my own domain name. They think I'm actually the troll! I can't see the logic in that when they started the whole thing by nicking my image!

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

December 25, 2007

A christmas message

Happy Christmas everyone!

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

December 24, 2007

What have hotels and bananas got in common?

They don't stop for Christmas! ... The bananas go on ripening, and we have breakfasts and checkins to do tomorrow!

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

December 23, 2007

A story about benchmarking PHP

I've noticed recently that the response speed of this website hasn't been as brisk as I would have liked, and thought that the cause was a steady growth in the amount of code we run behind the scenes on each page - elements I particularly felt were culprits were identifying visitors to a country by their IP addresses, and the background booking system which I hope will be live within the next few months. Plans for these next few days included a couple of hours to look at each of these areas of concern and see if I could save a few cycles here and there, add in some caches, etc.

But then I have noticed that the occasional page that wasn't going through these areas was also running a little slower, and I started to investigate. The host we're using is a shared server and I have shell login ... and a few uses of the uptime command convinced me that all was not as it should be; there seemed always to be more work that the c.p.u. could handle, and a similar test run on an identical machine on which I look after another site did not show similar overloading. So perhaps something to have a word with my ISP about?

This is one of those cautionary Christmas tales!. One last check before I wrote an "oy - what's going on" type email to the ISP ... I added in a series of 30 calls to PHP's microtime function splattered throughout a sample page, saved them in an array and dumped them out at the end of the page (I don't expect anyone but me saw them - I can't imagine that may people will be looking for the printable form of the Tk course description this morning! And what did I find? That the elements I has suspected were only taking a few milliseconds; the real culprit was a MySQL database enquiry that searched 3 million records on a non-indexed field!. Solution - short term - clean up that table that, frankly, has a lot of old crud in it. Then add an index!!

And a 2 reminder lessons - firstly not to make assumptions, and secondly of just how useful a relatively crude tool like microtime can be!

You can click on that tk course link above if you like - it'll reveal out stats at the bottom. But you shouldn't see a jump of 5 seconds between stages 15 and 16 like I did this morning!


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


Useful link: PHP training

December 22, 2007

The Christmas Letter

It's become fashionable at this time of year in certain circles to write a newsletter to tell all those people with whom you remain in touch only at Christmas what's been happening with you and your family all year. I confess that I'm reminded of the film "as good as it gets" with some of these letters, where the waitress writes a "Thank you" letter so long - so many, many pages long - that the generous if quirky gent who has nobly (yet also selfishly) paid for a doctor to see her boy gets more than a little embarrassed. So let me keep it short, even if I use typical section headings for this sort of thing.

The Intro

Lisa and I have been running "Well House Manor" - the hotel associated with our training courses - for a year now. A steep learning curve on many fronts, but we feel we have learned and we welcome friends and family to visit us here.

The Family

Son Tyler (living in USA) got married to Alyssa in May and brought her across to meet us during a brief honeymoon the following week. Son Chris (living near Bristol), joined us as our general manager at Well House Manor in the Autumn and is having a huge and positive effect here. His wife Delene is an amazing person, but is going through a number of very serious medical issues which is very trying indeed on both of them. Daughter Kimberly (living close by in Melksham) lives with Tom, works happily in a preschool nursery, and has started day release to further qualifications.

Graham's Dad, living in Devizes, remains very active indeed of mind and body; a cataract operation just last week meant that I saw my dad for the first time in my life without bottle-bottom glasses just these last few days, and a milky opaqueness has been lifted from his sight and put a spring back in his step (mind you, that spring was never gone). We saw Lisa's Mum, in Virginia, her retirement "pad", in August. She's been through some medical stuff too, but we had a very bouncy family day with Lisa and her three siblings.

The Year and holidays

Helsinki for a course (with time for a brief look around) early in the year. Soon after Easter - a week (a course again for me) in the beautiful Belgian town of Brugge. That whirlwind week with Tyler and Alyssa in May. A week in the USA (Washington and New York State, where I gave a short course) in August. And a few days at the beginning of this month in Ljubljana, Slovenia.

The Christmas plans

Christmases past have been a whirlwind of travel. But this year, we'll be notably at home; with "children" no longer being children / family situations enforcing holidays at peak summer or peak winter times, we can stay around Melksham - and after a hectic year that suits us just fine. A simple Christmas dinner - probably just a handful of us - but seeing family and friends over the period.

Looking forward

2007 has been a year of stabilizing our major project of "Well House Manor" - having got the place refurbished at the tail of 2006, we've turned it into a fully functional and running training center and general business hotel this year. For 2008, I think the key target is "consolidation" - dealing with many of those little things that make up the long tail of the project, and quietly running a superb hotel and a great set of courses. Lisa and I are also looking for some more time for ourselves; we can't go on at the pace we have been doing, and with excellent staff now on board and fully "in tune" to run the place, that plan isn't beyond possibility. Knowing us, I don't imagine we would actually be out of touch for more than a day or two anyways!

Have you ever been on holiday and said to those people who you get on with really well that they must look you up when you're back home? You know it won't happen as they live in Ripon and you live in Abercrave? Well - we say to all our friends (and our business acquaintances become our friends too in our businesses) "Please DO look us up when you're in the area - or why not have a weekend away in Wiltshire and stay with us" and we mean it!

Something extra

I started talking about the typical Christmas letter. Well - I'm now going to add something that is NOT. I've talked about family - siblings, offspring and parents, but only in passing about Lisa. I couldn't do what I do without her - not only in business, but also in personal life - things which aren't "Well House" concerned or related. It's been a tough year for her - the pressures of what we have taken on effect us all differently, and it has "shown" on all of us. But I am delighted to report - just very recently - that the pressures have turned around, are easing rather than building, and very quickly like the first flowers of spring I'm seeing fresh shoots of joie-de-vivre in Lisa, and it gladdens my heart. And I have no doubt that the Christmas period, with a chance for so many things that we've been too busy to countenance these last months, will lead to a further blossoming in an early Spring. I'm not a good one for soppy words, especially publicly expressed ... so perhaps I'll leave this extra at just a short indication of something and someone special.

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

December 21, 2007

Next course - 7th January 2008, Regular Expressions

Yesterday afternoon ... I finished my training for 2007, and I'm now looking forward to two weeks of days with a different metric. Don't get me wrong - I utterly enjoy the training but all sorts of things have been stacking up to attend to including personal time. So it's not "quiet" but rather "different".

In past years I've suggested that this diary will reduce in frequency over the festive period, but that's not happened - so no such suggestion this year. Truth be told, I find more interesting technical facts to point out, more things to report, and I could double rather than halve.

Oh - I talked about the next course in mys subject line. Guess I should provide a link here to it, and to the Java Bootcamp that follows it.

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

December 20, 2007

FSB leaves its members feeling like mushrooms

"I feel like I've been treated like a mushroom - kept in the dark and fed a load of sh*t". So said one of the members at the start of Tuesday's already delayed AGM of the North and West Wilts Branch of the Federation of Small Businesses.

I can totally understand those feelings - for the members, in what is claimed to be a member led organisation, had just learned that their branch chairman had been suspended since June and remains suspended. And that's based on unproven allegations of actions that would be totally out of character that we all find very hard to believe. Some of us have known some elements of what has been going on, but as the branch committee is no longer allowed access to its members records "because it would be illegal under the data protection act" it's been impractical for them to tell everyone - and official requests to HQ for information for members have been stonewalled (although apparently it's NOT illegal for them to have member lists).

The members present were all the more shocked to learn that the regional committee - the next level up - is completely suspended too. That there was no timescale for the clearing up of these matters. That it appeared that proper procedures had not been followed in dealing with these matters. That the other person involved in the allegations continues in her job, even though she is a newcomer with an unproven record in contrast to our chairman is a long standing member with an unblemished prior record.

Points of order were called, and the meeting unanimously voted for an Extraordinary general meeting to be held as soon as possible, to which one of the FSB chiefs is to be invited to explain the situation. He has been recommended to bring his lawyer. And the AGM was suspended. After all, it would have been crazy for us all to vote for a new chairman, choosing between the incumbent for whom we have great respect but would be suspended straight away, a newcomer to the area who I had not met until yesterday, and another member who has been absent from FSB branch activity for years ... and we don't know what their agendas would be. Hopefully all will be sorted before the delayed AGM, and we'll no longer all feel like mushrooms, but the first flowers of spring and look forward to a properly running FSB branch.

As you can imagine, a very interesting meeting.

Credit where credit is due. I have to admire the gentleman from Liverpool (Norman) who came down to chair the meeting for his fortitude, calmness and strength of character in what must have been a difficult position for him. He is not one of the key players behind the farce I described in my first two paragraphs; he described himself as a member of the FSB like the rest of us, although he gives over quite a bit of his time to the organisation "to the detriment of my own business at times".

I don't have the luxury of having the time to be involved to the extent that Marion or Norman or many other good people are - and at times I feel like a mushroom too. I wasn't standing for re-election to the branch committee on Tuesday and was looking forward to being off the case that has wasted so much time for no good of the members. However, it looks like I'm still on there with the AGM aborted at least for another week or two. This one has run and run - watch for the next merry installment!

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

December 19, 2007

Some new C programming examples - files, structs, unions etc

A series of new "C" examples have been added to the web site - a course for a small group allowed me to go somewhat away from the more normal run yesterday and write some new illustrations in front of them.

Call by value v call by pointer comparison: link

Using extern to share a variable between two different sources: link and link

Handling command line parameters through pointers: link

Structures, and pointers to structures: link and link

Unions, where memory is shared between variables: link

File handling through open and read, fopen and fgets compared: link and link

And some C++ examples:

Fomatting floating point numbers in C++: link

Using a vector (in effect an object that's an array but can be extended as required: link

All examples have comments and sample outputs included and will open in a new window if you click on the links. All simple examples, and they're often the best!

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

December 18, 2007

Decisions - small ones, or big ones?

When you're traveling, you'll sometimes come to a point at which you make a decision - to go one way or to go another. Sometimes the decision is a small one - for example, if I'm driving through Marlborough there's a choice of the town centre or the road around the back; whichever I take, they come back together again very quickly. And at other times the decision is much bigger - we decided to fly on our recent trip to Slovenia, and once that decision was made and we started to act on it, the whole course of our time from Sunday lunchtime through to the following Friday evening was mapped out as alternative "B" rather than "A".

All the programming languages that we teach have conditional statements - if statements, or commands - and there's a requirement in every language to define the start and end of the conditional code - where the two tracks merge again, as well as where they separate. There are a variety of ways of doing this - using insets (Python), using an endif, if or do, done pair (Shell programming) but perhaps the most common is to use curly braces. That applies in PHP and in C (today's example) and - slightly varied - in Perl and Tcl.

#include <stdio.h>
  
int main() {
  int dayslong;
  printf("How long is the course ");
  scanf("%d",&dayslong);
  
  /* Condition applies only to first printf */
  if (dayslong < 5)
    printf ("Less than a week\n");
    printf ("No weekend activities\n");
  printf ("First Job done\n");
  
  /* Condition applies to TWO printf-s */
  if (dayslong < 5) {
    printf ("Less than a week\n");
    printf ("No weekend activities\n"); }
  printf ("Second Job done\n");
}

In the first section, no curly braces are used and so the condition applies ONLY to the first printf, but in the second section with curly braces, the condition applies to the first and second printfs.

Let's run that ...

How long is the course 7
No weekend activities
First Job done
Second Job done
[trainee@daisy cd07]$ ./cb
How long is the course 4
Less than a week
No weekend activities
First Job done
Less than a week
No weekend activities
Second Job done
[trainee@daisy cd07]$

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

December 17, 2007

Shopping for Christmas and looking forward

It's mid December and we're back from a record shopping session at Tesco. Life has been just so busy of late that we haven't had the time to do replenish our supplies of tins and packets and the meals we've been having have been more weird, more wonderful, and more eaten-out or take-away than I care to think over recent weeks. So what started off as one trolley became two when I nipped out for a second one, and we commandeered a third one to help with the goods once scanned and bagged. Have you noticed how goods seem to start filling a trolley, then not go back in once you're past the till, and expand even further when they get in sight of your freezer at home?

"Shopping for Christmas?" asks the young gentleman on the checkout as we banter with him, dropping a large tub of finest Brandy Sauce onto the floor, to burst and spread all over the corridor through which customers pass to leave the store. Yes, and no. I'm sure that we won't be doing another major shop of this sort until 2007 has become 2008, until the days are getting longer again.

It's been feeling a little Christmas like for weeks already this year - that's most unusual for us as we seem to work up until the last minute then with a final flourish finish the last course, say "Goodbye" to the last customer and head off to our own world. But this year is going to be different - the lights of the Christmas fayre in Ljubljana the other week were the start ...

Decorations are our closer to home too. In the nearby town of Devizes, the Wadworth Brewery is always tastefully decorated in December and makes a cheering picture on the corner.

And of course Santa comes to town. Here he is - two weeks ago now - traveling to Melksham to turn on the Christmas lights here. There's a certain magic about Santa; we can always rely on him to mysteriously appear, as he did that day in Swindon when one or two of us were starting to get just a little concerned that we had misunderstood his whereabouts for the day.

But it's not really about Santa, is it? It's about the children; see their faces light up as Santa came down the carriage and stopped for a chat with each of them.

Here in Melksham, the lights go on to top all other lighting displays, and the people come from far and wide to see the lights and give generously to the collection for a local charity.

Acquaintances and business colleagues meet up, socially, for perhaps the only time in the year - here's Melksham Chamber of Commerce, last week, at the Three Magpies. "A great time had by all".

And it's our customers too. On Friday, we ate out in Ashers in Melksham amongst the festivities. Another group of wonderful people who we're blessed to have visit us. Not so flamboyant as the Melksham decorated house, but a warmth and an enjoyable course that confirms our "come as a student, leave as a friend"

But the run up to Christmas isn't over yet for this year - quite apart from two more courses (Monday to Thursday) this week, it's going to be a little different for us over Christmas.

We're not shutting out the world. We're not putting the shutters up. Yes, we are celebrating Christmas, partly thanks to that magnificent shopping session that I started this piece telling you about. But also because we're now - literally - "open all hours". We're delighted to have guests with us right over Christmas and Boxing Day - indeed we even have Christmas day checkins - and we'll have family around and welcome our guests too. And - do you know - I'm looking forward to Christmas this year.

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

December 16, 2007

Tcl/Tk - updating your display while tasks are running

Let me make two statements:

1. When you are popping up a new window from your program, the very last thing you want to see happen is for the window to gradually appear, with bits of it being resized as it comes on the screen - not only is such an operation irritating on the eye, but also it's burning up a lot of processor time in working and re-working the display which slows the whole operation down.

2. When you press on a button within a window, you're looking for near-instant feedback - gratification that the button press has indeed been accepted, and if your press starts a longer operation running on the computer, you're also hoping - I'm sure - to receive feedback while the job is happening. Maybe a progress bar, a moving graph, or something like that.

These two requirements are opposites.

In Tcl/Tk, the screen is automatically updated just before the Tcl/Tk application goes into an event wait loop - in other words, the windows will pop up / be updated just prior to the point at which user input is once again accepted. This is very efficient in terms of display (as you would expect from a system that was written years ago, when computers were much less powerful) and usually pleasing on the eye.

On that small proportion of occasions that you want to have your display dynamically updated, you can add an update idletasks command into your Tcl/Tk code at appropriate times. This command causes all queued screen updates to be performed, even if the user is not about to be prompted for further input straight thereafter.

Here's an example of what I mean.

Initial display:

When I click on the "check status" button it runs a ping test three times, at intervals of one second, to test out the connection. If and only if I use update idletasks, the following will be displayed while this ping test is going on:

and when the task has completed, you'll get a full report (in all cases, as the screen is automatically updated prior to being available for further user inputs)

Here's a snippet of code - the proc that's run when the "check status" button is pressed. Full code on our web site here

proc pingit {} {
  global currenthost
  .result config -text "running test ... please wait"
  update idletasks
  # If you comment the previous line out
  # the user is left wondering what is going on!
  catch {exec ping -c 3 $currenthost} result
  # Note the use of catch to recover exec results
  .result config -text $result
  }

You may have guessed that I just completed a public Tk course - inspiration to write up in more details and for "Joe Public" many of the issues that we cover on the course. GUI design - topics like fill and expand, sticky news, canvas scaling and update idletasks are perfect to teach and learn in the classroom, but are very hard to pick up from the books. Our Tk course is always a very effective one and students leave having really gained a huge amount that would be so hard to appreciate fully through self-study!

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


Useful link: Tcl training

Using Tcl/Tk resource files for flexible applications

If you're looking to write a Tcl/Tk application that can be flexibly configured, don't forget to use named resources. Here are two displays from the same program:

So - how did I get the difference in colour and text labels?

1. I drew the buttons WITHOUT ANY TEXT AT ALL, and I did NOT specify a background colour either.

2. I specified an option readfile in my code to bring in a file of resources ... to complete those definitions.

3. I actually created the resource file .... which is simply edited when I want to make changes, but don't want to pay for the expense of getting my program changed!

Here's the resource file - for the Orange, White Hill, Hastings example ...

*top.text: White Hill
*bottom.text: Hastings
*background: Orange

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


Useful link: Tcl training

December 15, 2007

Making a variable dynamically visible in a Tcl/Tk GUI

set bill "and Ben"
label .about -textvariable bill
button .first -text "First" -command {set bill Bradshaw}
button .second -text "Second" -command {set bill Bailey}
button .done -text quit -command exit
pack .about .first .second .done

Tcl/Tk's -textvariable option, on commands like label and button, allows you to have the contents of a variable display within you GUI (Graphic User Interface) ... and simply changing the value in the variable will change your display.

Quick, elegant, easy to program and easy to maintain.

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


Useful link: Tcl training

The Horse goes on and on

The number of blogs that I have seen come, and go .... and yet "The Horse's Mouth" carries on. I don't know how many posts I've made exactly, but it's approaching 1500. Why the difference? I suspect it's because many blogs don't have a long-term purpose and so the blogger starts off with a fit of enthusiasm, but that wanes with time. And add to that ... if it doesn't become a daily habit, then odd days get missed then batches of days and the thing dies.

This blog has not one but multiple reasons that keep me going; it's unlikely to "fold", and at times the main reasons are competing with each other.

• The blog is a way of making technical tips and techniques available to the world - these items are not for regular reading, but for search engines to index and provide a quick route to some hard to find answers

• The blog is to keep in touch with family who may read it from time to time, and with friends. We say "come as a Student, leave as a Friend" on our courses and so the line between technical and non-technical can blurr here

• The blog is a quick route to putting up some more "salesy" material - either for our clients to find and read directly (for hotel or for courses), or at times for standard answers which outselves keep using in emails to customers - a repository of standard paragraphs, if you like.

I try to balance - to post about 50% of my articles non-technical and 50% technical - as a compromise for all my visitors. And when I "err" as I have done in the last week and get all too technical, the knowledge of this helps pull me back in balance. I do have a load more Tcl and Tk examples to post - you'll see them in the next few days - but I also have some non technical subjects I'm just looking for a moment to tell you about. Thank you for reading thus far, and please carry on watching this space!

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

December 14, 2007

Cliff Lift simulator- Lynton to Lynmouth - in Tcl/Tk

In Tk, you can use the variable option to a slider and the textvariable option to a label or button (or some other widgets) to 'project' the value of a variable onto the display - either changing the text on a button, or moving a slider automatically when some value changes otherwise within the code.

Cliff lifts such as the railway that runs up and down the hill between Lynton and Lynmouth on the north coast of Devon work on a counterbalance principle - as one car ascends the hill, a steel cable over a drum at the top lets the other car descend. And the whole lift works by making the car that starts at the top heavier by filling a water tank underneath the floor. That tank is then emptied when the car gets to the bottom.

Here are some Tk sliders ... showing how it works.

With the code that I wrote here, all I need to do is drag one car up or down and the other car moves equally and opposite, using the variable option on the scale command.

Link - Lynton and Lynmouth Cliff Railway

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


Useful link: Tcl training

December 13, 2007

fill and expand on Tcl/Tk pack command

pack .this .that -expand true -fill both

Why are there two different options expand and fill? Are they both needed?

expand causes a widget to expand to fill the space available as a window is stretched, and fill causes a widget to be filled to the cell so that it lines up with other widgets.

In order to show you the difference graphically, I wrote this demonstration program:

button .this -text "this" -command exit
button .that -text "Something unthis" -command exit
 
if {$argv == 1} {
  pack .this .that
  puts stderr "Neither fill nor expand"
  # small buttons in one side of window
} elseif {$argv == 2} {
  pack .this .that -fill both
  puts stderr "No expand but with fill"
  # button widths match
} elseif {$argv == 3} {
  pack .this .that -expand true
  puts stderr "No fill but with expand"
  # buttons distributed through window
} elseif {$argv == 4} {
  pack .this .that -expand true -fill both
  puts stderr "Both fill and expand"
  # buttons expanded to truely fill window
} else {
  puts stderr "Usage: $argv0 \[1|2|3|4\]"
  exit
}

Neither, and just "expand" ...

"fill", and both ...

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


Useful link: Tcl training

December 12, 2007

Curley brackets v double quotes - Tcl, Tk, Expect

In Tcl, both Curley braces and double quotes can be used to hold a block of program or data together as a single unit / parameter ... but there are differences ...

a) Curley braces can stretch over a number of lines, with new lines within the block being simply a part of the block. So they're ideal for defining blocks of code
b) Curley braces can be nested - since there are different open and close characters, blocks within blocks are written easily and naturally, which is quite impractical with double quotes!
c) the biggest difference is that double quoted blocks are evaluated at the time they are encountered by the language parser, but curley braces are deferred until they are (perhaps) evaluated later under the control of the command of which they form a part.

Let's see an example - I've defined two procs with identical code in the body, but one is done with braces and the other with quotes:

set sample 5
 
proc demo {} {global sample; return $sample}
proc omed {} "global sample; return $sample"
 
set sample 27
 
puts "Curley braces - defer substitution until block is run"
puts [demo]
puts "Double quotes - just grouping; substition at definition time"
puts [omed]
 
puts [info body demo]
puts [info body omed]

The first proc - demo - has a DEFERRED block which means that the $sample variable isn't evaluated until the proc is RUN.

The second proc - omed - has an IMMEDIATE block which means that the $sample variable is evaluated as the proc is being DEFINED and the proc always returns "5" ...

The info body command allows you to see the contents of your procs ... not a very common requirement, but wonderful for a demonstration like this one!

Here it is, run ...

Dorothy:dectcl grahamellis$ tclsh t2
Curley braces - defer substitution until block is run
27
Double quotes - just grouping; substition at definition time
5
global sample; return $sample
global sample; return 5
Dorothy:dectcl grahamellis$

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


Useful link: Tcl training

December 11, 2007

Lexical v Arithemetic testing, Bash and Perl

If you tell a story against someone, best to be telling it against yourself!

One of our web servers (running standard, not our own software behind the scenes) has been having a problem with handling denial of service attacks which are coming in from time to time ... and I have a monitoring script running in bash which notices an overloaded system within a short time period, and takes appropriate action. That's done using the uptime command, and was originally written as follows:

buzz=`uptime`
busy=`echo $buzz | sed 's/.*load//' | awk '{print $2}' | tr , " "`
if [[ $busy > 4 ]] ; then

In other words .... get the statistics for the server loading, and if it's had more that 4 jobs in the queue for the last minute on average, take appropriate action.

The script has been running well - tripped occasionally when we've had an attack and had the server back quickly. But this morning I found the server dead and unreachable ... ("Don't Panic" comes to mind!).

Turns out that I have a coding error in my bash - did you notice? I used a > check which tests whether the loading is LEXICALLY greater than 4. Alas - my loadings had jumped in such a way that they were always lexically less than 4, even though they were arithmetically much higher:

06:44:00 up 7 days, 12:16, 1 user, load average: 0.13, 0.54, 0.35
06:45:00 up 7 days, 12:17, 1 user, load average: 1.75, 0.80, 0.45
06:46:05 up 7 days, 12:18, 1 user, load average: 26.47, 7.81, 2.86
06:48:44 up 7 days, 12:21, 1 user, load average: 123.63, 54.70, 21.22

So my trip had never been activated .... and once the loading gets up to that level the system is pretty well screwed!

Solution - change code into ...

buzz=`uptime`
busy=`echo $buzz | sed 's/.*load//' | awk '{print $2}' | tr , " " | tr . 0`
if [[ $busy -gt 4000 ]] ; then

and I now await the next attack to see how it copes. (Shell arithmetic is integer, so we have converted the floating loading!)

This is a tip for users of bash. Note that in Perl, the operators worth the other way around with gt being lexical and > being arithmetic. I'll use that, as I'm predominantly a Perl programmer, as my excuse!

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


Useful link: Perl training

December 10, 2007

stdout v stderr (Tcl, Perl, Shell)

When you're programming, you shouldn't write code to read directly from the keyboard and write to the screen .... what if you want to have your program read from or write to a file sometimes? Instead, you should write code to read from stdin (Tcl) or STDIN (Perl) and write to stdout (Tcl) or STDOUT (Perl). Then you can re-direct from and to file!

But wait .... if you redirect ALL your output to a file, including error messages, you'll find it pretty irritating having to look in a file to see if the program worked. Better to use the alternative stderr (Tcl) or STDERR (Perl) output channel for warnings, errors, and status reports.

Here's a Tcl example of code written that way:

puts -nonewline stderr "Who are you? "
flush stderr
set yername [gets stdin]
 
puts "Hello $yername and welcome"
puts stderr "Job Completed"

And here's an example of that program running:


arth-wind-and-fire:~/dec07 grahamellis$ tclsh tt
Who are you? Graham
Hello Graham and welcome
Job Completed
earth-wind-and-fire:~/dec07 grahamellis$ tclsh tt > xx.txt
Who are you? Graham
Job Completed
earth-wind-and-fire:~/dec07 grahamellis$ cat xx.txt
Hello Graham and welcome
earth-wind-and-fire:~/dec07 grahamellis$

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


Useful links: Perl training, Tcl training

December 09, 2007

Effective Java training - the bootcamp approach

Our public Java courses:
Java Bootcamp- 4 days
Java Programming for the Web - 5 days
Deploying Java Apps under Linux / Unix - 5 days
Apache httpd and Tomcat Deployment - 2 days
Our courses are modular and we have further material - please ask about private courses if you have a group of delegates as we can tailor to your needs


Employers want to get the very best out of their employees' time (which is their money) ... and if an employee is away on a course, it's not only costing one lot of time and money in immediate salary, but a second in terms of having someone else stand in, and a third in terms of course fees ...

Do I sound like I'm selling myself out of a job here, as a course provider? Maybe, but I'm pointing out the considerations that companies like ours should make in order to provide the most effective service to our customers. I'm passionate about training ... I believe that it's a vital part of staff development, and the staff make the company. An investment. And one we ourselves make in our staff - carefully weighing up factors such as whether the course content is appropriate, and whether our delegate will be able to ask extra questions / get specific help if necessary, or will be left to flounder or with issues unresolved. And it's not always easy to know, ahead of time, how a new course supplier will "pan out" with regard to these issues - good, bad, or patchy.

The word bootcamp is flavour of the month at the moment. The free dictionary defines it as:
1. A training camp for military recruits.
2. A correctional facility that uses the training techniques applied to military recruits to teach usually youthful offenders socially acceptable patterns of behavior.
and that worries me a little, as it's slightly off the way the IT industry uses it, so let me try my own definition:
3. A course on which intensive techniques sometime applied to military recruits are used in order to provide the maximum of effective, targeted training in a short period - usually just a few days.
and that definition really suits our courses well ... to the extent that one or two of the most intensive are now described as "bootcamp"s.

Features of our Java Bootcamp include:
* A residential course at our own hotel where you have access to the computers you're working on 24 x 7
* Lessons run from 9 a.m. to 5 p.m., with the tutor available to you from 8 a.m. (or earlier) until 6.30 p.m. (or later) if you have any questions
* Group size typically just 4 or 5 delegates to ensure maximum attention for everyone's requirements
* Course materials include background information and additional optional sections to ensure that the presentation can be tailored to suit the individual group
* Wide range of examples and notes provided to meet everyone's targeted applications.
* "Buddy system" encouraged during practicals, where delegate may work together to resolve issues encountered
* Library of some 600 technical books on hand, together with internet access from the training room, and from delegate's bedrooms too. You can even take the workstation you're using during your course up to your room ...
* After course access to tutor via forum, via email, and via all the examples from the training notes on line for your use.
* Course agenda carefully prepared to include all vital topics that are hard to pick up from a book, but to exclude too much repetitive coverage of elements that you can easily read up on - ("Once you know what Chicken Curry is, and you know what Beef is, you can work out Beef Curry for yourself!")

Our 4 day Java Bootcamp course follows the above philosophy to a tee. For delegates who wish to go into some of the subjects a little deeper (and add in topics such as Applets, Database connectivity, and coding standards) our extended - 5 day - Java Programming for the Web follows the same agenda for the first four days but gives you those extra topics (and a chance to get in some more practice) on the fifth day.

Both the courses run every couple of months (as do our deploying Java applications under Linux and Deploying Apache httpd and Tomcat courses). Click on the links for the individual courses for forthcoming dates.

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


Useful link: Java training

Perl, PHP, Python, Tcl, Linux, MySQL, Ruby courses ...

What's this list got in common (apart from all being countries?)

Belgium
England
Finland
France
Germany
Guernsey
Ireland
Netherlands
Norway
Saudi Arabia
Scotland
Slovenia
Sweden
USA
Wales

They're all countries that I've visited to give training coures over the past few years - five or six of them just this year - and it shows just how globally Open Source software is in use. And you could double the number of countries when you add places from Turkey to Spain, from Italy to Cyprus, from where delegates have come for our courses in Melksham.

OK - so this is an advert in my blog ;-) ... We're getting busy for early 2008 already ... but of you're from one of the countries listed above (or most others!) I'll be delighted to provide training for you in Perl, PHP, Python, Tcl, Linux, MySQL, or Ruby. Bookings confirmed by 31st December are at 2007 prices ... on 1st January, there will be a modest increase in travel expenses due to ever-rising fuel, flight, hotel costs.

P.S. Don't forget Java and Tomcat!

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


Useful links: Python training, Linux training, Perl training, PHP training, Tcl training

December 08, 2007

Python Script - easy examples of lots of basics

Here's a Python script which is pretty imperfect, but shows a whole lot of the basic facilities of the language in use - a sort of "you can do it this way" crib sheet for newcomers. Written during last week's course, with delegates making suggestions as I went along - so if you think the code looks like it was designed by a committee of eleven ....

The overall objective is to read in a web server access log file and report the elepase time in days and hours from the first to the last record .... I will add comments which we did NOT add on the day!


# Bring in regular expression and time handling code from the Python
# distribution which is NOT loaded as standard every time you run an
# individual Pyton program. Use import to keep each in their own
# namespace rather than from which would pollute the top level.
import re
import time
  
# Set up some standards - incoming file name, and the pattern to look
# for when hunting for a date and time stamp in a record
fname = "access_log.xyz"
linematch=re.compile(r'(\d{2})/(\w{3})/(\d{4}):(\d{2}):(\d{2}):')
months=["Jan","Feb","Mar","Apr","May","Jun",
  "Jul","Aug","Sep","Oct","Nov","Dec"]
  
# Read in the whole file and keep the SECOND and last lines only
# Line counts starts at zero, by the way - but in our data file the
# first line is a header record that we want to ignore.
# Enhancement note - do NOT use readlines if the source file is huge
info = open(fname,"r").readlines()
lines = [info[1],info[-1]]
print lines
  
# Define a function that extracts a timestamp using a
# rerular expression, and returns seconds from 1.1.70
def getsecs(matcher,stri):
  dt = matcher.findall(stri)
  elapsed = list(dt[0])
# index saves a loop to look for the number for the month!
# Months grabbed from outside so that different month names
# can be used if you're not working in English!
  elapsed[1] = months.index(elapsed[1])+1
  elt = time.mktime((int(elapsed[2]), int(elapsed[1]),
    int(elapsed[0]), int(elapsed[3]),
    int(elapsed[4]), 0,0,0,0));
  return elt
  
# Bit messy this bit - get elapsed time via a loop
# (I was trying to be too clever with the code!
tato = 0
for sample in lines:
  tat = getsecs(linematch,sample)
  print tat
  tat = tat - tato
  tato = tat
print tat
  
# And get the days and hours ...
el = int(tat)
days = el / (3600*24)
elx = el - days * 3600 * 24
hours = elx / 3600
print days,hours

Running that ...

grahamellis$ python daterange
['seaweed - - [15/Jul/1998:08:32:38 -0400]
"GET / HTTP/1.0" 200 1476\n',
'sealion - - [02/Feb/1999:11:54:03 +0000]
"GET /perlman/READMEs/README.threads HTTP/1.1" 200 10787\n']
900491520.0
917956440.0
17464920.0
202 3
grahamellis$

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


Useful link: Python training

December 07, 2007

All the special characters in HTML ...

There's a wide variety of accented characters used around Europe - and Slovenia this week was no exception! I know I should simply use a standard code chart when I need to find a "special" but it's so much easier to write a couple of loops of PHP!

See here for the source and here to run it

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

10 training days to Christmas.

There are just ten training days left to Christmas ... and I have four courses to give.

Next Monday to Wednesday, I'm running a public Tcl course that's followed by a Tk course on Thursday and Friday. It's a bit late for me to advertise the Tcl (!) but actually our hotel is full so any more places with accommodation would have to be "accommodation elsewhere". We do have a couple of "day places" available though.

And then on 17th and 18th I'm doing a C bootcamp - for experienced programmers who want to learn some C and that leads into a C++ bootcamp - prior knowledge of C assumes - on 19th and 20th.

Yes, I know I said "10 training days" left ... and that's only 9. I have the single day on 21st available if anyone wants it ;-) ... otherwise I'll be using that day to prepare for all the behind-the-scenes we'll be doing in our quiet season which lasts from that point until the second week in January. Except we've already got bookings to start on 4th January ...

The first public courses in the New Year are a Regular Expression Day on 7th January followed by a Java Bootcamp, from Tuesday 8th January.

For those of you who have been following my training trip to Slovenia here on the last week - we got back at a quarter to one this morning. And the courses shown above all run in Melksham, UK and not Ljubljana, Slovenia!


Ljubljana, Town Hall

Melksham, Town Hall

Perhaps not so different as you might imagine!

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

December 06, 2007

Python - input v raw input

If you use input, then the data you type is is interpreted as a [b]Python Expression[/b] which means that you end up with gawd knows what type of object in your target variable, and a heck of a wide range of exceptions that can be generated. So you should NOT use input unless you're putting something in for temporary testing, to be used only by someone who knows a bit about Python expressions.

raw_input always returns a string because, heck, that's what you always type in ... but then you can easily convert it to the specific type you want, and catch the specific exceptions that may occur. Hopefully with that explanation, it's a no-brainer to know which you should use.

Example

ccode = 386
 
first = input("please input something: ")
second = raw_input("please raw_input something: ")
 
print "First was ... ",first
print "Second was ... ",second
 
as_an_int_1 = int(first)
as_an_int_2 = int(second)
 
as_an_int_1 += 7
as_an_int_2 += 9
 
print "integers with addition ... ",as_an_int_1,as_an_int_2

Here's an example of that running ...

Dorothy:dec07 grahamellis$ python ivr
please input something: ccode
please raw_input something: ccode
First was ... 386
Second was ... ccode

And you start getting in to all sorts of issues if you don't realise quickly that one of your variables contains "386" not "ccode" ....

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


Useful link: Python training

December 05, 2007

Christmas fare in Ljubljana

Our last evening in Ljubljana - and we took the bus into town and walked through the Christmas Market - so many colorful pictures yet as it seems in this city it's the people who make it ...

... and on for a meal in the old town - traditional Slovenian Fayre, perhaps?

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

Interactive training, and advancing techniques further

One of the unusual things about the way that I train is that I write examples in front of my classes - I don't just go through cases that have been prepared ahead of time. Not only does that mean that I can show people what they want to see rather that what I have guessed they want to see, but it also illustrates to them how I reach the answer in the first place. And that is important and they, too, will need to know how to reach an answer when their course is completed. Why is my method so unusual? I believe it is because many tutors aren't knowledgeable enough about the subject they are teaching to be able to present it clearly and without hitches on the fly as I do.

You'll notice that I said present it clearly. And that has involved the writing of some code and explaining it, followed by running the code. Delegates want to see both at the same time, so I have got into the habit of leaving a lot of white space above my programs and that way they don't scroll right off the screen as they are being run. But there's always scope for improvement and my thanks go to Blaž on today's Python course for coming up with the suggestion that I might work with two windows side by side.

... thanks ... and blindingly obvious when pointed out to me (but not beforehand). I'll have a careful look when I'm back at base nest week to see if that will work well on the rather smaller projector / screen that we use - but I think it will, or at least can easily be adapted to do so. Lightbulb moment, perhaps - and a step forward again - an ever improving training product.

Link - Python course Well - I had to add an ad after a post like that, didn't I?

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

The wrong way to put up prices

I wouldn't mind 8 pounds for each piece of hold baggage - really I wouldn't - when the base price of the flight is so cheap. EasyJet have come up with a sensible formula there ... except ...

I mightily resent being sent a booking confirmation, specially printed for my flight on 2nd December about a week prior, that tells me that the charge is 5 pounds only to find out at the airport that it went up "several weeks ago" and that Easy Jet were NOT prepared to honor the price of the extra that they had printed even after the price had risen.

I've seen the "Airport" show on TV. I know the "take it or leave it" attitude of the airline even if they are acting (as I think they are in this case) at the very edge of the law. But I decided not to push the matter; I've better things to do with my time than take the airline to task over this failure to honor their offer, I could do without inducing high blood pressure by trying, and besides it makes a darned good story to tell to people for years to come ... how easily Easy Jet have moved themselves right down my choice list, to join British Airways who move right down - gosh - many years ago by a different but equally gross unfairness. These stories last and do companies huge harm. My brother-in-law Phil tells a similar story about a New York Carpet Company that's even older ....

Let this be a reminder to me, to our team in the hospitality business, and to many others that just once careless action can loose many years of goodwill. And remind us also to be careful at all times, and to treat our customers fairly if - as I believe in this case with Easy Jet - we make a mistake.

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

December 04, 2007

A day in Ljubljana

It's Tuesday morning, and I'm in Ljubljana to give a Python training course. Unusually, I traveled out 24 hours early - rather that arriving at something approaching midnight last night after a Monday that was wasted with travel anyway, we (Lisa and I) came out on Sunday and had a look around what is my first even former Yugoslav capital; Lisa may have passed through in her childhood. Impressions?

Very friendly, very modern yet historic too, very well organised and very Western. The incoming airport was an example of what was to come; a very short walk to the immigration line, passed swiftly and into a baggage reception hall where the conveyor was just starting for us. And we had our luggage and were in a taxi (for which we did not have to queue) within a quarter hour of touchdown; within half an hour we were in our hotel room. Which ... is so modern it's too modern, but that's a story for another day. Monday was a chance to look around!

The hotel, about 2 miles out of town, runs a shuttle service 8 times a day to the centre. Nah - we really don't want to wait for that and we want to learn about Slovenia by traveling with the Slovenes. The startled porter at the hotel confirms that, yes, that is a bus stop across the road [[I had drawn this conclusion already because of the number of buses that we saw stopping there to pick up]] and that we can pay when we get on (THAT was my real question). And so we head over and wait for a 6, or 8, or 11, or 21 - all of which seem to run so frequently that there's never more than a couple of minutes to wait. A 10 minutes ride on a "bendy bus", ironically down a dead straight road, and we're in the main shopping area close by the old town.

Bustling. The bus was bustling - a few seats and many standing and indeed we ended up getting out one stop after we intended; stop handling is very fast and efficient as one would expect on a suburban network with mostly-regular travellers. And nearly everyone has some form of season ticket / pass. Ljubljana compares in size to perhaps Reading or Swindon, and such an efficient and frequent bus service there, every few minutes and to all quarters, would one feels cut the overall traffic levels.

Across from the bus stop and shops, some of the more interesting areas of the old town - pedestrian walkways between big old buildings which (surely) must have some history down to the Ljubljana river, with market stalls setting up for an early Christmas. Decorations being hung high with fairy lights and tinsel, and stalls selling cabbage and slaw and mushrooms which are surely there all year starting to mix with some of the clearly more seasonal ones.

The river forms an arc through the old town, and inside the arc is the great mound of the castle hill - surely that's going to be a great viewpoint? Maps show a zigzag path going up there, and we find it between some of the less ostentatious but probably most historic buildings. But - goodness, does it look steep? A cliff lift just around the corner is far more enticing!

Did I comment on "new" and "friendly"? A gent at the cliff left asks if we need help with the ticket machine - help accepted, although we had it just about worked out, and he turns out to be the driver. The single car, with counterbalance running in a track underneath, ascends the hill in a couple of minutes and looks new - indeed it is; the driver tells us that it was only opened last December. Lisa is still clicking away (or rather ... her CAMERA is still clicking away) as we get to the top, and our friend assures us that there's no hurry while she takes a few more shots of the spectacular view. Somehow, I can't imagine our local railed transport supplier holding up services in Bath while the tourists take pictures of the train, can you?

And so ... to the Castle. What a mixture of ancient and modern. I'll let an array of pictures tell you something of the story ...

In one quadrant of the castle, you can climb a high circular town - the climb beyond the climb - for further magnificent views. And have a virtual tour of Ljubljana - 3D glasses, earphones with the English translation. Great to learn something of the history, although I got the feeling that the 3D effects were such a great toy when the system was put together that they were overused, and that the more significant events in the heavily fought over part of Europe were glossed over as if the creators of the show wanted them forgotten. Just a few words about the second world war, when "A huge fence was put around the city and it became an internment camp", and the break away from Yugoslavia was described as "... voted for independence. The Yugoslav army marched in for 10 days ..." and then we went on to the next part of the story as is the army had come for one final alpine holiday before letting the country go happily, peacefully, and with cheery good wishes. I'm sure it was NOT like that, or was it?

By the time we came down from the castle, it was getting towards dusk with some spectacular views of the bowl and the hills beyond, and some lovely lighting in the old town

The obligatory (for me) look at the local public transport system - a quick stop by the railway station - showed what seemed to be underutilised facilities that were lacking the hussle and bustle of the bus system; I think commuter traffic is low. The odd short train came in or out of the eight long platforms while we were there, but they weren't packed. Destination boards showed a proportion - perhaps 25% - of trains as "intercity" and named other European capitals which I would be hard pressed to put on a map.

It was now dark - indeed, pitch black apart from the lights of the city, and we hadn't really eaten since breakfast. How about a bite? But we were out of the city, on the 'burbs side of the station and that 2 mile road to the hotel, and were doubtful as to what was on offer. Signs outside a restaurant in a language so far removed from ours were of minimal help, although the layout and prices gave a positive clus and looking - carefully - the word "biftek" was a hint that perhaps cow meat was on sale, for around 12 Euros a plate.

But this is Slovenia - so it turned out better than we could have hoped. The waiter / barman didn't have a menu in English but explained that we could still get the lunch menu which would be a good deal and we had soup, salad, main course, desert, wine and sparking water for two - and we ended up full - for just 18 euros in total. No wonder that tourists find England so expensive.

[

And so a ride back to the hotel. Stop just across the road from the restaurant, going to right outside the hotel. Less than 5 minute wait, less than 10 minute journey ... and so to the end of a memorable day.

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

December 03, 2007

Right up to the top of the City

Today was a day's holiday - a very rare day's holiday - before I start Python training first thing tomorrow morning, and a chance to see a little of the city of Ljubljana.

Many pictures taken - many of them spectacular, but I need a while to sort through and find a handful of the best that portray the place. But how DO you portray a place which along with its sights and sounds has a friendliness to the visitor which goes in no small part to make it so welcoming. That's deep, and cannot be portrayed in pictures.

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

Connecting to MySQL 5 from PHP on Mac OSX Leopard

What is the difference between "localhost" and "127.0.0.1"? Everything, it seems, when you're trying to connect MySQL (and I have version 5.0.37 Community at the moment) running on Mac OSX - the latest Leopard release - with their PHP release including the MySQL drivers. It's PHP release 5.2.4.

In a nutshell:
mysql_connect("localhost","wellho","nottherealpassword");
FAILS with an error message:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Library/WebServer/live_html/test/test.php on line 2

but:
mysql_connect("127.0.0.1","wellho","nottherealpassword");
works just fine.

Another gem ... to add to the loss of classic mode (serious issue for us FrameMaker users!) and the movement of configuration files. I have to admit this hasn't been the easiest of upgrades, and I wait to see whether I have more issues to find.

If you want to learn all about Apache httpd installation / configuration - and the PHP and MySQL elements too - see our LAMP deployment course. I'm the tutor and the "L" for Linux is close enough to the "M" for Mac OSX for it to be pretty damned close and very effective training. And I can and will show you how it works on my Mac too ;-)

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


Useful link: PHP training

From Sunday to Monday, from Melksham to the Balkans

Subject Drift ... an email entitled "Brakes Requirements" received turns out to be all about virus scans, and a "Twonky Apple" subject line is confirming receipt of our arrival in a former Yugoslavian republic that's now a part of the EU. Other emails in my box this Sunday night / Monday morning urge me to advertise in North Devon (why?), fill me in on the political infighting at the local Federations of Small Businesses where - whatever the rights of wrongs - the focus of neither set of protagonists is on the members who they should be servicing any more. And then we have the "More Train Less Strain" folks in a strop about a 30p per mile train fare that we on the TransWilts line would be very happy to pay for a decent (correct time, reliable) service.

It's been a long day and I'll be posting this just into Monday morning. It's always a dreadfully long drive up to the Cambridge area; today to Stansted, and a 2 hour flight followed by half an hour in a taxi, arriving at a huge modern hotel that seems to be not at its busiest on a Sunday evening. "Free Wireless Internet" is a huge attraction, and of course I'm on line. So is Lisa with another computer, and she's also trying out the technology.

I've clicked off my first few pictures, but to be honest the view out of the room could be - so far - what you would see in any modern European big town.

Tomorrow I'll have a chance to explore. Judging by the several high, floodlit castles that our taxi driver passed on the motorway, we're in the heart of a fascinating country. Watch this space! And see how my subject has drifted from the start of this message - it must be the local beer ...

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

December 02, 2007

What makes our courses special?

It's one thing to provide a training course ... and another to provide an effective training course that the delegate will fondly remember, and the course administrator will book as his first choice for the next student for the same subject. Yesterday evening, I wrote something of our philosophy for a proposal that we're submitting and I'm going to share it here to give you a flavour.

Looking for yesterday's Santa trip - see here in the archive ... this blog moves FAST ;-)

3. The Well House Consultants Philosophy

We aim to provide you with a superior product - we want you to be so happy with what we deliver that you'll automatically think of us first next time!

How do we achieve that? Here are some of the factors.

3.1 We write all our own material. And we update it regularly too - you'll find that courses have small changes made quite often to mention new techniques and software releases, for example. This also means that we are not constrained to any agenda required by an authorisation centre, but rather we can be flexible to your needs.

3.2 All courses are presented by our own staff who are the experts who wrote them. This means that we can answer all on-topic questions as the course proceeds (and many off-topic ones too!) meaning that your delegates leave with everything covered. Where a question is to be "come back to later" we make a note of it so that we really DO cover it later.

3.3 We offer a "no cancellation guarantee". Once you have booked a course and it's confirmed, we will not cancel it - very occasionally, that means that a public course ends up being a private one, but we know that our customers schedule their training in amongst a whole complex mesh of other tasks and really cannot afford to re-arrange at short notice.

3.4 Public courses are limited to a maximum of just 8 delegates to ensure that each delegate gets plenty of the tutor's time and attention during class and practicals - we won't leave your staff behind, nor run so slowly that we waste their time.

3.5 After the course, delegates will find all the examples in the notes on our web site, which they can download if they wish. Our tutor also offers follow us support via a forum or email, at no extra charge within reason.

3.6 We only teach subjects that we enjoy. Quite apart from us being a little selfish in this regard, it means that your delegates will be motivated during the course; where the subject being taught is appropriate, the tutor writes new examples in front of the delegates to illustrate not only a solution, but more importantly how that solution is reached. And with the tutor enjoying the subject, you'll often find him in the classroom from early to late if the delegates wish to ask extended questions.

3.7 Our training centre is also a high quality business hotel. That was, the delegates on our public courses spend time with others learning the same subjects from different organisations - widening the scope for all concerned. And if you take over our hotel for a private course, you'll see excellent team building benefits too.

3.8 Our training room was fitted to our own specification with our own courses in mind. Everything from a quiet environment to large desks, whiteboards that cover the whole wall and lighting for optimum use of projectors has been taken in to account. Good visibility from all seats, tea coffee, soft drinks and water available at all times, etc, help make an easy environment in which to learn.

According to my records, we have trained almost 30 delegates from [organisation name] in the past 2 years, and I would confidently suggest that you ask any of them for confirmation of the above.

Found this page in my blog through a search? Who are we? .... Here's some of the introduction text from the same proposal!

1. Introduction

Well House Consultants write and present technical and programming training courses in a range of niche subjects - mostly "Open Source". Most of the subjects we teach run as regular public courses at of Melksham, Wiltshire training centre. That's about 100 miles to the West of London, 160 miles south of Leeds, and 15 miles east of Bath. We also run private courses for groups of delegates from individual client organisations, and those courses can be run at or near your office, or at our training centre.

Since our subjects are highly specialised ones, many delegates travel a considerable distance to attend and we so our training centre features hotel standard rooms - indeed, it is open as a hotel for visitors to local businesses when we've got rooms that are not required by delegates.

Our training web site is at
http://www.wellho.net
and our hotel site is at
http://www.wellhousemanor.co.uk

2. Subjects Taught

Our current offerings include public courses in Perl, PHP, Python, MySQL, httpd / Tomcat web servers, Tcl, Ruby, Java, C, C++, and Linux. For many of these subjects we offer a range of courses, to suit different levels of delegate and different levels of competence to be achieved.

We can offer ALL of those subjects on private courses too - run in house at your offices, or at our training centre / hotel as appropriate. The following subjects are also available (the list is not exhaustive - please ask): HTML, web page and web site basics. CSS. Shell programming. Introduction to Object Oriented principles and database design. Private courses can be (and usually ARE) tailored to suit the group of delegates to be trained, and we routinely write a small amount of extra material if our customers require an extra course element which is not on our regular catalogue. There is no extra charge for this tailoring.

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

December 01, 2007

Santa on the train to Melksham

Today was the day that the Melksham Railway Development Group ran their Santa Special trip to Swindon. As usual, even a strengthened public train was crowded, but everyone had a great day none the less!

Santa visited all the children on the train - and our party today included 33 children!


Santa Claus appeared mysteriously (as you would expect for Santa) at Swindon station for the quarter past 3 train.

Santa at Westbury ... off home by train from there, I understand, as Rudolph had the day off


Santa got off the train at Melksham as so many children were waiting to see him.


What it's all about ... fun for the children!

Full report and more pictures

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

More PHP sample and demonstration programs

It's amazing how many little (and not so little) new programs and demonstrations I write - here are som from the last couple of days:

• The Melksham / Bowerhill Christmas Quiz, 2007. Ten questions, work out the answers, click on a link at the bottom the page and it will be refreshed to tell you the actual results. Uses a data file of questions - would work equally well for Skegness, St Anne's or Aberdovey!

Try the Quiz, source

• An updated demonstration of joining two images with a "tear" - graphic artist effects via the GD module of PHP on your web page.

See a sample, source

• Sorting an Associate Array - and how User Defined Sorts work in PHP. The business of a callback function is quick a new concept to many of our customers, and this demostration shows how it works ... complete with print statements within the comparator to help explain the algorithm.

See it run, See the source

• Sorting a regular array in PHP - forward, backward, and in a user defined way using a date that's embedded in the line. This demonstration program also shows you how to extract a date and time from a line of data using regular expressions, to convert it to a standard time format (that can be compared, sorted, etc) and then convert it back into a text form that's human or database readable.

Run the demonstration, and look at the sourcecode for it

• There are many ways of looping through a PHP array, and this final example shows many of them compared in the same short program.

Run the program, source

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


Useful link: PHP training