Ad-o-matic: The ad generator


September 9, 2008

Why waste time thinking? Let the Ad-o-matic take the strain.

Coming up with award winning ads day after day is hard work. But thanks to the Ad-o-matic, with a few clicks you can create great ads in an instant. Leaving you free to get on with the important jobs – like deciding what trainers to wear to the next award ceremony.

So the next time the Creative Director comes knocking, you know what to do.

Tags: , ,

The SEO experiment – Part 2 Google Rank graphic


August 17, 2008

A sites position on Google work like this:

Position = Relevance of content * Google Rank

So, knowing my current Google rank is going to be handy. There are a bunch of different ways to discover a sites rank from the Google Toolbar, to a million and one websites. As I want to chart the progress of this site I also need a way to periodically record my results.

I need the following components: a script to periodically measure Page Rank, a database to store the results, and a script to chart the results.

Page Rank Script

After a quick search I came across a great Open Source Google Rank script. This script returns code for a graphic so I rewrote the function pr_image($pagerank) to return a number instead.

The Cron job

I set up a Cron Job to periodically call the following script. (This script is placed outside the html directory for security).

<?php
//Connect to the database
include 'connect.php';

//Include the Page Rank script
include("pagerank.php");

$today = date("Y-m-d");

//Discover the current Page Rank
$gpr= new pageRank();
$gpr->printrank("http://www.matthewbyrne.co.uk");
$pageRank = $gpr->get_pr();

// Insert a row of information into the table
mysql_query("INSERT INTO googlePR (theDate, rank) VALUES('$today','$pageRank' ) ") or die(mysql_error()); 

//We've finished with the database, so close the connection
mysql_close($conn);

?>

Charting the results

The results are displayed live in chart (to the right). This script still needs a bit of work, as it will run off the edge of the graphic after a couple of months, but for now does the job just fine. Also, it looks a lot nicer when the bars are not all zero, so I’m keeping my finger crossed that Google moves me up a rank or too.

<?php
//Connect to the database
include 'connect.php';

//set up image
$height = 120;
$img = ImageCreate(230,$height);
$white = ImageColorAllocate($img,0xFF,0xFF,0xFF);
$black = ImageColorAllocate($img,0x00,0x00,0x00);
$blue = ImageColorAllocate($img,0x14,0x8A,0xD6);
$grey = ImageColorAllocate($img,0xCC,0xCC,0xCC);

//Query databasebase
$query= "SELECT * FROM googlePR_MB";
$data = mysql_query("SELECT * FROM googlePR_MB")
or die(mysql_error()); 

//Build array
$results = array();
while($info = mysql_fetch_array( $data )){
	$reformatDate=date('d M',strtotime($info['theDate']));
	array_push($results, array($reformatDate,$info['rank']));
}
//We've finished with the database, so close the connection
//mysql_close($conn);

$resultCount = count($results);

//Generate bars
for ($i=0;$i<=$resultCount;$i++){
	imageFilledRectangle($img,20+(5*$i),($height-1)-($results[$i][1]*10),20+(5*$i)+3,$height,$blue);
}

//Generate y-scale
for ($j=0;$j<10;$j++){
	ImageString($img,1,8,$height-(10*$j), $j,$grey);
}
//Add titles
ImageString($img,1,20,0,"Google Rank for www.matthewbyrne.co.uk", $black);
ImageString($img,1,20,10, $results[0][0]." - ".$results[$resultCount-1][0],$black);

//Output graphic
header('Content-Type: image/png');
ImagePNG($img);
?>

Postcode widget – Part 2


August 16, 2008

The Easypeasy Database

Today I’ve been testing the Easypeasy database for my widget project.

I began by installing the data to MySQL. Very easy to do as the downloadable zip comes with a file you can import directly into MyAdmin.

With the database installed I used two scripts to look at the data in more detail. Firstly, one to establish the initial database connecion – it’s an idea to keep this file separate so you only have to write it once. Then, a second script that builds a form and processes the results.

Once I started to plot my results it quickly became apparent that although Latitude and Longitude is returned for each entry, the numbers are all rounded up. This puts W10 and SE13 on the same spot, so there’s still a bit of work to do to figure out how to the x and y fields effect the results.

