mattwhite

They’re Red Hot

There comes a time in every band’s life when they have to step up to the plate and play the ultimate gig. Last night it fell to the Red Hot Chili Peppers, they were playing Portman Road the home of the greatest team in the world, Ipswich Town!

A group of us went along to the gig in some of the best weather of the year so far. The setup couldn;t have been better, a short walk from my house to the ground, a few beers and some “interesting” support acts. First one were !!! (pronounced chk-chk-chk), who were, being honest not great. The most entertainment came from the audience at the front trying to hit the band members with empty plastic cups and bottles. A few good shots maybe explains the very short set, only 20 minutes. Based on that I don’t think anyone will be rushing out to buy the album.

Next up were the Dirty Pretty Things, made up mainly of ex-Libertines members with a grudge against Pete Doherty. They’re a new band even though the members are all famous from previous ventures. A couple of decent songs, give them a year or two to build up a decent play list and they’ll be pretty good but in the end everyone was there to see the Chilis, not the support acts.

From the moment they came on stage to the moment they left, 2 hours later, they put in such a huge amount of energy that I’m surprised they can keep this up for a full tour. Flea was jumping round in a skintight bodysuit like a madman, the other guys were giving equally as much to the performance. There are some bands which just do live performance as well if not better than studio performance, these guys fall into that category. Even the obligatory “Hello Ipswich” bit was done well with humour. The set itself was a really good mixture of the new album (it is the Stadium Arcadium tour after all) and the old classics. The inclusion of Dani California early on got everyone going, but it was really the older songs which got the best reaction: Californication, Under the Bridge and Give it Away. It was all good, I can even forgive the self indulgant guitar noodling. Just superb!

If you get a chance to see them on this tour I would totally recommend it. Although if the rest of the dates are anything like last night you’ll do well to find a ticket, it was a complete sell out.

I’ve stuck a few photos up on Flickr and some trademark shaky video up on YouTube:

Logging JavaScript Errors to OpenLog

If you haven’t heard of OpenLog then you should get over to OpenNTF and catch up now, don’t worry we’ll wait for you…

OK, are you ready now? Good then we can continue.

I have been busy adding OpenLog to a couple of applications over the last day or so, all works wonderfully (as we have become used to with Julian’s code!). However these apps are very JavaScript heavy and there are some problems which need to be sorted. The challenge is locating all of the errors out there, so I thought it might be useful to be able to log JavaScript errors to OpenLog as well as LotusScript and Java. It’s a little more involved than other implementations but my solution seems to work pretty well. (I know Kevin came up with a great logging apporach for when users do particular tasks, but I want to trap all unhandled JavaScript errors to make sure that we are fixing all of the underlying problems).

Javascript allows us to set the “onerror” function so that whenever there is a JavaScript error a function is run. What we are going to do is create an AJAX request which submits all of the details about the error to an agent which then logs the information to the OpenLog database.

Step 1
First we add two new JS libraries to the form header: “prototype-1.4.0.js” and “jserror.js”. Prototype is being used for the AJAX stuff (of course you can use your own method for the actual posting of data if you want to, it’s just we already have Prototype on every page anyway) and the new library called jserror.js:

function doError(msg,url,ln) {
  var strURLPrefix = document.location.href.split(“.nsf”)[0] + “.nsf”;
  var strURL = strURLPrefix + “/agLogJSError?openagent&rand=” + Math.floor(Math.random()*1001);
  var strData = “message=” + escape(msg);
  strData += “&url=” + escape(url);
  strData += “&ln=” + escape(ln);
  new Ajax.Request(strURL,
    {  method: ‘post’,
      postBody: strData,
      onComplete: handleErrorResponse
    }
  );
  return true;
}

function handleErrorResponse(originalRequest) {
  alert(“An error has been detected on this page and logged with the support team. Please continue to use the application as normal.”);
}

try {
  window.onerror = doError;
}
catch(er) {}

Step 2
Now we need to create the agent which errors will be posted to, it’s called agLogJSError and is really very simple:

