Tuesday, 20 December 2011

A picture is worth a thousand words: North Korea in the dark

Check out this article. I haven't even read it yet, but the image they present is saying it all. Even someone such as myself, a firm believer in national sovereignty and the right to follow whatever twisted philosophy one chooses as long as it doesn't affect others, can't remain indifferent to it. What you see above and below North Korea are China and South Korea. You can tell North Korea apart, because it is the dark patch.

Friday, 16 December 2011

Default parameters in Attribute constructor

Update February 2016: Tested it on Visual Studio 2015, with the Roslyn compiler, and the problem seems to have vanished.

Here is the now obsolete post:

A class in .Net can have default parameters, with values that are specified in the constructor signature, like this:
public MyClass(int p1,int p2=0) {}

If the class is inheriting from the Attribute class, then one can also specify property values when using it to decorate something, like this:
public class MyTestAttribute:Attribute {
public int P3 { get;set; }
}

[MyTest(P3=2)]
public class MyClass {}

What do you think this code would do?
public class MyTestAttribute:Attribute {
public MyTestAttribute(int p1,int p2=0) {}
public int P3 { get;set; }
}

[MyTest(1,P3=2)]
public class MyClass {}


Well, I tell you what is going to happen. Visual Studio and ReSharper both will see no problem with the syntax, but the compiler will issue an error based on the exception "error CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type", but without specifying any file or line.

My guess is that it is trying to interpret the P3=2 line as an expression to be calculated and passed as the second attribute of the constructor. What I was expecting is to set the default value to the second constructor parameter, then set the property P3. The vagueness of the error points out to a possible bug.

Thursday, 8 December 2011

The Chrome undocumented special URLs

It all started with this site that got stuck in the Google Chrome's DNS cache so that any changes to the Windows/System32/drivers/etc/hosts file were ignored. I didn't want to close all Chrome windows (since the DNS cache is application wide in Chrome), so I googled for an answer. And here it was, a simple url that, typed in the Chrome address bar, would allow me to clear the cache: chrome://net-internals#dns.

But there are a lot more cool things there: testing of failed sites, a log of browser network events, control over open connections and so much more. That got me curious on other cool chrome:// URLs and I found some links listing a lot of them.

I don't have the time to parse all these cool hidden Chrome URLs and review them in this blog entry, so I will just list some links and let you explore the goodness:
Google Chrome’s Full List of Special about: Pages
12 Most Useful Google Chrome Browser chrome:// Commands
About and Chrome URLs

Update: The Chrome url containing all others can be found at chrome://about/.

Tuesday, 6 December 2011

The Eye of the World by Robert Jordan

Book coverThe Eye of the World is the first book in the series called The Wheel of Time, by Robert Jordan. Written in 1983, it is very similar to Lord of the Rings. It features a complex world of nations and races with their own languages and cool sounding names, a battle of good light versus evil dark that is so ridiculously polarized that at first I thought I couldn't finish the book, a party of different people in which the main character is a poor country sheppard boy, a quest that has the goal of saving the world via a long trek of personal transformation.

Actually, if I think about it, it seems almost entirely inspired by Lord of the Rings, with none of the innovations that appeared since playing any effect except maybe The Chronicles of Thomas Covenant the Unbeliever, when describing the Blight. Something that is clearly different in the book is the role of women.

While Tolkien had them placed high on a pedestal, queens and princesses that were supposed to inspire men but not be touched, Jordan presents them as important members of the party, with Moraine, the "wizard", holding most of the authority. Actually, it goes further than that, giving all women characters an almost indomitable ability to influence men. Only one female in the entire book is evil, and that for a very brief period of time, and none of them are weak in any way. It doesn't even matter much that The One Power has two sides, one female and one male, and that the male is tainted by The Dark One. Even if they would have magical power, men are doomed to be ruled by women in The Eye of the World and probably the rest of the books.

The evil Shai'tan is a dark entity with burning eyes and eternal rage, imprisoned yet powerful, corrupting everything he touches, while the power that opposes him is white pure light that heals, purifies and avenges. The only shred of ambiguity comes in the shape of The Children of the Light, a warrior sect dedicated to fight evil, but that are nothing more than pompous gang members that define evil as anything they don't like.

All and all the book was pleasant enough and, being December, I plan on reading at least the next book in the series before I start with a technical one. However, it doesn't come close to most of the books I've read recently. The simple design and clear inspiration is probably the reason why they want to adapt the story to television, now that the likes of Game of Thrones have shown the model successful. If the quality of the books does not improve in time, it may be so that it would be more effective to wait for the films instead of reading the book. Then again, I will make up my mind after I've read more. I have hope.

Wednesday, 30 November 2011

Tuesday, 22 November 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.

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

Saturday, 19 November 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.