Tuesday, 1 May 2012

Gearing up...

Well, it has been a while since I last posted anything of worth here, so I thought I'd update with some opening thoughts on the new technical features for the Beavervision Scoreboard.


Problems what I was having with the old scoreboard (2010-2011 version) - whilst it was lovely were (in no particular order):

  • Feature adding was becoming a pain, LINQ to Entity Framework is difficult to get right with lazy loading, and easily chews up far too much memory.  Whilst this can be fixed, I was becoming less-and-less of a fan - the effort required just to change data retrieval is a tad silly, and adding features becomes quite onerous... surprisingly, databases have these amazing things called Stored Procedures - which, you know, do all this really well for you - as they have done for years.
  • Device support, was, well poor.  Sure I could support some iOS devices, but not very well and it was all turning into a teetering tower of terrifying tutiness.  Anyone with anything out of the ordinary was shunned (and rightly so).  But I wasn't making use of the available features on those devices I did support... so it was time for a rethink in that area.
  • Last minute fudges, were numerous and ugly - this year I gave myself way more time to think things through and come up with something right, mostly.
  • And numerous other things that I wasn't quite happy with... that I shall hopefully remember later on when I write more on each topic.
Now, thankfully, as I'm sensible and unlike many developers can actually design a database properly, that end of the problem stack wasn't a problem... in fact I've been extending the data model quite merrily without a hitch - and most of the core of this database will still merrily work on a 2004 version of the scoreboard front-end (I don't have the software or inclination to attempt to actually prove that... but you know, I'm right).

Next up the list is the DAL... and this was where I started with my first pile of changes (which I'll expand upon in my next post).  Traditionally I'd hosted everything in one monolithic website and stuck my thumbs up... as mentioned previously this had been implemented in LINQ to Entity Framework and all the SQL was abstracted away from my control - so this year I threw that all away.  I still use Entity Framework as my SQL Client and an Object Mapper, but all the data insie-outsie is done via Stored Procs - and the whole thing has been extracted into its own WCF host layer.

On top of that - ASP.NET MVC again, but this year I've decided to go for the bleeding edge 4 (Beta!) as the device detection stuff seems pretty solid and far simpler than previous versions.  This required rewiring all the data to methods exposed in the WCF host, modifying stuff to use RAZOR and well actually completely rewriting the site as everything had changed... again I'll go into this in more depth later on.

Finally, on top of all that, for mobile devices I've lobbed jQuery Mobile into the mix for good measure so that there should be a consistent behaviour across all devices (don't ever expect there to be consistent behaviour across all devices).  Expect plenty of whinging around this.

Thus far I've played about with it on various flavours of iPhone, iPad and Android devices - it all plays ball to a certain extent, and well looks quite good.  There a couple of features left to put in, but nothing particularly stunningly complicated or noticeable... so stay tuned for further updates.

Sunday, 10 April 2011

Eurovision Preview

The great Eurovision handicap is almost upon us... here are my initial thoughts about each of the entries (in no particular order, except alphabetical):

Albania: 3/10, Hi, we're re-working elements of that Turkish winning entry... can't see this doing much other than being loud and bad.

Armenia: 3/10, Boom boom chaka, chaka... I'd like to say this should die a death, but this is Armenia so it'll make the final.

Austria: 4/10, Might squeeze through qualifying, but incoming huff in 5, 4, 3...

Azerbaijan: 5/10, Actually, nice little pop song, perhaps not the sort of thing that wins Eurovision, but they'll qualify with ease - but I'd like to see if their performance is anything like the video.

Belarus: 3/10, "I love Belarus", well, that probably has limited appeal, as a tourist information song it hits all the notes... but selling the uranium clad borders to the song loving public, that's a harder act.

Belgium: 0/10, this makes no sense on any level, and is just wrong. Won't qualify.

Bosnia & Herzegovina: 4/10, cutesy, comical, Bosnian... checks, beard (no Deen), guitar... I've no idea anymore with this stuff, probably top 10 for no readily apparent reason.

Bulgaria: 1/10, utterly bland.

Croatia: 5/10, well it's trying to be an early 00s dancey classic, but hitting a late 80s cheesy pop song... and well, you'll notice I haven't mentioned her nose yet. Oh.

Cyprus: 0/10, HIYA GREECE WE CAN HAZ 12 POINTEYS PLZ, TATHXS!

Denmark: 6/10, A Friend In London, errm, bit meh, bit no, bit yeah, bit nothing. Lead singer is quite cute though.

