Monday, October 08, 2007

My New Blog

Good news, everyone!
I have come to dislike Blogger seriously. It's very hard for Iranians to post comments or even use permalinks (I don't know at which end the problem lies, our ISPs or Google.) You don't know what I go through just to post here!
Anyway, because of all that and more, I've decided to move my blog to my own web space at yaserzt.com. So, as of a couple of hours ago, my new blog address is http://yaserzt.com/blog/!
I've decided to use WordPress, because it can import Blogger weblogs (which it did nicely enough) and its installation was a breathe. I've heard good things about Serendipity as well, but I couldn't find any documentation about migrating from Blogger to Serendipity.

Infuriating and Ridiculous

Ridiculously infuriating is the act of blocking the English Wikipedia by Iranian judicial system and my ISP. How can someone with a half brain decide to block a community-written wiki encyclopedia? You don't know how much I want to meet the guy who made this decision, to stare at him in such a "عاقل اندر سفيه" ("wise man looking at a fool") manner that he would wish he was never born! Or probably, being the moron he is, he would just not notice. This is on the same line as restricting all private (households, etc.) Internet connections to 128Kib/s. Why are they doing this to us and to themselves?

Testing, Please Ignore

Merely for testing purposes.
--  "Programming is an art that fights back!" 

Friday, October 05, 2007

"No More Tears"

The above sentence was the happiest thing I'd seen in a while. Too bad it was written on a baby shampoo. I guess there's no salvation for me.

arT & Tar

Tonight (last night, to be more exact) I accompanied my friend Farzam to a taar-maker, for him to buy an instrument. The taar-maker was named "Rasool Khojasteh", a young man (32-ish, I'd say) who lives and works in Karaj.
We spent more than 3 hours talking with him, about many things, including taars and what set them apart, master taar players, the craft and art of making taars, how he became a taar-maker and the affair of a taar player and his/her taar. Since I know absolutely nothing about taars and music in general (and I'm pretty sure that I'm tone-deaf) I did not participate in the discussions, but the two of them talked and played some taar in the way that only two people with a common passion can.
He seemed to me as a very interesting guy. He talked about how he had found a 350-year old walnut tree in Alamut forests and had hauled it back to his workshop to make a dozen taars and many handles and other stuff. He said that he has more wood than he needs to make taar-handles(?) for a lifetime, and that now that the wood has been expertly dried and treated, many gun makers (or manufacturers) would pay him a dear sum to have the wood to make rifle stocks (you know, the end of the rifle where you put against your shoulder.) But he said there was no way he'd let the "precious" wood turned into guns, instead of taars. (Pretty quote-worthy, wouldn't you say?)
He also showed us his workshop. His passion was amazing when he was near his taars and was describing his procedures and experiences.
The story of him becoming a taar maker was also rather interesting. As he tells the story, he was born in a middle-class, and religious, family. When he was very young, maybe even before his teens, he hears a taar-solo and it moves so much that he falls in love with the instrument and with music. But his family considered music an unworthy and even sinful matter, so they wouldn't buy him a taar. Then he goes on and sells his older brother's bicycle, and buys a taar. When his father finds out, he breaks the taar, so he decides to make himself one. He remembers that he used to think that crafting a taar is not hard. He sets out to make himself one, with no knowledge of the craft. His first attempts were obviously failures, but his father breaks each and every one of them nonetheless. His father even hits him on the head with with one of the taars he'd made and breaks it! He says there's still a scar there. Anyways, he realized that there's science,art and craft involved in making a taar, and sets out to find out and learn from the other taar-makers. He remembers with a pang how they have treated him, keeping their information and methods from him (and everyone else.) But with bits and pieces of info from here and there, and the methods that he had to reinvent some of them for himself, he finally manges to build playable instruments. And now he reckons he's made hundreds of taars. But he doesn't do it for the money. We saw the evidence ourselves. He's agreed to make my friend a taar, and has agreed to accept his payment in a few installments instead of all at once, without knowing my friend and without him even having to give him a check.
Khojaste says that he became a taar maker to make one for himself, but after 18 years, he doesn't have a taar yet. He said that he's not made the right one yet. When he said that he loved the instrument and loved what he did, I had no trouble believing him.
All in all, it was an interesting evening. I wish I understood this music thing that is as clear as a pool of mud to me.

