Monday, December 31, 2007

Partial Readings: Smalltalk Best Practice Patterns and The Knowledge Management Toolkit

  • I have started with a book recommended by many sites about software architecture and design as a must read: Smalltalk Best Practice Patterns by Kent Beck. It is well written and I can see why it attracted a lot of people, even if there aren't so many Smalltalk programmers out there: it is written for use! That means that the book has less than 200 pages, but each of the specific patterns there are laden with references to others in the book, some even in the next chapters. That's because the book itself is structured to be kept nearby and consulted whenever a new project is started or in progress, not something that you read and forget in a bookshelf, gathering dust.

    However, the patterns presented are sometimes useless for a C# programmer, some being already integrated in language and some being not applicable. The fact that Smalltalk works with Messages further complicates things. I did eventually open a link to #-Smalltalk, but who will ever have time for it?

    I have decided that rather than reading this book and forgetting or not getting many of the things inside, it would be more efficient searching for a similar book that is more C# oriented.

    So, bottom line: great approach, both literary and technical, but a little hard to use for one such as me. Anyone know of a C# Best Practice Patterns book?
  • My next attempt was in the wonderful world of management! Yes, I was approached by their people, apparently they want me to join them and rule the galaxy. Maybe if they wrote more concise books!!

    The Knowledge Management Toolkit: Practical Techniques for Building a Knowledge Management System
    starts interestingly enough, describing the need of every company to build a way to retain knowledge against employee turnover or plain forgetfulness. Basically what I am doing with this blog. But it goes further than that, quantifying the return on investment for such a KM system, describing ways of rewarding people and encouraging them to use it (it is not something done automatically).

    All great, but then it kept going on telling me how the book is going to change my world, rock my boat, help me in my business... after reading the preface, the introduction, the "how it's structured", the marketing bullshit, the first chapter (full of promises about the next chapters) I was completely bored! If there is any technical description of what to do, when to do it, how to do it, why , etc, I didn't find a trace of it in the first chapter. Reading on my PDA from a badly scanned txt file didn't help either.

    Besides, I got more and more frustrated. I barely have the time to scratch all I planned on doing in this holiday (while getting nagged on by the wife, the cat and whatever friends I got left) and improving the company workings is not my responsibility. I am the god damn coder! I write code! I have a management system all of my own and I get my ROI by googling a frustrating bug and discovering I solved it a month ago myself and wrote about it here.

    So there! If you have a business it is good to have a repository of actual knowledge (a.k.a. processed information) and encourage people to use it so that they don't take all their experience with them when they leave your sorry cheap ass company! I've summarised the entire book for you! I am not reading it anymore. It hurts my sensitive techie soul!

A Quantum Murder by Peter F. Hamilton

A Quantum Murder comes to continue the story of Greg Mandel, psychic detective. Does it sound tacky? I agree that the subject is not the best possible choice, but the writing is good, Hamilton style: scifi social speculation, action, a detective story that makes the reader wonder what will happen next and whodunit!

I personally did enjoy the book, but it wasn't even close to the latest and more hard scifi writings of Peter Hamilton's. Maybe it's just me, but mental detectives in a post apocalyptic corporate world just doesn't do it for me. Maybe that's why The Nano Flower's first chapter starts with Suzi doing tekmerk stuff ;)

Again, the second volume of the three Mindstar books is stand-alone, making it easy to read even if you didn't read the first book. It is basically a scifi policier.

Friday, December 28, 2007

Mindstar Rising by Peter F. Hamilton

Another great book from Hamilton! This is part of the "Greg Mandel trilogy", that meaning there are three books to show for this particular side of the Hamilton universe, and unlike his later work, Mindstar Rising is actually a stand-alone book. You can read it without its next two parts and understand it as a single story. I've even started to read A Quantum Murder (volume 2) and Hamilton is making the effort to summarize what the characters did in the previous volume.

I understand the dilemma facing such a prolific writer: should one break a story in stand alone segments, thus cauterizing story arches and trying to put every single idea into single puny volumes? Should one bore the readers with summaries of previous volumes? Or should one write huge three volume books that you need to read in their entirety to understand anything? :) It would be a hard choice for me, as well. All I can say is that I enjoyed the big stories as well as the more common way of writing one book stories and reminding the reader of previous stories. I highly recommend the Seafort Saga for this particular style, even if it grows old by the eighth volume. Consider it, though, I was attracted to the story by accidentally reading volume 3 and understanding all of it!

Anyway, back to the book that I was reviewing, damn it! Mindstar Rising describes a post apocalyptic Earth, where global warming and subsequent social and economic disasters brought civilization to the brink of dissolution. A psychic ex-military, now working as a private eye is asked to help in finding the source of industrial sabotage and from then on it just gets more complex and thrilling. I wouldn't say that this is one of Hamilton's better books, though. Even if the book is definitely fun to read, it pales in comparison with Night's Dawn or the Commonwealth Saga. It is more like Fallen Dragon in style, although I do hope it doesn't end in the same ridiculous way.

More to come as I read the next two books.

Thursday, December 27, 2007

Pro .Net 2.0 Code and Design Standards in C# - by Mark Horner

book cover This book started great. It outlaid a structured view of how a software company should function, from the way one designs projects, to code and documentation standards. I really hoped this was the mother load: a book that would show me how a "standard" IT company functions on every level. It wasn't. Mark Horner started it well and ended it badly. A shorter book and more to the point would have been enough.

