and has 0 comments
No Comment

and has 1 comment
"Hey!", you will shout, "You are Romanian, what do you know about the American mind?". And you would be right. I don't know much about the American mind, but I do know what I see on the news and in the movies. And three movies I've recently seen opened my eyes even more.

First of all This Film Is Not Yet Rated talks about the MPAA and the way they enforce the ratings on movies. You might think that is not so important, but each rating brings with it a different possible audience size. There is a huge difference between the last two ratings R and NC-17 because an NC-17 movie doesn't get picked by distribution companies, nor does it reach into theaters.

What does that mean? It means people in the entire USA see nothing but what the MPAA deems "decent". Statistics show that in the last 50 years they mostly rate R violent movies, no matter how violent, while NC-17 are films which involve sex or even the manifestation of sexual pleasure. Do you think that has any connection with the fact the average American is a violent and militaristic puritan? Interesting enough, the MPAA "council" is completely secret. Movie directors get answers like "your film is NC-17 and we don't tell you who we are and why we rated it like this". Also, check out how the MPAA is financed by the biggest 7 film studios in Hollywood, which own 95% of all movie industry in the US and belong to conglomerates that own 90% of the entire US media!

Another interesting fact is that in that council there are two religious representatives, which brings me to the next two movies: Jesus Camp and The God Who Wasn't There.

Jesus Camp is a pretty famous documentary, because it was mostly comprised of filmed video footage and there were almost no comments in it, yet it spun a lot of controversy. Fundamentalists praised it and so did Anti-fundamentalists and atheists alike. It showed how children are entranced and then conditioned to believe in Creationism, to actively oppose abortion (when they are children), to support Bush and to think that they must act as soldiers that bring America back "under God". This camp teaches the Pentecostal religion, maybe only an extreme version of it, but what is majorly important in this religion is the Rapture. The Rapture is the second coming of Jesus, which will quickly take all true believers to Heaven, then end the world. Maybe even reformat the hard drive. 22% of Americans are Pentecostals who believe Jesus will come during their lifetime. Why wonder Americans don't really care what happens to the Earth? A major Pentecostal preacher is a weekly counselor for the White House and, interviewed in this movie, said that if Evangelicals vote, they determine the outcome of US elections. Pretty scary stuff. Even more scary is the fact that they are a big religion with between 40 and 80 million adepts and no one can do anything about this child brainwashing that they do in this camp (and a lot of others, I guess). David Byrne, from Talking Heads, said in his blog that he saw no difference between this camp and the extreme Muslim madrases training people to blow themselves up.

The God Who Wasn't There starts off like an atheist movie that proves most of Christianity is copied from other older religions, including details, and that average common sense makes believing in a religion like this kind of stupid. The special effects and direct attacks against religion made me think that this is an extreme in itself. Atheists turned anti-theists and throwing everything they have at poor people that believe stuff like that. This until the guy admitted he was a Christian Fundamentalist until the age of 15, when he actually decided everything he was taught under threat of eternal damnation was plain stupid.

OK. Back to the main point. Now I understand more about the American Mind. I understand how a nation that created the ideas of secular state, individual freedom and freedom of faith can also be hard ass conservatives, God fearing and warmongers in the same time. How most American morality is ridiculously naive when concerning sex while in the same time the US is producing the most adult content in the world. I realize why some of the Americans I talk to are really smart and funny people and others sound like rednecks from old Westerns, why US science is the most advanced in the world while in the same time regulated by people following 1st century morality.

Therefore I highly recommend seeing these films. Eye openers.

