« December 2008 | Main | February 2009 »

January 31, 2009

Learning Python - many new example programs

I ran a public Python course earlier this week ... and (as I usually do!) wrote a number of short examples during the class to show the delegates not only how something is done, but also how the coding process works and how the particular answers are developed. I can't show you that process here on the blog (I can on future Python courses) but I did promise my delegates that I would add some documentation to the code and post it for them ... so here goes ...

Day 1

[source] An answer to the practical exercise in which I ask delegates to come up with a list of 31 1-s, 28 2-s, 31 3-s, etc so that they can look up day number (say) 166 and see which month number it is in. The sample answer uses the power of Python's list handlers and does NOT involve nested loops!

[source] Lots of ways of manipulating a list - setting it with an array-like syntax, inserting elements, using slices and various ways of iterating through it. From some of the food products and mixtures that this demonstration uses, you'll see why I'm the trainer and not the cook.

[source] Single and double quoted strings, triple quoted strings, raw strings and other ways to get \ characters into a string.

[source] Setting up a 3 x 3 matrix (I would normally encapsulate this within a class - my example on day 1 was a simple list of lists)

[source] A program which prints out its own (embedded) documentation. Good programming practise is something I talk about on all the courses that I run, from the first day. However, writing code that is robust, reliable, easy to use and easy to maintain requires a wide range of the facilities that the language offers, so this example tells you that (for example) it is missing input validation.

Day 2

[source] In Python, you can define then redefine a function, and you can even put alternative function definitions within an "if" and its "else". Occasionally, you might even want to do this!

[source] An example that uses a generator to provide just-in-time values from a data source, rather than making up a whole (potentially huge) list first from which they are processed one by one. With a generator, care needs to be taken to ensure that you don't simply end up producing a list within the generator function, and you'll note that I've used xrange rather than range. When we get to Python 3, that will change as range will itself be a generator in this circumstance.

[source] An example of the scoping of variables in function calls, and also of optional parameters. Although you'll want most variables to be local, Python does offer the ability to have globals, and variables within the object and name space of the method too. And read-only references to variables that are unset in a function also cause it to look at the outer scope, which can be convenient if used with care. This example shows an awful lot of things that shouldn't be used a great deal ...

[source] A tiny module! ... and [source] a tiny program that imports code from a module.

[source] This example shows how a list can be passed into a function and have its contents altered within the function. Actually, this is the default behaviour of mutable parameters in Python ...

[source] and [source]. An important demo that shows how a data file can be read, the lines analysed and used to build up a list of objects. The objects are then compared (I wrote methods like elder and eldest) and various analyses are produced. A relly useful step towards a real life, practical program with most of the elements coming together.

[source] How to handle data files that aren't clean - this example uses regular expressions to process a data file which has a mixture of tabs and spaces (and sometimes multiple spaces) between fields.

[source] The example I described a few article ago that translates OSI (Ordnance Survey of Ireland) grid references into East and North measurements across the country. Great example of regular expressions, and it allowed me to show various other things like the command line handler and string to integer conversions.

Day 3

[source] Reading an input from the user, and converting it into an integer. If the user gets the format wrong (types in something silly!) it will flag an error and reprompt. Good use of exceptions within a loop all within a function!

[source] A class of cubic containers, which can be added together to make a larger container (larger x, larger y, sum of the zs). And a test program that works out how big a bag you need if you put a fillet of fish on top of a big mac!

[source] Some time functions!

[source] A GUI example using wxPython (wx was THE GUI that this group wanted!) ... this example being a short but complete example.

And I'll finish with [source] of a team effort - written by delegates, with some of my assistance - to build a complete GUI that let them select the "from" and "to" of a journey. It contains examples of each of the major elements - various widgets / components, placement of them, events, and the use of the event handlers to create and manipulate objects in the 'main' Python code.

Summary

That's a long post to show just how many extra examples I write during a typical course - though it is unusual for me to document most of them in this way (even on this course, there are a few intermediate files that I'm not posting). If you view any of the source codes, you'll see links to other similar examples too on the right of the page.

If you would like me to help you learn Python too, I would be delighted! There's a link to our public course description - with the next dates - here. If you have a group of delegates, we can run a private (tailored) course for you - see here for a course run at our training centre in Melksham, Wiltshire (should you live too far away to commute, you're in good company with many of our delegates - which is why we're also a hotel). And finally, if you've got a group of half a dozen or more, I can come to you and train on site. Let me paste in a couple of links to quotations ... for a Python course in Edinburgh, for Classes in Python in Plymouth and if you would like me to teach Python in Georgia (that's the USA state of Georgia - please email me for the country of Georgia!)

The Images are local Melksham pictures - all taken within about 1km of our training centre.

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


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

Baby Caleb and Fortune City in your web logs?

Our web site logs are getting a lot of requests containing "babycaleb" and "fortunecity" ... looking for URLs such as these:
/resources/ex.php4?item=http://babycaleb.fortunecity.co.uk/picture.htm?
/resources/ex.php4?item=http://64.15.67.17/~artatgig/caleb.htm?

and said to be from an Internet Explorer browser (user agent).

Hmmm ... they look like injection attacks to me, where someone is attempting to include his / her content into our pages. And because the requests come from a lot of different places, there's something viral about the attack - so that when it gets in to somewhere, it's not only feeding whatever the content is via that page if it can, but it's also taking over that machine and using it to attack further machines.

I have not looked all that deep, but I have checked that we're not vulnerable to the attack (save that it's using bandwidth - 12,000 requests out of 140,000 to our server yesterday!) and found some other pages - here and here which are safe to visit and will tell you a little more.

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


Related topics: via article database

UnboundLocalError - Python Message

What does THIS mean?

UnboundLocalError: local variable 'taxrate' referenced before assignment

It means that you have tried to modify the value of a variable - perhaps in a function - before you have given it an initial value:

taxrate = 15
def getnet(gross):
  taxrate /= 100.
  net = gross - gross / (1.0 + taxrate)
  return net
amount = getnet (230)
print amount

The variable taxrate is local to the getnet function ... the way the code is written, there is a DIFFERENT taxrate variable in the calling code.

You could share the variable by declaring it global in the function or - much better - you could use it read only in the function, in which case Python will see it from the outer scope.

So this will work:

taxrate = 15
def getnet(gross):
  net = gross - gross / (1.0 + taxrate/100.0)
  return net
amount = getnet (230)
print amount

And that's also far better because it doesn't alter the variable that contains the tax rate - rather it leaves it available for later use.

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


Related topics: via article database

Useful link: Python training

January 30, 2009

Python - a truly dynamic language

In Python everything is an object - and that includes functions which are objects which contain blocks of code. And this means that you can define different functions of the same name depending on a condition, and you can replace a function with another one too, if you want to.

This really is valid:

ontop = int(raw_input("Enter 1 if summat ontop "))
 
if ontop == 1:
  def tanksize(basedim):
    vlume = basedim * (basedim+1) * (basedim+2)
    return vlume
else:
  def tanksize(basedim):
    vlume = basedim * (basedim+2)
    return vlume
 
for k in range(10):
  more = tanksize(k)
  print "more is ", more
 
def tanksize(basedim):
  vlume = basedim * (basedim+4)
  return vlume
 
for k in range(10):
  more = tanksize(k)
  print "more is now", more

Would you write code like that? Probably not - but you could well write a piece of code that embeds within another application as required, and overrides default (preloaded) code. A number of commercial applications use Python for their tailoring, and this is the mechanism they often use to provide hooks for extra code for the minority of users who want to change certain algorithms.

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


Related topics: via article database

Useful link: Python training

Apache httpd and Apache Tomcat miscellany

When you start a newly installed Apache httpd web server, you may get the following message:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

It's only a warning! It means that the web server software can't work out what the computer is called; it will run as a web server anyway, but when it reports on the name if pages that it is returning to the user it will guess that they are http://127.0.0.0/.... pages. Only in a few circumstances does the browser actually use this returned information, however!


If you see a web page that just says It Works! and nothing else, you have probably got a brand new installation of Apache httpd 2.2.summat; this is the default page for that server. Why doesn't the Apache httpd team provide a nice front page? Well - they use to under 2.0.summat, but I understand that they got so many emails complaining about the web site not being what users expected that they took their name off it.


If you are building a mod_jk connector to add to your Apache httpd (mod_jk allows a Tomcat connection via ajp1.3 protocol), you MUST ensure that you build it to go with exactly the right version of httpd, If you try and install a 2.0.43 version on a 2.0.44 server (as small a difference as that!) you can have problems.

The way to do this is to configure the build as follows:
./configure --prefix=/usr/local/apache2 --with-apxs=/usr/local/apache2/bin/apxs
which uses the apxs utility that was built / loaded with your web server to provide the vital information about buffer sizes, etc, to your jk connector build.


Apache Tomcat does a lot of caching - and it's right that it should, as it's an application container and not a file server. Sometimes that can be a nuisance, and occasionally it can be more than a nuisance - it can be a major headache (if you have stepped back from an upgrade, for example).

In order to clear out work in progress and more recent temporary files from you Apache Tomcat setup, stop your Tomcat and delete the entire tmp and work directories which is where these deep hidden caches are to be found, then restart Tomcat. The first few hits to the web site after this operation may take a little longer as the directories are recreated, but they'll be recreated clean of information which has been removed from elsewhere and had remained only in the cache.


If you stop a web server and callup a page that it should have been serving on your browser "just to check that it really has stopped", you may sometimes be surprised to see the page pop up again.

Could it be that you have failed to stop the server? It could be, but it's far more likely that your browser tried to contact the server, failed, and so displayed a page it had cached locally. Hold the shift key down and reload again ... on most modern browsers, this will force a true reload, and tell you is it fails without giving you any cached versions.


The javap program tells you what symbols are defined in a java class file. And that lets you tell if a class can be run as an applet, a servlet, a stand alone program, or is something else.

[trainee@easterton classes]$ javap Smallest
Compiled from "Smallest.java"
public class Smallest extends javax.servlet.http.HttpServlet{
  public static int counter;
  public Smallest();
  public void doGet(javax.servlet.http.HttpServletRequest,
    javax.servlet.http.HttpServletResponse)
    throws java.io.IOException, javax.servlet.ServletException;
  static {};
}
[trainee@easterton classes]$

This is a Servlet - it extends HttpServlet, and it includes a method called doGet which means that it will respond to "href" links, to having its URL typed in to the command line, and to forms with method="GET". It does not have a POST method, nor specific code to allow it to be initialised or have its data saved when it is flushed out of memory.

There is no main method, so it cannot run as a stand alone program, and since it's a Servlet it can't be an Applet (Java does not allow multiple inheritance which would be needed for a class to double up in this way)


Above notes from today's Deploying Apache httpd and Tomcat course. We also offer a course that covers just Apache httpd if you're wanting to set up a more typical web server rather than being into the Java thing!

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


Related topics: via article database

Service Excellence Awards

First and foremost - my congratulations to Trowbridge Chamber of Commerce in arranging their 2008 service excellence awards, which attracted 60 entrants ... and a guest list of around 300 to Trowbridge Civil Hall last night. And to all fifteen finalists who reached the final stage of the competition, where one winner was selected from the fifteen but - as speaker after speaker keep saying - everyone was a winner.

Customer service is key. We hear it time and time again - you know the "Customer is King" and "Make your customer you ambassador" lines, and I totally agree; it's what we attempt to do. And then there's "go that extra mile". That's important too. For the first half of the evening, we sat though three batches of five videos, introducing each company (the runners) where we saw pictures of them holding sponsor's logos, some spinning artwork to set the scene, and a two minute presentation seated in front of a white backdrop. A little on how the company was formed, who owned it, and what they do, followed by examples of how they "go that extra mile". With fifteen presentations to record and format, there was a lot of work even with such a tightly controlled format and it gave us little chance to see more than a bit of how the selected rabbits from these companies acted when caught in the headlights, and to share with them their embarrassment at having to talk about an example of how they had gone that extra mile. "Bill opened the shop specially", "Claire stopped with Mrs Jones who had had her handbag stolen until the police arrived" ... yes - these ARE the things that should be done, should be commended, but to have the do-er talk about them, in a standard-format video, was so out of character for them as to be awkward.

I found myself wondering "what would I do in their circumstance" and - much more importantly - "could we be up on that stage / on that video?" The answer to the latter is yes, we could. We are a customer service organisation and we should all be going that extra mile not just in special cases but every day. Two days ago - running our delegates up to Chippenham station at the end of their course. Yesterday - nipping out to the postbox to post a letter for an overnight guest, and telling him that if he brings his wife next time we'll show them around. Today - already planned to move the whole course forward an hour so that the delegates can get away early for their long journeys home. But these are not things from which to select a single example and hold up in front on the audience.

"In their circumstance" I also asked. I am doubtful as to whether or not I would have us enter their competition, and very doubtful if I would allow myself to be dragooned into coming up with an example. I might if I were there; I don't know the pressures. But I also know that staff are key and if Chris and Sharon and Sarah wished that we enter, I would back them and give them hearty support. For it's the team that makes the customer experience and customer service, and I'm proud of our team. When the winner had been chosen (via a simulated horse-race - aren't computer graphics marvellous?), further speeches went on to emphasise the team aspect (agreed), and the need for training (agreed); something of a case of shutting the stable door after the horse had bolted (please excuse my continuing with the racing theme) as the people there last night were not the new businesses, nor the ones with crap customer service, to whom this message should really be delivered.

The question is asked "how and if should Melksham Chamber of Commerce be involved next year" and no doubt my opinion will be sought. The obvious first - we should encourage local service excellence in the town. We should put our name and effort to that encouragement. Whether we do so via a judged competition such as the Trowbridge one, followed by a major presentation evening, I'm a little more ambivalent about. For sure, it should get the press attention for a "good news story". Perhaps my problem with the evening was that I was driving ... and I wasn't quaffing away at the wine as those all around me were ... perhaps I'm just an old stick in the mud.