Bottom line, the book starts in an interesting way, describing what I would call "IT gap analysis", in other words the application of a simple idea: begin with a detailed (and documented) picture of what the current (start) situation is, then describe just as much detail the situation you want to reach (end). From then on, the job of describing the transition becomes orders of magnitude easier. That applies to software projects (start with what the client has and needs, then create the plan to bridge the gap), documentation (start with the functional and end with the structural) and ultimately code (start with abstract classes and interfaces, then fill in the missing code).

Other than that there are some (hopefully) nice references, then a lot of empty space filled up with irrelevant things: description of design patterns (which are nice, but there are books for something like this), a glossary of terms (some were never even used in the book!) and then the general way of describing something, then adding the "Standard acknowledges" part that basically says the same thing as his own description. It generally felt as a student paper from one that needed only a passing grade.

Sorry Mark, better luck next time. I will add here a short summary of what yours truly thought was noteworthy in the book:
  • use gap analysis for all the levels of your software work. When you define what you have and what you need, filling the blanks becomes easier.
  • use functional documentation, design documentation and structural documentation to detail what you wanted the software to do, how you designed to solve the problems and what are the basic building blocks of the project (classes, patterns, etc).
  • use code standards and peer reviews and even external code auditing to improve the quality of code. Refactoring is a must. Popular code development methodologies include Extreme Programming and Rational Unified Process.
  • use a design standard like the open-source architecture framework (TOGAF)
  • the enterprise vs. domain dichotomy. Should a software be started from scratch and done for the current set of requests only, or should it be designed as a general component ready for reuse? I would really go towards the enterprise, even when the profit from the extra work is not immediately obvious. Sometimes things that you have prepared in advance and nobody acknowledged become a real time (and life) saver when unreasonable requests tumble down upon you.
  • also linked to the enterprise/domain issue: an application framework solution. Create a basic Visual Studio solution that contains common components used in many projects and use it as a startup solution.
  • use the Visual Studio formatting options to keep your code well formatted. Use a standard of naming variables, methods, properties. My own choice is using lowerCamelCase for inner variables, prefixing the name with an underscore for fields. UpperCamelCase (or Pascal) for methods, properties and class names. Hungarian notation for controls (lbName for a label with a name). I don't really care if one names the control txtName, tbName or tboxName, as long as the prefix is revealing.
  • use the Obsolete attribute for methods and properties that are intended to be removed in the near future. In my own library I have used methods that became obsolete with the coming of .NET 2.0 and used this attribute to point not only to the obsolescence, but also to the blog entry detailing the reasoning behind it.
  • this is basically derived from other sources, but I do think it is relevant: best practices recommends using composition over inheritance, wherever possible. I admit that the coding of composition is much more complex, but with the refactoring tools found in Visual Studio and its add-ons (like my beloved Resharper), it becomes similar in complexity.
  • references:
    1. book: Programming C# by Jesse Liberty, published by O'Reilly
    2. dude: Martin Fowler is a leading authority on refactoring
    3. books to understand object-oriented development: Object-Oriented Analysis and Design with Applications by Grady Booch, published by Addison-Wesley in 1994
    4. Expert C# Business Objects by Rockford Lhotka, published by Apress in 2003
    5. book: Code Complete, by Steve McConnell, published by Microsoft Press 2004
    6. authorities on design patterns: Martin Fowler, Gregor Hohpe, Bobby Woolf
    7. dude: professor Trygve Reenskaug and his discussion on the role of object collaboration: Role Modeling and UML-VM discussions

My conclusion: read my summary and you don't waste two days of reading time.

Friday, December 21, 2007

Javascript regular expression split inconsistent between browsers

I was asked to fix a bug and I soon found out that the "bug" was actually IE's regex split implementation! You see? When you split by a string, the resulting array does not contain any empty spaces found!

Ex: 'a,,b'.split(/,/) = ['a','b'] in IE and ['a','','b'] in FireFox.

Searching the web I found this very nice page from regular expression guru Steven Levithan: JavaScript split Inconsistencies & Bugs: Fixed!. You can also find there a link to a page that tests the issues with your browser's Javascript regex.

Bottom line! Use Steven's code to regex split in Javascript.

Thursday, December 20, 2007

Holly tea!

I was bent on writing an article about tea. You see, tea :) is a word often used instead of "infusion", but the definition of the word says it is specifically an infusion of Camellia sinensis, or the tea plant. I drink tea a lot, although I prefer to alternate the different tastes as much as possible. Tea plant

But the tea and coffee plants are far from being the only ones used for energizing drinks. In the Theaceae family alone there are a few species that are traditionally used for infusions.

Then there is the mate, from Yerba Mate, a species of the Holly (Ilex) family. Ilex paraguariensis, the mate plant
Other members of the Ilex family are used for traditional drinks.

The Roiboos infusion is an African tea made from a plant that is part of the legume family! I've tried it and I didn't enjoy it much.Aspalathus linearis, or the roiboos

How about a little Coca to boost the spirit? The "Coca tea" or "mate de coca" is a traditional drink in the Andes. Coca Erythroxylum, the coca plant

You can try Bubble tea made from Tapioca, the processed root of the Cassava plant.Manihot esculenta, the manioc, yuca or cassava

All these links are giving me headaches, but there is more! The stuff above is just the tip of the iceberg, or the most famous plant infusions that are known as tea, because there are all the other plant infusions that are covered by the more generic term "Herbal tea". On that particular page you can find over 60 herbal infusions not made from the tea plant, including mate.