Sunday, September 30, 2007

Going Off the Radar

For reasons that many of you (if the number of people that read my blog can indeed be counted as many) know already, I'll be moving back to Mashhad in a month. The month is for me to tie some loose ends over here at work and help the project I'm involved in as much as I can, so when I return home, my (almost non-existent) conscience doesn't bother me unbearably.
On the other hand, I have made my decision and will return to Mashhad to pursue and finish my studies no matter what happens and small things like a guilty conscience and leaving dear friends between a rock and a hard place in a pick won't deter me!
Anyway, since I'll be leaving for Mashhad in a month (that's the minimum period my contract requires of me) and the project won't be finished until then (the plan is for another 3 month, with a 6-person team,) my friend and project lead - Farzam - suggested that we (him and myself) put off all life for a month and finish the project by ourselves! It's 18 man-months, shrunken into two! I don't know if we can, but with the overhead from all the unnecessary work (like generating documentation!) and communication and endless meetings gone, I think we just might be able to pull this off!
But for that to happen, I really need to cut off from the world. I think I'll check my emails from time to time, but instant messengers, browsing, probably posting to my worthy and popular blog (NOT!) will have to go into the cellar for the time being. So "¡Adiós Amigos!" Keep in touch, if at all possible!

Thursday, September 27, 2007

The Clovers Work!

"Good day to be alive, sir!"
"Good day to be alive," he says...
I just cannot not worry about what the soothing light at the end of my tunnel will end up to be! *shivers with a premonition*

Monday, September 24, 2007

Torvalds' Folly

Read this message on the subject of C++ as a programming language from Linus Torvalds.
To give you a little context, this is the git mailing list (or rather, newsgroup) which is the revision control system they chose after all the controversy around BitKeeper (which was proprietary and not at all suitable for the Linux kernel.)
Torvalds and others are developing git from ground up and they have opted to use C as opposed to C++. This message here is Torvalds going medieval on some guy because he suggested that they could start using C++ features to make their software better.
He even mentions STL and Boost as samples of bad C++! This is not the first time I've seen him act like this (not the opinion, but the behavior) which might be expected from someone who has zero time for newbies, but the opinion. Man, is he wrong! He just doesn't understand that a language is just as good as the programmer. He seems not to realize the "zero-overhead" rule of the C++ language: that no feature of the language has any runtime overhead when not used.
Anyway, I knew Torvalds was a bad leader (because of his attitude towards free software (as opposed to merely open-source software)) but I still counted him as a brilliant programmer and engineer. I guess we cannot rule out the "engineer" part, because of the evidence in the form of the kernel, but the "programmer" part has become under a dark cloud in my mind.

Monday, September 17, 2007

Two Strikes in a Row