It's 06:30, and I'm about to post. Sharon has been at "The Manor" doing at event breakfast for the last hour, and I want to get over there very soon. I know that one of our regulars has been going through some quite dramatic times for the last ten days and at the least I want to say "hi" and give him the sort of welcome I would want myself in the circumstances.

My congratulations to The Tale of Spice - the Indian Restaurant in the heart of Trowbridge, who won the competition. Something about their presentation, and knowing something of their culture, led me to guess that they would do very well. I've never been in to the "Tale of Spice" but after last night I'm sure that I'll go in there one day (and not wearing those Chamber of Commerce gold chains that make me rather stand out - but rather as Joe Public) and have a great experience - I look forward to it

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


Related topics: via article database

January 29, 2009

First Class

We're not going to be second in what we provide or what we do!

Last week, I was critical of another local hotel for hiring out their main restaurant for an event, kicking their residents into a side room which was below the usual quality of the place. I have been such a resident (not there, but elsewhere) and I didn't like it - neither did my fellow residents like it - so it's something we won't do. We provide first class service - Policy!

In my email from yesterday, I've been offered an explanation of why the County Council has cancelled a reservation they had with us for an event next month: "We were contacted by a Council owned venue this morning with a cancellation on 25th February and in line with our policy, we have to whenever possible arrange meetings at these venues." The lady writing did go on to say that there was nothing at all wrong with our product :-/ . Now this is an "interesting one" - one part of me applauds the local authority for looking to save money by using the facilities they own, and the other part of me despises them for making bookings for what is clearly their second choice (policy wise) of venue, just to let down - time and again - the businesses who run those venues. You may guess, it's not the first time they have done this. So ... we provide a first choice service - Policy - and we will not take "just in case" bookings.

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


Related topics: via article database

wxPython - Introduction and sample

Python has a number of GUIs ... and these days wxPython is the most popular. As one of the latter sessions of yesterday's Python Programming Course, I introduced the GUI and talked a little about how it's programmed, and the delegates put together a short sample application.

wxPython uses Python. So you need to know some Python. Then you import wx ... and write your application:

• Write a class (extending one of the ones that comes with wx) to define your components (widgets), how those components are laid out (geometry) and what to do when someone presses a button or drags the mouse (events).

• Create an object of that class, and put it in a frame

