Tuesday, September 29, 2009

Rands In Repose: Your People

Came upon this really good post about people you should cherish:

Rands In Repose: Your People

Really good insight - "As we edit our days into these stories, there is always a risk of fiction. This is why you need to identify and nurture Your People."

What are Your People?
"You tell these stories to Your People without reservation. Your People love your stories — fiction and all. They love how you tell them, they laugh about the lies you tell yourself, and then they stop and they tell you the truth."
You need someone to keep you honest. Read the post for a clear definition of Your People.

Tuesday, September 22, 2009

Strengths, weaknesses and games

StrengthsFinder is an amazing book, and an assessment tool that helps you discover your strengths. Its central concept is that you should focus on your strengths, not your weaknesses. I was introduced to it at the Summer of Code (NZ) program several years ago. The concept of focusing on strengths was just brilliant.

This really reminded me of my game playing style, especially in RPGs, where you have to increase the levels and skills of your character(s) in order to be able to fight enemies that pop up with increasing difficulty and toughness.

What is the usual strategy here? Increase your strong attributes up to insane levels. Weaker attributes would be increased only for the sake of 'balance'.  To translate into gamer-speak:
Level up all magic skills for the mage, and have some combat skills to keep up with the group. Increase the tank's combat and defense skills to insane, and increase healing and magic if there's a chance.
Balance is important as weaknesses cannot be so abysmally weak that you cannot function if a team member which has that strength was unavailable. In gamer-speak again:
Tank has to be able to self-heal and revive mage if mage goes down, and hang on until mage revives and heals group.
Imagine instead we concentrate on improving weakness more than improving strengths. What would result is a group that has similar strengths and weakness, i.e. a homogeneous group, but at levels lower than peak strengths. This team of 'all-rounders' would then be able to do each other's jobs, but none would available to handle particularly difficult problems. In game-land, this is referred to as:
Boss kills mediocre party in one stroke.
Whereas a team with people who has different and fully-developed skills will have a better chance of tackling the problem. In game-land, this scenario is better:
Boss unleashes stroke of hell, tank survives and manages to revive others. Or Mage casts protective spell powerful enough to protect party.
Which brings us to complementary strengths. The team must have a variety of different strengths to deal with different problems that crop up. This, ideally should be addressed when you are starting to hire for the team. Of course it's hard to figure out strengths in an interview. Take time, figure out what strengths are needed for teams, as you never know what high-level boss crazy, hairy problem your team will face...

Tuesday, September 08, 2009

find_each bites

ActiveRecord::Base#find_each is an awesome idiom for batch processing large sets of data. It combines the neat DSL of ActiveRecord and allows you to operate at the level of the individual item.

So, imagine my surprise when I debugged my code and discovered that find_each introduces a scope into ActiveRecord calls within the block. Demonstrating by example:

Slam.find_each(:conditions => {:value => nil}) do |slam|
  Slam.find_by_key(slam.key) #Find related key
  #However, in effect becomes Slam.find_by_key(:key => slam.key, :value => nil)

Looking at the SQL in the logs, I expected to see:

select * from slams where key = 'abcde';

Instead I saw:

select * from slams where key = 'abcde' and value is null;

It took me fifteen minutes to check and verify there is no code that should be generating that SQL, so the next candidate was find_each. Lo and behold, it was. Turns out find_each is using with_scope

Looking around, there are already some bug reports for this behaviour:
Question: Is this intended or this a bug? I think, given the "side-effect" feel of it, it's a bug

Update:  I have reviewed one promising patch to fix this. Needs one more person to review and approve this patch!

Sunday, September 06, 2009

Fear the singularity

I found several interesting things this month.
Ok, the last one is really out there, but it points the way. Imagine the whole sum of human creative endeavor (at least the popular ones) indexed in just 21GB. All we need is just some sort of instant hash expansion for that 21GB (and 20 more years of PC power advancement). And so on and so forth. Value of data or content would be worth next to nothing.

Will that happen? Probably, after flying cars.

Trying to do the impossible

Someone always asks this question -  how do you check types in Ruby? (*Hint: Ruby use dynamic typing) This typical newbie question would ask this and be answered with various levels of helpfulness - typically none - sadly.

However this thread is just beautiful in its helpfulness. http://groups.google.com/group/comp.lang.ruby/msg/eb4b49a511e44be6?hl=en

What happended snarkiness, or Slashdot / Youtube style comments? All this helpfulness must come from somewhere. I blame Twitter.