Thursday, May 31, 2007

31/05/2007 - Thursday

There has only been one Lynx Axe commercial that I've laughed at. It's the one where the guys dad goes into the bathroom, sees the spray can, decides to give it a try, walks out the bathroom, then the guys girlfriend/fiance/wife/whatever sniffs then air, says the "bow chicka wow wow" line, shimmies over to the dad, and rips off his shirt. With this commercial you know what it is about, but with all the other ones I've seen you just have the girl saying the line to the guy and then some moronic dancing thing, and you've no clue why she was doing it in the first place (well, you obviously know it's for Lynx Axe now, but you wouldn't know it seeing it for the first time!). All the other adverts have just been plain retarded.

Now someone has done a "music video" of it. I present it here for everyone to laugh at and then think how low the world has become.

Wednesday, May 30, 2007

30/05/2007 - Wednesday

Zooomr has been on the road to launching their new Mark III version. It has been a very rocky road with a previous attempt failing and the second attempt taking longer than expected. The road looked straight towards the end with Mark III being launched and things working fine. For around 15 minutes that is. Then they suffered a server crash which took out the database. Luckily they had very recent backups and the photos are all intact, but without the database there's no way of actually having a working website.

Earlier today they posted a blog post saying that they were working on getting a new server to replace the failed one so that things could get back online. There are many apologies in the blog post yet I feel that none are needed. I know myself how hard it can be to get a complex website out on time, especially if there is only one guy doing the coding. I've also watched Kris and Thomas while they've been working and I know how passionate the guys are about getting everything sorted out and working.

Good luck to both of them, they've got a lot of support from their users, and also support from Sun Microsystems, so hopefully they can get it all sorted soon and then they can relax and unwind a little!

Tuesday, May 29, 2007

29/05/2007 - Tuesday

There was a report on the news on Sunday about the government wanting to give more power to the police so that they can stop and ask the details of people that they feel are suspicious on the account of terrorism laws. This caused some outrage among the members of parliament and some ethnic communities citing that the new laws would alienate said ethnic communities. The way I see it, if a community feels that the laws would alienate them then they obviously know that it is their community that causes most of the terrorism in the world. I have nothing to hide and would never feel alienated if the police stopped me and asked me what I was doing and where I was going. I would actually be happy that the police are doing their job.

Thursday, May 24, 2007

24/05/2007 - Thursday

Zooomr is gearing up for the launch of Mark III. It has been a long time coming with problems on the first attempt at launching it, and the site is currently offline while Kristopher finishes it off. It's supposed to be launched later today, so good luck to Kris in getting it done!

I also noticed today that Gmail have increased the attachment size limit from 10 MB to 20 MB. I've only ever needed to attach a file larger than 10 MB once and obviously I had to upload it somewhere else which wasn't really a problem. It's still nice knowing that I can do it in the future now!

Monday, May 21, 2007

21/05/2007 - Monday

I was just watching the news report about the Cutty Sark burning. The was quite a blaze and the pictures of the shell after make it look a real sorry sight to see. At least the sails and other parts were removed due to the renovation that has recently started.

There is a video of the BBC news report on YouTube, but I don't know how long it will be up due to it being a copyrighted broadcast. I'll look later for an official video from the BBC to use instead.

20/05/2007 - Sunday

I finally got rid of the bug I've been working on for the last couple of days. I got rid of it by changing the code to work around it as I just couldn't track down what was causing it to go wrong. I would identify an area of the code that I thought was the problem, debug it for a while, attempt to fix it, only to find that there's now a bug in another area, or the bug just changes location. This frustrated me for several days before I came up with a good idea which semi-worked, but didn't, for some reason that I'm still not sure of. I was storing a true/false value which defaults to false when I create an object, but for some reason the value was changing to true all by itself (I wasn't changing it to true myself anywhere in the code), which caused the rest of the code to fail as the value needs to be false at some point before it can become true.

This did take me to the solution that I came up with though, so it wasn't a full wasted six days of confusing work. I can now move on to the rest of the program as I hadn't even got that sorted (I needed this other bit first before I can really do the rest). Hopefully I haven't forgotten where I was going with this!

Friday, May 18, 2007

18/05/2007 - Friday

