Google's charting API has been around for quite a while now, but I've only just needed to actually look at it. It became immediately obvious that I needed a PHP encoding function, so off to google I went. Though I found several implementations, they were all incomplete or deficient in one way or another (and it didn't help that there was an error in google's extended encoding docs), so I've written my own based on several different ones. Both simple and extended encoders support automatic scaling, inflated maximum and lower-bound truncation, so you can pretty much stuff whatever data you like in, with no particular regard for pre-scaling and you'll get a usable result out. They have an identical interface, so you can use either encoding interchangeably according to the output resolution you need (contrary to popular belief, the encoding to use has very little to do with the range of values you need to graph). By default, the full range of possible values is used as it just seems silly not to. I deliberately omit the 's:' and 'e:' prefixes so that you can call these functions for multiple data series, and I include a function that does just that. You still need to generate your own URLs and other formatting, but that's a different problem. Read on for the code...

Continue reading "Google Charts API Simple and Extended Encoders in PHP"

Why isn't UK voting anonymous?

Thursday, June 4. 2009

I voted in the European election today. I was pre-registered and had received my voting card. I went to the polling station where they looked at my card, checked it against my name on the electroal roll, crossed it out, and noted its number on a list next to the unique ID of the ballot paper. I made my choice and put the slip in the ballot box. Much of this process is necessary in order to combat fraud and ballot rigging, however, it's clearly not anonymous - a simple reference back from the paper's ID to my voting card ID means that the government knows what I voted. Knowing what I voted gives no anti-fraud advantage I can see, and means that the collected data is way more sensitive than it needs to be. The simple fact that this knowledge exists is likely to distort voting patterns - people might be afraid of their political leanings being exposed. I'm not particularly worried about that personally, but those with more extreme views (like those that vote for the BNP) might not want this known, and it undermines the absolute right to freedom of association. Political affiliation is regarded as the highest form of 'personal data' under the data protection act, along with ethnicity, sexual preference, medical records etc, and the best way to avoid problems with this kind of data is not to keep it in the first place, as the numerous leaks/losses/exposures of government information have highlighted. So why is it done? Aren't elections meant to be done by secret ballot? Did I miss something? Why aren't more people disturbed by this?
I've just had a slightly tricky time upgrading a subversion repository on sourceforge. They have recently added support for subversion 1.5 at the server end. 1.5 brings major new features for merging, but as it's not backward compatible with older subversion clients, the upgrade is not done automatically. SF have also done a major rearrangement of their documentation while transferring everything to Trac, and it's not always easy to get the right info. Normally to upgrade a subversion repo, you just run the 'svnadmin upgrade /path/to/repo', however, it's not quite so simple on sourceforge as you don't have direct access to the repo, and the instructions they give are slightly wrong at the time of writing. You're likely to get an error like this (it's not obvious that this is a fatal error) when you reload a dump file:
svnadmin: File already exists: filesystem '/svnroot/projectname/db', transaction '443-0', path 'tags' \* adding path : tags ...
This is because load is intended to add files to an existing repo, not to replace those that are already there, so you need to wipe the repo and start from scratch. So, here is a working command sequence that needs to be run from a project login shell on sourceforge (it applies to the project you're logged in through, substitute your project's name for projectname):
adminrepo --checkout svn svnadmin dump /svnroot/projectname > svn.dump rm -rf /svnroot/projectname/\* svnadmin create /svnroot/projectname svnadmin load /svnroot/projectname < svn.dump adminrepo --save svn
Yes, you do need to delete the whole thing and re-import it, but it's quick and easy, and you have a backup in the dump file you take at the start. After the upgrade, make sure you get a new checkout of your project to ensure that you're using 1.5 all the way through. Now you'll find that commands like 'svn merge --reintegrate' work.

Speaker & room calibration

Friday, March 20. 2009

I was lucky enough to pick up a Behringer Ultracurve Pro DSP8024 for a mere £50 on eBay recently. It turned out to have a buggy OS version (1.2), and Behringer very kindly sent me a replacement EPROM with a new 1.3 OS on it, which works just fine. I now have it installed between my Soundcraft mixer and my Wharfedale active monitors. I used its "Auto-Q" calibration routine and put up with some quite loud pink noise to calculate a room correction curve. Because it knows the spectrum it's generating, it assumes that what it gets back has been altered by the combination of speakers, room and microphone, so it can calculate an eq map to compensate for it. It's quite fun to watch as it has a nice big LCD screen to display the 31 1/3 octave bands - the initial spectrum is fairly peaky, but as it iteratively applies corrections you see (and hear) it flattening out. It's also very obvious that my monitors don't put out much below 50Hz (it analyses down to 20Hz), but that's to be expected from a moderately sized box with a 6.5" driver. The results are really pretty good, sounds lovely and smooth, but the real surprise is when you've been listening to it for a while and you switch out the EQ - it's really quite a shock to hear the uncorrected version. Lots of purists don't like room correction by EQ, saying it's better to fix the room in the first place, and also that EQ calculated like this is highly dependent on the listening position (which it is). I have a lots of bookshelves facing my speakers; they make fantastic diffusers, and I have some Universal Acoustics absorber tiles on the sloping ceiling above my listening position. The longest room mode will be fairly undamped (I'm not about to start hanging duvets around the walls!), but the resulting EQ is below 6db in either direction across the whole range - I've heard of rooms with 24db peaks! Anyway, after all that, it sounds lovely, and I'm happy!
When you're developing web stuff, working with projects in path names (i.e. not at the top level of a domain) can be difficult (gets in the way of absolute links, rewrite rules etc), so you often need to set up a local apache virtual host, stick an entry in DNS and create an SSL certificate before you can get on with the serious business of doing some real work. This can get to be a drag when you do it a lot, but there is an extremely elegant solution that means you'll never have to do it again...

