« October 2006 | Main | December 2006 »
November 30, 2006
Plain Ole nice pictures
It's a while since I put up some really nice pictures, for the sake of being picture. So here are three taken this week - daytime Tuesday, evening Wednesday and dawn Thursday. Locations are Swindon, Bath and Melksham.



Posted by gje at 02:56 PM | Comments (0)
More about Graham Ellis of Well House ConsultantsImproving the historic town of Melksham
On Tuesday night, we went along to the presentation by Melksham First of their design study for improving the environment in the town centre. Melksham's a lovely town - we've been saying that for years - but with a number of eyesores. There's a few things that could be improved at little cost, others that would be rather more expensive, and further ones that would need planning changes and the like.
The meeting was packed, the presentation impressive, and the spirit animated, good and broadly forward looking. I question the base criteria that the fabric and appearance should be looked at in isolation from other aspects, such as access routes in and parking. If (for example) Church Street Car park had more green areas, then where would people park? And how will the town handle the extra influx of people looking at our beautiful buildings (and they are!) and indeed just the extra local people as the town grows a further 20% to 40% over the next 40 years? I wasn't called on to speak at the meeting although I indicated an interest in doing so - that's fair enough at such a crowded event, so I have dropped the organiser a note to express my reservation.
In other words .... how great to welcome Melksham visitors to

Canon's Square, Melksham
rather than to

King's Street car park, Melksham
Links:
Melksham Hotel
Melksham Town
Posted by gje at 08:26 AM | Comments (0)
Python security - trouble with input
The danger of Python's input function - also known as giving away your secrets to your user.
If you're writing a Python program and asking your user for input, you should always use the raw_input function and never input. Why? Because what you type to input is interpretted through an expression and the result is saved into your target variable ... so not only does input assume that your user knows Python syntax, but it also opens some great little security holes.
Look at this program.
Something = "your toes"
Secret = "I have ten of them"
value = input("Please enter your age ")
print "You are",value,
print "and you have a secret about",Something
And look how easy it is to find out all the variables that are used inthe program, and their contents:
earth-wind-and-fire$ python dain
Please enter your age dir()
You are ['Secret', 'Something', '__builtins__', '__doc__', '__file__', '__name__'] and you have a secret about your toes
earth-wind-and-fire:$ python dain
Please enter your age Secret
You are I have ten of them and you have a secret about your toes
earth-wind-and-fire:$
First run ... find out what all the defined variables are called. Second run ... start reading those variables. Ouch!
Posted by gje at 07:53 AM | Comments (0)
Useful link: Python training
November 29, 2006
Python collections - mutable and imutable
Should you use a list or a tuple ... or perhaps a dictionary to store a collection of objects in your Python program? To help you make the decision, think whether you need to be able to modify the collection after you've created it (mutable) or not (immutable), and whether you want it to be indexed in order, or not.
Those two answers should lead to your collection type:
| Unordered | Ordered | |
|---|---|---|
| Mutable | Dictionary { and } | List [ and ] |
| Immutable | n/a | Tuple ( and ) |
If you want an immutable unordered collection (the empty box in my table), use a dictionary. And when you're initially creating the collection, use ( ), [ ] or { } as shown in the table. Always use [ and ] to reference member elements after the initial creation - Python does it like that to render any code you write polymorphic ... i.e. to be common code that will work whatever the collection type.
Posted by gje at 05:15 PM | Comments (0)
Useful link: Python training
Splitting Pythons in Bradford
Python supports two split functions methods to explode a string into a list of substrings. There's one in the default class that works on a string, and there's another in the re (Regular Expression) class.
Splitting at a string works very will if you've got a fixed delimiter, typically in a machine generated file of data. You write
inputstring.split(separator)
however, with data that's entered by a user and may well contain multiple spaces as the separator, you would be better advised to write
regex.split(inputstring)
and, yes, the parameters are indeed the other way around.
Here's the result of splitting an address which had multiple spaces in in between the company hame and town, using the string and re classes:
['Techsputer', 'Training,', '', 'Bradford', 'on', 'Avon']
['Techsputer', 'Training,', 'Bradford', 'on', 'Avon']
and you can see the full source code here
Posted by gje at 11:45 AM | Comments (0)
Useful link: Python training
Christmas in November
Does Christmas come earlier each year? Melksham's Christmas lights are up! To be fair, they were just testing them last night when I took this sneak preview, and they won't be switched on until Santa comes on 2nd December. Come to think of it ... that's only a few days away!
Posted by gje at 08:36 AM | Comments (0)
November 28, 2006
Coming from London to Melksham by train for a course
If you're travelling by train to a Well House Consultants course, we can meet you off the 19:08 arrival (Mondays to Fridays) from Swindon, which has a connection leaving London Paddington at 17:30.
If your course starts on a Monday, a train leaves Paddington at 18:00 on Sunday evening and arrives in Melksham (change at Westbury) at 19:51. There is also a later train on Sunday evenings. Please check Sunday times with the train operator, as engineering works at weekends frequently lead to schedule changes, diversions and bus substitutions.
For delegates who live near Paddington station, the early train at 07:00 will get you to Chippenham at 08:15, which gives you ample time to reach Well House Manor by taxi (approx 6 miles) for your 09:00 course start.
At the end of your course, we can help with arrangements for you to get home. We can drop you off at Melksham station for the 19:08 or 19:35 departures, or arrange a taxi to take you to Chippenham to catch the 17:55 train to London.
Some delegates prefer to stay over an extra night ... we can provide you with an early breakfast and give you a lift to Melksham station for the 07:17 train on Monday to Friday, connecting into the London train at Swindon. You'll be scheduled to arrive in Paddington at 09:00. This morning service runs 2 hours later on a Saturday.
Over the past five years, around 40% of our customers have arrived and left by public transport. Although we have plenty of parking and good car access, you don't need a vehicle if you're on one of our courses. We also have covered garage parking for cycles and motor cycles, and welcome delegates coming on two wheels.

Melksham to Paddington train service, weekdays from 11.12.06

