OSRM / Docker on an M1 MacBook

If you’re trying to setup OSRM with Docker on a MacBook you may run into trouble when extracting/processing map data. The script fails silently so isn’t much help.

Here’s the tutorial I’ve been following: https://medium.com/@anjulapaulus_84798/osrm-lets-run-it-on-docker-a437b6bf2f90

Specifically this part:

docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/sri-lanka-latest.osm.pbf

It turns out that the issue is just your machine running out of memory: https://stackoverflow.com/questions/53157542/osrm-extract-silently-fails

In Docker I increased my memory limit to 5GB, and my swap to 2GB. This was enough for the GB/Ireland map.

Getting into Angular and React

This is something I’ve been meaning to do for some time. Some stuff at work has required me to fixed bugs in an Angular project, so I’m researching and getting into that. At the same time, personal projects seem to be taking a turn towards React for front-end stuff.

So I’ve started by completing the O’s and X’s tutorial here: https://reactjs.org/tutorial/tutorial.html.

Correct WordPress File/Folder Permissions

Seems to be right to me, for most of the time anyway:

chown www-data:www-data  -R * # Let Apache be owner
find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r--

Thanks to Manuel: https://stackoverflow.com/a/23755604/12163343

Correctly POSTing boolean values in jQuery

When I’m building Javascript/jQuery based webapps, my go-to method of performing AJAX requests is via jQuery .post() using JSON.

My code normally looks something like this…

var postUrl = '/someurl.php';
var postData = {'id': 123, 'data': 'xyz', 'bool': true}; // etc

var jqXhr = $.post(postUrl, postData, function(data){
	
	// Do something with the result here...
				
}, 'json');

This generally works fine and is quick and easy, however you run into trouble with boolean values… they end up getting posted as the strings ‘true’ and ‘false’. Of course you can hack around this in the back-end but it’s far from ideal.

Below is a better way I have devised that behaves properly when it comes to data types other than strings…

var postUrl = '/someurl.php';
var postData = {'id': 123, 'data': 'xyz', 'bool': true}; // etc

var jqXhr = $.ajax({
	type:			"POST",
	url:			postUrl, 
	data:			JSON.stringify(postData), 
	contentType:		"application/json; charset=utf-8",
	success:		function(data){
		
		// Do something with the result here...
		
	}, 
	dataType:		'json'
});

So go back to using .ajax() rather than the short hand .post(), and use JSON.stringify() for the stuff you want to send back.

In the back end you have to add an extra step to retrieve your data. In php you must decode the result of file_get_contents(‘php://input’). Because I was altering existing code I put the resulting array into the variable $_POST at the top of my script as seen below…

$_POST = json_decode(file_get_contents('php://input'), true);

Webb Lawnmower Colour Code

I’ve got a 1970’s 24″ Webb AB series mower that could do with some paint work sorting out. It seemed difficult to pin down what colour the paint used was so I bought a British Standard colour swatch book and here I am publishing the result of my investigations.

At first when looking at the top of the mower nothing seemed to be a great match to the presumably faded paint. But then I removed the unneeded brake from the rear roller (I don’t have the seat), the unfaded paint on this part is a very close match to Olive Green (220-381C) which I’m confident it must have been painted in originally.

1970's Webb Lawnmowers are painted Olive Green (220-381C).

Mine’s the earlier belt driven one, but I think this will also apply to the later chain driven model and other Webbs of around the same age.

Apple Watch

Ben Thompson: Apple Watch: Asking Why and Saying No

While watching the unveiling of Apple’s Watch last week I was ‘feeling’ what Ben above articulates so well. Why do I want this device?

I now recognise that when I was studying Industrial Design at University, the best projects were the ones that really asked why something should exist, and the proposed solutions answered that question well. Unfortunately it was very common amongst students on my course (myself included) to go off on a tangent, creating great looking designs along with beautiful CAD renderings of solutions that had absolutely no solid answer to the why question. I hope Apple haven’t fallen into this trap.

Clark Goble:

I just can’t quite figure out how many people would want the watch. I didn’t see that Apple made a compelling need case for it. Say what you will about Jobs. But he always had a killer function — even for the iPad. Exercise seems to be the attempt for the watch, but even that isn’t that compelling given the limits of the watch itself.

I’m not a big jewelry wearer so I found myself coming to the watch from the fitness angle too. However when you find out that it relies on the GPS in your iPhone you know that it’s a non-starter. My iPhone is a bit big to take running with me, but to track runs and be a music player it’s my best option so I do. The Apple Watch doesn’t allow me to leave my phone at home, so that doesn’t help me. If Apple can move this way for version 2, then their watch plus a pair of bluetooth earphones could be compelling.

Learning LESS CSS

Been getting into LESS CSS recently.

Adding Cup Holders (BMW E39)

A few tips for adding cup holders to the front of an E39 BMW.

I had the now obsolete Traffic Master system so I replaced it with the cupholders (available on eBay).

However when fitting I struggled to work out what you need to screw them to. Apparently you need some metal clips that give you something to screw to.

Looks like the part number is ’07-14-6-988-451′. Also described as a ‘Body Nut’.

Edit: Here’s a link to what seems to be the correct clip.

When might we see an ARM powered Macbook?

A little while ago I compiled some ARM vs x86 Geekbench data.

The figures are for the base model Macbook Air released each year, and the processor found in the iPhone (I’ve left out the iPad only A5X). When surfing Geekbench I discounted values that seemed to be obvious outliers. If anyone knows where you can find an average score by CPU please let me know.

iPhone CPU, Date, Score 

1176JZ(F)-S 412 MHz, 07/07, 137
1176JZ(F)-S 412 MHz, 07/08, 137
Cortex-A8 600 MHz, 07/09, 148
A4, 06/10, 210
A5, 10/11, 406
A6, 09/12, 1278
A7, 09/13, 2557

MacBook Air CPU, Date, Score 

Core 2 Duo L7500, 02/08, 2315
Core 2 Duo L9300, 10/08, 2557
Core 2 Duo L9400, 07/09, 3093
Core 2 Duo U9400, 10/10, 2033
Core i5-2467M, 07/11, 4559
Core i5-3317U, 07/12, 5636
Core i5-4250U, 07/13, 5919

Continue reading

Burying the URL

Interesting article centring on a feature in a canary build of Google Chrome. Desktop browsers hiding the protocol and mobile Safari hiding the url has bugged me too.