« June 2008 | Main | August 2008 »

July 31, 2008

Punting on the Cam

I've been giving a Perl course in Cambridge this week and last night, driven out of my hotel room by the heat, I walked down to the river, bought myself an ice cream, and watched the couples, the tourists, and the punters go by.

You'll find bicycles everywhere in Cambridge they say. And until yesterday evening, I hadn't taken them literally - but perhaps I should. And this picture is a lesson that you should have a camera with you at all times, isn't it? Fortunately, I did!

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

More about Graham Ellis of Well House Consultants

July 30, 2008

Back from the future

It's good to take a strategic look ahead from time to time - not a look at the immediate tactics of the next step or two along the way, but a look far into the future, and see where we will be in many years time. A good friend of mine (a Doctor) who is something of a Timelord has downloaded the following for me from my future blog ... where I comment on transport in 2032. I wrote ...

25 years ago, in 2007, I attended the "Enquiry in Public into the Regional Spatial Strategy" in Exeter - a look ahead to government planning for housing and travel in the South West of England for the following 20 years. Arguments ranged about road developments, about where housing and employment should grow (and by how much), and so on. And it's interesting to look back now and see where we are today - how events have overtaken and modified the plans as they were made in those day, before energy prices rocketed from 2007 onwards, and ever decreasing resources and global warming forced some radical changes.

HISTORICAL BACKGROUND

In the South West, 2007 and 2008 were the peak years for long distance road passenger travel; a doubling of crude oil prices in 2008 lead to a 30% rise in petrol prices which lead to a move to more efficient private vehicles but, ultimately, a move on from the era where a family's affluence was measured by the number of cars they ran.

Long distance rail travel grew for several more years - peaking in 2010; the fuel price rises at first pushed people off the roads, and then (with rail prices rising too) more and more people reduced their journeys - working from home, holding electronic meetings, etc. The number of leisure journeys grew - but the length of such journeys dropped. Instead of holidaying in the Caribbean, our Prime Minister holidayed in Southwold.

Shorter public transport journeys - which we classify these days as local (up to 10km) and regional (up to 100km) continued to grow and indeed continue to grow to this day. Companies like First Great Western provided nearly all the rail services in the South West in 2007, and had bid for an operating franchise based on the "cash cow" of long distance travel and took on local services - with a forecast of 0.8% growth - only because the government forced them to. They found themselves seriously wrong-footed, and we went through some very interesting times. Totally inappropriate services were provided for a while - overcapacity from London to Bristol, but at the same time no practical service at all for regional / local services such as Oxford - Swindon - Trowbridge.

OVERVIEW - CURRENT SERVICES

How are services run today, then?

Almost every train service runs hourly, from 5 a.m. through to midnight.

Long distance trains stop every 40 or 50 miles, with a top speed of 90 m.p.h; faster than that was expensive in terms of extra energy use for very little gain. In any case long distance commuting is a thing of the past - people are now travelling to occasional meetings, or for leisure purposes on these services. Trains vary in length - up to 12 coaches on some routes, with 9 coaches for passenger seating, one customer service car, and a power and light goods car on the front and rear.

Regional services, which connect well at key points with long distance trains and other regional services, also run with a top speed of 90 m.p.h. Typically, they're "all stations" services stopping every 10 miles or so. They miss out some stations in urban areas where there are also local train services. You'll find up to six or seven coaches on a typical regional service - a power / light goods car, a customer service car, and up to 5 passenger coaches.

Local trains, in urban areas, run rather more frequently - at least once every 30 minutes, and sometimes more.

A high speed rail link was built in the first decade of this century, linking London to Folkstone for the Channel Tunnel. A project for other high speed lines, and trains called "HST2"s to run at very high speeds, were started. But after the Channel Tunnel link, none of these was completed. You can see some of the earthworks in the Midlands where construction was started and then abandoned ...

STOCK

The long distance trains (LDTs) that are running today use PEST (Practical Electrical Storage Technology). In other words, they're electric trains, but with no need for third rail or catenary that made electrification so expensive in infrastructure in the 20th Century. Originally designated "125" trains and capable of 125 m.p.h., these (now)electric trains have origins going back some 60 years. They were re-engined after about 30 years, with an intention of extending their life by another 10 years, then converted to stored electricity technology a few years later. Slower running speeds mean reduced energy use, reduced wear and tear, and it's no longer important to shave a few minutes off journey times. In any case, better acceleration compensates for lower top speeds, and a more uniform line speed increases line capacity in busy areas.

Regional trains (RTs) are also "125"s converted to PEST - or rather they are "half 125s". Half the length of long distance trains, single power coach, and with a streamlined cowling on the other end of the train. The much reduced frequency of long distance trains lead to a surplus of units, and the elimination of peak demand in what used to be a peak hour released more of them - and each spare LDT converted to two RTs.

Local trains, also PEST powered, have a top speed of 60 m.p.h, which is plenty. Electricity gives excellent acceleration, and distances are short. Once again, you'll find old diesel units at the heart of most of the local trains - former class 150 units from all across the country now work in the West, forming 4 car local trains in Bristol, Exeter, Plymouth.

SERVICES

This example is from my own region - trains to and through Severnside which stretches from the town of Bent on the northern flank on Salisbury Plain up to Tewkesbury, across to the Welsh border and down to Taunton and Yeovil.

• Long Distance Services every hour:

Paddington - Reading - Swindon - Badminton - Bristol North - Severn Tunnel (passport control) - Newport - Cardiff

Paddington - Reading - Westbury - Castle Cary - Somerton - Taunton - Exeter - Newton Abbott - Plymouth

Exeter - Tiverton - Taunton - Bristol Central - Bristol North - Gloucester and Cheltenham - Birmingham - Crewe - Liverpool

• Regional services every hour

Swindon - Wootton Bassett - Chippenham - Corsham - Box - Batheaston - Bath - Bristol Central - Nailsea - Weston-super-Mare - Highbridge - Bridgewater - Taunton - and stations to Minehead

(from Bedford) Oxford - Abingdon - Didcot - Wantage - Shrivenham - Swindon - Wootton Bassett - Chippenham - Lacock - Melksham - Staverton - Trowbridge - White Horse - Westbury - Frome - Bruton - Castle Cary - Sparkford - Yeovil (to Exeter and Plymouth via Tavistock)

Swindon - Kemble - Chalford - Stroud - Stonehouse - Gloucester and Cheltenham - stations via Lyndey and Chepstow to Severn Tunnel

Reading - Theale - Newbury - Kintbury - Hungerford - Bedwyn - Pewsey - Lavington - Bent - Westbury - Frome - Radstock

(from Wales) Severn Tunnel - Bristol Central - Bath - Trowbridge - Westbury - Salisbury - Romsey - Eastleigh - Fareham - Gosport - Portsmouth.

• Local Services

Salisbury, Wilton, Codford, Warminster, Dilton, Westbury, White Horse, Trowbridge, Bradford-on-Avon, Avoncliff, Freshford, Limpley Stoke, Batheaston, Bath, Oldfield Park, Saltford, Keynsham, Brislington and Bristol Central. (2 times per hour)

Weston-super-Mare to Bristol Central, Bristol North, Gloucester and Cheltenham, Ashchurch and Worcester (All stations, 2 times per hour to Gloucester, then hourly)

Portishead and all stations via Bristol Central and Bristol North to Severn Tunnel (2 times per hour)

Bristol Central and all stations to Clifton, Avonmouth, Henbury and Bristol North (2 times per hour)

Bristol Airport and all stations to Avonmouth (via Bristol Central, Bristol North, Pilning and Severn Beach) (2 times per hour)

• Connections

One of the key features of the rail network is to provide for true door to door journeys with excellent connections all along the way. Although trains are less frequent on some lines than they used to be, they are always "clockface" at all times of day, and connect excellently.

Taking my own regional service from Melksham, for example, it offers a rail connection into the Salisbury and Portsmouth express at Westbury (the two trains pull in alongside each other), a connection at Yeovil for Weymouth, at Exeter for Kingswear, for Exmouth and for Ilfracombe, and at Plymouth for Cornwall. In the other direction, there's a connection at Chippenham for Bath and Bristol, at Swindon for London and South Wales, at Oxford for Birmingham, at Milton Keynes for Liverpool and for Gretna, and at Bedford for Sheffield and the North East. With all services being hourly, other changes no longer involve the 2 or 3 hour waits we were familiar with in 2008 under First if - for example - you wanted to travel from Melksham to Westbury and on to Taunton.

STATIONS AS RAILHEADS

"Door to door" is the objective of public transport, so you'll find that nearly every station is now fed by a network of PEST Trolleys - vehicles that carry up to 20 passengers at speeds of up to 20 m.p.h. and congregate at stations just before trains are due, leaving shortly after trains have called. They're automatically driven along fixed routes and to a timetable, but with extra vehicles on standby to provide some fillin at busy times.

Talking Melksham - most services run from the 2012 station hub at the Dunch Lane retail park (formerly Leekes)

Service 1 - Bromham - Sandridge - Forest Road - Town Centre - Station - Whitley, Atworth, Stonar
Service 2 - Hilperton - Semington - Town Centre - Station - Avon Road - Beanacre - Lacock village
Service 3 - Bowerhill - Spa Road - Town Centre - Station - Broughton Gifford - Holt
Service 5 - Station - Town Centre - Woodrow
Service 6 - Avon Meadows - Station - Town Centre - Queensway - Snowberry - Snarleton
Service 9 - Station - Town Centre - Spa Road - Melksham Oak - Sells Green

Through services are not provided to neighbouring settlements, but route ends co-incide for good connections. For example, Service 1 at Bromham connects into the service via Devizes to Lavington, and at Atworth into the service from there to Box.

OPERATIONAL MATTERS

All trains operate under the Train Operation and Safety System for Automated Railways (TOSSAR). This is a driverless system that used GPS over a secure network to track train positioning, and wide area rail track analysis (WARTA) to monitor the condition of the track and its surround with the passing of every train.

Trains carry enough PEST cells for 8 hours of running, with cells being replaced at selected stations throughout twice a day on each unit. PEST cells take up to a week to recharge through solar, wind or wave power. Some services even make additional stops to ensure that the cells can be replaced without the need for further transportation of them. (Dawlish, Pilning for wave energy).