• Show the frame (important this one - otherwise you won't see your work)

• Call a main application loop method which waits for events and handles them. All the action of you code will take place within the event handler routines, and other code that those event handlers call - you won't call the functionality directly.

• That's the end of your code. The main loop never returns as you (should) have some sort of application exit within it, programmed onto a quit button.

Here's a sample display:

And the source code is here

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


Related topics: via article database

Useful link: Python training

The Wiltshire Police

How much do the police cost? Where / on what is that money spend? Who pays?

What do they cost?

Questions I had never asked myself until last night when I went along to the Wiltshire Police Authority's "Budget Consultation" with the county's Chambers of Commerce. Clearly a fascinating subject as some 15 members attended out of thousands of members of The Chambers, but at least I can get back to Melksham Chamber and report.

Next year, the Wiltshire Police force will spend 105 million pounds. That's sold to us as 152.59 on each Council Tax band D property, but in fact the council tax money only accounts for 36% of their income - the rest is from central government who are funded by (wait for it!) the taxpayer / population of this country too. So I could also tell you that the equivalent including money passed back from Central Government is 423.86 for each Council Tax band D property, or about 180 pounds for every man, woman and child in the county.

The budget has grown by 3.6% from the 2008/2009 year, with broadly the same expenditure plans. "Unavoidable" increases accounting for 4.1 million - things like pay and general inflation; there is in my view an element of double-speak here as the police force is now up to its full allowed strength for the first time in five years, and had they chosen not to fill all the vacancies, their salary bill would have been lower. However, that's a whole other question, and as I listened to Chief Constable Brian Moore and his team talk about how an officer making an arrest for a small issue at the start of his shift can be 'processing' for the rest of his 8 hours (or pass across to a less well paid civilian to process, taking the same time), I came to understand that there's a lot of the cost which is the cost of bureaucracy. And that only a proportion of that is within the remit and control of the local force - much is forced on by law and government.

Where is it spent?

91 million pounds out of 105 million will be spent on staff. That's 62 million on 1226 police officers - just over 50,000 per officer - and 29 million on around 1100 civilian staff, or 26,500 each. Just under a half of the remainder goes on premises, with IT and vehicles being mentioned as significant "other" elements. 10 million of the 62 million on officers goes back to the government to fund officer's pensions (a money-go-round?) and 15% of the 29 million (4.3 million) goes to the civilian pension scheme which is run with other local governmental bodies such as Wiltshire (county) Council.

Premises include 24 police stations, but few have their front desks manned. "Little point in having someone there for just half a dozen visitors a day" say The Chief, mentioning that only a few larger stations such as Melksham (!) get significant numbers. "Haven't they heard of multitasking - doing other work and breaking from it to answer an enquiry?" muttered another member of the audience and - I confess - that's a good point and something we do at the Hotel; I suspect that the police do, but the "we can't afford to spend your money having someone waiting for enquiries" is a good sound bite, isn't it?

With such a lot of money going on manpower, where is that manpower deployed? Brian Moore told us that some 85 to 90% goes on the policing we see around. The rest goes on a wide variety of other areas such as keeping tabs on organised crime, background work in tracking of prostitutes to and via Wiltshire, drug work (drugs come into the county via Bristol and London, and to some extent Birmingham), counter terrorism work and internet policing, where apparently we have a local team who may end up catching someone in another country. And we have a kidnap team too, as ransom demands from some of the world's hotspots can arrive at family's homes in Wiltshire ...

As I understand it, Special Constables are unpaid officers who police in their spare time, so should be a lower cost option for certain roles. Although paid officers are currently up to the allowed strength of 1226, there are under 100 specials out of an allowed 300. The Chief Constable, new in the job just a year ago and selling a number of significant changes, wants to get 'up to strength' on this, and feels that the specials are a good resource who have been poorly treated in the past. He talked, for example, of giving them a good choice of roles - "if they want to be in the thick of sorting out a pub brawl ... let them". Hmmm - there's a danger of attracting the wrong sort there, me thinks - but I'm sure he's aware.

Although the evening was sold as a budget consultation, there was no talk (and I hadn't expected it) that overtly related to taking our inputs and recording them with a view to making any spending or policing decisions. It was much more a meeting to tell us, and to answer questions on what is pretty close to fixed in stone. There's a Police Authority meeting in Devizes on 5th February at which the budget will be voted on (and no doubt approved); it will be open to the public, but I can't imagine the funding allocations being changed that evening in response to public input.

And on to other matters

There's more that pure finance when it comes to policing - the money is just the means to the end. There was talk of 'boy racers' in the Tesco car park across the way from where we were, and the police powers to seize and crush vehicles ("very effective"). There was talk of the technology that's around the area (I'll spare you the detail) which means that the police know what's going on without being there. 25 years after George Orwell's 1984, we should not be surprised.

As a county that borders many others (and other force areas), the question of mergers, and also of sharing resources for the sake of efficiency, were raised. Mergers suggested by the government a couple of years back won't be happening - now or in the near future - but changes to the law to require forces to work much closer together have come into effect. Changes are painfully slow, we were told, as each force has its own local ways that it wants to protect. But (for example) I can't help but think that some pooling is a good idea; an "Internet team" in Trowbridge, one in Exeter, one in Gloucester, when catching people downloading in the USA (the quoted example) or Japan seems a needless localisation.

The Police Helicopter and Wiltshire Air Ambulance - funded 75% by the police and 25% by local donations - has been renewed for a further five years (1 million pounds per annum); much of its value comes in the form of police relations and publicity and - like having bobbies on the beat at the car park - isn't necessarily the most efficient use of money, but indirectly brings huge rewards in terms of the critical relationship between the police and the community.

Chief Superintendent John Kirby, responsible for the division that includes Trowbridge, spoke of the enhanced neighbourhood policy to help with this community relationship. Although there has been a neighbourhood policing policy in place, it has lacked (in places) a dedicated sergeant to provide management support, and local officers have all too often been seconded elsewhere or have not been replaced when away. There's now an 80% beat pledge, a pledge to replace officers who are away for 28 days or more, and a pledge to have all areas supervised by a dedicated more senior officer rather than one who's main task and mind set is answering 999 calls.

Wiltshire is a safe county. At least that's my conception and that of most of us in the area. Reported crimes are around 30k per annum, and this is down 10% this year. The decrease was sold to us as being a good thing, so I assume that there's no evidence that reported crime hasn't dropped just because people know things they report won't get followed up, or there's no-one at the police station to whom to report them. Last year, before the new Chief Constable arrived, some 21 to 22% of crimes across the county were detected. This year, I understand, detection rates have risen - up to 37% in Salisbury was quoted. Of course, it's not statistically valid to compare the two different measures here (but many people will be tricked into doing so, I'm sure!), but I did come away from the meeting with a re-assurance of an earnest team at the top of our police service, working against some incredibly (over)complex systems, and far better placed that you or I would be to deal with the wide ranging calls on their service.

Posted by gje at 04:35 AM | Comments (0)


Related topics: via article database

January 28, 2009

Conversion of OSI grid references to Eastings and Northings

In both Ireland and the UK, the Ordnance survey divides down the country into a series of lettered 100km x 100km squares, represented by 1 letter (Ireland) or 2 (UK mainland), and then measures / reports and Easting / Northing within that square.

Example:
ST645332 (UK, box ST, 64.5 km east, 33.2 km north)
J665543 (Ireland, box J, 66.5 km east, 54.3 km north)

For Graphic Information systems and for other comparisons, there's a need to remove the letter and add extra numbers onto the Easting and Northing to produce a pair of system wide co-ordinates, and due to the lack of a pattern in the letters, that's typically done with a lookup table.

Yesterday, I wrote a python program to do the conversion ...
Dorothy:d2 grahamellis$ ./irish_grid G552844
155200 384400 G552844
Dorothy:d2 grahamellis$

... which also handles a whole load of other formats (and reports to two more significant figures)


You are welcome to view / copy / use that program [source code here] which is an excellent expression of how regular expressions are used and captured in Python, and of course you are very welcome to come to our Python Course if you want to learn more about how to do this sort of thing yourself!

Illustration - Trim Castle [link]

P.S. Answer to a totally different question - look here for the class that lets you read Excel spread sheets into Python (Answer for course delegate!)

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


Related topics: via article database

January 27, 2009

How long should a training module be?

Our courses are divided into a series of modules ("chapters"). This allows us to mix and match appropriate material for private courses, to modify public courses over the years as some subjects become more mainstream and others get deprecated into backwaters, and to print out and present specific extra subjects after the normal public course day has finished as necessary. The scheme works very well, ensuring that our delegates cover all the elements of the subject that they need.

I have been asked the question - as a course author - "how long should a module be" ....

Answer - there is no hard and fast answer.

The normal minimum I set for a module is that it should cover a lecture and a worthwhile practical exercise. In fact, that's an ideal size too - very occasionally it could be no more than 15 minutes of presentation, but more typically it will be longer. But, dear course author, beware about going over an hour for a session. No matter how keen they are on the subject, most of your delegate's concentrations will start to lapse somewhere in the 60 to 75 minutes area of presentation in any style, and if they are in the "I am here cos I were sent" brigade (how fortunate that we get few of those!) you'll start having a real issue.

The upper limit for a module is a series of 'a few' lecture / demonstration followed by practical sessions that logically run one after another, are (almost) always all run as a series of successive presentations without a break from the sequence, run on the same day, and have a single logical heading.

Our Linux - an introduction for users module is the longest example we have, and is really a one day course all in a single chapter. Why can it be one?
• It's a neat single description.
• Everyone who learns Linux needs Logging in, navigating, copying, editing, permissions, metacharacters, and using it on the network
Subjects such as Linux Utilities and Shell Programming are separate modules - they are not always needed with the Introduction, they may be presented on different courses for some delegates who already have the experience, and they have their own good, logical headings.

Notes ...

Just because there's a practical and a minimum run time when fully presented for each module doesn't mean that I (as tutor) have to talk at least that long and give a practical every time. There are occasions where some aspects of a subject are less relevant to all the delegates on a course than is the norm, and a quick overview of as little as a minute may be enough. A classic example are the Graphic User Interface modules with Python - TkInter, GTK, Qt or wXPython? Each a logical module, each in a public course note set - but chatting with my delegates I'll more likely than not find that only one or two are relevant each week. But delegates are concerned if you skip a chapter completely without an overview of it - somehow they feel cheated, even if the module wasn't on the public course description.

I personally break the sessions up by switching between projector presentation of material in the notes, drawing diagrams on the board, and writing code examples from scratch. And it's great to involve the delegates by putting data that THEY come up with in those examples. It may be as simple as their names, it may be an object of a type that they can easily relate to ("a golf course" or "a Chinese meal"), or it may be data in a format that they will be having to use. But you really have to know your subject well to avoid getting stuck up on some minor issue that colours the whole session.

Summary ...

Really, modules are an artificial division unit and there is no hard and fast rule for sizing them. A course should average no more that (say) six per day as the subject names provide a roadmap of the points along the course, but in essence the division is logic based not time based.

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


Related topics: via article database

January 26, 2009

The Royal Mail Receipt

You might be amazed just how much goes on behind a small business like our ... here's a story, written up by Lisa, to Chris who look after the Petty Cash, that's just landed in my mailbox .... enjoy ....

I have tracked down the answer to the Royal Mail receipt that had shown up in the petty cash box. Not that it will make any difference, just that you might be interested in what the charge was for. It's one of those "Holy Cow!" stories.

Chris, the receipt found its way to the box because Graham found it in a drawer under the box and didn't want it to go astray. He didn't take any money out, and so it's not being counted as part of the receipts from last week. But he didn't know where it came from. And I could not put it through without knowing.

I emailed Jxxx to ask if she knew and she came back with the answer.

She had posted out an application to a young fellow asking for a job at the Manor. He filled in the app and put it in the post. Only he didn't use a stamp. And for this potential 34p cost to the applicant, Jxxx had to go down to the Post Office to personally collect the post being held for us, and pay them £1.42 for the problem it caused.

At this stage in the job application process, the guy failed miserably.

As (I'm sure) does any company, we get applications from time to time. And there seem to be more than we're used to coming through at the moment, even though we're not advertising vacancies. Some are high quality, but some ...

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


Related topics: via article database

January 25, 2009

The Month Ahead - What is happening in Melksham

Tue 9th Feb Melksham Chamber of Commerce - "Update on Melksham" Meeting [link]
Fri 12th Feb Winter Olympics Open
Fri 12th Feb Wessex Chambers of Commerce Annual Dinner / Dance (Trowbridge)
Fri 12th Feb Wiltshire School Term ends - [link]
Sun 14th Feb Valentines Day
Mon 15th Feb Deploying LAMP - 4 day course - [link]
Tue 16th Feb Shrove Tuesday (Pancake Day)
Wed 17th Feb Ash Wednesday
Mon 22nd Feb Wiltshire School Term starts - [link]
Sat 27th Feb Last night of "Weekend Special" - [link]
Sun 28th Feb Winter Olympics Close
Mon 1st Mar Perl Programming (5 day) course - [link]
Sat 6th Mar Travel Watch South West meeting - [link]
Tue 9th Mar Melksham Chamber of Commerce - Regular Meeting [link]

OK - I admit it - I am lazy, so the list above moves forward through all the events I have in my calendar and you shouldn't find lots of old stuff hanging around. And I'll teach you how to make this easy on our PHP Techniques Course.

If you have an event to submit, email me - graham@wellho.net and I will include things which ...
• are in, about, around or pertaining to Melksham
• effect local businesses, travel
• happen not more than once a month
• are open to a wide range of people, though you may need to ask for an invite

There's a full calendar listing all events I have in the diary for the next year at http://www.wellho.net/melksham/diary.html

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


Related topics: via article database

January 24, 2009

Launch of Melksham Food and Drink Festival

"We've risen from 3 employees to 44 in 2 years". I was attending the launch of the Melksham Food & Drink Festival on Thursday morning, held in the Dining Room at Beechfield House, a country house hotel on the road between Melksham and Lacock. We had actually looked at Beechfield, very briefly, as an alternative to Well House Manor, and concluded that it was too much for us to take on - that it would move our business into areas that we didn't want to go, that it would leave us competing with good friends at places like The Conigre Farm Hotel and The Spa B & B.

Listening to Chris Whyte talk, and seeing Beechfield on a sample morning, I can't help but feel happily confirmed in our decision to concentrate on providing rooms for delegates on our courses, and to provide accommodation for others that's tuned to the needs of business visitors to the town; not for us the wedding and alcohol licenses (with the noise and children that inevitably follow), nor the posh restaruarant and out-of-town location which leaves guest who want a drink (so cannot drive) a restricted choice of places to eat. And I certainly wouldn't want to be running a team of that size and with what seems a surprising staff to room ratio which implies that the food drink and event aspect of the business must now be paramount.

And so ... what an ideal and logical venue Beechfield House was for the event that launched Melksham's Food and Drink Festival. The event itself will run from Sunday, 3rd May, and what an excellent boost and even it will be for the town. The Town Council is headlining it, and there are a number of sponsors already signed up, or going to be doing so. Rather than me reproduce the details here, have a look at their web site.


Top Table at Breakfast

Everyone came by car

I do look and learn as I'm around - as you'll have seen elsewhere on this blog - at how other hoteliers ply their trade. Very clearly, we're not competing with hotels in St Brivaels or Manchester, Maidenhead or Cambridge, and I feel morally justified in picking up ideas from them, and also thinking "gosh - we must make sure we don't do THAT!". With Beechfield, I feel (or felt) in a bit of a moral dilemma until the Thursday - but in practise, it's not that they're in a different league, but playing a different sport! Chris - if you happen to read this, you carry on doing weddings and we'll carry on with training courses and quiet accommodation. And I'm not stealing any ideas either ... I came back having had a great breakfast, determined to help push the event for the good of the town, and with some things to tell our own staff team that we should avoid in our own customer care roles, even though they are practised at many other places.

"Why not push the boat out - do something really special for the food and drink week at your establishment and bring people in ..." I am quoting from the launch. And I though about that. But then decided that our best approach at Well House Manor is to continue to do what we do best. To provide excellent accommodation for business visitors to the town, good value, plenty of choice of local eaterys, come and go as you please. Late arrivals, early departures, bringing you own food (or phoning for deliveries) NOT a problem ... and we'll continue with that during the Festival week. We'll fully support the festival - but we're not in the business of doing special food that week, encouraging in new local traffic, just to disappoint them when we return to normal on 10th May. I prefer a consistent product for our regulars and don't want to turf them out to some annexe while we host a one off event.

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


Related topics: via article database

January 23, 2009

Contrast

I've been very 'technical' of late ... a lot of good material that I didn't want to melt away from my mind as I moved on from Tomcat to learning to program, C, C++ and - next week - Python. But I did think these two pictures above, taken last Thursday and Friday, are an interesting contrast between the places I was at just 24 hours apart.

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


Related topics: via article database

Variables and pointers and references - C and C++

If I have a variable called "weight" that contains a float, I can use and set its value by using that name.

Pointers

If - in C or in C++ - I declare a variable to be a pointer then that variable may contain a memory address ... I use a * in my type declaration, and then I use & in my assignment:
float * pweight = &weight;

I can then say that I want to use the contents of that variable by preceeeding the name with * in my code, for example:
cout << "www " << *pweight << endl;

References

In C++ only, I can also declare a variable to be a reference by using an & in my declaration:
float & rweight = weight;

A reference gives a variable a second name, and once it has been assigned the variable can be directly accessed by that new name without any extra characters, for example:
cout << "xxx " << rweight << endl ;

References are a commonly used and useful way of giving a variable a second and temporary name without the undue complexity that's imposed by pointers. There are, however, times that you can't do without pointers!

Here's an example of a complete demonstration program:

#include <iostream>
using namespace std;
int main () {
  float weight = 16.8;
/* Pointer */
  float * pweight = &weight;
  cout << "www " << *pweight << endl;
/* Reference */
  float & rweight = weight;
  cout << "xxx " << rweight << endl ;
/* Direct Access */
  cout << "yyy " << weight << endl ;
/* Each of these alters the same variable */
  rweight = rweight + 14.7;
  weight = weight + 3.75;
  *pweight = *pweight + 4.9;
  cout << "zzz " << weight << endl ;
}

Note, specially, how the final three assignments all add to the same variable, but it's referenced in three different ways ... calculating 16.8 + 14.7 + 3.75 + 4.9 when all added together comes to 40.15:

[trainee@easterton lp]$ ./prd
www 16.8
xxx 16.8
yyy 16.8
zzz 40.15
[trainee@easterton lp]$

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


Related topics: via article database

January 22, 2009

Variable Scope in C++

In C++, a variable is 'scoped' to the block in which it is declared. In other words, it exists from the point at which you tell the compiler what type of value it contains through to the close brace at that matches the open brace preceeding that declaration.

In the most frequent use, this means that a variable defined inside a loop doesn't exist after the loop has been exited. And that's very useful indeed in clearing down temporary memory storage for use within the loop's iterations. If you should happen to have another variable of the same name in the outer code (usually a daft thing to do!), its contents will NOT be visible within the inner block as they'll be masked by the more local variable, but they will be unmasked after the outer block is exited.

You can even set up a block that's not a loop and not a conditional - that's there purely to scope variables - if you wish. Simply use a pair of culry braces without any if, while or other keyword. Here's a code example that demsonstrates these features:

#include <iostream>
using namespace std;
 
int main () {
   int demo[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
   int k;
 
   int answer = 42;
 
   for (k=0; k<12; k++) {
 
      int answer = demo[k]; /* masks the original answer */
      cout << answer << ", ";
      }
 
   cout << endl << "hidden was " << answer << endl;
 
   { /* This block is only for scoping purposes */
   float answer = 3.1415;
   cout << answer << " is something to do with cherry pie" ;
   }
 
   cout << endl << "hidden was " << answer << endl; /* the original again */
}

When I run that code, my results look like this:

[trainee@easterton lp]$ ./vscpp
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
hidden was 42
3.1415 is something to do with cherry pie
hidden was 42
[trainee@easterton lp]$

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


Related topics: via article database

January 21, 2009

Discount Training Courses - PHP, Perl, Python

Here's an email I wrote in answer to a request for a discount earlier today.

Many training companies quote high(er) prices, with the full anticipation that they can offer a wide range of discounts to their major customers, to students, to big companies who they would like to have an 'introductory offer', to last minute bookers to help them fill places, to people who book early and help them plan ahead ... resulting (in the end) with very few people actually paying the full price.

A long time ago, we took a policy decision that we would NOT inflate our list prices just so that we can knock them back down again via discounts to where they should have been in the first place. So - I'm sorry - we can't offer a student discount off the price; we just don't have the scope to do so.

It's always difficult to say "no" - but it's also difficult to justify to a delegate who has paid full price for a course why others who are there with him have been given special prices and he's just about the only one to pay the full amount. I have been place in the position of having to justify a "raise prices so that we can then discount" policy like this for a former employer and, quite simply, it's not our style. From Well House Consultants, you get a darned good course at a darned reasonable price ... and it becomes even better value when you consider that we keep the number of delegates on our public courses down to 8 so that you get plenty of attention to your own questions, and we keep our courses short and intensive rather than stretching them out.

I learned a lot from listening to the author of an Open Source product that competed with a Commercial one. He was describing how it's the TCO (Total Cost of Ownership) that counts, rather than any individual prices and components. In the training world, which is best - a full price course that runs for 3 days and costs you 800 pounds, with 5 delegates, OR a course that's listed at 1595 pounds, discounted by 20%, and has been stretched to a week so that there's more time for the provider to make money, and to answer questions from the 24 delegates.

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


Related topics: via article database

Useful links: Python training, Perl training, PHP training

January 20, 2009

New C Examples - pointers, realloc, structs and more

Every time I program in C, I marvel at how clever the language is ... yet at the same time I curse some of the devices that are used to perform certain actions, which make the code that much more of a 'puzzle' to right.

I've finished a 2 day C Programming course today ... and written a whole raft of new examples as I did so; the elegates gain so much more from seeing HOW I achieve the results as well as just seeing the results themselves. So I give you:

• Loops and conditionals - throwing a die until you get a six, then printing out the sum / average of all the throws [source]

• A program to head in your height and weight (in once file) and call functions in another to calculate your BMI and also to return a comment about your health. [source] and [source]

• The significance of call by value v call by name. If you call a function and pass it a COPY of the data, then no matter how much it changes the copy, it won't effect the original. But if you pass in a POINTER so that the function works ont he same data, then it CAN change it. Which is best? Both have their uses - it's a case of horses for courses. Examples - [source] and [source].

• Summing numbers typed in on the command line [source]

• How to pass an array to a function in C [source]

• Passing pointers into functions in order to allow the function to return multiple values [source]

• The difference between the . and the -> operator when used to access a member of a structure or union in C [source]

• Reading data from a file, tokenising each line into a structure and storing those structures in an array [source]

• Examples of the #define and #include pre-processor directives for setting up compile time constants and including a file of headers within multiple source files. [source] and [source]

• How do you read a file of unknown length in C and store it in memory, when you have to give you arrays a fixed size? You use the realloc function. This example shows you how to do it, setting up a block of memory which is expanded to take however much data you have in the file [source]

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


Related topics: via article database

January 19, 2009

I have not programmed before, and need to learn

Yesterday was the second day of my Learning to Program introductory course - for delegates who are learning to program - as well as learning a particular language, and (since the target language is C), I wrote a number of new C examples. And these examples were written in front of the delegates to show not only the final result but also how the result is reached!

Here they are:

Arrays and their use
Opening and reading data from a file
Data validation and more maintainable code

To demonstrate that there are many similarities between languages - learn one and you know (at least) some of the principles for others, I also wrote A short piece of PHP.

All twelve examples are indexed under our Learning to program resource. And if you need to learn to program in Lua, or Ruby, or C, or Python ... email me and I'll be happy to run two extra days in those language. If you're new to programming with Tcl, PHP or Perl being your target, again get in touch - we have different and well suited solutions there too.

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


Related topics: via article database

January 18, 2009

2000th article - Remember the background and basics

Entry number 2000 ... little did I look forward to my two thousandth article when, in the summer of 2004, Lisa suggested that I should join that trendy group who were starting their blogs. But here I am, in my fifth year of posting, averaging more than one article per day.

Why has it lasted? Perhaps because I have a purpose in writing; it's only partly to keep regular readers in touch - and that's a small part. It's also because I'm producing a catalogue of notes and ideas and thoughts that are searchable, across our courses via the module list - so that I don't have to repeat the same work / the same training example / the same answer too many times. After all, all programmers are lazy, and much of the time I'm a programmer. Yes, I do appreciate the irony that I'm suggesting that I have written several thousand articles more out of indolence than anything else.

If you read back through the 2000 articles, you'll see how we've moved from being a small training company providing niche courses to ... still being a small training company providing nich courses.. But we've added onto that our own Residential training centre and hotel, with lots of stories about the refurbishment and operation of that. Four years ago we were very quiet in the town, whereas now I'm the President of the local Chamber of Commerce. And four years ago, I knew nothing of local government or transport planning or how train services run, but now I find that I spearhead the campaign for an appropriate train service and run a forum with over a thousand posts a month from Paddington to Penzance - the First Great Western Coffee Shop.

Other things have changed and moved on too over the years; personal matters tend not to bubble up to the surface here, largely out of respect for the privacy of family members and friends who - whilst they might enjoy the high regard I hold them in - would probably rather I didn't shout about it too much in public.

At lunchtime yesterday I was sitting with delegate John (yes, a Saturday course!) in "The Cornerstone" and musing as to what article 2000 should be about. And I decided that it should also go right back to basics. I love this whole 'computer training' malarkey, and I'll probably be at it for many years yet. But, interestingly, this weekend I'm back to the most fundamental of programmer training - for a delegate who has never programmed before and for whom I'm working very much from first principles - the concept of a stored program, the 'what' and 'why' of variables, the elements of a conditional. And you might not believe what fun, and at the same time how tiring, it is!. I hope to have many more chances to go back to first principles again before I reach article 4000.

From Saturday - seven new source code examples - "Learning to Program":

A first example - a series of instructions
Calling named blocks of code
Calculate and print
Precedence in calculations
Calling functions with parameters
Conditional code
Loops to repeat code

(These examples are in C because that is the target language this weekend ... but ask me to run the same course using Lua, Perl, Python or PHP and I'll be delighted!)

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


Related topics: via article database

January 17, 2009

How low can you sink?

"Graham chose to compare Melksham to Dyce because ... " wrote Lee, and came up with some very good reasons why I might have chosen Dyce to make my railway station comparison, and to show just how hard done by Melksham is.[link]

But Lee gives me too much credit - FAR too much credit. I can, quite frankly, choose almost any station and make a comparison and you'll see the crass inequality of treatment of this town or some 24,000 people for whom the DfT specify 2 trains each way daily, and accept the train operating company running the first one out of Swindon at 06:15 and the second one back in at 20:20.

But I said ALMOST any station, didn't I?

Here's another very different comparison - Melksham with Denton.

Denton is an example of just how much WORSE the train service at Melksham could get, and just how dreadfully more unappealing the station area could become. For it has a service of just one train a WEEK (in one direction only!) and the footpath under the motorway that leads from the Premier Inn to the station is so dark that - for the first time in my life - I was scared to go through there the other night when I was in the area.

The weekly service is specified by the same government office that has specified the Melksham service. And they've done it within the letter (but perhaps not the spirit) of the law - a lesson for us to note, and to keep on our guard with regard to making sure the TransWilts service doesn't slip further.

You may ask whether anyone in their right mind would consider further cuts at Melksham, where there's a town of over 20,000. Alas, Denton station is right beside quite a large hotel and pub, a few paces from a major supermarket, just behind a bus stop with good pedestrian access and 4 services calling regularly. And even that hasn't stopped the reduction of the service to a travesty. Yes - we need to keep on our guard!

Link - further article

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


Related topics: via article database

January 16, 2009

Text on a background image

 Denton Railway Station, at Night.

 Served by just one train a week ...

A bustling area - a supermarket, warehouse / store, hotel, pub, car dealerships, pedestrian walkways and this desolate station ... that's what I found at Denton, near Manchester, on Wednesday night. And as well as words, I wanted to paint a picture like the one above. How could I do so, without image manipulation?

I have used a table to hold the image, and a cell within it with a background url rather than a colour ... sizing my table cell to the size of the image:

<table cellpadding=5>
<tr><td style="background:url(/pix/denton2.jpg) top center repeat-y;
color: yellow;" width=450 height=300 valign=top><h3>Denton Railway Station,
at Night. </h3> Served by just one train a week ...</td></tr></table>

See here for an article I have written on the area near this station, and the lack of service. See here for further pictures, and comment.

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


Related topics: via article database

Travelling to a course - station pickups

Most of our customers travel a considerable distance to our courses and it's their first time in Melksham. And a high proportion come by public transport. We're very used to helping people with directions, and arranging the last 'hop' from a nearby station [or airport] to our hotel / training centre.

Here's an example of the sort of advise and arrangements I've just been making for a delegate on a Python Course - with names changed to protect the innocent!



Hi, Mary - that's good, thank you - I have copied your email on to Lisa who will pencil in a place and room for Gerry pending receipt of the paperwork. Lisa will also put a note on file that Gerry would like to be collected from the station ... the local station is MELKSHAM which has three trains on a Sunday evening, and if Gerry lets us know which he'll be on I (or - just possibly someone else) will be there to collect him, with a Python book in hand. It's a small station - he'll have no trouble finding us!

If there are engineering works (or connection problems) and you can't get a reasonable train to Melksham, we can pick up from Chippenham or Westbury instead, or (worst case scenario) ensure that our local taxi service can pick him up. And either of those two stations is also fine for his return - anything from 17:15 or later if you're booking a specific train, and we'll get him there. With courses on which delegates come from all over the country, we're "dab hands" at welcoming people Wiltshire, and ensuring that the final few miles are smooth.

Graham

P.S. Our freephone number (0800 043 8225) reaches us 24 x 7 ... and can be used as an emergency contact even during the journey to us.

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


Related topics: via article database

Advise before my Apache / Tomcat course

We want our customers to get the very best from their courses, and we're deligheted when they ask about preparations they can do (reading, etc) ahead of time. In fact, this is such a good question that I'm pasting (below) a copy of an answer that I have just emailed to one of the delegates coming on our Apache httpd and Tomcat Deployment course in a few weeks time.


The main "before course" advise we give to people is to arrive in good time and refreshed - coming the evening before which you are doing, I understand, is ideal. And also to ensure that they won't have a constant string of messages to answer ... most people find it very hard to (say) exchange contracts on a house purchase one minute, then learn to program the next ;-). I know that's pretty non-technical and not really what you were asking, but it's about all we ask before the course - our typical customers are very busy with other things before they come along, and rarely have much of a chance to do pre-reading so we cannot assume it would happen, and we present our courses based on delegates meeting any pre-requisites but no more.

You're an ex-unix sys admin and DBA ... which should stand you in good shape for the course. I note that you're going to be running Apache / Tomcat on Windows; if you get a chance to brush up one anything (and need to) the sys admin aspects of Windows could be the most helpful.

There is a wide range of books on the Apache and Tomcat subject and many of them are available during the course. I would suggest that you find which are best for YOU during the course, then order the current edition from someone like Amazon of any that you want to refer to again later. That's better than you spending based purely on my recommendation, not having (yet) met you or knowing the details of your application and what makes you tick.

If you're arriving in Melksham by train, please let me know and I'll pick you up from the station. Otherwise I'll probably see you on the morning of the course, with Chris, Sharon or Sarah checking you in the evening before.

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


Related topics: via article database

Automated server heartbeat and health check

Occasionally - very occasionally - we may have a problem on our public facing web server that's hosted in some network operation centre or other. It could be a software glitch, or it could be an internet connectivity issue. And we need to know about it quickly!

The problem is than none of us might actually be using the server. I could be giving a private course in Kent, Lisa may be in the office confirming a public course booking, and Chris could be at home in Calne. We have some excellent customers who have been known to alert us by email (thanks, customer Chris, the other day!) but really it should not be necessary for that - in fact, we should find the problem before it gets widely noticed.

I had a bit of a rant the other day about someone who's running a script that pulls a page off our site every five minutes to see if we're still running (see here) but it also set me thinking that we could monitor our own server in a similar way - it's a very different matter to monitor yourself that to monitor someone else uninvited, after all! And we do have a second (backup) server.

So ... here's what we are now doing:

a) I have installed a PHP program that runs stand alone on our backup server which checks with our main server and emails all three of us "techies" if the main server does not respond. (source code)

b) We have a regular times (crontab) job running 4 times an hour ... running this program. The crontab line is in the source code as a comment / example

And it can be that easy!

I have chosen to go one stage further - the page I am calling up on the public server is actually a status line generator, so that our backup server can do more that just say "live" or "dead" - it can also say "live but looking a bit sick" if it needs to. The status script is actually called up from within my Ajax Demonstation too, and you can see the source code here if you wish.

((As an extra, I should have our main server heartbeating our backup server in an equal and opposite arrangement so that we'll be notified if either one falls over))

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


Related topics: via article database

tomcat-users.xml; what a difference a space made

Product: Apache Tomcat release 6.0.something

Symptom: After some fine tuning of the configuration files, a working installation was no longer working ... requests for web pages resulted in the browser hanging and waiting, in perpituity it seemed, for a response. In other words, the connection was being made to the port but no response returned.

Analysis / solution: It turns out that extra (spurious) spaces between the "<" and the tag name in the tomcat-user.xml file were causing the problem.

Wrong (failed as described):

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
 <  role rolename="manager"/>
 <  user username="trainee" password="abc123" roles="manager"/>
</tomcat-users>

Right (working):

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
 <role rolename="manager"/>
 <user username="trainee" password="abc123" roles="manager"/>
</tomcat-users>

Background: The tomcat-users.xml file provides one quick and easy way of providing a login capability to the Tomcat Manager application which allows you to see how your server is running 'on the fly', and to stop and start and deploy web applications individually rather than controlling them simply by stopping and starting the whole server!

Learn More: On our Deploying Apache Httpd and Tomcat course.

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


Related topics: via article database

January 15, 2009

Load Balancing - Hardware or Software?

If you're fortunate enough to be looking after a web site that's so busy that a single server can't handle all of your traffic, what should you do?

One popular approach is to use a piece of specialised hardware - a load balancer - that sits in front of your network and distributed requests to a series of machines to service the requests. Devices such as the Cisco CSS 11506 Content Services Switch (CSS11506-2AC) , for example. But such devices cost money - this one pops up for around $20,000; other may be as little as a third of that price, but still serious money.

There are some sites / applications where such a device is the best way to go - but there are other ways too if your site is too busy for one server to do everything ... but not swamped by an order of magnitude. You could, for example, run a front end system to proxy all requests through to one of a series of back end server where the real application work is done. And that front end system needs to be nothing more complex that a regular system running Apache httpd, using mod_proxy and mod_proxy_balancer to distribute traffic onwards. It's not ALWAYS going to be the solution for you, but as your site grows beyond the capacity of a single machine, it will allow for expansion without a huge investment in a specialist device and the training on and support thereof.

It's been pointed out to me that using an instance of httpd to forward all traffic leaves a single point of failure. Well - so does a hardware balancer in the scenario I have described above. Heartbeat scripts, checking device, etc, can overcome this issue and it need not be a concern.

We cover forwarding from Apache httpd on our Linus Web Server course and on our Apache / Tomcat deployment course. The first course is the one you should choose if you're forwarding to more instances of httpd, and the second if you're using httpd to front one or more Tomcat Java Application Servers.

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


Related topics: via article database

January 14, 2009

A good time to travel

I think that was a record early start for me this morning - up at half past three, for a departure at half past four. Even when I stopped at the service area near Worcester, it as still in "night mode" with the shop closed, the "beware wet floor" signs propped outside the loos, and a deserted car park ... and so on to Manchester. I wouldn't normally even countenance travelling this far in the morning before a course, but a Monday and Tuesday without training, followed by an evening meeting that I couldn't miss, led to the extraordinary schedule. And I have to admit it worked very well - the usual snarl-up at Birmingham was a clear run through, and only around the Manchester Ring Motorway did I really hit any traffic. Arrival just after 08:30 was great for an 09:30 start ... and what a great bunch of delegates. I'm enjoying the course and I thing they are.

How wonderful to start so early in the morning ... it avoids wasting so much time. But I'm heading for sleep now - more Tomcat Training tomorrow, and the long drive home which you can bet will take a lot longer.

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


Related topics: via article database

January 13, 2009

Rules for a King

At Well House Manor, we're here to supply a service to customers. And the customer is King ... But even the King has to follow some rules

There are certain requests that we really cannot meet - the most extreme example I have personally had was a request for us to accept just twenty five pounds for a twin room, including breakfast.

Some of these requests will be try-ons. There's one woman I know who routinely complains about her room at every hotel she stays in in order to get an upgrade, and isn't against telling a few lies to help her case (she has never stayed with us, by the way!). Others will ask about something in all innocence, just wondering if we can help (a bar for example) and others may make an assumption that we offer a particular service when we can't - for example they might want their 12 year old to join them in a family room for the last night of their stay, but our insurance doesn't cover under 14s.

And it's always difficult - very difficult - faced with a customer and saying "Sorry - No". So here are three things to help:

a) We have a load of policies. And it requires at least TWO people to make a decision against a policy. So if the person on check out, alone, is faced with a customer who has a normal, payment on departure arrangement but is asked if it's OK for payment to be made next week, then the answer has to be "Sorry - no". And a phone call to Graham or Lisa if the customer would like to take it further. Even the MD [Graham] phones through and speaks with Lisa ... or Chris or someone in such a circumstance. This gives our staff the authority of the company, and doesn't lessen their position; the person getting you call will know full well the situation you're in "at the sharp end" and is there to HELP.

b) Know the policies, and know the REASON behind the policies, and explain them. "No - you need to pay when you leave. I know you are booked in again next week, but our cancellation policy allows you to change that booking and not come up to 11 a.m. on the morning. It's much clearer for everyone if each visit is paid separately. Customer are far happier if they no the reasons.

c) Offer sympathy / suggest an alternative. "We can't put your clothes through our laundry as there would be an insurance issue if they got damaged - and we're not trained as laundrymen. However, there's a laundrette in Melksham - I can tell you where - or we may be able to get them sent out for you".

As a follow up thought, here's a random list of policies that we have ... and everyone should be aware of.
* How late can I cancel?
* Can I check in early?
* Can you send the bill on?
* Can I have breakfast at 5 a.m.
* Can you get me a taxi to the airport?
* A lift to the station?
* Can I have a different room?
* Do you take Euros?
* I've got a meeting - can I come back and collect my belongings later?
* Can I meet with my customers in your lounge?
* Can you put a cot in the room for my baby?
* Can I order an evening meal?

Some - such as the laundry - are new questions that come from the blue. Try also
* Can I leave my car here until next week?
* Can I have a hire car delivered?
* Can I keep my medical samples in your freezer?

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


Related topics: via article database

January 12, 2009

Speaking all the languages

Phil Staiger, who talks about Tips and Techniques with Project Dogwaffle, can speak (as I recall) at least six languages. Working for an American company (Megatek) out of San Diego, his role as roving technical expert had taken him all over the world, and had him talking with people from many countries. I recall a great admiration when, across in California to learn the technical stuff company's graphics products and libraries so that I could take over the European support, I watched him switch from Spanish to English to French in successive sentences. I really wondered how he did it and all the technical stuff too.

I understand English (and write it only up to the standard you'll find in these jottings), and I have a smattering of French. I always struggled with Latin at school until allowed to drop it, after which the struggle ceased. I did no more than wonder about learning Swedish at one point. The motivation, incredibly, was a work role and not a blonde, but that is a story for another day.

Any yet I find myself programming and switching - "á la philip" - from Perl to PHP, then a bit of Tcl and some C before doing a bit of awk and perhaps ruby.. Looking at Philip's web site and links, I see he's talking Lua with Dogwaffle and, sure, I can do the Lua thing too. So - somehow - I'm on the other side of the fence with this switching capability that baffles others and people ask "how do you do it".

I'm afraid the answer is a very simple one.

All programming languages are based on the same underlying concepts. For sure, they're all implemented differently, but you've still got variables, and blocks, and conditionals and sequences of statements. Named pieces of code, loops, and some sort of collections. An ability to load more bits of code, shared between programs, from common files. A way to add comments to your code, and ways to read information in and write it back out. I'm suggesting that you could say there is really only one language - it's just implemented with a different set of grammars, and basic elements that are tuned very differently ... thus giving rise to languages which are strong in one area or another, and providing foundations on which you can ideally build one type of application or another.

You see ... really ... I still just know one language. It's the language of programming. Now Phil - he's clever - he knows the language of speech in depth too.

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


Related topics: via article database

So sad to see you go

We love people to come and stay at Well House Manor and learn on our public courses, but we're always sad to see them go. Which might be why I have a number of pages on this site about getting to Melksham but very few about getting home after your course, and I have been tipped the wink that I should add something to our "Getting Home" resource page as it's rather empty at the moment!

If you're staying at the hotel, we ask you to check out by 11 a.m. unless you've made prior arrangements ... but if we know ahead of time we can often extend. And we can always look after your luggage for you during the day, and give you a cup of coffee if you're waiting around, and a lift up to the station if you're booked on the evening train to Swindon and beyond.

If you're on a public course, we'll usually aim to finish at about half past four or quarter to five, to at least give you a chance to get on the road before the five O'Clock rush. But if all the delegates want me to keep talking, I can do so ... and if someone needs to leave early - perhaps to catch a flight from Bristol airport - I can usually make sure that the final subjects are re-ordered so that delegates don't miss anything vital to them individually.

If you're leaving after a course by TRAIN ...please don't plan to catch anything before the 16:55 London train at Chippenham (we can usually give you a lift, and at worst get you a taxi).

If you're leaving BRISTOL airport after a course, we can arrange a taxi for you and we'll suggest that you don't book a flight that leaves until 18:30 or later (but we appreciate that flights are not as frequent as trains, and you may decide to go a little earlier)

By BUS, there's a service at just after 17:00 from the stop in front of Well House Manor, into Bath and the hourly service from Chippenham to Trowbridge calls as the Market Square into the early evening.

If you're driving ... we can help with directions. When guests and delegates arrive, they usually leave the M4 at Chippenham as that's our closest connection to the motorway network, but we have some tips and techniques for people to find alternative and more pleasant routes back ...

... to South London via Stonehenge and the A303
... to West London via the Marlborough Downs an the old coaching road
... to the Midlands via the Roman Fosse Way - straight and avoiding towns

But it's not "Goodbye", it's "Adieu" ... you're welcome to email questions and let us know how you're getting on - and you're more than welcome to come and stay again - indeed, we welcome delegates back at the weekends at the same favourable rate they enjoyed when they stayed on their course during the week.

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


Related topics: via article database

January 11, 2009

Melksham, Wiltshire. Town Crier Competition, 2009

"Coming to Melksham on 25th April 2009 ... Melksham's 1st Town Crier Competition - 30 criers and escorts in a cavalcade of sound and colour"

Taking place in the Market Place - just five minutes walk from our hotel [about and bookings] - at 11 a.m. and 2.30 p.m.

Peter Dauncey, our Town Crier, and his Escort pride themselves as being Ambassadors of Goodwill ... and indeed we're very grateful for their support at many events ranging from the Santa trip on the train through the opening of Lidl!

The competition should be great fun ... I know we'll be going along. Other Melksham Diary dates are here - ranging from the local drama group's pantomime through open gardens to business meetings and training courses.

Pictures - the Town Criers of Ilfracombe and Melksham, pictured in Melksham.

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


Related topics: via article database

One Cheer for Local Democracy - Asda in Melksham

On Thursday evening, Lisa and I attended the Planning Committee Meeting of West Wiltshire District Council. Sounds boring, doesn't it? Well - it wasn't; a big decision to be made with regard to a new Asda supermarket to share a site on the edge of the town with Countrywide Farmers.

There were two other decisions to be made first - in both cases, the council's officers recommended accepting but the committee rejected. I don't know enough about the individual cases to make authoritative comment. Then we came to Asda. The Council's officers had looked at the proposal, and had come up with five reasons why they recommended it should be rejected. "There may be a smell from the sewage works", and "there could be traffic problems" and "it's not in line with government policy to develop this area for business" and my - laymen - paraphrasing of them. So, frankly, it didn't look too promising.

But the Mayor of Melksham spoke in favour. Of the chance of redeveloping an eyesore at the gateway to the town. Of an investment of around 25 million, and with hundreds of jobs coming in. Of a bus link to connect and help revitalise the town. And of shoppers staying in Melksham to shop rather than going to Trowbridge or Chippenham, and passing trade shopping in the Melksham area. Speaker after speaker followed - there must have been at least a dozen. A bus driver pointed out that there wasn't / wouldn't be a traffic jam problem with George Ward moving, and traffic light cycles upgraded since the initial proposals which the County Council had evaluated (so weren't actually valid any more). A speaker from the village of Holt pointed out that people from there would largely switch to shopping in Melksham ...

There was one (just one) high profile speaker against. Councillor Sarah Cardy raised the issue that the town's traders were worried about Asda pulling business away from the centre, and questioned whether the town could support a further supermarket. I confess that - as I listened to her - I was seriously worried that the committee would turn round and say "we haven't seen unanimous support from the town" and reject the proposal ... uneasy echos of the public consultation over the train service, where the DfT used just a single individual's representation (who said the train should serve HIS town instead) as a justification that public views were split. So my heart was in my mouth.

I had a brief chance to speak, and spoke of Melksham as a growing town where new businesses (such as our hotel and training centre) had brought new business to the area, at the expense of neighbouring towns if anywhere. And I pointed out that the town is growing and set to grow further - lots of housing, so the shop's needed. I probably amazed people who know me by NOT talking about travel and transport.

Further talk, and it came to the deputy Mayor then the committee members, and we held our breath. A Melksham representative spoke in favour, then another. A councillor from out of the area said that the proposal looks like a good one to bring real investment in, and that all too often planning folks look for reasons to turn plans down when they shouldn't. And councillors from Trowbridge (who had been accused - in jest - of looking far too much just to their town) spoke in support too. And pointed out that none - NOT ONE - of the traders who Sarah Cardy alleged were worried - had taken the trouble to come along and be heard. So very thought provoking support, with excellent and searching questions.

Wiltshire County Council had sent Allan Creedy (the guy who had been very quiet and appeared embarrassed at their lack of progress on the TransWilts train service at the November WWRUG meeting), and he was questioned by the committee. He explained how many assumptions had to be made in a transport model and that he couldn't be sure what would happen with regards to delays; in summary, he conceded that their models were out of date (it seems that - with officers saying REJECT - they may not have analysed the improved proposals fully enough), and that if there was any slowing of the traffic, it would probably be just a minute or two's delay at peak times only.

I love what Councillor Philips (NOT a Melksham councillor) came up with. "Let's see - we have to choose between a major investment of 25 millions pounds and lots of jobs, or the fact that it might lead to a couple of minutes delay". And his argument set the scene for a vote at which the committee (by about 12 to 2) came down in favour of progressing the proposal / making every effort to bring in the store.

So why just ONE cheer, not three?

We loose one cheer, because Central Government thinks it knows better, and it's not actually within the remit of the committee to approve ... a couple of the 'reason to rejects technically go against government policy (e.g. the site is technically not in town, even though it's closer than the new doctor's surgeries and school) ... and so they won't actually ALLOW the decision to be made locally - it has to go to the secretary of state - that's Hazel Blears, MP for Salford, Manchester - though may be delegated to government staff in Bristol.

And we loose a second cheer because West Wilts District Council ceases to exist on 1st April - with its powers taken over by Wiltshire Council, its officers joining them, and the elected representatives who made the decision on Thursday bein out of District Office. Wiltshire haven't show themselves to have taken the Asda proposal seriously, with Allan's outdated information - and he was far better than four other sections who - comment was made - "Amazingly, haven't even replied to out request for their inputs ..."

The officer's report for forwarding to central government comes back to the commitee in February (a very fast turn around) so that it can be put through before there's a change at the helm with the delays that could cause, but as the committee said "we want and approve this - but we'll be dead and buried before it comes to fruition".

So - one cheer for local democracy. I hope that seed that's been planted will grow into a mighty tree - I know that there's near-unanimous support for it to do so, with the benefits far outweighing the issues. Forward, to a vibrant Melksham.

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


Related topics: via article database

January 10, 2009

Walk to Bowerhill

I walked out - just a very short distance - to Bowerhill to drop off the post earlier today. A fine, crisp, frost bedecked trip; here is a selection of the pictures as these articles have got very technical of late!


The Old Spa houses, on the very edge of Melksham, still look out over fields

This isn't the time of year I would expect to find a butterfly ... but I did ... and some more things to picture


River Avon Loops

Wilts & Berks Canal Wharf

Rear of Spa Houses

Conigre Mead

Web on Leylandia

Kings Arms

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


Related topics: via article database

Learning to program as a part of your job

Scenario - you have never programmed before, but you are required to do so as a part of your job. You see lots of course (like ours !) on C, or PHP, or Python ... but they all assume some prior knowledge. And when you pick up a book it seems very theoretic and irrelevant, or looses you in the first page.

Does the scenario happen? Yes - sometimes it does, and the person involved may not have the luxury of a long time to go back to college or take evening classes for an extended period - he / she needs a quick start to get them going - not only in the basics of programming, but also in the slightly wider topic areas of making sure that they write easy to use and easy to maintain, robust, systems that don't duplicate work that's already been done.

Here's a possible answer. We can run an extra 2 days of tailored training for you in front of our regular courses - a "learning to program" addendum which will get the 'totally new to programming' delegate into the detail of the concepts (two thirds of the course) and the wider areas of efficient use of their programming time and how to produce good results (one third of the course).

If you're booking a PHP / C / Python / Lua / Tcl / Ruby course with us ... but have NEVER programmed before - let us know and come for an extra two days first. It will probably be a 1 on 1 session and it will get you up to speed for the following course. Examples will be written, in front of your very eyes, so that you'll see not only the results but THE THOUGHT PROCESS BEHIND HOW THEY WERE ACHIEVED, and you'll have an opportunity - with tutor help - to put the though process into practise yourself as you write you own first programs.

I'm running 2 days "Learning to program" prior to the C course that starts on 19th January - so that's two extra days that are available on 17th and 18th (yes, Saturday and Sunday!) and we would be delighted to have you. Standard cost for a 2 day course is £600.00 + VAT, add £70.00 (that's VAT inclusive) per night if you want to stay over.

If you have missed those dates [you probably are - the archives are very popular!] please email me graham@wellho.net or call us on +44 (0) 1225 708225. It isn't the first time that I've trained to this agenda and it certainly won't be the last. I would be delighted to share with you the fun of practical programming.

Sample agenda:

"Learning to program" course.

Your very first program

An instruction to display a message.
Storing that instruction.
Wrapping the instruction.
Preparations to run the instruction.
Running the instruction.
Multiple instructions become a program.

Joining instructions together

Storing information in memory while your program runs.
Defining and setting variables - declarations and assignments.
Variable type and naming variables.
Do I actually need to declare variables?
Displaying the contents of a variable.

Entering your data and calculating

Arithmetic operations.
Order of precedence, and how to change it.
Converting and co-ercing, rounding issues, etc.
Reading input from the user.

The first of many looks at usability and security

Adding comments to your program.
Making your code self documenting.
Making your code maintainable.
Program layout.
Making the output understandable and auditable.
Providing user documentation.
Handling unanticipated user inputs.
Providing user support.

Choosing different actions

The need for conditionals.
Conditions and optional operations.
Blocks, and merging the strands afterwards.
Alternative blocks (else, otherwise).
Setting the same variable in each strand.
What exactly IS considered to be equality.

Repeating sections of code

The need to repeat operations (loop).
How a loop differs from a conditional.
Making sure that you can get out of a loop.

Named blocks of code

The need to avoid repeating bits of code.
Naming a block of code.
Passing information in to a block.
Passing information back from a block.
Keeping variable names in a block private.

Looking forward

Separating named blocks into separate files.
Collection variables.
Using other data streams as well as keyboard and screen.
Easier loops (for, foreach).
Handling strings of text as well as numbers.
Pointers and references.
Objects.

Away from the detail of coding

Planning your work.
Choosing the right language.
Testing, release and source control and bug tracking.
Finding code that others have already written and using it.

Application design for ...

The Program writer.
The Program maintainer.
The program operators (human and automata)
The people who provide the data.
The people who make use of the results.
The system administrator who looks after the computer.
The user support team.
The malicious person trying to gain access via security holes.
And to meet legal and expandability requirements.

Contact - Well House Consultants, 404, The Spa, Melksham
+44 (0) 1225 708225 • graham@wellho.net • http://www.wellho.net

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


Related topics: via article database

Site24x7 prowls uninvited

Wanting to get an idea of where our traffic comes from on a typical Friday evening, I took a look at all visiting IPs to one of our websites over a 15 minute period and found the IP address 72.5.230.111 which I didn't recognise. A reverse DNS lookup points me to a domain called site24x7.com:
  Dorothy:jan09 grahamellis$ host 72.5.230.111
  111.230.5.72.in-addr.arpa is an alias for 111.65-123.230.5.72.in-addr.arpa.
  111.65-123.230.5.72.in-addr.arpa domain name pointer monitor.site24x7.com.
  Dorothy:jan09 grahamellis$

and a further look at my log file showed me it had been visiting, routinely every 5 minutes, all day. Indeed a look back in my history file showed me that it had been grabbing a copy of the home page at this interval for at least the last couple of weeks - and probably a lot longer, but I went back no further.

The web site of the 24 x 7 people says "Site24x7 is the easier, faster and more effective way to monitor the uptime and performance of your websites, online services and servers." In essence, their servers run robots that check your machine from a remote location, and gather stats. They offer a free account to monitor one or two sites at intervals of an hour (or less frequently), and paid options for more frequent monitoring.

It's a good idea for the admin of a server to have it monitored in this way. The problem that I have in this case is that I am the admin and I have not asked for the monitoring to take place.

Automata such as the monitor program are supposed to read the file robots.txt file (see robots exclusion standard) from time to time to check that they are welcome, and automata can - in theory - by excluded on a case by case basis. I say in theory because it's a voluntary code. It seems that the site 24 x 7 computer has enough time on its hands to monitor my site every 5 minutes, but hasn't bothered to read robots.txt for at least a month, so there's little point in me even trying to ask it to desist via that file!

Being a voluntary code, there's nothing illegal about what the site24x7 people are doing - but their system is being very rude in putting a small but repeated load on my server without even asking "may I" every so often. And someone's using the service in a way that it's not being sold. It's great to buy a tool that you can use to look for issues on your own site, and rather less clever to be able to buy a tool that lets you find fault and analyse someone else's site. I rather dislike the ability that site24x7 is giving person(s) unknown to monitor me.

Would it be practical for the folks who provide this service to check that they're only monitoring sites where they are wanted by the site owner? Yes - they could so easily ask the site owner to put up a specific file with specific content that they could check to validate ownership - Google does this for some services (and, as even, "Well done Google"). They could certainly check the robots.txt file from time to time (the respect it), and they could have easy to find information on their web site telling webmasters who come across them unexpectedly, as I did, how they can disable the snooping onto their server.

I sent an email to their support line asking (a) how to exclude their service from my server and (b) who has asked for us to be monitored. Since the company specialises in 24 x 7 monitoring, it seems ironic to me that they haven't got back to me yet, and it's been some 12 hours since I wrote.

But secretly, I'm slightly flattered that someone feel it's worth paying even a tiny amount of money to be told when our server's not running.

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


Related topics: via article database

January 09, 2009

Keeping PHP code in database and running it

The software for these articles lets me enter HTML and keeps it in a database. If I want to add PHP, that gave me a problem as the data (HTML) was simply read from the database and passed to my client's browser without being parsed for <?php to ?> sections. But problem solved in two different ways!

The current page is generated as I write the blog, and is saved on the server as a regular .html file. We have simply instructed our server that in this area, when serving files ending in .html it is to put them through the PHP interpreter - that's a line like
AddType application/x-httpd-php .html
in my .htaccess file.

Our archive pages are not stored- they're not called up so often, so we can afford to generate them on the fly. In addition, the menu of "other available articles" changes dynamically as new articles are added - so we cannot store the pages unless we chose to rebuild all 2000 every time an article was added or updated.

Here is the line of PHP that we used on the archive pages to include the HTML within the page:
$bodder = nl2br($row[entry_text]);

When we wish to include PHP in there too, we have a problem - it's going to be passed right to the browser, and as PHP source too. Here is our solution:
ob_start();
eval("?"."> $row[entry_text] <"."?php ");
$yeahz = ob_get_contents();
ob_end_clean();
$bodder = nl2br($yeahz);

a) The use of eval let me actually run the code from the database. However, the output would go straight to the browser which isn't what I want so ...

b) The ob_start buffers the output from the eval, the ob_get_contents returns the data to me from that buffer, and the ob_end_clean deletes the information from the output buffer and turns buffering off. So I have used the built-in facilities to trap the output from the PHP.

Does it work? Yes ... but I do need to check XML feeds as well if I start making heavy use of this. I suspect I need to parse them through PHP - not a big deal. Let me test it. The current time is 19:23 and the date is 9th February 2010. It is a Tuesday. [[Those sentences should have changed for you to reflect the time on the server when you called it up]].

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


Related topics: via article database

Useful link: PHP training

January 08, 2009

Cooking bodies and URLs

With over ten thousand different web pages on our web site, the issue of finding the right resource has become just as big an issue as having the right material available in the first place. Listings by article type and number (example) are great for crawlers / bots, and for staff checking page by page. Division of our material into modules (module list) can help somewhat, but still leaves people having to go through lists with a determination that comes to past students who know that they have a good chance of finding what they need, but misses the casual visitor (and potential trainee ;-) ) completely. That's where a search capability comes in - we've had one for a while, but not everyone says "I think I'll do a site search" so we want to automate that search, and add in a few results on many / most pages. You're probably very familiar with the sort of thing:

But how do I decide what to say in such a small area? How do I include the meat but trim out the fat? I've used regular expressions - and here (coded in PHP) are the specifics of what I have done for this example:

For the body, remove all the markup from the content block that we have stored in a database and trucate it to report just the first 150 characters, adding a few extra characters to avoid breaking it in the middle of a word, and then plonking a "..." on the end to illustrate that it's only the start of the body.

$body = strip_tags($row[body]);
$body = preg_replace('/^(.{150}\S*\s)(.*)$/s','\\1 ...',
  $body);

For the URL, take any sections of 18 or more characters between successive dots and / or slashes, and replace them with 8 chars ... 5 chars. These days, URLs are semi-descriptive, often comprising the title of the article with dashes or underscores anyway, and these URLs give some browsers folding problems. But the used DOES want to see the end of the URL to know if it's a ".html" or a ".php" he'll be linking on to. Here's the URL code:

$uddd = "http://www.wellho.net$row[url]";
$uddd = preg_replace(
  '!([/\.])([^/\.]{8})([^/\.]{5,})([^/\.]{5})([/\.])!',
  '\\1\\2 ... \\4\\5',$uddd);

There are not the world's simplest regular expressions (far from it!), yet they do show just how much can be done in a single statement. We cover such techniques with PHP specifically in mind on our PHP Techniques Workshop, and in more depth (and regular expressions more generally) on our Regular Expressions day.

You can see more results from these algorithms already in use on our resources pages (example), and in time many (most? almost all?) pages on our site will have an improved and consistent 'see also' along these lines. Key features include:

Automated We don't have to go through and do all the work of adding in extra links on every page - just provide some categorisation hints.

Adaptive We're recording hit / visit counts, so that we can promote popular pages higher up the listings.

Consistent across slightly varied page types. The display should be morally identical no matter what the resource type is. Frankly, you don't care whether the answer to the question "how do I tell Google which country we operate in" is in a forum post, a longer article, or a blog entry written in May 2007 - you just want to find the f***ing answer!

There are some other "salesy" things I could add too. Fast as it happens on the fly, expandable as we have the basis for it to expand from 10,000 different URLs to 100,000 very easily ... marketable - maybe; I'm certainly happy to tell you how we do things like this, and to sell you my time as I tell you and help you understand it in depth. That would be called a private training course.

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


Related topics: via article database

January 07, 2009

Bitter cold

It's bitterly cold here in Wiltshire at the moment (and the "Global Warming folks are hibernating, it seems!), but how to express that in pictures? A slight sprinkling of snow, ice on the driveway gives something of a clue:

In words, I can tell you of feeling cold (that's unusual for me!) and of huddling over a heater. I can tell you of turning on our second central heating boiler at home. A long story, that one - we're on 4 levels and hot air rises, so we normally heat the bottom and let the bedrooms be a little cooler, but we do have the ability, used in the most brutal of weather, to add an extra boost of upper heat. And I could tell you of finding that both cars had flat batteries and wouldn't start for us on Saturday evening - so we walked into town (yeah - mad!) and warmed up with a really hot curry.

But here's a sunset picture from yesterday evening - with the second car also back and running, I paused at Seend by the canal bridge:

So you can see - it really IS bitterly cold in Wiltshire at the moment!

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


Related topics: via article database

January 06, 2009

Michelle

Is 2009 going to be "The year of Michelle"? After a lull over Christmas and the New Year - usual in our business - enquiries are flowing again, and bookings picking up where they left off. And yesterday there was a predominance of Michelles. Question - "Did you get back to Michelle". Answer - "Which One?"

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


Related topics: via article database

January 05, 2009

Looking forward, in Melksham, in 2009

Late in 2008, I was delighted and honoured to be elected the President of the Melksham Chamber of Commerce and Industry - something of a figurehead role in which I can listen to the views of businesses in the town, and advocate the shared business views both within the town and further afield. Here, starting 2009, are a few words looking forward that I have penned for The Chamber's New Year Message. Other "Chamber related" material is indexed here

2009 will be a challenging year for businesses big and small; a rapidly changing economy will create both winners and losers, and all businesses will need to adapt and adopt to thrive.

In Wiltshire, we're seeing political changes too. The new Unitary Wiltshire Council takes over from the two tiers of District and County in the Spring, and already the officers of the new council are talking about the tightness of their budgets, and of working for "Salisbury, Trowbridge and Chippenham" - their words, which should act as an alert to the other towns in the new authority, such as Melksham, that they need to raise their voices to ensure their interests are fully considered.

In Melksham, a new supermarket has just opened, another is in planning and an existing store is planning expansion. And although we see the occasional empty shop front, the town is more vibrant than many others in the Wessex Chambers area. And these very developments can bring their own problems - with serious traffic congestion, parking demand in excess of supply in the central car park at times, and road works which also discourage business.

Melksham is also home to a wide range of industrial businesses, scattered around the edge of the town. It never ceases to amaze me to see a "Melksham" address crop up in the most unexpected of worldwide marketing literature - from railway components through tyres and furniture to disaster appeals and lighting supplies. Much of this business is traditional, and much of it is online too - Melksham's thriving virtual community. And all of this activity, which brings jobs and prosperity to the area, needs stores and housing and schools and medical and other services and transport fit to support the business activity.

A new school to open in 2010 - the Melksham Oak Community School - is under construction. The site of the George Ward, which it replaces, is earmarked for replacement by additional housing, and some 750 new homes have been approved for the east of the town. That's in addition to recently completed expansions in areas such as Bowerhill. Expansion is set to continue, with the Regional Spatial Strategy planning growth of around 50% by 2016. The big stores who are coming to the town and expanding here know of these plans, and are thinking forward. Recent new medical centres, and the school changes, also look to the future. But in some other areas, work remains to be done. All road routes are already congested to the point of discouraging traffic at peak times, and the current train service to Melksham station are totally inappropriate for the needs of people travelling to and from the town and its businesses.

Melksham Chamber of Commerce and Industry exists to support the current, and future, needs of all businesses which operate in the town and surrounding area. From immediate issues and concerns, through training and networking programs and marketing of the town to planning for the future for businesses and the people who work for, and are customers of, those businesses. Many of our activities are such that a wider perspective is useful, and we're proud to be members of the Wessex Association of Chambers of Commerce.

We look forward to supporting your through Chamber activities in 2009 - to seeing you at events ranging from our meetings to Party in the Park and to the Council's budget meeting, to helping you with training and networking, or perhaps just to keeping you informed through our regular mailings of matters relevant to Melksham Businesses.

Upcoming diary events (Chamber and some others!)

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


Related topics: via article database

From spam to mod_alias - finding resources

Nine articles on Spam and seven articles on scams ... ninety eight resources that mention spam and twenty five resources that mention scams, out of over fourteen thousand resources on our web site. It's amazing how our site has grown over the years. Looking at some more technical, you'll find 52 resources that mention mod_rewrite (53 when I post this!) of which 17 are primary resources. Add 29 on mod_proxy, 21 on mod_jk, and a handful on mod_alias.

Resources aren't limited to text, either; I don't know what you'll see presented to the left of this block as it's just one random image out of thousands.

When I wrote my first blog jottings in the summer of 2004, I mused as to whether I would be able to keep it up - to some extent, I started because it was the fashionable thing to do, with little expectations that it would be running by that Christmas (178 resources), and with severe misgivings that it would be a flash(69 resources - it's a techie thing) in the pan. Yet it has kept going - why?

People don't just walk up Spa Road in Melksham huge number of resources), turn into our hotel (over 1000) and think "I'll go on a Lua Course today". They need to find us - and find us quite early, as we can be far more helpful as people initially learn than when they've been studying Lua (or Ruby or PHP) for a few months. And thus the technical resource that our web site has become.

Between 26th and 30th November last year (2008), our daily web traffic dropped by 50% - in just four days. From a log file of over 35 Mbytes to one that was less that 18 Mbytes. And I'm delighted. Because that was from a midweek peak to a weekend trough, it's part of a regular cycle that we see, and it confirms to me that a high proportion of our traffic is real, human visitors and furthermore that many of them visit us during their working week.

By 3rd and 4th December, our traffic was back over 35 Mbytes per day again, with hundreds of people (literally) finding pages such as the one on MySQL joins and reading about how to upload an image via a web page and store it in a database. Of these visitors, the majority won't be interested on coming on a public course, and the majority will in any case me from "far far away". Looking back at yesterday - a Sunday, which is an awful day to analyse, only 16000 out of 90000 impressions were sent out to UK based IP addresses. But it's sales and marketing and it helps people be aware of us.

Conventional marketing looks at "conversion rates" - the number of flyers that are sent out per sale made - and our rate is truly low. Let's face it, if you're looking for code to add a PRINT button to a web page or to resize an image to fit the browser window, you're unlikely to want to travel to a different continent and go on a course for the purpose when key facts are available to you. But you will rememeber - perhaps bookmark - the site and come back. And the conventional "conversion rate" measure isn't quite so important, since the cost per visit on the web is extremely low (I have issues with the Google AdWords 'pay per click' method of marketing and feel it's not well suited to our approach - we could easily spend a lot of money on low quality traffic because of our resource-lead approach!)

With good technical content being so critical on our site, it's also important that it's updated from time to time. Articles such as this one, with the data in it date related, clearly WILL age, and age gracefully, but some others need revisits and updates from time to time which is important but not urgent behind the scenes work. And the downtime over Christmas and the New Year - such is there significance that the cyclic access pattern breaks for a couple of weeks - is an excellent opportunity to do much of this work and also to put new, and underlying, algorithms for gathering popularity rankings and filtering material in place. And that's where I started with my counts of scams and spams ... and we are now making a tuned sitemap available to Google and Yahoo and others, telling them not only about the URLs that we would like to share with the world, but also giving them a relative ranking as far as we're concerned.

At the nuts and bolts level, lots of pages have been added / updated too - far, far too many to list - but I will encourage you to have a look through the following (and I'm fully aware that the "you" I may be addressing, deep in this post, is a search engine!). So - some new or refreshed pages that I haven't previously mentioned:

Quotation for Meeting and Training Room hire
Hotel FAQ
Command Central
Web site Visitor Maps
Bowerhill Quiz
Latest News
Portrait of training course author and presenter
An introduction to C
And an introduction to C++
Christmas Quiz
Phishing not fishing - identity theft and other scams
Melksham Resources

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


Related topics: via article database

January 04, 2009

Going round the block

Have you ever looked for a pattern in the roads where you live? Where to you end up if you turn alternately left, and right, and left, and right? Such is my mind that at times in the past (and now too, it seems!) I wonder about such things.

Out or our gate, right, left, right, left, right, left and I'll end up at the "bus gate" on the old A350 (Semington Road) right next door to the Police Divisional HQ where, I am told on the best of authority, they turn the camera on the bus gate at quiet times and catch a few motorists. I think I'll give the trip a miss.

I went "round the block" this evening. Yesterday after dark it was fearsomely cold and we had trouble starting the car (OK - *both* cars - how unlucky can you get?) so I wanted to get at least one running today and, having coaxed some life into Lisa's, I took it round the block. Doesn't sound very far, does it?

If you go our of our cul-de-sac and turn left, and left again, and ... keep turning left (but skipping all the dead ends), you soon realise just how much we are in the country ... several miles later, and I was still on the A365 Devizes Road and in Sells Green. Where I did NOT stop at The Three Magpies - always tempting, but I'm always going somewhere when I pass. And - at last - a left turn!

The sideroad leads over the track of the old Holt to Devizes Railway as the site, in a long-filled cutting, of Bromham and Rowde Halt. Although the station was in Sell's Green, such was the expected traffic from these other places - both several miles away - that the station was named after them.

Bromham is a s-p-r-e-a-d o-u-t village ... a pocket of rich soil and you'll find vegetable fields surrounding the village where other villages and towns in the area have fields of wheat and grass. It's so characteristic of the one place that you could drop me on a corner that I didn't know and I could say "this is Bromham". View stretch from Bromham to the flank of the Marlborough Downs - illustrated

An so onto the A3102 and back down Sandridge Hill, through Sandridge and in to Melksham at The Foresters. Another lovely, late afternoon run (though it was getting a little dark for pictures, so I'll admit to you that these are all images from my library today!

And so down Queensway, past the corner of Cowslip Mews (where I often wonder about the Cow's lip, and why they didn't call it Pigstail Close!), along Spa Road and into the Spa. Even on a day which is so brutal cold that even the cars didn't want to go out, we still live in a lovely county.

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


Related topics: via article database

Where is this IP address, IPv4 and IPv6

Do you want to know where in the world an IP address comes from? I often do and I've used a number of tools - but they tend to draw me fancy maps and lead me away from my page. So this morning I put together a cheap and cheerful "which country is this IP from?" script, using Maxmind Open Source Technology which just produces a little popup. Oh - and if you cut and paste an IP address with leading and / or trailing spaces into it, it actually works too.

Ask about ip: 

Have a play with it - it's IP6 aware too, so you can put in things like ::ffff:dc05:ca4b and find out what THAT means too!

I have coded in many (most?) of the special cases ... if you try IP addresses like ::1 or like 192.168.0.1 you should get sensible results - but please do let me know if you find anything that's not covered in IP terms. The Maxmind database is pretty darned good, but it is NOT guaranteed to get every IP address right, so if you put in your own IP address, seated in Bristol, and get told you're in France ... then chances are that you're using the connection of a French company and your packets hit the internet in Toulouse!

There's a permanent link to this utility on our front page which I invite you to bookmark and use. And you may wonder what the "distance" indicator is that sometimes comes up on your results. It's a very rough guess at the distance (in miles) that the IP address given is from our training centre, because I would love you to be remember our training courses ... we'll teach you how to write little toys like this one on our PHP techniques workshop, for example.

And for the more technical ...

IPv6 cases considered:

Full IP6 e.g. 65e1:763d:6652:1342:0725:4c65:1424
Shortened IP6 e.g. ::1a72:189 and 1234::17a3:712
IP4 mapped current e.g. ::ffff:64ed:54
IP4 mapped obsolete e.g. ::8c4b:430a
Teredo Tunneling: e.g. 2001:0::154a:19:a4
ORCHID: e.g. 2001:0013:64ec::879a:0:15
Documentation e.g. 2001:0db8:1342:0725::1a:74a0
Multicast e.g. ff75:7762::
Local, Managed e.g. fc05:8854:87::65
Local, Random e.g. fd76:638d:c737:83ab:552c:6509:65ab:817
Site-local (deprecated) e.g. fed5:7764:9a77::
Link-local e.g. feab:17:18:e745::65a
Unconfigured i.e. ::0
Loopback i.e. ::1

IPv4 cases considered:

Full IP4 address e.g. 83.170.95.163
Automatic private addresses e.g. 169.254.67.128
Local class A addresses e.g. 10.1.0.16
Local class B addresses e.g. 172.18.0.7
Local class C addresses e.g. 192.168.0.1
The local class C network we use e.g. 192.168.200.215
Loopback e.g. 127.0.0.1
Class D (multicast) e.g. 224.0.0.4
Class E (experimental) e.g. 246.86.55.164

And (though it's a bit of an aside), here's the Javascript and form that I've used on this page for the popup:

<script type="text/javascript">
function popUp(myURL) {
day = new Date(); id = day.getTime();
window.open('', id, 'height=308,width=250,scrollbars=1,
toolbar=0,location=0,statusbar=0,resizable=0,menubar=0');
myURL.target=id; return true; } </script>
 
<form method=GET action="/resources/iptool.html"
onSubmit="popUp(this)"> Ask about ip: <input name=ip
size=31 value="83.170.95.163"><input type=submit value=go!>
</form>

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


Related topics: via article database

January 03, 2009

Well House Manor Hotel - on plan for 2009 business guests

Three years ago, we were contemplating the "Well House Manor" project. An offer had been made on "The Old Manor" B&B with a view to turning it into delegate and businessman accommodation for our courses, and had been accepted. It was (at that stage) subject to the inevitably slow property sale cycle in the UK, and that was made more so that our purchase was conditional on planning permission being received to ... err ... do very little in fact! We needed planning consent to reclassify from "residential" to "business"; we had no plans to live at "The Manor" and that made the change necessary. The neighbours were suspicious, and we came to understand why once we learned fuller details of the proposals to develop the site that had been quietly submitted in a prior plan, and rejected.

As a sanity check for myself to make sure that all the jigsaw pieces would fall into place correctly, and as something that we could present as a business plan, I put together a provisional Well House Manor web site describing what we would be offering and how it would all fit. Three years later, and a log file from Google's crawler reminded me of the site, sitting there in some dusty corner. And that gave me a chance to see how close we are to our target.

Actually, we're remarkably close! Amazingly so! So let me just pick at the differences.

1. We had been considering continuing to run the training courses at the building that is now our HQ ... but the availability of two large, ground floor rooms at The Manor has lead us to run the courses there. A sensible move, as it means that the delegate don't have to traipse 800 yards up the road to class, it means that the phones of HQ don't disturb the course, and that we have our home back seeing as we also live at HQ!

2. Breakfasts are much more substantial that we proposed; we've added yoghurt, fresh fruit, hams, other meats and cheeses to the 'short' continental originally planned, and the orange and grapefruit juices are freshly squeezed by the customers - a nice touch that we came across as a realistic option just before we opened.

3. The cancellation terms we proposed seemed sensible, but in explaining them through to staff and potential customers we realised that we should go with something that was more of an industry norm. Leisure hotels tend to require considerable notice and apply heavy penaltys, whereas business hotels know that they need to allow for reasonably last minute changes of plan without scaring the would-be customers off from rebooking. So - although it can hurt occasionally - we allow cancellations right up to the day you're due to arrive, normally at no penalty. Regrettably, we DO have to say "normally" and reserve the right to charge, in order to prevent a tiny minority blocking rooms for possible rather than probable visits.

4. We've added an 0800 (freephone) number with a diversion capability so that the duty staff member can be reached, 24 x 7, wherever they are. And we've extended the range of credit and debit cards we accept to include American Express.

5. We took the opportunity of the VAT reduction last month to round down 2 of the three prices we quote to make it a neat 90 - 80 - 70 system (pounds, per night, double, single, and contract/delegate).

6. Checkout time is 11 a.m. rather than 10:30, and Saturday and Sunday breakfasts are from 8 to 10 rather that the 7 to 9 of the rest of the week.

7. My proposal to call the in-room information folder by the name RTFM was vetoed - and probably correctly. If it's not a term you've seen before, it stands for "Read The F***ing Manual" in the IT technical support business; it might well have puzzled those who were NOT 'in the know', and offended those without a sense of humour who did understand. And I will admit that the term could be regarded as putting customers down in a way I would not wish to do, even in jest.

8. We have mellowed a few policies. The "no walkins" rule still applies to new customers late at night, but we can (and do) take regulars late if they show up at the door, and we'll take new clients with appropriate ID even into the early evening. We don't shout our "no children, no smoking" policy quite so loud; many of our guests appreciate the effect of these policies, but it seems so negative to shout them from the rooftops. And - as planned - we do not have a Gideon's Bible in each room, and again that's not a policy we shout about. We do, though, offer a wide variety of reading materials in our library, which guests may take to their rooms if they wish.

There's a lot of other things that we've done as well as what we planned ... but those changes are the biggest. And in fact the web site was so close to being right, even now, and is search engine indexed, that I have elected to make those minor changes necessary (and the major change of tense!) and leave it up and running.

See the first single page here. See the site that followed it shortly here. And see the FAQ that I wrote as my nuts and bolts concept test here

The full, current Well House Manor site is here if you want to make a comparison, and if you want to book you can call that freephone number which is 0800 043 8225, or use our secure online booking system.

Notes - the picture at the top was (literally!) taken today - it's current. As is the news here which is another page that Google reminded me that I needed to update!

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


Related topics: via article database

Moving a directory on your web site

Apache httpd's mod_alias is part of your standard web server build ... it's the part that allows you to put alias directives into your configuration file httpd.conf to that different parts of your web tree can reside on different parts of your computer's file system. As an example, the manual that's supplied with Apache httpd will be usually be found in /usr/local/apache2/manual rather than somewhere like /home/website/htdocs/manual, and an alias command will be used to cause any requests to be served appropriately.

Mod_alias has other uses too. The Redirect directive lets you give the server that requests for a particular URL are to be passed back to the browser with a note that the file in now to be found in a new location. This uses a location header, and you can set up the redirect to be temporary or permanent.

If you have retired a whole directory of URLs and want to have any remaining request that are made for resources in it to be passed on, you can use a redirectMatch ... for example:
  RedirectMatch 301 ^/modules(/.*) http://www.wellho.net/resources$1

This example is from the .htaccess file within the /modules directory on our server, and it refers all requests to the /resources directory (where they should have pointed in the first place!). So if you type http://www.wellho.net/modules/H999.html into your URL bar, you'll see that you get the page http://www.wellho.net/resources/H999.html instead, the URL bar is changed (usually - it's browser specific), and the same rule applies to any other URLs in that directory.

The complete .htaccess file, engineered to deal with mod_rewrite issues and more fully commented, is available for your use. And we would love to teach you more httpd deployment techniques on our Linux Web Server course.

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


Related topics: via article database

Required Request

Required Request ... that medical / legal term that requires hospital teams to ask if the body of a newly deceased person is available for transplant. It sounds ghoulish, but without "required request", the clinical team doesn't like to ask and the family is too distraught to even think about it ... until it's too late and say "I wish we could have helped / if only we had known / little Billy would have wanted it".

This morning, we have a new page in our hotel's guest book. We have a lovely morning, and a fresh year. And we had a couple of guests checking out who seemed (as most do) more than happy with the service we had provided. I could have simply let them walk out, leaving the page still new - but instead I took a deep breath and invite them to sign the visitor's book which they were more that happy to do!.

Leisure guests WILL sign a guest book ... business visitors are less inclined to do so. But I'll be asking Lisa to add a box onto the checkout form that says "invited to sign guestbook", and letting everyone know that it's a requirement (a rule) to ensure that all departing guests know they're welcome to sign.

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


Related topics: via article database

Pettifog and forum boards away from public view

I looked up the word "pettifog" online ... and found the definition "To act like a pettifogger" here. Hmmm - I don't want to get too heated about this, but have you ever seen such a useless definition. And an ironic one too - because to Pettifog means to argue or quibble or grumble or carp over something that might not be too serious. Yes, I'm pettifogging about the definition of pettifog.

Why was I looking up the word in the first place? Because I've always liked it since I saw it introduced for a members-only board on the UK-Yankee forum where I used to post regularly and do some moderation. And I felt it might be apt for a new indexing tag for some of my posts - the pedantics and the rants that I allow myself the luxury of posting occasionally. The jury's out on that one - I'm polling the views of other members of the Well House team as to whether or not such things should be gathered in one place when I'm fully aware that I've indulged in a bit of mud slinging now and then, that mud always sticks, and it's probably not terribly good marketing to cluster it all in one package.

Should every forum have a "Pettifog" area, which is restricted in its access? Why not simply allow material / comment up to a certain point, then at that point say that "enough is enough"? There's a lot of mileage to be had for an area in which potential developments can be discussed, kites flown without fear of them getting caught in a storm, stronger views expressed that should not be in the public domain. And, regrettably, there's sometimes a need to have the more argumentative areas of a forum accessed only over a hurdle that's high enough to make it less that worthwhile for trouble makers to get over it ... to avoid your forum becoming the home of those people who aren't interested in the actual topics covered, but just in arguing! So I'm very much in favour of such an area on most forums.

How do you restrict your Pettifog area?

First question - do you even let guests know that it exists? In reality, you can't prevent word getting out even if you keep it off the menus, and it's probably not worth trying to keep it secret - someone will mention it, and nearly all regular users of any forum will in any case be aware of such board, and perhaps even at different levels.

Second question - who can post to your Pettifog board? Do you make it writeable to anyone who's a member? To members who have passed a threshold number of posts? To members who are invited by other more senior members or by the admin team? And if by invite or the admin team, how do you keep the qualification fair and open?

Third question - who can read Pettifog? Almost inevitably, not guests. Nor (probably) new members, as that would encourage people to sign up just to read the board. But there is an argument for allowing members to read at a slightly lower threshold than they need to post.

The wider subject of restricted boards is one that every forum provider needs to consider. As well as a "Pettifog" area, you may choose to have other areas which are limited in different ways - "children's club" for younger members only (if your board accepts under 18 sign ups - a whole other issue), "fat club" for members who are working together to loose weight, and a moderator and administrator's discussion area where the team that helps the owner keep a watchful eye on the happenings on the board, in private. The presence of this latter board sometimes causes negative concern amongst the more mouthy members (a good pettifog subject!) but it does provide a logical and quick way for the operations team to decide whether a thread should be split into two, if the word "shit" is to be allowed in a particular context, and to alert one another of a suspicion that two members are perhaps one and the same person under different aliases. And this moderator's board allows these discussions to be inclusive, and decisions co-ordinated.

Although I'm not shouting about this on the main forum at the First Great Western Coffeshop, I'm going to use it as a brief case study example.

We have four levels of board.

1. Most boards are public readable, and writeable by any member who is signed in.

All new membership applications need to be approved by the administrator, a step that is regrettably necessary to stop signups that are made purely to post off topic adverts, to message all your members, or to create a second "persona" for one individual.

2. Our "Frequent Posters Club" is readable and writeable by any signed in member with a certain (quite low) threshold of posts to his / her name.

3. "Behind the Counter" is an area where administrators and moderators discuss issues out of the public gaze - mainly problems that have come up, and ideas for future development and "beacon" posts.

Our administrators are the technocrats who know how the board works and can fix operational problems with databases, etc; they do not necessarily understand the detail of the subjects under discussion, but they are a safe pair of hands with the ultimate authority. The moderators are a group of subject experts, respected for their knowledge, and their calm and fair approach. Most moderators are quite active in their own posting, but we have several respected "elder statesmen" in the group who's circumstances mean they're no longer around very often, but who's inputs we greatly value.

4. There's also a "Deleted Posts" board which only the administrators know about. It's virtually never even looked it - it simply retains a history of material that we've had to take down for one reason or another, with the purpose of allowing the admins to check back if they come across something which "looks awfully familiar ..."

Traffic is heavily concentrated on the public boards - of over 1600 posts made last month, none at all are in the deleted area, a dozen or so in "behind the counter", and less that a hundred in the "frequent poster's club". It's actually a good achievement that the most restricted of the areas is so quiet - that's not a target in itself, but rather an indication that we're not having to manage the boards to the extent of having to over manage them.

Of just over 450 members, just under 150 are qualified to post in the "Frequent Poster's club"; as a forum where many people come initially because they want to rant (pettifog!) against a certain train operator, we do expect to find a proportion of our members who are "one topic wonders", and that's fine by us.

In fact, the whole requirement for the forum in the first instance was to give a voice to customers who weren't happy to just go along with things as they were - at the least, they wanted to be able to find out a bit more by asking "why?", and many wanted a chance to express their views or rant a little. Which means that if the issues that our board was set up to help address actually ARE addressed, we might be working ourselves out of a role.

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


Related topics: via article database

January 02, 2009

Telling Google which country your business trades in

I have a solution the the question I asked last September - which country do the search engines think we are in?. It seems that Google takes the top level domain name if it's geographic ... and otherwise it uses the IP address of the server to give it guidance. But there's another was of tuning this, which is in the webmaster tools. See here. However, Google's page tells us that this only effects ranking on advanced searches where the user calls up for certain countries only.

Up until Summer, 2008 our server was located in the USA and our top level domain - .net - gave no clue that we were primarily UK / European. At a move of server (we needed to be on a dedicated server anyway with our traffic levels and need for flexibility), we chose a hosting company who have their computers in London, partly to get fast local responses with the trans Atlantic lag and partly to appear to be in the UK. And it was noticeable that the proportion of UK:USA traffic changed, and in the right direction too.

As a further (final) stage, we've altered that Google setting ... and I'm glad that we've solved something that was quite tricky to find the answers on!

Diagram shows where current traffic to our web site originates from. See source code and resultant graphic from our example of visits from Europe. Subject covered on our PHP techniques workshop

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


Related topics: via article database

Plagarism - who is copying my pages?

Page copy protected against web site content infringement by Copyscape I came across a little banner like this one when I was doing some gentle browsing this morning, and (as I'm interested in this whole copying of content / plagiarism business!) followed the link. Turns out to be a rather nice little engine which you can give one of your own URLs and have return a page of links where text that is - err - remarkably similar - may be found. The site is at www.copyscape.com

Giving it "a whirl", I'm surprised (and slightly flattered and slightly scared) to have found quite a few copies of things out there. The first page I tried - my article on Python threads - came on on four other sites, including one from a cheeky chappy who had posted it as if it was his own, but he was asking for forum help as it wouldn't work for him. He had only gone and named it after a standard Python module - which is actually an easy enough mistake to make and a hard one to spot, but he's not got too much sympathy from me. I wrote as follows:

xXxxxxx,

I'm flattered ... the code you've posted here comes straight off my own website ... now why didn't you ask me when it wouldn't work for you?

You'll find a full page describing the application [here] and you'll note that I've called the two examples of that page alive and kicking so that they don't get confused with standard modules.

The second page I tried - my explanation of MySQL joins and left joins also came up on four other pages ... including some blog articles from people who really should know better. I'm NOT going to give them the oxygen of publicity by giving you links here, and I feel slightly cheated that some of them are letting the reader assume that they're the original author.

I tried a third page - my one on linking three or more tables and once again a screen full of possible copies. Some of the copies are of the complete article, others just of snippets of the code ... but never the less, rather naughty. To one person, I penned the following:

Sxxxxx, that three way join looks very familiar to me - in fact identical to the one that I wrote at http://www.wellho.net/solutions/mysql-left-joins-to-link-three-or-more-tables.html .

They say "imitation is the sincerest form of flattery", so thank you for using it. And I'm happy for you to keep it there if you'll just add a link back to my site. Many Thanks.

I tried the engine out on another page - something rather more obscure called Clean my plate but keep my wine bottle, but I got an message that told me The maximum of 5 searches per month has been reached for this site. For more searches, please sign up for a Premium account. That's fair enough, I guess - I had been wondering how their financial model worked. Should I wish to, I do have a work-around which I don't think they would want me to publish, but I have been able to re-assure myself that the copying doesn't go right down my site!


As a footnote, pages on the http://www.wellho.net site are protected by the copyright statement that's here. There's a plain English precise of it there too, which says:

This means that if you like one of our pictures or descriptions, you may NOT simply take a copy of it and place it on your web site, nor may you add anything to your web page which brings up one of our pictures within your page, and makes it look like your own work. To take our material in such a way without asking us is theft.

However we do like our pictures to be widely seen and we encourage you to ask if you can use them - we'll usually say "yes" provided that you provide a credit / link. See www.wellho.info if you would like more details.

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


Related topics: via article database

January 01, 2009

Search Engines. Getting the right pages seen.

"I've been visited by a robot - what do I do about it?" I chuckled at the question when I came across it yesterday when looking up the Robots Exclusion Standard ("also known as the Robots Exclusion Protocol"). The answer given was "do nothing" and I would agree - almost. Or I might suggest "Celebrate".

Why do we want search engines and other robots to visit us?

It's no good having the best web site in the world ... the most authoritative information on Druids Lodge and Ratfyn Junction ... the most easily understood explanation of a left join (as opposed to a join) ... the best value Linux courses in Melksham ... your excellent picture of a sliced orange or unique illustration of Balloons at Beach ... if no-one can find it!.

You put links in, of course, as you write and update your site but - let's face it - the web is a huge place, and the chance of someone who's looking for "mood" pictures of California stumbling across reading your blog and finding this page is pretty slim ... unless they're helped. And that's where the search engine robots come in.

The Search Engine Robots are automated programs that read a page from your web site, and store in their indexes the keywords and other data from that page. Then they follow the links on that page, and do the same with the pages that they find there. And then the next level of pages. And so on. Thus building up a map of your site. [Technical notes - they have special mechanisms in place to avoid re-checking the same pages too often, and to avoid making so many requests all at once that they effect your web server's performance].

Once a search engine has started to map your page, it will start to offer them in search results where it sees that they are appropriate. And there's your gain from having the robotic search engine visiting lots of your pages to the extent that it's a significant part of your traffic (our robot traffic is around 40%; I have heard others quote as high as 90%!).

How do I tell search engines where to go?

Remember my "do nothing but celebrate" statement? Well - there's something of the same answer for you here. Provided that you pages are all linked in, on a straightforward web site you'll find that the search engines do a pretty good job of finding the pages, and since it is in their interests as well as yours to present relevant results both you and them are working to the same goal - automatically.

But you can help them along somewhat if you want.

Firstly, there may be pages that you do NOT want them to index - they shouldn't follow that link to your private staff area (which in any case requires a login to see staff-critical stuff, right?), and there's little point in them following all the colour and font size changes that you have on every page. You can instruct well behaved robots to avoid certain places through the robots exclusion protocol - provide a URL (almost inevitably a plain file) on your site with the name /robots.txt for this purpose. Here is the "meat" of our file:

User-agent: *
Disallow: /cgi-bin/
Disallow: /net/unique.html
Disallow: /happens/
Disallow: /resources/mywellho.html
Disallow: /net/search.php4

And it excludes all well behaved robots / search bots / crawlers / spiders from certain places. I have placed a commented version of our robots.txt file in our Web Site Structure resources index. You can read more about the file format and use here, and there's a file checker here which lets you validate yours.

A second way to tell the search engines where they may go is to provide them with a sitemap file. Google accepts a number of site map formats - the easiest is probably a plain text file, but others such as the sitemaps protocol allow you to provide some extra information, and are re-useable across a number of search engines. Here are some sample records from a sitemap file:

<url>
<loc>http://www.wellho.net/resources/P668.html</loc>
<lastmod>2008-12-25</lastmod>
<priority>0.808</priority>
<changefreq>weekly</changefreq>
</url>

<url>
<loc>http://www.wellho.net/pix/mcem02.jpg</loc>
<lastmod>2008-08-15</lastmod>
<priority>0.383</priority>
<changefreq>yearly</changefreq>
</url>

Google - the largest search engine but by no means the only one - state that they do not use the sitemap to prioritise your site over someone else's but they DO use it as a helpful crawling map, and they do take note of your priority values when selecting which of your pages to offer to visitors.

There are tools to help you generate your own site map, and there's a sitemap checking tool available too. As I want to skew priorities on our own site and have an adaptive system that provides much extra information, I've chosen to experiment away from the tools. You'll find the full sitemap easily enough if you look in the usual places - or you can have a play with the human readable demo form that I've been using in testing here.

Search Engine Optimisation

This is another huge subject - and it's one that a great deal of time and money is thrown at. The sitemap and robots.txt files simply give the search engines guidance within your own site - but you'll want to have them offer your site in preference to others.

Some suggestions / ideas that work:
a) Provide plenty of good content
b) Write your site in good, clean HTML
c) Have lots of links internally and externally
d) Keep content changing, but not *too* often
e) Get lots of people to link in to you too
f) Get listed in lots of good places
g) Use keywords in the URLs and have a good site name

Some things that you should avoid:
a) having the same page appear under lots of different URLs
b) adding "search engine fodder" text in white on white
c) providing different pages to the search engine than to your user
d) having useful content that can only be accessed via cookies
e) copying text of other people's sites to bolster your content

It's not just a question of "how high can I get my rank", but "how can I get my rank high for the appropriate visitor". As an example of what I mean, our site provides a huge resource range that's useful the world over BUT I want my resources to be especially highly ranked for visitors for whom a trip to Melksham is feasible. With s top level domain of ".net" because we're NOT purely a UK company, and a service hosted in California, this wasn't working too well this time last year. A server move to a UK based host, though, has left our traffic levels static but increased the number of UK based IP addresses visiting us, at the expense of other countries.

What about other robots?

I started this article talking about robots in general, and then moved on to talking about search engines specifically. What other bots are there?

A lot of them are specialised search engines - ranging from specific industry tools to others such as the Turn it in bot which crawls the world indexing texts so that the company running it can sell their services to academic establishments who want to check for plagiarism.

With some of these more obscure search "bots", there are questions as to whether it's really worth the bandwidth in allowing them through - and indeed if a "bot" such as Turnitin grabs 4000 pages of your site one day, it could be at the expense of performance, at cost to your pocket, just to help those commercial people at "turnitin" make a bit more money. See further discussion on this and add something like

User-agent: TurnitinBot
Disallow: /

to your robots.txt to ban a specific robot (but a well behaved one with regards to it using the file).

There are some very nasty spiders / robots around too. The same technology can be used to crawl the web and harvest email addresses for spam mailing lists, and to look for holes in your web site. See more about those nasty programs and how you can sanitise your applications against them. Regrettably, by their very nature they won't respect your robots.txt and may even make use of it to find out which directories you would rather not have crawled!

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


Related topics: via article database