Estonia: 6/10, Has potential, works quite nicely, but seems to have fabrics from 1984.

Finland: 8/10, POLITICALLY CORRECT SONG AHOY! But it's a cute little song, no, nothing to do with him. Tom Dice will be proud.

France: 0/10, Bookies favourite apparently... I assume for the bottom of the table.

Georgia: 0/10, HI WE FOUND RAPPING... it's never worked in Eurovision before, it won't start now.

Germany: 7/10, I prefer this to last year's song... so it'll come last.

Greece: 0/10,"Watch my dance"... I'm failing to see any dancing.

Hungary: 10/10, Something left off the Ray of Light album, which I think is great... surely a potential winner?

Iceland: 0/10, Utter bollocks.

Ireland: 2/10, "you spend money like you're on death row", "are you heading for a car crash?" - nuff said.

Israel: 4/10, Dublin's best airport makes a return to the Grand Prix, with a big walloper.

Italy: 0/10, Italy pressed pause 14 years ago, and they just pressed play again. Terrible.

Lativa: 5/10, Pop song, tick, haircuts tick, performance tick, performers - ermmm... yeah should qualify.

Lithuania: 2/10, "pork on my fork" type rhyming.

Macedonia: -10/10, HI BYE.

Malta: 2/10, It's not a ballad, what did the Doctor do?

Moldova: 0/10, NO GRANNY NO POINTS!

Netherlands: 7/10, Bit of a U2 vibe to this, it's good, but will it stand out?

Norway: 8/10, Clap, clap, shake, shake, hey, hey, woo, woo. T&A margin, claps, easy song, and a good rhythm will help this entry. Should be top 10. And if it's a warm summer night across Europe... who knows?

Poland: 6/10, Funky, dancey, should do better than it will.

Portugal: -100/10, Easily my favourite song of the contest, Portugal return to their roots of sending mad rubbish nobody else will understand or vote for, this will struggle to score a single point. Fantastic!

Romania: 8/10, On the plus side, we see his sex & painful wee face in the same song... but I don't think this is going to be a first win for Romania.

Russia: 10/10, What I believe to the likely winner, and he's not so bad looking himself. Loud, memorable, easy to understand... a good performance and we'll be back to Moscow for 2012.

San Marino: 9/10, And another great song, would be great for such a small "country" to win, but in the meantime I'd really like them to qualify with this.

Serbia: 9/10, they've found the 60s, and a good sounding pop song with it... this should make top 5 easily.

Slovakia: 3/10, Twins, climbing all over a car, not sure this will translate to the stage.

Slovenia: 1/10, I think that Eurovision has moved on from these sorts of songs...

Spain: 2/10, Un Bloody Mary, por favor!

Sweden: 1/10, Justin Timberlake, rhyming impossible with possible, smashing glass, loud, pop song, he's not unattractive. Did anyone mention he can't sing?

Switzerland: 0/10, Bit of a copy of Lena from last year (which I hated), so this has to die a death, boo!

Turkey: 4/10, err no.

Ukraine: 5/10, not quite what we've come to expect from the Ukraine recently, which is a shame.

United Kingdom: 10/10, well, it's a Blue song... it's a decent pop song, I've not been here with the UK entry for a long time... top 5, come on guys!

Sunday, 30 May 2010

7, at once, and no scarring...

Woo Hoo it worked! 7 people voting at once, a few tidy-up requests for next year, but generally a thumbs-up. No issues, it passed off smoothly, technology working as it should.

Ok, well apart from those without iPhones - maybe I'll make them do semaphore next year.

Wednesday, 26 May 2010

Beavervision (Pt 1)

Right, part 1, for which there were plenty of opportunities for failure, seemed to pass off without a hitch.

2 people simultaneously using the iPhone scoreboard, with no issues - we were able to poke around our own results nicely, and it just worked, as it should. The manual entry for those without the technology also seemed ok, and no complaints of dropped scores (as there were last year).

Results popped up, twitter was fed and Facebook got the full force of the updates.

All-in-all, I'll give myself a B+ so far - part 2 should be easier, and part 3 will be the big technological test were we may have 5 or more people using the AP - sure it should all work, but I just worry about these things... I even have 2 backup plans, I'm nothing if not prepared.

The best comment I got was "it was a lot less stressful" regarding the iPhone site, it just flowed in naturally for me, and made the whole thing a lot better, letting me concentrate on having a fun time instead of queuing people up to use a PC. Win all round.

