Connor Cummins TT 2010

You gotta love the TT. Year after year the death toll increases, yet no-one would dream of cancelling it and wrecking the Isle of Man’s economy. And still the racers come back for more… including Conor Cummins, who is racing in this year’s TT after recovering from this accident in the 2010 TT.

It’s dangerous. I would never do it. But I love watching it…

Google Chromebook – Google launches its Chrome OS and own laptop

Is this the dawn of a new era in computing? Is Google some sort of binary messiah leading us mere users to a new land of promise?

Probably not. Read more »

PHP and MySQL Development Tools for Mac

Over the years I have used all three platforms (Mac, Winblows, Linux) to do my development work, and have used a wide range of software tools. I’ve finally found a selection of tools that work really well for me, so I thought I would share them. These are all Mac based.

Coda 1.7
www.panic.com/coda/ – $99
Coda doesn’t have all the features of some other IDEs, but it has everything I need for PHP, HTML & CSS development. Completely customisable code colouring, syntax prompting, built in file management (local and remote with FTP or S/FTP), built in SVN support, and even a built in terminal. All very useful. Version 2 is long overdue, but no doubt it will be out sometime this year, and will add even more goodies like code folding. Overall, the interface is just superb, and best of all it doesn’t have Dreamweaver’s bloated price tag.

Sequel Pro 0.9.8.1
www.sequelpro.com – donationware
Sequel Pro is a brilliant piece of software for managing MySQL databases, and is much more user friendly than MySQL’s own Mac management tool. Supports tunnelling through SSH, and like all great software, it just works.

Transmit 4.1.5
www.panic.com/transmit/ – $34
The best FTP & S/FTP client for Mac. Nothing else comes close. Being able to mount remote locations as drives on my local machine is pure genius. The sync tool is extremely useful too.

Mac Terminal
Part of OS X and absolutely essential for remote server management. One of the main reasons I use a Mac is the inherent compatibility with Linux machines thanks to the UNIX core of OS X. Somehow, using PuTTY on a Winblows machine is just not the same. I regularly transfer massive websites, and the best way to do that is gzipped tarballs transmitted via scp on the command line. Quick and easy.

Versions 1.1.5
versionsapp.com – €39
Versions is an absolutely fabulous Subversion client for Mac. If you use SVN, you’ll want to take a look at Versions.

The Problem(s) With F1 2010 – fake lap times, dodgy AI, ludicrous pit stops

Let me start this post by saying that I have invested over 100 hours playing F1 2010 on my XBox 360. I love racing games and I love F1. I could barely contain myself when F1 2010 was released, and duly got my sweaty paws on a copy as soon as I could. I think that maybe I was so seduced by the jaw-dropping graphics and realistic physics that I never really noticed the issues during my first season with Virgin Racing. By the time I started my second season I was with a better team and always out front and therefore didn’t really notice the problems either, though I started to suspect that something wasn’t right in qualifying. At the end of my 4th season, I ended up accepting a contract at Ferrari by accident, couldn’t undo it, so decided to start again with Lotus. Now the problems became very obvious indeed.

The simple rule:
If you make a game ultra-realistic, or sell it as a simulation, then you had better make damn sure you make every aspect realistic. I use video games to calm down after a stressful day of coding. I want to escape the real world, and live in a fantasy world for just a little while, where I am a world-reknowned F1 triple champion. What I don’t want, is unrealistic game elements spoiling that fantasy.

So, here are all the problems with this game.

AI times in practice and qualifying are simulated…
…meaning that the AI cars on the track are completely disconnected to the lap times they are given. Anyone who has played the game for any length of time will have spotted this. When I’m qualifying, I seem to be flying past every other car on the track like they’re barely moving, yet despite this, they get quicker lap times than I do. This is not acceptable.

Codemasters have admitted this. They say that because they allow you to jump to a sector, or fast-forward qualifying time (whilst sat in the garage), there is a problem when switching between live simulation and time simulation. Because of this, Codemasters decided to simply fake (or estimate) all the AI car times in practice and qualifying. In their official statement they make the following comment about accelerated time:

“With 30 times speedup, we cannot simulate car physics at 6000+mph without losing some fidelity.”