Sub Initialize
  On Error Goto Whoops
  Dim sess As New NotesSession
  Dim dbCurrent As NotesDatabase
  Dim docContext As NotesDocument
  Dim vFields As Variant
  Dim vData As Variant
  Dim strMessage As String
  Dim i As Integer
  Dim url As String
  Dim errorline As String
  
  Set dbCurrent = sess.CurrentDatabase
  Set docContext = sess.DocumentContext
  
  Print |Content-Type: text/xml|
  Print ||
  
  strMessage = “Javascript Error:”
  
  vFields = Evaluate(|@URLDecode(“Domino”; @Explode(REQUEST_CONTENT; “&”))|, docContext)
  For i = Lbound(vFields) To Ubound(vFields)
    vData = Split(vFields(i), “=”)
    If vData(0) = “url” Then
      url = vData(1)
    Elseif vData(0) = “ln” Then
      errorline = vData(1)
    Else
      If strMessage “” Then
        strMessage = strMessage + Chr(10) + Chr(13)
      End If
      strMessage = strMessage + vFields(i)
    End If
  Next
  
  Call LogErrorJS (strMessage, url, errorline, SEVERITY_HIGH, docContext)
  
  Print ||
  
  Exit Sub
Whoops:
  Call logError()
  Print ||
  Print “Error #” & Err & ” ” & Error$ & ” ” & “Line #” & Erl & | in sub/function: “| & Lsi_info(2) & |”|+ “.”
  Print |
|
  Print ||
  Exit Sub
End Sub

Step 3
Finally to make things slightly easier I have created a new function in the OpenLogFunctions script library called LogErrorJS which just formats the error slightly differently than a “normal” LotusScript or Java error.


The end result of all of this is that when there is a JavaScript error the user gets an alert saying that an error has been encountered and logged with support but please keep going as it shouldn’t affect you. In reality you may not even want to notify your user that an error happened, I am undecided about that as yet, we’ll see what they think during testing.

To be honest all of this is terribly simple but I hope it demonstrates two things. Firstly JavaScript is a “proper” language and should be treated as such, ignoring error messages is not a good long term strategy. Secondly OpenLog is great but it’s also flexible, if it doesn’t do exactly what you want then just change it to meet your requirements, I don’t think Julian is going to mind too much ;o)

Big Reminder
Ooh, I almost forgot. If you’re using IE (spit!) and you’re a web developer then you probably have Script Debugging turned on. Well for the “onerror” function to work you have to have script debugging disabled. If you don’t then the function is just never called! Wonderful IE eh?

Online Demo: here
Download Demo Database: JSOpenLogDemo.nsf
Technorati Tags: Show-N-Tell Thursday

Google Reader not so great

Over the last few months I’ve been using various Google applications such as gMail, Google Talk and Google Calendar more and more. To the point, now, where the majority of my online life is spent with at least one of the three open in a window somehwere. So I decided to give Google Reader, the RSS aggregator from Google a try.

I have been using Bloglines for a couple of years now and thought it was time to try one of the competitors to see if they have caught up yet. The first thing to say is that the look of Google Reader is excellent, nicely animated and a good use of the screen real estate. But unfortunately that’s where the good stuff ends. It’s rare for a Google app to have concentrated on the look and feel at the expense of functionality but it seems that’s what’s happened here. If you have been reading blogs for a while your blog roll is likely to be quite large, mine is hovering around the 200 feed mark, so I imported my OPML file. Or at least I tried to but Google was unable to interpret the XML. It was pretty easy to identify the problems but, importantly, the file was valid XML. Bad show Google.

After I had managed to import the file, obviously all of the feeds were unread so there were several thousand entries which needed to be marked read to get me up to date. Unbelievably there are no "bulk" operations available. So a quick scan round the internet turned up the Grease Monkey script which will open each entry and mark it read. Leave it chugging for an hour or so and voila, everything is up to date.

I can forgive the problems so far, they will only happen once during setup and ths is a beta product after all. But just normal use is not great either. There are no keyboard shortcuts (that I could find at least) to navigate between entries. There are keyboard shortcuts, but I didn’t find them. The actual aggregation is slow (like 6 hours or more behind Bloglines). The AJAX code, although very clever, is perhaps trying to do too much, so that you’ll often have to refresh the page to get over JS errors which have been caught but not handled properly.

All in all quite a disappointment from Google. Back to Blogines for me I’m afraid.