It's a pity the semi-final was so dull, it was hard to pick a bottom 7, let alone a top 10... and the voting outcome was, as usual, ridiculous - Russia should never, ever, have gotten through.

Thursday should be way better, and Saturday - well now I'm over the first hurdle, should be fun... that might be the first time in 7 years.

Thursday, 8 April 2010

Ready, Steady, Done?

I've sped through the Beavervision Scoreboard development rather quickly. All the core features are there now, and the addition of the iPhone interface should make the whole voting process significantly quicker this year - in the past we've had clipboards and pens and been very officious taking notes and scoring. This year we can all just sit there and stroke our precious... well those of us with iPhones - the Luddites will have to make do with the old method. So that means multiple input methods - yay, MVC to the rescue.

I've used (and abused) IUI to provide the iPhone interface, it sorts out quite a lot of the fiddly issues for you. I need to tart some bits up and fiddle with the routing around the site (currently everything goes back to the homepage), but on the whole it's mostly there...

Time for some gratuitous screenshots:











All very pretty. I'm a bit worried about drunken fat-fingers operating the Next buttons (the select list uses the default Apple UI "scroller"). The images on the page (background, logo, flags, artist image etc) are all fed from the same Controller Action as the main website - but are scaled and cached for the device (and in the case of the background is a completely different source). And fed from the database - I've put in 3 years worth of artists images (typically several hundred KB each) and all the flags, and the website images for this year and the database is around 14MB, so I'm not too worried about any performance overheads with that.

I've also setup a Windows Server 2008 VM with SQL Server 2008, and transferred the database & website from my local machine to it. Remarkably simple process in the end, and all seems to be up and running happily - I had a few transfer issues (mostly to do with project references), but they were easily resolved.

I've also imported all our Beavervision history into the new model, so all our historic scoring is available - which makes for some nice stats probing.

I think that's done then, short of tidying up a few little issues, I can't think of much else to do with hit.

So, it's clearly lacking features...

Saturday, 3 April 2010

Eurovision Preview

The great Eurovision handicap is almost upon us... here are my initial thoughts about each of the entries (in no particular order, except alphabetical):