I’m a programmer by trade and I’m not buying this. Speeding up game time does not mean that the cars are travelling at 6000+ MPH, it simply means that the calculations have to be performed 30 times faster. Now if the CPUs in the XBox 360 or PS3 can’t handle this, don’t provide a 30x time accelerator. There’s already a 6x time accelerator, and I daresay both consoles could easily cope with that.

To me, this seems like the developers have invented a plausible-sounding excuse for the simple fact that the game is badly programmed. Codemasters certainly have access to great developers, and I really don’t believe that they couldn’t solve this problem – it’s much more likely that they simply ran out of time. In fact, most of these issues seem to smack of a developer struggling to meet a deadline.

So, the cars you see on the track are nothing more than space fillers to slow you down, and that’s not acceptable for a simulation and it’s not realistic.

Do the AI cars always pit during a dry race…?
I’m not at all convinced that they do, and I’m not the only one. In fact this is listed in Codemaster’s statement as something they are looking into. I haven’t been able to conclusively prove it due to the lack of data shown post race, but I’m fairly certain that during 2 races in my current season, Alonso has failed to pit and has therefore finished ahead of me. If this is the case, then it’s a simple bug to fix.

Rubberband AI
Arcade racing games often use “rubberband AI” for the cars you are racing, i.e. the computer controlled cars tailor their speed to your own. This works in an arcade game as it delivers a more entertaining experience, but it has no place in a simulation. I’m not sure whether this is happening during a race (although there are plenty of people who think it is), but I have noticed that during qualifying, you can blitz past another car like it’s standing still, then all of a sudden it speeds up and stays on your tail for the rest of the lap. Not realistic.

Pit Stop Fiascos
Why am I always kept waiting in the pits if there are any other cars in the pit lane at the same time?
It’s ludicrous! Yesterday, I sat waiting for 12 seconds after my tyre change whilst the team lollipop guy let every other car out before me. I went from 6th to 18th and stayed there – race ruined. It doesn’t matter if they’re half a mile down the pit lane, he won’t let me out. This is not what happens in Formula 1. Even if the lane is clear, there’s always a pause of a second or more before he lets you go. These delays cost races for human players, but never affect AI players.

Car and Team-Mate Setup
Ever had your engineer tell you during a poor qualifying spell that you should look at your team mate’s setup and copy his? Ever worked out how you can do that? No, me neither. You can’t view your team mate’s setup and you can’t copy it. In fact, the whole car setup is completely pointless. I put my car on the most extreme dry setting for every race, regardless of the weather, because it seems to have little effect other than to slightly slow you down through corners, but that’s hardly an issue when you can drive so fast everywhere else. Which leads me neatly on to:

Why are weaker teams able to compete?
In real Formula 1, you won’t see Virgin or HRT anywhere near the front of the field, yet in the game you can jump into one of these cars, change the setup to dry via the engineer menu, and then romp past the Red Bulls, Ferraris and McLarens down the straights. I won a championship in a Virgin Racing car – how likely is that? Even if you stick a great driver in a crap car, it will still be slow.

How do I change research and development focus?
The game keeps telling me that only driver 1 in a team can change R&D Focus, but I’ve never been able to do this. Another feature that got left out due to time?

Where’s the podium???
So, you’ve slogged it out and got that hard-fought podium finish… only to discover the game has no podium. You go straight to the press conference (always after the other two drivers are already in there seated) to get asked the same three questions by the same short-haired female reporter.

Sensitive Team Bosses
I lost my ride with Red Bull for criticising the car after the penultimate race of the season, despite having said nothing but positives about the team all year, and despite winning the drivers championship for them. I would have thought contract renewal would be automatic in such a situation, and not jeopardised due to one comment about the car. What’s the point in allowing you to make a negative comment if it’s just going to wreck your game? In real life, drivers highlight faults with their cars all the time, and they don’t lose their contracts over it.

Contracts, Drivers and Numbers
When you start the game you get to chose HRT, Lotus or Virgin, and you replace driver 2 at each of these teams when you join. That driver disappears for the season, fair enough. What’s odd is that he won’t appear again unless you leave, at which point he returns to his original position. OK fine, the game can function without Timo Glock, but when the same thing happens when you move to Red Bull, it’s just weird. I moved to Red Bull and Sebastian Vettel disappeared. I went to Ferrari and Massa left the game. In fact, these drivers never switch teams, and that’s just crap.