Please follow the plethora of links as I can assure you you will find a lot of interesting things there. This also got me thinking of the way the markets are functioning right now. I drank about every possible tea I could commercially find without looking too deep and I've only experienced tea and mate infusions. How about all the others? When will I be able to drink tapioca tea or coca tea? The plant itself is not illegal! Perhaps deeper digging in the commercial part of the Internet will help me find sources for some of the drinks above. Also, if I only had the time, I would try to learn about herbalism.

Eh, enough of this. Now I must add the images to the post and hopefully someone will read it.

Tuesday, December 18, 2007

Monday, December 17, 2007

Darwin's Children by Greg Bear

Bookcover imageDarwin's Children comes to continue the story from Darwin's Radio.

My general feeling is that this is not a very good book or series. The basic ideas that started it are interesting, although pretty hard to advocate to a scientist, certainly interesting from a literary point of view, giving multiple opportunities for tension, drama, unexpected, etc. Unfortunately, Greg Bear failed to capitalise those ideas, writing a book that has only a few characters that kind of stumble upon the most important clues for the book subject; it all happens in the USA, with almost no regard to what could or would have happened elsewhere. In a time of a great crisis, the international situation is put on hold, like every nation would take a time-out and ignore its neighbours. And the style is really not touching any emotional chord whatsoever.

Let me summarize: the sudden leap in human evolution is treated by the politicians as a disease, the new species being imprisoned in what could only be described as concentration camps. The entire U.S. democracy and freedom collapses like a giant soap bubble, while the fear of every child bearing family transcends to racism and fascism in no time. The few enlightened people that understand what is going on and try to protect the evolved offspring are also persecuted and surveillanced.

So here we have the eternal American obsession with children in distress and terrified families combined with concentration camps for some of their children, racism and civil disobedience, a newly discovered and frightening evolutionary mechanism, cutting edge genetics and archaeology. This could have been a fantastic story! But no, what came out was an impersonal account of hard to believe actions or feelings coming from emotionally stunted characters. And what was worse is that whenever the tension grew and there was a hint of a great thing happening, the author would make a sudden leap in time, after all had already happened, without describing much anyway.

Also, Darwin's Children is the last book of the series, while the story (as far as I am concerned) stopped halfway through, with no reasonable conclusion. Bottom line: not worth the time.

Friday, December 14, 2007


Her name was Andrea, but her friends called her Andrew, for some reason. Or at least this is what I found out a bit later, at my place. I'd also call her Andrew, as I thought she enjoyed it, or at least that she was used to it more. Turned out she really hated it, but she would not show herself vulnerable to something like this in front of her acquaintances.

One would not call her neither skinny, nor athletic, but she was a thin blonde, with a rather tense looking face, a bit short, but not much; really nice skin. I met her at this party and, even if I wasn't really attracted to her, I was in the mood. I wouldn't have minded shagging her if she was up for it. She certainly was more friendly than the brunette earlier. The bitch had noticed me looking at her and started making faces, to everyone's amusement. I told her she was looking very cute, in a babyish kind of way. I am not very good at acid remarks, obviously, especially when I am wasted. Hitting on a girl that drank in a corner with some other girl was not a good idea, anyway.

I had sobered up by the time I met Andrea. She started talking to me, actually, and I found the conversation with her quite entertaining. Her face was really interesting once she got to smile. All the tension would suddenly vanish and that smile would take 10 years off her. I was quite curious to see how she laughed. She wasn't much of a laugher, though, although I did use some of my best party jokes.

After a while she started telling me stuff about her, even rather private things. I am used to people getting drunk and spilling everything out - I usually do that - but she wasn't drunk. She did accept a drink from me, but she was definitely sober, yet she seemed desperate, somehow. Apparently she was quite the party girl. She told me about one time when she and her friends partied in a bus they rented and they woke up the next morning, all hung over and drooling all over each other. I stupidly smiled and told her I knew how that felt, all the time feeling a bit envious because I had no idea. I also felt like she read me like an open book, anyway.

By that time we'd ended up at my place and Andrea and me continued talking about all kinds of things. In a matter of hours we ended up feeling like good friends, although it was pretty clear we would not stop there. We were never going to be in love with one another either. I think she really enjoyed that I wasn't like her friends and that I didn't even know them. It was then when she told me not to call her Andrew anymore, her name was Andrea.

In fact, we got to leave the party after she did something really unexpected. We had been talking for a few minutes, normal stuff like names and how we are feeling and how the party is like, the bus thing, when she suddenly pulled a big notebook filled with pictures and personal notes written on paper that was cut in different shapes, all glued together in a thing that looked like a little girl's diary. She said "You want me to show you my life plan?". She'd written in that thing all the dreams that she had, detailed plans of what she intended to do with her life, things that she saw and she liked and she wanted to see more of. Her photos were really good, but the notes were really personal. I couldn't believe that she would show something like that to me. I felt like a thief, getting something I did not earn. The party was not a good place to be anymore, it was too impersonal and it lacked privacy.

I told her that if she wrote in the thing that she wanted to get married and have children and that was some weird ploy to pull me into it, it would certainly be a waste of time and not go well. Then she laughed, mind you. It was something I was really honest about, but I think she realised that and to my personal relief, there was no talk of children inside there. Her laughter was really beautiful.

So back at my place I started to look deeper into her journal thingie. She gave me a CD, told me that she would need to process some of the pictures she took and that on the CD was a special software that would read Binko files, whatever graphics format that was, and it would be good if I had it on my computer. It was funny and refreshing to hear that, I laughed and proceeded on installing the software. You see, we never talked about getting together again after this, certainly not at my house again. It was like she was admitting that she liked me and that she knew I liked her and that talking about it would be moot.