Albania - Disco. Better now in English, and losing the Victoria Wood haircut (though there's nothing particularly wrong with that in context) - video is stupid, but I suspect the staging could make this very good... 9/10.

Armenia - Pop. Bit blah - songs about fruit and nationalism don't always go down well, video involves over-excitable fat-bloke. It will no doubt track the Armenia success story and make the top ten... 2/10.

Azerbaijan - Power Ballad/Pop. Probably one of the better entries. Azerbaijan seems keen to host a Eurovision event (after the Dance Contest was canned) and going all out this year with a very strong entry... could do with a little bit better staging, but will probably at the sharp end of the scoreboard... 9/10.

Belarus - Ballad. The child in the video will not be allowed on stage, talented lighting director that he is - no I jest - pianist. Seems to be want to be an anthem, but never quite gets there... bit six4one, might pick up some points... 5/10.

Belgium - Busking. Once you get past the ridiculous accent and lyrics, it's a pretty little song which does build. Not sure it'll be stand-out enough to do anything for Belgium, which is a shame - they'll deserve to do better with this... 7/10.

Bosnia & Herzegovina - Pop/Rock. What a very serious song from the Balkans that doesn't seem to go anywhere. Sure it'll probably meander through to the final thanks to the neighbours... 3/10.

Bulgaria - Pop. No stilts, no fun. 3/10.

Croatia - Pop Ballad. Every one's favourite suppository group enters for Croatia with a better sounding song than 2005, and they don't urge you to call them... although sung in Mr Jonathan Foreigner's language I couldn't be entirely sure that's true. Builds quite quickly and supports strong voices. I'll wait for the live performance before getting too excited... 6/10.

Cyprus - Pop. Singing about spring in May is starting to push it, even for Europe... a mistake some countries have made before. This is, given that, surprisingly good though, and may do well (12 points from Greece)... 6/10.

Denmark - Pop. The Police should probably sue. However this should be right up there with the rest of the Scandinavian crowd, even singing into the teeth of a fierce gale, and must be a very strong contender for the title. Might be held back by the "Andy Abraham" factor... I hope not. 9.5/10.

Estonia - Alternative. Quirky, I love it. Estonia are really bringing some interesting songs to the Eurovision recently... might not win but improves the field, which is commendable. 8/10.

Finland - Folk. This will not be in with the rest of the Scandinavian crowd. It seems too desperate to rip-off last years winner, but doesn't really understand what it's doing. 1/10.

France - Shit Pop/Dance. I'm not sure which drunk Frenchman picked this abomination, but the constant "whoop, hmm, whoop, whoop, whoop, hmm, whoop" being the face of the lyrics are laughable, even for the French language. Deserves the stage to collapse during the performance... -10/10.

Georgia - Ballad. So they want to hold it in Moscow next year? Pretty little song, not sure it's the best of the ballads though... 4/10.

Germany - Unsure. Wahey, we've found the bottom of the final scoreboard. She's doing her hair, and underwear for us... but she won't go any further. Nor will the scores. 0/10.

Greece - Ringtone. Ugh, really, ugh. 1/10.

Iceland - Pop. According to Iceland this is sung in French! It's an interesting performance, but I'm not sure I'd want to see her special "something"... good pop song though, should be up with there with the Scandi crowd... 8/10.

Ireland - Ballad. I do love Ireland, they have many of my all-time Eurovision favourites - and this is no exception, Niamh is a safe pair of hands and a voice to match the soaring lyrics. I'm a sucker for this stuff, but I really hope this goes top five... 9.5/10.

Israel - Ballad. Unusual, but not unlikeable - I need to see the final performance as much can be changed, but it sounds pretty good and heartfelt... 8/10.

Latvia - Pop. Very simple, very crap too... 1/10.

Lithuania - Pop. Kazoo in the Eurovision? No. 1/10.

FYR Macedonia - Who Knows? Macedonia can occasionally be right "out there" - and once again achieves it in 2010. The song isn't unpleasant until the rapping, neither is the singing or presentation - but you're left scratching your head. Not entirely sure this will do well... 2/10.

Malta - Pop Ballad. Blah even by Malta's standard. Can't see this making the final, 4/10.

Moldova - Pop/Dance. A million times better than the French entry - could do well, very hard to tell when you get a very different style of Eurovision song. Based on Iceland 2008 this should be top 15. 7/10.

Netherlands - Toilet Break. If the Netherlands ever wanted to demonstrate they had stepped out of the 1970s, or dropped the Smurfs as their strongest musical influence - then they might have misread the script. This is the utter pits and thoroughly deserves 0 points. 0/10.

Norway - Ballad. A winner with the potential of a double? It's possible, strong ballad, and a good singer. Will need to nail the performance in the final, and should it win - well ner-ner-de-ner-ner to all those idiots (aka Chris) who voted for Scooch, as this is a complete rip-off of Cyndi... 9.5/10.

Poland - Folk/Pop. Oh dear, oh dear, oh dear. 4/10.

Portugal - Portugal. I admire Portugal - they have sent the by far the most bonkers entries in the last 30 years, always seemingly at least sixty-steps away from the rest of European "culture", but not afraid to do their own thing - and for the last couple of years it has produced good results - but this is just bland by their own standards. Where are the rocket launchers? Exploding pianos? Marauding Vikings? Dancing Hitlers? Its just a song... 5/10.

Romania - Pop. Stepping back towards the "banging" Romania entries of the early/mid 00s with a bit more generic pop song, interesting. Beyond the novelty of the silly pianos, can't see this hitting the final. 4/10.

Russia - Football chant. Underlining the expense of hosting the 2009 contest is this entry... 0/10.

Serbia - Hairdressing. Underlining the expense of hosting the 2008 contest is this entry... 0/10.

Slovakia - Ethno-Pop. Interesting entry from Slovakia - could well climb the rankings and be a surprise... 6/10.

Slovenia - Hard to pin down. Most countries stopped sending songs like this in 1997... 0/10.

Spain - Pop. I really don't get this, many people I speak to seem to think it's the winner - perhaps it's a bit too French for me... 3/10.

Sweden - Pop Ballad. Certainly one of the top of the ballad contenders, and will be up their with the Scandi crowd. Might be top 5, I'd certainly hope it is. Lyrics are actually good, song is powerful, singing is good... was by the far best entry in Melodifestivalen. I'll chance my arm by my occasional "sit up and listen" moments, which I did straight away with Serbia in 2007 - and say the same of this... good contender for the win... 10/10.

Switzerland - Pop. I also love Switzerland; Paolo Meneguzzi performed a fantastic song (sadly let down by a poor performance). But this just doesn't seem quite as complete, more pop - sure, just not quite my thing... 6/10.

Turkey - Pop. I'm half convinced Turkey could turn up and take a shit on the stage, and guarantee 12 points from Germany and the United Kingdom... and this year we seem to be edging towards completing my convictions.... 1/10.

Ukraine - Whiny Rubbish. Third time "lucky" for the Ukraine. No, that's right, it took them just three attempts to come up with this! They'd have been better off staying at home and shooting pigeons... 0/10.

United Kingdom - Err. Ok - disclosure time, I know a few people involved in the UK effort, and they have done a good job themselves... so lets start with the good points, he can sing live, and he is quite good looking. Ermm, and that's where it sadly ends in my opinion. I wish Josh well, but I'd be surprised if this hit the top ten... 3/10.

Saturday, 27 March 2010

Images, BLOBs and other general database madness...

I've been playing around with storing image/media data in the database for the Beavervision Scoreboard - partly so I could just ship a whole database backup around without having to remember a whole heap of additional content files, and partly to test out BLOB handling through ADO.NET Entity Frameworks.

Firstly, file upload and reading/writing to the database. A doddle, read the incoming file into a byte array and stick it into the db object e.g:

HttpPostedFileBase v_HPFB = (HttpPostedFileBase)Request.Files[v_File];

if (v_HPFB.ContentLength != 0)
{
tbl_Media v_Media = new tbl_Media();
byte[] v_Buffer = new byte[v_HPFB.ContentLength];
v_HPFB.InputStream.Read(v_Buffer, 0, v_HPFB.ContentLength);
v_Media.value = v_Buffer;
}

Obviously for larger files you might want to stream rather than reading all into memory.

And then equally reading out from the column is also a doddle as its exposed as the byte array - obviously take care including the table holding the BLOB as you don't really want it to come back every time you do a simple query. I created a separate media table (cunningly called tbl_Media (which has just an identity column and a value image column - as above), and then have link tables for each area of the system that can have media, and only go to the BLOB on actual request for it.

So then we need to get this image out and use it somehow. I cracked out MVC and found the FileContentResult and FileStreamResult which you can attach to an action to essentially return non-HTML-view data. Thus to fetch an item out of the media table by ID I created a generic action, e.g

public FileContentResult Get(int id)
{
BeavervisionEntities v_Ent = new BeavervisionEntities();
tbl_Media v_Media = (from m in v_Ent.tbl_Media.Include("tbl_MediaType") where m.id == id select m).First();
return File(v_Media.value, v_Media.tbl_MediaType.type);
}

The Media Type table being the associated mime-type of the media stored in a normalised fashion.

Of course, once you wander into processing the BLOB, rather that just serving it up from a static location, you can start to muck around with it mid-stream...

So (hang on to your hats now), I know that I have a list of countries taking part, they all have their own flags, and I want to put them on different parts of the site in different sizes (e.g. a small one for a list, a mid-size one for view)... so I'll create a number of facade actions in the controller to neatly wrap a more complex action, and just upload and store a high-quality large transparent PNG (which I use as the source for all my images anyway), I then knocked-up a quick static html page to call these
, and the output looks like:
  • A is the original image as from the /Media/Get/1 source.
  • B is the same image, unprocessed from /Media/Flag/Albania - querying through to find the relevant country name and pulling the associated flag image back.
  • C is through the /Media/SmallFlag/Albania facade action to provide a 50x28 PNG.
  • D is through the /Media/GetFlag/Albania?height=84&width=150 action, which outputs an 150x84 PNG (the facade in C is actually passing through to this action).
  • E are two re-encoded images (JPEG & GIF respectively) used by appending &format=image/jpeg (or image/gif) to the GetFlag action.
All very nice and pretty (and pretty ugly too), and quick for me using the site on my own - but what can we do to try and reduce server & database overhead? How about some output caching? Well MVC nicely supports this with OutputCache attribute, so before the Flag & SmallFlag actions I told it to cache (for 2 weeks) with:

[OutputCache(Duration = 1209600, NoStore = false, Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "id")]

Now to test this, I decided to upload a flag for a different country - but wouldn't you know it, me being the dunce who wants to test caching I deliberately uploaded the wrong image and bring up the static page designed to query it (i.e. changing Albania to Andorra), duh me. OK, so then I bin that from the database and upload the correct image - then let's see what came out for that:

So, using the same lettering from above I told the actions called in B & C to cache with the wrong image, and lo it doth return the cached image, whereas A, D & E haven't been told to cache and do return the correct image.

Neat.

Now I can abuse this to within an inch of its life.