Saturday, April 24, 2010

Migrating to syntaxhighlighter 2.1.x

I recently decided to upgrade to syntaxhighlighter 2.1 from 2.0 on my blogger blog. I thought it was going to be as easy as dropping in a new version. I was wrong, the TEXTAREA in which i was putting my code is no longer supported. instead SCRIPT tags are used to enclose the code! AHHH! I have about 40 code snippets on my blog and conversion seems very not-fun.

I started to hand convert some of the entries, to find that the new blogger post editor was also losing all of my tabs! This was going to be painful to do by hand..
Alas, i decided to try to do it with javascript, and it worked!

I pulled in the latest jquery into my template to ease the pain. Instead of the regular synataxhighlighter init i now have this:

Now, i dont need to hand convert all of my textareas to the new format, and the tabs are saved. Good deal!

Friday, April 23, 2010

Populate a DTO with mock data

Every so often i need to have a list of some simple DTOs in order to build a screen. The DTOs need to be populated from the database, but the query is not ready. Its somewhat painful to write dummy data creation methods over and over again.

Using Groovy(though not required), Spring and a bit of reflection i cover most of the simple DTOs.

To use, pass the class a list of which you expect

Wednesday, April 21, 2010

jQuery plugins: default options

jQuery plugins should expose their default options as a global hash. This is useful if you want to always override the defaults in the exact same way across your entire site.

Most good plugins already do this, for example jQueryUI plugins do this. Here is the plugin code that will let you expose your defaults as a global variable:

Tuesday, April 13, 2010

Tibetan Prayer Flag Cat Toy

I recently got a Tibetan Prayer Flag in the mail from the Dali Lama. I am not a Tibetan, nor do i pray, but my cat loves it. This is by far his favorite toy. Thank you Dali Lama.