# Creating an API first

I am currently working on a project due to be released in early April. From the outset I wanted to include an API which would allow third party developers and companies create their own UX or platform independent applications, almost selling the product API as a service. When I was in the design stage of the application, I thought why not create the API first and build the Web app on top of that. This would not only show that the API was technically sufficient enough to build a full application with, but also meant I could power through iterations of the product without upsetting the base application. Adding additional features would simply be an extension of the API parameters, without having to deprecate old functions which may be still in use, therefore fully supporting v1 to v10 without extra code. I am also pushing around an idea of creating an API automatically using parameters set in the database and code, but it still needs some work.

# Lottery Predictions

On a wet Sunday afternoon thought it would be a good idea to try and become a millionaire, using the lottery. To do this I needed to find out which numbers where most likely to appear. I searched the Loto website and found the result archives, dating back to 1994.  I created a simple PHP script to analyse the previous numbers from every lottery since 1994. I then collated the results assessing which colours, numbers and bonus balls would be most likely to appear. Obviously this technique working would imply that certain numbers are more likely to be shown that others… which would indicate that each number had a different probability.

The probability of a ball from group of colours appearing were:

white = 18.338708271594%
blue = 19.471803364421%
pink = 20.32598274209%
yellow = 20.639762921642%
green = 21.223742700253%

The green group providing the strongest odds of a win.

In regards to the numbers 13 was the number with the least appearances, which is coincidentally perceived as an unlucky number. Number 38 had the most appearances.

13 = 1.656%
41 = 1.761%
20 = 1.787%
16 = 1.804%
15 = 1.883%
7 = 1.909%
14 = 1.926%
1 = 1.926%
36 = 1.926%
19 = 1.944%
21 = 1.944%
22 = 1.944%
5 = 1.952%
46 = 1.97%
37 = 1.97%
18 = 1.979%
8 = 1.996%
26 = 1.996%
10 = 1.996%
42 = 2.005%
24 = 2.013%
39 = 2.022%
2 = 2.022%
12 = 2.022%
29 = 2.04%
49 = 2.04%
48 = 2.048%
28 = 2.048%
17 = 2.057%
34 = 2.066%
3 = 2.066%
27 = 2.074%
4 = 2.074%
32 = 2.101%
40 = 2.109%
35 = 2.127%
30 = 2.127%
45 = 2.135%
47 = 2.153%
44 = 2.188%
9 = 2.196%
6 = 2.196%
11 = 2.205%
33 = 2.214%
23 = 2.223%
43 = 2.231%
25 = 2.257%
31 = 2.275%
38 = 2.397%

Which draws me to pick the numbers 11 23 25 31 33 38 43 for Wednesdays draw. Wish me luck.

# Solution “Cannot load from mysql.proc. The table is probably corrupted” Error Navicat

Just tried to do an SQL dump of a database using Navicat and got this error.

"Cannot load from mysql.proc. The table is probably corrupted"

There is a simple fix to this problem simply run the following command from your server console.

Replacing the “{USERNAME}” with a privileged MySQL account.

Problem solved.

# Javascript Accounting Library for Money and Currency Formatting

Working on a new web based application (to be released later this year) I stumbled upon a small JavaScript library which is used for formatting money and currency correctly. The library is aptly named “acounting.js” and requires no outside help from any other libraries.

The script is lightweight and localisable, perfect for an online accounting application. It is available here.

# FireFox 3.5 is released

I have been using Firefox 3.5 since its release stage (RC1). Converting from my old and frankly obsolete Firefox 3 was a breeze. All this basically entailed was to simply download and install the new version. My bookmarks, cookies, passwords and histories just simply worked. Which is what I should expect however I was very surprised, as you know this is a somewhat rare experience with computers. As it turned out the initial glory of this achievement was short lived… as computers being computers they just couldn’t resist concocting a problem.

I would advise anyone who is upgrading to FireFox 3.5 in the coming days to check the extensions which you rely on to see if the developer has updated the extension to work on 3.5.

Overall FireFox 3.5 is pretty good, seems to crash less and it looks like Mozilla have managed to patch some of the holes in the memory sieve. There are a few new features such as InPrivate which allows you to browse sites in private, I use it all the time… *cough* never *cough*. Obviously this, being basically the only real new feature added was worth breaking all the extensions created by developers over the past 18 months.

# Why are Web Analytics so stale?

If you have ever used any web analytics application you will have noticed that they all give you are the same old boring statistics which may people cant make use of. This usually consists of pageviews, bounce rates, total visitors and where the visitors have come from for example search engines, refers or directly to your site. There are many others but most arn’t relevant too the majority of people. Some of these statistics may help you with keyword targeting and campaign tracking, but in reality most of these statistics mean absolutely nothing.

Web Analytics Visitors Graph

For example, a potential visitor is searching Yahoo and is looking for “plant potting techniques” and they get directed to your site. They stay on your site for 30 seconds and then leave. Your web analytics will show you that there was a visit at say 10am which came from Yahoo with the term ”plant potting techniques” they stayed for 30 seconds and what their browser was (which is “very useful”). Now this can be perceived in two ways, one the visitor found what they were looking for and were content with your site or the visitor didn’t find the information they where seeking and left disgruntled. You need to interpret these results for yourself, which is virtually impossible even if you are a top web analyst.

