Sunday, December 31, 2006

So you want to be a... anything!

I've spent my last two days watching popular science shows. I've started with the very bad and time wasting "What we still don't know" and ended up with the marvelous "Stephen Hawking's Universe". I've always had this fantasy of doing something that matters, maybe become proficient in the things I really like, but rarely do, like writing, or science. And, in the good old trandition of Sierra games, I've thought of a "So you want to be a ..." series, where average everyday people like myself could be shown how to become something they always wanted, in the shortest time possible. Something like a career guide on speed.

Well, I am certainly not the only one to have come up with this idea: Dr. Michio Kaku wrote an article about becoming a physicist. Well, he basically tells you you cannot become a physicist if you've already lost the train. But I disagree. If you really want something, you can achieve it, at any age, only you can't do it with support from others.

So, what do I want to become? I've written in my todo list to check out calculus, topology and noncommutative geometry. That is almost certain not to go well, but at least I plan to try (trying). Damn, I like to think of stuff and never do anything about it. I only like whinning more! But the question is: what do you want to become? Don't waste your time. And I am not talking about carrers, I am talking about the things that makes one define himself on. Like for me, I am a C# programmer. That defines me at this moment. I certainly am glad there is more to add to that, like other achievements or "I am a good person" or "I have felt true love", but I still wish I could add more. Maybe being a part time garage cosmologist wouldn't hurt. Dreams ARE important and they are surely unachievable only when you don't even try to achieve them.

Thursday, December 21, 2006

Lying for your life!

Ok, I am not the greatest child lover in the world. I don't want any children, not even to have sex with them. But when I see sites like this: 'Santa Claus does not exist' school tells stunned kids I can't help myself reply in anger.
Does anyone realise that while telling nice stories about Santa, or God, or Halloween or whatever, one is actually lying? When I read the above mentioned article, I immediately replied in irony that kids should believe in Santa and other increasingly idiotic things we usually are told when we're kids. And the list grew immediately to a stagering dimension. I stopped myself, censored some of the things I've written and sent the reply. I am curious if it will ever be published on the said site, as I've noticed that UK sites, including BBC, only publish the moderate or expected responses, especially if you mention you're not from the UK.
How did you feel when you found out Santa is not really a real person? Didn't it change not only the way you see Christmas and the world, but the trust you had in your parents? I am almost 30 and I remember the day when my dad told me an obvious lie and I realised, for the first time in my life, that my parents do lie to me, as opposed to what they've said to me in the past. A lot of the things I've been told during my childhood have been lies, and while there weren't bad lies, nobody desiring my harm in any way, they shaped the way I saw the world afterwards.
Every time such a fairy tale bubble burst, I felt more out of touch with reality, more insecure, sadder, disappointed. Don't do that to your children, no matter how obnoxious they are. So they don't let you sleep well, don't punish them by giving them false hope you just know will break their heart when they realise they have been fed with lies. Beat the crap out of them, it's safer, it hurts less.
Of course, I have no idea how a kid would develop if you told him everything. It is a frightening concept, but does one really have the right to shape one's reality as they see fit just because they don't like the one they live in? "Yes, daddy is going everyday to a shitty job, hating his shitty life, wanting to die, but lacking the courage to end it all." Would such a notion push a child to suicide or to a real life, one that is different from the one his dad hates?
There is no such thing as political corectness. Politics are about the acquisition and application of power. Will you give your child the option to apply his own power of the brain to his own chosen life or will you maim him in his infancy, by feeding him false information, seeding his mind with lies that will never go away, no matter how much he tries as an adult?

And as a small Christmas article that makes sense, check this out: The Real Story of Christmas

Wednesday, December 20, 2006

The death of Siderite's wife

Have you seen the movie "The Death of Mr. Lazarescu"? It is a Romanian movie about a guy that is taken from hospital to hospital in order to fix what seems to be a slow cerebral hemorrhage. Wonderful moment when, in the very end, the man is still living, but in a very bad state, and the movie ends. Because the title does say it all.