and has 0 comments
This is not one of John Saul's best books, but then again, when you say John Saul you say cliche book. All his books contain some sort of drama, usually concerning children, always in a backwater town or suburb, always playing the child in danger, family connection, deep instinctual fears, etc. But some of them are more interesting than others, me liking science related books more, even if I almost always relate to the mad scientists and their evil creations than to the pseudo-moral rednecks that fight against them. This one is plain boring.
The Perfect Nightmare is about a child abductor. He goes for young innocent girls, he takes them into a makeshift playhouse and "plays" with them. Being a mass production book, it presents some brutal violence, almost no sex at all, even if it hints towards it, and the first and largest part of the book is simply puffed with the actions and fears of the people left behind which are mostly average boring people. This makes the book average and boring. The murderer himself is not something truly original, neither is the way he is portrayed.
The ending of the book has a catch, but after reading 90% of it, it doesn't really has any effect. Bottom line: not even for John Saul fans.

and has 0 comments
I have found this very cool game while browsing the net. While I personally hated Sonic games, I found this one strangely interesting. The minimalist design probably did it for me. Anyway, check it for yourselves.

I have been working recently with Page.LoadTemplate and ITemplate.InstantiateIn to add content from user controls to pages or other controls. This thing solves the problem of having to declare abstract classes in App_Code, but poses another problem linked to the lack of object references to the user controls you instantiate. What that means, among other things, is that you lose the ability to use events in your code.

