Wednesday, November 30, 2011

Tuesday, November 22, 2011

New Coma song for 2011

Coma has finally released a new song. It's completely free to listen and share. Here is the SoundCloud link for it: Un semn. You can also listen to it here.
Coma - Un semn [2011] by COMA-band-official

I wish it weren't such a light piece or that Dan Costea would have added some of his trademark screams in the background at least. I can't but think of Linkin Park, starting with great, powerful songs and continuing with whining in their next album. But being the first piece out, it may be a teaser for what it is to come.

There is a video for the song, and here it is:

Saturday, November 19, 2011

Windows authentication dialog when trying to access the Reports path in a web site

I was trying to access http://localhost/Reports/Page.aspx, in other words an ASP.Net page in the Reports path of the local site. Instead, I was getting a Windows authentication prompt that had no business being there. At first I thought to debug the page, but it wouldn't even get there before I got the authentication prompt. I googled for it, but I didn't get far because I was looking for weird Windows authentication prompts, not for the specific location of my page: the Reports folder. It was stranger yet, as I stopped IIS and the authentication dialog was still appearing!

In the end, a colleague told me the solution: SQL Reporting Services is answering on the local Reports path! I stopped the service and voila! no more authentication prompt. Instead, a Service unavailable 503 error. This article explained things quite clearly. Even if you stop the service, you have to delete the access control list entry for /Reports with the command netsh http delete urlacl url=http://+:80/Reports or, I guess, restart the system after you set the Reporting Services service to Manual or Disabled.

Update: It is even easier to go to Sql Server Configuration Tools (in the Start Menu), run the Reporting Service Configuration Manager, then change the URL for the Report Manager URL to something other than Reports.

But what is this strange Access Control List? You can get a clue by reading about Http.sys API in Windows Vista and above and about Namespace Reservation. Apparently, one can do similar things on Windows Server 2003 and maybe even XP with the Httpcfg utility.

Friday, November 18, 2011

Lord of the Flies, by William Golding

Savage boys from the 1963 film
This book touches a very uncomfortable subject for me: the mindless, visceral hive mind of the crowd. There is nothing more horrible, I find, that being powerless in front of a mob of people united by only their stupidity and fear. Lord of the Flies is the archetypal book about this subject. It tells the story of a bunch of British kids stranded on a small island without any adult supervision. They create a parody of human society which ultimately fails horribly towards the end.

The book is short, but to the point. Sections of it are almost unbearable to read, not because it features monsters or supernatural creatures, but because you feel deep inside that it is the truth, that these things happen and that they do because of something deep inside each of us.

The only failing of the book, I feel, is that Jack and Roger are portrayed as classical psychopaths and it is clear from the beginning that one cannot empathise with them. A slightly longer story that would have made the effort to make these characters slightly likeable would have had an even deeper impact. In that case, I fear, the book would have become completely unbearable. People need their illusions about the society around them; shattering them completely would not do.

This book is a must read for any student of human psychology and one of the best books to reference at parties to make you look smarter than you are :-) I've actually read the book because I was doing that too much, but had only seen the movie. I wonder if I should get other works from William Golding, since I liked this one so much.

Wednesday, November 16, 2011

SET versus SELECT in T-SQL

Let's start with an example:
SELECT @SiteId=isnull(SiteId,0) FROM Orders WHERE OrderID=15
UPDATE Order_Sites SET SiteID=@SiteId

Can you spot the problem? What if SiteID in Order_Sites is not nullable? What if there is no order with OrderId 15?

That's right, when you select into a variable, you must be certain that the query returns any rows, otherwise the variable will not be set at all.

The solution is to add another operation that sets the value correctly. Here are three possible options:
  • Set @SiteId to 0 before the select.
  • Set @SiteId to isnull(@SiteId,0) after the select and simplify the select to not contain the isnull.
  • Use the select as an argument of the isnull operation:
    SET @SiteId= isnull((select SiteId from Master_orders where OrderID=-1),0)
    Yes, you can do that.

Either way, always pay attention to this gotcha in using SQL.

Thursday, November 10, 2011

Have children, please!

"Oh, no! Siderite's blog has been hacked", you will think immediately. People who know me know how I feel about having children, and that is: I don't feel anything. I seem to lack that inner feeling that makes people procreate for no good reason. And while I am at the subject, I do not deny the existence of this feeling in the world and I don't believe most people are like described below, at least I hope so, but it just hit me that so many times, people have said something and meant another. I will elaborate. Stay assured, my blog was not hacked yet.