As a divine retribution for accusing the holidays of sucking, my wife had a car accident. Some female driver hit her while on the designated street crossing area. She is fine, thank you all, but for a clavicular fracture. This specific injury means that she can barely do anything by herself and I have to tend to her until the bone fuses together or she has surgery (I'll know for sure on Sunday, December 24th, when I take her to the hospital again).

Ok, back to mr. Lazarescu. As in the movie, the medical establishment is a dirty, underfunded, disorganised piece of crap. When I got the phone call, Maria was already at the hospital, waiting for treatment. The emergency hospital Floreasca was partially closed, due to reconstruction, and the only entrance was covered with signs that said "Access forbidden to visitors!". I was a visitor, but it was the only way in, so I phoned my wife and asked. I was supposed to enter through there.

I found her holding her right arm with her left, in obvious shock and pain, waiting... for what? She just had her radiography taken to her shoulder and they sent us to another section of the hospital. There they asked what has happened, and my wife explained that immediately after the hit she couldn't see well, and that she was afraid not to have a head injury. So they sent her back to the radiology room.
[small paranthesis] The woman doctor indicated we should go right, then right again, to where the rotating door is, in the middle of the wall. That was her female for first door on the right. There wasn't any revolving or rotating door anywhere![end paranthesis]
I was told to wait outside the radiology room until the male nurse would call us in. I waited, seeing three people appearing out of nowhere and entering in, before I got the nerve to ask the guy there "excuse me, is there a name calling, an order number system, or people just enter?". "People just enter", he replied apathetically. So I took Maria, pushed her in, to finally get her head scanned. All this time she held her injured arm with the other, no one even considered doing anything about it, even if we already had the radio image of the clavicular fracture.

Then we went back to the previous room where a doctor interpreted the scans, then sent us to another section, the one where they actually do something. We waited there as well, at least another half hour, in front of a door which said "we are in the middle of hospital reconstruction, we only have limited support, we prioritize people, do not enter, do not open the door, etc". Already knowing the drill, I opened the door and entered, taking Maria with me.

The actual fix was to make a figure 8 bandage around her shoulders, to keep the bones together. Then they sent us again to the radiology room, to see how well the doctor did, then we went back. All this was done without anestethic, even if it didn't hurt too much, and the only shot they gave her was an antitetanos shot for a little scratch on her leg.

You have to imagine this so called hospital, with rooms that had building materials in them and the whole facility smelling like a zoo. This is not a metaphor, I've recently been to the zoo, and the neglected reptile cages smell exactly how this hospital did. Maria reached the hospital at around 16:40 and we left at around 21:00, this being an «emergency» hospital.

The doctor also prescribed us some medicine, because they didn't actually have a farmacy there. So we had to take a cab, look for a farmacy, pay for the medicine, get back, take her home, etc. I then inquired on how will the insurance company (ING Bank, btw) cover this, since it wasn't her fault (it was determined by the police that it was the driver's fault) and we had to both miss work, pay for medicine, go to the hospital now and then by using a cab, etc. It appears that the insurance, which we dutifully payed for at least 3 years now, doesn't cover anything but the spitalization cost. No spitalization, no fucking insurance. More so, in order to take some sort of compensation from the driver, we must actively sue her, go through courts and so on.

Let me make a short synopsis: car accident, hospital, 4-5 hours spent for 3 X-rays, an antitetanos shot and a bandage, no insurance coverage. If my employers weren't good human beings (as most aren't) I would probably be forced to either neglect my wife or lose my job, and in order to somehow fix it, I should actively sue the driver and (without a job, maybe) go through courts, pay a lawyer, etc., which I don't really want to do anyway, since the driver didn't actually intend to hit my wife, she was just incredibly slow!

Did you like the movie? It's a nice holiday piece. Fuck!!!!

The funny thing is, Floreasca is actually one of the good hospitals. No doctor asked us for extra payment, each doctor or technician actually wanted to help, I am sure whatever they did, they did good work, but they do it in such a misguided, unfunded, disorganised matter. I mean, do I actually need to scan a bone, create a picture of it, carying it all around the hospital in order for another doctor to see it in the next room? It's like the middle ages in there!

There is this saying that the road to hell is paved with good intentions. None of the people involved in this story had any bad intentions, but we still got screwed!


Maria doesn't need surgery. Phew! We've changed the bandages to a more manageable type that is also adjustable in case it is too tight or too loose. We are going to the doctor's on January 2nd for another check. Then on the 3rd I am going to work X(. Anyway, I was going crazy sitting in the house all the time, helping Maria up and down, etc. (you have to appreciate me not going into the sordid details), so I guess it will be good.

Thank all the people that showed genuine concern over my wife's state and I hope you had better holidays than my own. ;)

Update 2:

X( We went to the doctor's again. It seems that the bones didn't fuse together and it mostly because the last bandage was too thick and thus ineffective. So Maria was right after all, she always is a good judge of character, that Petre doctor that made the bandage last time was all talk and nothing else.
More than that, it's not that she doesn't need surgery, is that after 4 weeks of observation we will know for sure. Doctors are certain it will heal, eventually, but the whole process gives me the creeps. I'll keep you posted here until she heals (or gets off my back! :) just kidding.)

Update 3:

Another visit to the hospital (with yet another doctor) was close to personal hell for me. The entire facility was packed with old sick people sitting in queues. This might not mean a hell of a lot to others, but I really hate these kinds of things. The only thing I hate more is being very hot. Sure enough, when we left from the radiology section to go to the actual doctor we reached and even more crowded room, which had the air conditioner turned to hot and with no open door or windows. Being very crowded, Maria went in and got out almost immediately. The x-ray looked better, the bones seemingly fusing. So the doctor send us home, told us to return in three weeks. Then we will know more. :-/ Well, at least there are some good news.

Earlier today I went to the family doctor (in Romania this is a doctor that is assigned to our family... and other thousands of others X( ) to ask for a medical break for Maria's work. I had to fought off sickly old people again in order to get to see the doctor, but after all I only had to take a paper in and return with another paper.
Of course, it wasn't going to be so easy. Apparently, the doc is supposed to give me a paper for the orthopedy department, they will give me the medical break letter. However, I need to take there yet another document to attest that Maria is hired somewhere. Why the hell would I need the papers for a medical break if she wasn't hired?! I say this while trying to ignore that if I weren't around Maria would have to make one trip to the work place to get this latest paper, then go to the family doctor to get that paper, go to orthopedy, etc.
Getting to the orthopedy department reserved a special surprise to me: it was going to open at 14:00 hours. Of course, it was 8:00 and I went there especially in order to find the family doctor who worked mornings and get to work immediately after. So that would have meant another trip for Maria.

Update 4:

Ok, last update on this post. Maria is now (1st of February 2007) ok. Her bandages are off, she is painfully using her hand and she goes to kineto and physio therapy. We had to pay around 50 euros to be able to do that now and not after a few weeks (with the other people waiting to get well, but without money) and, of course, that's not a sum that will be covered by the insurance. The medical insurance actually payed for nothing at all. Isn't that great? Fortunately, the driver agreed to pay us the medical expenses so we won't sue. We wouldn't have sued anyway, I think. Although for my avid readers I might have started a whole Romanian legal system series :)

'Interface not registered' when building a project

Check out this little link: You receive an "interface not registered" error message when you try to build a Setup project in Visual Studio .NET
Why this is happening in the first place, I do not know, but the fix worked wonderfully. I was trying to build a Net 1.1 setup vdproj with Visual Studio 2003 and I got the error: "Could not find the file '[file that was obviously there]' 'Interface not registered' ".

Sunday, December 17, 2006

The X-lions.

Hey! I have internet at home, at last! I dedicate this entry to the Titannet guys :)

Browsing the web I stumbled about this almost incredible story, one that shows in no ambiguos terms that evolution does run continuosly and that it can happen very fast: The superlions marooned on an island.

Long story short, a group of lions were marooned on an isolated island for 15 years. Instead of dying out they've adapted to a new prey (the buffalo), becoming swimmers, more intelligent pack hunters and stronger as individuals. They have become a lion subspecies in 15 years flat.

Friday, December 15, 2006

Metamorphosis - by Franz Kafka

This book is odd enough. Finally finished reading it a few days ago, I remained with the feeling of not getting it. What the hell? A guy is turned into a bug, then his family tries to take care of him, but after a while they just stop being nice to the poor insect and it finally dies.

But then, thinking about it, I noticed the symbols in the book. It is all about a dark hopeless capitalism as in Kafka's day, one that can only be coped with by roaches. Working continuously while being at the whim of whatever greedy employer you have, supporting family and servants and a bigger house than needed because you don't dare have a spine. In this sad little story, the main character did not once revolt against the situation in which he was. Actually, I am wrong, he did revolt against some trivial things like taking a picture from his room or wanting to see his sister playing the violin, thus exiting the room where he was confined.

The book itself ends with his family feeling relief of getting rid of the big roach in their house and having a better life because each of the members had to take a job to get through this.

Conclusion: this didn't feel like a very good book, but it was good enough. It is also a classic, this being the reason for reading it. So, it's worth a read, if you can take the time to think about it.

Wednesday, December 13, 2006

Holidays suck!!

Yes! At popular demand and enormous pressure, the World Sucks series is back!
Todays episode: holidays! The word itself comes from holly and day, but in the meanwhile it collapsed into this one word that has nothing holly in it anymore. It's all about buying stuff, planning vacations in the "season" when all prices are inflated and all nice places are assaulted by noisy tourists (like yourself) which makes them less than nice, getting job time off in the same damn time with everybody else (and being considered not a team player if you want to work while all the others go away) and, last but not least, all kind of deities mixed together with local folklore to create a special kind of brand for each particular miserable disgusting day of each bloody holiday.

Accept it, people, holidays suck! It's this type of awful planned and allowed liberations that show the true nature of slavery. Holidays have become so much embedded in our culture, that we measure our own time and pleasure by them. If there is a holiday, you must enjoy it! If you don't you are a weirdo and if it ends you must stop enjoying anything. Get back to work, you lazy bum! I see people that expect those few free days from work like a child awaits the cndy from the sweets dispencer. What about the other days?! They are also yours. You can decide what to do with them. You can stop feeling miserable in any given day, you can miss on office work and stay in bed all day any time. I completely understand that some employers might not agree with this and even some self employed work alcoholics that think the world spins around them might growl at me from their dark den, but that doesn't make them right!

Holidays suck because they take away freedom, in it's most basic sense. You are allowed to not go to work, you are allowed to buy things that in the middle of the year you wouldn't even consider buying (ask yourself why?) and you are allowed to spend it with your family and friends. What? You don't have family and friends any other day? What if you don't want to spend your free time with family and friends? What if you just want to be left alone, to make a cool software program, play a game for 24 hours straight or watch the entire third season of Battlestar Galactica continuously from start to end? Then you clearly don't have the holiday spirit. Well, fuck the holiday spirit! It sucks!

Gerrold, David - The Martian Child

Wee! I've received a PDA from my bestest of uncles (which will soon work for Google and I am so proud of him). Ok, back to adult mode. I've used the newly acquired PDA to read books! I've started Metamorphosis by Kafka, but the file was incomplete by accident, so I ended up reading The Martian Child.
It's a small text, 80KB in length, and it's not really sci-fi, but it's nice. It's the kind of warm, easy to read text suited for bus rides. It involves a sci-fi writer adopting a child who says he is a Martian. During the entire text, the author struggles with the eerie feeling that the child was actually right, even if there is no way to prove it.
It was nice enough.

Thursday, December 07, 2006

InvalidCastException error in an ASP.NET 2.0

Sometimes, when you use ASP.Net 2.0 with MasterPages, UserControls and dynamic loading like LoadControl, you get a silly error: Unable to cast object of type 'X' to type 'X' where X=X. Of course, it is a versioning problem. Some of these errors appear in the VS2005 designer, when the designer uses an older version of a library, but also when trying to open the web page in a browser.

Microsoft has released a fix for this: , but, to quote the same source: "This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft .NET Framework 2.0 service pack that contains this hotfix.". So you risk screwing things up.

The issue seems to be mostly a developer problem. That means that during programming, you get this error when you keep changing stuff in the project. A client might get this error if an update of the site created this problem. The iisreset utility won't work. Recompiling locally and reupdating the site usually solves the issue.

Monday, December 04, 2006

The most efficient way of getting rid of security issues: jail hackers for ridiculous amounts of time!

Another suspected NASA hacker indicted tells the story of a Romanian hacker who entered 150 NASA computers, then made them display messages boasting the hack. Of course, the US government immediately took initiative and fixed all their computer security holes, suing the corporations that made the buggy software sued the Romanian hacker for "conspiracy and nine counts of computer intrusion", mounting up to 54 years in prison, if found guilty on all charges. I won't even go there. It is just ridiculous. A few years ago, an American soldier killed a man in a traffic accident and he was immediately flown back to the States, where they found him guilty of a misdemeanour and he didn't even do jail time. Read again he KILLED a man.

But there is also some justice in the world: U.S. marine sentenced to 40 years for rape in Philippines. Now, of course, the poor guy didn't do anything as serious as hacking into a computer and boasting that he did it, so he gets only 40 years.

Bush in Space, part 2.

A couple of weeks ago I posted this: Bush in Space. Now I come back with a few nice articles that show what the future of space is likely to be. Or not to be.

First of all, a news article from May 2006 US seeks laser to shoot down satellites talks about a "secret" U.S. project that uses lasers to shoot down "enemy" satellites. Considering the ability of most nations to put satellites in orbit, I can only conclude that they mean Chinese, Indian, Japanese, Russian or European satellites. Probably, the Chinese thought the same thing, and here is where this article: China Attempted To Blind U.S. Satellites With Laser comes in. It talks about the Chinese trying to shoot down (or at least blind them considerably) U.S. satellites spying on them. This story was "dug" here. You can see in the article that the US already plan for a "constellation" of satellites to replace the vulnerable spy satallites they already have in place.

Now, most comments on this are usually either moronically nationalistic, either uselessly anti-American. However, there are people that have actually put thought into this. How come the US is augmenting this "Cold War" with China, when they have such a lucrative economic bond. Is it because they see a more business oriented (read democratic) China as a more maleable one? A good consumer market just ripe for the US culture? Or is it because they actually fear a democratic China, as a very serious competitor. Most analysts observe that placing and defending stuff in space is way harder than destroying stuff in space. Even lasers work in space, but low tech solutions like plain old rubble would work just as well. This is described as asymmetric warfare. When even the little guy can fight back.

But what does all this mean? The US have all but openly dismissed the ISS. The only science projects that they do on the station are related to the human habitation of space, which leads me to believe they either plan on colonising the Moon or even Mars (a man can hope) or they just don't care about space any more than their precious spy satellites. How does the entire "teritory" concept work in space? How can you attack in space and not get into a ground war at the same time? These are questions about things one might think do not affect us, but they do. From weather to global positioning, from TV to the Internetand the telephone, they all come through space. You have to imagine a world where space wars are common and plan ahead against it. We cannot color the sky, we can't afford to.

Wednesday, November 29, 2006

Kafka on the Shore, by Harumi Murakami

I've just finished reading this book, in Romanian translation, and I found it nicely written, but not exactly my type of book. For me, art needs to draw you into atmosphere and conclusions, not to be understood only if you make the effort to draw the conclusions yourself. Yes, I am lazy, but don't get me wrong, I like art. It's just that art is supposed to communicate. I may recite a beautiful poem in Romanian, but if my audience is English, it wouldn't do any good.
So my review on this book is as follows: it is well written, freely written (I can sense throughout the book that Murakami has an open mind, not clogged by clichees and prejudice), it draws you into the atmosphere. But there is where it stops. I know there are deeper meanings in the things that happen throughout the book, but they are not properly explained. I can draw beautiful conclusions and see very deep things, but it would be my merit for making the effort and looking deep, not the writer's. And I wouldn't be sure that it's what the writer intended telling in the first place.
Read it if you are into atmospheric books :D and if you like dark, philosophical discussions.

Tuesday, November 28, 2006

Fast String Distance (SIFT) Algorithm

This article is obsolete, a better version of the algorithm has been published: Sift3

While researching different ways of measuring the distance between two strings, or how different they are, I've found of course the Levenstein algorithm. The problem with it is that it is slow. Searching more, I've seen some algorithms that seemed fast, but I didn't have the time or brain power to understand them. So I've devised my own algorithm, called SIFT. You might think the name comes from Siderite's Intelligent and Fast Technique, but it comes from the English word 'sift'. :)
How does it work? Well, the common scenario in comparing strings is that someone made a mistake, a typo. So in principle, the two strings should be very similar in order to be worth comparing them. So what I do is this:

foreach phase
remove identical overlapping characters
shake strings
return number of shakes + the length of the longest string between the two.

There is an optimisation towards the safe side: if the sift similarity is big enough, perform the constly Levenstein distance.

Ok, it might not be so clear, let's take an example:

Step 1: remove all identical overlapping characters (sift)

Now we have smaller words to check, let's suppose there was a typo, that means that part of the one word is offset with one or maybe two characters from the other. So we move them a bit, that's a 'shake'.

Step 2: shake

Oops, no overlapping characters. We do this one or two times more and there is no result, so...

Step 3: return result

There you have it. The sifting algorithm, because it resembles sifting grain.

Not satisfied with such a simple example? Let's take another:
Click here

Tests have shown it to be pretty close to Levenstein, at least in the cases that matter, while being substantially faster.

Monday, November 27, 2006

Running processes in background

Long story short: the BackgroundWorker object. Available in .NET 2.0
This is a Microsoft tutorial on using BackgroundWorker:
How to: Run an Operation in the Background
This is an older and more Windows Forms basic tutorial on multithreading:
Safe, Simple Multithreading in Windows Forms, Part 1
Safe, Simple Multithreading in Windows Forms, Part 2

BackgroundWorker has the DoWork, ProgressChanged, RunWorkerCompleted, and Disposed events. You need to assign at least one method for DoWork and one for RunWorkerCompleted, then run
The DoWork method should do something like
while the RunWorkerCompleted method should do anything related to the GUI. There is also a CancelAsync() method, to try to stop a background operation.

Also, here is an article about a possible bug in BackgroundWorker, but I haven't replicated it on my computer.

Thursday, November 23, 2006

I'm a dink!

According to Wikipedia, dink, can mean a lot of things, ranging from small boats to small penises. A dink is also a creature in the SpaceBalls parody of Star Wars. But is seems that the main use of this word right now is for "Double Income No Kids". That's me! Well, I have a cat, but he doesn't generate any income. You can also find this particular demographic group called DINKY, which is a more dynamic acronym that takes into the consideration the future possibility of offspring(Y=yet). The Americans seem to prefer Dink, while the UK and their former colonies Dinky.

Apparently being a dink means that one is part of a high-earning couple who choose not to have children and are therefore able to afford a more expensive consumer lifestyle. A dink is considered a lot of times as being also a yuppie, or Young Urban Professional, with pejorative connotations of selfishness, materialism, and superficiality.

So, apparently, I should :

  • generate an income (checked)

  • have a mate (checked)

  • the mate should also generate income (checked)

  • both generated incomes should be high (yeah, right)

  • selfish (checked)

  • materialist (not really)

  • superficial (yes!)

So, I have demonstrated creating by oneself a Cosmopolitan test by using Wikipedia. Are you a dink? How dinky are you? Take the test! :D

Wednesday, November 22, 2006

Building a GridView, DataGrid or Table with THEAD, TBODY or TFOOT sections

There are 726 articles on Google when you search "gridview thead". Most of them, and certainly all the first ones, talk about not being able to render thead, tbody and tfoot elements for NET 2.0 table based controls. But it's not so!

Each table row has a property called TableSection. If you set it to TableRowSection.TableHeader, TableBody or TableFooter, the specific tags will be created. Let me show a quick example of creating a THEAD element in a gridview:

And that's it. This kind of behaviour works for the Table WebControl and everything that derives from it or uses it to render itself.
However, the rendering of these elements inside the Table control is done simply with writer.RenderBeginTag(HtmlTextWriterTag.Thead), which gives no one the ability to change from .NET code the attributes of those sections. You can't have it all! You can use CSS, though. ex:
.tableClass thead {

The Marsians are attacking!

In 2001, July, a strange phenomenon in the form of red rain occured in southern India. While the official explanation of this is that desert dust has been brought by winds and brought down by rain, Dr. Godfrey Louis, a proffesor of physics for the Cochin University of Science and Technology thinks otherwise: it's all about alien microbes that arrived here by riding a comet.

The story might seem a bit far fetched, but even BBC News wrote about it. And this guy released a science paper about it after what appears to be five years of study. Take a minute to read it, it's only 18 pages long. What seems odd to me is that, even if he maintains that the red rain particles are biological in nature, he doesn't mention anything about reproduction, nor of any attempt to revive them.

Anyway, it seemed interesting enough to blog about it. There is a more down to Earth and detailed article about it in Wikipedia. You can also find here is the transcript of a news report together with animations that talks about Cardiff University scientists confirming the presence of some sort of DNA in the seemlessly devoid of nucleus cells.

Monday, November 20, 2006

Multiple IE versions on the same computer

Usually, when I decide to blog on something, I do the testing and researching and installing first, then blog about it. But now I intend to use this cool site:
which boasts with installing all IE versions since 3.0 (oh, beloved 3.0) on the same computer without any problems. Since I am not a trusty guy, I blog about it before, then, if no one ever hears from me again, it means that no browser on any computer worked anymore after this :)

Well, without further due, let me proceed :-SS
Extra info:

Step 1: Installing IE7.
Of course I had to validate my copy of Windows to download it, then I had to download all updates (even if I went to Windows Update right before installing IE7), then wait until it searched my computer for malicious software, then installing everything. You can't imagine a smoother installer. It just tells you to wait and does everything in the background, showing you meaningless text labels, a cool progress bar and, of course, asking you to close everything before and restart Windows after the installation.
But it worked, and I am not writing this from Firefox :)