I felt than that maybe she would end up fixating on me, acting all neurotic and possessive at one time or another, but I didn't really care. If she would do that, she would be just opening more to me and I would never be forced to lie to her because of it, I would just react to what she would be doing or saying. Without actually defining it, it was already decided that we would have an honest relationship above all else. Not like boyfriend and girlfriend, more like that of best friends.

At that time I got a little nervous, thinking maybe I will get the "let's just be friends" speech and that was to be that, but before I could finish my thought, Andrea was kissing me. She would be gentle and sentimental in bed, not something one would expect from a party girl, but then again, I wouldn't want to believe that she would do that with anyone else.

And then I woke up. It was time for me to go to work and Andrea was already fading from my memory. It was a beautiful dream.

Thursday, December 13, 2007

Using Cache in ASP.Net applications

Most programmers use the ViewState to preserve data across postbacks and the Session to preserve data for a user. There are cases when you want to preserve data across users. Maybe you are using an IHttpHandler and you want to send information through a key between your application and the handler. Or maybe you want to keep data that is resource consuming to acquire, but used by more users of the same application. Here is where Cache comes along.

There are two things you need to pay attention to when you are using the Cache:
  • While using the syntax Cache[key] is very simple and consistent with the ViewState, Session or other dictionaries you are used to, you need to be aware that in case of the server freeing memory, the cache items will be removed based on priority. Try to use Cache.Add or Cache.Insert with CacheItemPriority.NotRemovable when you are sure you don't want this to happen. The Absolute and Sliding expirations will still work.
  • I've read somewhere that HttpContext.Current.Cache does not work across users. It's like another Session object. Use HttpRuntime.Cache instead. I also looked in the ASP.Net source code and I found out that HttpContext.Cache returns HttpRuntime.Cache, so I don't see how these two properties could behave any differently. HttpRuntime is much easily usable, though, since it works in situations where HttpContext.Current is null

Wednesday, December 12, 2007

Rental Magica - interesting anime, but too silly to take seriously

Group image of the main cast
Rental Magica started very well, like a combination of Elfen Lied and Full Metal Alchemist. Unfortunately the magic is a lot more benign and not founded on anything interesting like in FMA, and the only connection to EL is the fact that the lead character is a nice guy surrounded by children looking female girls that have a crush on him.

Other than that, I've only watched the first 10 episodes. There was the potential of greatness, while the series explored the taboos of magic and what happens to mages trying to break them. Also there are a homunculus and a mechanical archenemy present. However, someone decided that it is better to fight evil with goodness and that in the end goodness should win, making the whole thing really silly.

I would recommend it to children only.

Monday, December 10, 2007

Vampire the Masquerade - Redemption

Game cover image
I got this game from a colleague of mine, something she labelled as strategy. Well, it was actually an RPG, and a pretty good one, too. Considering that it is rather old, it certainly goes up there in my games top. It is one of the games in the Vampire the Masquerade series, codenamed Redemption and released in 2000 by Activision.

Ok, the idea is that you are a crusader, left behind by your company due to severe battle trauma. A helpful and kind nun takes care of your wounds and makes you better. However, you soon find out that the city (of Prague) is plagued by monsters and undead creatures. As a devout follower of God's path (infidel! I kill you!), you get your mighty sword and crusader expertise and proceed on a debug mission. It would be pointless to go further from here, as the story evolves until you get in the year 1999 and in the cities of Prague, Vienna, London and New York.

The fun of the game is that you use both vampiric attacks and magic and a bit of strategic thinking in order to attain your goals. Starting out with a single character, you get to have up to four.

Now about the fast lane: how to finish the game as soon as possible. First of all try to equip your characters with the best armour and weapons you can find. At first you don't have a lot of money, but you find all kind of stuff when you kill monsters. Second of all, you will get to find a lot of rings and necklaces and bracelets that only improve APP(earance). You might think that wearing them will pimp your vampires, but Appearance is very important for one of the most crucial spells in the game: Enchantment. The other very important spells are: Feed, Blood Healing and Ice Statue. If you master these four spells you can defeat anyone. Unfortunately, Ice Statue will not be available until you defeat the Tremere, which is quite advanced in the game. Any spell that makes the target not attack will be as good, though. The next important spells are Awaken (wakes up a dead member of your group) and Walk the Abyss, which allows you to instantly transport to your save game place (the Haven) and store your objects and increase your stats. A good secondary spell is Spirit's Touch, which will identify the unknown objects you find.

Another important thing is to go to Options -> Controls and remove all spells from your group except auto healing. Otherwise your vampire buddies will gobble up blood like it's 12 years old Whiskey. And talking of control, near each character's picture there is a green light. Click on it and the guy will not follow you around like a dumbass, killing the people you are trying to feed upon or do magic tricks on.

And back to the fast lane: use Enchantment to control an enemy to fight the others around him when there are more than one foe. Then run in front of him with one of your group, so that he follows (or do that from the start if you can separate him from the others or if he is alone), then wait with another character with big Feed rating and, of course, Feed until the foe dies. In order for this to work, the little green lights must be off, otherwise they will follow and attack like idiots. In the case of monsters and non-blooded creatures, freeze them and kill them.

Also to note is that Christof's AI is more violent than for others. Even without his little green light, he will still attack stupidly. Another thing to note is that using the middle mouse button, the characters will attack with a slower, but stronger attack, optimal for frozen creatures or when they are fighting someone else in the group. Remember to keep your Feed guy empty by letting the others feed on him!

