Latest posts

Using Twitter as a voting platform

Cast of Star Trek

Like a lot of other people, I've had a love/hate relationship with Twitter. At first I didn't see the point - it was just Facebook without the features, then I drank the kool-aid, and fell in love with its simplicity and openness. Nowadays I've backed off a bit and see it as an interesting social phenomenon that I enjoy being a part of. I'd been meaning to check out the Zend_Service_Twitter PHP library for a while, but hadn't really thought of an excuse.

A few weeks back I was unlucky enough to watch Star Trek V and tweeted about how crap it was, despite my friend Nick thinking it's the best of the lot. There was a bit of back and forth, so I posted an order for the films, from best to worst. A few of my friends then did the same, with the hashtag of #startrekrank as a way of identifying the posts.

It struck me that I could somehow aggregate these results using the Twitter API, so I present to you, StarTrekRank.com!

Simplify pagination logic using a custom Zend_Paginator_Adapter

Pagination logic is something that I've found myself redoing a number of times over the years, and each time it's been a relatively fiddly and painful process.

This time around I decided to check out the Zend_Paginator component from the Zend Framework, and found the process useful enough to share! In my case I was using Doctrine to retrieve data from the database. I'll skip most of the Doctrine-specific stuff, however, as hopefully this will end up as a decent example of how to integrate Paginator with other non-Zend libraries.

When the Paginator is instanced, it's given an instance of an appropriate Adapter and told what the current page is:

<?php
$paginator 
=  new Zend_Paginator($adapter);
$paginator->setItemCountPerPage(20);
$paginator->setCurrentPageNumber(2);

Article in php|architect (maybe)

Sorry for the lack of recent posts - I've been distracted recently working on an article I've written for php|architect.

In theory it'll be in the August issue but these things are subject to change and frankly they could probably still reject it if they wanted to.

Anyway there's still time to subscribe if you want to get a copy!

Working out the speed of light using a fish pie

Today I brought in some leftover fish pie for my lunch. I heated it up in our office microwave, but didn't notice that the turntable had slipped off its axis, so the whole thing didn't turn. When I came to eat the pie, there were hot and cold patches on the top, in a classic interference pattern. Microwaves always have these hot and cold areas, which is why the turntable is important.

No more pie

Sadly the pie disappeared before I could take a picture

My tupperware box is about 20cm across, and the hot patches were about half its width across, so I estimated the distance as 10cm. The label on the microwave gave the frequency of the magnetron as 2.45GHz. The relationship between wavelength and frequency of a wave is as follows:

wavelength = speed of wave × frequency

or:

speed of wave = wavelength ÷ frequency

Webmasters: opt out of Phorm now!

I just got the following email:

"Thank you for your submission to the Phorm website exclusion list. If there are no obvious grounds to doubt the legitimacy of the request the URL will be blocked as soon as possible, usually within 48 hours."

You can get one too by writing an email to the Phorm opt-out address () asking them to remove their service from any and all domains you have control over. I could explain why, but it's best if you just do it first. What you'll be doing is placing a vote against a fairly insidious new marketing system that most of your users won't know how to opt out of, or even know is happening. Go on, do it before you read the next paragraph.

For years marketing companies have been offering consumers the following deal: "Give us a completely history of every website you visit, and in exchange we'll give you slightly more targeted adverts". Most people on hearing this proposition don't really see what's in it for them, and decline. Basically, the price in privacy is worth far less to most people than some idea of amazingly personalised advertising.