Step 2: Installing multiple-ie-setup.exe
Wow! It took around 1 minute to install everything. Of course, not everything is going as smoothly as planned. First of all, I can't see Blogger (and suposedly not any other cookie using site) in IE6.0. Then, it redirects me to a nocookies.html files that doesn't exist :-/ But that's a Blogger issue. The Options menu in IE6.0 is actually the IE7.0 menu and the settings for cookies cannot be overriden. Actually, you can, but the settings won't save.
After looking at the TrendoSoft site, I've noticed that this bug is considered solved, even if some of the people seem to continue to have problems. So I've tested more throughly. Session variables seems to be saved, but Blogger continues to take me to the nocookies page. Also, AjaxPro, the ajax library I am using, doesn't seem to work with IE 6.0.

All in all it seems a pretty functional program. However, the type of sites that I am building have certain characteristics that seem not to work with it. I will try to log on TrendoSoft and get the problem fixed, but I guess Yousif did the best he could so far and resolving every issue I have will be hard if not impossible.

Tuesday, November 07, 2006

TransactionScope in .NET

Amirthalingam Prasanna's article about the transactional model in NET 2.0.

As far as I understand, the old declarative ADO.NET Begin/RollBack/CommitTransaction model has become obsolete and a new TransactionScope model is used in NET 2.0. You have to add the System.Transactions.dll file to your references.

Basically, the C# code is like this:

using (TransactionScope scope=new TransactionScope
(scopeOption,transactionOptions,interopOption)) {
// do database ops

// if everything is alright

scopeOption is an enum of type TransactionScopeOption, with the options Required (requires a transaction and uses if there is already on open), RequiresNew (always opens a new transaction), Suppress (don't use a transaction, even if one is open)

transactionOptions is of type TransactionOptions which has two interesting properties: IsolationLevel and Timeout.

interopOption is an enum of type EnterpriseServicesInteropOption and specifies how distributed transactions interact with COM+ transactions.

But what about the old NET1.1 framework? Doesn't it have something like that? Here comes Alexander Shirshov with help:
TransactionScope in .NET 1.1

.NET Framework 3.0 has been released!

Release announcement

NET 3.0 is NOT working on dotNET 3.0 or C# 3.0. It's just the old Windows Communication Foundation, Windows Presentation Foundation, Windows Workflow Foundation and Windows Cardspace into one package.

It is optimised and designed mostly for Windows Vista though and be sure you uninstall any CTP versions before installing this one.

The online documentation for the Windows SDK for Vista RC1 and the .NET Framework 3.0 is also now available.Here are the direct links to the documentation for the .NET Framework 3.0 technologies:

Thursday, November 02, 2006

Friday, October 27, 2006

Sort datatable with the Select method when column names contain commas

Well, basically, you can't do it.
I am looking at the internal ParseSortString(string sortString) in the DataTable object of NET 1.1, where the first thing the method does is to split the string by commas, then check for square brackets. This insures that there is no way to sort datatables by columns with commas in their names. The funny thing is that the filtering expression is treated like royalty by an ExpressionParser object, and allows column names with commas inside.
Now let's check the code for NET 2.0. It's identical.

The solution is a little annoying code like this:
private DataRow[] SelectSafe(DataTable dt, string filter, string sort)
  var columns = new string[dt.Columns.Count];
  for (var c=0; c<dt.Columns.Count; c++)
    columns[c] = dt.Columns[c].ColumnName;
    if (dt.Columns[c].ColumnName.IndexOf(',')>-1)
      dt.Columns[c].ColumnName = dt.Columns[c].ColumnName.Replace(',', ';');
      // assume that the column name was bracketed correctly in the select
      sort = sort.Replace(
        "[" + columns[c] + "]",
        "[" + dt.Columns[c].ColumnName + "]");
  var dr = dt.Select(filter, sort);
  for (int c=0; c<dt.Columns.Count; c++) {
    dt.Columns[c].ColumnName = columns[c];
  return dr;

I am sure there is more elegant code, but this seems to be the only solution so far except manually sorting a DataTable.

Wednesday, October 25, 2006

MSDN Briefing Bucharest 24th of October 2006

The whole meeting took place at the Titulescu room at RomExpo. They had 4 desks that spanned the alphabetical ordering of software firms participating, so the entry was really comfortable. They gave us a pen and a little notebook to take notes, too. The whole meeting lasted from 9:00-16:30, then there was an hour of free talks.
My general impression of the briefing was good. The presenters were enthusiastic and talked about: application development on Windows Vista with NET 3.0 and Sharepoint and Office 2007. The new Microsoft XML office format was presented, programatic methods of accessing and creating them, how to mix Sharepoint and Office in order to create quick Excel based web sites, etc. The most interesting part, though, was of course the last. It presented the advances in programming technology like the C# 3.0 features and ADO.Net vNext. Too bad I've already read about those technologies, but the enthusiastic presentation mode (alas, SPOKEN TOO LOUD) was refreshing.
The information was as compacted as possible, but there was too little code for me, even if most presenters seemed to have the same hatred for marketing slides as I did.
There were also 30 minutes of coffee break and 1 hour of lunch. The lunch food was very good and varied, from chinese apetizers like sesame meatballs and Shanghai chicken to sandwiches, salads and sweets. Taking into account that I've been to a similar Microsoft thing in Milano, where they barely gave us some sandwiches in plastic bags, this was truly great.

Monday, October 23, 2006

NullReferenceException in GridView BuildCallbackArgument when trying to render it dynamically with paging

Whoa! Big title there. This article applies to errors in ASP.NET 2.0 when trying to dynamically render a gridview with paging.

I have been trying to "Ajaxify" my web programming and I've found that the easiest method is to wrap everything I need in Web User Controls, render the controls, then send the rendered string through ajax to fill some innerHTML.
Well, the fine people at Microsoft thought otherwise. I have been trying to render a web user control with a gridview inside it for 3 hours now and nothing helped. I kept getting a NullReferenceException when calling GridView.DataBind and the StackTrace showed it originated in the BuildCallBackArgument(int) method.
Nothing helped except actually decompiling the code of the GridView itself. I've found out that it called a method in the Page of the control, in other words it needed a page. I gave it a page, but then another problem occured that I'd already solved here. I already had a parent page that overrode the offending method, so the final code is this:
ParentPage pp=new ParentPage();  // where ParentPage is a Page with VerifyRenderingInServerForm(Control control) overriden so it doesn't do anything
pp.EnableEventValidation = false; //another silly error
uc.Page = pp; //uc is the user control needing rendering

Bush in space.

It just had to come. It was inevitable. Bush has signed a "tough space policy" which basically says the US will hold space itself hostage as they do water, air and economy on Earth.
Just read the BBC article and draw your own conclusions. Before they even explore it, the Americans seize space as their own, all in the name of "protecting" their space sattelites or whatever.
So next time you god damned university students want to launch your geek science projects into space, you'd better clear it with Bush. Or Rumsfeld.

Thursday, October 19, 2006

Javascript replace function

Unlike .NET C# (or most other programming languages), the Javascript replace function only replaces the first instance of a string. To replace all the instances, you need to use regular expressions.
Simon Willison's Weblog contains a good article on this.

Basically, if you use str1.replace(str2,str3) it will return str1 with the first occurence of str2 replaced with str3. If you use str1.replace(regexp1,str3) and the regular expression has the g modifier it will return str1 with all matches of regexp1 replaced with str3.

A regular expression looks like : /searchpattern/modifiers.
You can create a regular expression from a string by using the
new RegExp(str2,modifiers)

The problem comes when you want to create a regular expression from a variable that may contain regular expression escape sequences. Here is Simon Willison's function that "escapes" the string in order to use the RegExp syntax safely, slightly modified to contain the '^' character:

RegExp.escape = function(text) {
if (!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '<', '>',
'(', ')', '[', ']', '{', '}', '\\', '^'
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('\\') + ')', 'g'
return text.replace(arguments.callee.sRE, '\\$1');

Example: str=str.replace(/\\/g,'\\\\') (replace slashes with double slashes)

Wednesday, October 18, 2006

Oh, come on!

This is an image from the BBC web site and the title of the BBC article is Rice launches Korea crisis tour and the caption is Japan and the US pledge to work on implementing sanctions on North Korea, the US Secretary of State says.
I knew politicians are assholes, but how can you smile like that while deciding pledging to impose sanctions on some other nation? Look at her! You'd say she's hugging her daughter while petting the cutest cat ever. And she's imposing sanctions! And the title sounds like she has just opened a tourist resort. That whole picture is wrong. Geez!

Tuesday, October 17, 2006

Checking your web app against different browser resolutions

    I have found three basic methods:
  1. Use an online type of viewer.
    You select the resolution, type in the URL of your site, then sit back and relax.
      I see a lot of problems for this method:
    • you don't want everybody to know you are working on a site

    • you don't want the site to be open to the public while you work on it

    • you need an internet connection

  2. Use an external program.
    BrowserSizer is as good as any. It's free and easy to use. You select the resolution and it resizes your IE window accordingly.
    The only problem I see is that you need the program. You install it, it messes with your browser settings, etc.

  3. Use a javascript script in the IE addressbar:

    Unfortunately, the zoom messes up quite a few things, including fixed table headers or custom javascript controls. However, I do believe it is the best solution for most situations.

ASP.NET DefaultButton on LinkButton or ImageButton and Mozilla Firefox

You may experience unexpected results when you open a Web page that is in an ASP.NET 2.0-based application in Mozilla Firefox and the DefaultButton property is assigned to a LinkButton control or an ImageButton control

Just a reminder of a bug I am likely to encounter. The obvious solution is to use ControlAdapters or inheritance to create LinkButtons and ImageButtons that are rendered as buttons.

FxCop - automatic check of NET code.

I've accidentally stumbled upon FxCop, a Microsoft free tool that analyses the generated NET code (.exe or .dll) for bad design practices.
While many of the errors and warnings I got were related to casing, a lot of them were not and they had come with links, extended information and solutions. The rules that FxCop has help you to make members static if none of the instantiated object's properties or members are used in it, use case insensitive String.Compare instead of comparing two ToLower strings, or StringBuilder in loops, use NET 2.0 constructs instead of 1.1 ones, etc.
I find it at least interesting and I intend to use it in my future software projects.

Missing on spam!

I've recently changed my email address, added spam filters both on the server and on the client and moved all known addresses into a special folder, leaving any unknown source (thus mostly spam) emails alone in the inbox folder. This resulted in me not receiving spam email for at least a week. Now I kind of miss it. I mean, I feel something is wrong, like some essential part of my life is gone. How weird is that?
And apparently, I am not alone. 231 pages in Google have "I miss spam" in them.

Thursday, October 12, 2006

Virtualize! Good bye, cruel real world!

ASP.NET 2.0 has this nice feature called Virtual Path Providers. What it
actually does is enable you to get your site files from anywhere using an
override of the VirtualPathProvider class.

Virtualizing Access to Content: Serving Your Web Site from a ZIP File
This is a very nice article where a Microsoft guy shows how to run a
complete ASP.NET site from a ZIP arhive. Just two lines of code in
global.asax , a standard web config file and a ZIP arhive.

This opens up a lot of possibilities, like reading the ASPX or CS files from
a class that creates them dynamically, or reading the files from multiple
sources at once. Yummy!

Tuesday, October 10, 2006

Nullable types in C# 2.0

I vaguely remember reading of nullable types in the C# 2.0 "what's new" documentation, but somehow it slipped by me. Now I've stumbled over this useful new feature and I can explain it for a bit.
Here is the Microsoft explanation.

Basically you can declare any value type as nullable by using the syntax <type>?.
Example: int? x=null;
There is even a nice operator ?? that acts like the SQL isnull function.
Example: int y=x ?? 0;
The two above examples are the short for the following:
System.Nullable x=null;
int y=x==null?0:x.Value; int y=x.HasValue?x.Value:0; OR int y=x.GetValueOrDefault(0)

    The Nullable type has some nice methods:
  • GetValueOrDefault([value]) - gets the default value or the specified value when the nullable type is null

  • HasValue() - something like is not null

There is no IsNull method to the Nullable type. Also, x=null makes x==null true, as opposed to, let's say, the SqlInt32 type.

Monday, October 09, 2006

Thomas Covenant, by Stephen Donaldson

I've just finished The Runes of the Earth, the first in the last series of the Thomas Covenant saga. I must say that the style and content changed significantly from the first books, therefore I felt the need to review the whole saga as I see it now.
I liked that in each book new ideas were introduced, they weren't just reprints of the same story. The moral basically stays the same, but everything else, sometimes even the lead character, changes.
From the second series, a new model of writing was used, thus all the books in one series make out a story rather than one book per story. I didn't like that, especially now, when I have to wait for the next books to be published in order to see what is going on. What I also minded was the need of the characters to shed tears over all kind of stuff. I think the author overdid the misty eyes scenes. A lot of the creatures and the culture from the first series was completely obliterated in the second, but it seems to be making a come back now.
The good thing about it, though, is that the writing gets better with each book. In hindsight, the first book seems amateurish compared with the rest. No more singing, more story, less descriptions. It is interesting that the last series of the Chronicles of Thomas Covenant the Unbeliever was published 20 years from the end of the second. Donaldson justified this as taking time to become a better writer before ending the story.
Let's see how it goes.

Tuesday, September 26, 2006

MSN messenger random picture issue

For as long as I can remember, the MSN messenger changed my picture in a random fashion. I was setting it, then at the next restart, another was there. The last version I am using is 7.5.
Today, I finally found out what caused it: Tools → Options → Security → "This is a shared computer, so don't store my address book, display picture or background on it".
It is nice to know that if I want to keep the same picture on the messenger I have to also store my address book on the computer. Microsoft seems to think they are of similar importance :-/

Monday, September 25, 2006

Sunday, September 24, 2006

Osama bin Laden, a modern Hannibal?

Spurred by two TV shows about two famous people, I came to the conclusion that Osama bin Laden's history has a lot in common with the one of Hannibal Barca, the Carthaginian general, just as the history and technological development of the US has a lot in common with the Roman Empire.
Think about it!
Hannibal was born in Carthage, but he left it when he was nine years old. He hated the Romans with all his being and when he attacked their empire (which then span the Italian peninsula) he did it by hitting targets deep within their teritory. Using innovative strategy, he defeated the strong Roman army by using its flaws: size, but no coordination; force, but not precision. With a small mercenary army that also used elephants, he surrounded the huge Roman army and destroyed it. He then demanded support from Carthage, in order to siege and capture Rome, but the politicians of that state decided that it would be safer to not antagonize the Roman Empire and didn't sent support. Powerless to set siege to Rome, Hannibal could do nothing but watch how the Romans build another army which will then defeat him. In order to avoid capture, after years of exile, he commited suicide.
Osama didn't leave Saudi Arabia from childhood, but he was exposed to the teachings of returned exiled teachers, who brought different ideas. He came to hate the Americans and when he attacked them, he struck deep within their teritory. Using innovative strategy he defeated the US antiterrorism machine by using their flaws: size, but no coordination; force, but bureaucracy. With the smallest of terrorist groups that also used air elephants (heh, I stretched it out a bit, but it holds), he struck a major blow to the confidence of the US. He then demanded support from the Arabic nations, which decided to not antagonize the American Empire. We all know what happened to the ones that did. Powerless to continue his campaign, Osama watched as the US machine learned from its mistakes, rebuilt it's antiterror army and then defeated him. After years of exile, he dies, avoiding capture through death.
Now, what it even more interesting is that Hannibal's actions led to the expansion of the Roman Empire into Iberia and Carthage and the refining of their army and war strategy. This eventually led to the Roman Empire conquering so much and becomnig the most famous and technologically advanced civilisation of its time. Carthage was completely raised from the surface of earth, destroyed by Romans and plowed clean. If we were to continue these parallels, the American Empire should now have a more powerful and precise war machine, it should conquer or at least neutralize any threat from the Arab nations, then proceed on conquering the world. Some poor country should take the blame, as Carthage did for Hannibal, and be completely ravaged by war. Does it sound familiar? Brrrr...

Other related links from people that had similar ideas:

There are even more links, in total Google showed 573 links that contained Osama bin Laden, Hannibal and not L*ecter. But since people spell Osama differently, others make it clear that it's not the guy from the movie, thus causing false positives and there are a lot of sites that just enumerate famous people, the count cound be completely different.
Happy thinking!

Tuesday, September 19, 2006

God is a brand

It was one of those moments when you think of nothing and suddenly something distillates into conscience. It sounded too good and too important not to find it on the net so I googled for "God is a brand" and I found 17 entries out of 98.200 (yes, Google is getting weirder and weirder).
Now, when it hit me, it seemed like something really smart, but now I understand it is just obvious; I was the dumb one for not getting it sooner. People don't have holly wars on Linux vs Microsoft, they are having brand wars on Jesus vs Mohamed.

What started me is looking for furniture for my new rented apartment (expect a huge blog in a few days) and I found the same models in two different places, but with two different prices. My wife said that it was because the more expensive ones were better made, but they really weren't.
Then I realised that most commerce is run on brands, it's nothing new, it goes on from the beginning of trade. You buy from where you know it's good, or from where stuff makes you look or feel good. People are attached to the spirit of the thing, not the thing itself (well, most people). The Stradivarius violin can be made better and cheaper using modern computer modelling and automated manufacturing, but people care about the original Stradivarius, made by a human, a human that represents something. The enormous price of Stradivarius violins is not due to their utility, but the faith of the people in the original builder, the artist. Ring a bell? Original artist? The Creator? Yes! God!
The epiphany came when I explored the idea in my mind. People doing idiotic things because of their faith, the experiment where people were given to wear a t-shirt for 10$ and refused to do it when they heard it belonged to a serial killer or the one with the children that were given a "perfect replica" of an object that they loved and they prefered the original or the simple superstitions like avoiding number 13. Movies, as well, usually portray clones as imprefect, evil, empty of true purpose or life. People remain married for decades, respecting and even loving the other person, when all rational motives to stay together have withered in time. Of course, this is also linked to the way human instincts work, but nevertheless, there are people who do it and people who don't.
Somehow, the intricate mechanism of the brain puts values on associations rather that on the objects. I think this is important. It is obvious that people have inner representations of different things and people, but I've always assumed that the inner value is put on the thing not on the associations. I now believe to have been wrong. It makes sense: there is no absolute value, only when you put something into context it reveals its value.

Therefore, returning to the God is a brand issue, it seems to me that the branding is made on oneself. You don't buy the product, you become the product. You brand yourself with a god, then act in accordance with its meaning. Then losing one's faith would be like becoming an clone of yourself, empty of meaning. It could explain the feeling of loss of a person, when "there are other fish in the sea". It makes old people be grumpy, since no one truly understand the different deep meanings that they've attached to objects and people and behaviours.

I can't even ask myself "Do brands suck?". It would attack a defining feature of humans AND animals alike. This warrants a look into the idea of religious feeling in animals. It is not possible for everything to suck. Religion sucks, though.

Monday, September 18, 2006

ASP.NET 2.0 Parser Error Message: Access to the path '[something.cs]' is denied

I was stunned today to see that a site that I was working on was not starting because of this idiotic error:
ASP.NET 2.0 Parser Error Message: Access to the path '[something.cs]' is denied.
And further down:
No relevant source lines

The only thing I remembered doing was close the project in Visual Studio and work on another. I tried starting the site with the URL, without loading it into Visual Studio and the error occured. If you search on the net this error, you will see that there are a lot of articles that talk about the ind*exing ser*vice, but I stopped it a long time ago. So what was going on?

  • The file was accessible

  • The file was not opened by another application

  • I could freely delete/remove/modify the file

In desperation I compared the Security settings for this file with other files in the directory. To my surprise, there was a major difference. The files that were accessible had a lot of users with access rights to them, the file that gave the error had around three.

I have no idea what caused this. I just copied the same rights from the other files to the problematic one and it worked. I am using Visual Studio 2005, Resharper and SourceSafe. Do you also hear the Twilight Zone soundtrack?

Friday, September 15, 2006

Programatically trigger event in Javascript

It's is done in two different ways: the IE way and the DOM way.
IE way) really simple, use element.fireEvent(eventName,[eventObject]), where element is a HTML element and eventName is something like "onclick";
DOM way) really complicated. A short example:

function simulateClick() {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById("checkbox");
var canceled = !cb.dispatchEvent(evt);
if(canceled) {
// A handler called preventDefault
} else {
// None of the handlers called preventDefault
alert("not canceled");

As you can see, you need to create the event, then initialize it, then dispatch it.

    Things you need to take care with:
  • in the DOM model the event name is not prefixed with "on". In the IE way, the event is prefixed with "on". ex: DOM:click IE:onclick.

  • in the DOM model the event triggering does everything the event would have done, like setting a value, in IE it does not. ex: triggering onclick in the above example would check or uncheck the box. In IE you need to change the value yourself.

This is code I did to programatically click a checkbox and also trigger the onclick event:

if (box.onclick)
if (box.dispatchEvent) {
var clickevent=document.createEvent("MouseEvents")
clickevent.initEvent("click", true, true)
} else
if (box.fireEvent) {
} else
} else box.checked=!box.checked;

Wednesday, September 13, 2006

Tuesday, September 12, 2006

Debugging Javascript with Visual Studio or other tools

Yes, you've read right. You can debug Javascript with Visual Studio. Here is a blog entry that blew my mind when I've read it: JavaScript Debugging.

Basically, what needs to be done is first go to Internet Explorer Options and disable Disable Script Debugging (Internet Explorer) (No, I didn't mistype, there is a checkbox that needs disabling and it's called Disable...) in the Advanced section. Be careful not to disable the other script debugging box, only the Internet Explorer one. Then, when an error occurs, the system asks you what debugger to use. You can choose Visual Studio 2003 or 2005 from the list (provided you have them installed :) ), trace, put breakpoints, etc.

There is also the javascript debugger keyword, which fires a debugging window at the specific location, so it's like a breakpoint.

Googling the net I've found that there are both free and commercial Javascript debuggers. There is even a free one provided by Microsoft: Script Debugger for Windows. One, unfortunately shareware, product that I saw recommended on the forums is 1st JavaScript Editor.

The only disadvantage to this, that I've seen, is that any javascript error will result in opening the debuggers window, without the ability to check "ignore errors on this page" or anything like that. It could be annoying while browsing. Yet I am surprised that I've heard of this method of Javascript debugging only now.


If it seems the list of debuggers does not appear anymore (or never did), go to Visual Studio Tools -> Options -> Debugging -> Just-In-Time and check the "Script" checkbox.

If it seems Visual Studio doesn't correctly find the right Javascript line to debug when entering debug mode, start the web site without debugging and then choose Microsoft Script Debugger. It gets the current line right, but has a difficult to use interface (Hint: use the Command Window). Of course, you have to download and install it first :).

CSS Friendly ASP.NET 2.0 Control Adapters

CSS Friendly ASP.NET 2.0 Control Adapters is a little project run by Brian Goldfarb and what it does is use the power of the ControlAdapter object to change the way ASP.NET controls get rendered. They use CSS layout to control the way things look and try to remove the old table based format.

While this could be a good thing in some situations, it could be harmful in others like low resources or weird changes in the CSS laws. I let you decide for yourselves. And while the ControlAdapter approach is very elegant, I've used this concept in creating my own controls when needed by overriding ASP.NET classes and using simpler code. Also, these Control Adapters are in Beta 2 stage. Major changes are still in the works.

So don't trust it blindly, but do check it out, as it is a worthy and honorable quest :)

Monday, September 11, 2006

Friday, September 08, 2006

Ring of the Lords

I am used to commenting on the things I see in life. I do the comments on movies on IMDb, but I haven't made an account on iblist, since I read so ridiculously few books that are not technical and IbList doesn't seem to be so complete and organised as IMDb.
So I will blog about books until the time when I see myself worthy of an iblist account.

Spurred on by a need for fantasy I've just finished Lord Foul's Bane, by Stephen R. Donaldson. Remarcably well written, it is obviously inspired by Tolkien's Lord of the Rings. There are lords, there are rings and there are brave and honorable quests. At times this becomes annoying, when characters feel compelled to sing songs (and the author actually wrote the lyrics in the book) or sacrifice themselves in rather ridiculous ways. I didn't like the way Lord of the Rings was written because of all the useless details in it. Lord Foul's Bane, the first in the Covenant series, is a bit like that, but not as bad. The main character, Thomas Covenant, is also most interesting than Frodo, having come from our world and being full of pain. Unfortunately, in the most important parts of the book, Covenant does things as moved by a puppeteer rather than by his own logic and good sense. This makes the plot seem a bit too unreal. The fantasy world, though, is pretty well done, with sensible magic and purposely made to look like a mirror image of our own, with all the bad things in our world not present and (I would say) all the good things being bad there. Like stopping from your journey and starting singing songs that are sometimes labeled as gay in the book.

I've also finished the first two volumes of The Spook series (The Spook's Apprentice and The Spook's Curse), by Joseph Delaney, which is interesting and well written. In this one, a feudal world is plagued by evil witches, ghosts and banes. The man that takes care of this, like a Dark Ages ghostbuster, is a spook. He does the job that no one wants to do, everyone needs him, yet everyone hates and fears him, including and especially the Church, which in this series are portrayed as a bunch of corrupt and amateurish incompetents. The main character is a young child who, under the guidance of his more than ordinary mother, becomes a spook's aprentice. There are twists in the plot and the magical domain is well conceived. Unfortunately, the plot is rather straightforward, with young useless brat finding out he has unsuspected power. But they don't call it heroic fantasy for nothing, so , there it goes. I liked the series and I expect to read the third book (The Spook's Secret), released this year, as soon as I find it.

I've also read the first two Eragon books. While the fantasy world is very complex and well written (especially taking into account the age of the writer) the magic "technology" is a bit hard to wield. I hope the author refines the way it works in ways that don't turn ridiculous. Christopher Paolini is a young American writer of Italian origins, born from a wealthy family of book editors. He started writing Eragon at 15 and finished it at 19. It should come to no surprise that the book became a huge hit; it is well written, but the marketing of the book was intense and privately funded by the author's family. There is an Eragon movie due to be released in 15 of december this year.

A quick mention of Christopher Stasheff, a rather prolific fantasy writer, who tries a combination of magic and space science-fiction. Unfortunately I couldn't finish his first book (Escape Velocity), the first of the Warlock of Gramarye series, as I found the writing style rather annoying. I've read good reviews about his latest books, though, and I plan on starting a bit further up, maybe with the Rogue Wizard series.

The end. :)

Wednesday, September 06, 2006

How to format your GridView autogenerated columns

The GridView is nothing more than an oversized DataGrid. The internal concept is completely rewritten, as far as I see, though. For example, Columns are not called columns anymore, they are DataControlField. Well, I stumbled upon one situation where I needed to format the autogenerated columns in a GridView. Normally, you could take the Columns collection and change the DataFormatString property for each column, but autogenerated columns (or AutoGeneratedField) are not part of the Columns collection. More than that, AutoGeneratedFields are nothing more than BoundFields with lots of useless restrictions on it like being a sealed class and throwing errors when trying to change some properties (like DataFormatString).

The first step is getting hold of the autogenerated column. Luckily the GridView control has a virtual method called CreateAutoGeneratedColumn which returns a AutoGeneratedField. So create a control that inherits GridView, override this method, take the generated field in the base method, change DataFormatString. I couldn't find any way to do that except with reflection. I noticed that the value of the DataFormatString property was stored in the ViewState of the AutoGeneratedField, so I used reflection to get to it, then I changed the value.

This is the code:
protected override AutoGeneratedField CreateAutoGeneratedColumn(
AutoGeneratedFieldProperties fieldProperties)
AutoGeneratedField field =
StateBag sb = (StateBag)field.GetType()
BindingFlags.GetProperty |
BindingFlags.NonPublic |
null, field, new object[] {});
sb["DataFormatString"] = "{0:N}"; //or the format string you prefer
field.HtmlEncode=false; //see update
return field;