If you do manage to put up with the game’s faults long enough to win a championship, you’d be justified in expecting your car to sport the number 1 the following season, but no, that doesn’t happen either.

And why exactly did Ferrari offer me a contract as number 2 driver when I had just won 3 championships on the trot? That’s not realistic either.

Yippee! It’s raining!
I love it when race day features heavy rain. Just set the car up for very dry conditions, take care to avoid the kerbs, and you will be significantly faster than everybody else. Just like real F1… not.

Where is the data?
My engineer occasionally tells me that I just did the fastest lap. Great. I’d actually like to be able to see that data after the race, but I can’t. Where’s the full breakdown, the lap-by-lap performance data? This stuff is important to F1, yet it’s completely missing from the game – presumably because it would clearly show that all the timings are in fact fake.

Season Calendar
There is no season calendar. That’s pretty annoying. Such a simple thing to add, but no, I’m expected to remember in which order the races happen.

Stupid Penalties
Why exactly do I get given time penalites when an AI car crashes into me? The whole penalties and flags system is rubbish. There’s no safety car.

Slow Race Starts
No matter what I do, everyone else seems to be able to go around the first corner quicker than I can. Is it because my tyres are cold? It’s not like I’m given the warm-up lap to warm them up, assuming of course that the tyre simulation actually works and isn’t faked like the rest of it.

Dodgy Barriers
Particularly prevalent at the Singapore circuit (and also at Monaco), this problem completely ruins all illusion of realism. There are points on the track were the barriers don’t meet flush, so there is a very slight lip that you can crash into. Drive a bit too close to the barrier and hit this lip and you will stop dead. The car doesn’t bounce off, or spin, it just stops on the spot and you’re stuck watching all the other cars fly past you. Did no-one test the circuits before the game was released?

Give me my money back!
There are more faults, but I’m fast approaching 2,000 words on this post, and I’m getting tired. The long and short of it is this:

  • F1 2010 is an unfinished product, not ready for sale
  • Codemasters promised a patch, and despite announcing it and other online sources saying it is available for XBox 360, I can find no trace of it and have never been prompted to download an update.
  • F1 2010 is an arcade game not a simulation and should not be mis-sold.
  • I feel I deserve a refund. I have been cheated. All the time I have spent in the game has effectively been worthless.

Rant over.

Be warned: Royal Mail Special Delivery Guaranteed Next Day, is not guaranteed

In fact, your package is just as likely to not be delivered as if you send it by regular first class post. The “guaranteed” bit refers to the fact that you can get your postage refunded if the delivery deadline is not met. Sneaky. Why does the Advertising Standards Authority allow such blatant misleading advertising? Do Royal Mail get special treatment?

The money you are paying is not for any superior postage service (your Special Delivery item will go out with all the regular post), it’s for an insurance policy to cover the value of the item(s) you’re posting. And that insurance does not cover any other financial losses you or the recipient may incur if Royal Mail can’t be bothered to deliver on time. If you want this cover, you have to pay extra for “consequential losses” insurance, and it is highly unlikely your local Post Office will offer that to you – Royal Mail keep it well hidden.

So, there is nothing “special” about Royal Mail Special Delivery, and it is not guaranteed. On their own website, Royal Mail advertise the service as:

“Special Delivery Next Day – for guaranteed next day delivery”

As a consumer, I interpret “guaranteed next day delivery” to mean that I can damn well expect my item to be delivered the next day. I do not interpret that statement to mean that the postage fee I paid is guaranteed to be refunded if the item doesn’t turn up next day.

You can’t trust the tracking service on the website either. I entered my reference number and was given a message saying that my item would be delivered before the deadline on the 8th February (today). At about 1 minute past the 1pm deadline, the website message changed to a generic “your item is making its way through our network” message.

This has been a bad week of deliveries for me. First, Parcel Force took 6 days to deliver an “Express 24 hour” item, then this nonsense from Royal Mail. If I serviced my customers this way, I wouldn’t have an income.

