Wednesday 8 April 2009

A new project, a piece of code, and crossing the streams

Let's give this blogging thing a go.

I've recently been doing design/development on a band's new website. It's going to be a simple 1-page sound-clip/mailing list sign-up type page, but I am keen on throwing around some of the more interesting/modern (read trendy) web gubbins.

Out of principle i've until recently refused to use twitter, and I still don't 'get it' - but as an incredibly simple method to get band members posting on their own site, without setting up a blogging tool, it's great.

Also, the hosting plan they've bought is html only, which is actually quite invigorating, forcing me to get more into javascript coding, rather than just relying on PHP/MySQL to do a lot of the legwork. This also means that the scope of the site is drastically limited, only allowing me to scrape up the putrid run-offs from other sites content streams.

This seems to be a large part of the (now slightly aging) web2.oohhdeargod ideals - outsource the maintenance/admin/storage tools to other site, and simply collect their streams into one place. The RSS feeds (and more recently the easy to use APIs) these content managers (such as twitter/flickr/youtube etc etc) coat themselves with now mean that even the simplest sites can provide dynamic content with a few lines of code.

Which leads, bizarrely, to the code part of this blog post. Ripped and modified from the great CSSTricks, this simple snippet of JQuery will search for a specified string using Twitter's API, grab up to 100 posts, and randomly pick 2 from those that are available (see the CSSTricks article for the supporting .linkify() function).

$(document).ready(function(){
var q = 'hot rats';
$.getJSON('http://search.twitter.com/search.json?
q='+q+'&rpp=100&callback=?',
function(data){
var i = Math.randomMax(data.results.length-1);
var j = Math.randomMax(data.results.length-1);
$('#twitter1').append(
data.results[i].text.linkify());
$('#twitter2').append(
data.results[j].text.linkify());
});
});

(I promise that future code will be more interesting)

The idea behind this was that, even if the band guys never post a single message, there will be random, anarchic content always appearing on the site. In the design it is fairly well scrambled using negative letter-spacing over a b/w silhouette, so that too much isn't taken from the inane twitterings. There is whole bunch of enhancements that could be added to this - such as only picking tweets of a certain length, not picking the same tweet, etc etc.

Note that this is my first look at JQuery code - I have been using Prototype as my JS library of choice up until now. I prefer Prototype simply because of history, but it looks like JQuery is winning the popularity vote, so I've decided to give it a go in new projects.

Despite its flaws, JS seems to be where a lot of the heavy lifting is heading in webdev, and it's been good to get a bit of practice in.

Monday 6 April 2009

A new blog - what are the odds of me posting to this again?

If we take the need plus desire of others to read my thoughts, multiplied by the actual value it would have to them, divided by my own narcissistic desire to splurge my brain-wanderings all over their eyes, subtract my ability to produce anything remotely readable, entertaining or useful, and then divide the whole mess by 0 (the number of visitors this blog is likely to ever receive), we can see a result that is absolutely meaningless, which demonstrates nothing, and which is of no discernible value to anyone.

Anyway - if I do ever write here it could well turn out to be a mixed bag, mostly snippets of code (PHP/Javascript, mostly), some links I guess (though the internet is full of them, why would you want more?), and maybe some other random thoughts (maybe i'll even go off on a rant about the planetary sized ego of amateur bloggers...)

Bosh. Blog that you blogging bloggos.