Ok, that's it. The game has a multiplayer option as well, but I haven't explored it yet. The movement AI is the worst part of the game. Also the story could have been more interesting. At some times I managed to enter unfinished portions of the game, where characters would just sit and not interact or where the dialogue would have been replaced by general options like "Threaten" "Leave Alone". Other than that, it's a pretty smooth, though linear, game.

If anyone is interested, there are three possible endings, and here are the YouTube links. Just make sure you want to see them before you finish the game or not.

Good Ending
Neutral Ending
Bad Ending

Saturday, December 08, 2007

How to select VLC default encoding of subtitles

Update 11 Feb 2016: I've just taken another look at the VLC menu (version 2.2.0) and the way to get to the encoding is: Tools → Preferences →
  • For 'simple' interface: Subtitles/OSD → Default encoding
  • For 'all' interface: Input/Codecs → Subtitle codecs → Subtitles → Subtitle text encoding

I have been using VLC Video Lan Player for a long time, mostly for myself, since it can show instantly movies that are incomplete and gets past most video performance issues in Windows by mostly ignoring the default video renderings and using its own codecs.

But there was always this problem with the Romanian translations. The specific Romanian letters (diacritics/diacritice) appeared like weird characters and it got annoying. I thought a simple configuration setting might solve the problem, but it wasn't the case. In the extensive (and mostly incomprehensible) configuration interface there were all kinds of options regarding the subtitles, but not a default subtitle encoding.

Ok, so here is how to do it.
  • Method 0: See above :) It's the GUI way of choosing the setting at Method 3
  • Method 1. Load the movie from the Open menu option. You get to choose your subtitle file and also the subtitle encoding, in the Advanced Options menu. For Romanian all you have to do is choose is 8859-2 (Latin2). But this doesn't solve multiple movie files in the playlist or set a default encoding. This doesn't seem to work anymore
  • Method 2. use the --subsdec-encoding=ISO-8859-2 setting in the VLC command line.
  • Method 3. And the one that solved all my issues. Go to the folder <Operating System Drive>:\Documents and Settings\<Current User>\Application Data\vlc\ and open in a text editor the file vlcrc. Then search for the option subsdec-encoding, uncomment the line and change the Default to your encoding, for example ISO-8859-2.

That's it.

Friday, December 07, 2007


Mushishi is a strangely calming anime. It takes place in almost feudal Japan (they seem a lot more liberal and have access to some technology like microscopes and the mushishi talks about genetics in one episode) and follows Ginko, a man that can see the strange lifeforms that are all around us, called Mushi.

In the end the episodes are rarely tense, with no or almost no violence. The mushi themselves are not perceived as evil that must be killed, but as a part of the ecosystem. Unlike most mushishi (a sort of mushi hunter/doctor), Ginko, the lead character, seeks only to restore the balance between normal life and mushi life.

The anime itself takes place for only 26 episodes, all self contained, you could watch any of them in any order without losing any continuity. The manga is of course much longer and you can read it here.

The calm music and the elements of traditional Japanese life and history are most welcome for a leisurely time when you want to relax and take your mind of things.

Thursday, December 06, 2007

Hidden porn in ASP.NET Ajax

I was building my nice little web app, you know: grids, buttons, ajax, stuff like that. And of course I had to create CSS classes for my controls, for example a button has the class of butt and the Send button has a class of buttsend. I agree it was not one of the most inspired CSS class name, but look what ajax made out of it:

Details: Error parsing near 'ass=buttsend'

Bucharest in all its glory

One of my favourites blogs is The BÜKRESH Blog which boasts a number of excellent concise images, although rarely meaningful text. However, I found this particular entry having all the makings of a great article. It has it all: great pictures, ironic text and an unbelievable subject. It is written in Romanian, so I will try to translate it below. First visit the link and see the pictures. (and yes, those are real human bones)

Human bones and empty plastic 2L beer bottles

First a bit of data that might help you understand what is going on: In the old center of Bucharest they recently found ruins from a previous time. I have no idea what time and what the ruins represent as I am not interested in archaeology, but bottom line they tore up a couple of streets and started digging underneath and expanding the site.

Gypsies are an ethnic minority in Romania, genetically linked to populations in India, and mostly shunned for their style of life, unclean living conditions and high criminality rate. They represent a maximum of 5% of the Romanian population and discriminating against them is illegal in Romania.

What the article is about is the way the archaeological site is being handled.

Is it hard to describe the mixed feelings the medieval ruins in the Bucharest old center gave me. I passed by there for the first time (across the street from the Comedy Theater on Tonitza street) last week. In the space from the second image
there were 4 people - a 50 years old Gypsy man, sitting in a squatting position and smoking a cigarette, a Gypsy woman of the same age, with all the Gypsy clothing arsenal (I have nothing against them, quite the contrary, but I want this description as clear as possible), digging like she would be working the field, and another Gypsy girl, 15 or 16 years of age, kissing with her boyfriend who came to see her at work. In the top-left corner there was a pile of bones, a complete human skeleton, cranium included, and on the edge of the hole there were bags of food - lunch for the four workers. Yesterday I went there again and this time there was nobody there. I took the pictures you see. Today I passed through again and it was the same situation as yesterday. On the French street there were 10-15 workers digging, aged between 15 and 60 years old, multiple ethnicity and some of them were either drunk or very drunk. They wore no protection gear or uniforms. Some wore Adidas type shoes (and working in mud), no one had gloves or protective helmets. I asked them about the archaeological site and why there were hundreds of years old human bones laying around... They said they didn't know and that people had come before and taken some in big bags. I asked them if their bosses ever came to see them and they said that they do that, once or twice a day...

