Can you imagine 1922? It was 85 years ago. That means that almost certainly all the people that worked on this movie are now dead! But it is still a masterpiece of cinema. They did that with no previous inspiration. After you watch this, you can only ask yourself how come people have 85 years of example and they still screw movies up. So here it is: Nosferatu

I've accidentally stumbled upon a thing called OutputCache. Weird little thing, I thought, how come I didn't hear about it? It seemed such a wonderful concept: just cache the output of ASP.Net pages and controls for a specific amount of time, specify for what parameters or controls or properties the cache is valid for and if it is shared between different users. Then just output the cached version and don't execute the entire thing all the time.

I tested it and it works. Most useful I find it for user controls. One can put a list of unchanging stuff like a list of cities or provinces or even customers in a user control, cache its output and forget about it.

How to use it:
A) declaratively. Put in the page or control something like this:
<%@ OutputCache Duration=100000 Shared="true" VaryByParam="none" %>
Just read the link above for the details.

B) programmatically. Put in the page or control code something like this:
CachePolicy.Cached = true;
CachePolicy.Duration = new TimeSpan(1, 0, 0, 0, 0);
CachePolicy.VaryByParams.IgnoreParams = true;

Update: it has come to my attention that this returns an error with the message "The CachePolicy cannot be used, since the control is not being cached." which is returned when the CachePolicy was not instantiated with a BasePartialCachingControl as a parameter. The solution, it seems, it is to also decorate the user control with the PartialCaching attribute.

ex: [PartialCaching(20)] - set the caching to 20 seconds.

C) One can even validate the cache programmatically after whatever of A or B methods were used like this:
Response.Cache.AddValidationCallback(new HttpCacheValidateHandler(MyCacheValidatorMethod),null );

That's it!

This book is written by a guy that made a small company dedicated to programming with free tools. Thus, it tries to show how to debug ASP.Net assuming that you come from an ASP background and that you don't have Visual Studio .Net. So I don't think I have to tell you how much useless information there is in there. It even covers programmatic code tracing.

That doesn't mean it is a bad book, just useless for me. If you expect some wonderful debugging frameworks or code structure that would allow you to easily debug your applications, then this book is not for you. Not to mention that at the time it was written, Visual Studio 2005 was not out yet.

Bottom line: just a hands on approach and some Google when you meet problems will solve any problems that are solved by this book.

and has 1 comment

Dan Dobos is a Romanian writer and so I find it difficult to bad mouth his work. He also had bad luck with this one, as I'd just found one of the better writers of sci-fi and read a few of his books before trying to (re)read The Abbey.

Bottom line, The Abbey tries to be a Romanian Dune, with some Christian theology thrown about, a planet controlling the resources of the entire human dominion, people with heightened intelligence, instincts, subtle two way dialogs and verbal manipulations, etc. It fails. The characters are inconsistent, obvious, their best attempts at charade are ludicrous, their motivations are inedible, the whole human galactic evolution completely unbelievable. The writing style is also very shallow, made only of dialogue and inner thoughts, with little detail of what is actually going on.

Although I admire the attempt, the basic ideas and the fact that he got published in a country where people rarely buy books and if they do they don't buy Romanian authors, this series is a failure. Better luck next time.

and has 0 comments

Enough said, I started reading anything this guy wrote. I've found Fallen Dragon, a single book this time, but filled with ideas that obviously grew into the Commonwealth Saga. With this earlier novel I did find Hamilton's Achilles heal, the one thing that bothered me in his books more than the slight over detailing of everything: the characters have no freedom.

Let me expand on that. When you write something, you have the characters in your head, fighting and shouting to let them free to do what they want. If you do that before they are fully matured, they break havoc with your writing, even considering you have the skill. However, when you force them to do your bidding like slaves, you also damage your story, because they lose credibility and consistency.

In this book more than others, the characters were forced to do something that they should never have done. A soldier looses his squad to a bunch of idealistic galactic eco terrorists, but eventually joins their ranks. That is just not possible. I was wriggling in bed, waiting for the moment the hero would remove his mask and kill that brain damaged bitch. He did no such thing, just letting his mates die for no reason. Thinking back, the same happened with Judas Unchained, when all characters willingly marched against an alien that was clearly lacking any resources and just trying to escape in a wild wild west kind of quest "let's all personally go and kill the bad guy".