The BoundField object formats values differently depending on html encoding. If the html encoding is enabled, then the value is transformed into a string, then the formatting is applied. That means that number formatting will NOT work when html encoding is true.
That is why I've added the field.HtmlEncode=false; line above. A more secure option would be to make the HtmlEncode property depend on the field.DataType.

While this works, I don't recommend doing it like that. I am using it because I have custom user controls that inherit from the GridView and I need to cover the AutoGeneratedColumns=true case. It is much easier to generate your columns yourself from the DataSource using BoundField objects (Or any other DataControlField objects) that you add to the GridView.Columns collection.

Street sweepers suck!

Welcome to another lesson in suckology! Today's topic is Manic Street Sweepers from Hell (or Bucharest).
When the weather is good I go to the office by bike. Yeah, I am a hot shot biker. My bicycle is state of the art junk and I can ride it even through major Bucharest street holes. Ok, I am being a bit unfair, as they are rebuilding all the streets now... So let me rephrase it: I can ride it even through destroyed streets that are in the process of being rebuilt.
When I first bought my bike it had no wheel protectors and I quickly realised that driving through wet or muddy terrain tended to leave a long straight line of wet dirt from my trousers bottom to the top of my head. So I bought these metal things that protect my wheels and myself from things like that. Now I can even go through moderate puddles and I only wet the bottom of my pants legs. Which is ok, I am tech guy, I'm married, I don't really need to look good. You did sense the irony there, right?
So everything was set for riding my bike. I could even hear the Queen song while going to work. To my immediate surprise I found the streets were wet! Not only in the morning, when I go to work, but also in the evening when I return. The culprits seem to be [echo]Street Sweepers!

