Wotif sucks when trying to find two nights accommodation for the weekend. You cannot search for two night stays, so you have to hover over all the prices to find out if they are suitable (ie. are not for min 5 nights or something like that).
Here is an example that uses Greasemonkey plus jQuery to bend Wotif to my will
Basically it scans all the price tooltips to find text that includes ‘2 nights’ and highlights the cell in red. Note that a tooltip on this site is actually a function invoked on the OnMouseOver event, which we can still select using jQuery:
// ==UserScript==
// @name Wotif2Nights
// @namespace tag:2007.wotif.2nights
// @description only shows hotels with 2 nights
// ==/UserScript==
// Add jQuery
var GM_JQ = document.createElement('script');
//GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.src = 'http://localhost/served/jquery-1.2.1.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
function GM_wait()
{
if(typeof unsafeWindow.jQuery == 'undefined')
{ window.setTimeout(GM_wait,100); }
else
{ $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();
// All your GM code must be inside this function
function letsJQuery() {
//make sure there is no conflict between jQuery and other libraries
$.noConflict()
alert('running');
FindRoomsForTwoNights();
alert('done');
}
function FindRoomsForTwoNights()
{
var x = unsafeWindow.Text;
var keepers = new Array();
var kCount = 0;
for(i = 0; i < x.length; i++)
{
if(x[i].indexOf('2 nights') > -1)
{
keepers[kCount] = i;
kCount++;
}
}
for(i = 0; i < keepers.length; i++)
{
var selector = 'SPAN[@OnMouseOver="showTooltip(Text[' + keepers[i] + '])"]';
$(selector).parent().css('background-color', "red");
}
}
This post describes how to get Greasemonkey and jQuery working together
It works fine, although I changed the url of the jQuery library to my locally hosted copy (GM_JQ.src = … on line 3) for snappier performance.
Published at 30 October, 2007
in Craft.
I started looking seriously at jQuery this week, primarily because I know I’ll have to get back to the metal on the client side when MS MVC hits. No point getting right back to the metal though, you should be using at least one of the many Javascript libraries out there to bootstrap.
Anyhoot, jQuery seems to be the current darling of the scene, and with good reason. It’s focus on DOM element selection feels ‘right’ - thats what we are doing 90% of the time anyway, and the action chaining that follows selection is sweet sugar.
My 10 second explanation:
A jQuery expression is made up of 2 parts:
1. The selection part (using css selector or XPath syntax)
eg. $(”div”) means select all divs
2. The action part
eg. hide(”slow”)
Put them together:
$(”div”).hide(”slow”);
- this will slowly hide all divs.
jQuery expressions are chainable (like a DSL) so you can do stuff like:
$(”div”).show(”slow”).addClass(”someClass”);
Now go and check this stuff out:
Selector examples here and here
jQuery site (with stacks of great stuff)
Visual jQuery API
jQuery bookmarklet (way cool - run jQuery against any site)
Have fun!
Published at 12 October, 2007
in Brain.
Just slashed the number of RSS subscriptions from 260 to 120 or so. Required medium drunkness to do it. Feeling no pain currently
Reflecting on the experience… Much easier than expected (+1 for wine)
Ditched some real long timers - Seth Godin, Scoble, Hugh McLeod etc
Ditched a bunch .Net’ers
Kept a bunch of Ruby’ers, Pythoner’s, DLR’s, Silverlighters
Trimmed my VC’s, Personal Development Gurus, Financial dudes
Kept my designers, UI’ers, flow’ers ( I am sooo crap in this space, my brain has a gaping hole)
Where to from here? Once upon a time I would subscribe to a feed on the basis of a single post. For a while now I’ve been feeling reticent to subscribe to new stuff because of my always full RSS reader.
I feel free again.
A new folder called “New Folks”. Easy entry. Write a single post that interests me. Any topic. I’ll subscribe.
Monthly review. Promotion to core set of feeds, or prompt deletion.
Yay! Like the old days. Maybe 
Published at 11 October, 2007
in Craft.
DamienG provides a good summary of the new MS MVC framework if you haven’t watched the video yet.
It’s going to be interesting watching the uptake of the framework from current .Net folk, but also seeing if any folk from other camps take a serious look.
A clean MVC model + DLR + Silverlight + decent IDE (intellisense, refactoring, debugging) makes for a very compelling platform.
If the framework shows great performance to boot I’m sure there will be folk who are currently throwing stacks of hardware at their rails apps stopping to check it out.
Now I recently read elsewhere an argument that MS should allow SQL Server to be hosted free up to some limit, in order to attract LAMP developers. Given the pieces listed above I think it’s a fantastic idea to try and regain the steadily declining developer mindshare that has been happening over the last few years.
Can the Empire Strike Back?
Published at 10 October, 2007
in Craft.
Earlier this week Scott Guthrie presented at the ALT.NET conference the new MVC framework coming from Microsoft.
Scott Hanselman has released a video of that presentation. Enjoy.
My previous post described a neat trick for quickly changing a page to reduce eyestrain.
You probably noticed that you lose the effect as soon as you go to a new page (or refresh the current one).
This time I’ll show how you can keep the effect for all pages, forever!
1. Download and install Greasemonkey - you are using Firefox right?
2. Add this as a user script:
// ==UserScript==
// @name EyeRelief
// @namespace tag:adam.webber.2007.eye.relief
// @description Grey background
// @include *
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
addGlobalStyle('body { background-color: lightgrey ! important; }');
3. Now, whenever you activate Greasemonkey, the background of *all* pages
you visit will be set to lightgrey
The script is not perfect, and you will probably find pages that don’t quite grey out as you wish.
Well, get to it and write your own script! Or search this great repository of scripts at the UserScripts repository.
Have fun!
Reading a long article? Eyes hurting? Fix it quick!
1. Use Firefox, get and install Firebug
2. On a page that is hurting your eyes, hit F12,
a. Click the Inspect button
b. Click on the part of the screen that is white, you will see firebug put a blue border around your selection.

c. Right-click in the style that is being displayed in the right pane of Firebug, choose ‘New Property’

d) Type: backgound-color: lightgrey

e) Hit Enter, then F12

Done! The sweet joy of no eye strain!
SilverWeight Code
The zip contains a VS2008 Beta 2 Solution, which contains 2 projects, SilverWeight and TestHarness
You should be able to open the solution in VS2008 Beta2 and hit F5 to make it run. *Please* let me know if this is not the case.
SilverWeight is the physics engine, it has no external dependencies.
It is not responsible for any kind of visualisation, purely physics calculations.
The key entry point is the World, you add Body(s) and Joint(s), and then Step the world in some kind of loop.
TestHarness shows the engine in action in a *limited* set of scenarios, I’m looking forward to seeing other people play with the engine.
The TestHarness references the SilverLightGames101 library, note though that it references an old version that is included in the distribution. If you update your references to the latest version of SLG101, the harness will not work without making changes.
If you create anything using the engine, please come back and post a comment - I’m looking forward to seeing peoples’ play things!
Have fun!
Sorry. This post has no fun graphics in it. But it is where my head is at.
Back to abnormal programming soon.