More Haste, Jake, More Haste
Last night, like an idiot, after a couple of glasses of wine I completely forgot about what I'd read on Volker's site and upgraded to Firefox 3.5. This broke Gears. This on the eve of moving in to the testing phase of the Gears project I've been working on for about a month now.
While I could have used IE or Chrome instead, Firefox is the only one for which Gears and HTTPWatch work together and you really need a HTTP sniffer if you're debugging Gears apps!
Luckily, this morning I managed to downgrade back to 3.0.11, which is a simple case of downloading and running the installer. You don't even need to uninstall 3.5. That's one of the things I've always liked about Firefox - it never loses your settings.
Will Firefox 3.5 Even Need Gears
One thing I did get out of my brief look at FF3.5 is the (exciting) knowledge that it's moving towards implementing its own kind of Gears. I've not digested it all fully but if you read the DOM Storage page on Mozilla's site and the W3C's Web Storage page you'll see what I mean. It looks to me like browsers of the future will all have local databases to use for persistent data across sessions. Hopefully without the need for 3rd party plugins.
More To It Than "Going Offline"
While using Gears this last month I've been thinking more and more about what other uses it could have, apart from "going offline".
All you have to do is imagine you have a local SQL database that is easily accessed from JavaScript and you'll get an idea what you can do. It's like having a massive cookie to use for whatever you like. One example would be to keep a cache of values which are regularly used in forms/type-ahead by the user but which rarely change at the server. Why keep fetching them with Ajax when you could get them in an instant locally!
Hopefully I'll get chance to show some alternative usages of Gears shortly.
5 Comments Read - Add | Thu 2 Jul 2009 | Open »
Life With Windows Mobile 6 and HTP Snap (stinks)
Having spent a couple of weeks with my HTC Snap and Windows Mobile 6 I'm starting to regret my choice of phone.
There's nothing wrong with the phone itself, per se. I love the look, feel, size, usability etc. It's just the software on it that sucks.
Yesterday I was trimming my finger nails and was conscious of not going too far back on the thumb as I need it on a daily basis to remove the battery cover to do a hard restart!
It seems to crash at least twice a day. Seemingly for no reason at all. Although it has been a bit better since I stopped using HTC's customised home screen, which I prefer to what I have now, so that's a pain too, but there you go.
It even managed to lose all my email and text messages on one occasion. Not a big deal, as I had copies of the emails in Thunderbird too, but the fact it has the potential to just forget all email account settings and delete the messages is somewhat worrying.
I've tried using Windows Update to get any "service packs" there might be but that too fails. Something about the date and time being wrong on the device. Great.
Who To Blame?
Things that don't work really get on my nerves. I don't mind (and expect) the odd bug in software but when I have to mess about removing the battery cover and waiting for it to startup on such a regular basis it gets a bit daft.
If this were any other piece of electronic equipment that I'd spent +?รบ200 on (camera, DVD player, whatever) then it would be straight back to the shop and I'd be demanding my money back. So, why do I feel reluctant to even try and return the Snap? As if whoever I speak to is just going to say, derr, it's Windows, what did you expect!?
Who should I contact -- the seller, HTC or Microsoft? I guess I should start with the seller? I think I'll start with them and see how far I get.
No Way Back
Having used a smartphone for a couple of weeks I can now see that I need one and don't want to go back to not having one. I just think that Windows Mobile probably isn't the way forward. Perhaps Android is...
22 Comments Read - Add | Wed 1 Jul 2009 | Open »
When Hard Coding is Ok - My Very Own Year 2100 Bug
As part of my current job of porting an application to Google Gears I wrote a snippet of JavaScript to validate that a user enters a date in the format ddmmyyyy or ddmmyy. The users are using PDAs so we really don't want them to have to do it in the format dd/mm/yyyy. The less key taps needed the better.
Here's the code:
var re = /^(0[1-9]|[12][0-9]|3[01])(0[1-9]|1[012])((19|20|)\d\d)$/; //Test format first if (re.test(input)) { var bits = input.match(re); if (bits[4]==""){ bits[3]="20"+bits[3]; //Will last 91 years before breaking! } var entered = new Date(); entered.setFullYear(bits[3], bits[2]-1, bits[1]); //Validate range here if needs be } else { alert("Not a valid date!"); }
The end result is a JavaScript Date object representing the date entered, which you can do with as you must.
When Hard Coding Is Ok
What keeps making me think about the code is the bit where I've hard coded the 21st century in to any date where the century part isn't specified. In 91 years it will break. As an opponent of all things hard coding I can't decide how happy I am with it.
Although I know the application itself will, like me, be long dead by the year 2100 it's just bugging me. Is it ever ok to knowingly introduce a bug, even if you know the bug will never get to live?
A Simple Fix
In this case it would be trivial to remove the bug, so that it always added the current century when none was specified:
bits[3]= new Date().getFullYear().substr(0,2) + bits[3];
I just can't decide whether I should retrofit this fix or not. Maybe I should. Then, should a source of eternal life be found by then, I'll be guilt-free.
23 Comments Read - Add | Mon 29 Jun 2009 | Open »
Friday Fun Challenge
On the topic of web-form spam and the ever-evolving ways in which I deal with it, I made a change to Rockalldesign.com's Contact Us page so that it sends me a daily digest of the entries made. It gets used so little for the purpose it was intended that it's safe to check once a day if a real person has used it. Most won't mind waiting 24 hours for a reply, I'm sure.
Anyway, here are the email addresses of the "people" who posted on Rockall's contact "us" page over the last 24 hours. Rather kindly, I always think, the spammer make it pretty obvious it's spam.
The Challenge
Your challenge is to make a short story that includes all of the words used below and in the order they appear!
present@rain.com system@claim.com shine@sheet.com five@such.com milk@tail.com ground@character.com fruit@safe.com island@search.com difficult@during.com problem@felt.com carry@size.com pick@warm.com while@wind.com believe@back.com bell@difficult.com decimal@invent.com since@state.com
Extra point for anybody who can make it topical and about Michael Jackson (the word "five" is in there, how hard can it be!?). The less extra words you use to pad out those above the better.
8 Comments Read - Add | Fri 26 Jun 2009 | Open »
Ten Years On And Still Learning -- Notes Agent Data Stores
Rob Shaver replied to yesterday's post about using the LastRun property of Scheduled Notes Agents with an another, even better, alternative.
It turns out that Scheduled Agents have their own document/storage area that you can add to and read from. I never knew that!
You get to it via the SavedData property of the Session object (in LotusScript). See help page on it for more.
With a bit of tweaking I re-wrote the code I mentioned yesterday to more accurately find the documents created since it last ran, which is posted below.
This gets round the fact that the agent's LastRun property is the time it last finished. Any documents created while it ran won't ever get processed. Using the agents "saved data" area we can add a more reliable time to state when it began.
Set thisAgent = Session.currentAgent Set agentDoc = Session.SavedData Dim query As String, datepart As String 'Default date string datepart = "@Adjust(["+Cstr(thisAgent.LastRun) +"];0;0;0;0;0;-30)" If thisAgent.HasRunSinceModified Then If Not agentDoc Is Nothing Then If agentDoc.HasItem("LastBeganAt") Then datepart = "["+Cstr(agentDoc.LastBeganAt(0))+"]" End If End If Else datepart = "@Adjust(@Now; 0; 0; -1; 0; 0; 0)" End If query = {Form="post" & @Created>=}+datepart+{ & Approved="0"} agentDoc.LastBeganAt = Now 'Set this after query is built! Set collection = db.Search(query, Nothing, 0) 'do stuff here agentDoc.Save(True, True)
Forever Learning
How long have I been using Notes now!? Must be getting on for, if not more than, ten years. How this nugget passed my by I don't know. Going back to Monday's whine this is an example of one of the things I do love about this site. Without it I wouldn't know half what I do. The learning process is two-way! Thanks Rob.
