My Twitter Flickr Mashup

I attended full frontal last week, which was excellent. It gave me inspiration to experiment a bit with some JavaScript.

I went about setting myself a very loose brief; Completely written in JS, I wanted to do something quick, in no more than seven hours, I didn’t want to have to write any server-side code and wanted the code to reside on a single page.

I went about looking into the Twitter and Flickr APIs and decided to combine them by doing a photo search on Flickr using tweets from the Twitter public timeline every 60 seconds.

What I came up with ended up as a kind of visual social commentary using Twitter and Flickr.

flittr

visual social commentary

I can’t claim any credit for any of the content and I doubt that the idea is unique or original but  I did set out some rules for getting the content : search terms had to exceed two words and I attempted to recognise proper nouns and only use them. The content updated every minute. The tweets must not be recognised replies.

The result gave some interesting effects on me as a viewer. The search result images weren’t always obvious results from the tweets, hey – people tag their photos with strange tags. So knowing that I only had 60 seconds to look through the tweets (not always in English) it made trying to figure out the relationship of the narrative with the  corresponding photos more important, somehow and it became more important to look at the photos and see where the connections came from when I got frustrated.

I also liked the fact that very few users would see the same page with the same tweets and images. This makes me want to expand on the idea and add the option to ’save your favourite fleet’ (a fleet is what I called the combination of tweet a Flickr images, brilliant hey!)
I thought about adding the option to enter a twitter screen name and allow that to work in the same way on a specific timeline.

To support Lotus F1 Racing or not?

My first memory of Lotus of any kind has to be the 1986 JPS team. I’d certainly watched races previously, my Dad is a fan of Lotus so I couldn’t avoid it, thankfully. This is where, as for most kids, a fanatical interest in any sport or team comes from.

I remember the season specifically because Johnny Dumfries was driving for them. He only drove for them for a year, the year in which he partnered a certain Ayrton Senna. Senna was a driver who I spent years supporting, even after he’d left Lotus, over and above the British driver Nigel Mansell (who’d left the team earlier). This didn’t go down well at school and it was hard enough liking Fomula One rather than football.

I supported Team Lotus fanatically until 1994, when they left the F1 grid. I camped in the rain at several GPs with my Dad, visited Brands Hatch to watch Johnny Herbert race around in a single Formula One car. I visited the Lotus factory and the old Team Lotus garage which still contained many of the parts of old F1 cars. I spoke to David Hunt briefly about his efforts to bring Team Lotus back to the grid and I  bought a Lotus (M100) Elan and couldn’t bare to sell it.I still feel an affinity to the road cars and anything that Group Lotus does. I think that the work that Classic Team Lotus does is excellent and Clive Chapman is a credit to his dad, Colin Chapman.

I’m not old enough to have watched the great racing Team Lotus triumphs  as they occurred, unfortunately. The closest I came was watching Ayrton Senna win, which I believe was more of a credit to his driving ability than that of the quality of Team Lotus cars at the time. I have however seen days of video footage and purchased plenty of books. I feel like I watched Jim Clarke, Mario Andretti, Emerson Fittipaldi et al , the Lotus 25, 72 and may others numbers below 100 that were amazing for many different reasons.

It was with great anticipation / trepidation then, that I read about Lotus’ return to F1 in 2010, initially as a Lightspeed re-brand.  At least two members of the old team would be part of it, I thought. I think (and its not been mentioned much) that there was some kind of time limit on ownership of the rights to the Team Lotus name that could be legally challenged this year and I suspect that this has something to do with this happening.
So when the initial bid failed and the new Malaysian effort raised its head I had mixed emotions. It was covered in confusion I felt : ‘a Malaysian team needing a name to boost publicity’ maybe.

I’ve had a few weeks to reflect and I’ve seen the things that have gone on since Lotus F1 racing were allowed the 13th (yes thirteenth) spot on the grid. I’ve seen Group Lotus put their name behind the team, even if that is only by not distancing themselves too heavily. Then I heard the Group announce interest in many other forms of racing; potential sports car racing, rallying and Indy car. They’ve appointed Danny Bahar as their CEO, a former Ferrari Racing Director I believe.