The firm that is handling the rehabilitation of the old center is called Sedesa and it's from Valencia. The money are sourced in a non-refundable credit (in other words free money) from the Dutch government, a credit from the European Bank for Reconstruction and Development and public funds (the city-hall, Sector 3 division).

I am concluding with these words taken from the Sedesa company site:

Sedesa is a solid business group with more than sixty years of experience and international activity. Its high level of specialisation has not only enabled the group to establish itself in numerous sectors, but also to carry out projects and infrastructure based on quality, respect for the environment and solid technological ability.

by Vlad Nanca on 05 December 2007

Monday, December 03, 2007

Now this is how a man should act...

I am not the one to write essays on how "real men" behave or anything. But this article says it all: I have all the respect and admiration for Vitangelo Bini, even if he is too old to really lose anything by incarceration. He showed logic and respect for his wife. For her spirit, not her decaying body.

I always thought that if I get into the same situation, I would kill myself. But I wonder if this resolution is not stored in one of the first regions of the brain affected. Before I realise what is going on, I forget I always have this option. In situations like this I say screw the law and the hypocritical society that spawned them. Way to go, dude! This is how real men act.

Wednesday, November 28, 2007

Friday, November 23, 2007

Darwin's Radio, by Greg Bear

I remember reading Greg Bear books a while ago and thinking they were really cool. The coolness, of course, came from his hard sci-fi style, mixing good ideas with believable science. Now, after about a decade I suppose, I've decided to read another of his books and here is my review.
Darwin's Radio cover
Darwin's Radio starts a little like Village of the Damned, but without the extraterrestrial origin, continues a bit like The Stand, without the religious mambo-jumbo, and ends in waiting for Darwin's Children, the next book in the series. The plot is about a major and sudden evolution of the species, without the X-Men powers.

My personal feel was that the writing is less than I wanted. The book seems shallow and uninteresting after reading Peter F. Hamilton. While the science is interesting, it also makes huge leaps of faith and I wouldn't put it behind Bear to end the story with a good versus evil battle. Was I too young to appreciate good writing, starved as I was of anything interesting in my life? Or is this book not so hot?

I will certainly read the next volumes, but I am a bit disappointed. I feel like I am watching a play after seeing a real good movie.

Thursday, November 22, 2007

Nullable types and their boxing in O/R mapping

Nullable types are new to .NET 2.0 and at first glance they seem great. The idea that you can now wrap any type into a generic one that also allows for null values seems valuable enough, especially for database interactions and the dreaded SQL null.

However, having an object that can be both instantiated and null can cause a lot of issues. First of all, boxing! You can define a Nullable<int>, set it to null, then access one of its properties (HasValue). So suddenly a piece of code like obj=null; obj.Property=...; makes sense. But if you want to send it as a parameter for a method, one that receives an object and then does stuff with it, the object must represent the null value, which means it is no longer an instance of anything. Therefore you can't get the type of the variable that was passed to the method!

Quick code snippet:
int? i=null;

With Save defined as:
public void Save(string name,object value)

Now, I want to know what kind of nullable type was sent to the method. I can't see that if the parameter signature is object, so I am creating another signature for the method:
public void Save(string name,Nullable value)

At this time I get an error: static types cannot be used as parameters. And of course I can't, because Nullable is a generic static type that needs the type of the wrapped value. So the type is actually Nullable<int>. My only solution now is to create a signature for every value type: integers, floating point values, booleans, chars and IntPtrs. String and Object are value types, but they accept null, so Nullable<string> is not used on them, but if you count all the other value types , there are 14 of them!

There is another option that I just thought of: a custom object that implicitly converts from a nullable. Then the method would use this object type as a parameter.
I tested it and it works. Here is the code for the object:
Click to show

There are issues regarding this object, mainly refering to constants. If you pass a constant value like the number 6 a method that expects either Object or NullableWrapper, will choose NullableWrapper. More than that, it will choose a NullableWrapper<byte> since the value is under 256. Adding signatures for int, double, etc causes Ambiguos reference errors. So my only solution so far is to consider the UnderlyingType of even Nullable<byte> as Int32. It is obviously a hack, but I haven't found a good programming solution to it, yet. If you have an idea, please let me know! Thanks.

