Thursday, December 27, 2007

2008 resolution

Since it is 'fashionable' to have 'New Year resolutions', here goes mine. Not for the 'publicity', as no one should really care, but just for myself and for my personal record.

So, in 2008, I would like to not judge anyone for anything. Do what I do best at work, try to help others achieve the level of experience and professionalism. And also, not to bother myself with all the intra-office political bullshit and think and care more about my loved ones, not "pointy-headed' bosses with 'tunnel vision'.

Here you have it... Happy New 2008 YEAR!

Later...

Saturday, December 15, 2007

Fetch random GORM model

Despite busy schedule at work and a year old daughter at home, who now requires constant attention, I was able to get some time to work on the Grails community site (Grails Crowd).

As a part of it, I wanted to have a feature to display a 'random' user (a 'member') In fact, keep displaying a random user as long as 'Discover users' link is being clicked. You know, kind of like Flickr's "Explore" feature. So with a help of standard JDK library features i.e. 'java.utils.Collections.shuffle()' and Groovy closures, here's what I've come up with:

MemberController's action:


...

def findRandom = {
def member = null

withMemberIds { memberIds ->
//Pick the last one
member = Member.get(memberIds[-1])
//Then remove it from the list
memberIds.pop()
}

if(member) {
render(view: 'discover', model: [member: member])
}
else {
//No one is registered yet - just 'go home'
redirect(uri:'/')
}
}

private def withMemberIds(closure) {
def memberIds = session.memberIds
if (!memberIds) {
memberIds = Member.withCriteria {
projections {
property('id')
}
}
if (!memberIds.isEmpty()) {
//Some members are in the database:
//Shuffle 'em up
Collections.shuffle(memberIds)
session.memberIds = memberIds
}
else {
//No members are in the database
return
}
}
closure(memberIds)
if (memberIds.isEmpty()) {
session.memberIds == null
}
}

...



It works like a charm.

Later...

Sunday, December 9, 2007

"Agile" labs environment

I was asked by our management to lead the innovative software research of new technologies at our organization. I'm all for it. But personally I think what would be the first step in this undertaking is to have a little bit of freedom for our engineering team. By that I mean it would be great if our management supported and approved to have a some sort of a "labs" environment, consisting of a say Linux box with full root given to the engineering team, so the full freedom of experimentation could be achieved without the usual hurdles and roadblocks of a day-to-day operational and engineering teams interaction.

If that somehow happens, I would have a hope :-)

Later...

Friday, December 7, 2007

Why Grails is so 'close to home'

Here's another [big] reason why Grails is not a "foreign" technology for Java developers. I know, it's been said before, but this is a real world example of a Java person coming to Grails and experiencing this familiar state of things: 1) Create war; 2) Drop into any of the available Java Servlet container/app server 3) Sit back and relax (in the ideal world) :-)

I'm not sure if the same is true for JRuby (On Rails), so I'm not going to speculate here ;-)

Later...

Wednesday, December 5, 2007

Web 2.0 "bubble" video

Here is a great "web 2.0 bubble" video!