I realise that I supported a team that wasn’t run by Colin Chapman, for eight years. I supported them simply because of what Colin Chapman had achieved previously and how that was introduced to me.
Drivers who drove for Lotus drove for them to be part of something that was once great and would hopefully be great again. Their mechanics must have felt the same and I remember, even in the years when Lotus struggled to qualify for grand prixs, more Lotus fans than any other constructor, Ferrari aside, supporting their team.

So I’ve been considering how I feel and haven’t been able to reason why I should throw my support behind what is essentially a new team, like I used to. That was until, Toyota left F1 this week, Renault considered leaving and Ferrari started throwing their toys out of the pram.

When other manufacturers are leaving F1, Lotus are returning and without having to invest any money, by the look of things. They are also doing so with tenuous connections between the (Lotus) Group and the F1 team, if it all goes wrong it should be easy  to distance themselves and the F1 team rebrand like many before. This could be a genius move and I suspect that Danny Bahar is well aware of this, as is Tony Fernandes.

This is a new Lotus racing team. Not Team Lotus, that team hasn’t really raced in F1 since the eighties, maybe even since 1982.
This is a team which has allegedly ‘pinched a design’ from Force India. A team that has not been shy of mentioning its intent to move to a purpose built factory in Sepang in two years and has most of its funding coming from Malaysia.

Surely then this is nothing like the Lotus of old? Nothing, like the team that moved from North London to a purpose built factory in Cheshunt before moving to a better facility in Hethel, Norfolk. Nothing like the team that introduced sponsorship to F1 in a big way and got investment for racing from it, from all corners of the earth. Certainly not like the team that was driven by winning and even ‘borrowing ideas’ and whose cars caused more controversy than most in F1 (Lotus 88 anyone?)

Colin Chapman had a huge, maybe unique ability. I don’t think that there has been anything close since, aside from maybe Gordan Murray. I don’t think we’ll see anything like him again.
This doesn’t mean that there can’t be another team like Team Lotus. Chapman’s ideals and passion still hold as much weight as they ever did. If this team has the same principles, ideals and commitment they could potentially be more of a Lotus F1 racing team than has been seen for 28 years. I hope Tony Fernandes and Mike Gasgoyne and anyone involved remember this, as I and hopefully many others support Lotus, with pride,  again this coming Formula One season.
Good luck guys and thank you.

As I remember it, ‘if you’re not winning, you’re not trying’.

windows 7, Firefox and slow google reader and google mail

I recently upgraded to windows 7 64bit (RTM) from Vista 64bit. It all went suprisingly well and after only a couple of weeks I’ve not had any issues to speak of except an annoying browser issue which I only really nocticed when using Google Reader and Google Mail.

When tryign ot user Google Reader, I notices a huge performance decrease when looking through a feed.
In Google mail I noticed a decrease in performance and then sometimes unresponsiveness, or what looke like a lost connection.

I assumed that this would be the new virus softwarer I had installed (AVG, which seems very good by the way) because it was the only new software I’d installed other than Windows 7, because Onecare no longer worked.

After some searching around I found that the problem lies with the Skype add on I have installed. DOnt ask me why, but disabling it sorted everything! I hope this helps someone else!

http://support.mozilla.com/tiki-view_forum_thread.php?forumId=1&comments_parentId=429871

The government has selected Martha Lane Fox as its ‘digital champion’ …

Just a quick one!

The government has selected Martha Lane Fox as its ‘digital champion’ according to the bbc website. I only know a little about Ms Lane Fox, mostly from the original legend of lastminute.com, but from what I’ve read it’s difficult to disagree with her intent (and the govenrment’s).

Upgrading to Windows 7 Ultimate

I’ve just installed windows 7 Ultimate, upgrading from Windows Vista Ultimate …

This is a rough timeline of my installation …

19:30 – tried first install
19:45 – removed onecare

