Wednesday, November 25, 2009

as in chess...

Prophylactic thinking, my favorite subject in chess.
Seeing the problem long before it manifests and laying ambush for it...
Recognizing and removing the weed before it germinates (not that kind, pleeaase - let it grow for I and I).
Prophylaxis; a shiny word for the deepest, coldest, calculated(est) concept
You play your game in your opponent's mind, and if he is any good the battle field will shift between your mind and his often. The game of chess is not played on 64 squares!

We learnt the rules long ago and through work work work. It boils down to 3 simple concepts really:

POSITIONAL ASSESSMENT
PLANNING
CALCULATION
in that order.

If you practice the three well and fastidiously, you will be blessed with a fourth, brilliant combinations, tactical coups that eliminate the obstacle in flash and style. But first:

Positional assessment: this is counting, weighing and comparing.
not the number of pieces you have, no sir! Your assets vs liabilities
  1. the effectiveness/activity of your pieces in relation to the achievement of your goals (happiness, anyone). sometimes you cannot see a clean relationship between the goal and the effectiveness of your tools, in such cases, the effectiveness of the tools is to be weighed against other factors of your position
  2. the way in which the pieces you have co-operate. do they help each other? complement each other? like 2 bishops gazing across the two colored board at the hostile kings position... or 2 pawns standing side-by-side to cover 4 central squares. or do they get in each other's way?
  3. the amount of space you have to manoeuvre. how much lee-way do you have to take decisions and quickly execute plans? are you constrained by factors like lack of cash? necessity to complete mortgage payments? contracts you need to uphold? people you need to please?
  4. the safety of your king. what things are dearest to you? have you invested in proper safety measures like insurance, remote backup of critical files, communication in relationships, safeguarding your reputation...
  5. then the numerical strength of your material. how much material weight can you push to achieve your goals?

Now you get to the planning stage. and the questions you would like to ask yourself all come out of the positional assessment's what next beg...
  1. how well off am I? am i in black or red? stronger or weaker than my opponent (poverty, unhappiness, lack of fulfilment, feeling of inadequacy...)here you need the honest truth. you can lie to everyone else, but at this point it is just the worst thing to say 'i am well', 'i am rich', and all the other assertations. this is the point where you make the fork. left or right? either way is good - if it is the way home (or to school, church, bar, whatever). There is a standing rule in chess: when in an advantageous position, you have the right and the need to attack or risk losing your advantage. When at a disadvantage however, you have to rein in your horse, dig a ditch and defend stoutly, endeavoring to cover up the weaknesses in your position and edge toward neutrality. In a balanced position, you maneuver and actively seek ways of extracting some sort of advantage or at least an imbalance that you can take advantage of.
  2. Also, at this point you need new answers: if I am stronger, where does my strength lie? where is the weakest position in my opponents board? How do I conduct my attack to increase my grip on the position? When weak, the opposite questions are as important: Where is my biggest weakness? How can the opponent most readily attack me? What can I do to mitigate my weaknesses? Opportunities for counter attack are not far from your thoughts as well
Calculation is the ability (we all have) to look at the possible outcomes of our actions, what is profitable and what is not. How do we know what is profitable and what is not? we have to do an assessment of the possible positions after the imagined series of actions, weigh them again on the scale and decide.

A last word, consistency is a virtue as long as it does not grow to complacence or fear of change. It is a wild game. Come let us play it with zest and energy.

So we lather, rinse, repeat as we master this age old game of ours

Tuesday, November 24, 2009

a spin in the yarn

The white "hiluxy" truck was about to overtake my rickety audi. I have just looked at the rear view mirror, the right side mirror, the fuel guage, dashboard clock and speedometer. Every thing was fine. a hundred and 10, maybe 20 km/hr, a quarter tank of fuel, a stationary 911 truck about 75m away to the left. The hilux was passing me... crack! did he touch me? The car skid to the left. started in a spin, counter-clockwise. Don't freakin touch the brakes!
"Father help me, help me please"
The car spun around twice or more, narrowly missed the parked 911 and headed for the culvert. I crashed into the the cement culvert, and the car ground to a halt.
I breathe a "thank you Lord"
Put off the car engine, unfastened the seat belt, opened the door and squeezed out. The hilux had sped along, but my friend, Diran, who was traveling ahead of me in his honda had stopped a few meters ahead and was walking back. I waved at him so he knows I am Ok.
Hope I don't have nightmares...

Thursday, September 10, 2009

A tale of two aunts

When Aunt Dora became information minister, I was a bit skeptical cos she was doing such a great job at NAFDAC. So she gets promoted (it seemed) and in a short while we start to hear of a new project to re-brand (brainwash) the country. Bravo! (it seemed again). But thinking about it a bit, what is the meat of the re-branding project? At first glance it seems like we want to show the world (and ourselves) that Nigeria is not all corruption and fraud (419), suffering (and smiling - RIP Fela), failed (x-point) agendas, etc... But that we are um... what? (I have to re-brand/brainwash myself again, it seems).
Every Nigerian of a thoughtful disposition (and most who have their thinking done for them by the media and gossip-channels) know what's what. We are all tired of talking about it (yawn), though we are apparently not sick enough (or courageous enough?) to do anything about it. The people who were are almost all gone now: Gani (sun re o!), Fela, Beko...
I wish Aunt Dora would tell us exactly what we are re-branding? Is it the mess that is Nigeria? Bob Marley (RIP) said: "Some people put their best outside, some people keep their best inside". Aunty, pls we want to keep our best inside not outside for display, when we DEY HEAR AM for inside.
Another lovely aunt of mine, Aunt Cecilia is being harassed for sharp practices in the banking sector. I have heard so much said about my poor aunt that...
I believe that in this life, the only things we take with us (we are all gonna die!) are the things we leave behind...