Continue reading "The web developer's holy vhost trinity"

Ginger and Honey Snaps

Monday, March 9. 2009

I had this peculiarly specific desire to make some biscuits that were crunchy rather than chewy. Nigella didn't seem to have anything that fitted the bill, but I found this recipe in Rachel Allen's "Bake" book that I got for Christmas, and have had good results with so far. When rolling out the biscuits (definitely the best part) I thought they looked oddly like small potatoes. Next time I won't squash them quite so much so that they stay a bit rounder. While I was baking there was an enormous rainstorm, really quite spectacular and unexpected as it had been quite sunny all day. They came out brilliantly (if I say so myself), a lovely crisp mixture of sweet and spicy, exactly what I was after. As usual, the main problem with making biscuits is that I eat them, which isn't terribly good for me. I did send some round to Sandeep and Pam though, and they are proving handy for bribing Zoë.

Changing MacBook Bezel

Monday, March 9. 2009

I recently had cause to change the bezel on my rev A 13" MacBook. If you follow the guide on MacFixit, it is a long and complicated procedure, involving dismantling nearly everything. Luckily, most of it is unnecessary - it's really quite easy to simply remove the bezel without dismantling anything; just jump straight to step 35 and carry on from there.
Someone at AMEE pointed out to me that there's been a flurry of activity around so-called "Web Hooks" when I referred to the concept. This is quite heartening as I thought of this a couple of years ago and implemented this in Smartmessages early last year! I call them callbacks, but the idea is the same - it's essentially a distributed observer pattern. I couldn't figure out why nobody seemed to understand what I was on about... When I get some interesting event (e.g. a message open, mailshot completion, clickthrough etc), I ping a user-supplied URL with the appropriate event data, pretty much the one-liner that Jeff alludes to. The reason we do it is that sync with external systems (usually CRM) is something that were always running into, and there seems to be no sensible, generic way of dealing with it other than this, so I'm surprised it has not been discussed in this context before. There's one downside as far as I can see - it is highly dependent on the receiver to be able to handle the event in a timely fashion. This isn't an issue if you're connecting say, Yahoo! to Google, but it could be a big problem if you connect Google to your Wordpress blog... My experience of CRM systems is that they are simply too slow to cope with the high rates of traffic that we are likely to generate, for example, if we point a stream of ~200 events per second at a CRM system, it will probably just bog down and fail (I'm thinking of the SalesForce API here which typically takes 1-2 sec to deal with a single SOAP API call). Retrying will only make this worse. I have two solutions for this: limit events to those that don't happen so often (kind of lame!), or alternatively, use an outbound message queue to rate-limit the sending (Amazon SQS and Memcacheq spring to mind). Queueing works, but you lose some of the real-time aspect. Ideally clients would implement their own incoming queue in order to allow them to process events at their leisure, but this is mostly beyond the vast majority of web authors (or at least those that host the CRM systems that we hear from!). Anyway, it's nice to know that I'm not completely barking...
« previous page   (Page 2 of 12, totaling 93 entries) » next page