19:53 – restarted, tried second install
19:54 – files copying
19:57 – files copied
19:57 – gathering files…(38434 files) started
20:13 – gathering files…(982638 files) still going
20:28 – still gathering files etc (982638) …
20:33 – gatheirng complete
20:33 – Expanding windows files
20:34 – Vista shuts down (1st restart)
20:36 – Windows 7 starting for fist time (Starting windows Message)
20:36 – Upgrading Windows screen, [continuing upgrade]
20:40 – Expanding files (18%)…
(gathering additional information before expanding files / please wait)
… hmmm five minutes, no progress, hdu light happily flashing away though …
21:00 – expanding files 34% complete …
21:07 – 2nd restart
21:09 – setup updating registry settings
21:10 – starting services
21:10 – transferring files etc…
21:13 – video card screen refresh
21:20 – transferring files etc … (1021072 42%)
21:37 – transferring files etc … (1021072 58%)
21:44 – transferring files etc … (1021072 61%)
22:00 – transferring files etc … (1021072 62%)
22:04 – 3rd restart
22:07 – transferring files etc … (63%)
22:09 – transferring files etc … (1021072 72%)
22:11 – transferring files etc … (1021072 72%) couple of DOS prompts flash up
22:19 – transferring files etc … (1021072 85%) Removing temporary install files
22:21 – ‘Setup is preparing your computer for first use’
22:21 – ’setup is checking video performance’
22:22 – product key entered
22:23 – windows activated
22:23 – network, region and time setup complete
22:24 – finalizing settings
22:24 – logon window
22:25 – preparing desktop

So, I’ve been playing with it for around an hour now, everything seems to work (except OneCare).  So far this is the most impressive visual enhancement of any Windows upgrade I’ve seen since Windows 95. It Will be interesting to see what Snow Leopard has in store later this week.

Javascript League Tables

Having seen a lot of league tables on various websites I was suprised to not see the implementations use the UI more effectively. Most of the implementations required the user to click on seperate links to view the current table, results or fixtures.

I was interested to see if I could provide an easier way of navigating between these sets of information, whilst providing a generic API to support different sports, using Javascript only, fed by JSON serialised data.

I naturally chose soccer (football!) as the base of my test data and used the current English Premier League teams to build a demonstration table.

This is what I’ve come up with so far: Javascript League Table and Fixtures

What I’ve done so far is delieverd completely in Javascript and is a bit verbose! If anyone is interested in getting me to develop it further for their website then let me know!

Private, priviledged and public class members in Javascript

I’ve just started reading proffesional Javascript Design Patterns. Whilst I understand the principles and the concepts, changing the way I write Javascript is proving to be a little more difficult. I’ve been writing Javascript for a long while and getting out of bad habits is tricky!

One of the first things I kept forgetting, was how to declare private / public and priviledged members.  So  I wrote this quick ‘reminder  stub’ to help me remember.

//constructor
function SomeClass()
{
 //private member -->
 var privateMember;

 //private method -->
 function privateMethod(){
 return 'private method';
 };

 //priviledged method
 this.priviledgedMethod = function(){
 return 'priviledged method, not a '+ privateMethod();
 };
}

//Implementation / public members -->
SomeClass.prototype = {
 //public field -->
 publicField : null,

 //public method -->
 publicMethod : function(){
 return 'public method';
 }

}

// examples -->
var someObject = new SomeClass();

someObject.priviledgedMethod();
someObject.publicField;
someObject.publicMethod();

jquery-1.2.6-vsdoc.js and focus()

I’ve just spent the last twenty minutes trying to resolve a problem where jQuery wouldn’t focus on a form element when trying:

$('#formElementId').focus();

I reverted to doing:

document.getElementById('formElementId').focus();

to see if there was something else causing the problem in my code and it worked straight away.

I didnt have any other javascript in my code so I was a little perplexed at first. I did the usual Google search and Stack Overflow returned no results.

So I thought I’d try and replace the version of jQuery library I was using, which comes with the ASP.Net MVC site template I was using and has Visual Studio documentation, with one from the Google AJAX hosting library.