It is very difficult to gain understanding of a visitors intentions simply by looking at numbers a pretty graph and sometimes shinny map. The only real way is to talk to your visitors during their visit and ask them. There is currently an analytics program on the market which can do this however it could appear very intrusive to a user who may not which to cooperate and even alienate them from your site (especially since the software I am talking about can even start up a webcam on the visitors computer to observe them).

I am sure it would be an very arduous task for someone to create an algorithm which would define what type of visitor they were calling information from other sites which they have visited, however this would be a privacy black-hole. Although this could improve understanding of visitors actions for web developers to enable them to target content more effectivly.

# All in One IDE Solution (Aptana Review)

A few days ago I was looking for a competent free Javascript Integrated Development Environment (IDE) because I wanted to experiment with some features in mootools and jquery. I came across a IDE called Aptana which is based on Eclipse. I had never seen or heard of Aptana before, so I decided to give a try.

The unique thing about Aptana is the ability to add development environments with a few clicks of the mouse. You start Aptana with the basic HTML, Javascript and CSS environments installed and then you only install the environments you want to use, therefore the IDE becomes accustom to your needs. In my case I installed the PHP, Ruby on Rails (RoR) and Python plugin environments, I also added the iPhone enviroment just to play with.

There are loads of other great features in Aptana too including:

• Create Projects on Local, Shared, FTP, SFTP, FTPS and Cloud resources
• Test your scripts quickly on a local webserver (which Aptana provides with a click of a button)
• HTML, CSS, Javascript code assist which includes your custom functions or classes
• Can be installed either standalone or as an eclipse plugin
• Good documentation, community support and video tutorials
• Wide range of Ajax libraries included
• Very competent code debugging
• Database explorer included
• and many many more!

The only problem with Aptana is the code assist doesn’t work with your own custom functions and classes in PHP and RoR which is a bit annoying having to look back at your functions.php to check the variables however Aptana is under regular development and apparently it will be included in the next update of the PHP plugin.

I would highly recommend you give a try, its free… what have you got to lose?

# GOTO function in PHP 5.3

PHP are now adding “GOTO” support in PHP 5.3 rather than waiting for PHP 6 to add the feature. GOTO has now been documented on the PHP website here. GOTO is a very nice function which allows the script to jump to any sector of the code while in execution. For example:

<?php
echo "Hello";
goto a;
echo " Coder";
a:
echo " World!";
?>

The output for this script would be:

Hello World!

Remember that most IDE’s will not recognise “goto a;” or “a:” and display an error.

# Sad Face – How to fix a broken iPod (Classic)

I had recently been given an iPod classic to fix, basically the problem was a sad face (image below) on the iPods screen whenever it loaded.

First I tried the old hold center and menu button however this didn’t remedy the problem I then proceeded to hit the iPod. Because the iPod Classic uses a disk drive to store data and not solid state drives it is vulnerable to shocks, fortunate for me. I obtained this technique from one of my old external hard drives which stopped working. After the second beating IT WORKED!

# Hadrians Cycleway (Route 72) Review

I recently completed the Hadrians Cycleway (Route 72) on my bike. I would highly recommend the route to anyone however you must have some stamina to complete the ride.It took us 3 days to complete the route however I feel that I could have done it in 2 if I pushed myself.

## Equipment Reviews

Here are a few reviews about the equipment I used on the route.

### Tires

I was using a pair of Specialized Nimbus Armadillo tires which were great. They are kevlar lined so you are very unlikely to pick up any punchers they also have very little rolling resistance which made them great for free wheeling when things got painful. These tires also handle well on the off road sections, however the off road wasn’t exactly what you would imagine (compact gravel tracks). The tires were stuffed with “Dr Sludge” inner tubes which basically are self healing inner tubes, however because my tires were kevlar lined I didn’t need to use these.

### Cylcle Shorts

I managed to get hold of some cycle shorts from the local bike shop the day before we set-off, thank god I did. Usually I do around 30 – 35 miles on an average outing and it hurts a little so I had a good idea of how much a 170 mile bike ride would hurt. The shorts were great and to be honest it doesn’t matter what brand they are they all do the same thing protect your behind. I wouldn’t advise anyone to do route 72 without a pair of cycle shorts. And don’t take any notice of the “Do not tumble dry” warning.

### Lubrication

I would recommend that you lubricate your bike after every day of cycling. To do this I purchased some “All in One Extra Dry Lubrication” and it worked great I just splashed I bit on every morning before I set off and I had no problems. I think it worked out at £4.30 for 120ml which is good value when you consider I only used about 20ml of the stuff. DO NOT use WD-40 or any other similar product. The problem is with products like WD-40 if that it not supposed to be used on heavy duty moving parts and in the long term it strips any lubrication which the manufacturer had put onto the bike in the first place.

### Lights / HV Jackets

We all wore High visibility jackets however not everyone had lights including me. I would highly recommend lights however it depends on what time of year you are going to do the route. In the middle of the summer lights are probably going to be very unnecessary because the nights are longer however in autumn or early spring lights are a must. You could be delayed for whatever reason our reason was huge amounts of flooding in Carlisle which meant that we had to navigate a 15 mile detour. This resulted in us cycling in the dark for the last hour of the day.

Overall I really enjoyed the experience and hope I have the chance to do it again next year!

Please note: I wrote this a few days after completing the coast to coast (October 08) I just found it kicking about in my posts page with the unpublished status so I stuck it up. This article has not been proof read.