Sunday, 18 March 2018

As some of you may know, some time ago I had a bit of a play with the Open Data from the Ordnance Survey. This is free data you can play with.

One of the rather fun things is the location of every postcode in the country (well the centre of it), but there is a lot of raster map data as well, and tools to convert Eastings/Northings to/from Latitude/Longitude, and quite a few other things.

Whilst we make use of various bits of this data, I put the raster map information in to a web site called

I also set up some magic DNS, e.g. you can do

dig LOC

to find the location of a postcode.

When I first made the web site, I messed about with the images, made smaller tiles, and organised them and renamed them based on E/N co-ordinates. It worked quite well, and made for a useful link to show locations. Nowhere near as good as google maps, but was a fun project.

A few months ago we had a disk issue, and because of the size of the mapping data, and the fact it is available from Ordnance Survey anyway, it was excluded from the back up. It should have been simple to restore and re-instate the old site, but turns out I did not document the re-tiling stuff very well, and it looks like the original mapping data may be a different format and filenames now, so I could not simply re-instate it.

Apparently loads of people use it though! So I have found a bit of time this weekend to re-do some bits and have another play. If you have safari then you'll find it basically works now. Other browsers, maybe not - just a blue square... I'll explain why... [update: it does now]

My idea, this time, was to try and make an image that, by construction of the URL, would be a specified size, scale, and location, to make it easy to include an image on a web page. We had this on our order page when someone selects an address, but it was not centred and was just one of my map tiles which was only like 100m square. I wanted something way more flexible that would allow embedding any size image I like, so I can link in to various of our internal web pages and so on.

However, what I did not want to do is have a back end rendering a custom image on every request, that is slow. So, I hatched a cunning plan. Make the image an SVG. You can include an SVG using an <img...> tag in a web page.

So I worked on the SVG, and the URL after allows for location by postcode, or by easting/nothing, and a scale (A, B, C, D, E), and image size as widthxheight, and finally a .svg on the end.

E.g. makes a 500x700 SVG image centred on the postcode RG121QS. The idea is you can include in an <img...> tag.

In order to make the SVG, I use the tiles as provided by Ordnance Survey, so all I had to do was unpack the zip files you download. These are TIFF files, the smallest of which is 4000x4000 pixels. So in many cases only a single tile is needed suitably positioned so the location is in the centre. SVG makes it easy to add a semi transparent pointer and some text.

Bingo... Or so I thought...

Unfortunately I have two problems. Firstly it seems that whilst an SVG can include an <image.../> referencing a TIFF file, and that works, it does not work when that SVG is used in an <img...> tag in an HTML document. I have no idea why, and I cannot find anything by googling as to why this is. So that undermines the whole reason for doing it all this way. The other big issue is that whilst safari is happy to load a TIFF in an SVG, it seems other browsers are not (the SVG spec requires PNG, JPG and SVG at least but does not mandate TIFF). I'll have to do more experimenting on that one to confirm.

To work around the first problem I have put the SVG in an <iframe...> instead, which works, but there is no point, I could simply include the SVG in a web page and use that in an iframe. The whole <img...> thing is a bust, which is a shame.

As for TIFF, assuming that is the issue, I will need to convert to PNG or some such, and if doing that I may as well re-tile and rename everything. Except this time I'll make sure I have a proper script / code to do it, and document it. It would have the advantage of allowing more manageable tiles, such as 1000x1000. I won't go down to 100x100 as I did last time as that was overkill.

Obviously, as I'll be changing the site, this blog will be out of date at some point. It depends when I find the time to play with this project again. I may even open source and put on GitHub...

So, sorry for the delay - normal service will be resumed shortly.

P.S. It really was taking all day (well all night) to tile the images, until I discovered the trick. Convert the large tiff in to an mpc file using graphicsmagick, this is its internal cache format. Then use crop on the mpc file for each tile - it maps the mpc file to memory, so making each tile in under a second.

P.S. PNGs work in firefox and chrome where tiff did not work.

P.S. All changed to new tiles now, some more tweaks to make I expect... Looking good and nice and fast.

P.S. Seems to work in everything now, even Firefox