Sure enough, it fixed the problem straight away!

It looks like there is a bug in the VS documented jQuery library that ships with the MVC templates that stops the $(xyz).focus() from firing.

Auto Tabbing, Single Character Password Box using jQuery

I’m sure a few of you have had to write some Javascript to represent a single character password box before, as I have. I hope that you were sensible enough to keep the code unlike myself!

I found myself in this situation this afternoon and kicked myself for not keeping it last time.

Doing this with jQuery is straightforward.
There were two issues however,  one that I (believe I) have resolved and one that I haven’t (yet)!

The first was using ’shift+Tab’ to tab back to the previous box. On release the ke up event was fired and focus sent back to the next box. So I added the check for the event.keyCode.

The second issue was within the keyup function I had to do the following:

var nextElId = elmB.attr('id');
document.getElementById(nextElId).focus();

rather than:
elmB.focus();

Can anyone tell me why please!

Here’s the usage:

$(‘#uxTxtNum1‘).PasswordCharacter(‘uxTxtNum2‘);

where:

#uxTxtNum1 : is the jQuery selector of the text field/ password field that is to be used as a single character password field.

uxTxtNum2 :  is  the html Id of the element that is to gain focus after a character is entered in the textbox.

Here’s the code:


function MakeSingleCharSelection(elmId, nextElmId) {
	//-- setup the textboxes that are to be used
	var elmA, elmB;
	elmA = $('#' + elmId);
	elmB = $('#' + nextElmId);

	if (elmA == null || elmA == undefined) throw 'Element with ID : ' + elmId + ' was not found';
	if (!(elmA.attr('type') == 'text' || elmA.attr('type') == 'password')) throw 'Element with ID : ' + elmId + ' is not a textbox';

	if (elmB == null || elmB == undefined) throw 'Element with ID : ' + nextElmId + ' was not found';

	//--
	elmA.attr('maxlength', '1');

	elmA.keyup(function(event) {
		var currentElm = this;

		// check that we haven't tabbed here
		if (event.keyCode == 9 || event.keyCode == 16)
			return;

		// make sure that there is a value in the textbox before forwarding to the next one
		if (currentElm.value.length > 0) {
			var nextElId = elmB.attr('id');
			document.getElementById(nextElId).focus();
		}

	});
}

jQuery.fn.extend({
	PasswordCharacter: function(nextElm) {
		return this.each(function(){MakeSingleCharSelection(this.id, nextElm)})
	}
});

Please give me a mention, where possible, if you use it.

Lewis Barclay

Asp.Net MVC and mocking frameworks

On the current MVC application I’m working on I’m writing quite a few unit tests. I’ve not built a fully fledged MVC app before and watched quite a few videos on how to approach building an MVC application.

I’ve written unit tests before, ‘played’ with Rhino Mocks and read about other unit testing frameworks, so when it came to writing unit tests for the MVC app I’m working on it seemed like an obvious choice to use a mocking framework to assist in mocking the ‘web objects’ that are part of an ASP.Net environment, namely the HttpContext and its attribute objects. … ERROR!

I was using Scott Hanselmanns MVC Mock Helper which would have helped a lot if I could grasp the mocking framework properly!

I felt like I was going round and around in circles trying to get my tests working with a mocking framework. I wasn’t sure if I was approaching it wrong or if my production code was designed incorrectly, but every time I wanted to use a dependent object in my MVC app I ran into one problem or another.

In the end I opted to build my own fake classes and implement the properties and methods as I required them. This worked out to be quite straightforward and I’d recommend this to anyone else  attempting to unit test MVC controllers. That’s not to say that Mock frameworks aren’t useful, I just found it easier not to use them in this case.

I’ve since downloaded Oxite and have seen that this is the same approach that was taken when it was developed.

I’d be interested to hear if anyone else has had similar problems and how what they did to resolve them and if they stuck with a mocking framework or chose, like I did, to revert to a more manual approach.