You know those dreams we have when we are young? We will get rich and famous, we will find true love, we will be the best at what we do, we can do anything if we want, we can quit anytime (but we don't want to), we will always have time to lose weight and go to the gym, etc. We actually believe those things will happen for most of our youth and early adulthood and some of us actually do something about it, while the most just expect it will happen if they wait long enough.

Well, after a while, reality hits home and we understand that we actually cannot do all of those things, maybe none of them and that our life will not get any better than it is on its own. Some people, at this moment in life, start thinking about children. This way they can delay losing hope by passing it on to their children. That's why many parents are disappointed with their offspring, not because they actually thought their children were special, but because they forced themselves to believe it. In the end, they spawn other normal people, just like them.

You may feel that I am too much of an asshole saying these things, even more than usual, but I don't think so. You see, the assholes are people who spontaneously start advising you to have children, like they already have or plan to. When they say that, they are saying "For a moment now, I thought you might be better than me and I felt a little threatened. Have some children, please, so I can feel better about myself". Have you ever heard the one about children "fulfilling you"? Do I look half full to you? My life does have meaning and I am quite happy with it. I don't need children, therefore I am not having any. If I look unhappy, it may be because I still have hopes for myself and I still believe I can do better. I get disappointed in myself because I expect a little more from me.

I had to write this post because the only times I actually considered having children for more than one second was when I was depressed for not doing something as well as I wanted or when not having time to fulfil ALL of my dreams. I just realised that. There was never a content, happy time in my life when the thought ever crossed my mind.

Now I know that alphish or hormonal males and females do naturally feel the need to have children. I understand the overall need for our species to procreate (although, not right now, when we are too many to fart without a human nose having to smell it). I also don't begrudge or disrespect people having children (as long as they keep them out of my face). However, think long and hard before you tell someone to have children. What is actually the reason you are saying that? Aren't you a bit of an asshole, even if it were any of your business?

Monday, November 07, 2011

Careful when reusing Javascript RegExp objects

I had this operation on a Javascript object that was using a complex regular expression to test for something. Usually, when you want to do that, you use the regular expression inline or as a local variable. However, given the complexity of the expression I thought it would be more efficient to cache the object and reuse it anytime.

Now, there are two gotchas when using regular expressions in Javascript. One of them is that if you want to match on a string multiple times, you need to use the global flag. For example the code
var reg=new RegExp('a','');
will alert 'baa', because after the first match and replace, the RegExp object returns from the replace operation. That is why is normally use the global flag on all my regular expression like this:
var reg=new RegExp('a','g');
(alerts 'bbb')

The second gotcha is that if you use the global flag, the lastIndex property of the RegExp object remains unchanged for the next match. So a code like this:
var reg=new RegExp('a','');


will alert 0 both times. Using the global flag will lead to alerting 1 and 2.

The problem is that the solution to the first gotcha leads to the second like in my case. I used the RegExp object as a field in my object, then I used it repeatedly to test for a pattern in more strings. It would work once, then fail, then work again. Once I removed the global flag, it all worked like a charm.

The moral of the story is to be careful of constructs like
when _reg is a global regular expression. It will attempt to match from the index of the last match in any previous string.

Also, in order to use a global RegExp multiple times without redeclaring it every time, one can just manually reset the lastIndex property : reg.lastIndex=0;

Update: Here is a case that was totally weird. Imagine a javascript function that returns an array of strings based on a regular expression match inside a for loop. In FireFox it would return half the number of items that it should have. If one would enter FireBug and place a breakpoint in the loop, the list would be ok! If the breakpoint were to be placed outside the loop, the bug would occur. Here is the code. Try to see what is wrong with it:

forEach(typesResponse,function(type) {
if (type&& {
var m=/(\{tag_.*\})/ig.exec(;
// type is tag
if (m&&m.length) {
Click here to see the answer

Saturday, November 05, 2011

THE PLEASURES OF STATISTICS: The Autobiography of Frederick Mosteller.

Book cover
I was looking for autobiographies, since I liked quite a few of them lately and I felt like more, and so I got two. One is interesting because it is finally in print after 100 years since the author's death. I am talking about the first volume of Mark Twain's biography. However, I really could not make myself read it: the language was so pompous and the content so lame that I felt pain trying to.

Not so the second book, which seemed even more unlikely for me to like it: THE PLEASURES OF STATISTICS: The Autobiography of Frederick Mosteller, but which I did. It started with a few projects that Fred Mosteller participated in, explaining the day to day concerns and situations of a statistician while working on them. I thought at first that the book is going to be all like this, so after about a third I was about to abandon the read. You see, it was all very interesting from a professional statistician's point of view, but I wanted the more personal viewpoint of the man. And so I got it. Suddenly the book changed pace and went with the early life and education of Mosteller. The end of the book again covered some cases of work, but this time with a personal touch that explained the motivation behind the acts. And finally, the editor's epilogue, written from testimonies of friends and colleagues.

In this review, a Theodore M. Porter argues that the autobiography was flawed, as it covered little of his family life and couldn't reconcile the different viewpoints that appeared in the book, like the scientific and personal. But I disagree. The autobiography was unfinished and I guess the editor did the best he could with what he had, but it couldn't have been a lot different from what Mosteller himself intended. You start with the actual work: statistics, explained in layman's terms, then you continue with the actual man, explaining the origins and education, then you get back to statistics, but examining the work from the personal viewpoint of the man described. Yes, he could have written about his family more, but it wouldn't have been about statistics. The little he does write about his wife is about how supportive she was throughout his career. And yes, the tone of the book is a bit clinical, but this is how the writer actually thought like; he was a scientist in the true sense of the word and I liked this book exactly because it made me understand how such a man thinks and feels.

Even more than the structure of the book and the insight in the mind of a conscientious and brilliant scientist what I liked most is the peek at the world in the middle of the 20th century and how strikingly different it was from what we see today. The concerns of a teacher towards the best method to get his students to understand and like the subject, the way people were getting together to solve problems and worked for years on a book or bunch of science papers, the way academia was also supportive, not only political, and most of all, to see how people can be both brilliant and empathic, both clinical in science and warm in person.

I wouldn't recommend this book to everyone. I had a hard time reading it to the end and paying attention to every bit. Nor should one study it like a school manual, because as far as I see, the book is about a man's soul and you only have to understand and feel that. Whether it is because of my autobiography fad or because I resonated with the man or for some other reason, the bottom line is that I enjoyed reading the book. Maybe you will too.