Does the new MacBook Air have a fan?

Yes it does, but you have to be working the air pretty hard before it will spin up. How they managed to fit fans in such a small case is a mystery.

Do we need credit card companies & banks to be our moral compass?

A few days ago I felt compelled to write a little about the Wikileaks debacle (Wikileaks “cablegate” – fallout from the release of classified US Embassy cables) principally because I’m disgusted at the way various companies have suddenly decided to withdraw services from Wikileaks. This frankly smacked of coercion by the US government – something which they denied. Except of course, this it yet another lie as it has since emerged that the US government did in fact request Paypal to stop providing services, since they deemed Wikileaks’ activity to be illegal in the US. The country that prides itself on its values for individual freedoms, is in fact trying to stymie free speech.

Since my last post, a Swiss bank has frozen bank accounts belonging to Mr Assange. The Swiss? Surely they are the world leaders in confidentiality and discreet banking? Not any more it would seem. Presumably the US has been sticking its nose in there too.

Then of course Visa and Mastercard decide they can no longer process donation payments for Wikileaks – a journalistic publisher. They are still perfectly happy for you to use your credit card to buy all manner of pornography, violent movies, and even guns. You can gamble yourself into unmanageable debt with your credit card – that’s fine. Just don’t think about making a donation to Wikileaks. These companies are hardly qualified to become some sort of global moral compass, and there’s no reason why they should try to be such, unless of course the US government is once again pulling strings behind the scenes like a petulant child.

I don’t agree with what Wikileaks has done in publishing classified information without properly redacting names of people, who may now be in danger as a result. I think Julian Assange is hugely foolish if he thought there would be no backlash from all this. But… everyone has a right to speak their mind, and the Internet is the ideal place to do it. Any effort to stifle free speech on the Internet is an attack on the freedoms of every citizen in the world. It seems odd that this should come from a country that sends its armies around the world to bully other countries into adopting “democracy” and “freedom”.

I always knew the world, and especially its governments, were completely corrupt, but I didn’t expect business leaders in the online world to capitulate so completely, so quickly.

What do they all hope to achieve anyway? There are more than 500 mirrors of Wikileaks, and that number is growing daily. People will still get this information, and if someone wants to donate to Wikileaks, they will find a way. It won’t be long before groups emerge that accept donations on behalf of Wikileaks.

Yesterday, a group of activists that are pro-Wikileaks, initiated a DoS attack on Mastercard and killed SecureCode processing, causing annoyance and frustration for anyone trying to shop online with their MasterCard. I certainly don’t endorse such criminal behaviour, but if a company like MasterCard takes a ludicrous and unfair stance such as they have, they have to expect recriminations.

And every one of us should be in fear of our civil liberties. These sort of actions set dangerous precedents. If I write something on my blog that someone else takes a dislike to, do they then have the right to coerce other organisations to stop supplying me? Will my bank accounts be frozen? Probably not, because I don’t publish classified secrets on my blog, but the principle is worthy of thought all the same. Regardless of what anybody thinks about Wikileaks, the simple fact is that they did not steal this information. They have simply published information that was given them. This may be irresponsible, but the same accusation could be levelled at the vast majority of the world’s press, and I don’t see their editors being arrested on trumped up charges, or having their assets frozen.

How do you get the length of a string in jQuery?

If you’ve found this page, then chances are you are coming up against the problem where the Javascript .length method is always returning 1 for a jQuery selector. For example, if you have a variable in Javascript, you can ascertain its length as follows:


var myString = "Hello World";
alert(myString.length);

Which should give an output of 11 – i.e. there are 11 characters in the variable. This also applies for variables within jQuery functions. However if you try to apply .length to a selector – e.g.:


alert($('#mySelector').length);

You will always get a return value of 1. What you actually need to do is as follows:


HTML Code:
<div id='mySelector'>Hello World</div>

jQuery Code:
alert($('#mySelector').val().length);

Which will give the expected return value of 11.

Wikileaks “cablegate” – fallout from the release of classified US Embassy cables