Back to Fallen Dragon, it is an interesting story, with some moral teachings as well as a delicate temporal paradox, but it's not comparable with Hamilton's latest books.

and has 0 comments
After finishing the Commonwealth Saga, by the same author, I started reading the next series: The Void Trilogy. As in the aforementioned saga, the story does not end in any way at the end of the first book, you have to read all three books to reach the end, which effectively makes this another huge monolithic story, not a series or saga.

Set in an even more technological advanced future, but in the same Commonwealth universe, it depicts the interactions between a powerful pseudo-religious void worshipers, ANA (a quantum artificial intelligence where people download when the are tired of living and the next evolutionary phase of the SI) and its competing factions, the different alien races and the void, which is a dark impregnable sphere in the middle of the galaxy that only some psychic humans seem to penetrate.

The style is the same, the writing as almost flawless as before. I do think that P.F. Hamilton is one of the greatest sci-fi writers I've read, up there with Tolkien and Herbert.

and has 0 comments

I have seen the movie on TV a while ago, but didn't catch the start, so I never knew what the name was. Finally, someone in a Romanian book club found the translated print here and reminded me of it and told me that it was based on a book. I've decided to read it in its native language, a bit scared that I would understand nothing of it, but the French is pretty easy to understand. Maybe because the author is Belgian :)

The story of Fear and Trembling is about a Belgian girl, born in Japan (just like the author), employed in a big Japanese corporation as a translator. Due to her inability to understand the local customs and the irrational feelings of her employers, she is demoted time after time until she ends up replacing toilet paper in the water closets.

The book itself is not meant as a comedy. The main character sees everything with a stoic detachment, analysing both her feelings and the feelings of others, trying to make sense of a world that she can't seem to fit in. It made me understand more than ever the illusory nature of reality. Both her and the Japanese were occupying the same space and time, were observing the same events, but their realities were completely different. That clash of incongruous realities is the core of this small novel.

A bit too French for my taste, not in the language, but in the endless repetitions of metaphoric interpretations of the same event, that overwording of inner thoughts that makes French writing sound pompous. However, I did enjoy the book, I recommend it to anyone wanting a light and distracting reading.

and has 0 comments
I wanted it to sound like Fruit of the Loom, for the connoisseurs in gaming :), but failed miserably. This blog post is about the exotic (and shamelessly expensive) fruits one can found in market stores.

The first one is the Lychee fruit. It is small, has a rough skin that has to be removed and a big seed inside. It leaves little else, but the flesh is very tasty, with a taste like that of a grape, but less sour and stingy. No wonder it is called the Chinese grape. I recommend it, at least try it once.

The Mangosteen. Now that's a fruit. Big as a small apple, it has a similar hard skin to remove and a similar taste as the Lychee, with the added advantage that it has more flesh. I would venture to say that this is the most tasty fruit I'd ever tried, even if a little too sweet. There is a funny story here, too. When I was a child I used to keep newspaper bits of the "did you know?" column (back in the days when newspapers has a science and information section). One of them said that the Mango is the king of the fruits, the very best in taste, but hard to transport because it rots easily. I was disappointed when I first tasted mango. It wasn't even tasty. But apparently, the author of the article made a confusion between the Mango and the Mangosteen. 20 years later, the article is vindicated ;)

The Carambola. A yellow star shaped fruit that can be bitten into, has the taste of a Quince fruit and a bit of its texture, but a bit finer. I would prefer it to quince, even if I don't particularly enjoy apple/pear tasting fruits.

The Kiwano, or horned melon. This is an odd fruit. It can be cut in quarters and eaten like a melon, has a greenish yellow color and taste like a combination of cucumber and banana. It is an interesting experience :)

I have tried another fruit, one that looks like a plum shaped (but smaller) orange. And it is :) It is like an orange pill. If it weren't for the price, I would use it to make arranciata. The name is kumquat and it can be hybridised with lime to fruit limequats. There are a lot of citrus fruits in the world, not only the orange, lemon and grapefruit!

