It's been about two weeks since I started driving here, and it is not as bad as I thought it would be. First you really have to change your mindset and understand the mentality of people on the road. Once that is done, it will not be bad. There are many people from very different regions of the world here. most people do not have the proper traffic training, and they just hate rules. Even police cars do all of the things below!
Some of the common things you will always see are:
* Making a dozen lanes in a three lane street at traffic lights.
* Not seeing lanes at all while driving.
* Some very very wide stretches of roads without lanes at all.
* Stopping at the right lane on the road, and then making a U turn at the lights. crossing two or more lanes who want to go straight, and one or two who want to make a left.
* Who stops at roundabouts? Who has the right of way? I still did not figure this out, but it seems that whoever can stop, should. In most cases it is those at roundabouts who stop.
And all of that behavior is perfectly normal. very few honks are ever heard while doing any of this.
It is in other words, "organized chaos".
But one cool thing is, you can do all of that too, and get away with it! Just like everybody else on the road, others will generally take care for your wrong moves. You might hear some horns, but you will probably give some to others too. Just relax, and blend in.
Two major things that are proven by looking at the streets here are:
1. Allah does exist.
2. HE is very forgiving and merciful.
Otherwise there will probably be no man alive in here. I still recall that guy crossing a 3 lane congested highway, without even looking, hearing no breaks or horns at all, and him reaching the other side safely like nothing happened. By all laws of probability and physics, he should be dead meat. But Allah Raheem.
Happy driving if you do it in KSA :-)
When a Tandem, or HP NSK program crashes, it creates a memory dump file called a SAVEABEND file. When my brain crashes, it adds an entry to this blog.
Wednesday, November 29, 2006
Wednesday, November 08, 2006
Moving
Leena and I were busy packing and arranging for the move over a week ago. The move to Jeddah was planned months before that. But somehow it just seemed like another minor thing. Even though we both knew it was a BIG move. We knew we will leave many things here, and will start a new life in Jeddah. We knew of all of the details, but we just did not feel how BIG it was Until last night.
Yesterday we went to get our one-way ticket. Then I went to finalize selling my car, and realized I still have another 2 years instead of just one of loan payments. We went back home, and my brother came to get some stuff. That stuff was a spare desk, and my PC desk. Both desks occupied most space in my "operations" room. I had to pack my PC. And then my operations room was almost empty, except for some boxes.
Now I feel it. We are moving, we are leaving all of this behind, and starting a fresh start.
I am not feeling sad or afraid for the move at all. I am excited, but I will miss all things, and most importantly all people here.
The different thing in this move from all the others I made previously is that this time, I will take the most precious person with me. That makes it easier :-)
Yesterday we went to get our one-way ticket. Then I went to finalize selling my car, and realized I still have another 2 years instead of just one of loan payments. We went back home, and my brother came to get some stuff. That stuff was a spare desk, and my PC desk. Both desks occupied most space in my "operations" room. I had to pack my PC. And then my operations room was almost empty, except for some boxes.
Now I feel it. We are moving, we are leaving all of this behind, and starting a fresh start.
I am not feeling sad or afraid for the move at all. I am excited, but I will miss all things, and most importantly all people here.
The different thing in this move from all the others I made previously is that this time, I will take the most precious person with me. That makes it easier :-)
Thursday, November 02, 2006
7ajafaan
No, it is no typo. This is one very versatile word in my family's personal and growing vocabulary.
My family, have passion for laughter. One of their talents, and joys, is remembering sentences, sayings, and miss-pronounced words and creating our own proverbs and sayings.
Today's word is "7ajafaan". This is pure family heritage. It's not even a word! Yet we say it so often, that it is part of our daily vocabulary. We share it with our friends and relatives. It's also a sort of passcode that when any one of my family hear it, they will know you are part of the family. Sort of get's you in the circle.
And the story for this word happened way before I was born. During a gathering that included my uncle, many others and a very old man having a heart problem. The old man did not look well that night and was asked what was wrong. He said "Madri, yumkin 3indi 7ajafaan fi al qalb" 7ajafaan instead of khafaqan (pulse). One of my uncles heard it, and loved that word. And so the word was born.
And from that day for anything that is not okay, and the reason is unknown, we say "fee 7ajafaan", or "having 7ajafaan".
Examples.
"What's wrong with your stomach? You don't seem well.". to which you answer. "madri, fee 7ajafaan".
"What's with this program? a bug?" "Yeah, this program fee 7ajafaan".
My family, have passion for laughter. One of their talents, and joys, is remembering sentences, sayings, and miss-pronounced words and creating our own proverbs and sayings.
Today's word is "7ajafaan". This is pure family heritage. It's not even a word! Yet we say it so often, that it is part of our daily vocabulary. We share it with our friends and relatives. It's also a sort of passcode that when any one of my family hear it, they will know you are part of the family. Sort of get's you in the circle.
And the story for this word happened way before I was born. During a gathering that included my uncle, many others and a very old man having a heart problem. The old man did not look well that night and was asked what was wrong. He said "Madri, yumkin 3indi 7ajafaan fi al qalb" 7ajafaan instead of khafaqan (pulse). One of my uncles heard it, and loved that word. And so the word was born.
And from that day for anything that is not okay, and the reason is unknown, we say "fee 7ajafaan", or "having 7ajafaan".
Examples.
"What's wrong with your stomach? You don't seem well.". to which you answer. "madri, fee 7ajafaan".
"What's with this program? a bug?" "Yeah, this program fee 7ajafaan".
Sunday, October 29, 2006
The Mont Blanc Pen
I got a Mont Blanc Pen as a farewell gift from my dear friends and colleagues. It's a Mont Blanc, it looks very professional, it has the new, and very cool Mont Blanc floating star, it is one of the new styles, and I generally love their products... but.. but... but I just don't like that style at all. It is too "complex" for me.