Thursday, 15 March 2018


Having been caught out by this (and yes, I should know better) this is a friendly reminder for those coding in C.

The man page on memcpy is clear.

       The memcpy() function copies n bytes from memory area src to memory area dest.  The memory areas must not overlap.  Use memmove(3) if the memory areas do overlap.

In days gone by the memcpy would be done by a simple loop copying bytes from src to dst until length runs out. e.g. while(len--)*dst++=*src++; or some such, but probably in assembler.

So a classic case of copying a block of data back a few bytes, e.g. memcpy(data,data+1,len) would be fine.

Unfortunately the warning of The memory areas must not overlap. is not to be ignored.

You will get away with ignoring it a lot, and that is the problem! Whether you get away with it depends on a lot of things. Version of C libraries and even version of the compiler, the specific alignment of the points you are moving data to and from, the length you are moving, and probably more factors I cannot think of.

So things may work 100% until next recompiled, or simply until run on a new machine. Worse, they may work most of the time, but not quite all.

The reason is that a memcpy can be carefully optimised. For example, on an ARM you can load a whole load of registers in one go and then store a whole load of registers in one go. It may be more optimal for it to start copying from the end and work backwards, for example. The specification of memcpy not permitting overlapping areas allows for all number of optimisations to be performed in the implementation.

On the other hand memmove has to allow for overlapping areas.

       The  memmove() function copies n bytes from memory area src to memory area dest.  The memory areas may overlap: copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.

In practice it does not have to copy to somewhere temporarily, just make sure it moves data in the right order if there is an overlap. This means more checks and code that may not have quite the same optimisations available.

So, always be careful to use memmove if you cannot be sure the memory areas do not overlap.

P.S. Someone pointed out I am getting forgetful. See

Wednesday, 14 March 2018

Staying sane

Someone asked if I could post some words of wisdom on how to stay sane.

Well, the first question you have to ask is whether I am sane. Sadly I think I am, at least for the most part. At least I think I am rational.

That said, I lack a lot of tact and have wondered if I have slight psychopathic tendencies. i.e. I tend to look at things more on a rational basis than on an empathy basis, which is very much a psychopathic trait as far as I know. But clearly I have had plenty of cases of empathy, so perhaps I am normal apart from being just tactless :-) Even so I try to consider some social cases by using logic, which is always a bad idea.

So assuming I am sane, how do I stay sane.

Well, it is an odd mix. I try to stick to important principles, and do so even when that is not the best balance of cost/reward. I have a strong sense of fairness and justice. Does that work? Well, my concern is that as soon as you make exceptions you start a slippery slope, even if only with your own conscience. I am happy with rules as long as they are applied so that people know where they stand. Let one thing go because it is small and insignificant and you may as well let a larger thing go, and so on. I also feel that some times there are too many people that ignore the smaller transgressions and as a whole someone has to stand up and draw a line. So I try to draw a line and stick to it no matter what. That said, I am open to rational argument that says the line I have drawn is in the wrong place. Moving the line on what is fair or right is not a bad thing really as long as there is still a clear line, and not random transgressions. OK do I sound crazy saying that.

Having said that, as I get older, I realise there are some battles I cannot win. It is very hard to let such things drop. This is where things like the blog come in - by documenting the intractable issues I encounter, small or large, I can "park" them and try to move on. Mostly.

It is also worth looking at the big picture - even laws you do not like can ultimately be challenged and changed. When we are young we assume there is a framework of rules one must follow, but as you get older you realise that framework is made by men (and women), and worse, made by politicians, and is flawed in many ways. It is worth trying to change things some times - I have managed to do that on occasion - making laws more sane. But even laws can be challenged.

The idea of sticking to principle is not that bad I feel, and "doing the right thing" (even if understanding what is the "right thing" can be up for debate) is important. But I try to be rational and reasonable on what the right thing is, which is a mix of things like "what the law says", and what is "fair" to those concerned. Some times my ideas are at odds with other people's - that happens.

I would say one thing to do to stay sane is be prepared to change though. To accept a sound argument for why things need to be different and if so, then change your view. This is hard. It is always hard to change your views at any level.