For other exotic (for me) fruits, check out Part 2.

and has 2 comments
I've been to a small village near Sibiu, home of my parents in law, called Sarata. First major trip outside Bucharest by car, we managed to reach Sibiu, Ocna Sibiului, Sighisoara, Basna, Balea Lac, Paltinis and to travel the entire area back and forth.

We have become intimately familiar with dust and washing the car, but it was almost worth it, if it wasn't for the permanent noise (yes, I went there for the silence) and I got people (and their atomic children) shouting, screaming (and that without actually fighting, simply communicating), phones ringing (and I thought it was bad they didn't have a phone) and roosters making all kind of noises (man, I hate that rooster!). On top of everything, I've spent around two nights fighting the excessive warmth and another two fighting an intense case of indigestion.

But you won't be interested in that :) Anyway, let me review some of the touristic impressions I had.

Firstly, Sibiu. Because of the "European capital of culture" thing, Sibiu is now transformed. Not that it's not a city like any other, but it is now completely crowded by cars, parking spaces, tourists, etc.

The same impression I got from Sighisoara, where I was expecting a medieval town with cute little taverns and interesting castles, yet I found a city in reconstruction, filled with cafes and "Authentic Souvenir" shops filled with things of incredibly bad taste.

Ocna Sibiului is a small tourist place with salty and iodised waters. I'd expected a place full of old people coming to treat their illnesses, but I did not expect the level of mismanagement of the place. Imagine a few holes in the ground filled with naturally salty water, but not cleaned, with a few old wooden stairs that looked ready to crumble at every step. We had to pay to enter, the prices inside were huge and in order to find a place to change your clothes you had to find a bush somewhere. I had fun in the water, as I could leisurely fall asleep in a water that seemed to easily sustain people of ... lesser gravitational pull as myself.

Basna seemed nice, but we didn't stay long. An expensive hotel is placed there, with pools and everything, and then there are the mountains right there, ready to be hiked.

Balea Lac, just a short trip, even nicer place than Basna, but really commercialized, souvenirs and stuff. The hotel being just a normal mountain hotel.

Paltinis is just like Balea, but villas and hotels are sprouting there like mushrooms.

Some very nice villages and locations are found by travelling between the major place of tourism. We've found a 702 years old evangelic church in Valea Viilor, a small village near Copsa Mica, with an old woman greeting us with Guten Tag, and then by Buna Ziua, even if we were in Romania. The wife loved the architecture and I loved the cool air. Also a nice place was in Cisnadioara.

What was a little off putting was that we were guiding ourselves by a map made in 2000 and after reaching Valea Viilor, for example, we tried taking a road on the map and a villager said "Oh, that road? It isn't functional for more than 20 years now". Also, getting out from a temperature of 19C in one of 30C was not "cool", either, so we preferred watching the beauty of nature from inside the car. Not having to smell the nature was a plus for me, as well.

Sorry for a lack of pictures, but I don't have a camera :) I will remedy this for sure, but it's not a priority right now.

and has 1 comment
Am I turning metal? I used to hate songs played by long haired guys barking aimlessly on a heavy and repeating guitar riff. But I really enjoy listening to Sonata Arctica. Maybe because they're Finnish? :) I am developing a taste for Finnish music, apparently.

Anyway, here is a live performance of the song Broken, which I like best so far. I did look for an official video on this song, but drowned in home made crap videos. I did find official videos for other songs, but the band seemed even less charismatic in those, trying to seem really upset and managing to look like a shampoo commercial.



Another song of theirs I like is Replica.

You are trying to use a WebMethod or a web service ScriptMethod in Javascript and you get an InvalidOperationException saying something about a circular reference. It happened to me when trying to read a DataTable in Javascript.

Why. The Javascript serialization of DataSets, DataTables and DataRows was available once in the ASP.Net Ajax web extensions. That's why you probably found a lot of Google results with people that could either only serialize DataSets, but not DataTables, or people that made it work by magic by adding some lines in the converters section of web.config, things that can't possibly work with your setup. Then, the option was removed in the final version of ASP.Net Ajax, only to be readded in the ASP.Net Futures, which is a test playground for future features of the platform.