See the many fine rings it has? The black and silver? The two black rings?
I take simplicity to the extremes I guess. I like simple, clean, straight designs. Nothing fancy at all. "Less is More" is one of my favourite proverbs. And this applies to design too.
So, as much as I appreciate the gift, I just had to exchange it. I want to have a gift that I like. It still seems unethical to me, but I proceeded. I went with my wife to Mont Blanc in Seef Mall with the Pen. I didn't have a receipt. So I did not know if they would accept an exchange. I just told them I got it as a gift two days ago, and I want to exchange it. They gladly exchanged it for another.
So now, I have a gift from my dear friends and colleagues, and it is something I like. A clean, straight, and simple, yet sophisticated Mont Blanc.

I also like the fact that this pen has a cap that you need to screw to open/lock it. It sorts of lets you think before you use the pen. Not just any cap you get from a Bic. You make sort of an effort to use it. After all you are using a Mont Blanc :-)
What do you think?

See the many fine rings it has? The black and silver? The two black rings?
I take simplicity to the extremes I guess. I like simple, clean, straight designs. Nothing fancy at all. "Less is More" is one of my favourite proverbs. And this applies to design too.
So, as much as I appreciate the gift, I just had to exchange it. I want to have a gift that I like. It still seems unethical to me, but I proceeded. I went with my wife to Mont Blanc in Seef Mall with the Pen. I didn't have a receipt. So I did not know if they would accept an exchange. I just told them I got it as a gift two days ago, and I want to exchange it. They gladly exchanged it for another.
So now, I have a gift from my dear friends and colleagues, and it is something I like. A clean, straight, and simple, yet sophisticated Mont Blanc.