Here’s the code I wrote for the form:

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
Input Post Code:</br>&ltinput type="text" name="code" size="30">
<input type="submit" name="submit" value="submit">
</form>

<?php

//Connect to the database
include 'connect.php';

//If the form has been submitted then process the form
if (isset($_POST['code'])) {

//Grab the Postcode from the form
$postcode = $_POST['code'];

//Convert the Postcode to all uppercase
$postcode = strtoupper($postcode);

//Break the Postcode into two
list($outcode, $partTwo) = split(' ', $postcode);

//Pull out the relevant fields from our database
$query = "SELECT latitude,longitude FROM hwz_postcodes WHERE
outcode = '$outcode'";
$result = mysql_query($query) or die('Query failed: '.mysql_error());
$line = mysql_fetch_array($result, MYSQL_ASSOC);

//Print Results
print $postcode.' : ';
print $line['latitude'].','.$line['longitude'];

//We've finished with the database, so close the connection
mysql_close($conn);
}

?>

Google Badge Map


August 2, 2008

Click here to see a working version

Here’s an experimental Google map made using some excellent software from UCL Centre for Advanced Spacial Analaysis (Casa). The application slices up a large digital image – the one used here is 8000 x 8000px 30mb into a 256 x 256 pixel tiles (you might have noticed the how the map image builds up from these unit blocks).

The tiles correspond to the magnification of the map. At the lowest level the entire image is contained within a single 256 pixel square repeated left and right – this is the maps initial state. As you zoom in the tile samples are closer to the original image resolution.

The plan for the map is to lay a data layer on top of the map corresponding to each individual badge. This will hook up to the eBay API so when it comes time to sell the badges we can see a live data feed.

References:

Casa
http://www.casa.ucl.ac.uk/software/googlemapimagecutter.asp

Tags: , , , ,

Postcode Widget – Part 1


July 31, 2008

Background

After playing around with Google maps for a few days it became apparent that having a list of UK postcodes plus the corresponding latitude and longitude to each would come in very handy for a lot of people. If you had such a thing you could build loads of exciting applications, from route planning to food mile calculators.

The problem is that here in the UK the list doesn’t exist in the public domain. It’s available from the Post Office, but it’ll cost you, making it effectively useless for most small groups and enterprises.

What’s currently available from Easypeasy is the first half of the code. With this you can break the UK into about 3,000 separate parts, narrowing a location to within a few kilometres.

Project Brief

There appear to be two groups pushing the Postcode into the public domain, Free the Postcode and New Popular Edition Maps.

What I’d like to do is build a widget that people can put on their website that makes it easy for the general public to enter their Postcode, and help build the free database. Currently you are required to specifically visit either of the two website and with Free the Postcode know by heart your latitude and longitude.

Using the Google Map API combined with the first half of the postcode the widget would pull up a map of your local area, from here it’s easy to stick a pin where you live or work, and then after (an email?) authentication your postcode is added to the database.

References

Free the Postcode: www.freethepostcode.org

New Popular Edition Maps: www.npemap.org.uk

Postcode Schema: www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm

Easypeasy: www.easypeasy.com/guides/article.php?article=64

A Simple Actionscript Class Definition


July 30, 2008

I know I’m a little late to the party on this one but I finally cracked Flash Classes last weekend – yay!

To be honest there wasn’t really a whole lot to crack, just the definitions of private and public functions.

Essentially a public function will execute when the class is initialised, and a private function will wait to be called, and that’s all there is to it .

Try this out:

In a text editor create a file and name it TestClass.as

Type the following:

class TestClass{

	public function foo(){
		trace(“Hello from Foo”);
	}

	private function baa(){
		trace(“Hello from Baa”);
	}

}

Now create a new Flash document and save it in the same folder as TestClass.as

On frame one (or any other) type:

var myTestClass = new TestClass();

now publish your movie and you should get the output “Hello from Foo”

If you now add the following line:

myTestClass.baa();

publish your movie and you should get the output “Hello from Foo”, “Hello from Baa”

Yes, it really is that easy!