Oh, and whisky helps.

Tuesday, 13 March 2018

Blogs brewing

I am usually the first to "blog first and ask questions later", but for a change I have a list of things that are brewing.

There are some simple things, like one about councils and arsehole neighbours and planning permission. One that will probably be blogged once I get, or fail to get, the necessary permission and the way the law can be an arse, and any way I can make a certain neighbour's life hell. We'll see - you never know, it may all blow over. I'll blog when sorted, or when I am suitably pissed off.

A less simple thing is the way that my grandson was killed by negligence of several parties just over a year ago, and this is one of those that nags at me every day. Some things matter more than others, and this is one of those. Once the lawyers have finished I expect to blog that in some detail, but for all I know that could take another year! That is one that eats at me every day and I really hope blogging it will take a load off my chest one day. We know life is not fair but sometimes it is unnecessarily so.

I may have a blog over one carrier being a dick, but that may be something we agree on and not to blog. At the end of the day if someone can actually sort the issues and reach a good result, I don't have to make it all public. Not telling the world seems odd some times, but may be in all our interests. We'll see. My blog is only a weapon if compliance means I don't use it :-)

I have some technical things I may blog on - waiting on some kit. We'll see how that goes.

I have some interesting stuff on product safety and fascias and things, which may be fun, but waiting on things to happen.

There are always the political blogs - the latest on the stupid stupid age verification for porn, thankfully delayed a few more months at least. That and the way the government are trying to censor shit all over the place with no consideration for human rights and free speech. To be clear, some people's free speech is repulsive and offensive to me, but I'll fight for their right to express it. The day we lose that right we are in a police state with censored media - a day that may have happened already.

I have one relating to trade marks, and stuff, but again waiting for some shit to happen or not happen. Some will have seen the ® on my blog title. All part of a plan.

And then there is the new FireBrick, and new A&A tariffs and stuff, which all are happening. We actually have new install prices today, but more will be added over next few days.

So lots due to happen, honest - some more serious than others.

Monday, 12 March 2018

Fair reporting

I rant on here and some times there are reasons to be positive instead of negative.

I ranted about Apple, and they have fixed things, so here is the "Well done Apple" video.

They have done a lot, and I am sure it is not down to my blogs and videos.

FYI, the Canon gripe was multiple things - the screen is touch focus and so very easy to accidentally touch the corner and have a string of videos focused on the wall FFS. The recording will revert to card 1 far too easily and then not record video one a few seconds. I managed to accidentally move the exposure bias, FFS, far too easy to do that. Then, on like the 10th take, someone called me in the middle - I had all on silent apart from my desk phone, and nearly lost the plot. The above video is around 6 minutes original as a result. I even had the Apple TV crash at one point, but I'll let it off this time.

Oh, and wow - that I am a "bond villain for turning to/from the screen like that". Thanks.

Sunday, 11 March 2018

Frustrating year so far for me

Well, where do I start...

FireBrick FB2900 should have been selling months ago, and such stupid things now being the delay - we have loads on the shelves. Safety testing final sign off within a (small number) of days with stupid minor things having caused delay. The fascia printing on the boxes, the last thing I would think would be an issue, expected in something like 10 days, but who can say for sure. I may blog the story and name and shame, perhaps. So, really, FB2900 will be shipping real soon now. The training course we ran last week went well, so do contact us if interested in the training or being a dealer!

But let's be positive - it will be shipping soon, and is awesome, and we should start work on FB9000 soon.

The new A&A tariff work we started last year, I expected to be doing more. And one of our carriers, who I have promised my own staff not to tear a large piece out of on my blog just yet, are causing some crazy issues for us. Things that should have been done and dusted over 6 months ago are not, and so more work on tariffs is a tad stalled. Even so, we hope to plough ahead with some improvements this month, albeit more risk for us doing so. The existing changes, with more lines able to get Terabyte packages, and better usage roll over and higher entry level allowances, have clearly helped, but we expected to have done more by now. More will be coming I am sure.

But let's be positive - the changes we made late last year are good, and things are happening this month too.