This morning, two important events were waiting for me when I got online:
  • Google.com were filtered out by some utterly stupid people (I'm running after those guys to take back the IDIOT award to give it to these guys!) but it was restored in less than 12 hours AFAIK.
  • Robert Jordan just died! What happens to the Wheel now? :-((

Sunday, September 16, 2007

Hardy According to Hector

Uncoffined...
Unkissed...
Unrejoicing...
Unconfessed...
Unembraced...

It's a turn of phrase that brings with it a sense of not sharing, being out if it, whether because of diffidence or shyness, but holding back, not being in the swim of it. Can you see that?

Monday, September 10, 2007

C++: Fun With Comments

There's much fun to be had with C++ comments, and a lot of seriously usable tricks there as well. Of course, most of programmers already know all I could tell about the subject, but nonetheless, I think I'll take a shot at bringing all the techniques I think might be useful together, and I might be able to use a few possible tricks that a possible visitor would possibly leave on this post!
The first thing any programmer has to realize about comments is that (as their name suggests)
Comments are not the code that the compiler doesn't see, but the sentences that a human would read.
Write comments (and code in general) for another human (or you yourself) to read. This generally means you should generally avoid too clever constructs that have no other advantage. I say it again: Write code for other humans to read, not the compiler to compile.
You can use special comments and tools like doxygen to generate useful, beautiful, always-up-to-date and comprehensive documentation of your source codes automatically, with little extra work (e.g. with putting a line with three slashes ("///") at the beginning and describing the purpose of a function before its prototype.) These kinds of tools make you appreciate the value of comments!
My first advice is never use "//" or "/*" to comment out a piece of code. Those characters are reserved for "comments", i.e for writing descriptions of your code! Always put another character (or sequence of characters) after them, and use different characters to distinguish the different situations in which you've commented out the code. For example, use "//0" and "/*0" for code that you suspect is incorrect, use "//1" and "/*1" for test code, and so on and so forth. Keep in mind that these are only suggestions. Any system you opt to use, must be documented somewhere. Write 10 lines to describe the meaning and connotation of the 10 different types of comments you use. Don't take this lightly! As time goes by and you write more code, you'll accumulate these rules and split or merge them, but your commenting rules become more comprehensive, more concise and more useful.
Anyway, suppose you want to comment a multi-line piece of code. Always put the comment openning and closing on a line by themselves. No code on those lines! Also, use "//*/" for the closing marker (instead of just "*/".) This way, you can uncomment and recomment that part with only a single character; a '/' that you add to or remove from the beginning of the openning marker. Look at snippets 1 and 2.
There are times that you want to switch between commenting two parts of a single line. In these situations, you can put "/**" before the first part, put "/*/" between the two parts and "/**/" after the second part. Like snippets 3 and 4, you can then switch between the first part being commented out and the second one by adding a single '/' after the comment before the first part. (Also note the parsing/formatting bug of jEdit on line 18!)
You can also do it in the slightly prettier way that snippets 5 and 6 demonstrate (I really think so!) but only if you want to switch between two multi-line segments of code.
Commenting large blocks with "/*" and "*/" has a major problem. The commented blocks don't nest. For this reason, I suggest the cleaner method of using "#if 0", "#else" and "#endif" blocks (snippets 7 and 8, but they lack the coloring.) This way, not only you can nest commented out blocks inside of each other and enable/disable them individually just changing the '0' to '1' (provided the outer blocks are not disabled) but also you can comment the commented-outness(!) of these peices, and you can use preprocessor macros instead of just '0' to be able to switch these segments on and off from elsewhere. The only problem is that many editors and IDEs don't process preprocessor directives and they won't colorify the disabled parts as inactive.
In your "comment" comments, you can use well-recognized keywords like "NOTE", "WARNING", "TODO" and "FIXME" to make their meanings more apparent and to searching for them easier. Just remember to use them neatly and consistently.
If you have more ideas for using comments, I'd be happy to hear about them and to include them here. By the way, anybody has a clean and pretty way of switching (commenting/uncommenting) among three or more segments of code?
   1://{Snippet 1}
   2:/*0
   3:    for (unsigned i = 0; i < v.size(); ++i)
   4:        swap (v[i], v[v.size() - 1 - i]);
   5://*/
   6:
   7://{Snippet 2}
   8://*0
   9:    for (unsigned i = 0; i < v.size(); ++i)
  10:        swap (v[i], v[v.size() - 1 - i]);
  11://*/
  12:
  13://{Snippet 3}
  14:    for (unsigned i = 0; i < /**/ v.size() /*/ v.size() / 2 /**/; ++i)
  15:        swap (v[i], v[v.size() - 1 - i]);
  16:        
  17://{Snippet 4}
  18:    for (unsigned i = 0; i < /** v.size() /*/ v.size() / 2 /**/; ++i)
  19:        swap (v[i], v[v.size() - 1 - i]);
  20:        
  21://{Snippet 5}
  22:/*0
  23:    for (unsigned i = 0; i < v.size(); ++i)
  24:        swap (v[i], v[v.size() - 1 - i]);
  25:/*/
  26:    for (unsigned i = 0; i < v.size() / 2; ++i)
  27:        swap (v[i], v[v.size() - 1 - i]);
  28://*/
  29:        
  30://{Snippet 6}
  31://*0
  32:    for (unsigned i = 0; i < v.size(); ++i)
  33:        swap (v[i], v[v.size() - 1 - i]);
  34:/*/
  35:    for (unsigned i = 0; i < v.size() / 2; ++i)
  36:        swap (v[i], v[v.size() - 1 - i]);
  37://*/
  38:        
  39://{Snippet 7}
  40:#if 0
  41:    for (unsigned i = 0; i < v.size(); ++i)
  42:        swap (v[i], v[v.size() - 1 - i]);
  43:#else
  44:    for (unsigned i = 0; i < v.size() / 2; ++i)
  45:        swap (v[i], v[v.size() - 1 - i]);
  46:#endif
  47:        
  48://{Snippet 8}
  49:#if 1
  50:    for (unsigned i = 0; i < v.size(); ++i)
  51:        swap (v[i], v[v.size() - 1 - i]);
  52:#else
  53:    for (unsigned i = 0; i < v.size() / 2; ++i)
  54:        swap (v[i], v[v.size() - 1 - i]);
  55:#endif
UPDATE:I was wrong about the parsing/formatting bug in jEdit I mentioned above. That's a Doxygen comment and jEdit handles it correctly. Oops!

Wednesday, September 05, 2007

Idiots on Steroids!

After the last presidential election over here, I thought I knew who the most stupid person in the world was, or alternately, the most stupid people.
Three days ago, I was proved wrong! I travel a lot (only between Mashhad and Tehran) and some of these trips are by bus. The bus tickets are sold online as well as in traditional ways. Let me add here that the online bus ticket selling system is brain-dead, but not quite as much as the train and airplane systems!
Anyways, as you might guess, I buy almost all of my tickets online, and this last time was no exception. Only this time I bought them from a bus company that I had not heard about before.
The online system works like this: you go to http://ssit.ir/ and sign in (WARNING: Internet Exploiter-only website!) and choose your city of origin, the bus company, the destination, date, bus, seat, etc. and make the purchase. It gives you a 12-digit reservation number that you present in the bus terminal along with your name, and they print out a ticket for you if the information checks out. It takes about 2 minutes online and 2 minutes at the terminal, and you don't even have to show an ID or something.
When I went to the terminal in Mashhad about 15 minutes before the departure time, I foresaw no problems. How wrong was I! I went to the counter for my bus line and asked them to give me the print of a ticket I had bought online. The guy said "OK, no problem. Give me your ticket." I thought he had misunderstood me for some reason. "No, I bought my ticket on the Internet. I want the hard copy now." (I didn't say anything about the concept of "hard copy" to him of course. He would have died of brain hemorrhaging right then!) He said "OK, but you have to give me your ticket first." I said that I don't know what he's talking about and he went on to produce a single grease-covered piece of yellow paper that was a printed snapshot of the web-page that contained the reservation number! I was astounded, but I kinda expected this (maybe I'll tell you later about the time I got on a plane without showing a ticket!) So I began explaining that that piece of paper was completely worthless and anybody could write that up in a matter of minutes. And that I have traveled by online-reserved bus more than a dozen times and all I had to provide to get my ticket was the 12-digit number. He went on and said the most stupid thing he could have said. He said: "But how could we get our money from the company that handles the online sales?" !!!
I did not laugh. I could barely contain my anger as it was. I told them to check their passenger records and see that a ticket with the same number that I was giving them and my name was in there. They called in one of their colleagues and after much conferring and discussion among themselves, they managed to view the list of the passengers for my bus, and guess what, my name was indeed in there. But this did not change anything at all. The morons still insisted that I needed to give them my "ticket"! I even suggested that they print two copies of the ticket they were supposed to give me, but no; they couldn't do that, because "their computer did not print the tickets," (which I guess means their "program" didn't print tickets) which is BS, because I know that their software is the same for all bus corporations. They couldn't even find the Farsi version of the "Print..." button (maybe the problem was the three dots? After all, three is too many!)
In the end, I went out of the terminal, found an Internet Café and printed the online confirmation page (with the buttons and menus and everything!) and brought it back to them. They took it with such looks of triumph that someone from outside might have thought they had taught me a valuable lesson on the mechanics of the universe. They wrote out a piece of paper for me, and finally I went on to the bus, half and hour late. My seat was changed and the bus still waited for another 15 minutes before finally getting on the way.
Now you understand why these people win the honor of the most stupid people in the world.

Sunday, September 02, 2007

Many Miles

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.
This part of a poem by Robert Frost sums up my current situation. I just hope that I don't fall for the woods or sleep.