All stations now have security in the form of Station Entry Arches (SEARCH) which undertake necessary security checks and note traveller's Wireless Credit Cards (WCCs) to charge for the journeys. There is no longer any need to purchase tickets ahead of time.

Services operate 7 days a week, from around 5 a.m. to midnight, with closure from 00:30 to 04:30 to allow works to be carried out on the tracks. Minor train maintainance is carried out overnight, with trains undergoing further (full day) maintainance at regular intervals. Such maintenance is a 7 day a week operation too.

Schedules are set to include an extra 10% for unforeseen delays on each stage of the journey. There's a target for 99% of service to arrive at each station they call at within one minute of the scheduled time, and for 99.9% to arrive within 4 minutes. These targets are regularly achieved.

STAFFING

All trains except local trains convey a customer services coach with a customer services representative on board who can help you with travel information, sell you refreshments, etc. The customer service representative is also a trained rail safety officer who is on hand to deal with any emergency situation.

PRICING

Journeys are charged at 3.5 Euros per mile (that's the equivalent of 35p per mile at 2008 prices) with an additional charge of 20 Euros for each journey to cover administration costs. So that a 100 Mile journey from (say) Melksham to London would cost 370 Euros (37 pounds at 2008 prices). In order to encourage regular passengers to travel at times when services are quieter, there's a 10% surcharge for travel if the train was more that 80% filled on the same day 4 weeks previous, and a 20% reduction for travel at times that the train was less that 40% filled on the same day 4 weeks ago.

All travellers may purchase an "I prefer the train" railcard for 400 Euros annually, entitling them to a 10% discount off all fares expect at the busiest (80% + full) time.

All trains are single class, and there are no longer fare reductions for Pensioners, Children, Overseas Visitors, members of the forces, students, etc. VAT is charged at the current lower rate of 21%.

FREIGHT - parcel / retail level

60 years ago, people used their local shops when they wanted to make purchases and they carried them home on the bus. 40 years ago, people drove in their cars to the store on the edge of town and brought their purchases home. 20 years ago, goods were ordered online and a much-duplicated set of delivery vehicles ran short and long distance making deliveries.

Today, we use a Package Integrated Service System. Packages are collected by local vehicles running on PEST and taken to the local railway station, where they are fed into the Warehouse for Through Freight. The luggage /power cars of long distance and regional trains pull up alongside the warehouse, and goods are automatically transferred onto trains ... and the process is reversed at the destination to give a door to door integrated system. (suggestions for acronyms, please, for the Package Integrated Service System and Warehouse for Through Freight)

ROADS

Only a few people still run their own private petrol or diesel road vehicle these days - and they're mostly historical enthusiasts; their mileage is limited by the high cost of fuel - some 150 Euros per litre (that's 15 pounds per litre at 2008 prices). But many people have PEST vehicles; although slow to charge at home through wind and solar energy, they are more than adequate for local journeys on which they are computer driven - using the same system as the trolleys. They're ideal for the school run, or for personal transport to your nearest trolley stop or station; there's no parking problems there any more, as now that they're automatic the vehicles can make their own way home, and can pick you up too, summoned to meet your train by computer control.

The former motorway and trunk road (bypass) network is to a very large extent redundant - long distance travel for passengers and freight has been very much reduced and is almost exclusively rail based. In my own part of the world, the M4 motorway still has some use with extra junctions every mile or two making it into a useful local road. The A350 bypass sections around Chippenham and Melksham are used for local traffic, but the Westbury bypass, built against all forward looking advice and without and intermediate accesses, turned out to be a whiter elephant. There's simply no need these days for a road that avoids the major transport hub at Westbury station, and it's now the most beautiful of tracks for walkers, cyclist and riders who want to take in the magnificent Well Head Valley and fine views of the Westbury White horse it affords.

AIRLINES and SHIPPING

Air travel has also reduced in the past 30 years; still relying largely on fossil fuel as PEST cells are very heavy, flights are now down to a strategic set of long distance routes. In our area, Bristol flights run every 4 hours to Rekjavik (for connections to North America), Amsterdam (for connections to Europe) , Bagdad (for connections to the East), Cassablanca (for connections to Africa and South America) and Dundee. Flight prices are based on 5 Euros per mile (50p at 2008 UK prices).

There has been a resurgence in passenger travel by sea over very long distances; rather than fly to the USA for an annual holiday in Florida, most families will make in the trip of a lifetime, taking a month out and travelling on the daily liner from Liverpool.

Graham Ellis
Melksham
Friday, 30th July 2032

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

A short Perl example

#!/usr/bin/perl -pa
$_ = "$F[0] $F[-2]\n";

What does that Perl code do?

Although it's very short, it's also somewhat obscure, and my delegates yesterday were not at all sure that they would wish to be given code like this to maintain ... but then they admitted that they have seen things like this around ...

There are some Perl programmers who take what I feel is a perverse delight in writing their code as short as possible, even to the extent that it looses clarity; for sure, you should make good use of the Perl language and its facilities to avoid needless loops - use a grep in place of a foreach loop with a regular expression check and a push, and slurp a file into a list by all means rather that reading in through a while loop - but the above takes it just too far!

Oh - I asked you what it does, didn't I? It reads the file named on the command line in line by line, and prints out the first and next-to-last field on each line, throwing away the rest of the data.

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


Useful link: Perl training

July 29, 2008

Equality and looks like tests - Perl

Whenever you do an equality check in a Perl program, you must think whether you're checking if two numbers are equal, if two test strings are equal, or if a string looks like a pattern. And you write different code in each case:

Checking numbers: If ($stuff == 6) { ...
Tests whether $stuff contains the number 6 (or a string that evaluates to the number 6, or the number 6.0)

Checking text string equality: If ($stuff eq "Well House") { ...
Tests whether $stuff contains exactly the string "Well House"

Checking a text string against a pattern: If ($stuff =~ /hotel/i) { ...
Tests whether the string in $stuff contains, somewhere within it, the word "hotel" in upper case, lower case, or a mixture.

You need to be especially careful not to use the == (numeric) operator to check text strings, as text strings that do not start with digits return zero - so (for example) it would always tell you that two names are the same!

Here's an example to illustrate that:

print "What is your name? ";
chop($hes = <STDIN>);
 
# Numeric equality
 
if ($hes == "Graham") {
   print "Hello and welcome\n";
} else {
   print "Not known\n";
}
 
# String equality - EXACT match!
 
if ($hes eq "Graham") {
   print "Hello and welcome\n";
} else {
   print "Not known\n";
}
 
# String match to regular expression
 
if ($hes =~ /Graham/) {
   print "Hello and welcome\n";
} else {
   print "Not known\n";
}

And some results from testing it:

Dorothy:cs2 grahamellis$ perl u
What is your name? Graham
Hello and welcome
Hello and welcome
Hello and welcome
Dorothy:cs2 grahamellis$ perl u
What is your name? I am Graham Ellis
Hello and welcome
Not known
Hello and welcome
Dorothy:cs2 grahamellis$ perl u
What is your name? Simon Smith
Hello and welcome Test zero against zero
Not known
Not known
Dorothy:cs2 grahamellis$

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


Useful link: Perl training

July 28, 2008

Hot Courses - Perl

It feels like a heatwave! Or rather "summer has come to the UK".

We were doing some sums on today's private course in East Anglia, which is running at the customer's office with some 16 delegates (far more than on our public courses, where the limit is 8) so that made 17 of us in the room, plus 18 laptops and hubs and a projector.

17 people at 500 watts
18 laptops at 75 watts each
2 hubs at 20 watts each
one projector at some-more watts

So that's over 10 Kwatts - or the equivalent of 4 electric fires running full blast. No wonder that the air conditioning unit was struggling!

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


Useful link: Perl training

July 27, 2008

A future vision for Melksham

"Melksham should be like this" said Lisa as we walked around another Wiltshire town, somewhat smaller that ours, this lunchtime - and indeed she's right.

A waterway passes through (both) towns, and it could be so active - you see canoes, walkers, cyclists and boaters all making use of the water corridor through the town, and all bringing welcome business in too. The Wilts and Berks Canal Trust is working hard on bringing this to pass and indeed there IS hope - the section you see here was closed for around 40 years, and re-opened only in the last decade.

The River and hsitoric bridge in Melksham should be a huge asset to the town, and somehow they can disguise the factory with boarded up windows you see in the background here.

Melksham has a wide range of historic buildings - in around 1800 it was the largest urban area for a LONG way around and much remains from before or around that time. But it does need local inspiration to help this along and organisations such as Melksham 1st (of which we are members) are working on this.

We know that Melksham has been christened the "Takeaway Capital of Wiltshire" and so it is - and we have excelling Indian and Chinese restaurants in the town, cafes, and pubs that offer meals too. But we need to attract visitors with - say - Thai, Italian and a Tapas Bar (this picture was taken in a Tapas bar) and a quality restaurant where you don't have to book. It can be done - it has been done in my comparison town.

A good transport infrastructure, with an appropriate level of services again will bring in the business and subsidies given will be recouped by the county council via the extra wealth generated in the town. The Melksham Railway Development Group is key to the local (Melksham) campaign, and in the last three years the case for an appropriate service has been recognised, and has moved from a "no hoper" to something that will more than likely come about in a year or two (though politics being what they are, we may have to wait for a change in government and/or key players at County Hall)

The question has to be asked - "would we need more hotel rooms?" Maybe - but I wouldn't anticipate a need for many more central rooms, and new B&Bs spring up all the time - for example Sandridge Tower at Bromham, who's owners have written to me in the last few days. Our own Well House Manor is too small to make any appreciable impact on it own, but who knows - we could help by adding a few more rooms.

Am I being unfair in my comparison here? Have I chosen a bigger and better resourced town to compare Melksham to? No, I've chosen a town that's about a half of our size - so we should be able to achieve twice as much. But, yes, I have chosen a town that's got better resources - in the most part because they worked hard for them as we should be doing!

If you're not "in the know", my comparison is against Bradford-on-Avon, just six short miles up the road from us.

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

addslashes v mysql_real_escape_string in PHP

One of the most popular pages on our website is the one that shows you how to upload an image and store it in a database. And the associated demonstration showing you how to view images via a PHP script from a MySQL database is very popular too.

An image may contain and ASCII characters at all ... so you can't just take the image data that you uploaded and put it into the MySQL INSERT statement - special characters such as NULL, and the double quote character, will cause problems - at best like the illustration you see accompanying this posting, and at worst you would leave yourself vulnerable to an injection attack.

PHP provides a number of routines to allow you to add in extra characters to the uploaded image to protect the special characters from the database handler and ensure the data does truly get inserted into the database.

addslashes use to work very nicely before the days of different character encoding - but it can't cope with that encoding in more recent MySQL versions and should no longer be used ...

mysql_escape_string adds in appropriate slashes but it doesn't take care of the current encoding type if it's none-default; this function was deprecated at PHP 4.3.0 and replace by the one you should use ...

mysql_real_escape_string which adds in the appropriate protection taking into proper account the current encoding.

If you're using the mysqli functions rather than the mysql ones, you should use mysqli_real_escape_string which is just an alias to mysql_real_escape_string

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


Useful link: PHP training

July 26, 2008

Bath - Melksham - Devizes. Bus route changes, new timetable

Bus service (route and timetable) between Bath and Melksham

Bus routes have changed recently. The former First routes X71 and X72 have been replaced by the 271, 272 and 273. Faresaver also run a service, which is their route 272.

If you're wondering why the service numbers have changed ... it's because the route has altered beyond Devizes. Until recently, the buses continued on past Devizes via Potterne, West Lavington, Market Lavington and Easterton where they terminates and turned around apart from a very few which carried on and turned around at Urchfont. I understand that there were safety concerns about the turning point at Easterton, so the buses now travel alternately from Devizes via Urchfont and via Potterne to Easterton, allowing them to carry on through that village (as the route comes in at opposite ends) without having to turn around. Buses running via Potterne are route 272, and via Urchfont are route 273.

Route 271 runs from Bath to Devizes, and takes a different route in Melksham, serving Queensway and Melksham Forest rather that Well House Manor and Spa Road.

Buses via Whitley do not bear a different number - you just have to know which buses they are if you want to go there!

First's Bath to Melksham bus timetable

Buses leave Bath for Melksham (Well House Manor) and onward to Devizes as follows:
Monday to Friday: 07:00 and every hour to 17:00, then at 20:20
Saturday: 09:00 and every hour to 17:00, then at 20:20
Sunday: 10:30, every TWO hours to 18:30 and then at 19:30

Buses leave from the stop in front of Well House Manor (Melksham) for Bath at
Monday to Saturday: 07:37, 09:05 and every hour to 20:05, and 22:20
Sunday: 10:34 and every 2 hours to 20:34, then 21:34

The above buses are on routes 272 and 273.
Route 271 does NOT serve Well House Manor, but is does serve Melksham town centre; addition service as follows:
From Melksham, Monday to Friday at 07:00 and 07:27
From Bath, Monday to Saturday at 17:40, 18:20 and 23:08
It is a walk of about five minutes from Well House Manor to the Town Centre

Full timetable - here

Faresaver's Bath to Melksham bus timetable

Buses leave Bath for Melksham (Well House Manor:
Monday to Friday: 08:55, 10:00, 11:00, 12:00, 13:00, 14:00, 16:33 and 17:33
An additional bus at 14:33 runs to Melksham Town Centre only.

Buses leave from the stop in front of Well House Manor (Melksham) for Bath at
Monday to Friday: 07:32, 09:10, 10:10, 11:10, 12:10, 13:10 and 15:50

No Faresaver service on Saturday or Sunday.

Full timetable - here

Notes - both operators

• Tickets are NOT interchangeable between the operators.
• Journey times 45 to 50 minutes
• Sunday service applies on bank holidays
• No buses on Christmas day or Boxing Day
• Times at Well House Manor are approximate
• Faresaver operate via Kingsdown and First via Box

Service details updated July 2008.

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

PHP examples - source code and try it out too

The move to our new server has given me the impetus to look at some of the online examples we have on our server - code you can try out, then see how it works - and I've started with some of the PHP ones ...

A sample application shell using the "4 layer model" which keeps the business logic, the web helpers and the look and feel each in a separate file (or set of files) so that each can be independently maintained. Try it!

Instead of displaying in your data in a single column, why not show multiple values per line? That's what this demonstration shows! Try it!

Five short demonstrations in PHP - showing the current date and time, including an image that changes every hour, including a message of the day, having a page that automatically echos its own URL, and a page that displays its own source code. Try it!

A simple MySQL database query - with a form to allow you to tailor it further if you wish. Try it!

It's possible for your web site to recognise the preferred language of your visitor - this demonstration in PHP shows you the bare bones of how to do it! Try it!

If you want your web site to save a file on your visitor's disc, you'll have some security issues to content with. After all, users really do NOT want to visit your page and have you potentially hide things on their system. By setting the MIME type, however, you can trigger their browser's mechanism to handle the data in a way such as offering them a "save to file". This example shows you how to save a .csv (comma separated variable) file to your user's disk - with his permission Try it!

How to create and use a multidimensional array (array of arrays) in PHP. Simple example. Try it!
and a further example of array handling in PHP Try it!

Laying out tabular data from PHP - bus times around the Melksham area. But please bear in mind that bus routes can change qith as little as 6 weeks notice and you'll find these are already out of date - but the code is good! Try it!

A demonstration of how you can use PHP to "cloak" one web site behind another; in this training example we have not rewritten style sheet and images URLs so that it gives you an inside view as to how this can be done - and alerts you to the security dangers too (we'll go through those on our PHP techniques workshop. Try it!

Pages that automatically refresh every 20 seconds or every minute are often produced using a <meta tag. This example shows you how we produce a page that updates every minute. Try it!
We also have an enhanced version in operation (if you want to sit there and watch a series of pictures while time ticks by ;-) .. http://www.wellho.net/clock/

The ASCII character set - every code in HTML from ADE-32 to ADE-255. The page shows you the codes, the course shows you how we do it! Try it!

A demonstration of PHP's switch statement - tossing a coin to give you heads or tails, and a default that handles other conditions
Try it!

Another small demonstration in PHP - entering a temperature in degrees Celsius and converting it to Fahrenheit and Kelvin. The demonstration really shows conditional statements in PHP, telling you whether water is solid, liquid or gas at the temperature that you enter. Try it!

Cookies are sent to your browser by many web based applications ... and a copy is then returned by your browser each time you visit a page on the site. This is how web based applications usually keep track of who is who in a potentially very busy environment - a critical element of web applications which we introduce on our PHP Programming course and cover in more detail on our PHP techniques workshop. This demonstration shows how cookies are set, reported back, and deleted. Try it!

PHP's Object Oriented model is now excellent - and it's the way you should code if you're writing a larger application, especially one that deals with a whole series of different types of information which are similar to each other but not the same. Instead of writing separate code for each type of thing (I am trying to avoid using the word "object"), you write a single piece of code and then a series of extras that just define the changes (I am trying to avoid using words like "extend class" in that description). An array of things ("objects, remember) can will then be handled by the appropriate piece of code when you run a function ("method") on them ... that's known as "polymorphism". We run a course on Object Oriented PHP which covers both the principles involved and their application. Of course, all the clever stuff is hidden in the code - but you can see how simple the outputs can be and link to the code from this demonstration: Try it!

There are many more samples to follow ... I had better make this just the fist page in an occasional series and come back with some more later!

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


Useful link: PHP training

Perl 6 - When will we have a production release?

The "Perl 6" project was announced some years back now, with the philosophy of "right rather than rushed" and the comment "you'll have it for Christmas, but we won't tell you which Christmas".

It's in the nature of an Open Source - community - development that the development strands will be in the public domain and that the time from announcement of a product through to final release will be far longer that it would be for a commercial product, developed in a secretive backroom to avoid the competition getting wind of the project and stealing many of the ideas. And this extended lead time is to the detriment of the Open Source product, as it leads to FUD (Fear, uncertainty and Doubt) in the minds of people who are waiting - at first patiently then perhaps less patiently - for the upcoming release.

Programming languages are surprisingly static!! That's typically what the programming organisation wants - it does NOT want to have to redevelop code written in 2005 when a fresh (and incompatible) language comes along in 2008, nor to have code that's being developed this year [I'm writing in 2008] being written off and re-implemented before 2012. So "Right rather than rushed" does make huge sense. And the naturally impatient (of whom I am one!) need to temper our impatience and remember (a) Perl 5 is a SUPERB language, and (b) Perl 6 WILL support the Perl 5 grammar so that mass redevelopment will NOT be necessary.

I headed this piece "Perl 6 - when will we have a production release?". I don't know is the answer; I'm not one of the central team and in any case, with anything that involved research and development to the extent that this does cannot be timed to specific dates. I did come across a very interesting discussion - here - if you want to read further in to the current status as it was a few months back.

Does it matter to me when we have a release? Not as much as you might at first have thought - because:
• We can still develop code in Perl 5 and (remember) it is superb
• We know enough about Perl 6 to develop with the future in mind
• Perl 5 will have a very long support tail - note the new 5.10 release

And from a Perl Training viewpoint:
• We already look ahead (briefly) to Perl 6 in our courses
• We already use some Perl 6 terms and advise our delegates on how to write code that's going to be supportable and maintainable for as long as possible
• The uptake of Perl 6 (which some have argued should be given a new name and not just the next version number) will not be so fast and overwhelming that it will make Perl 5 redundant overnight - even if it turns our to be the language that saves the world from running out of resources and global warming, large amounts of legacy code will dramatically dampen the switch to the new source language.

The is, though, a danger of Perl 6 - if it takes too much longer - missing the boat. Already you see "competitive" languages (and you'll note that I have quoted the word competitive) such as Python and Ruby and Lua making inroads into what - 5 years ago - would have automatically been Perl projects, and you've seen PHP and various other systems take over in the web programming sphere. Which is not to say that a "superb ** 2" Perl 6 won't have people flocking back. It just gets harder to see that happening by the year.

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


Useful link: Perl training

Some Ruby lesser used functions

Tidying up (as one does after the recent server move!), I came across a list of functions in Ruby which are important at times, but not exactly top of the list ... and I thought I would share them here - with a few words on each - in the hope that I might save someone a lot of hairpulling at some stage in the future!

abort - teminate your program
at_exit - register code to be run when you exit
autoload - register a class to be loaded only when used
caller - return the current execution stack
eval - evalute the given string as ruby code
exec - exit and run the given command in its place
fork - create a child process (could be a whole module on this!)
sub and gsub - perform string substitution (see under regular expressions)
lambda, proc - convert a block into a proc object
readline - same as gets but throws exception at eof
select - checks for availabilty of inputs without blocking
sleep - suspend operation for n seconds
srand - seed the random number generator
syscall, system - run system calls and commands
trap - set a signal handler (e.g. if you need to catch ^C)

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

July 25, 2008

A special day - last Friday in July

The last Friday in July is Sysadmin Appreciation Day ... thats TODAY! Today is the 9th such day ... many thanks to one of my (Sysadmin!) delagates today from bringing it to my attention!

Read mode about it here

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

July 24, 2008

Increasing Java Virtual Machine memory for Tomcat

Q. "How do I increase the memory that my Java Virtual Machine in Tomcat can use?" A question asked - not for the first time - by a delegate on todays's Deploying Apache httpd and Tomcat course.

A. Set the JAVA_OPTS environment variable. Longer answer:

If you're running on a Unix or Linux system, edit the setenv.sh file in Tomcat's bin directory to add in a line like:
export JAVA_OPTS="-Xms128m -Xmx512m"
or on a Windows system, add in to setenv.bat something like:
set JAVA_OPTS=-Xms128 -Xmx512
and restart the Tomcat server.

By default (out of the tar), Tomcat starts up with just 64 Mbytes allocated to the JVM, and that's also it's maximum. This is a very low figure, but it's a sensible default for a new install where the person setting the system up isn't into the tuning of the system.

The two extra parameters specified via JAVA_OPTS are as follows:
-Xms - the amount of memory that the JVM starts with.
-Xmx - the maximum memory that the JVM may have.
I have seen advise (but have no proof) that your should keep the -Xms figure rather lower than the -Xmx figure, since Tomcat uses more memory at startup than when it's running. The result (if you have them set to the same value) is a peak and unnecessary memory demand at startup which in an extreme case can cause a failure.

A couple of other tips:

a) You should consider using the -server option too to run your JVM in server rather than (default) client mode (actually, they're two different but related VMs). The server that's selected with -server is slower to load but is said to run faster.

b) We have customers who run multiple instances of Tomcat on the same box (but on different ports) - not a bad idea if you're sharing load between multiple processors. You can front them with httpd using mod-proxy-balance or mod-jk to distribute the requests, but at the same time to provide "sticky sessions" so that a series of requests made by an individual user will all be handled by the same instance.

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


Useful link: Java training

July 23, 2008

Q - Should I use Perl or Python?

An interesting question posed to me today - and not for the first time. And not for the first time, my answer had to be "tell me more about your application, and about the people who will be writing and maintaining it".

A comparative diagram on the board provides some help - but of course what's important to one organisation isn't important to another, so conclusions will differ. What did we come up with?

Perl is the ultimate "glueware" with the ability to link to virtually anything - it's been hevily used for a long time and is designed to be able to talk to technologies old and new. Python connectivity's pretty good too but it's not got quite the same wide range as Perl.

Perl has been provides with many ways of doing the same thing. Now while that's great in theory (and it's great in an environment where there are people spending most of their time writing and maintaining Perl, and they know the subtle differenceces), it's something of a nightmare in a scenario where code has been written by someone who's perhaps on holiday or has moved on, and/or where a particular way of doing something has been chosen because it's what the particulare code happened to know. Python, on the other had, has intentionally got a very limited number of ways of doing things - "that's a good alternative" was NOT used as an excuse to add something to the language.

Perl assumes you know what you are doing. Which if you do is fantastic - code can be written very fast indeed and got working very quickly - "far faster than in any other languagei" I could say ... but then if you're not entirely sure what you're doing Perl has some lovely traps that can extend you debugging cycle if you don't know the language very well, to the extent that development ends up being slower than Python.

Both languages include documentation systems - there's Perl's POD and Python's docstrings - and I'm delighted that both languages have something like this available, for it's important that your programs contain the executable code and programmer's comments anduser instructions.

Both languages originated in 1988. To remind you how long ago that is, it's the year of Perestroika (economic restructuring) in the USSR, and that same nation started their withdrawl from Afghanistan that year. Wimbledon won the FA Cup, and Stefan Edberg (now aged 42) and Steffi Graf (now aged 39) won the singles in the tennis at Wimbledon. It was 3 years before the announcement of Linux (25th August 1991) and 6 years before the very first website was created (7th October 1994). So both languages have a long pedigree.

For compatability reasons, programming languages cannot change much over the years - you have to maintain the ability to run older programs - which is why so many languages have come along, become popular, and then faded away. In Perl's case, it's eclectic "many ways of doing anything" approach has lead to the addition of lots of other facilities along the way - most recently things like the say function in Perl 5.10 and even more ways of doing the same thing - something to be sorted out by the new Perl 6 grammar which will allow Larry Wall and his team to clear out a lot of dead wood from the syntax used by new programmers, but at the same time will allow the ongoing support of the Perl 5 grammar for established code. Python grew in use much more slowly - see the graph - because it was in many ways hugely ahead of its time. I'll say why in the next paragraph. That meant that there weren't a huge number of features added 10 and more years ago which are now an embarrassment, and that's doubly true because of Python's "let's not provide too many ways" philosophy. Python IS headed for "Python 3000" but do not expect it to be the huge change that Perl 6 is - it simply doesn't need that sort of overhaul! And you'll see on my graph I have given two ways forward for Perl depending largely on how well Perl 6 does and how soon it comes along - but I've only given one way for Python and that's up.

Why, then, did Python take of slowly? In part because it's an "Object Oriented" scripting language [Today's article is not the place to sidetrack onto OO!] that burst (or perhaps just bubbled) into a world where scripting was structured coding if you were lucky. People weren't ready for it! In the case of Perl, it didn't start of as being an OO language - the OO features and capability were added in 1992 and to some extent had to be fashioned around the language as it then existed. But having said that, the OO model is very flexible. Result of all of this? You can write good code for medium sized to large projects in Perl, but you will - almost automatically - be pushed towards good coding if you use Python.

What conclusions can we draw?

1. It is far easier to maintain programming standards into the future in Python than it is in Perl - Perl provides lots of ways of doing things which means that you need a very strong and technical managegial setup to provide a framework in which to work if you're doing a lot of long term coding.

2. Thoroughly experienced programmers can develop and maintain quicker in Perl than in Python but the learning curve is a much longer one, and for most people the pendulum will swing towards Python (it certainly does for the customer who gave me the inspiration to write this article today).

Here's a view of a customer of ours, a great fan of the Python language who works for a company that's a "Perl shop". See how he confirms my statements ;-)
"Secretly, I do like Perl but I 'think' in Python, and hate the non-maintainability that I see in Perl programs of just a few hundred lines of code. I think Perl users have a style for one-liners that doesn't scale to larger Perl programs. People need to write larger Perl programs with maintenance in mind." - Donald McCarthy

Oh - I will ONLY run training courses in languages that I like, and for customers who I feel that the language they're learning is an excellent solution. And we provide both Perl Courses and Python Courses. My recommendation today was towards Python - "even though" that will cost me £500.00 per delegate in lower fees as the Python course is shorter [not so many alternatives and complexities to learn!] - but I would rather earn less or even loose a prospective customer completely than I would lead someone up a garden path!

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


Useful links: Python training, Perl training

July 22, 2008

Larger applications in PHP

I've just finished a two day PHP techniques course - a subject that's tremendous fun to present, and a huge benefit to the delegates, as PHP programs can be written with great beauty, maintainability and expandability (like a Picasso) or they can be an unmaintainable mess (making the dog's dinner look neat!) and this course takes people who already have some PHP experience and helps them learn how to produce Picassos and not dog's dinners!

When you first write a larger application in PHP, it's tempting to provide a separate URL and file for each stage of the application ... but you quickly learn that's NOT the way to go when you discover that program section "x" has to be able to produce form "y" "z" and "a" depending on what the user entered ... and that users will insist on bookmarking intermediate URLs and will appear, Hogwarts wizard like, in mid application if you give them half a chance. Separate files for each stage of the main application is NOT the way to go - you want the whole under a single umbrella!

Our classic "4 layer model" example - (source code, run it) provides a series of stages to an application all under a single parasol - with each step of the process being controlled by a switch statement - the first finishing up from data entered on the previous page, and the second preparing for the next page, whichever one that might be as it depends on what the user had entered.

The four layer model is neat - very neat (and I don't claim to have originated - I give full credit to Rasmus Lerdorf who wrote PHP, and from whom I learned of the technique. But it has always worried me slightly that - as I implement it - ALL of the business logic has been loaded for every page, and that can get a little inefficient as the application moves up the scale to massive.

A chance comment today from a delegate - and I have developed the application forward one more stage. By replacing each switch statement with an include to bring in only the correct finishing code then only the correct preparation code, the technique becomes massively extensible without the need for the main code section to grow either. One of those "bolt of lightening moments" if you like.

Here's the heart of the code ...

// Deal with initialisation
if (! $_SESSION[stage] ) $_SESSION[stage] = 0;
$stage = $_SESSION[stage];
// Finish from the previous stage and prepare for next
// These files would usually be in another directory!
// and one that did NOT have its own URL!
// It would also be a good idea to docement each stage here!
include ("stages.finish$stage.inc");
include ("stages.prepare$stage.inc");

http://www.wellho.net/demo/stages.php

You can try it our here. The sample has got sticky fields, data validation, error messages and all the rest in it - and it uses a separate template to keep the look and feel apart from the business logic. The web specific helper routines are also kept in a separate file so they can be shared by other applications. (Am I starting to sound like an advert?)

Source code:
Top level
Web Helpers
Look and feel template
Finish code -from initialise, from user entering his name and department and from each main data entry.
Preparing for next page - for reading name and department, for reading main data entries and for confirming logout.

If you're looking to learn PHP and you feel this is the sort of thing for you, we're running our PHP techniques course every 2 months. If you feel it's likely to be too advanced for you at first, why not come on our PHP Programming course which runs every other month - next start date, 11th August!

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


Useful link: PHP training

July 21, 2008

Pictures from South Hampshire

This weekend - a 'mad' last minute decision to get away overnight within a hectic schedule, and we just got in the car with no particular destination - and I ended up taking a lot of pictures with no particular purpose; back in the middle of yesterday afternoon, I've catalogued a few that looked rather good or may be of some interest.

Gosport is a town that I've driven through before on my way to work at Haslar, but I've never stopped; although very militant in nature and dwarfed by Portsmouth, there are some interesting things to see. More pictures of Gosport

The Gosport to Portsmouth ferry runs frequently through the day and right up until midnight; just a five minute crossing with efficient green and white boats carrying for passengers and cycles. More pictures of the Portsmouth to Gosport Ferry

Across the ferry, we ate at the rebuilt and rejuvenated Gun Wharf More pictures of Gun Wharf, Portsmouth

Lee-on-the-Solent is a windswept beach and frontage, with many retirement homes these days, that looks out onto the straight separating the mainland from the Isle of Wight More pictures of Lee-on-the-Solent

Although Gosport Railway station hasn't seen a scheduled passenger train in more than 50 years, and a freight train for at least 40, the grand colonnade still partly stands. Marked as a dangerous building, and security fenced, we were limited to taking pictures through the wire - but of great interest never the less More pictures of Gosport Station

Stokes Bay is just around the point from Gosport and another great place to watch the shipping.More pictures of Stokes Bay

The inlet of the river Hamble is stuffed with yachts these days - it must have been a very different scene during the second world war when all manner of boat yards and military activity took place there! More pictures of Hamble-le-Rice

Portsmouth is a great natural harbour and standing at the entrance you'll see everything from yachts, via ferries, to military shipping passing by. More pictures of ships and boats at Portsmouth Harbour

Hillier Gardens were a real "gem" of a find - what we though might just be a small garden centre turned out to be many acres of enjoymentMore pictures of Hillier Gardens and even more

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

July 20, 2008

Hillier Gardens, Hampshire

I don't have the patience for wildlife photography - which is why I'm very grateful to the Hillier Gardens, between Romsey and Winchester, for having an "Art in the Garden" exhibition on at the moment. Lisa and I visited on Saturday - a pure co-incidence, as we set out for an impulsive day-and-a-bit away after some fairly intensive work schedules, and with the knowledge that - contrary to the rest of the world which seems to be slowing down - we're speeding up!

Some 130 works of art are spread around the arboretum, and I find myself spoilt for choice in which to show you. Both the samples I've chosen today are clearly representational of nature and wildlife - but there are plenty of geometric shapes and other more abstract clevernesses too. Whether these are art or whimsy, I question ...

There's a great temptation to explain comedy, but I think many of the people who see this picture will "get it" straight away, and most of the rest will enjoy thinking about it.

This one struck me as a tautology (I hope I have that word right!) with the same point being made twice.

Lisa surprised me with this one - apparently the term it represents isn't in common use in the USA; ah - but we're less than a month from the "Glorious 12th"

And the last two are nothing at all to do with the animal in who's outline the second shape is cut, but I still enjoyed the wordplay.

Very much '60s. Will the younger generation get this one?


And just in case you need to know ...

Pointer, Rocking Horse, Gun Dog, Catfish and Lava Lamp

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

July 19, 2008

Ways to accept credit cards - or not!

Here are four statements I've come across in the last 24 hours

"We accept credit and debit cards"

"We don't take credit or detit cards for payments of under 10 pounds" (which struck me as very negative with words like "don't" and "under".

"We only accept credit cards for payments of five pounds and more" (which had me worried because I was about to pay in cash - but fortunately my bill was under the five pound limit above which the rule, if literally taken would have to be paid on a card!

"We don't accept credit or debit cards"

One of our best decisions - made before our training industry generally accepted credit cards - was to accept Visa and Mastercard, and our recent decision to accept American Express too has been rapidly vindicated. And because of the nature of our business, we don't have to apply any limit - we can proudly say "We're happy to accept payment my Visa, Mastercard or American Express for your hotel stay in Melksham, for you event at Well House Manor, or for your Open Source Training Course

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

July 18, 2008

As different as night and tyres

I was going to say "as different as night and day" - but they're really too similar! You'll be reading this forum post on our new server, and I'm already seeing a dramatic improvement in performance - partly related to the heavy load on the previous server, partly because the previous server wasn't specifically tuned to our specific requirements, and partly because it was physically located half a world away from us, which added in a lag time on each access no matter how fast and under loaded the network connection was. Map out the IP address that we're now using for www.wellho.net, and you'll be pointed to London, England!

Of course, we have grown to make extensive use of some very specific facilities over the years the site has been hosted in California - some of which were rushed in to short demonstrations which were intended to show a feature or facility rather to to be flexibly hosted, so a number of issued remain to be fixed over coming days, or finally transferred over the coming fortnight.

All sorts of issues with the upgrade (but no major software version issues - after all we do train people to be forward looking!) but I thought you might "enjoy" what is perhaps the most dramatic error message I can ever recall getting out of a Linux system:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: POSSIBLE DNS SPOOFING DETECTED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for www.wellho.net has changed,
and the key for the according IP address 83.170.95.163
is unchanged. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /Users/grahamellis/.ssh/known_hosts:29
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
9d:8b:2d:0f:b8:17:fd:b3:24:ce:34:ef:de:cb:77:37.
Please contact your system administrator.
Add correct host key in /Users/grahamellis/.ssh/known_hosts to get rid of this message.
Offending key in /Users/grahamellis/.ssh/known_hosts:1
RSA host key for www.wellho.net has changed and you have requested strict checking.
Host key verification failed.
earth-wind-and-fire:~

And what caused that? Well - it could have been paraphrased into:

You're in touch with a different machine to the last time you contacted www.wellho.net. Are you sure this is right? and of course, in the circumstances, I am sure ;-)

The solution? Either delete the offending line from the known_hosts file (that :1 in the message means that it's line number 1) or - as I did (but should not admit) just clear down the .ssh directory and reauthenticate all hosts next time you connect to them!

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

July 17, 2008

Rapid growth leads to server move

Here are some web site statistics for you ...

Over fifty thousand different visitors in the last seven days. Those visitors have called up over a quarter of a million pages (that's about five pages each), and each of those pages has called up one or two extra file such as images and style sheets - making a total of nearly three quarters of a million requests to the server. Total traffic transferred - some 24 Gbytes. Even the log files total some 175 Mbytes of data!

Can you believe those are our "stats" for the www.wellho.net site - our main web site that covers our Open Source training?

In the last 24 hours, 900 people have read our page that explains joins and left joins, 220 have read about using PHP and MySQL to store an image database, 240 have visited us to find out about Python threads, and over 6000 (yes, that's six thousand) accessed have been made to our source code resources which are listed subject by subject.

The growth has been dramatic over the last couple of years, and the shared server that we've been using is starting to creak a little - partly due to volume, and partly due to some clever background code that we're running - and which we want to develop further. So we're in the process of moving to a dedicated server which is being tested at present and should go live in the next week or so.

What difference will you see? Very little indeed at first - although you might notice a speed improvement if you're in the UK - the server being hosted in this country now. But the move will give us the chance to put in seriously recent software versions (Apache httpd up to 2.2, PHP up to 5.2, MySQL 5, for example) all of which are way ahead of the WSP's machine that we have been using. And then we'll be able to run other servers and you'll see Tomcat, Django, Ruby on Rails, Mason and more (Or perhaps you won't spot them if they're hidden behind regular URLs!)

Both PHP 5 and MySQL 5 are not quite as compatible as we might wish with the older versions (I should know - I teach the subjects!) but we don't expect any problems. And we will be doing a lot of testing too. However, with thousands of different URLs on our site we may overlook something and if we do can I ask you - friends reading this - to drop us a note if you spot something odd - graham@wellho.net. Thanks!

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

July 15, 2008

At the Westbury Bypass Enquiry

Last night was the evening session of the Westbury Bypass enquiry that's presently running in that town, and Lisa and I attended and listened with interest.

A bit of history.

The town of Westbury is the largest town on the A350 that remains unbypassed and although the traffic delays through there are not as severe as some would wish us to believe, the town does slow down traffic from Warminster and the south headed up to the M4 motorway, and there are some narrow twists and turns on a road that wasn't intended for the traffic it now carries, leading to air pollution, noise, vibration, unsuitability of footways due to HGVs close by and much more - it can't be pleasant living on the road these days.

Various routes to the North and West of the town have been proposed in the past, serving the West Wilts Trading Estate - a growing industrial area - on their way around the town, but these are no longer under consideration and the route being proposed by Wiltshire County Council is to the South and East, with an additional link road in to the Trading Estate. Rather late in the day, a weight limit has been proposed on a critical bridge over the railway within the town of Westbury, in order to prevent HGV traffic from the West Wilts trading estate that's headed south from continuing to go through the town even if the bypass is built (but the weight limit won't, of course, stop cars using the old route rather than the new long way round)

The "West" route runs through six parishes, and there are many people there who have put up a spirited campaign to keep it away, although if the new road ran close to the railway line its disruption wouldn't be all that much, and it would give direct access to Westbury Station, and to the Trading Estate, without the need for artificial restrictions as I described above.

The "East" route runs through two parishes, through high quality agricultural land which is also beautiful countryside, with antiquities and more along the line. There's lots of wildlife around (some rare, I understand) and there's very serious concern that it's as close as it is to the Westbury White Horse.

The inspector's task is to recommend to the Minister for local government (I think) and the Minister for Transport, Ruth Kelly, whether or not to approve the Eastern route, for which a great deal of research has been done. The inspectors pointed out some 20 feet of paperwork on a shelf behind them that they have to consider, much of which has been prepared at my (taxpayer's) expense. The outcome of the enquiry cannot be a recommendation of approval for an alternative route; it has to be a "yes / no" but can be subject, as I understand it, to extra conditions being applied.

The evening

There were 7 speakers in favour of approval, followed by 14 speakers listed as objectors.

The speakers in favour of approval (with two exceptions) spoke of how they lived close by the current A350, and what a nightmare that made life there. And I really felt for them; I can understand their anguish even if it was laid on a bit heavy for the enquiry. But they weren't speaking to the support of the Eastern Route - rather they were supporting any route, and they are behind this scheme simply because it's the only one on offer - "that or nothing".

The speakers listed as objectors, on the other hand, weren't saying "no, there shouldn't be a bypass", nor were they didn't encourage a solution being found for the first group of speakers - what they were saying was "this proposal doesn't make sense". Although the bypass to the east will relieve Westbury's town centre for its residents, the scheme as proposed does nothing for the Yarnbrook just to the north, already more of a hotspot than Westbury itself on the DfT's congestion delay map, already an accident blackspot, and destined to receive the traffic off a fast bypass funnelled back into 19th Century roads if the bypass goes ahead on current plans.

Other speakers talked of the loss of habitat, tranquillity, antiquities, and of the lassoing of a section of beautiful countryside between the town and the new bypass which would inevitably end up being in filled. They talked of the cutting off of Westbury from its major asset - the scarp face of Salisbury Plain with only limited crossings, and of a mitigating bridleway that will be too steep for horses to use in safety.

And they talked of scandals and the massaging of public opinion and statistics. Of councillors banned from talking at meeting, and banned from voting, because they lived close to the proposed road; as I understood it, Wiltshire County Council has described the scheme as having "the [full/overwhelming] support" of Westbury Town Council, when in fact only 5 out of 15 members voted in favour, with 4 voting against and 6 being either excluded of advised on legal grounds that they must abstain. Some of these spoke yesterday - all against the plans - and it sounded like some very serious flaws in the local democracy were being revealed to put it mildly.

Some thoughts

Both Lisa and I were very struck by how the supporters weren't actually supporting the specific route proposed (just one exception) - they would / were supporting any route - the principle of a bypass. They would have been - again with that one exception - equally happy (and perhaps more happy) with a Western route which would take even more traffic away from their doors. And the objectors weren't actually objecting to measures to divert traffic away from Westbury town centre - but rather to a scheme which has serious flaws and has been pushed through as the only alternative in ways that may be legal, but don't seem to conform to the best of democratic standards.

We were very impressed by a well run evening that stuck to schedule, was very polite in spite of the differing views being strongly expressed, and by the inspectors who gave an impressive demonstration of being well organised and impartial.

My interests in this? Firstly, an over engineered (an so expensive) bypass will act like a sponge and suck traffic into the area from far and wide - leading to a dramatic increase in traffic elsewhere on the A350 - Yarnbrook, Beanacre, North Melksham, and around Chippenham - all of which are either congested already or serious accident blackspots. Better a solution to deal with Westbury's issues; there seem to be a number of credible alternatives.

Secondly, there's a perfectly good railway line - linking Southampton with the Midlands and North that runs through Westbury and has capacity, and a trackbed that would allow it to be doubled without demolishing anyone's house or shoving more traffic past their front door. That's a lot of your freight dealt with. Then you should also run a decent passenger service - and you'll cut the car traffic too. I've made this point lots of times here already, so I won't go on further about it again. Just to say that ... if you MUST build the eastern bypass, please Mr WCC, cut back a little on the heavy engineering (I have some suggestions!) so that you don't sponge traffic in the area, and put a half of the money you save into a decent alternative rail service.

As fuel prices rise, metal on metal or rail rather then rubber on tarmac of road will make the heavy rail freight ever more environmental and economic. And as fuel prices rise, multi passenger fast public transport will be an ever more attractive way for people to get around - in the longer term, cheaper than individual road vehicles, and certainly far more environmentally friendly.

Illustrations - The A350 in Westbury, photographs taken after the session concluded between half past nine and a quarter to ten. And a picture that's about 2 years old (from my library) taken on top of the White Horse, looking across the the area where an Eastern bypass would run.

Update See also an earlier view of how Wiltshire might develop

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

July 14, 2008

There is more that one way - Perl

"There are six ways of doing anything in Perl." So say I on Perl courses and just occasionally I come up with an example that proves it. This one doesn't quite - I show you just five ways of finding the names of all the files in the current directory:

$stuff = `ls`;
 
@fings = glob("*");
 
opendir(DH,".");
@allfings = readdir(DH);
 
@another = <*>;
 
open (FH,"ls|");
@yetmore = <FH>;

Why so many different options? A good question, partly answered by the fact that they're all slightly different in what they do, so each has its ideal use. But I'll admit that the language probably didn't need THAT many ways all in quite common use. It does keep me on my toes on Perl Programming Courses such as the one I ran last week.

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


Useful link: Perl training

July 13, 2008

A Train Service Update for Melksham Party in the Park

Yesterday was Melksham's "Party in the Park" and carnival, where it seems the whole town turns out to see the stalls in the afternoon, the parade in the early evening, and the concert and fireworks after that - or at least to attend some of the events.

Last year, the Melksham Railway Development Group and the Save the Train campaign took a stall to inform a new audience who are perhaps not on line and don't keep up with local news about the service and campaign we're running - and we we delightfully amaze to find just how very supportive everyone was. And indeed the campaign progressed well over the year ... until just a few days ago, when First Great Western emailed to let us know - that after all the hard work - that they hadn't been able to sort out a financial package (yet?) and so there will be no improvement to train services calling at Melksham until December 2009 at the earliest.

I'm disappointed at the news, but not entirely surprised. The Department for Transport point at First Great Western, who point at Wiltshire County Council, who point at the Department for Transport. The DfT say they've no money, but finance load of other schemes (mostly in marginal constituencies). FGW say they're a commercial organisation as indeed they are, and yet they've found some 200k to hire an extra train for a few extra summer Saturdays for a Weymouth service which would make the difference for the "TransWilts" for a whole year. Wiltshire County Council plead poverty, then spend 2 million (that's enough for 10 years) in a fruitless search for a new water source on the slopes above Westbury, and continue to pour money into buses that are demonstrably carrying few passengers. Curious thing is ... everyone agrees that the case is a sound one and would be of huge benefit not only to Melksham but to the area as a whole, but no-one of the three takes a bold steps and puts the passenger (and wannabe passenger) first. The DfT's steer is marginal constituencies, FGW's steer is shareholder return, and WCC's steer is the a principled stand and the voters of one particular Westbury ward.

What case, then, to present at "Party in the Park" - to say "Lost again - end of campaign", to say "Whatever they say - NOT yet lost for December", to say "let's start pushing the harder for next year", or to say "let's regroup". What we presented, though, was the current situation. We filled in friends and contacts, and we listened. We listened to Joe Public's thoughts on rail services - not only on what they would like to see, but what they would use, and where we should go. Not so formally as last year, where we ran a survey - but listening still to what people want. Conclusion? People want a decent train service!

My "Party in the Park" handouts are on the Web site - here (current timetable) and here (a brief status report).

As an important footnote to the reader of this article - The TransWilts train service links (twice a day - 06:15 and 18:45 from Swindon) the five largest population centres of Wiltshire, of which Melksham is just one. There are no through trains at all in the reverse direction. An appropriate train service is (according to the county council) hourly ...

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

July 12, 2008

Configuring Apache httpd

There are two approaches to bundling software for user installation.

"The MicroSoft way" is to use an install wizard that drops each of the elements of the software into the best operational place on the user's system, and configures it there for running straight away.

"The OpenSource way" is to install software into a specific area of the disc so that it can easily be adjusted, configured and experimented with ... without effecting other software on the computer, and giving the installer an "easy out" if he / she wants to try out an alternative.

But neither approach is ideal - I have painted a positive picture above, but I could equally have been negative and pointed out that Microsoft-style software is hard to fully remove later, and that Opensource-style software needs extra work to place certain elements of the software into the best operational areas. There is no ideal.

Yesterday, I was installing Apache httpd (and PHP, and MySQL too!) as part of some LAMP deployment training, and I made a few notes of some of the "gotcha"s / changes from the default install.

1. The server was built with --enable-so as that's a necessary option for the installation of PHP, something that you only discover later on in the process if you don't read right through at the start. (The full line we used was ./configure --enable-so --enable-rewrite --enable-proxy --enable-proxy-http --enable-proxy-balancer with the extra options preinstalled for other topics also to be covered)

2. The User and Group were changed from "daemon" to "apache" which is a daemon account that already exists on Red Hat / Fedora. (This is Apache httpd 2.2.x; under 2.0.x, the defaults of nobody / -1 are much more dangerous that daemon, and the change is all the more critical!) User accounts set up to be in group apache, which is used to set the permissions that the web server has over resources placed on the web site.

3. The Web site itself was moved from the default location in /usr/local/apache2 to /home/websites/default (that latter choice because we we going on to add virtual hosting and have just a tiny default site)

4. Log files moved to /var/log/httpd, and regular timed jobs under crontab set up for log file rotation.

5. apachectl copied to /etc/init.d and symbolic links set up to that file from /etc/rc3.d and /etc/rc5.d (to make the web server start automatically on reboot)

Some other things to note ...

a) You need to install MySQL before you install PHP on your LAMP setup - so that PHP can make use of the MySQL libraries as you load it. And being an Apache module, the PHP install must be after the httpd install.

b) Make sure that you make references to executable files you have just installed with a "dot-slash" in front of their names to run them in the current directory - otherwise you can end up running a version that was provided with the Linux distribution which probably won't be configured / tuned in exactly the way you want. Here's an example showing how forgetting the ./ can lead to the wrong server starting ...

[root@easterton bin]# ./apachectl start
[root@easterton bin]# ps aux | grep httpd
root 4144 0.0 0.1 4236 1944 ? Ss 10:04 0:00 /usr/local/apache2/bin/httpd -k start
apache 4145 0.0 0.1 4236 1408 ? S 10:04 0:00 /usr/local/apache2/bin/httpd -k start
apache 4146 0.0 0.1 4236 1408 ? S 10:04 0:00 /usr/local/apache2/bin/httpd -k start
apache 4147 0.0 0.1 4236 1408 ? S 10:04 0:00 /usr/local/apache2/bin/httpd -k start
apache 4148 0.0 0.1 4236 1408 ? S 10:04 0:00 /usr/local/apache2/bin/httpd -k start
apache 4149 0.0 0.1 4236 1408 ? S 10:04 0:00 /usr/local/apache2/bin/httpd -k start
root 4151 0.0 0.0 3916 688 pts/1 S+ 10:04 0:00 grep httpd
[root@easterton bin]# ./apachectl stop
[root@easterton bin]# apachectl start
[root@easterton bin]# ps aux | grep httpd
root 4160 9.6 0.9 24588 9820 ? Ss 10:04 0:00 /usr/sbin/httpd -k start
apache 4161 0.0 0.4 24720 4716 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4162 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4163 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4164 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4165 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4166 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4167 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
apache 4168 0.0 0.4 24720 4712 ? S 10:04 0:00 /usr/sbin/httpd -k start
root 4170 0.0 0.0 3920 688 pts/1 S+ 10:04 0:00 grep httpd
[root@easterton bin]# which apachectl
/usr/sbin/apachectl
aroot@easterton bin]#

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

The Story of Well House Manor

"What's the story of this place?" ... a question that I'm often asked at Well House Manor as I check out hotel guests.

Well House Consultants has been running specialised computer training courses in Melksham since 2000 - so specialised that the majority of our customers travel a long way to attend, and need to stay locally during their course, which typically lasts from 2 to 5 days.

At first, our delegates stayed at the wide range of Bed and Breakfasts that was available, and some of the small local hotels, but gradually the B&Bs decreased in numbers, one of the hotels closed, as our delegates required en-suite facilities, they required internet access, and they needed to pay by credit card which limited the choice further.

As a company that brought visitors into Melksham, looked after them at our training centre during the day, provided their internet access, charged them (by credit card or on account if they wished) for our services, advised them on what there was to do around, fed and watered them, we were already - in essence - a "daytime hotel". When "The Old Manor" came up for sale, we purchased it and after major refurbishment re-opened it as Well House Manor, offering accommodation to our delegates which allows them to be trained, and have the facilities they were looking for, all under one roof.

What are our delegates looking for? For accommodation with en-suite facilities. For a desk / space to work and good internet access. For easy parking and places to eat nearby. For somewhere they can arrive late at night and get an early breakfast if they need to. For somewhere they can book online, and where they can copy vital papers and meet up with friends in the area. For somewhere that they're welcomed - even if just looking for a single room, or staying for just one night. For somewhere they can get a cup of tea or fresh coffee, or a can of soda, at any time, day or night.

It turns out (we expected that it would!) that other businesses in Melksham have visitors who are looking for a similar mix of facilities, in the area and at a sensible price. And so we're also offering our accommodation - and conference facilities - to other local businesses.

At weekends and holidays, there are some visitors to Melksham who are looking for a quiet, slightly luxurious base ... and we offer that too. We're big enough to have a range of public areas that our guests feel they can use freely without invading our home, yet small enough to retain the personal touch. And so, there's a further market. We're getting known by word of mouth, and so we're getting quite busy at weekends too, with guests we love to have - people who appreciate the particular set-up and mixture of facilities we have.

Here are the most recent comments in our vistor book ...

"Delightful place. 1st Class Service. Wouldn't hesitate to recommend"

"Outstanding Service - Great Accommodaton"

"Excellent quiet and comfortable"

"Lovely Honeymoon. Peace, Quiet, Lovely Rooms, Excellent Service. Thanks, Graham and Lisa - you made our stay extra special"


Well House Manor, 48 Spa Road, Melksham, Wiltshire, SN12 6QL.
• Quiet, friendly accommodation just five minutes from the town centre ...
• Slightly luxurious rooms - spacious, large TV's, Superking beds and more ...
• Business facilities - 24 hour access, unlimited internet, printing and copying, all major credit cards accepted ...

For full details, to check availability of make a booking see the hotel web site (www.wellhousemanor.co.uk), call us on 0800 043 8225 or 01225 709638, or drop by.

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

July 11, 2008

Environment variables in Perl / use Env

If I say use Env;, Perl loads in a module which allows me to access all my environment variables directly within my code, by name. If I add an explicit list of variable names as a list to the module, then only those variables will be imported. So in this example, $PATH prints nothing but $SHELL and $PWD tell you the shell and the present working directory. Extra environment variables can be accessed directly from the %ENV hash (and that can be done whether or not you have called the module in).

# Env brings environment into current namespace
use Env qw(SHELL PWD);
 
print "--- $PATH ---\n";
print "--- $SHELL ---\n";
print "--- $PWD ---\n";
 
print "--- $ENV{PATH} ---\n";

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


Useful link: Perl training

July 10, 2008

Finding operating system settings in Perl

In Perl, you have a variety of special variables available to you ... preloaded with information in many cases. Some of their names are "special" such as $^O, $^T, $", $/, $! or $_, and others are capitalised such as @ARGV, @ISA, %INC and %ENV.

Here's a snippet of code that checks whether you're running on a Microsoft based operating system through the $^O variable, then splits the PATH environment variable which it gets from the %ENV hash into a series of directories that the operating system searches for executable programs.

$sep = ($^O =~ /^MS/) ? ";" : ":"; # Windows uses ; separator
@pels = split(/$sep/,$ENV{PATH});


The complete code example, which lists out all executable files available to you in alphabetic order, is listed here.

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


Useful link: Perl training

July 09, 2008

Perl ... adding to a list - end, middle, start

You can add an extra element on to a Perl list with push, into the middle with splice and onto the beginning with unshift.

You can extract a single element from splitting a scalar and calling up the element you want using square brackets and the appropriate subscript.

Example:

open (fh,"../../requests.xyz") or die;
  
@x = <fh>;
  
push(@x,"aaron Perl Ruby Opal\n");
unshift(@x,"bob C Lua Matlab Perl Python\n");
splice(@x,3,0,"chris Lua PHP Perl Java\n");
  
foreach $emp (@x) {
  if ($emp =~ /Python/) {
    $name = (split(/\s+/,$emp))[0];
    push @pythoners,$name;
  }
}


Here's the result of running that:

BirthdayBoy:csr1 grahamellis$ perl skillz
Python with bob hazel leane olivia adam barry harry ken nigel rupert
bob C Lua Matlab Perl Python
antonia Perl XML PHP Tcl/Tk MySQL
barbara Tcl/Tk ASP Ruby Java
chris Lua PHP Perl Java
cherry Perl Java Ruby MySQL
delia XML PHP Java ASP
ethel MySQL Perl Tcl/Tk ASP
florence Ruby PHP Java ASP
BirthdayBoy:csr1 grahamellis$

If you want to take something off a list ... pop off the end, shift off the beginning, and splice - again - to take items out of the middle.

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


Useful link: Perl training

July 08, 2008

Running operating system commands in Perl

Perl is excellent "glueware" - a language which can be well used to connect together a whole lot of elements. And one of those elements may be operating system commands run from within the Perl program.

Here are (three!) ways that you can do it - in each case leaving the result of running the commands in a scalar variable.

# CAUTION - OS Dependent!
 
$imc = `uname -m`;
 
$imd = qx!uname -r!;
 
$imcalled = <<`DONE`
uname -s
date
uptime
DONE
;
 
# CAUTION - OS Dependent!
 
print ("***** Here document:\n$imcalled\n");
print ("***** Backquote:\n$imc\n");
print ("***** qx:\n$imd");

So that's
* A text string of commands in backquotes
* A text string of commands in a 'qx' string
* A text block (here document)

And here's how it runs:

BirthdayBoy:csr1 grahamellis$ perl bq
***** Here document:
Darwin
Tue 8 Jul 2008 18:41:38 BST
18:41 up 31 mins, 2 users, load averages: 0.01 0.05 0.06
 
***** Backquote:
Power Macintosh
 
***** qx:
9.0.0
BirthdayBoy:csr1 grahamellis$

You can also run operating system commands via a piped file handle, where you'll read back the response line by line:

open (FH,"ls -l *.*|");
while ($line = <FH>) {
  print ++$n," ",$line;
  }

Which gives us ...

BirthdayBoy:csr1 grahamellis$ perl lbl
1 -rw-r--r-- 1 grahamellis grahamellis 2856 7 Jul 16:35 dis.txt
2 -rw-r--r-- 1 grahamellis grahamellis 825 8 Jul 09:24 fred.txt
3 -rw-r--r-- 1 grahamellis grahamellis 3 7 Jul 10:04 pod2htmd.tmp
4 -rw-r--r-- 1 grahamellis grahamellis 3 7 Jul 10:04 pod2htmi.tmp
5 -rw-r--r-- 1 grahamellis grahamellis 502 8 Jul 14:28 tick.pm
BirthdayBoy:csr1 grahamellis$


(By the way - the name of my computer today - "BirthdayBoy" - has been allocated to me by the router at the hotel and does not imply anything about the day I was born!)

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


Useful link: Perl training

July 07, 2008

Training Course and Business Conference Technology

When a new technology comes out, it's described as "leading edge" - it tends to be very expensive, and whilst it functions it does so with limitations that make its adoption limited - by only those people who really need the technology and / or are prepared to put up with its restrictions. When I was first on line in 1994, that was very much the case - dialling in to a bank of modems on a long distance phone call, waiting for the evening to do so, and running email exchange programs to keep my connect time down. There were periods, as the uptake got bigger and the modem banks failed to keep pace, that I could be redialling for half an hour to get online ... and then as just 9.6k.

Moving on beyond leading edge, we got to general adoption, and we're now in a state of general adoption - at the Salisbury RailFuture conference on Saturday, there's just a small proportion of member who are not online and they are being gently chided for not being there!

The same thing has happened with computer screen projectors. Our first, two thousand pound model, had a light level of 700 lumens and needed a carefully lit room for its use. Termed portable, it was more "luggable" than portable. But each generation has become lower cost and higher powered - both in terms of lumen, and in terms of resolution.

Here's our new projector in use - I wook it to the Salisbury event to project my talk, and it was used by others too through the day. Some 100 people attended and the unit gave crisp, bright pictures that they all could see. One or two speakers of "the old guard" didn't use slides, but for everyone else their powerpoint slides were clearly visible to the whole audience. Truely, general adoption has now come to this technology too.

For smaller courses, this new projector is almost TOO bright, and we'll continue to use the 2500 lumen unit in "The Berks" at Well House Manor. For larger course in "The Wilts", which can seat up to 50 theatre style (but we limit courses to 8!), we'll use the new 3500 lumen unit. Both rooms also have wired and wireless internet access.

If you're looking to book a training event, business meeting or presentation room in Melksham, please consider Well House Manor. A projector and the internet connection will be available for you to use - together with one of our laptops (or indeed several laptops if you're doing a course). "The Berks" has a complete white wall which you can use as both a projector screen and a whiteboard, and no less than half of the walls in "The Wilts" are so treated.

We have all the usual facilities you would look for at a business conference too - a variety of catering options, plenty of parking, copying and printing facilities - and we also have "the best bedrooms in Melksham" according to some or our reviewers - and who are we to disagree?

Your Contact for events - Christine Sivier. If you email our general enquiry address - info@wellho.net Christine will get an automatic copy, or if she's busy running a conference our office can get straight back to you instead. Or phone Well House Manor on 01225 709638, or drop in and see us at 48, Spa Road, Melksham - that's the big building set back in 3/4 of an acrea of grounds just a couple of hundred yards from the town centre.

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

July 06, 2008

FTP server on Fedora Linux

Using vsftpd ...

Turning on manually / for current boot

1. Log is as root
2. cd /etc/init.d
3. ./vsftpd start

[trainee@melksham ~]$ su -
Password:
[root@melksham ~]# cd /etc/init.d
[root@melksham init.d]# ./vsftpd start
Starting vsftpd for vsftpd: [ OK ]
[root@melksham init.d]#

4. Test from remote machine

earth-wind-and-fire:~ grahamellis$ ftp melksham
Connected to melksham.
220 (vsFTPd 2.0.4)
Name (melksham:grahamellis): trainee
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

restarting automatically on reboot

1. Log is as root
2. chkconfig vsftpd on
(you may wish to check with chkcofing --list as in this example:

[root@melksham ~]# chkconfig --list vsftpd
vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@melksham ~]# chkconfig vsftpd on
[root@melksham ~]# chkconfig --list vsftpd
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@melksham ~]#

3. Reboot to test

If you are installing vsftpd yourself

1. Download (.tar.gz)
2. unpack
3. make
4. as root - make install

5. You will probably wish to configure vsftpd to loosen up some of the permissions; the Fedora Core version says in the config file "The default compiled in settings are fairly paranoid. This sample file loosens things up a bit, to make the ftp daemon more usable. Please see vsftpd.conf.5 for all compiled in defaults." ... and they have the following active lines in /etc/vsftpd/vsftpd.conf

anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
pam_service_name=vsftpd
userlist_enable=YES
listen=YES
tcp_wrappers=YES

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


Useful link: Linux training

If you are learning Lua, here are some more examples

During some courses, I write few (if any) new examples in front of my delegates, rather relying on the standard ones in the training notes (which I wrote anyway!) and making small changes and adjustments to illustrate how things work. On other courses, though, I write a some new examples from scratch - and such was the case during last Thurday and Friday's two day Lua training class.

Here - primarily for the delagates in that class - are links to the many of the new examples, which I have added to our on line resource. If you follow the links to any of these, you'll be offered links to other related examples too!

Lua Fundamentals

Comments in Lus
Simple sting.format example
for loop example in Lua
strip.rep to repeat a string
getting the minimum value from a table in Lua
Pattern Matching -getting names from amongst a stream of punctuation

Lua functions and modules

Variable number of arguments to a function
Lua functions to return larger of two values and largest of a table of values
How sorting works in Lua - looking under the counter
A Lua program that calls in a module and the module itself
An function which could usefully be turned into a coroutine and that example amended to run as a coroutine

Towards Object Orientation in Lua

A reminder of tables
Adding Lusa's metables to change functionallity
Creating and using a table of Lua 'objects'
Redefining operator behaviour on tables in Lua

Lua is a really excellent language with a small "footprint" - the more I use it, the more I like it (and I like it a lot!). You won't find the "bloat" of other open source languages, but you WILL find nifty and useful features which come together to make it a very valuable programming tool; it's this feature set that has led to its widespead adoption in the games industry where (for example) it's used in "The world or Warcraft" to customise the user interface.

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

Dealing with The Press

A big thanks to Bruce Williamson who held us all spellbound at yesterday's RailFuture Annual National Conference with his talk / "masterclass" on dealing with the press - something which many of "us campaigners" have learned the hard way.

Bruce has many years of experience on both sides of the microphone, having been one of the presenters on Radio Caroline a number of years ago, and now being the press officer for RailFuture (a national group campaigning for improved rail services where appropriate), he's on the other side of the fence.

Although almost everything Bruce said makes common sense - it's obvious once you've been told - it's not necessarily something you'll pick up automatically. He talked about two types of press contact - the newspaper press release, and the radio interview.

Let's see what I can remember the morning after ;-)

On Press Releases

The Story
• Look for a NEWS story / news angle
• Don't be afraid to jump on a bandwagon
• Add human interest
• Spice it up (but be truthful, of course)
• Keep it snappy

The Format
• Do the job for the journalist - write as a news item
• Snappy start - expand a bit - bulk of article with quoted
• Put words into peoples's mouths
• Write to entertain
• Write for the audience
• Provide notes for editors on background
• Provide contact information and references to stats sources, etc

And
• Split stories - don't burn all your wood at once
• Email direct to the right journalist if you can
• Put your headline in the email subject

On Radio Interviews

Initial Questions you must ask
• Where and When?
• Who is doing the interview?
• How long will it be?
• Will it be live?
• What will it be about?
• Who is the audience?

Doing Your Homework
• What is your overall message?
• Think sound bites. They may be re-used to your benefit
• What awkward questions might you be asked
• Bone up on the recent news
• Check it with policy.

During the interview
• Bridging. Use questions to link (back) to what you want to talk about
• Remember the listener - don't use jargon, and explain
• Don't lie
• There's no such thing as "off the record"
• don't go off topic
• don't get wound up.

Taking a leaf our of Bruce's book - "Keep it Snappy" - I'll leave it at that.

Thank you, Bruce - I recommend anyone who gets a chance to list to you to go out of their way to do so!

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

July 05, 2008

Sorting in lua - specifying your own sort routine

In Lua, the table.sort function allows you to sort a table and by default is sorts into the order that's given back by the < operator on each of the objects to be sorted. If you want to override this behaviour, you can pass the name of a function into Lua's sort and it will call this function each time a comparison is needed.

In order to help demonstrate this, I wrote a sample program with my own sort routine which I called "mysort" - as a direct replacement for table.sort with two parameters - table and function.

You can see the source code here.

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

July 04, 2008

Saying NOT in Perl, PHP, Python, Lua ...

"Isn't there one standard way to say NOT?" asked one of my delegates on today's course - and it's an excellent question. But the answer to a question about a negative subject is itself in the negative - no, there isn't just a single way!

In fact .. I can think of no fewer that 12 ways!

• 1. ! The ! is the unary not operator in a wide range of languages.

• 2. != Using != means "does not equal". In languages such as C and PHP, it checks the contents of the variables, and in Perl it checks whether two values are numerically the same. In many OO languages, the operator is (or can be) overridden to mean something of your own choice.

• 3. <> This operator in some languages Perl is an alternative to the the != operator.

• 4. ~= In Lua, instead of using != to mean not equals, you used ~=.

• 5. ^ The caret character is used to indicate NOT on of in a regular expression group, and it has the same meaning in Lua's pattern matching too. For example ... [^aeiou] means match any one character which is not a lower case vowel.

• 6. not The word not operates in the same way as the ! operator in many languages. However - it has a different place in the operator precedence tree which means that you'll sometimes need to use round brackets in different places with not and with !.

• 7. capitalisation In a regular expression in Perl, and in Perl-like regular expression such as PHP's preg functions and Python, you can invert a charactered group b y capitalising the letter. So \s means a space character, but \S means a none-space. Capitalisation also applies in this way in Lua's pattern matching - so for example %a matches an alphabetic character, but %A matches a none-alpha.

• 8. unless In Perl, an unless statement may be used to cause a block of code to be performed only if a condition is NOT true.

• 9. until You'll find until loops in Perl and Lua - a block of code is repeated while a condition is NOT true (i.e. until it is true).

• 10. ne Perl's ne operator checks whether strings are equal. And the -ne operator in shell programming checks whether numbers are equal, using the == operator that Perl uses for numbers for strings instead. (This sort of difference really helps to keep me on my toes when I'm training!)

• 11. !~ "Does not match ..." a regular expression. Perl.

• 12. !== "Is not identical to" in PHP. The difference between !== and != is that the latter operator will return false (indicating two values are equal) if you compare the number zero to either the string 0, or an empty string, or a variable that does not exist. The former will ONLY return false if you compare two values of the same type that have the same value.

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


Useful links: Python training, Perl training, PHP training

July 03, 2008

Lua Course - here is the index

If you want to look something up in a book, you'll probably use the index. And so it is in Lua that if you want to look something up in a table (the collection structure in Lua), you'll use an index too.

We have just announced our Public Lua Course - it's a natural for us, as we specialise in niche, open source languages that we like using ourselves - and I thought what better way to tell you about all the various things we cover on the course that an index ... so I'm reproducing (below) the index from our training manual of some 128 pages.

What else do you need to know about the course?

• It runs at our Melksham, Wiltshire, England training centre
• It's a 3 day course starting on 29th Septmeber and again on 17th December
• It costs £850.00 + VAT for the first delegate and £750.00 for the second and subsequent delegates on the same course / order.
• We limit the class size to just 8 delegates
• If you don't live nearby, we're a hotel too and we can arrange for you to be picked up from a local railway station or airport if you come in by public transport - no need for a car.
• Some prior programming experience is required, but if Lua will be your first language please ask as we can usually arrange an extra "lead in" day immediately prior to the course.
• We also run private courses - at our place or yours; such courses can be tailored to suit your exact needs and are lower cost than public course places if you have more than a handful of delegates.

And the index of content? ...

-- 16
# 27
.. 26
... 47
.lua extension 42
== 20
-- 16
__add 64
__index 64
__lt 64
_G 14, 58, 87
~= 20

A
addition 16
anchors 50
arithmetic operations 17
array 30
assert 77
associative array 34
Associative tables 31

B
blocks 45
break 23
build 90

C
C API 13
capture strings 52
CGI script 53
character groups 50
class 62
classes 8
client 104
clock 84
clone 37
cloning 36
closures 8
coercion 8
Comments 16
Common Gateway Interface 100
compile 92
Concatanate strings 26
conditional 20
constructor 11
content type header line 100
coroutine 104
CoRoutines 96
coroutines 8
counts 51
cpu seconds 84

D
date 84
debug.traceback 78
dictionary 31
directory listing 86
division 16
do 21
double quote 26
Download 90

E
else 20
elseif 20
encapsulate 65
end 20 <