Haven't really done anything majorly new recently. I started on something new but it has bugs in it already (something that I've used before in the past and worked fine then but doesn't want to work properly now for some reason) and I've spent the last couple of days trying to work out exactly what is going wrong. I managed to fix one bug only for another bug to appear in a different area. I'm finding it hard to debug properly as the debugging causes the problem code to be run more times than usual, as the code is to do with drawing text and the debugging interrupts this drawing and when I resume running it causes the text to be redrawn again and the loop continues. This resulted in lots of rubbish data as the bug wasn't happening at the beginning of something, it happened after more text was drawn, but the debugging didn't let it get past the first bit of text.

I think I know what has to be changed now though. I got annoyed with it late last night so I gave up until today. Hopefully I will be able to fix the bug and get on with the rest of it as I'm doing this program to allow me to do my website work more easily (it's a very basic code editor as all the others I've tried are just too bulky for me).

Saturday, May 12, 2007

12/05/2007 - Saturday

So Eurovision 2008 will be held in Serbia. Congrats to them even if they did win because of the block voting. Unsurprisingly the United Kingdom finished nearly last, although I was actually expecting us to get 0 points. That's what you get for having most of Europe hating us :)

Friday, May 11, 2007

10/05/2007 - Thursday

Commiserations to Switzerland who failed to make it into the final of this years Eurovision, even though they had a great song. The songs that did make it were good songs, but there were a few better ones that failed to make it too. The one country that I was happy for getting through was Moldova who have a great song as well.

I ended up watching the semi-final online so that I could record Holby City on one of the other computers in my room. To watch the online video stream I had to install a plugin which connected to the actual video stream. I then had to open Windows Media Player which connected to the plugin to play the video. The only thing wrong with it is that it was buffering too much and also skipping chunks of the video. I tried closing WMP and using VLC to do it, but that couldn't connect to the server (the plugin). In the end I had to open WMP, connect to the server, open VLC, connect to the server (which actually connected and displayed the video stream), then hit stop in WMP but leave it open. I was then able to watch it fine in VLC without any buffering or skips. Yay for VLC!

Wednesday, May 09, 2007

08/05/2007 - Tuesday

For some reason the BBC decided to move Holby City to Thursdays so that they could put the new Holby Blue on in its place on Tuesdays instead. For me this is one stupid decision by the BBC as they obviously had the Thursday slot free so they should have just put Holby Blue on then instead of disrupting the Holby City schedule (it has been on Tuesdays since it started I think). That and the fact that I watched the beginning of Holby Blue last night and was totally disappointed by it. It didn't do anything to grip me to it and it also had the feel that me as a viewer was viewing what was going on from outside, instead of actually being there like with Holby City and Casualty (and even The Bill from the few times that I've watched some of it). This resulted in me changing the channel less than half way from Holby Blue so I doubt I will ever watch that again.

Good news now. Deadliest Catch has returned! The Discovery Channel usually has the show on every day at 1pm so I've been watching it while having lunch (watching the repeats too as it's a good show and I always miss something), but now the new season has started at 9pm. Luckily this doesn't clash with anything else that I watch in the evenings so I was able to watch it. The new season looks to be a lot more intense with one boat already sinking before the season really gets started. It also followed more with the US Coast Guard as they were searching for Survivors (they found one). Previous seasons have only hinted at the US Coast Guard's involvement by just mentioning them and showing the helicopters on land, but not actually showing them in action (other than one helicopter checking out the ice). I think this is good as obviously the trawlers and the coast guards have their work mixed together with the Bearing Sea being as deadly and unforgiving as it is.

Sunday, May 06, 2007

06/05/07 - Saturday

I wrote yesterday that I was trying to simulate the OpenID website talking in my integration tests. This evening I sat down and attempted to do it better as I wasn't happy with the tests still doing some OpenID related work. I'm pleased to say that I actually got it working. I had tried this approach before but it didn't actually work, but that was because I was doing it in the wrong place. I stuck this in my test_helper.rb file:

require 'session_controller'

class SessionController
def create
redirect_to home_path
end

def complete
@user = User.get($mockuser.openid_url)