What. There are several options, one being to reference an older version of ASP.Net Ajax and uses the converters there. But why bother? It's unlikely you use the DataTable or some other object in Javascript with all the options of the C# object. You probably just want to itterate through rows and read properties. So build your own converter.

How. Create a new library project. Add a class named DataTableConverter that inherits from JavaScriptConverter, and implement: IEnumerable<Type> SupportedTypes, IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer) and object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer).

You probably won't need to Deserialize anything, you can leave that unimplemented. The list of convertible types is easy enough, all you are left with is the Serialize code, which is actually very easy, too. Then all you need to do is add this in the web.config file:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization >
<converters>
<add name="DataTableAjaxFix" type="AjaxTypeConverters.DataTableConverter"/>
</converters>
</jsonSerialization>


And here is the complete C# code of my DataTableConverter, but you can easily adapt it to anything:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web.Script.Serialization;

namespace AjaxTypeConverters
{
public class DataTableConverter : JavaScriptConverter
{
public override IEnumerable<Type> SupportedTypes
{
get { return new Type[] {typeof (DataTable)}; }
}

public override object Deserialize(IDictionary<string, object> dictionary, Type type,JavaScriptSerializer serializer)
{
throw new NotImplementedException();
}

public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
{
DataTable listType = obj as DataTable;

if (listType != null)
{
// Create the representation.
Dictionary<string, object> result = new Dictionary<string, object>();
ArrayList itemsList = new ArrayList();
foreach (DataRow row in listType.Rows)
{
//Add each entry to the dictionary.
Dictionary<string, object> listDict = new Dictionary<string, object>();
foreach (DataColumn dc in listType.Columns)
{
listDict.Add(dc.ColumnName, row[dc]);
}
itemsList.Add(listDict);
}
result["Rows"] = itemsList;

return result;
}
return new Dictionary<string, object>();
}
}
}

Yesterday I was trying desperately to understand why my web site was crashing without any error, the only information I could get being that the connection to the server has been reset. I've spent hours trying to determine what was wrong. Apparently I needed a break, because today it took me a few minutes to realize what it was.

First of all, duh! If there are issues with the connection server, look into the Windows Application Event Log. But we'll get there.

The "error" appeared at any postback after I loaded a certain page, but only if that page displayed a minimum of data. Above that threshold I would get the server reset thing that you can see both in IE7 and FireFox2 in the animated GIF. Basically the error messages were:
FireFox
The connection was reset
The connection to the server was reset while the page was loading.

Internet Explorer
Internet Explorer cannot display the webpage
Internet connectivity has been lost.
The website is temporarily unavailable.
The Domain Name Server (DNS) is not reachable.

Ajax UpdatePanel
Server returned error 12031

So, today I realised I should look in the Application Event Log and this Web Event Warning was displayed (shortened it a bit):
Event code: 3004
Event message: Post size exceeded allowed limits.

Process information:
Process name: aspnet_wp.exe

Exception information:
Exception type: HttpException
Exception message: Maximum request length exceeded.

Stack trace: at System.Web.HttpRequest.GetEntireRawContent()
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.get_HasForm()
at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
at System.Web.UI.Page.DeterminePostBackMode()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


It turns out I was putting a lot of data into the ViewState, which, as you know, is saved as a HiddenField (a.k.a. hidden html input) and the size of it exceeded the set up maximum POST size.

Solutions:
A. Add this code to your page: (NET 2.0)
 protected override PageStatePersister PageStatePersister
{
get
{
//return base.PageStatePersister;
return new SessionPageStatePersister(this);
}
}


This should put your ViewState into the Session, rather than in the page. This solves some other issues as well, obviously.

B. Increase the maximum Request limit (default is 4Mb)
- In the Machine.config file, change the maxRequestLength attribute of the <httpRuntime> configuration section to a larger value. This change affects the whole computer.
- In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:
<httpRuntime maxRequestLength="8192" />

This is an exact quote from the Microsoft support page.

That's it, folks!

Update:

