March 19, 2010
Stairs
I was in Trowbridge in the afternoon, dropping off some papers ...
Here are some stairs. I know they are stairs. Why do I need a sign to tell me they are stairs?
Note for the reader - this picture has been slightly retouched so that you can more easily read the sign; the sign is not illuminated.
Posted by gje at 11:44 PM
| Comments (0)
More about Graham Ellis of Well House Consultants
Related topics: via article database
March 18, 2010
Exception handling in PHP
PHP has exception handling - where you can try a block of code; it it completes, that's good and normal, but if something doesn't work in the normal manner an exception is thrown, and a piece of code to mop up the problem is run, in a catch block.
I've written an example to show this ... I have a function that will return the first or second half of an input string, but if the string that's input to it is an odd number of characters long, it can't work so it throws an excpetion. See that code - the function and the exception handler too - [here].
Here is what I get when I run that code:
Dorothy-2:sj grahamellis$ php exp.php
Ple-ase [use] [various] excep-tions i-n [PHP]
can't cut use in 2
can't cut various in 2
can't cut PHP in 2
Dorothy-2:sj grahamellis$
Exceptions were only added to PHP quite late in the day, so you'll find that many issues with older functions are handled as errors and warnings, but modern OO based functions (and new code you write!) should use exceptions. Exception objects have a number of methods you can run on them - in the example I've given, you'll see that I've used getMessage to find out a description of the exception.
Posted by gje at 11:00 AM
| Comments (0)
Useful link: PHP training
Related topics: via article database
Car Parking in Melksham
Car Parking in the centre of Melksham is a major concern to many residents of the town and the surrounding area. Shops out of town are limited with a very limited bus service to may parts, driving is the only practical way to "nip quickly into town".
This April, car parking costs across Wiltshire will rise roughly in line with inflation, according to Dick Tonge, Wiltshire Council cabinet member with responsibility for parking within his portfolio. But for next year (starting April 2011), a radical shakeup is planned - Mr Tonge hopes to move forward to a system that's more fitted for the future, and rationalises the 25+ different parking regimes he interited in Wiltshire to a much more manageable handful. And he is seeking inputs and suggestions as to what people think should be done, through organisations like the Community Area Partnership and the Wessex Association of Chambers of Commerce. This will be a process that lasts up to nine months.
At a meeting of the Chambers of Commerce on Saturday, 13th March, this was discussed, and particular concerns expressed across the county were:
* The need for short term parking, preferably at no charge, to quickly 'nip in to the bank'
* The need for parking for staff without charging them an hour's salary per day, or forcing them into neighbouring streets
* The feeling that the Council is Draconian - making a lot of money out of 5 minute overruns and other minor infringements
* Fees such as 55p per hour, and machines offering no change, forcing people without a 5p coin to overpay.
The suggestion has been made to drop the 25 regimes to just 4, and initial inputs were being sought as to the potential rates and changes. However, this is an opportunity to look somewhat more radically at the matter and consider options such as:
* Pay on exit, so you only pay for the time used
* Ring and Go / other mobile payment schemes, so you can "top up" if you get caught in a queue
* Payback schemes, where you get a refund of your parking costs from a shop that you use
* More frequent local buses from suburbs
The present pay on arrival, and pay for how long you're staying "up front" system was critisized for various reasons:
a) With a ticket displayed in your car, thieves know which cars they car can more safely target at the owner will be away for a long time
b) Shoppers sometimes have to cut short their trips as their ticket is running out; it is unrealistic to expect people to know if there will be a long queue in the bank or not!
c) Wardens seem to pounce on cars that overshoot by just a couple of minutes, to the extent that it seems they might be doing so to get commission payments.
d) More cautious shoppers often have to but a ticket for far longer than their actual stay, just in case the time is exceeded.
e) It's not practical for visitors to extend their visit if they're really enjoying the town.
With any of the fairer schemes, it needs to be noted that the income needs to remain at current levels, so that charges may need to go up to compensate for the reduction in income from fines, and from people overpaying. It is said that each of the two car parks in Westbury costs 48,000 pounds a year to run, although it is unclear how that figure is reached.
There are specific issues in Melksham:
a) Parking for staff, especially part time, at an affordable price
b) Parking in residential areas, such as Thackeray Crescent
c) Blockage of the town centre by a heavy flow to the short term spaces in Church Street, when King's Street and Lowborne might be better for this.
d) Discouragement of business by the current setup
e) Gaps of 50 minutes in every hour in bus services to Bowerhill, Semington Road, Roundpond, Berryfield, Riverside ... let alone to the villages.
f) Loss of spaces when Market Square becomes a more pedestianised area
Watch out for further development of this story. If you would like to make your point, come along to the Melksham Chamber of Commerce meeting at Well House Manor on 13th April at 6:30 p.m., or contact the president of the chamber - Graham Ellis - graham@wellho.net. There will be other opportunities to make inputs later in the year, but if you have any brilliant ideas not let us know. Dick Tonge is said to regard car parking as something of a poisened challice, and if you have a good, practical solution for him, I'm sure he would be delighted.
Car parking and its fine balance will be different between the different Wiltshire towns - each has its own characteristics and needs, and current "hot issues". The pictures illustrating this article show parking in Devizes, Trowbridge and Melksham ... and a core strategy planning meeting in Melksham.
Let's join up the core strategy, economic development, a more radical transport plan than includes offering a practical public transport alternative for those who want to use it ... for the good of all. Let's move away from a parking scheme which seems at times to have swelling income and traffic enforcement staff employment, to the detriment of businesses served by the car parks.
Posted by gje at 07:34 AM
| Comments (0)
Related topics: via article database
March 17, 2010
Adding extensions to PHP Open Source applications - callbacks
Over the last two days, I've installed and configured MediaWiki, WordPress, Status.net and Drupal on one of our training systems, and looked (in each case) at how to configure them and install extra plugins / modules - both starndardly available ones, and also how to start writing your own.
In two days we've only been able to scratch the surface of these huge topic, but the question arose "How do the standard packages see / register call the add ons". Details vary, but much of it is done through the use of callbacks. So - how do callbacks work?
The base code of each of these open source applications includes arrays which contain the names of all the functions that might be called - as strings. And other strings can be dynamically added to the list too.
When the code if run, these extra routines will be called at predetermined places in the source, thus running that extra code; a check with function_exists ensures that the application doesn't fall over by trying to run code that's not available. There's a demonstration [here] which shows you the mechanism.
I was very impressed by the extensive documentation in MediaWiki for its extension hooks - see [here] - perhaps this is the open source applicaion that I'm most familiar with tailoring, although we also use the SMF forum in many guises ;-)
Posted by gje at 06:53 PM
| Comments (0)
Useful link: PHP training
Related topics: via article database
Tcl - a great engineering language
It might be a little old and out of fashion - but Tcl is still very much in use, we use it and we can offer you a learning to program in Tcl training course if you're new to programming, or a Tcl Programming course if you've programmed in another language before. We also offer a two day Tk course as a follow up if you're going to be using that GUI.
Tcl is a very stable language that's great for engineers and we quietly get a lot of web site traffic looking at the examples on our web site. It's because one of those examples bubbles up to over 50 accesses per day that I've been reminded just how important the language remains.
Here's part of that popular page: [full example]
if [expr $cost > 100] {
set cost [expr $cost * 0.8]
puts "SPECIAL Group ticket at $cost"
} elseif [expr $cost > 20] {
set cost [expr $cost * 0.9]
puts "Group ticket at $cost"
} else {
puts "Total Price will be $cost"
}
Although the code looks fairly conventional, Tcl is actually a command base language rather than an operator based one. And that means that in the code above, spaces and line breaks are significant. if is a command. It takes a minimum of two space separated parameters - in this case there's one in square brackets, and one in curly braces. The curly brace parameter lasts severla lines ...
There are five more parameters to if in this particular example - "elseif", a "[]" condition, a "{}" block, "else" and finally another "{}" block. You'll note that only the "{}" blocks carry on from line to line - normally a new line is teh end of a Tcl command, and that means that placing the "{" on the end of the first line (and preceeeded by a space) is vital.
I really enjoy working with Tcl / giving courses in the langauge. For sure, I do more training on the likes of Lua, Python, Ruby and PHP these days, but please get follow the course links or get in touch if you would like a Tcl course!
Posted by gje at 06:21 AM
| Comments (0)
Useful link: Tcl training
Related topics: via article database
March 16, 2010
Static class members in PHP - a documented example
Within a class, you can have dynamic or object variables and methods, where the code and the values associated with it are applied to individual objects. They're far and away the majority of your variables / methods - in yesterday's public transport service exercise, each train or bus had a potentially different start time, for example.
But just occasionally, you need a static or class variable or method, which applies to the class as a whole.
In PHP, you can define a static variable within your class using the static keyword (and you should initialise it as you do so):
static $id_service = 0;
You can then reference that variable within both static and dynamic methodsusing the notation self::...:
self::$id_service++;
You can define static or class functions too, but they can only access static variables - they do NOT have any $this-> access:
static function next_id() {
return self::$id_service + 1;
}
Within the calling code, you access the static method using the notation class::method:
print ("The next service will have id ". service::next_id() ."\n");
There is a complete example [here] from which the above lines of code have been "Cherry Picked"
| When should you use static members? Very rarely indeed!! There's a great temptation to use them to hold a count of the number of objects you have of a type, but that approach can fall over on you if you want to create a number of different groups - you should hold them in arrays and count the arrays if that's what you need to do. My example for this post uses a static variable to assign a unique ascending ID number to each object of a type; that's subtley different, and a good use of statics. |
Posted by gje at 07:11 AM
| Comments (0)
Useful link: PHP training
Related topics: via article database
How to build a test harness into your PHP
I was writing a PHP demonstration yesterday, and I wanted to include a test harness with my class definitions that I could leave in place on the live code on my server, to be silently skipped over ... but which I could re-use at a later date for testing class changes, etc.
How did I do it? An environment variable, which I need to provide in order for the test harness to be run. My PHP code contains
if ($_ENV["TESTING"]) {
# Test environment - run the file
# On a production run this will be skipped!
# Test code here
}
And it runs like this:
Dorothy-2:sj grahamellis$ php staticmember.php
Dorothy-2:sj grahamellis$ export TESTING=1
Dorothy-2:sj grahamellis$ php staticmember.php
Service leaves at 05:19
Service leaves at 16:39
Service leaves at 07:02
Service leaves at 17:02
The next service will have id 5
Dorothy-2:sj grahamellis$
Posted by gje at 06:47 AM
| Comments (0)
Useful link: PHP training
Related topics: via article database
March 15, 2010
Reaching out to the community - a good case for support
Over the past few weeks, I've attended a number of town and parish council meetings in Wiltshire. I've sat in and listened to talk about flooding and drainage at Dilton Marsh, about who should be the next deputy Mayor in Westbury, and to signage issues at Warminster last night. And it has struck me - come to the table knowing what you want, why you want it, and knowledgable on your case.
Last night, the councillors were really very good with one member of the public, who was looking for signage to her (public sector) establishment. But she didn't know if she wanted it for vehicles or pedestrians. She knew the request had been made before, but didn't know to whom, or why it hadn't been taken forward. She was aware of parking problems, and that her car park didn't always have spaces for everyone ... but she was sure in her mind that the people who came to her place weren't the cause of the problems, but had no confirmatory evidence. And it wasn't at all certain that this was actually a matter for this particular level of local government either. Full credit to the councillors for their patience - I have been very much impressed as I've been doing the rounds, and the person looking to sort out the parking did leave with a possible way forward.
Why was I there? To ask for the support of the local councils up and down the TransWilts railway line for their support of the idea of a Community Rail Partnership - an idea that's budding in the area, with the community and the rail industry coming together for the mutual benefit of both. We've got a public launch meeting at 19:30 on Friday, 26th March at Bridge House in Warminster, and we want to get a wide variety of people - individuals and group representatives - along. I'm asked "what will the outcome of the meeting be". Well - we have ideas, but we'll be looking for inputs from everyone so I can't actually tell you. This isn't going to be a scripted meeting.
Outcome in Warminster? As in each of the other places ... a short presentation, some excellent questions, and a vote unanimously in favour of sending a representative along on 26th. In reallity, it's an "easy sell" for us - a no-brainer.
What is a Community Rail Partnership [here].
How to get to the meeting on 26th [here]
"I can't attend but I'm VERY interested" - sign up form [here]
More detail - the flyer about the event [here]
Posted by gje at 11:10 PM
| Comments (0)
Related topics: via article database
March 14, 2010
Blowing out the winter cobwebs



Spring was here for the first time this weekend - and Sunday afternoon was an opportunity to blow out the cobwebs a few miles from home on the Westbury White Horse.
Posted by gje at 11:00 PM
| Comments (0)
Related topics: via article database
March 13, 2010
Changing Times
We try to be helpful ... and when we were getting a lot of hits on our web site for people looking for arrivals at a local public transport place, because we were top Google hit for certain keywords, I dropped them a note to suggest that they make some changes to their web site wording.
I got a really snooty email back - along the lines of "we are Bristol INTERNATIONAL Airport and not Bristol Airport, and if people do the right search for 'Bristol International Airport Arrivals', they do find us".
So I was rather amused to see on the local TV news last night that, with a big fanfare, Bristol International Airport is renaming itself as Bristol Airport. I wonder if that Snooty c*w is still there ...
Posted by gje at 07:42 PM
| Comments (0)
Related topics: via article database