But there is a way to bubble events to the upper controls and catch them. The first thing you should look at is the OnBubbleEvent protected method of the Control object. It catches all the events raised by its controls. Override it and you can catch events and treat them. Now, this method returns a bool value. It tells the RaiseBubbleEvent method (I'll talk about it shortly) if the event was handled or not. If it was, then the event doesn't rise above that control.

Now, about the RaiseBubbleEvent method, also a protected method of the Control object. What it does is go up the object hierarchy and execute on each object the OnBubbleEvent. It also stops if the method returns true. It is so simple and perfect that it is not overridden in any of the ASP.NET 2.0 WebControls.

But there is a catch. Some objects, like DataLists, DataGrids, Gridviews, Repeaters, etc, choose to handle the events in their items no matter what. That's why if you click a button inside a DataList, the event won't bubble to the OnBubbleEvent method from the UserControl or Page the DataList is in. Instead, the event reaches the OnItemCommand event.

So, if you want to use this general bubbling method with WebControls that override OnBubbleEvent, you have two options.
One is use inherited objects that remove this issue altogether (like inheriting from a DataList, overriding OnBubbleEvent, executing base.OnBubbleEvent, then always return false), which might make things cumbersome since you would have to define a control library.
The second option is to always handle the OnItemCommand and other similar events with something like RaiseBubbleEvent(sender, args); . This very line will re bubble the event upwards.

Benefits: the benefits of using this general event bubbling technique is that you don't have to always specifically write code in the OnItemCommand or having to handle OnClick events and so on and so on. Just catch all events, check if their arguments are CommandEventArgs, then handle them depending on source, command name and command argument.

and has 1 comment
I know it's bad taste, but it was too good not to blog about it. I just had this vision of this school bully, pushing kids around, hitting and scaring them. One day, one of the kids fights back and kicks the bully in the nads. So he crumbles to the floor, but then tells everyone how that attack was unmanly and cowardly and then beats the crap out of the kid.

The same thing happened with the 9/11 thing. Two every important American items, symbolically destroyed to show the otherwise almighty US that they can be hit, even by the little people. It hurt like hell and it made everybody angry, but it also made the point.

The vision of the twin towers, as giant testicles (with small sperm inside?) felt hilarious to me...

and has 0 comments
Agent Smith from Matrix once said "I hate this place. This zoo. This prison. This reality, whatever you want to call it, I can't stand it any longer. It's the smell, if there is such a thing. I feel saturated by it. I can taste your stink and every time I do, I fear that I've somehow been infected by it" and that made me like him instantly.

He described perfectly how I feel whenever I exit the subway or bus at Unirii and go towards the tramway 32 station. It's only 100 meters, maybe 150, but you have to fight your way through a river of people, a lot of them smoking, then wait for the green semaphore light a long time while smelling all kind of interesting flavours, then try to get in the tram without being rubbed away like a pencil trail by people who don't really care if they touch you or not.

If you are lucky enough and it's winter time, maybe before some holiday or another, you get to smell the homeless people who decide that either it's too cold outside and camp in the tram, either that you have to give them a holiday present and start begging and singing and other things which basically mean they also move or crawl, thus evenly smearing the air with their fetid stink.

and has 0 comments
The lead characters of this author seem to always be quiet guys, ready to accept anything and be taken anywhere by the story. The same incredible things happen, all narrated in a very calm way, making them real. The obsession for American or English music permeates everything. I've read two Murakami books, but also some reviews for other books, and the same situation seems to be repeating itself.

Dance, Dance, Dance is about this kind of a person, caught in a kind of metaphysical quest to find himself. Some symbolism, weird characters, absurd situations. In the end, surprise, he finds himself. Compared with Kafka on the Shore it is much slower at the beginning, but it picks up pace closer to the end, yet the very end is slightly different from the rest of the book. I first though that Kafka was a better book than this one, then I switched sides and now I see them as of similar quality. Not much else to say.

Now I can't say I didn't like the books. They are the kind of stories that take you nowhere, but on a very pleasant road. But in the end, you are left with nothing. Nothing really learned, nothing really gained, just like a walk in the park. And I rarely enjoy walks in the park.

So I have decided to call it quits. Harumi Murakami is a good writer, there is no doubt about it, just not my type of a writer. I feel his writing is too English and not Japanese enough, thus defeating the very purpose I started to read his books in the first place.

First of all there is no reason not to apply this method to any other templatable control like GridViews or DataGrids. The basic mechanism is the same.

The problem here is how to display different templates for different items (not just for different item types) like when databinding to a general collection of different objects.

Basically all you have to do is use the OnItemCreated event to first load a template (using Page.LoadTemplate) from any user control and then applying it to the DataListItem (using ITemplate.InstantiateIn). But there are a few catches. First of all, the original templates (the ones in the as?x file) are applied before the OnItemCreated event. So if some templates are defined, like ItemTemplate for example, you need to clear the controls in the item before you instantiate your template. Second of all, you cannot declare the OnItemCreated event in the Page_Load method, since it is executed after the OnItemCreated event. But you can declare it in the as?x file.

So let's combine all this into code. First the aspx:
<asp:DataList id="dlMain" runat="server" OnItemCreated="dlMain_ItemCreated" >
</asp:DataList>

nothing fancy. Then the cs code:
protected void dlMain_ItemDataBound(object sender, DataListItemEventArgs e)
{
ITemplate template1 = e.Item.ItemIndex % 2 == 0
? Page.LoadTemplate("~/ucTest1.ascx")
: Page.LoadTemplate("~/ucTest2.ascx");
e.Item.Controls.Clear();
template1.InstantiateIn(e.Item);
}


That's it! ucTest1 and ucTest2 are two arbitrary user controls I am loading alternatively. For this particular case an AlternatingItemTemplate could have been used, but you get the point.

and has 0 comments

and has 0 comments
Check out this interesting piece of code:

javascript:document.body.contentEditable='true'; document.designMode='on'; void(0);

Pasted into the address bar of browsers like IE6, IE7, FF2 (haven't tested on others, but I think it should work on most) it allows the editing of HTML directly on the page. You can expand and shrink HTML elements, you can edit text, etc.

While on Internet Explorer the changes are not saved if you save the page, on FireFox you get spell checking while editing (with red underlines for unrecognized words) and you can save the changes with save page.

It's really weird, check it out.

and has 1 comment
I just finished watching a very cool documentary, called The Human Behavior Experiments, that I highly recommend seeing. It describes some of the mechanisms of the human mind that make us behave inhumainely, or iresponsibly and the experiments to expose them. I found very interesting the information on Wikipedia about these experiments and I will post a list of links below.
Doing the research, I've stumbled upon sites that describe (or plainly show the pictures) of the Abu Ghraib tortures. Those links I will not publish, but you can easily use Google to find them yourselves. It is incredible that after those things got published, people still support any war or detention center at all. The movie I was telling you about explains how things like blind obedience or difussion of responsibility function in most of us, ordinary people.

Links:
The Human Behavior Experiments
The Milgram Experiment
The Stanford Prison Experiment
Das Experiment
Abu Ghraib abuses
The Bystander Effect
Asch conformity experiments
Depersonalisation
Responsibility diffusion

and has 1 comment
Telemarketing is already embedded in the western popular culture, but in Romania, we didn't have it until recently, and only very rarely. Usually they didn't want to sell stuff, but to poll opinion. So I was immediately annoyed when a authoritative male voice started to talk to me about increasing the money I get from my insurance. That annoyance increased when the voice continued "if you want to... bla bla bla, press 1". They didn't even bother to put a human to give the phone calls, it was all automated. Swearing at a machine would have been ridiculous, so they took away the only possible emotional outlet. They have denied my anger!

So of course I resorted to THE BLOG [lots of echo here] to shout my frustration! But since I have worked with telephony in my days, I thought "wait a minute, there is a solution". I could strike back. First of all, I would install an answering system that requests the user to press a key. "If you are a telemarketer, fuck off, if you are a human being, press 9". Then add the tone of the key "1" and repeat the message. But then again, why would I bother, for one lousy telemarketer? Because they took away my outlet! I want it back, damn it!

One of the issues that largely remains unsolved in AJAX applications is the ability to bookmark (say, add to the Favourites) the page with all the AJAX added info on it. This very cool javascript library allows one to save the state of the page using the window.location.hash variable, which holds the string after the # character, also called a hash.
Javascript can modify and read this value with no refresh of the page. Also, if you have anchors in your page, like... <a name="hash" Javascript code like
window.location.hash='hash';
will scroll the page there.

I have this Web User Control that has a simple function of displaying a customised grid and fill it with data. Since I had to email the rendered HTML I've added a static method to the Web User Control that would render itself based on some parameters. However, in Net 2.0 one cannot dynamically use the types declared in the codebehind of a user control or page inside another control or page, only types declared in App_Code. In pages this gets solved as in the link above, but what do you do when you want to use the type inside a class in App_Code or, like I needed to, in a web service (where register directives are not allowed)?

In my case, there were two solutions. One is to create a page that loads the user control and nothing else, then read its html. That solves the problems of using the code, but adds security issues. I have to either add a security mechanism to the page or allow anyone to render the UserControl. The second solution, the one that I ended up implementing, is to use reflection.

Let's recap. I have the web user control, let's call it Wuc, and I have the static method Wuc.GetHtml(int i) that I must access from a Web Service. If I write
string s=Wuc.GetHtml(i); it doesn't get to compile, returning the error "The name 'Wuc' does not exist in the current context".

So I do something like this:
UserControl uc = new UserControl();
uc = (UserControl) uc.LoadControl("~/Wuc.ascx");

and I get the object I need to get the type of. Then I should get a reference to the method I want so I try:

MethodInfo mi = uc.GetType()
.GetMethod("GetHtml",BindingFlags.Static);


which should work, but it doesn't!

Why not? Because the type of the object is not Wuc is wuc_ascx and it's the dynamically generated ASP.NET type. I get all the methods of Wuc, but not the static ones! So, the (really ugly) solution is to make the method not static and use this code:

MethodInfo mi = uc.GetType()
.GetMethod("GetHtml");
string s = (string)mi.Invoke(uc, new object[] { i });


which finally works.

Update
Scott Gu was nice enough to respond to my request on how to do this. He has this blog entry that explains how to render a control in NET 2.0 within an ASP.NET Ajax environment, but what really connects with my blog entry is this archive and the ViewManager object. Scott uses here the Page.LoadControl method (here is why) to load the control and Server.Execute instead of RenderControl.