Ok, a small technical paranthesis. All this is done to protect the mighty citizen from dust. Or so they say, actually, this is more of a EU directive or standard and, as we Romanians love to brown our noses, the City Hall felt compelled to comply. Street sweeping, in theory, should be done to clean the street of debris (by using machines with brooms) which also employ some system to keep the dust from rising up while brooming. Most employ water, the most advanced use vacuum generation and filtration.

Well, Romanians decided to split this process into two separate parts: one machine wets the street, the other sweeps. Even better, while one wets one street, the other sweeps another. The result is dry sweeping that generates immense quantities of air borne dust and wet pavement. As you might not be familiar with Romanian technology, let me explain to you what these street wetters looks like: big water containers with sprinklers. And not your average street wetter sprinkler system with a row of small water sprays, but one big water pipe with holes in it!
What this does is create huge puddles of water in the crossroads, where the trucks stop, but the drivers are too lazy/stupid to also stop the sprinkler system. Also the roads are far from flat, so in all the little depressions in the asphalt other puddles occur.

Well, how does this affect me and why these abominations suck? Let's take them one at a time:

  • water makes my bike skid on the pavement. While this might be acceptable in other countries, with flat roads, maybe even with bicycle lanes, in Romania you have roads with waves, especially on the sides, no bicycle lanes (and the only one in Bucharest is used by old people to walk on) and the sewers are right in the pavement, they look like big square 5-10 cm deep holes. So, if on bicycle, you might want to break from time to time

  • water makes cars skid on the pavement. It's actually called hydroplaning, when the water goes between the car wheel and the road. Some drivers might want to control or at least stop their car when they wake up and see they're on a collision course with a bike.

  • new research shows that water on the pavement elevates the temperature comfort level, making it even easier to affect oh, let's say, people that drive on the said roads when the heat is up and don't have air conditioning in their car. Or a car.

  • there is no way to get around a street wetter with the bike. The only solution is to wait until all the cars go past it, then go all around the other side of the street to avoid getting sprinkled. Luckily, these dumb ugly beasts are slower than my bike.