if @user.nil?
@user = User.new(:email => $mockuser.email,
:nickname => $mockuser.nickname,
:gender => $mockuser.gender)
@user.openid_url = $mockuser.openid_url
@user.save
session[:return_to] = edit_user_path
end

@user.last_login = Time.now
@user.save

session[:user_id] = @user.id

redirect_back_or_default(dashboard_path)
end
end

What this does is reopens the SessionController class (the controller that handles the login) and overrides the two methods create and complete so that they run different code to the original methods in the SessionController class.

The create method just performs a redirect as the OpenID code would redirect the user to the OpenID website at this point. The complete method is a bit more complicated as it first checks if the user exists, if not then it creates a new user object, saves it, then stores the users profile page, after that it updates the last login time, saves the user to update it, stores the users id, and finally performs the redirect.

To glue all this together I just have to set $mockuser from within my actual test. For example
def login
$mockuser = user
get 'login'
assert_response :success

post 'session', :openid_url => user.openid_url
assert_response :redirect

get 'session/complete'
assert_response :redirect
assert_redirected_to dashboard_path
assert_equal user.id, session[:user_id]
end

which logs in an existing user (I have a different method for logging in a new user as I haven't attempted to combine the methods yet - although I just thought of a good way of doing it!).

This makes all the tests pass plus it doesn't involve any OpenID related code. You might say "well, your tests always assume that the user can login! you don't test for invalid users trying to login". My reply to that is that the OpenID website handles all the checking to see if you are who you say you are. If you are you then the OpenID website redirects back to my website telling me this. If you are not who you say you are then the OpenID website redirects back to my website and tells me that also. Users are only logged in (and created if they're a new user) if the OpenID website tells me that you're real. If it says otherwise then you're redirected back to the login page which displays an appropiate message. I trust that the OpenID code works fine in that regard and that it would never lie about a user being real when they're not, so that's why I'm not too bothered about it.

Friday, May 04, 2007

04/05/2007 - Friday

I've been working on tests for the first bit that I've done for the Healtheriser. I know I should have done them first but I had never really got into the swing of it. Over the last week I've been reading a book that does a website using the TDD (Test Driven Development) technique and it allowed me to start to get my head around it. I'm also now starting to understand integration tests, which is like simulating a user doing various actions on the website one after the other (like logging in, viewing a page, adding something, editing it, viewing it, deleting it, adding something else, then logging out), which is different from the other tests that only tested each individual part and not how they fitted together.

I ran into one problem with writing the integration tests though. I'm using OpenID for logging in and that involves another website to authenticate you are who you claim you are. This doesn't really work well with integration tests as they're not running as a real website so the OpenID website can't contact back saying who I actually am. In my other tests I could easily fake that I was logged in as I have access to the session variable where I can store the user, but in the integration tests I don't have write access to that variable, I can only read it, so that way would fail.

I did a quick google search and could only find one solution. It requires mocking a few of the OpenID library methods to return what I want them to return instead of it contacting the real OpenID website. It still does do a bit of OpenID work as I've no idea how to mock the begin method of the OpenID checker, which attempts to find out what it should do with the given openid url. I think that's the only activity it does and it doesn't actually contact the OpenID website for the openid url, but I'm not entirely sure. I'll see if I can edit it later so that it doesn't do any checking at all.

Anyway, he's the code that I used to mock out most of the OpenID stuff. I have it in a seperate method in my testing DSL as I use it in two different places (not just a single login method). It expects to be passed a model object which contains at least a variable called openid_url. It also does some of the optional OpenID values, but that can be deleted out if you don't need them. You can also easily change the name of the openid url variable, it's only used on the last line of the method.

def stub_user(user)
OpenID::Consumer.any_instance.stubs(:complete).returns(
OpenID::SuccessResponse.new(1, {}))
OpenID::SuccessResponse.any_instance.stubs(:status).returns(
OpenID::SUCCESS)
OpenID::SuccessResponse.any_instance.stubs(
:extension_response).returns(HashWithIndifferentAccess.new(
:nickname => user.nickname, :email => user.email,
:gender => user.gender))
OpenID::SuccessResponse.any_instance.stubs(
:identity_url).returns(user.openid_url)
end

Just call the stub_user method before doing a get request to the login page, then the post request to complete the login.