Paddington to Melksham train service, weekdays from 11.12.06
Posted by gje at 06:42 AM | Comments (0)
What happened at Geekmas
A big "Thank You" to everyone who came along to Geekmas over the weeken - a good time, a great night at the hotel, and a fantastic curry had by all!
Code quality, testing and mantainability turned out to be a major theme that ran through the weekend - with topics ranging from Rasmus Lerdorf's 4 layer PHP model through the doctest module in Python - and that's a pretty wide range.
The scheme for a campaining web site (Neuroblastoma) that I posted up here yesterday was something that we worked out on the tail end of Sunday, and I wish Dan all the best with his work on that site.
Even with Melksham loosing all its useful trains in a couple of weeks, a half of the people who stayed overnight actually arrived by rail. Alas, the train turned into a bus (again) for their Sunday return journey ... and in two weeks time there won't even be a daytime Sunday bus to Chippenham and Swindon
People travelled from the South Coast, from the Netherlands, and from London and Harrogate to attend (and that is NOT intended to be a complete list!). We were also delighted to welcome the partner of one of the originators of HTML, who worked alongside Tim Berners-Lee at Cern. A really interesing insite into the life and times around then; and I'm not name-dropping to respect privacy.
We've intentionally got cycle and motor cycle space, under cover, at Well House Manor and indeed we welcomed one of our delegates as our first cycling guest. He happened to be collapsible (you know what I mean!) but I'm cheerfully saying "yes, that' a sensible provision" to myself.
Do we do Geekmas again next year? Yes - we probably do, although there are elements of it that are starting to happen year and weekend round ... technical people in at other weekends, and all that sort of thing.
In fact, Bruce and Lika have invited us all to come down to New Milton (I think he said tents in the garden as he doesn't have a hotel like us ;-) and I understand that Lika makes an excellent Lamb Shaslik. Just don't tell my friends on the left!
Posted by gje at 12:23 AM | Comments (0)
November 27, 2006
Python and the Magic Roundabout
I'm giving a Python course in Swindon today and tomorrow, and my group of seasoned programmers were concerned (that's putting it politely) that blocks of code in Python are inset, rather than being written between a { and a } as happens in most other languages.
Have you come across the Magic Roundabout, formerly the County Ground Roundabout? It's a cluster - five smaller roundabouts around a central core. And it works very well - very well indeed. And yet ... it worries newcomers to Swindon. Us regulars take more care that usual of other drivers in that area, but never the less get through it quickly and easily.
Chatting with my Swindon Residents, I've learnt how they were concerned and worried about the Magic Roundabout when they moved to the town, but how they now treat it with a degree of loving care and are proud of it. And I was able to reassure them that they'll get to feel just the same way about embedded blocks in Python.
Posted by gje at 06:35 PM | Comments (0)
Useful link: Python training
Sludge off the mountain, and Python and PHP
Is Python 2.3 compatible with version 2.2? How about PHP 5.1 with PHP 4.4?
In an ideal world, the answer to every such compatability question would be "yes, it is" but it's not always quite that simple. Python's upwards compatability is excellent - as a language, it was designed for the purpose for which it's used to this day, and it's not overburdened with facilities, especially redundant ones, that make onward extension awkward. PHP, alas, started as "Personal Home Pages: and has grown to something much more powerful ... meaning that a few of the (then excellent) early decisions have had to be revisited and there have been a few compatability issues - sometimes solved via the php.ini configuration file. (register_globals and magic_quotes come to mind ...).
However, there's always the exception to disprove the rule ... and I've been talking about Python compatability today, and how the "yield" keyword was added for generators. "That would only be a problem if you happened to have a variable of that name" says I. "We do, quite often" says one of my trainees. "We're very often forcasting the yield of sludge running off a mountain in wet weather"
Posted by gje at 06:28 PM | Comments (0)
Useful links: Python training, PHP training
Running an on line campaign
One of the topics that came up over Geekmas (about which I could post a lot more!) was the running of a successful on line campaign.
Ah - now I will be the first to admit that our "Save the Train" campaign has NOT been 100% successful in that we haven't acheived our ultimate goal of saving the train (always knew it was something that we had a very limited chance with only) but never the less we've got huge interest, huge exposure, questions being asked at Westminster, local press looking to us for answers on anything train related, MP wannabes and present and other senior politicians on side. So we have had quite an element of success.
So - talking with Dan yesterday concerning a new / revamped web site to provide support and help, and to campaign for recognition, for Neuroblastoma - a rare and usually fatal childhood cancer - I felt we could offer some pointers. Some "do as we did" and others "we could have done this better". What did we come up with?
A Dynamic front page - one that changes, at least in pictures, every day or two - make it more interesting for people coming back. Page to include:
- A Message of the day / stop press box
- Common navigation to 5 to 10 top topcs
- Date and time that the page was accessed
- Contact details so that people can get support or give money
A handful of pages on background topics - most of the 5 to 10 pages that I've described in the paragraph above, most with dynamic pictures, all with the stoppress box. "What is Neuroblastoma". "Where can I get more information", "Where can I get support", "How Can I help?". AND ALSO ... a search and naviage the forum page, via .html URLs so that it becomes a growing resources written by the people with the most experience - those going through Neuroblastoma.
A forum - an area for anyone to read, and for people (once registered) to chat and contribute. KISS - Keep it Simple, Stupid. Just half a dozen different areas and not a frightening array.
- Notices
- Introduce and chat
- Technical issues on Neuroblastoma
- Neuroblastoma help and support
- fundraising, meetings and calendar
- Help and support on the use of this board.
Blog feeds page - a lot of people with children going through Neuroblastoma write blogs - keep a page of feeds of some top current blogs on the topic. Probably don't host the blogs on the site, as you want to be able to gently skip pass by a feed if the author is in such a crisis point that they've stopped writing for a few days.
Mailing list and Paypal contribute pages Discussion here on how frequently to mail people (max 6 times a year?) and how much personal information to ask for. Delicate topic but so useful for targetted support.
What's the URL, I hear you ask! Well - Dan will be registering a new one and I'll come back and tell you what that is later. For the moment, have a look here and here. Both of these domains will compliment the new one, with (planned) many crosslinks to that they'll help each other in ranking, traffic, and in the support they can offer.
Good luck, Dan - I hope this "brain dump" of mine from yesterday afternoon helps you. And good luck in your Marathon run too.
Posted by gje at 07:44 AM | Comments (0)
What is an SQL injection attack?
An SQL injection attack is where a user of your form enters a piece of SQL code into it, and wraps it in special characters in such a way that the data entered doesn't get used for the purpose you had intended - it gets used to corrupt or destroy your database.
For example, if your form returns to $_REQUEST[message] and you write
INSERT into msgtab (message) values ("$_REQUEST[message]")
in your code, then without the appropriate precautions I could enter
Got you"); delete his database;
or words to that effect ... and that would be a nasty injection attack.
Note that most copies of PHP are configured with magic quotes on to insure against this kind of hole being left by newcomers to coding, and that my example - quite intentionally - doesn't exactly attack; rather, it shows the principle
As well as SQL injection attacks, Javascript can be injected too ... and even tags like <h1> can sometimes be injected to make the whole of the rest of a response page be shouted back at subsequent visitors to (say) a poorly written forum or chatroom.
Posted by gje at 06:01 AM | Comments (0)
November 26, 2006
Look around this mouth.
What have these in common? Alton Barnes, Cherhill, Devizes, Hackpen Hill, Marlborough, Uffington, Westbury and York. Need another clue? Add Cerne Abbas, Dunstable and Fovant in the same genre.
And there's another clue in the title.
You've probably got it quite quickly .... and here are some links that you can follow to confirm:
Alton Barnes
Cherhill
Devizes
Hackpen Hills
Westbury
Posted by gje at 08:04 AM | Comments (0)
Code quality counts
We're celebrating Geekmas this weekend ... and we've got a full place. Plus others who are coming in for the day. Really good session yesterday on the good DESIGN of an interactive (scripted) web site that "mines" user information to give a tailored presentation, and a great intro by Paddy to Python's doctest module which I'll be pushing rather more on courses that are coming up. Over all, the theme of the day was application and code robustness, testing maintainability and shere quality - utterly important topics which can so easily be overlooked in the mad rush to get anything working.
Posted by gje at 07:41 AM | Comments (0)
November 25, 2006
Just ******* Google it
"Can you tell me the email address of the butterfly expert Mr Jxxxx Bxxxxxxx?"
"What is the history of the bridge over the river Avon In Malmesbury"
"Please supply me with details of the Xxxxxx retirement home in Bromham"
Some of the recent requests that I've received in my email, along with the more regular ones that I expect to get on Open Source programming, local train services, and hotels. I came across this site - here - this morning, and it brought a wry smile to my face. Actually, I'll continue to answer such questions as the ones above as I receive them, the the best of my ability in a minute of two - a favour done is a piece of networking and can be returned a thousand times over. But I will continue to refuse, as I did earlier this week, to take several hours to travel our of the county and tramp around a churchyard looking for a grave. I'm sure the local vicar is much more qualified to do that sort of thing.
Posted by gje at 07:12 AM | Comments (0)
Matching within multiline strings, and ignoring case in regular expressions
Regular Expressions are powerful matching tools and you can specify almost anything within them. But there are certain facilities that are naturally applied to the regular expression as a whole rather than to parts of the match, and there are specified in a different way in each language / implementation.
For example, in what is commonly known as multiline mode you may want to match not only at the start / end of the string as a whole, but also match at embedded new lines. You can specify multiline mode as follows:
In Tcl, using the -lineanchor option
In Perl, with the /m modifier on the end of your regex
In Python by adding re.M or re.MULTILINE to your compile
Here's an example, in Tcl, looking for embedded lined containing just ABC:
set samples [list "Hello world\nABC\nThis matches" \
"Another test\nABCD\nNo match" ]
foreach sample $samples {
puts [regexp -lineanchor {^ABC$} $sample]
}
ther facilities often added onto your regular expression as modifiers include:
a) The ability to have "." (the dot) match any character at all, and not to exclude the newline character which it does by default. Sometimes known as single line of linestop mode.
In Tcl, leave off the -linestop option
In Perl, add /s
In python, add re.DOTALL onto the compile
b) The ability to ignore case in the match
In Perl, /i
In Python, re.I or re.IGNORECASE
In Tcl, use (?i through ) in the regex
c) The ability to add white space as comments into your expression
In Perl, /x
In Python, re.VERBOSE
In Tcl, use (?X through ) in the regex
Posted by gje at 05:48 AM | Comments (0)
November 24, 2006
Index of Pictures
Over the last year or so, we've accumulated a very large number of pictures on this site and in the last 6 months or so they've gradually found their way into the MySQL database of images that we have in the background. With some 1000 of the 1500 being labelled up with descriptors, why not make them searchable? Well - I've done so and put them all at appropriate URLs too - mod_rewrite can do some wonderful things.
So have a look at http://www.wellho.net/pictures/Melksham.html which is also http://www.wellho.net/demo/picclim.php?look4=Melksham and search from there.
Posted by gje at 01:39 PM | Comments (0)
Snagging
Here we are, some 7 weeks after opening and we've still got a few "snags" on the electrics ... it seems that the ground here is a bit damp, and the uplighters are getting submerged, so there's some work to be redone. Ah, yes, you have to expect odd snags like that and for the majority of the works I would recommend / use the same people again.
I think what worries me about the lights (and the fire alarm system too, which is another story) is that we were assured it was an easy job. When problems occurred, the finger was pointed at us for running over the lights (all 11 of them???) with a heavy lorry. Then when we had disproved that, it was put down to a minor wiring error. Now it's something more serious. I would much, much rather have been told the truth in the first place, and I would much rather have had the contractor admit what the problems were than passing the blame to us. It leaves me wondering now if this third reason given is the real one. Or if there's something else even more fundamental. It also leaves my worried that - a week after they failed, with electricians still here as I write, what we'll do on any subsequent failure - if it takes THEM all this time to track down an issue, what chance have we once they're away?
But, these are small trials. By the very nature of this stage of a project, some 99.5% of the work is completed, completed to a high standard, and working and running. Alas, it's just the 0.5% that continues to be noticed and irritate.
Let's have a great Geekmas, everyone!
Posted by gje at 09:29 AM | Comments (0)
November 23, 2006
Winter at Well House Manor - Open Houses
Now that we've got a month or two's experience under our belts, we can't wait to show our geek friends, neighbours, and business contacts what we have to offer at Well House Manor - so we've got a series of free, open events coming up.
For Technical folks - the Geeks we have Geekmas on Saturday and Sunday 25th and 26th November. A free technical weekend - everything from Perl to Python, from Apache to Tcl - and a look around the hotel, an Indian meal, and a chance to meet old friends and new.
For our neighbours, we're having mulled wine and mine pies, late afternoon and early evening on 19th December - we'll be dropping invites through the doors of those closest to us, but if you find this page and want to come, please let me know.
For local businesses, Cheese and Wine is in the afternoon and evening of Monday, 29th January 2007 - have a look at our facilities so that you'll know if we match that special need you have for a hotel room, or that extra meeting room equipped with floor to ceiling whiteboards.
If you want to meet other businesses, we're hosting a Federation of Small Businesses Networking evening on 20th April 2007. That one can't be free - it'll be 9 pounds a head - but you'll get snacks, soft drinks, a complimentary glass of wine and a chance to meet many other businesses too, and to promote your own business too.
The first three above events are free - but please let us know if you'll be attending. And if you've missed them, get in touch anyway - we'll be delighted to make another date to show you around and we've always got freshly ground coffee and tea on tap, even if the mince pie season is over
.
Posted by gje at 08:14 PM | Comments (0)
Swipe cards for hotel rooms - Security issues
We're using swipe cards for room access at Well House Manor - it allows us to give our guests a single key that gives them access to their room, the front door, and the conference rooms if appropriate. And as they're time limited, it allows our guests to be reassured that a previous guest who failed to return his or her key cannot return and get back in the room ... also good news for us as proprietors as we don't have a security headache with lots of keys out there. And cards that are NOT printed with room numbers, addresses, etc, also pose less of a problem even when "in date" if they get dropped or mislaid.
But I've learnt of a story - an urban myth - concerning these cards. It was said that some hotels put credit card details on them. And indeed it turned out that it wasn't always an urban myth - a few hotels (NOT us) were caught doing it. But, hey, the blank cards are cheap. We do like to reuse them but if you're concerned you're welcome to take them with you. Perhaps we should add an advert on them?
At the moment, our room cards are themed with the pictures in each individual room, and guests will have seen them in use from the first day. We've now added card holders with a note of our contact numbers if you need to phone back in, and our 24 page room information folder (our "FAQ") is available.
Posted by gje at 06:55 AM | Comments (0)
Bratton and Edington new town, Wiltshire
To meet the extra housing needs of an expanding population in the next 20 years, an additional 11,000 to 12,500 new homes are to be built around the villages of Bratton and Edington in West Wiltshire. The population of the new town will rise to approximately 30,000 by 2026, so making it comparable in size with Trowbridge today.
Access to Bent (as the new town will be called) will be off the Westbury bypass, currently in the planning stage. A flying junction just below White Horse Hill will lead to a 3 mile access road running along the valley just to the North of Salisbury plain. Terraced housing on the edge of the the plain will allow maximum housing density to be achieved while at the same time giving most new residents spectacular views across the valley of the Avon and up towards Pewsey Vale. Rail access will be at nearby Westbury station, although if the population growth exceeds expectations, it's possible that the Department for Transport could approve the reopening of Edington Station with a limited London commuter service from 2021. This would need additional financial support from the County Council.
Schooling for primary children will be in the town, with secondary children travelling by bus to their parent's choice of Melksham, Trowbridge or Warminster. Medical facilities are already available nearby in major hospitals at Bath, Salisbury and Swindon, and a new doctor's surgery will be included in the plans for Bent. Good shopping facilities are available at Trowbridge, to be supplemented by a convenience store, a hairdresser and a selection of take aways in Bent itself. Jobs will be at Swindon, Chippenham, Melksham, Trowbridge and Warminster; it's anticipated that there will be little new employment offered within Bent itself, as it's not historically an area of high employment apart from in agriculture, and planning applications for major factory units may not be acceptable to the local population.
In 1821, one in every 100 people in Wiltshire lived in the Bratton and Edington area, but that dropped by 2001 to just one in 350. These proposals for Bent will help restore that historic balance and more and put Bratton and Edington back on the map.
Pictures - Edington Church, a development in nearby Trowbridge by Newland Homes and Bratton camp on Westbury Hill
Please note - the above is just a speculation based on what could well happen. Have you ever wondered at some of the posh-sounding documents and plans that you hear about ... often they seem so abstract until you start coming down to detail. The "Regional Spatial Strategy" is one such, and I've got involved with some very limited elements of it because of the work I've been doing on the Melksham train service..
The RSS calls for 15,500 new homes in West Wiltshire in the next 20 years to handle an increase in population, and places 5000 in Trowbridge - the rest at the discression of the local District Council. There's also a suggestion that the draft RSS figures are low and will increase by around 25% across the board. Now - they could (and probably will) have Melksham, Westbury and Warmisnter each grow by 4000 homes - that's around 10,000 people based on current household sizes - or they could go for something like the plan described above. Employment, housing type, schools, hospital and access suggested in my spoof proposal are based on my understanding of current planning, practise and trends.
Update - 3rd December The Westbury Bypass campaign people have picked up this spoof page and referenced it from their Westbury Eastern Bypass Proposal page. Ladies and gentlemen, I'm flattered.
Posted by gje at 06:27 AM | Comments (0)
November 22, 2006
Display an image from a MySQL database in a web page via PHP
There's lots of clever scripts around to tell you how to get images in and out of databases, but nothing simple to show you the principles of including such an image via (say) PHP in a web page. So here goes.
you need TWO URLs - you need the HTML page that's going to contain the image, AND you need a second URL - PHP in my example - that's going to retrieve the image and feed it out as part of the page. You CANNOT feed out both the HTML and the image from the same http request.
Here's a sample HTML page we're going to include an image in:
<html>
<head>
<title>Demo of Database Image in a page</title>
</head>
<body>
Here is your picture:<br>
<img src=picscript.php?imname=potwoods><br>
Example by Well House Consultants
</body>
</html>
Then you need the PHP script - called picscript.php in the same directory in my example:
<?php
mysql_connect("localhost","wellho","xxxxxxx");
mysql_select_db("wellho");
$image = stripslashes($_REQUEST[imname]);
$rs = mysql_query("select * from im_library where filename=\"".
addslashes($image).".jpg\"");
$row = mysql_fetch_assoc($rs);
$imagebytes = $row[imgdata];
header("Content-type: image/jpeg");
print $imagebytes;
?>
If you want to try it out, then the HTML page is here.
Want to take this further?
As a next step, I would validate the connection after the mysql_connect, and check that an image really had been returned by the mysql_query ... substituting a default image if not.
We host a complete working example of image upload, save to database, select from database and display all via a PHP script. See article on the subject
There's a forum discussion here.
Posted by gje at 04:48 PM | Comments (0)
Useful link: PHP training
November 21, 2006
Global, Superglobal, Session variables - scope and persistance in PHP
"Global" is a poor choice of word! It really means "share this variable in this function with the variable of the same name at the top level" but there isn't a simple, easy better word for that than "Global". If you bring in code within an include / require file, then any top level code's variables in there will also be in the space that will be shared by any global declarations within the functions.
Superglobals are variables like $PHP_SELF, $_REQUEST, and $_SERVER. They are so called because they're always available in any functions without you having to make a global declaration. However, once again they do not persist between pages in a session, with the singular exception of $_SESSION as described in the next paragraph.
(Super)global variables of this type do NOT persist between successive pages of a session - the (modern) way for a variable to persist in that way is to (a) have a session_start() call in your code and (b) save the value you want to retain in the $_SESSION superglobal.
The other way to retain information between pages in a session is to bounce the information required via the browser - either in the form of hidden fields, a URL rewrite, or a cookie. That's really how $_SESSION works, but it's hidden from the programmer at the low level, and the information bounced via the browser is a single value which equates to a file name or database row key which can in turn be used to pick up all the other saved (session) values on the server.
It has been suggested that rather more than just these variables can be stored between pages, as database connection sometimes appear to persist rather than be refreshed every time. This is rather different - PHP routines like mysql_pconnect will make a persistant connection which will be stored in a pool of open connections once a page is completed. Then the already existing connection can be reused by a subsequent page which may, or may not, be a part of the same session.
Posted by gje at 04:46 PM | Comments (0)
Useful link: PHP training
Autumn leaves in Wiltshire - Potterne
Autumn in Wiltshire brings a great beauty to the countryside with the bright yellows and golden brown of the turning leaves in the low November sunlight.
On Sunday, Dad and I walked over the hills near Potterne - a few miles from home in Melksham - with our cameras. You can see the beauty on the picture here (and there's more here).
Alas, this Autumn we've been far, far busier than would have been ideal for us to go round and capture the magic of this time of year in to many local places, but it was really good to get out on Sunday. A brief stop in Edington allowed us to grab some pictures of the historic church there too.
Posted by gje at 08:22 AM | Comments (0)
Clustering, load balancing, mod_rewrite and mod_proxy
"It's not friendly - it's like a reference book". Customer comment on yesterday's tailored training day, where we were load balancing a web application between a number of back end servers, using Apache httpd, with mod_proxy and mod_rewrite to do the clever bits.
Our customers are right - it IS tough for a newcomer to work out what to do from the mod_rewrite manual. So you might like, for starters, to read my article on techniques for load balancing and clustering. Then you might like to look at some of the sample configuration files that we used to have a single httpd instance share the load between multiple further httpds, or multiple Tomcats. Yes, that's right, the solution works not only for Java applications, but also for Perl and PHP ones!
For newcomers to balancing the load, via mod_rewrite and mod_proxy, here's a commented version of the additions we made to httpd.conf at the end of the day, to share PHP applications in a directory called /demo on our backend servers via a URL called /booze on our front end.
# Set up a mapping of server names - see below
RewriteMap SERVERS rnd:/usr/local/apache2/conf/phpbal.conf
# Only make the following tests if the URL starts /booze
<Location /booze>
RewriteEngine On
# Look for a cookie called "what", which is the flag
# we use for a continuing session.
# If the cookie is there, it's been set up to include the
# server name as given in the phpbal file ... and if you
# find it, rewrite the URL to the appropriate server,
# in the demo directory. The [P,L] tells mod_rewrite to
# call mod_proxy for the new URL, and that this is the last
# rewrite in the chain - i.e. if it matches, don't look at
# any further instructions!
RewriteCond %{HTTP_COOKIE} "what=(\w+)-(\w+)"
RewriteRule /booze/(.*) http://${SERVERS:%1}/demo/$1 [P,L]
# If there was no cookie, however, this is the first request
# of a series and it should be forwarded to a server in the
# group at random. FIRST is defined in phpbal.conf
RewriteRule /booze/(.*) http://${SERVERS:FIRST}/demo/$1 [P]
</Location>
# Responses from the two servers may (will?) have been
# rewritten to point directly back at the back end server.
# Rewrite those returned URLs so that future requests will
# also be brokered via the front end server, and the back
# end system will be transparent to the user.
ProxyPassReverse /booze http://192.168.200.67:80/demo
ProxyPassReverse /booze http://www.wellho.net:80/demo
The phpbal.conf file is as follows:
local 192.168.200.67:80
live www.wellho.net:80
FIRST 192.168.200.67:80|www.wellho.net:80
and that instructs the server to randomly choose between our live web server and one of the servers in our training centre for first service ... then to revert to the same server if the cookie is set with a "live" or "local" value. The full source of the PHP application we tested with is in one of the links above, but the vital line to set the cookie is worth reproducing here:
setcookie("what","local-".$uniquekey);
with "local" changed to "live" on the second system in the cluster ...
I do enjoy days like yesterday, when we explored topics that are advanced and not quite the nor for our usual courses. My customer left really happy with what we had done, and I had the opportunity to push through and develop further practical knowledge and further my own understanding of some of the detail - a true win/win. And of course I'm all the better place not if YOU want to come and learn more about sharing the load across servers - whether you've a PHP or Java application.
Posted by gje at 07:02 AM | Comments (0)
November 20, 2006
Course Joining package - updated
The moving of training to our new venue just 1km up the road in Melksham, and the extra facilities we've added has lead to a bevvy of updates to our web site - some immediately required by the move, and others caused by consequential alterations - extras that we can now provide and things we have to alter.
We've changed the advice on getting the best from your course to show a new start time from next January, and to update our suggestion that you stay in Melksham to include the comment (already proven) that almost everyone who stays does so at our place.
We've changed the advice on using our services after the course to include a reminder that our Open Source library of some 650 books is available to hotel guests, and to tell people they're very welcome to check in for a weekend away in the future.
More obvious changes like a new 'how to find us' page are provided, together with a less prominent how to find our offices / HQ page, as our admin operation is still based in the previous location and will remain there.
Our web site has good placement, and that's important to us - so if you're looking for a course for one or two people, our public course index that will give you dates and links to course descriptions remains at the same URL. The page that describes our public courses has been updated to show the new centre and to reflect on the availability of accommodation ...
Further changes are to come too - partly in light of our initial 3 months experience, partly when we revised our pricing in January (training course are typically quoted without VAT, hotel rooms typically with VAT, and things like that need re-factoring!), and partly to reflect the local roads getting busier so we can't do the whole complimentary range of pickup runs we used to ... and that the train service changes completely 3 weeks before Christmas. Watch this space!
Posted by gje at 05:20 AM | Comments (0)
November 19, 2006
A tale of a wee wall
When does making a wall wee make it turn into it not being a wee wall any longer?
Walking home on Friday night, after most of the pubs had shut, I note a chap a few hundred yards in front of me. I thought nothing more of it, and he disappeared into some gateway or other and I carried on walking.
Catching up to the point where he had vanished, I was surprised to see him appear again just a few yards ahead of me now, from behind a high garden wall, and continue on his way.
We had heard that Spa Road - or certain properties on Spa Road - attract revellers from the town, wandering home, to meet the call of nature in their gardens behind high walls. Indeed, after we had bought 'The Manor', we learnt that it was a favourite spot for such activities.
Our plans always included lowering THAT wall. It made the place look like a fortress. It made it dangerous to leave the drive in a car because of the dreadful visibility and, it appears, it also provided a haven for meeting the call of nature and goodness knows what else! The wall is largely gone - from being nearly 2 metres tall, it's now around 20 cm tall - and it's now just a wee wall and not the neighbourhood's weeing wall. And we're much relieved about this.

Before

After ... now ... this morning .... for ever
For those who don't speak the same native tongue that I do, the word "wee" is both a Scots term for tiny, and also ... well, I'm sure you can make out the other meaning from my post. And, yes, the whole double use of this word has lead to a lot of jokes and plays on words along the lines of the one above.
Posted by gje at 07:49 AM | Comments (0)
November 18, 2006
Before and After - Well House Manor
Do I want to show people, proudly, all the works we've done on Well House Manor and how it's now such a different place? Of course I do. But at the same time I don't want to discourage visitors who happen upon our web site and see the old rather than the new.
So ... for those of you who are interested, we've put up a page of before AND after pictures - or rather a site of three pages. Start here with external picture and click through "add more pictures" until you end up here with internal, externals, befores and afters!
These two pictures, samples from our 'renovation' site, are both taken of the room now known as bedroom 5. Dated decor, worn out plumbing, lighting and fixures, fittings and electric has all been replaced by a quality modern look, and we're proud to have turned a B&B that was getting mixed reviews into a hotel that's already attracting return guests within the first weeks of opening.
Until 31st December, we're offering rooms at Well House Manor at 60 pounds a night (single occupany) and 80 pounds (double occupancy) to include a continental breakfast. link - details. These are 'silly cheap' prices as we're in our settling in period and there are a few final touches to be added yet. We're also - until the end of the year - marketing only to our course delegates although we'll accept other general bookings too if you would care to get in touch. The main web site is in embryonic form at the moment .... but there'll be a booking system, room tours and more up there by the new year.
Posted by gje at 10:59 AM | Comments (0)
-> , >= and => in Perl
Yes, Perl is eclectic - lots of things it can do, taken from lots of places and so, yes, it does have all three of those operators!
-> Run the method named to the right on the object named on the left
>= Return 1 (a true value) if the expression to the left is numerically greater than the expression to the right
=> Normally used to indicate a key, value pair for entry into a hash. In fact, the => operator is the equivalent of a , (a comma) which can be used instead - the=> is just provided to make the your code easier to read, and (in some circumstances) saves you the need to quote keys.
Examples:
$kgs = $current->getweight();
# Get the weight of the $current object
print "heavy\n" if ($kgs >= 100);
# Print out if $kgs is numerically 100 or greater
%info = (weight => 120, height => 1850);
# Set a hash with 2 key, value pairs
Posted by gje at 10:44 AM | Comments (0)
Useful link: Perl training
November 17, 2006
Presenting Melksham - for a weekend away in Wiltshire
I do my best presentations when under pressure. ((Important NOTE to wife / staff / cat - DON'T pressure me every morning)). By which I mean that a new presentation or one I'm not quite prepared for even though I know my subject can, I think, sparkle with a freshness that's not there if it's been wellprepared and identically done many times before.
"What would I see around Melksham if I came to stay here?" A question asked of me last night, and although I have long extolled the local beauty I've never got down to doing a more formal presentation. But I found myself, joyfully, with the opportunity to say just how much there is to see and do around here, even if you're using public transport.
Click on any image for further information about that location / venue / activity
Melksham itself was mentioned in the Domesday book - King William 1st's review of his kingdom. And many buildings that are hunreds of years old remain, all be it much altered and (in the town centre) fitted with modern shop fronts. But there are excellent walk around opportunities for the evenings, or for a Sunday afternoon. And there's a good selection of eateries and one or two hotels to stay in too.
Do you like historic houses and villages?
4 Miles North is the National Trust village of Lacock - with Lacock Abbey that was a monestry disolved by Henry VIII, and where Fox Talbot took the first reversal process photograph at the start of the Victorian era. See the Fox Talbot Museum, the Abbey, the Church and more.
6 Miles (North Westish) is Corsham - an old Cotswold town with teh magnificent Corsham Court, open to the public and with ground that you can walk through designed by Capability Brown.
3 Miles West ... Holt, where the National Trust gardens at "The Courts" attract visitors from far and wide - another favourite of ours.
Other features of interest?
5 miles to the East is the great flight of locks up Caen Hill, near Devizes, on the Kennet and Avon canal. You can watch boats as they take the 29 steps up the hillside, and perhaps help push a few gates. There's a tearoom at the top of the flight ..
8 miles to the South is the nearest of Wiltshire's White Horses - the Westbury White Horse - overlooking the town from the flank of Salisbury Plain. See handgliders, families out for the fresh air, enjoy the views yourself.
About 12 miles, and you'll find the Avebury Stone Circle (older and larger than Stonehenge, I may add), Silbury Hill, Windmill Hill, West Kennet Long Barrow, the Sanctuary and a host of other features that will occupy you for the best part of a day within a couple of miles.
Towns and cities?
Again about 12 miles away, the Roman City of Bath is a tourist Mecca. From the Baths which gave it its name, throuh the Abbey and the Royal Circle to river trips, shops and the Theatre. The bus goes into Bath from right outside our place - an excellent way in as the traffic and parking aren't always what you want to contend with on holiday.
Bradford on Avon is just six miles from us, with its old buildings (Church, Tithe barn), Canal, and much more. Devizes, again around 6 miles away is riddled with historic building and some excellent original shops too. Any you've Chippenham and Trowbridge (the county town) also at a similar distance.
Countryside?
I have left, perhaps, the best to last. The countryside around here is fabulous.
When Lisa's sister visited from the USA, after a day cooped up travelling I took her for a walk along the canal which passes just to the South of the build up area of Melksham (Bowerhill). Along to "The Barge" at Seend, "The Three Magpies" at Sells Green and on up Caen Hill. And we caught the bus back. I've been known to take customers on the same walk too.
Just beyond Devizes, you have the Marlborough Downs - Walk on Roundway Hill and Olivers Castle, take in the bracing air and glorious views.
But there's countryside all around. We have detailed maps here, available for loan or purchase, and the path network in places is almost as extensible as the roads. With a little bit of planning, you can take a bus out and walk back (or vice Versa) and discover new places for yourself that I've not listed above and don't know - find you own Wiltshire - there are plenty more gems out there.
Posted by gje at 08:26 AM | Comments (0)
November 16, 2006
C++ and Perl - why did they do it THAT way?
"Why did [they] do it THAT way?". It's a question often asked by the brighter and mre persceptive delegates on courses concerning some features of a language that I'm teaching them. And the answer "because they did" is a poor one. It's like saying to a child "because I said so" rather than looking behind the scenes for a real reason.
C++ builds up on top of C, and maintains the C syntax. So there are many things in C++ which, had it been written from a clean sheet, might not have been included. And C++ is a low level language with bit / byte / register control capabiilty, so some of the constructs, capabilities and syntax is somewaht more cumbersome than would be ideal for many modern applications. Which is precisely why it's still much used in computation intensive type works and device drivers, etc, but has been displaced by Java and C# for many of the more mainstream uses - Java and C# both take the philosophy and approach of the C++ syntax, modifying and extending it to remove the low level and C compatability, and other complexities who's implementation costs outweigh their usefulness in the mainstream. It's little wonder that Java and C# look very similar to each other, then, with the same starting point and same philosophy and the same market.
Perl's another language where "Why is it done THAT way" is an excellent question that is, from time to time, answered by a rather glib "for historic reasons". The use of @ as the special character to signify a list would probably NOT have been the decision made after email addresses became common, but it was an excellent choice at the time. But many (most) other answers to "why was that provided" in Perl cam come down ro a far, far better answer.
Why use \s \d and \w to represent space, digit and word characters in Perl regular expressions? Because they're very quick to type and you can get a whole lot of code in a little space ... because the \ is already designated as the 'escape' character for strings and regular expressions, and because s d and w stand for space, digit and word. But why go on to use the capital equivalent \S \D and \W for a non-space, non-digit, non-word? Now that one stumped me the first time I was asked, but I can now ask you back "what better suggestion do you have?". In practise, using the same letter in capital and lower case makes them very easy to remember once you're used to them. And the resultant regular expressions are short and elegant.
Of course, Perl is eclectic ... so you can, if you prefer, write [[:space:]] for a space character and use all of the other posix standard regular expression handlers too.
This week started with me teaching OO programming in C++ and is ending with me teaching OO programming in Perl (on our Perl for Larger Projects course). And the two philospohies and approaches make an interesting comparison. Both are right for the right application ... both are great languages and what a great deal of fun I've been having.
A series of C++ examples that put together a whole host of the facilities offered by C++ - inheritance, static, inline, public, private, const, friend, vector, namespace, new, overriding, overriding operators ... was written on the fly, and I've posted them up under our putting it all together modules. I don't have the same Perl examples to show you, as that course has still got a day to run but of course you'll find plenty from previous courses in places such as "more object in Perl" resources.
Posted by gje at 11:14 PM | Comments (0)
Useful link: Perl training
November 15, 2006
Hotel door furniture
What a difference the word 'hotel' makes!
![]() | ![]() | ![]() | ![]() |
Just some of the fixtures and fittings associated with our bedroom doors - all of which are, of course, to the latest fire standards. Add spy holes, smooth closures, 'washer' lights so you can see your way at night and in an emergency, and you'll see the difference even more in this tiny area.
Posted by gje at 08:41 AM | Comments (0)
Training rooms to learn Open Source programming
The designer incorporates a dimmer. The engineer removes the starter. The trainer shifts the room around. All solutions that I've seen to the lighting of training rooms.
We've used self-lighting projection systems for many years ... in the 1990s and prior to that, courses were presented through a series of viewfoils (or OHPs) through which light was shone to project them onto a screen, with a lareg lightbox and a lens that threw the light through 90 degrees onto a screen or wall. These days, viewfoils are nearly extinct, and we're projecting off the screens of PCs. Light output has risen from a few hundred lumen to several thousand, and the intelligence of the units and their resolution has risen too, even as their cost falls.
Yet - still - a poorly planned training room, with a flourescent tube pouring light onto the screen, distracts from the presentation all too often. And when you come to switch off that tube - guess what - it's all too often tied in with the lighting in the rest of the room in such a way that your audience can EITHER see the board OR they can see their own notes - not both as the trainer does his best to compromise between a flood of light throughout and a theatre-style darkness.
I've been giving a C++ course to Engineers in Milton Keynes for the last couple of days, in a room that triggered this article, so of course we've removed the starter. Today and through to the end of the week, I'm in our own training room at Well House Manor in Melksham, giving an advanced Perl course. Being our own room, it's been designed with a separate dimmer on the lights that shine on the projection board, and lighting's not really an issue.
Our old training room was excellent ... but our new one's even better. Once again, we're projecting onto a special wall rather than a screen that waves in the breeze, but now the wall is also useable as a whiteboard. Not only can I throw up code on the screen, but I can also write all over it to show how it runs, or use the extended area around the picture to make points and then "arrow" them onto the diagram being projected to show how the points are implemented.
And we've moved up from 'just' a large whiteboard to white, writable, walls through a half of the room. After just a month, I'm finding that it's making a real good difference in my training; that I'm able to cover (say) regular expressions on the 2nd day of a four day course, then leave my notes on the board as a reminder right through to the course end. By the door, there's a narrow band - about a foot wide - on which I've taken to writing notes of subjects that I've promised to return to during the course, but which I can't appropriately cover early on when, perhaps, the question was originally asked.
There's plenty more to having a good training environment than just the projector. This view shows how we've maximised the space that's available for each delegate, yet left each with a good view to the screen and plenty of circulation space too.
Posted by gje at 07:45 AM | Comments (0)
November 14, 2006
C++ - just beyond the basics. More you can do
Things you can do in C++ ... just a bit beyond the first basics of a class:
1. You can declare that a method is const if it doesn't change any of the instance variables and that will make it a bit more efficient when you run it.
2. You can refer to an instance variable within a method using this-> if you want to use the same variable name for a parameter to the method (or as a local variable within it)
3. You can declare a destructor method (which has the same name as the class name preceeded by a ~ - a tilde) which is code to be run when you've finished with an object, and before the program finishes
4. You can have two methods of the same name but with a different 'pattern' of parameters, and your program will work out which is the one you're calling in each case. This is similar to polymorphism ... but not actually polymorphism; Polymorphism IS supported by C++ as well!
These are all just slightly beyond the first basics, and you certainly won't use ALL of them in a single program (unless you're doing a class excercise as I was yesterday!) Here are sample declarations for three of these techniques:
class MSheet {
public:
MSheet(float ecs, float why);
MSheet(float ecs); // No. 4 - 2 methods of same name
~MSheet(); // No. 3 - destructor
void setx(float size);
void sety(float size) ;
float getarea() const; // No. 1 - const
private:
float x;
float y;
};
and for "this":
MSheet::MSheet(float x, float yy) {
this->x = x; // No. 2 - this
Posted by gje at 12:05 AM | Comments (0)
November 13, 2006
The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl
It all started on Friday as we came back from the pub. I was describing how we've been, twice, on Neil Bauman's Geek Cruises but never been asked to talk or lecture, even in a "lightning session" on them. A little wistfully, maybe, as I'm a "wannabe" - I would love to get up and deliver a talk just as I do here in the UK for a living. We came to the conclusion that Neil's not asked me because (a) I'm not a big name in his customer's world which is USAcentric and (b) I've not written published a book. It could also be that we've not been pushy enough - HEY - NEIL ....
I've written a lot, and I still write a lot. You'll find nearly 1000 articles in this series, about a half of which are technical. You'll find over 1000 pages of technical detail in our course notes which we hand out when you come and learn with us and you'll find over 1000 technical postings in our user forum.
So why have I not been published? Well - it's not because I've not been asked (please excuse the double negative) and it's not because people don't read the stuff I write - they do. On a typical weekday, around 300 read my page telling them about the difference between a JOIN and a LEFT JOIN, a further 300 learn about using PHP and MySQL to upload, store and serve images, and even on subjects as obscure as dynamic mapping hits will be into three figures. No - the real reason is that I've simply never felt I have the time to put a complete book together, and proof it, and get it through all the formal publication stages, that I've always felt there are plenty of competing books out there, and that I've always felt that having published a book on our technologies it would only be a matter of weeks before I felt it was out of date or that I had something I wanted to add.
However, we did come to the conclusion on Friday that I have a book, constantly updated and already written, and it's here on this website. The LAMP Cookbook. A number of longer articles on Linux, Apache httpd, MySQL, Perl and PHP in our solutions centre, then a large number of tips and techniques on each of the topics - PHP, Perl, MySQL and Apache httpd and Linux all indexed under category and subcategory.
A quick Google search doesn't - YET - reveal a "LAMP Cookbook" page, so perhaps there's an opportunity there. But then most of my readers here will know that for every 10 good ideas we have, we only have time to bring one of them through to fruition. So perhaps I'll leave you, the reader of this musing, to pick at the pages on this site as my virtual book ... you'll find that each of the topics (such as PHP) goes down into subtopics (such as arrays in PHP, and within there you'll find numerous souce code examples such as this one and a whole load of short tips under unlikely hames such as breaking bread
Neil, I might be available for a week sometime next summer ...
Posted by gje at 07:54 AM | Comments (2)
Useful links: Linux training, Perl training, PHP training
Why shouldn't I spam?
Here's a post that I wrote to a forum that I very occasionally contribute to - I thought it was worth sharing the words a little wider as it help give a bit of a deeper insite into the world of internet moderation, security, rules and advise for the majority of people who are users and don't really need to be fully aware of these things. The post was following up a slightly aggressive young lad who needed a few analogies to help him appreciate the effects of spamming should he have chosen to start doing so.
I'm just an ordinary member of this forum ... but I do have admin / moderator rights elsewhere. So I can tell you the sort of things I go through when I see (or are informed of) abuses of what the forum's intended for, and I cannot tell you what or how the moderators and admins here would differ from that. But it can give you a general insite.
Quote: ""Heh, Im only 17. I dont pay for the internet. So I havnt read the ToS. Is there anywhere online that I could read that? And is spam considered illegal or abusive?""
You're using someone else's service, so you could get them into trouble, and yourself into trouble with them. Perhaps a parent, perhaps a school / college. And wouldn't it be a shame if you upset them and they took away your access / course of study. At 17, you're old enough to drive in most countries, and even though it might not be legal, to obtain drink. Would "I''m just a 17 year old kid and I didn't actually buy this car myself" be enough of an excuse for someone left dead at the roadside if you hit them while driving under the influence? Aren't you allowed to sign up and die in Iraq for your country at 17? So why do you think you might not be responsible for your own activities on line?
But, seriously, spamming isn't in the same league. I'm personally very used to deleting spam and indeed I take quite a lenient view of what is and isn't spam. That's not the case with certain of the moderators here, who have stated that they have deleted complete posts (and I suspect banned members) because a post include an advert for the site/services of the poster within their message. I feel that's draconian, but it's the site owner's ultimate choice and right to have such a policy. That's a 'civil' matter - not a 'criminal' one.
As something gets to be a more obvious nuisance, and/or becomes sustained, the owners and moderators have other tools they can use and, yes, they do have elements of information that allow them to trace you. At a certain point - for example if you were posting porn that was visible to minors - your activities would move from 'civil' to 'criminal'. And I would imagine that certain activities from you would trigger certain actions in the owners and other site visitors, and that certain activities such as posting up of unsuitable material might result in reports going back through ISPs, and through various legal authorities.
Does this happen? Yes, it does. I can tell you first and second hand stories (not third nor fourth hand, you'll note) of an ISP threatening to cut off a service because of an assumed spamming incident that actually involved a single email message, of a major commercial company taking someone to court (but then settling for a payment of thousands of dollars) for copyright violation, and of threats of immediate action against a web site owner unless certain activities were ceased with immediate effect.
In summary, it's in your interest NOT to start spamming to see what will happen.
Posted by gje at 12:52 AM | Comments (0)
November 12, 2006
Staying at your own hotel
There's nothing like trying out the services of a business to learn about how that business works, and how it looks after its customers. And it's especially important for the owners of a business and their customer facing staff to know how they, their colleagues,and their service look to their users.
And so ... one of the things we planned at Well House Manor right from the start was to offer every member of staff who'll routinely be checking in guests, answering their questions are requirements from late afternoon through to breakfast time and beyond, the chance to stay for a night in one of our rooms. Well - actually we didn't really just offer - we made an offer that was hard to refuse.
Lisa and I stopped overnight during last week - we sampled bedroom 3, we got to try out the TV and the bathroom, to learn a little about the fixtures and fittings, and to see how our housekeeping team was settling in. And very well they're doing to - we just picked up on a couple of things that we should vary ever so slightly, but all in all there was a whole heap of congratulations flowing from the night.
Both Martin and Leah have also stayed over - on diffent nights, trying our different rooms, and they've come back with very positive reports too. Again, I'm sure there's odd things that they noticed (and perhaps they'll see from both sides now) and the odd thing that they've told us about ... but most importantly we - all of us who are likely to get a customer query from 5 p.m. though to 9 a.m. - now know somewhat more about the operation and action of all the technology we've put in - from adjusting the temperature in the bath to remembering to take our keys out of the energy savers as we leave the rooms.
Posted by gje at 04:11 PM | Comments (0)
November 11, 2006
French Exchange
"Getting a bit technical". So says my closest friend, and she's pretty technical at times. "A lot of PHP and Python". Yes, there has been a lot of PHP and Python for the last couple of weeks, so now for something completely different.
Yesterday I was recalling how we had a school visit about 12 years ago from an exchange student from France. Peter was a bit of an oddball, and initially we put this down to the culture of where he was being brought up - in a quite remote cottage in an off-the-beaten-track corner of the Alps. But when, half way through the exchange, we met up with the teachers and other parents we were rather taken aback by solicitous questions "how are you managing with Peter?". It seems that Peter was considered to be a difficult visitor to place and we had been specially selected - without our knowledge - as being the best able to cope.
A barbecue in a beautifully manicured garden in Frome. Many of the parent were there in posh finery, and all the English and French young ladies and gentlemen were being cultured. "Afternoon tea" in the English style - except of course for Peter, who was intent on climbing a very beautiful tree that could scarce support his weight in what was our host's award-winning grounds. Of course, the teachers were there for a social and it fell to me "in loco parentis" - to take appropriate action on which, no doubt, the others present judged me.
I recall that Peter was very forceful in requiring the TV to be turned to the channel that he wanted to watch, and that he would routinely read through any personal papers that were around; really we had nothing to hide, but we found ourselves locking up things like bank statements and breaking from our usual habit of leaving the day's opened (but needing attention) post on a counter top. "Do you read everyone else's letters at home" we asked. "Yes" he replied, apparently not comprehending that his actions were causing offense and weren't fitting in with the English way of life he had come to learn.
Should we have treated Peter "like one of our own", or should we have treated him differently? Does and exchange student coming in to a house get treated as a guest / customer who can do no wrong, no different to anyone else as he's a member of the family, or as someone who has to be licked into British shape in just a few short weeks? We opted for the middle option - treating Peter as one of the family - yet modifying that treatment a little to be more understanding of times when we would have suggested to our own that they were out of line, and to provide additional guidance in areas where he couldn't / didn't appreciate how things worked around here. Alas - a pretty thankless task. "You're telling me that because I'm adopted". "You're asking me to stop doing that because of the colour of my skin". No, Peter - we're asking and telling you in just the same way that we would ask and tell each other. The reason that you may feel at time that you're to only one being told to do something - such as get down from that tree - is because you're the only one climbing it and in danger of causing damage, expense and upset. But - gee - those explanations and maintaining the calm was hard.
One final memory of Peter was his shower. I think he had come with an instruction to shower well and long ... but he had overlooked it for the majority of his stay and was starting to get a little aromatic. We were quite relieved when he announced a day of two before his return that he would take our advise, and a shower. And what a shower it turned out to be. He must have been in there over an hour. And he came out ... complaining ... that there wasn't enough hot water and he'd had to finish early.
A dozen years after, I can still recall some of the aspects of Peter's visit; I wouldn't describe it as enjoyable, nor fun, nor a walk in the park. I would describe it as character building for all concerned, and a learning experience for all concerned. And from that view point, the objective of the exchange was achieved. And I look back and think "yes, I'm glad I went through that".
Posted by gje at 09:07 AM | Comments (0)
November 10, 2006
A lion in a cage - PHP
A lion in a cage shouldn't be a danger - but release the lion from the cage and you could be at risk.
An include file that's pulled in by a PHP script shouldn't be a danger if it's used only from within that PHP script, but if it has its own URL the it could be released like the lion, and it could be a danger. If you're writing a PHP script that requires or includes files, please put the included files in a directory that's NOT got its own URL .... you can do it by giving a path to the file in the include or require statements, or by using the preconfigured directory that's set up on your PHP installation.
Image from Hone's Everyday Book
Posted by gje at 06:34 PM | Comments (0)
Useful link: PHP training
November 09, 2006
Freedom for X is denial of privacy for Y
I'm a great believer in the internet offering an ability to communicate - a freedom - and on that basis the various web sites that I run start off with an "allow all" premise. Even if someone's views don't match mine ... if they want to express them on a board such as opentalk or save the train, or follow up on entries such as this via the comment button, or email me personally, then I think that's great.
Alas, with the ability to communicate on topic comes the ability to communicate off topic, the ability to continue a communication when one party considers it closed and the ability to bulk communicate, including to parties who aren't interested. At a low volume, and when sent to responsible adults, such communications are not really any big problem. As the volume rises, and if the recipients may be minors, it can be another matter.
Nearly 5,000 email messages hit the Well House Consultants server yesterday - the number's very high because we have email to a whole lot of domains that we look after all coming through our central account - and over half of those are clearly marked as being unsolicited bulk email according to our stats page. In fact, I lowered the hurdle that a mail has to jump to be regarded as 'spam' some 24 hours ago, so less traffic of this type is now reaching us - but this is a tricky one as there's always the chance that an advert-like email from a friend or contact could get trapped too and I would regard that as a wrong side failure.
Emails aside, what do we do about off-topic posts on the forums? At their simplest, we've got a clutch of moderators and administrators and a larger group of good friends and contacts who can delete such messages, or inform someone quickly if inappropriate messages need to be deleted. And such messages end up - with our "must be an adult to sign up" rule - as being little more than a nuisance. Occasionally a net newbie will read one before it's deleted and get offended by what we're publishing; a quick explanation usually clarifies things. "Blaming us for the content would be rather like blaming a bus operator for running a scheduled service that happens to take a thief away from the scene of his crime"
One of the great features of our boards - and other boards too - is the ability to send personal messages to another member. After all, everyone might be concerned with / want to read about the reliability issue with the 18:09 - cancelled 3 times in a week - but if John and Jane are arranging to meet on the 21:34 tomorrow night, that's probably not a public meeting. But personal messages can be abused ...
Yesterday, at around 5pm, my mailbox was hit by around a hundred emails within a minute of two. That's as against a regular 5 to 10 an hour. What had happened? A newly signed up member to a board had used the "personal message" system to write to everyone. And, I understand, the picture was pornographic (there's some speculation that what was shown was plastic rather than real, but it's hard to tell these days!). And the "pm" was notified to all 350 members of "save the train".
My 100 initial emails were all "bounces" - emails returned from addresses that were no longer active - and it gave me my first clue that something was up. They were followed within a few minutes by the first emails from real users letting me know that they had received the notification / message out of the blue - mostly good humoured, thank goodness. And this is where I realise what a valuable team and great friends we have; before I had even had time to take appropriate actions, Leah had done the job - removed the parallel posts to boards, turned off the member's ability to contribute in that (or any other way) and was onto the damage limitation. Thank you, Leah. And others were posting on the main board on the subject, helping me to make it very clear to all that "this is NOT our message".
I started off by saying that I believe in freedom, but one (wo)man's freedom to post such a message to everyone is another's denial of freedom from receiving unsolicited messages that may offend. What's the answer? I looked at 'intended use' of the personal message system and asked myself 'is there any way that I can add a restriction here that will allow intended and good use but trap issues like the current one' ... and I've come up with a configuration that only lets people send personal messages once they've made a handful of public posts on the board.
With the new scheme, anyone who receives a "pm" from someone they don't know can look back and see a little of how their correspondent stands on things. Their correspondent will have shown a clear, repeated interest in our main topic and will already have been vetted by peer pressure on the board. And people typically don't sign up just to send legitimate messages without making a contribution to the community as a whole - so I think our solution is a good one.
Posted by gje at 07:53 AM | Comments (0)
November 08, 2006
Databases needn't be frightening, hard or expensive
Have you written a web site using plain old HTML (perhaps with style sheets and images) and then extended it to more interactive content using a little PHP, JSP, Perl, cgi or similar? Are you keeping the data associated with your PHP - your on line programs - in plain text files? If you are, that may be the right decision, or it may be the wrong one. Database engines such as MySQL are available for free download and install, are provided as a standard part of the package by most WSPs (Web Service Provider)s, and can provide - in the right circumstances - an easy, effective and efficient way of storing, accessing and updating data. And those "right circumstances" are so common that they'll apply to elements of most modern web sites.
If you keep data in plain files on your web site / within your application, it'll work fine while the application and the data is small and doesn't change a great deal, but plain files have a number of issues you need to consider:
- If you edit a file, you have to rewrite the whole file.
- You need to write code to understand the format of the file - strip out comma separators, but allowing for commas within fields, etc.
- File locking isn't nice - great care needs to be taken if there's any chance of two concurrent changes being made.
- As data grows, the file / directory structure with a very large number of files becomes inefficient and unmanageable.
- Searching a file / looking for data becomes all the more inefficient as the data volume grows.
You'll notice that many of the limitations I mention relate to data volume and you might thing to yourself "but I don't have a high traffic level - I don't need to bother". You might be surprised at just how quickly data volumes increase and tip the balance in favour of databases even for a small organisation. At Well House Consultants, we're a team of just 4 full time staff ... and yet without databases and tables, navigating our web site would be like running through treacle.
Even this article, when I post it, will be in a database. As a user of the system, I wouldn't need to know that or to take any special action, but as a user I'll see it filed efficiently. And because it's in a database it will be very easy for me to correct spelling mistakes later without having to pull in all the past articles too, and it also helps make it very, very easy to provide search tools. Have a look at this demo that searches through the title of old entries and see just easy the code is.
I train people on using plain text files. And I train people on databases too. So I have a foot in both camps. When would I recommend a switch to a database for a particular table of information?
- When there's a large amount of data
- When there's a possible need for concurrent edits
- When the data is structured and elements would otherwise be repeated
- When there's a need for searching and summarising
Examples of database use on this site
- This daily diary link
- Our rank and review system link
- Our user editiable pages link
- Our forum link
- our current user history link
- Our accessibility preferences link
- Our library link
Posted by gje at 07:38 AM | Comments (0)
November 07, 2006
Syntax checking in PHP
If you want to check the syntax of your PHP page without actually running it, the -l option (that's lower case letter L) to PHP at the command line will do that for you:
wellho@lightning:~/public_html$ php -l index.php
No syntax errors detected in index.html
wellho@lightning:~/public_html$
Remember - even if you're developing code on a systems that's not your main server, you can install an Apache httpd and a PHP onto almost any systems for testing .... including the PHP command line.
Posted by gje at 08:10 AM | Comments (0)
Useful link: PHP training
Driving customers away
Domain name registration is something that has dropped in price over the years and rightly so - it's very much a service where the volume of customers has dramatically increased and so the bulk savings of automatic processing allow for keener pricing than there was in the past. Netcraft tell us that there are now 100 million sites - that milestone was passed in late October.
We've got a great number of domains registered at or by Well House Consultants - as well as the regular www.wellho.net that's our root and anchoir point, we have a whole load of other "wellho" domains - .co.uk, .com, .info, .biz to name a few, and also a number of "wellhouseconsultants" domains. Then there's all sorts of others such as www.wellhousemanor.co.uk and one of two relatives, www.grahamellis.co.uk, www.savethetrain.org.uk and on to the more exotic such as www.sheepbingo.co.uk - most of which have there purpose but some of which (not named here) are frankly parked up at the moment. So the falling cost is greatly appreciated.
Most of our domains are now hosted at a couple of good value central points from which we can control their DNS, but just a few remain outside that 'fold'. Some suppliers are excellent and reduce the renewal price as their costs reduce on a year by year basis and I'm happy - more than happy - to stick with that supplier. But, alas, one or two others feel that people will pay steadily more exhorbitant fees rather than go to the trouble of moving a domain ... and at times they're right in the short term. In the long term, though, such activities loose the respect and loyalty of their existing customer base.
Case in point this morning. One of our "wellho" domains that's hosted off to one side came up for renewal, and whilst I HAVE renewed "in situ" for another year, I'm swearing that it's the last time. The actual amount involved is small - no more than the cost of a good meal for a year's registration - , but the loss of credibility for [company name omitted] is tremendous.
And when I clicked, reluctantly, on renew, up came a page called upsell1.jsp that offered my privacy for my address and contact details for an extra $10 a year. Then there were upsell2.jsp through upsell4.jsp for me to reject ... offering me their hosting, their spam filters, and their logo design services before the registration was completed.
Posted by gje at 07:07 AM | Comments (0)
November 05, 2006
Paging through hundreds of entries
I can display all the entries in a table on a single page if there are 10 or 20 of them. When I get up to about 30 or 40 entries, it's getting out of hand ... and with hundreds of entries, I REALLY need a paging system.
Quite commonly, I see requests for "paging systems" to meet such requirements and, not having written any new PHP for a few days, I though I would see how compact and explainable an example I could come up with. Well - 43 lines, 1300 bytes including the HTML!
Source code - here and code in operation here. Now I just need to add a title search capability! Ah - perhaps this will do the trick .... wanna see the source?
Posted by gje at 06:24 PM | Comments (0)
November 04, 2006
A practical example of roles
As I drove south from Scotland this morning, I was listining to the radio; an increasingly rare chance to catch up with the in depth news and review programs on Radio 4 that provide a more thorough background to history and events than I feel I get from the snippets of TV that I watch. A program of about an hour on the early days of Aids, from its discovery in communities in New York, through the gayphobia it caused in many people as it was attributed to that community, and on through to the acceptance by the UK government that it needed to provide public awareness had me thinking back and recalling a history from a time at which I was in a monogomous relationship, had been for years, wasn't receiving blood products, so had the luxury of being able to take a lesser interest in the subject than many.
Do you recall a leaflet distributed to 23 million households to give them Aids information - part of the "tombstone" campaign? One of the speakers on the program commented how her organisation heard, a few days before the leaflet was sent out, that their phone number - with a total of 4 lines - was to appear on the leaflet as a number for people to call if the wanted advise. Panic - and potential meltdown at that organisation, and a rush to get in more lines and staff.
As a strange twist of fate, some of the folks I was training yesterday were also very much in a (temporary) panic mode because of someone's circulation of a single help desk line / phone number to some 500 staff, with a suggestion that the staff contact the help desk and have them delete what were considered, by the message originator, to be a tier of excess and confusing email accounts. But in this instance, it turned out to be something of a 'false alarm' in that extra level of email accounts forms a vital part of the system - and also an excellent illustration of the use of roles.
Roles - or extending a user's data views
The concert of roles has, in recent years, been added to the concept of users and groups as far as user's authentication and rights are concerned - it's something we come across on our Deploying Apache httpd and Tomcat course amongst other places.
Let's say that I have a whole series of staff working at a higher education establishment - then I'll give them all login accounts that let them do what staff can do, see the views of the data that all the staff can see, and make alterations which are in line with their positions as staff members. In other words, each member of staff has a staff role on the systems.
Are staff also students? Well - perhaps they aren't - or perhaps they are. Cetrainly, some of them may need to take on the role of a student, allowing them to access the systems and data in the same way that a student would. With such a mechanism, a staff member in his/her sudent role could check that the system would perform correctly when one of their students submitted coursework / used the system as required as part of their course. And that's a vital thing for staff members to be able to do.
Then you'll have some staff members who will also take on the roles of internal and external examiners, and so on. (If you're familiar with Unix / Linux groups, you might see how roles are in effect an extension of that concept).
On a system that wasn't originally developed with roles in mind, you can have something of a problem in terms of how to allocate multiple roles to a single log on account, and one of the solutions is to provide each user who needs multiple roles to have multiple logins - a bit of a 'kludge', but it works. And with multiple logins will come multiple email addresses ... which formed the background of yesterday's panic. It seems that some of the multi-role users had only been checking their main email account and messages had been lost. Some staff members were being branded "rude" by people who had been writing to them and not receiving replies, and a number of mailboxes were slowly collecting a mixture of dust and emails - inflating like balloons in some cases and eating up disc space with unread messages.
As with any problem, a quick analysis and a step back from the issue points to a straightforward solution ... and in this case the solution is email forwarding. Once email forwarding is implemented on all the accounts concerned, the multilogin / multirole features that are needed will be working a treat, and the lost email accounts will no longer be acting as accumulators.
Posted by gje at 02:51 PM | Comments (0)
November 03, 2006
Python - A list of methods
In Python everything - even named blocks of code - are objects. Which means that you can have a list or a dictionary of functions, and you can pass named blocks of code in and out of other functions and methods
games = []
colls = [350, 120.5, 1, 400, 289, 400]
c2 = [4,3,4,5,4,7]
games.append(lambda x,y: x//15 + y)
teams = map(games[0],colls,c2)
print teams
The code above shows you (briefly) the mechanism. By setting up dictionaries or lists of code, you can selectively run algorithms based on an index or key - something I've seen used really nicely as an alternative implemnetation to a switch wihich Python (rightly in my view) lacks.
Posted by gje at 06:52 AM | Comments (0)
Useful link: Python training
November 02, 2006
Recursion in Python
I'm not a great advocate of recursion - pieces of code that call themselves; most of the examples that I see in books are "training examples" that are overcomplex and achieve results that could much more easily be achieved by alternative means. I'm not telling you NEVER to use recursion - sometimes (such as when you're travesing XML, for example) it does work very well.
Anyway - one of the dangers of code that calls itself is that it will get into an endless loop and so there will be a limit to the number of levels deep you can go. That defaults to 1000 in Python, but you can increase it - there's a setrecursionlimit method in the sys class. Here's an example of it in use:
# Python defaults to a recursion limit of 1000 levels, which
# you can change - see this example. Beware - it's said
# that the standard windows build has a hard limit of 2000
# that you cannot exceed!
import sys
sys.setrecursionlimit(1500)
def zz(x):
if x < 1: return 0
result = zz(x-1) + x
return result
print zz(1200)
Without that extra line, you get the error message
RuntimeError: maximum recursion depth exceeded
when you run the code
Posted by gje at 01:10 AM | Comments (0)
Useful link: Python training
November 01, 2006
Letter Home
Course went well ... but an awful day with the car. As I drove in to the college in Inverness where I'm training, I saw that one of my headlights was out so I bought a bulb ... and came to fit it in the college car park. But the bonnet wouldn't open. Called the AA and I had to give them a one hour slot with me AT the vehicle for them to come, so I was in the freezing car park (there's snow visible on the hills here) from 12:15 to about 12:45 when he arrived. By twenty past one, he wasn't into the car and was throwing his hand up "I dunno what to do" ... not one of the 90% they get sorted at the roadside, alas, and I was on to looking to use other resources to get on the road for the evenings and drive home.
While still light - it gets dark early this far north at this time of year, I drove up to the Renault dealer, close by. Of course they didn't have a mechanic to look at it straight away but I left the car with them ... and they called me back about an hour later to tell me that they had got into the bonnet and that the latch was broken (I knew that!). No spare in stock and so, whilst they could replace the bulb, they couldn't guarantee that they could securely close the bonnet when they had done so, so it might fly open when driving. Oh - and on the other hand it might take another garage to get in again next time.
They can get a spare latch to them by first thing Friday morning, so I've left the car there and one of the delegates has given me a lift back to the hotel with the kit (because it's the night we're changing from Inverness College to the Holiday Inn Express ... no room available all through anywhere ... and the delegate's picking me and the equipment up at my hotel (Travel Inn) at 08:15 in the morning.
I know that courses for these people will always be memorable ((I also know they're net savvy and prossibly read this stuff ;-) )) - I came up a number of years ago and in that case trained them on Skye and it's a course that I still remember well. The playing of the fiddle, the harp concert at lunch time and, so much, lovely people - quiet, twice as bright and twice as resourceful as the typical delegate - I remember being exhaused at the end of every day last time too!
And, of course, they're still lovely people. It's so much the norm when I'm away to present a course that everyone has a home to go to and I sit on my tod in a hotel room; actually I'm used to it but it's still a pleasure, and indeed it was a huge pleasure, to join them last night for Spanish Tapas and a pink of non-alcoholic summat at the Harlequin on Castle Hill just thereafter.
The memories of xxxx, yyyy and zzzz will endure much after the car incident fades to the back of my mind. Why - I can remember an Indian meal with Lisa also on Castle Hill in Inverness which must have been - what - the best part of 10 years ago now. Perhaps she'll join me again next time.
Posted by gje at 07:03 PM | Comments (0)