Nullable Types (C# Programming Guide)
Check If Type is a Nullable Type - Convert Nullable Type to Underlying Type - C# 2.0 Generics

Friday, November 16, 2007

FxCop integration in Visual Studio 2005 Standard or Professional

FxCop is a free Microsoft utility that analyses compiled .Net code and makes suggestion based on rules, may them be design, security, performance of company policy rules.

The first problem is that you can only use it on compiled code. That means executables and DLLs. But what about ASP.Net 2.0? It doesn't build a DLL anymore, like 1.1 did. How can one use it? I have built an application (one that you will have to message me to send to you) that takes the project name as a parameter and then creates an FxCop project file with the DLLs from the site bin folder as reference DLLs and the DLLs from the Asp.Net temporary folder of that project as analysis targets. That means that you can also use it for ASP.Net now.

The second problem is that FxCop is now part of Team System, the overpriced and overhyped version of Visual Studio, and any attempts to use it with the Standard or Professional versions are cumbersome and undocumented. Siderite to the rescue! Here is a quick way to integrate FxCop as an external tool to Visual Studio and use it for either Console and Windows Forms applications or Asp.NET sites.

Step 1. Download FxCop. The latest version is 1.35, but there is also a 1.36 beta available that knows about lambda expressions and stuff like that.
Step 2. Get from me the FxCopAspNet application (completely free and with source), or build your own. Here is a possibly working link for it: at MediaFire.
Step 3. Open Visual Studio, go to Tools/External Tools and add two FxCop entries:
- FxCop [use C:\Program Files\Microsoft FxCop 1.36\fxcop.exe as Command, "$(TargetPath)" as Arguments and C:\Program Files\Microsoft FxCop 1.36 as Initial Directory]
- FxCopAspNet [use C:\Program Files\FxCopAspNet\FxCopAspNet.exe as Command, "$(ProjectFileName)" as arguments and C:\Program Files\FxCopAspNet as Initial Directory]
Step 4. Just open your web site or application in Visual Studio, compile it, then click on the FxCop item that applies.

Now, this is not meant to be a tutorial on FxCop, here are some links that might enlighten people:
Download FxCop 1.36 Beta
Download FxCop 1.35
Open Source FxCop Integration Add-in for Visual Studio 2005
How to copy the necessary files from Team System to Visual Studio 2005 Professional to make integration work
Use FxCop from your own code
A small tutorial
FxCopUnit, FxCop testing unit project
Video on how to create your own FxCop rules

There are a myriad rules included in the default installation of FxCop, some of them are just annoying, like some naming rules or some telling you you shouldn't raise Exceptions just objects inherited from Exception, but some are pretty good. A lot more can be found on the Internet and now, with the integration in VS Team System, I expect a lot more to pop-up.

Sunday, November 11, 2007

TV Series I have been watching

The third in this category of blog entries, this describes the few TV shows I have been watching lately. The previous entry can be found here.

House MD is a doctors show. A bit more interesting than E.R. and Grey's Anatomy because they actually focused on interesting characters and interesting medicine. However, after three seasons, the quirky intelligent doctor is just annoying, the supporting cast makes no sense and the medicine is becoming a joke. It's never lupus!

Prison Break is the new Lost. It had an interesting premise and I admit I watched it with pleasure for about a season and a half. Then it all went haywire. I predicted it, too... When people recommended the show I said "How the hell can you keep a prison break for 3 seasons?"; and the answer is that you can't. Not without bringing in mysterious government secret agencies with hidden and malevolent agendas. As acting goes, I like Dominic Purcell, interpreting the older brother, but I can't seem to see him in any decent show. You may remember him from John Doe, another clicheatic TV dead end.

Also in the list:
Numb3rs, even if the math has gone sour already and the show has basically turned into another pure police show. (good versus bad silliness)
Stargate Atlantis, which will probably end with this season without any other decent sci fi to replace it.
Battlestar Galactica, which was great, but moving towards boredom.
Regenesis probably won't get another season after season 3. It was never a great show, but it was decent, being Canadian and all :), with a bunch of virus hunters. It could have been a lot more scientific.
Grey's Anatomy is still on the market for my wife, but barely. A doctor show, but now it is very little about medicine and a lot about the human side of the characters; and who the hell wants a movie about people, completely overlooking the cool stuff happening near them?
Private Practice is an off shoot of Grey's Anatomy, but we never even started watching it.
Ugly Betty still sucks enormously and the wife still watches it.
Eureka. The second season waits on my harddrive, cobwebs on each file. Maybe if I am really bored...
Desperate Housewives takes the desperation way too far, probably reflecting the feelings of the screenwriters when watching the audience numbers fall.
A new season of Doctor Who will start in December.

Night's Dawn trilogy - Peter F. Hamilton

He did it again! Or would it be better for me to say he has done it afore, as I am kind of moving backwards in the Peter F. Hamilton writings? Night's Dawn is a huge book, about 9Mb of pure text, divided into three parts purely out of paper formatting reasons, I am sure. So far, this is the best thing he has written, at least in my opinion.

Maybe the guy is the kind of writer who writes his best work first, then tries unsuccessfully to follow up. Not that any of his followups could be called a failure, it's just that Night's Dawn is really cool! I mean who can seriously deal with possession, necromancy, devil worship, witch hunting, vampires, werewolves, ghosts and demons, all in a future world in which humanity has conquered space an tries to attack the situation with science and rationality? Seriously! If this guy would have written the Bible, there would be no Muslims! (Ron Hubbard, eat your heart out!)

There isn't much else I can say. I certainly cannot summarize a book that spreads over about a dozen inhabited planets, all with their own history, socio-economic situations described and own characters to add plot (real plot) to the story. Right now I am terrified. I need to find the Greg Mandel trilogy, which is the last of the Hamilton big stories, and there are only two outcomes: a) I hate it, which would have wasted my time and trust in humanity; b) I love it, and then I go into withdrawal waiting for the last two volumes of the Void trilogy and whatever else he brilliantly writes in the future.

Bottom line: if you like Sci-Fi, you need to read this. Hamilton and the ReSharper guys are the only people I ever felt the need to send money to in order to apologize for my shameless Internet piracy.

Peter Hamilton's official site
Wikipedia's entry on the Night's Dawn trilogy
Peter F. Hamilton's entry in Wikipedia.

Friday, November 09, 2007

Lateral parking solution for women everywhere

There are a lot of people in the world having problem with lateral parking. It is not only difficult to manage when you have nothing to go on but the little tiny images in the car mirrors, but stressful as well, as normally the procedure is done on a crowded street with drivers behind you urging you to do it faster.

Not a problem anymore! The Chinese have found the perfect way of parking in under 5 seconds! Here is a video tutorial on how to do it:

Here is an alternative solution.

Sunday, November 04, 2007

Fruit of the mall - part 2

Two months ago I wrote a post about the exotic fruits I found in a hypermarket in Sibiu, now it's time for additions, taken from the Bucharest Metro.

My own photo of the fruits
So here are the fruits I bought today:
the Maracuya
. It has the same feel as a fruit from my first post, the Kiwano. The taste, though, is very sour, like a lemon, and a little spicy. I could eat it, but I think people don't really eat it raw. The outer skin is hard, inedible and thick.
the Kaki fruit. It is very tasty, although it has a peary texture that I didn't quite like. It is a sweet banana tasting fruit.
the Cactus fruit has a sweet coating around the hard inedible seeds inside with a texture of baby food and taste like a not aromatic cantaloupe, similar to the Pepino. The seeds, though, make it less than pleasant to eat.
the Pepino mellon has a similar texture to the Kaki, but it has the taste of Cantaloupe, yet not so aromatic.
Now, the Papaya is an interesting tasting fruit. I am afraid my best approximation is still the cantaloupe, but the papaya also has its aromatic properties and the texture. Its aroma, though, is slightly different, more like banana. It has a big core of inedible seeds and the skin is also inedible. That makes the useful part of the fruit rather small.

In conclusion, one must definitely try the papaya and the kaki. The maracuya is the weirdest taste among all, not entirely pleasant, although I can try to eat it with sugar or something. The net suggests mixing the seedy content with water and sugar after letting the skin wrinkle.

Fried Calamari - simple and damn tasty!

I went to one of the Metro hypermarkets in Bucharest and I was pleasantly surprised by the variety of stuff one can find there, as compared with other hypermarkets that seem to be supplied from the same sources. Also check my next entry, I will write about exotic fruits there.

Calamari in a plate. My own picture.In this post I will talk about calamari! There is an entire store dedicated to fish in Metro, filled with a lot of nice looking and/or packaged treasures of the sea. My picks were swordfish stakes and one big calamari. Well, not that big... it's no architeuthis, but it will do.

I went home, made a longitudinal incision, threw away the awkward looking organ inside (which I suspect had a digestive function) and the eyes and beak, then threw it in boiling butter after putting a bit of spice over it. I removed it after 2-3 minutes and ate it. Yes, it's that simple! The taste is not strong, but really special and it was totally worth the buy.

Warning, as read from the googling on calamari: Calamari is either to be cooked in 2-3 minutes or in more than 30. Everything in between turns it to rubber. So, if you are like my wife and you want to spit it after you taste it, you might want to try the long cooking calamari recipes out there. :)