But I am not all about work, there is more to life that work. The stress of the broken TV was disproportionate - it is, after all, just a thing. I just feel betrayed by what almost certainly was a family member, and that is hard. Oh well.

But let's be positive - I have a nice new TV now, and rather like it. It is pretty awesome I have to say!

I've been on Indapamide, albeit a small dose, for over a year. I believe it has side effects, most notably that I am always getting out of breath very easily. I noticed right away I could no longer cycle up the hill to my house. To be frank, it is getting annoying, so I am off it now. I have to see if new meds work well, and if indeed I regain my stamina. I thought of stamina as a metric in World of Warcraft, but I could do with some now. A few days in to new meds, not sure yet. I may try starting to cycle again, we'll see how that goes.

But let's be positive - if that was the side effect, I can start cycling, get more exercise, and lose some weight!

And finally, today, it has been a year since my Grandson died. My daughter has been taken by her partner for a weekend away, but we all feel for her. Being Mothering Sunday does not help.

But let's be positive - we know exactly what killed him now, and once the lawyers have finished their stuff I'll be able to blog about it and get it off my chest. My daughter is surprisingly strong.

Friday, 9 March 2018

Limits and tolerances

Frustrating how this is dumbed down for the public and, IMHO, for no good reason.

We all know that the ASA have a big issue with someone saying that broadband can be "up to 80Mb/s". They need it dumbed down to a 90th percentile or some such.

Indeed, even OFCOM want a "range" of speeds on an individual line estimate, but rather than a range of the "lowest speed we would ever expect without a line being faulty" to "the highest speed physically possible on that line length", they actually want 20th to 80th percentiles, to dumb it down, and create a case where 40% of people see line speeds that are not in the "range" that was quoted.

So, some simple bits of logic here, which any scientist or engineer will understand.


If I quote a simple single figure for something, such as 100mm, there has to be some tolerance for that. E.g. let's say I am telling you the length of a metal rod that is to be used as a part in some machine.

You cannot make a metal rod that is 100mm long. Basically, at the edge of that rod will be atoms, and at the very best you can make it one atom more or one atom less in length, and even the "edge of the atom" is questionable. If 100mm is not an exact number of atoms long, you have not made a rod 100mm long. It is just close, even if very very very close...

In practice I may say 100mm ±1mm. This creates a range of 99mm to 101mm. You can aim for that, and will meet it or not.

Whatever analogue metric you are quoting, length, temperature, voltage, as a fixed value, ultimately it has to have a tolerance. It should all be explicitly stated, though some specification may say "all lengths are ±1mm" or some such. In any case you need to know the tolerance to understand the fixed value you are given.


Very similar to the above, any measured analogue quantity will have an error margin, and it is just like a tolerance. If you say it is 20 in here, then that will have a margin, maybe ±0.5


If you specify a limit, e.g. a minimum, or a maximum, or a range, you do not need a tolerance.

A limit can be absolute. E.g. that metal rod must be <100mm. A rod that is one atom longer is not within limit.

Stupid regulations

Some of you may have seen my example label for the new FireBricks. Based on the specs of the parts we quoted 85V-264V AC. That is a range.

These limits are absolute, 84.9999V is too low, 85.00001V is fine (as it 85V).

But guess what? The figures we quote have to allow for 10% tolerance. WTF? Limits do not need tolerances, they are absolutes.

End result, we have quoted 100V-240V. The 240V with 10% is 264V. The 100V with 10% off is 90V not 85V, but we can handle down to 85V. We decided to give in to the madness as say 100V. We could have gone for 110V maybe. The same issues with frequency of supply, a range but with a tolerance on the values?!?!

But really, what is wrong with actual limits - why is this remotely hard - limits do not need tolerances.

As an engineer I would read that as 241V is too high, but apparently that is not the way the regulations work!

P.S. I saw a strange use of ± on train times, I think in Holland, but not sure. Basically they would say train due in ±5 minutes, when they definitely did not mean due -5mins. They actually means 5mins ±something, but was a strange way to quote it. It was almost as if they used ± as "about", when it means "plus or minus". Using ~, e.g. train in ~5mins, would make a lot more sense as "about 5mins".