The maxRequestLength maximum value is 2097151, that is less than 2.1Gb. No file that exceeds this size can be uploaded through the default upload mechanism.

You may have noticed that in debug mode, in Visual Studio, you have a little magnifier glass next to some of the variables in Autos, Local or Watch debug windows. Once you click on it, you get to visualize your data in a more comprehensive way. A good example are the DataSet Visualizer or the DataTable Visualizer which show you in a normal DataGridView a DataSet or DataTable.

The good news is that you can build your own visualizers and that in a very simple way. Here are the quick steps to achieving this, followed by some links to other people detailing:

  1. Create a new Visual Studio class library project
  2. Add a reference to the Microsoft.VisualStudio.DebuggerVisualizers library you can find directly in the .NET tab
  3. Go to Add New Item and choose Debugger Visualizer. That will create a small class for you with ToDos and stuff like that. What is important is that you don't really need to declare the Type of your data object in the class, as suggested by the template.
  4. Remove everything from the class except the override of the Show method
  5. Change the Show method in order to use your own data type.
  6. Add a reference to System.Windows.Forms
  7. Add a Windows Form to your library and make it display your data the way you like it
  8. Add the following lines to decorate the namespace of your visualizer class:

[assembly : DebuggerVisualizer(typeof (--YourVisualizer--),
Target = typeof (--Your Type--),
Description = "--Your Type-- Visualizer")]
namespace ...


Warning: use a different description from whatever default or own visualizers that are already there. Use stuff like "Siderite's DataTable Visualizer" not "DataTable Visualizer", since there is already an out-of-the-box visualizer with the same name and you won't get to see yours.

Now compile. The resulting DLL can be either copied in My Documents\Visual Studio 2005\Visualizers in this case any contained visualizers will be available only to that user or in C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\Visualizers to make the available to all users.

That is it! Now links to others explaining in more detail:
Writing a Visualizer at MSDN
Post on Debugger Visualizers from 4GuysFromRolla
Julia Lerman on Debug Visualizers

Update:
A problem with this solution is that the debugger visualizer expects your target type to be ISerializable. But what if it is not? The solution is to add another parameter to the DebuggerVisualizerAttribute like this:
[assembly : DebuggerVisualizer(typeof (--YourVisualizer--),
typeof (--YourVisualizerObjectSource--),
Target = typeof (--Your Type--),
Description = "--Your Type-- Visualizer")]
namespace ...


You see, the debugging is done through communication between a debuggee and a debugger. The VisualizerObjectSource is the debugee and the default one tries to serialize the target object and send it to the debugger. What you have to do it create your own class, inheriting from VisualizerObjectSource and overriding public void GetData(object target, System.IO.Stream outgoingData). This method has access to the actual object, so you can transform it into any other object, one that can be serializable.

A simple example is a DataView or a DataRow. You take the DataRow, you add it to a Table and you return the DataTable, which is serializable.

Another issue you might stumble upon is a weird Access Denied error for the DLL containing the visualizers, especially after adding a VisualizerObjectSource to the library. The solution is to add trust level to full to the site you are debugging. I am looking for a more elegant solution, but so far what you have to do is add this to the web.config of the site you are debugging:

<system.web>
<trust level="Full" originUrl="" />
</system.web>

More links, specific to this update:
RemoteObjectSourceException: Graphics is not marked as serializable
Visualizers For Web Debugging

Yes, the situation is fairly simple, you do a parentControl.FindControl("someOtherControl") in ASP.Net and you get controls that are not in parentControl. Why?

Because apparently, FindControl wants a NamingContainer in which to search. If the parentControl is not an INamingContainer, it will look into the parentControl's NamingContainer.

Sollution? Create your own FindControl method, one that recursively goes through the child controls and looks for the specific ID.

and has 0 comments
I've accidentally stumbled upon a very interesting video of a science conference about sleep. Called "Sleep, Waking and Arousal" it details a very interesting compendium of information about sleep in humans, mammals, other vertebrates and even fruit flies. I am posting the link here, but what is even more interesting is that it is part of something called the "The University of California Television" that has its own web site with a lot of (presumably) interesting videos.

Sleep, Waking and Arousal
The University of California Television