PR update
Oct 01
I just noticed on Shoemoney that there’s a Google PR update underway.
Sure enough, this site has dropped from PR6 down to PR5. It’s a bit annoying obviously but not a lot I can do about it. How have you fared?
No Comments » | Add yours
Light emitting material
Sep 07
Phillips have made some serious advancement in the light emitting material arena, as this video on YouTube shows.
How long before we have couches linked up to TV sets to give ambient lighting effects that engulf where you’re sitting?
That would be cool.
No Comments » | Add yours
Calculating distance with latitude/longitude in MySQL
Sep 03
I’ve created a few sites in the recent past that have required some kind of distance calculation. Each of these sites have been solely UK-based and therefore I’ve used a MySQL setup whereby the table contains an X and Y column consisting of the Ordnance Survey grid reference (OSGB) for a particular UK postal code.
From this I can do a simple query such as:
SELECT id,name,((sqrt((($x - x) * ($x - x)) + (($y - y) * ($y - y))) / 1000) * 0.621) AS distance FROM companies HAVING distance <= $miles ORDER BY distance ASC LIMIT xx
Passing in the variables $x and $y as the starting point and $miles as the maximum distance to travel we can then produce a result set of all the companies in the database ordered by distance in miles.
This is all well and good for UK datasets, but what about mapping distance anywhere in the world?
Instead we need to switch to using the latitude and longitude of the location instead of the X/Y grid references and use a much more mathematical query:
SELECT id,name,(((acos(sin(($lat*pi()/180)) * sin((latitude*pi()/180)) + cos(($lat*pi()/180)) * cos((latitude*pi()/180)) * cos((($lng - longitude)*pi()/180))))*180/pi())*60*1.1515) as distance FROM companies HAVING distance <= $miles ORDER BY distance ASC LIMIT xx
So in this instance we pass in the variables $lat and $lng for the starting point as well as $miles for the max distance to search, with the database containing columns “latitude” and “longitude” for the dataset. This query is easy enough to alter for mapping in kilometers instead of miles.
You’ll want to index latitude and longitude in the db to ensure the queries aren’t uber slow, and I haven’t tested this on a table with more than 3000 rows so performance could be an issue.
Something else to consider is the value of pi() within MySQL. For greater accuracy you may want to include a static value to greater decimal places.
8 Comments » | Add yours
Flickr bit of Cake on the table
Aug 31
This is a screencast of a recreation of the RoR Flickr app but built using CakePHP. I recorded this screencast back at the beginning of May but due to sound quality issues I never posted it up or re-recorded it.
A friend of mine mentioned it’s existence in #cakephp on irc.freenode.net and I noticed that they had another version up on the website by Ros-soft. Whether it was the reason it was made I dont know but I didnt feel the need to release this one afterwards, but here it is anyhow.
The sound was very quiet so I exported the .wav, bumped it up and re-imported it back in. Quality is not all the brilliant and it goes a bit out of synch but it will do
It’s only in Flash .SWF format right now, if someone could convert it to a Quicktime .mov I’d be uber grateful.
Also, this was my first attempt at recording, and it’s my first ever screencast so it’s not too brilliant and I made some schoolboy errors along the way there — just cut me some slack…
Direct link to SWF (16Mb).
1 Comment » | Add yours
TechCrunch UK
Aug 29
I must be behind the times this week, I didn’t even know that TechCrunch had launched a UK specific site.
So far it looks pretty good. I’ve said before that the UK is really lacking in a quality Web 2.0 blog and it was obvious TC would get in the act at some point even if someone else beat them to the punch.
I’ve subscribed so we’ll see how it fares.
No Comments » | Add yours