PS
My apologies to all who are offended by my use of Fela and Bob Marley's quotes. Perhaps I should have used quotes from Ghandi, Awo, Zik, Nkrumah, Lincoln, Aunt Maggie, Oga Churchill, etc... Perhaps even from the Bible or Quran... But we no need to go that far, bros.The winch wey dey worry us, na inside awa house e dey!

PPS
My apologies to those I have also offended by picking on the (few) ladies we have in high places... But I have long lost faith in the uncles and (sugar?)daddies that have held our poor country hostage for decades. They have apparently sold some part of their souls to the devil and so we have to use XX-long spoons when dining with them (don't swallow please)

Saturday, August 1, 2009

the scent of a coders conference

There is the scent of a hackers conference in the air...
A group of hackers and hacker-cum-businessmen met yesterday in the busy city of Lagos with one agenda in mind...
To organize a top notch programmer's conference here in Lagos. A conference with the central goal of exposing young and would be programmers to the wonderful labyrinth of languages, tools and technologies out there.
Experienced hackers are not left behind with the dazzling array of tech talks and hacking sessions.
Hey, this is just the dream. Don't quote me!
Watch out for more information on developments.
P.S.
The project is code-named {braces}

bluetooth file transfer with PyBluez and lightblue

I just learnt to send files via bluetooth to my phone using python. I am ashamed to say it took a couple of days to get it off the ground.
I have a nokia e63 and my development box is an linux ubuntu 8.04 (hardy heron) machine
Starting out I gathered some info about the bluetooth stack, learnt the way to go was bluez (and PyBluez in my case as I would much rather work in python than the other options I came across, java or c).
So I did an apt-get install python-bluez and experimented some. I found it terribly easy to scan for bluetooth devices and connect, but I did not succeed in sending files to the phone.
Then I discovered lightblue!
So off I went and downloaded lightblue, cd'd to the directory and went
sudo python setup.py install
Unfortunately, I got lots of errors starting with
could not find bluetooth/bluetooth.h or bluetooth/hci.h and a whole slew of similar messages. A google search revealed that I needed to install the development files for bluez. So:
sudo apt-get install libbluetooth-dev
and voila! some of the error messages went. The errors left had OBEX all over them, and so I guessed that they were missing the OBEX development files as well.
sudo apt-get install libopenobex1-dev
sudo python setup.py install
Now the install went smooth.
I wasted no time in testing:
import lightblue
for device in lightblue.finddevices():
lightblue.obex.sendfile(device[0],9,file_object)

9 is the port for OBEX push
device[0] will give the address of the bluetooth device
file_object is either a file name or a file obtained by calling open(file_path)
Next, I will find how to send files asynchronously as a step toward building a full-scale bluetooth marketing device! So till then!

Thursday, July 30, 2009

shiny new Django1.1 in a few words

"It was with joy that..." I viewed the announcement of the release of django 1.1.
It has a ton of features like (opening the release notes):
- speed up of test performance (now i'll stop being a hypocrite and write those unit tests)
- aggregation (instead of grabbing a bunch of records and finding the length, or writing custom sql, i can just ask for the Count, or SUM,MAX,MIN of particular fields)
- annotation (give me all the drugs that i brought in last week and the total number of sales for each)
- F (query)-expressions (give me all the drugs whose purchase dates are greater than the expiry dates, and by the way get the list of people i have sold them to, grouped by drug)
- deferred fields (when you have 'expensive' field data, large text fields for instance, you can defer their loading till they are needed). Nice performance feature
- Admin actions (d admin site just got better with the addition of batch delete and custom actions)

Since I have been running the development version, I have gotten used some of these, However, there are a ton of other stuff I just got to know about:
- unmanaged models
- proxied models (i am a fan)
- url namespaces
- loads of other stuff that i will be looking at in the next few weeks, especially as I have a million project ideas to work on.
The django team has done a wonderful job! I can only hope for the privilege to contribute to it in the future... of course I will!

Wednesday, July 22, 2009

crappy virgin nigeria online booking experience (aka where are lawyers when i need them)

I was trying to book a flight from lagos to port-harcourt for the 22nd of July (today) and I found that you have to be extra careful when booking for virgin nigeria flights. The 2 issues are:
1. I selected 22nd of July for the booking date. By some crazy magic, when i clicked next to continue the booking process, the date 23rd July shows up as my booking date. Since I was more interested in the cost of the flight, my brain did not take the new (magically derived) date in. So, I pay and only then discover that virgin nigeria prefers that I travel tomorrow instead of today, and also that cancelling my booking will cost N2,500 that I never budgeted for. I (and any reasonable user, IMHO) would have thought they could indicate that flights on the date I selected did not have any available seats, like putting a LARGE RED SIGN that screams 'There are no seats available for the date you selected, however we have flights for the 23rd of July...etc' with a very big sorry sign on it (i don't think it costs anything to say sorry even if it's not your fault that the user did not book early enough).
Or maybe a separate list of suggested travel dates, that is clearly marked 'RED PAINT: SUGGESTED TRAVEL DATE: XX/YY/ZZ'. But just tricking him/her to book on any arbitrary date (tomorrow is as arbitrary as next year) is just bad bad bad!!!!
Another source of frustration is that our own dear virgin nigeria claimed to charge N15,650 for the flight... How come my sms alert rounds it up to N16,000? are there hidden costs that they do not show us? or is somebody stealing my money behind my back? or both?
Virgin Nigeria you have to get your act together and make your online booking experience less of a JAMB exam!
At least we have the option of going aero for their cheap flights (small advert for them here)