My obvious conclusion is: Street sweepers suck!
I am citing from a random link: PM-10 / PM-2.5 class street sweepers are in a developmental stage. This type of sweeper will pick up dust particulate down to 10 micron is size. The city's Envirowhirl PM-10 street sweeper utilizes a combination of mechanical and air sweeper features to pick up debris. They also utilize an internal system of dry filters to retain all dust larger than 10 microns within the sweeper's hopper. No water is used for dust control.
I hope they bring something like this in Bucharest soon and that it doesn't suck. Much.

Monday, September 04, 2006

Crocodile Hunter Steve Irwin dies

'Crocodile Hunter' Irwin killed

An incredible and sad news for me, Steve died from the sting of a stringray that (ironically) has venom with no lethal effect on humans. The barb on the end of the fish tail has up to 20 cm and it probably penetrated the heart or has hurt some other major organ in the chest area. Steve is the second man ever to die from a stingray in Australia, the previous death being in 1945. Ironic, stupid, sad.
It is amazing that his death affects me so much, when other big people's deaths have only made me a little sad. Maybe it's because he was young, in the middle of his life, having so much to look forward to. I've also admired his insane passion. I am rarely passionate about something and I admire any person that can shine a little, like Steve seemed to do 24 hours a day.
At least his memory will remain intact from the ravages of old age. My deepest condoleances to his wife and two children.

Saturday, September 02, 2006

Programming vs. Software Development

You know the annoying feeling when you want to find something on the net and you can't find the proper search keywords? It's like trying to find the Triple X movie rather than porn flicks. It happends a lot when you want to find something that you know is named in some way, but a new buzz word is emerging and you either don't find everything you need or you find a lot of unrelated stuff. Like trying to find people talking about computer programming, but you end up with all these TV programming sites. Now try to find how to turn your PC into a TV by programming :).

Anyway, searching on programming led me to wonder about the difference between programming and software development in describing my own job. As previously mentioned, there are other sorts of programming and development except computer ones and to top it all, people mean different things when using these concepts in the software context. Wikipedia, for example, takes "programming" and gives me the page for "computer programming". It then takes software development and takes me to software engineering (which in my mind are different things).

How does google see this? Let's search:
TermPage count
Software development175.000.000
Computer programming19.700.000
Software engineering80.700.000
Software developer27.400.000
Computer programmer4.270.000
Software engineer22.500.000

So it seems that there is a lot more programming and programmers than software development or software developers, but add "computer" in front and there is less. But that's because no one bothers to say "computer" in those cases.

And there is more. While software development/engineering start to go towards "designing programs", computer programming goes towards "typing code". I believe that is happening because in large software companies there are a lot of people writing code, but very few that actually have a say on how the program is to behave or what technology to use. I am watching Microsoft presentations and they are ridiculing the "old school" programmers that type their code while the new breed of software developers point, click, drag, drop and everything works in a few minutes. People that actually think through what algorithms to use and how it all works and optimize lines of code and try to think like a compiler from time to time are grunts to be enclosed in cubicles, while those who think how the general program should work, create UML diagrams of interacting business objects are the lords of their domain.
That makes no sense to me, especially since the drag and drop people use software delveloped by code typers. Or it does make sense in the way that software development has become a feudal industry, like most industries become shortly after they become mass consumed. They have an elite, a clique that behaves like aristocracy, while most members of that industry work their asses off in the employ of these people. This gives a whooole new meaning to the term software revolution :)

So what is this job that I am performing? Am I just a meta-computer? Something high level that understands what it must do and obeys blindly by using a computer? Why is it that I like to code? Is there a difference in my mind between software and a program, so that the term software developer scratches my ears while programmer boosts my ego? And why do most people feel the other way around?

These are questions that I will probably be asking for a long time. Meanwhile, take a look at this wikipedia page, which I found informative: Programming paradigm. Also, consider this little link: Javascript 3D where you can find the explanation on how to do a Wolfenstein like game in Javascript, with only 5 kilobytes of code. You might want to wait a bit until it loads completely or use Mozilla Firefox. I noticed it works faster. Can't believe it? Check it out! That's what programmers do!

Tuesday, August 29, 2006

Balchik rules, Albena sucks!

I have just returned from a holiday in Balchik, Bulgaria, and this is my view on it.

You might have seen a commercial or heard a friend that Albena and Balchik are a great place to visit and spend your holidays. Even if they are separated by only 10 km the difference between them is the difference between heaven and hell.