Update – Nicholas Baum from the Google Reader development team left a comment that I was wrong about the shortcut keys not being available. I am happy to correct myself. For further details go here.

All Better Now

Thanks for everyone for all the emails, phone calls and comments I am feeling much better now. The penicillin had an almost miraculous effect, within an hour of taking the first batch (I am on a week long course of about 20 pills a day!) I could feel the difference and ever since then it’s just been getting better and better.

The plan for this weekend is to relax as much as possible and try and catch up on some sleep. So not really much different than any other weekend overall! :o)

Sick Boy

I’ve had what I thought was a cold for almost a week now. I say I thought it was a cold although I only had a sore throat. It was annoying but nothing more, but gradually it has got worse and worse until yesterday I was struggling to even drink water because it hurt so much. I’m never really one to go to the doctor but even I thought this was a bit odd so I’ve been working at home today and just spent the last 90 minutes or so in the doctor’s surgery. They had a poke around and decided after a fairly quick discussion that I have strep throat.

So now I am being dosed up on penicillin and they have sent a swab off just for confirmation. Hopefully it will get sorted out fairly quickly as I haven’t slept properly for a week now.

Which Library to Use?

With all of the buzz around AJAX beginning to die down a little and people actually thinking about the best way to go forwards, this is an excellent article which looks at the four main contenders for providing function libraries. The ever popular prototype, the up and coming Dojo, Mochikit of which I know nothing and the very new Yahoo UI Library.

For a long while now prototype has been my library of choice, it is relatively lightweight and does everything that I have needed. However I have been playing with Dojo and barring some misgivings about its size (a whopping 142kb for the AJAX version) the functionality is incredible and now that IBM has weighed in behind it who would bet against it becoming the de facto standard?

Anyway, if you are a web developer and you don’t know much about these libraries then read this article, it’s a great intro and also does a good job of comparing the different options in an unbiased manner. For the moment I think I’ll be sticking with prototype but if/when the size of Dojo gets even more configurable I’ll definitely be taking a closer look.

What are other people going for?

Party Time

A friend was having their leaving do last night in the City, a night when every single person was trying to get into a bar or pub to watch the football. Luckily we managed to find a square inch to stand in and hold a beer or two or three or four and see the game. It’s always good fun when England score in such a packed environment, everyone just goes mad although they did keep us waiting.

Tonight is a traditional champagne and curry night (entering the sixth glorious year of these Domino team celebrations). So off to Tower 42, the Fishmarket and finally Brick Lane. Of course I’d love to be in Ireland for the ILUG today but with the new job couldn’t make it so this is a very nice substitute evening instead.

Good luck goes to Paul and all the rest of the stellar list of presenters today in Dublin. How Paul managed to get everyone together is a really impressive achievement, no doubt there will be stories a-plenty in the blogs over the next few days. They can only get better after the shocking photo of Bill that got released this morning.

Getting information from a user's person document

OK this is a really simple little tip using an @Formula which I had completely forgotten about (hence the post really). The situation is that we have multiple cascaded NABs (or Directory Assistance directories or whatever the cool kids are calling them these days), the current user could have their person document in any of them depending on the user type. I was trying to do a lookup into each of the NABs to find a field on the person document, inefficient and stupid as the NABs are properly secured so the user can’t even do the lookup in the first place!

Enter the @NameLookup function which will go through all of the NABs on the server looking for you and return a specified field name like so:

@NameLookup([Exhaustive]; @UserName; "OfficeCountry")

I just love simple answers to problems. It’s just a little embarassing that I forgot about this one. Notes.net does still have its uses!

Technorati Tag: Show-N-Tell Thursday

Creative Commons

You may notice the new Creative Commons license which applies to all code on this site now.

Really I don’t care if you use my code but after a recent experience I just find it rude and a little silly if you remove any attribution which may have been added to the source code. We all borrow code from the internet, our jobs would be nigh on impossible without doing so but please try and give credit to the author where possible. Apart from anything else the person who tries to pass off someone else’s code as their own just sets themselves up for a fall in the future.

No more will be said of the matter!

Update I just reread this and I sound like a bit of a tosser. Not meaning to, but I have taken care to include the names of people whose code has helped me within my sample code, I wouldn’t want their contributions to go unnoticed (or indeed for others to think I am being hypocritical!)