Javascript keeps on surprising me: you can find ready-made examples almost everywhere...:-)
Yesterday I spent the afternoon testing MacOS Tiger Widgets ( I decided I needed the latest Dilbert strip, when sipping my morning tea) and I found that a lot of them can be a very useful source of code.
Of course, not all widget let you freely use the code.
Anyway, amongst the free ones, there's still a lot of very inspiring material.
A good starting point:
http://www.apple.com/downloads/dashboard/