Friday, November 02, 2007

Getting the index or rank of rows in SQL Server 2005

A while ago I wrote a little post about changing a paging GridView in order to show certain number of pages and page index, but extract from the database only the data you needed. I was looking there for something in SQL Server like the MySql LIMIT, the T-Sql equivalent of TOP, but which accepts two parameters instead of only one.

I just found out that there is a way of doing this in Sql Server 2005 by employing functions that return the position of a row, depending on a certain ordering and partition, called Ranking Functions. From the little googling I did, it seems that Microsoft borrowed this technique from Oracle, but one never knows, maybe it was the other way around.

I will write a short example on ranking functions, then link to the appropiate articles. Given this SQL query:
select *,
Row_Number() OVER (ORDER BY name) as [Index],
Rank() OVER (ORDER BY name) as Rank,
Dense_Rank() OVER (ORDER BY name) as DenseRank,
NTile(3) OVER (ORDER BY name) as NTile,
Row_Number() OVER (PARTITION BY nr ORDER BY name) as IndexNr,
Rank() OVER (PARTITION BY nr ORDER BY name) as RankNr,
Dense_Rank() OVER (PARTITION BY nr ORDER BY name) as DenseRankNr,
NTile(3) OVER (PARTITION BY nr ORDER BY name) as NTileNr
from test

you get the following result:
ID Name Nr Nr2 Index Rank DRank Ntile IndexNr RankNr DRankNr NtileNr
1 Mark 1 7 8 7 4 2 2 2 2 2
2 Mike 1 4 11 11 6 3 3 3 3 3
3 John 2 8 5 5 3 2 1 1 1 1
4 Charles 3 2 1 1 1 1 1 1 1 1
5 Ellen 3 6 4 3 2 1 2 2 2 2
6 Mary 4 1 9 9 5 3 2 2 2 2
7 Mark 4 17 7 7 4 2 1 1 1 1
8 Mike 2 41 12 11 6 3 2 2 2 2
9 John 6 83 6 5 3 2 1 1 1 1
10 Charles 1 72 2 1 1 1 1 1 1 1
11 Ellen 0 68 3 3 2 1 1 1 1 1
12 Mary 3 21 10 9 5 3 3 3 3 3

As you can see, Row_Number returns the row index, Rank returns the rank, Dense_Rank returns consecutive rank (no gaps between rank numbers) while NTile puts each row in a category using a given number of total categories. Partition by makes the operations work for each distinct value of a certain column, in this case nr. If the partition would have been on nr2, all the ranking values would have equaled 1, since there are only distinct values on the nr2 column. The Over clause can be used on more than just ranking functions; it also works on Aggregate functions. Yummy!

Ranking Functions (Transact-SQL)
OVER Clause (Transact-SQL)
Aggregate Functions (Transact-SQL)
This article also shows a similar method in Sql Server 2000 of which I knew nothing until today: Row_Number() function in SQL Server 2005
Returning Ranked Results with Microsoft SQL Server 2005