Sunday, January 16, 2011

Odd thought about PI

I was just looking at an article that suggests replacing PI with Tau which is not shocking in any way. The relationship to the circle is just a multiple of what we're used to. However, in thinking about this I thought that the reason PI and indeed Tau is such an odd number is because they are based on a single dimension rather than a geometric relation between two two-dimensional values. A radius is always the same radius whether it is thought of in two dimensions making a circle or three dimensions making a sphere. It occurs to me that the complex nature of PI is so because it has to do with the relationships of a particular value expressed in different dimensions.

Wednesday, January 12, 2011

Extra unwanted empty namespace when adding XElement

I've been scratching my head over a problem today. While writing a program to modify an XML document I discovered that adding an XElement and then writing the document out to file results in an extra and unwanted xmlns="" being output. For example:

Original XML=

<root>
 <doodaa>value</doodaa>
</root>

When we add an element to the root we get:

<root>
 <doodaa>value</doodaa>
 <wimwam xmlns="">value</wimwam>
</root>

This often upsets things which is a pain and happens when the XML document has a namespace specified somewhere.

To overcome this problem we need to ensure that the namespace of the added element is the same as that of its parent so we can interrogate the parent element and set the namespace accordingly.

In my example I just looked at the document root element but you may have a more complex scheme to cope with. The actual code I used was as follows:

XDocument doc = XDocument.Load("somestuff.xml");
string docNS=((XElement)doc.FirstNode).Name.NamespaceName;
XElement ne = new XElement(XName.Get("wimwam", docNS), false);

Now, writing out the document I get the desired effect of:

<root>
 <doodaa>value</doodaa>
 <wimwam>value</wimwam>
</root>

Sunday, January 09, 2011

Guns don't kill people

The American archetype of today is a tall blonde man shouldering his way through a doorway with an automatic pistol clenched in his doubled fist. This image seen on popular television programs, films and movie publicity posters all over the world shows an American who is impotent without his 9mm weapon in his hand.
The more this image diffuses into the consciousness of the world, the more violence we see, not only from the youth of America whose "right to bear arms" affords them easy access to the tools of death but from the other young people of the world who are too so inured to death and violence through Hollywood anaesthesia that it becomes an option to solutions that no unpolluted person might consider.
Teenage school rampages and the gunning down of persons who lead lives that place them in the public gaze is so commonplace that we are almost immune to the shock of it now. I remember the assassinations of John and Robert Kennedy. I was too young to understand but shocked all the same when my mother told me about what had happened and the world was shocked too because the rarity of the events made them exceptional.
The more we see of men peering from behind guns, the more it becomes an accepted part of
our field of view. 

Will we ever rise from the barbaric throwing of stones and stabbing with sharp sticks to solve problems and become truly civilized enough to forever leave our brutal ape heritage behind? I often admit that we are nothing more than sophisticated monkeys. Perhaps it's time to become people instead.

Friday, January 07, 2011

Visual Studio 2008 dies without error when editing XAML

I only post this because working on a client's machine recently I had a new install of Visual Studio 2008 that just disappeared whenever I tried to edit XAML files or even XSD files. This was due to a known problem with the Visual Studio editor system and some time back a hotfix was issued for the problem (KB968760).
It happens that this hotfix has been superceded several times now and in order to fix the problem Mark Wilson-Thomas from Microsoft kindly provided be with the link to the hotfix that worked. I now have my VS 2008 up and running again. If you need the fix it can be obtained from here

Thursday, January 06, 2011

WOO HOO!!!!

Been talking about this and looking forward to it for more than a decade!


http://www.bbc.co.uk/news/technology-12124887