I also like the fact that this pen has a cap that you need to screw to open/lock it. It sorts of lets you think before you use the pen. Not just any cap you get from a Bic. You make sort of an effort to use it. After all you are using a Mont Blanc :-)
What do you think?
Saturday, October 28, 2006
Prada
My wife read the book, "The Devil Wears Prada" and she enjoyed it. Today we went to see the movie.
I was reluctant at first. I knew the movie was about fashion, main character is a she, so I thought it's a chick flick. It's not like that, although it does show a lot of chicks and a lot of fashion. I did like the movie and the points it was trying to make.
The movie is about Andrea, an educated smart girl, who is not into fashion, not that pretty, or at least thinks and acts as if she is not. She has no other opportunity but to work as an assistant to the editor of Runway magazine, Miranda. Miranda is so bossy, so over-the-top and a goddess of fashion. I will not spoil any more of the movie, but it is very good.
For me, the main point in the movie is that it doesn't matter if you have something that a million other persons dream to have, what matters is do you have what you want? And even if you think you don't have a choice but to do what you have to do, you always do have a choice, even if it is simply walking away.
I was reluctant at first. I knew the movie was about fashion, main character is a she, so I thought it's a chick flick. It's not like that, although it does show a lot of chicks and a lot of fashion. I did like the movie and the points it was trying to make.
The movie is about Andrea, an educated smart girl, who is not into fashion, not that pretty, or at least thinks and acts as if she is not. She has no other opportunity but to work as an assistant to the editor of Runway magazine, Miranda. Miranda is so bossy, so over-the-top and a goddess of fashion. I will not spoil any more of the movie, but it is very good.
For me, the main point in the movie is that it doesn't matter if you have something that a million other persons dream to have, what matters is do you have what you want? And even if you think you don't have a choice but to do what you have to do, you always do have a choice, even if it is simply walking away.
Tuesday, October 17, 2006
MySQL and index use
And yet another post about MySQL and how it uses indexes.
I have a transaction log file that contains a million plus records. Two essential fields I almost always use are TranDate and TranTime, CHAR(6) and CHAR(8) respectively. They contain the date and time in YYMMDD and HHMMSSss.
After the log table contained a million records, my queries were starting to take longer and longer, even though I had an index on TranDate and TranTime columns called DateTime. I needed to search for transactions between Date Time (YYMMDDHHMMSSss). The query had the following syntax:
I initially thought that the DateTime index will be used in the above query, but an EXPLAIN command on MySQL showed a full table scan. My index was not used!
I went digging in, and surely enough, MySQL will not be able to use the DateTime index, because the TranDate and TranTime are NOT used directly in the WHERE clause. The query basically tells MySQL to take the TranDate and TranTime columns in each row, combine them, and only return those rows between the given values. MySQL is no magician to know that the combined values are indexed already.
So, the solution was very simple. Create another column, TranDateTime that is the concatenation of both fields, and then modify the DateTime index to index that single column. The query will also change to replace the Concat function with the TranDateTime column.
Another EXPLAIN command, and the DateTime index is used, cutting the execution time to less than a second instead of few minutes.
The rules of index use in MySQL (and probably other databases) are very simple:
1) The columns that in the WHERE clause will be subject to index use if they are part of and index.
2) An index on (col1, col2, col3) can be used to search for any of the following combinations of columns: (col1), (col1,col2), (col1, col2, col3). The same index cannot be used to search for col2 only. Just think of the index as a sorted array of string, and you should figure out why.
3) The index used will be the one that returns the least number of rows.
1) Ask the database engine what is it doing. MySQL may not be the most sophisticated database, especially with multiple tables, but it does the job. Imagine what a database like Oracle, Sybase or one of the big guys will do.
All you have to do is ask.
2) Understand why is the engine doing what it is doing. Why is that seemingly suitable index not used? Is the right column present in a query WHERE clause? is that column used in a function that makes the index unusable? A LIKE '%value%' clause will not use any index.
3) Try to create a better index suitable for that query, or try to fine tune the query so the best index can be used.
Re profile, and continue until you get fed up.
Remember that you cannot solve your bad query problems by getting better hardware!
I have a transaction log file that contains a million plus records. Two essential fields I almost always use are TranDate and TranTime, CHAR(6) and CHAR(8) respectively. They contain the date and time in YYMMDD and HHMMSSss.
After the log table contained a million records, my queries were starting to take longer and longer, even though I had an index on TranDate and TranTime columns called DateTime. I needed to search for transactions between Date Time (YYMMDDHHMMSSss). The query had the following syntax:
SELECT *
FROM log
WHERE Concat(TranDate, TranTime) BETWEEN '061001' AND '061010'
I initially thought that the DateTime index will be used in the above query, but an EXPLAIN command on MySQL showed a full table scan. My index was not used!
I went digging in, and surely enough, MySQL will not be able to use the DateTime index, because the TranDate and TranTime are NOT used directly in the WHERE clause. The query basically tells MySQL to take the TranDate and TranTime columns in each row, combine them, and only return those rows between the given values. MySQL is no magician to know that the combined values are indexed already.
So, the solution was very simple. Create another column, TranDateTime that is the concatenation of both fields, and then modify the DateTime index to index that single column. The query will also change to replace the Concat function with the TranDateTime column.
Another EXPLAIN command, and the DateTime index is used, cutting the execution time to less than a second instead of few minutes.
The rules of index use in MySQL (and probably other databases) are very simple:
1) The columns that in the WHERE clause will be subject to index use if they are part of and index.
2) An index on (col1, col2, col3) can be used to search for any of the following combinations of columns: (col1), (col1,col2), (col1, col2, col3). The same index cannot be used to search for col2 only. Just think of the index as a sorted array of string, and you should figure out why.
3) The index used will be the one that returns the least number of rows.
Moral of the story?
1) Ask the database engine what is it doing. MySQL may not be the most sophisticated database, especially with multiple tables, but it does the job. Imagine what a database like Oracle, Sybase or one of the big guys will do.
All you have to do is ask.
2) Understand why is the engine doing what it is doing. Why is that seemingly suitable index not used? Is the right column present in a query WHERE clause? is that column used in a function that makes the index unusable? A LIKE '%value%' clause will not use any index.
3) Try to create a better index suitable for that query, or try to fine tune the query so the best index can be used.
Re profile, and continue until you get fed up.
Remember that you cannot solve your bad query problems by getting better hardware!
Monday, October 16, 2006
MySQL Crosstabs
I was writing some reports, and needed a better way of visualising some data. Instead of of having something like:
something like the following is much easier to look at, and graph:
There is no built-in crosstab or pivot construct in MySQL, but this is much easier than it seems. After you create it once, it will become second nature. I am using it very frequently to create all sorts of statistics and graphs.
So, let us assume you have the above data in a table like Listing 1. You need to transform it, or create another query that will generate to you the result in Listing 2.
Here is the Query:
The trick is using a SUM of 1 or null. 1 will be added when the condition in the IF applies, and null otherwise. The beauty of this, is that you can have any arbitrary complex expression in the IF statement to group records that must be added in the APP column. For example let us say you need to have only two columns for APP and OTHERS. Your query will be:
This gives you much more flexibility in constructing your crosstabs. It May get a bit complicated if you need many columns, or if you need a single column per value. If you have this, then probably the best thing is use the right tool for this. Use Microsoft Excel. Or use any one of several techniques that build the SQL for you. Just do a Google search on MySQL crosstab, and you will find some good ones. One good article on MySQL site is here.
Term Resp Count
ATM01 APP 100
ATM01 DEC 10
ATM01 REV 5
ATM02 APP 250
ATM02 DEC 23
Listing 1
something like the following is much easier to look at, and graph:
Term APP DEC REV
ATM01 100 10 5
ATM02 250 23 null
Listing 2
There is no built-in crosstab or pivot construct in MySQL, but this is much easier than it seems. After you create it once, it will become second nature. I am using it very frequently to create all sorts of statistics and graphs.
So, let us assume you have the above data in a table like Listing 1. You need to transform it, or create another query that will generate to you the result in Listing 2.
Here is the Query:
SELECT Term,
SUM( IF(Resp = 'APP', 1, null) ) as APP,
SUM( IF(Resp = 'DEC', 1, null) ) as DEC,
SUM( IF(Resp = 'REV', 1, null) ) as REV
FROM mytable
GROUP BY Term
The trick is using a SUM of 1 or null. 1 will be added when the condition in the IF applies, and null otherwise. The beauty of this, is that you can have any arbitrary complex expression in the IF statement to group records that must be added in the APP column. For example let us say you need to have only two columns for APP and OTHERS. Your query will be:
SELECT Term,
SUM( IF(Resp = 'APP', 1, null) ) as APP,
SUM( IF(Resp <> 'DEC', 1, null) ) as OTHERS
FROM mytable
This gives you much more flexibility in constructing your crosstabs. It May get a bit complicated if you need many columns, or if you need a single column per value. If you have this, then probably the best thing is use the right tool for this. Use Microsoft Excel. Or use any one of several techniques that build the SQL for you. Just do a Google search on MySQL crosstab, and you will find some good ones. One good article on MySQL site is here.
Subscribe to:
Posts (Atom)