I’ve been watching the Wikileaks scandal of late with some interest. For those who have had their heads in the sand, Wikileaks is a website that is in the process of publishing more than a quarter of a million classified US Embassy cables. Its founder Julian Assange, is currently in hiding (thought to be in the UK), and numerous prominent US officials are rushing to denounce the Wikileaks activity as “illegal” and insisting Mr Assange should be tried as a “traitor”.

Mr Assange is not a US citizen and Wikileaks is not a US corporation. Neither was Mr Assange or Wikileaks responsible for stealing the classified cables – they received the cables and decided to publish them, much like the press publish information from confidential sources. I don’t really see how US law applies here, though I have no doubts that the US will be pulling every string it possibly can to bring about the demise of Julian Assange and Wikileaks. Perhaps the US should instead focus its attentions on dealing with the US citizen(s) that stole the stuff in the first place, or maybe look at its security policies for sending such confidential missives.

From Mr Assange’s point of view, he may well believe he’s doing the world a great favour, but he must surely realise the foolishness of his actions. I mean really, is anyone actually surprised that the US slags off anyone and everyone behind the scenes, whilst maintaining a facade of “international friendship”? I imagine every country in the world has similar skeletons in their closet. Presumably, Mr Assange will be in fear for his life henceforth, and will have to stay in hiding.

What interests me about all this is not the political aspects – I already know that all politicians and governments are liars, and frankly any that believe otherwise are just fooling themselves – rather, what interests me is the speed with which some big gutless organisations have moved to take a stance against Wikileaks.

Firstly, Amazon decided to cancel hosting for Wikileaks, citing some feeble contravention of terms of service. (What happened to free speech?) Then Paypal followed suit, suspending the Wikileaks donation account (and no doubt pocketing any money that was sitting in it at the time). Both were perfectly happy to work with Wikileaks previously, despite the fact that Wikileaks has always been in the business of publishing information that would otherwise remain secret. Presumably, there are powers at work behind the scenes. Maybe these same powers are the ones responsible for the sustained Denial of Service attacks on the Wikileaks website – attacks which indiscriminately penalised EveryDNS, who were providing DNS services for the domain, and by extension its 500,000 other customers. Understandably, EveryDNS had to suspend service also.

Never fear, for the perpetually neutral Swiss shall come to the rescue. Wikileaks is back online at wikileaks.ch.

The information is already out there. Trying Julian Assange or Wikileaks for some perceived criminal activity will not stem the tide of information. Nor will quietly garrotting Mr Assange whilst he sleeps, or pressuring the Swedish government to pursue some trumped up sex crime charges against Mr Assange. The information is out there, and will have been copied all over the world as soon as it was published.

That’s the joy of the Internet folks. If you don’t want a secret to be found it, don’t write it down, and never put it anywhere on the Internet.

Validate numbers in PHP without using is_integer() or is_numeric()

One of the great features of PHP is its automatic typecasting of variables. You don’t need to tell PHP whether you are storing a string, a float or an integer value. This gives rise to some interesting error checking scenarios though. One of the simplest, is checking whether the value submitted from a form is numeric or not.

Annoyingly, every value submitted from a form is classed as a string in PHP. That doesn’t stop you performing calculations on the submitted value as if it were a number, but it does mean that is_integer() will always return false for that value. The PHP manual advises us to use is_numeric() instead, however is_numeric() and is_integer() are very different. For example, is_numeric() is quite happy to accept any valid number, which can include minus values, floating points and exponential numbers. For error checking this can be pretty worthless. Let’s look at a couple of different scenarios:

Scenario 1: we are passing a database ID in a hidden INPUT tag, and we want to ensure that only a valid integer ends up in the subsequent database query.

We can actually typecast the variable as follows:

$id = (int)$_POST['id'];
or
$id = intval($_POST['id']);

Nice and simple. However, minus values can also be valid integers, and sometimes we don’t want those either. We could run two tests, but that’s not particularly elegant. So…

Scenario 2: we are passing a monetary value to a payment gateway and it has to be in the lowest currency denominater (e.g. £10.53 becomes 1053). In this scenario, floating points, minus symbols and exponentials are all unacceptable.

The simple answer is regular expressions (regex) using preg_match.


if(!preg_match("/^[0-9]+$/", $_POST['amount']) {
// not valid
} else {
// valid
}