Albena is the standard seaside commercial resort, with wide beaches occupied by a string of expensive hotels, with jerks attempting to speak to you in your native language while trying to sell you junk at high prices, a place invaded by tourists and with poor service at any shop, as they are owned by companies and operated by hired help. The useful things you can buy at Albena are of very little variety, meaning that almost every shop has everything you can buy, all drinks are either Pepsi or Coca Cola, etc. Albena is a franchise, and besides the natural reserve (which is a nice forest patch) and the Tracian treasure (that I didn't really go visit), there is nothing nice there.

Balchik, on the other hand, is a small piece of paradise. It is actualy a town, a rather old one, with small houses (and villas) sprinkled onto an almost abrupt seawall. The beach is very small and private, while the shops in the area are operated by their owners, which are usually very nice people. The prices are almost half of anything you meet in Albena and the tourist numbers are small during the week and medium during the weekend. Another good thing about Balchik being a town is that you have both seaside hotels, small villas, large villas, apartments for rent or purchase, high profile restaurants, small cozy restaurants, cheap supermarkets, etc. So you have everything you need. The view is spectacular, with a tasteful combination of mountain and sea.

In conclusion, I highly recommend Balchik as a holiday destination or (as I fantasised during my stay there) a remote place where you can buy a house or apartment and write in the quiet atmosphere of the small town.

Now, for the detailed impressions from Balchik

Leaving Bucharest

Both me and my wife wanted a nice holiday where we get to experiment as much as possible, so we decided against an "all inclusive" package. So we arranged with people from Balchik to house us, while we took transportation separately. Searching on the web, we stumbled upon Balchik Holidays, a site owned by a young nice couple, Val and Marta, operating a small local tourism company with very decent prices. As you will see later on, they treated us fairly and nice and we recommend them if you need to make similar arrangements. We decided on Corali as a transportation company. Our opinion of them is poor to very poor. They are plagued by lack of proper organisation, delays in transport and drivers that don't know the cities they pass through. I will give them the benefit of the doubt, though. Maybe there are situations when they perform well, but this was not one of them. Unfortunately, I can't really imagine a Romanian company that would do a lot better, so don't expect too much from the trip to and from Balchik by bus. It could be a good idea to look for a company that goes to Albena, then get a 4 leva bus to Balchik.

The bus left Bucharest at 8:30 and, enough said, arrived in Balchik at 18:00. The bus started from somewhere in Transilvania, though, so there are people who spent a lot more in the bus than we did. Immediately it became apparent that the well organised passanger list contained 51 names. The bus itself had 50 seats. That meant that one lady got her money back and spent the entire road on a small chair with no back placed amidst the rows of seats. I also don't know who makes these buses. While they look nice and are air conditioned, I couldn't fit my legs properly the entire trip. Even if I am a rather tall guy, the length of the femur bone shouldn't be much bigger than the one of a smaller guy, the lucky guy the buses are designed on. I think the highest age at which I would have been comfortable in those seats would have been 14 years old.

Ok, enough with the seats. The bus starts from Bucharest, goes to Constanta, leaves the country through Vama Veche, then proceeds to Balchik. The highway to the sea is not yet finished, so there were delays there, then the customs, which must be "greased" to let us through. The customs officers reached a so high level of confort that they took money while we all looked through the windows of the bus. We could have had cameras or something, but they didn't care.

Once we reached Balchik we were deposited in a parking lot placed in front of the road towards the Botanical Garden. If I am to continue my religious analogies of heaven and hell, that spot is purgatory. It is the most 'Albenised' place in Balchik. You have restaurants that boast their menus along with greetings in Romanian and waiters that try (annoyingly, I might add) to speak Romanian or whatever your native language happends to be. The prices there are medium to high, the service depends on the place.
For example I was terribly disapointed by the service at Taraleza, a small restaurant that was praised in a Romanian TV news story. The only Romanian they knew was in the greetings outside, the prices were high, the crab rolls they gave us make my wife sick, the tripe soup they gave us had very little tripe in it and (what bugs me most) I asked them for garlic and they brought me a small cup of a clear liquid. They refused to bring me sour cream, they said the soup had enough (as they would know). I poured the entire cup in the soup, only to find it a moment later uneatable. The 'garlic' sauce was garlic in vinegar.
The Sea Horse, the restaurant right in fron of the parking lot, had the same tripe soup (even the amount and shape of the tripe bits were uncannily similar), but they brought dried red pepper bits and a sauce that contained yoghurt, as well as garlic and , of course, vinegar. That was more acceptable and I could even feel the garlic inside.
As a paranthesis, Tihia Kat, or at least this is how I remember the name, a serbian grill restaurant on the seaside, have a garlic sauce made from sour cream and very little garlic.
But back to the parking lot, except for their monetary exchange, you shouldn't really use anything there. Besides, when you will leave Balchik you will have extra levas (the Leva is the Bulgarian money) and you will have to wait for the bus (which will be late) so you will be forced to sit somewhere.


When the bus entered the town, we got scared. There were communist style blocks of flats, really ugly ones, and dirty garbage filled road sides. But that's just on the outskirts. As you will see, Balchik is actually made of two distinct parts: the side near the sea, which is the old part of the city, with houses and queen Maria's summer residence, and the expansion zone, where you will have blocks of flats, schools, a large super market, etc.
Our two rooms apartment was 500 m from the beach, as advertised. What was left unsaid is that the road is a continous hill at maybe a 30 degrees slope. That resulted in muscular pain for the first two days, but we quickly got used to it. What was unexpected was that the pain felt in the lower part of the leg, which is actually very little exercised. And I should know, I ride my bicycle to work.
This side of the city is a combination of modern construction techniques and old stone roads and walls. If you are a computer programmer and you build maps for 3D games, like shooters or, better yet, quests or MMORPGS, then you should definitely go to Balchik and your software company should pay for it. There is something to be said about stone stairs that are hidden from view by the fact the walls are made from the same exact material. If you stay more than a day or two, you will come to know not only the streets, but also these hidden stairs that you can find all over the place.
We also had TV cable in our rented apartment. Something was wrong with it, though, as only a few channels were clearly visible. And, even if I did want to relearn Bulgarian, I couldn't watch anything but National Geographic, Zone Reality and Viasat History. I even stumbled upon a show about a bus going down hill without breaks, entering the water, skidding 80 meters, then drowning most of the people in it. Nice show, huh?
Val and Marta were very nice, they took us for a dinner and they explained the main things we needed to know about the town, then they gave us the house keys and left us be. They weren't a bother in any way and hopefully, neither were we to them.


There was sun there. And lots of it. If it weren't for my wife, I would have cowered in fear in the room, trying to fix the cable. Luckily, she rules my life, so I went down to the beach every morning, then we ate in a restaurant, then we had long walks through the city. If you are like me, you should not disconsider the power of the sun lotion. They seem to have different strenghts marked by weird numbers. Just take the highest strength you can find and put it all over you. Else you get your skin burnt. And, if you are like me, you hate having oily things on you that smell like flowers and squeezed animals. Get over it. Not being able to touch anything or having any type of water except very cold one seem hot is not cool. (Pun not intended)
Balchik is truly beautiful. Formerly part of Romanian teritory, it was chosen by queen Maria for her summer residence. That means a huge domain was filled with beautiful gardens and a few nice mansions were built. The buildings themselves are not interesting, the small trinkets that are linked to the queen or to her house are nothing more than money wasters, but now the domain was turned into a Botanical Garden. Even if less organised than the one in Bucharest, it is a lot more interesting. It combines slopes, plants of all kinds (including cactae), water falls, a high view of the open sea and the all present stone stairs and hidden passage ways.
The town itself looks a lot like a more crowded version of Maria's residence, with fisherman style houses sprouting amongst the stone roads and plants. This is something that the Romanian seaside lacks: plants. Even Albena had beautiful trees and forest patches near the sea. Romanians destroyed everything that wasn't cheap commercialism.
The prices were all in leva, which was more or less half a euro, and stotinky, hundredths of a leva. Energizer drink: 1 leva. Average restaurant meal: 7 leva per person. Taxi ride: 1-5 leva (for the same distance). Beach umbrella: 3 leva. Beach chaiselong: 3 leva. (as opposed to Albena where a chaise was 5 leva, a pillow was 3 leva, an umbrella 7 leva, etc.) Evening meal from the supermarket: 5 leva for two people. Restaurant bread slice: 20 stotinky.
I have no idea why every Balchik restaurant asked us for the exact number of bread slices we wanted. I asked smilingly for one bread and they brought me a slice. When I asked for ten slices all the waiters turned towards me like they have seen the devil. "Are you sure?".
The sand on the beach was very fine, as well as the sand beneath the water. There were two days after what we gathered was a storm in the open sea, when the shallow water was filled with algae fragments, but it wasn't terribly annoying. The entire Golden Sands-Albena-Balchik beach is in a golf, so there are no big waves and the beach is somewhat protected. The water was warm and pleasant.
People on the beach ranged from very fat people coming in families to skinny young girls. Not many girls, though. The ones that were acceptably attractive were more slim than sexy. There is no distinctive Bulgarian genome. People can look like Turks, Russians, Romanians or anywhere in between. Balchik has amazingly few gipsies.
Language: all Bulgarians know Bulgarian. Some of them understand English, some of them understand Romanian. I guess that some of them understand German, since all the menus were in Bulgarians, English and German, but I didn't try it out.
Music. I have been informed that a few months ago there was a rock festival in Balchik, White Snake and The Scorpions sang there. But I found that this was not a good enough explanation for the fact that almost every song in the town was an American 60-70's song. It wasn't annoying, but it was uncanny. I've even imagined Teal'c observing that the music technology of the planet seemed to be 30-40 years behind our own.

The Dark Side

Search for the supermarket Akvilon, on Hristo Botev street. It marks the start of the dark side of Balchik, the place of ugly grey blocks of flats. They do have regular cable and internet, though. Akvilon does provide for anything you need, as it is similar to Billa or MegaImage shops. The prices are lower than anything you get in the old part of the city, but not by much.

The End

We left on monday, the bus was supposed to pick us up at 18:30 from the parking lot, they were there, but only arrived in Balchik. We had to wait until 20:00 for them to go to the Golden Sands and Albena, leave their passengers, then return. We arrived in Bucharest at 2:00 in the morning.
What else can I say except thank you for sticking to the very boring end of my notes on Balchik. Maybe I will add more as I remember.

Special Notes

  • Cats - Balchik is a town of cats. Everywhere you go you meet a cat of any conceivable color except green. Most are accustomed to humans and grateful for any petting, playing or, of course, food

  • Bread - restaurants give you bread in slices. They ask for the exact number of slices. One bread means one slice.

  • Ayran - in Romania, ayran is a liquid yoghurt drink with salt. In Bulgarian, airan means yoghurt. So you will be able to see Danone Airan. They do have a sortiment of liquid salty yoghurt that is very tasty in rather unpleasant plastic 500ml or 250ml bottles. Ask for airan at Morsko Oko. They used this variety. Then you can buy it at a supermarket

  • Boza - there is a drink made (I guess) from sweetened wheat called Boza. I can't imagine any person except an insane child that could drink boza and like it.

  • Music - most places were tuned to Radio Edno (radio 1) and they played mostly songs from the 60's-70's.

  • Garlic - beware the garlic sauces. They are likely to contain less garlic and a lot of vinegar

  • Romanian speaking waiters - beware! Even if there are some exceptions, Bulgarians trying to communicate in Romanian usually want to sell you overpriced or underquality stuff

  • Taxi drivers - good luck trying to convince them to start their meters. Try not to give them 5 leva for a trip.

  • Botanical Garden/Maria's Castle - you may be intrigued by the ticketing system there. You need to buy a ticket of 10 leva to see a small garden, then advance to a ticketing booth to get another 10 leva ticket for the castle and the actual botanical garden. At the entrance to the castle you will be asked for both tickets. You can't buy them there, you need to go back 10 meters to the above mentioned ticketing booth

  • Muscular pain from climbing up and down Balchik streets - a massage helps, try pressing more on the painful parts. It doesn't help too much though. Walking another day is useful, also.

  • Bus rides - if you are taller than 1.80m, ask for special seating for your legs.

  • Car rides - the Balchik streets are at 30 or more degrees slope. Drive carefully.

  • Toilets - most of the bars and restaurants in the town have the annoying habit of charging for the use of their toilets

  • Albena - it sucks. If you want to go there, there are regular minibuses to Albena, Golden Sands or Varna

  • Recomended restaurants: The Blue Lion , Morsko Oko

  • To avoid: Taraleza, the Irish Rover, the cafeteria in front of the Irish Rover, the bar in Queen Maria's residence.

  • You might notice in Balchik a lot of printed A4 posters glued upon light poles, gates, bulletin boards, etc, representing dead people and when they died. It seems to be a local habit of commemorating the deceased.