and has 0 comments
A year ago I wrote about being a bicycle rider in Bucharest. I complained then that there are no bike lanes and no one gives a damn about bicycle riders or the very law that should protect them. Things have changed, apparently, and now beautiful bike lanes are criss-crossing Bucharest's sidewalks. But it is all for show and appearance.

First of all, they serve no purpose on the sidewalk. Given the peculiar psychology of the majority of the population when they have to choose between walking on a nicely marked yellow/green stripe and the normal gray sidewalk, they will walk where the nice colors are. Even if they would somehow decide to think a little and ponder on the significance of the big bike signs painted on those lanes, there are children that have no idea what they are doing and could always jump in front of you. Normally, the population of the bike lanes in bucharest is comprised of mothers with babies, lovers holding hands, old ladies and people that just wouldn't give a damn. Very often I see young stylishly dressed women walking right towards my bike, ignoring me completely, expecting me to move aside. Do they even consider the damage that I would do if I'd just decided on a whim NOT to move aside? Not to mention places where there is space only for the bike lane and it would be stupid to expect people not to walk on it. And of course, the cars that park right on the lanes and about nobody does anything.

Second of all, the lanes were built close to autumn last year, a season not favourable to biking. Then, of course, winter came, and the plastic like stripes that mark the lanes were pretty much destroyed. So they had to put them again. However, during the spring they started working on fixing the streets. That meant scraping the asphalt (bike lanes on the street included) and puting it back on. But they did draw the lanes back on. Then they started changing the street border stones, usually placing them idiotically high right on the bike lane. And if it wasn't enough, they started placing all above ground wires under ground. That meant digging narrow, yet deep trenches in the sidewalk, interrupting the lanes from side to side, so that there is no way to go around, and they never filled them up! Basically every one in two bike lanes is now broken by this. And, as this was not enough, more often than not the lane is of worse quality than the rest of the sidewalk.

Therefore I will ignore these lanes completely, except the days when I am really tired and don't trust myself around cars, and risk my life and the paint on the cars around me rather than the lives of the people on the sidewalk. What a sham this all is. The Bucharest European mask is there only for outsiders, NOT for the people living in it.

and has 0 comments
In 1973, Frank Herbert wrote a book called Hellstrom's Hive in which it described a sect of people that lived underground, in a system much alike insects, with individuals specialised for different tasks and all living for the big hive organism. The book did not explain how it all got there, it just quickly described the situation and then delved into the action.

Jump to Stephen Baxter's Coalescent, the first book of the Destiny's Children series, which pretty much details how a group of humans would reach a plausible hive like society. Unfortunately, the book is more descriptive than anything else, failing to deliver in the action part. A lot of characters are developed and a lot of history (both personal and general) is detailed, but in the end the characters vanish as if they never mattered. It is, after all, the whole point of the novel, that ignorant individuals following certain rules lead to the emergence of patterns, but it did not fit well within a book.

Not that the book itself is not fascinating and well written, because it is, but the pace is very slow at the beginning, accelerating to a snail pace in the end, while the different parts of the book seem fractured, too little related to one another. I intend to read the rest of the books in the series, but I might just give up, too.

Bottom line, I think it would be a nice read to start with Coalescent and then read Hellstrom's Hive, although I do think the second book to be much better.

and has 2 comments
No, it's not one of the The World Sucks rants, it's actually very serious. I was terribly annoyed that after installing Windows XP SP3 my Internet Explorer 7 browser would (sometimes) freeze when closing tabs. I could replicate the bug easily enough by folowwing these steps:
  1. Open Internet Explorer
  2. Go to https://siderite.dev
  3. Scrollwheel click on Sign in, thus opening it in another tab
  4. Wait until the title of the second tab changes to Redirecting (because I have the cookie from a previous login)
  5. Press F5 (Refresh) in the first tab
  6. Click on the second tab and close it while the first tab is refreshing


At this time Internet Explorer would freeze with no error message. Waiting for a few seconds I could access the context menu on the taskbar button and choose Close or click on the X Close button, but everything inside the Internet Explorer window would be inactive. If I would switch tasks back and forth, the IE window would appear completely blank inside.

Now, whenever you look for the solution for this you get three answers:
  • Check the Warn me when closing multiple tabs option in the Internet Explorer tabs settings.
  • Run IExplore.exe with the -extoff command line parameter which will disable all add-ons and this will tell you if the addons are causing this
  • Check for spyware/malware


I did all this and nothing changed! I've reinstalled all addons. I've reinstalled IE7. I've switched to IE8 beta! Nothing worked. Then I proceeded in uninstalling all addons, see what happends. Finally, it wouldn't cause any issues. It was just after I've uninstalled Google Toolbar! I suspect the cause for the bug is coming from the popup blocker which interprets tabs as popups and tries to close them. Then there is the setting in GT that is trying to preserve any software from modifying its settings. Maybe that is why -extoff doesn't affect it!

Just to be sure I installed it again and tested the bug and I could replicate it. Something in Windows XP Service Pack 3 messes Google Toolbar up!

Bottom line: uninstall Google Toolbar until I can find out which part of it actually causes the bug.

As I was writing in the previous post, because of that law suit they are in, Google is starting to take measures to protect the copyright of videos on YouTube. The result is that all the blogs and sites that embedded video content that is supposed to be copyrighted now have beautiful flash players with a play button in them, but then the nasty surprise of seeing "video not available" when pressing play. At least display the damn message from the beginning instead of forcing me to play every video on my blog to see if there are still available!

But I did that anyway, for music videos for now, and switched to (currently) unaffected French video content site DailyMotion. Of course, lots of YouTube clones are on the net and even YouTube leecher sites. I mean sites showing a wonderful error when trying to play videos that now are removed from YouTube.

So, please folks, if you find some post with missing videos or pictures or anything wrong, really, please comment on it and I will fix it. Thank you and damn all lawyers to hell!

I really like Korn, they are heavy, melodic and the lead singer is pretty unique. I haven't posted anything by them yet because I was a teenager when I was listening to them. I remembered loving the video for Falling Away from Me and wanted to share it with my bloggies :).

This annoying error appeared out of nowhere in a project that used to work. I thought that the fault was of the new AjaxControlToolKit and the way it tries to register a CSS file. I was about to make really complex and , apparently, useless changes to my code until I've stumbled upon Rick Strahl's blog. It is not in the entry, but further down in the comments, but it's there.

Here is a distilled version: the error is not a page error, but a naming container control error. That means that if you do this in a PlaceHolder, let's say, it will only throw an error if the PlaceHolder has code blocks. The same applies to the header! The problem was not AjaxControlToolKit, but my own modifications to the MasterPage, where I had added script blocks with a dynamic URL.

So I added the script tags from the codebehind using this:

private void AddHeaderScript(string src)
{
HtmlGenericControl hgc=new HtmlGenericControl("script");
hgc.Attributes.Add("type", "text/javascript");
hgc.Attributes.Add("language", "JavaScript");
hgc.Attributes.Add("src", src);
Page.Header.Controls.Add(hgc);

}
. I don't know how this would work during an Ajax postback, but I wasn't interested in this, being a MasterPage thing. And it worked.

So, next time you get this error, be sure you know what control generated it. It can be solved by putting an extra PlaceHolder or, as is this case, replacing just some specific few code blocks.

and has 3 comments
Update: the title of the post should have been "Text searching in general, not as I expected". I did a quick test in javascript. Do 1000 indexOf and then 1000 search(RegExp object) in a long text and measure time. Here are the results:
Internet Explorer 7: search 90% of indexOf time!
FireFox: search 355% of indexOf time!?!
Chrome: search and indexOf same speed.


Update February 2016: I've tried it again, with Firefox 44.0.2, Chrome 48.0.2564.109 m and Internet Explorer 11.0.9600.18163 and indexOf is marginally faster than regex for all of them. For the case insensitive search, Firefox and Chrome take 50% than indexOf, while Internet Explorer is not only the fastest, but also only adds 4% when searching case insensitive.

It makes sense to have the same implementation of indexOf and regular expressions as in .Net for the Microsoft browser, so I am not that surprised, but what happened with FireFox? My hypothesis is that they used Boyer-Moore in indexOf (as any decent programmer should have!) yet used a simpler implementation for their regular expression engine.

A few days ago I was preaching that IndexOf with StringComparison.Ordinal is the fastest thing for text searching. I was even implying that it uses the Boyer-Moore algorithm from a Windows system library written in c++. I was dead wrong!

Thanks to Meaflux who told me that the Internet said things differently, I delved even further into the code, past the .NET code and into the library code of mscorwks.dll where the IndexOfString method that ordinal IndexOf uses, written in c++, appears to be a pathetic linear algorithm!!

Even worse, the Boyer-Moore algorithm is used in the .NET framework in the Regex class! The Regex class is written entirely in managed code, even if it uses all sorts of cool hacks. I've also tried a Boyer-Moore implementation from Codeproject that also included the Apostolico-Giancarlo, BCL, Horspool and Turbo Boyer Moore algorithms. IndexOf was slower!

Anyway, the code is simple: take a one megabyte Harry Potter text book and search a 100 byte text from somewhere near the middle of the text. Use IndexOf with StringComparison.Ordinal, then Regex with both variants, compiled and ad-hoc creation, then the class from CodeProject.

    Results for 100 tries:
  • Ordinal IndexOf - 390 milliseconds
  • Normal IndexOf - 2380 milliseconds (6 times slower!!)
  • AdHoc Regex - 190 milliseconds (take into acount the creation of the regex 100 times plus the use of Regex.Escape 100 times on the search pattern)
  • Compiled Regex - 160 milliseconds
  • Codeproject Boyer-Moore - 230 milliseconds


Would you have believed this?

Maybe the algorithm was better because the search string was 100 bytes, so I made it 12 bytes and redid the test:

    Results for 100 tries:
  • IndexOf - 440 milliseconds(more than with 100 bytes!)
  • Normal IndexOf - 2410 milliseconds!!
  • AdHoc Regex - 235 milliseconds
  • Compiled Regex - 230 milliseconds
  • Codeproject Boyer-Moore - 368 milliseconds (a lot more, similar to IndexOf, yet still less)


Ok, maybe the problem was that the string in which I searched was big. Let's make it 5000 bytes!

    Results for 100000 (1000 times more operations):
  • Ordinal IndexOf - 1109 milliseconds
  • Normal IndexOf - 1109 milliseconds
  • AdHoc Regex - 2500 milliseconds
  • Compiled Regex - 375 milliseconds!!!
  • Codeproject Boyer-Moore - 1312 milliseconds (finally something slower than IndexOf)


So Regex appears to be best for string searching in most cases!

Update: after optimizing the Boyer-Moore class and adding my own goodness to it, I made more tests. The Boyer-Moore algorithm can be improved by adding more preprocessing, therefore it is more and more efficient as the pattern size increases and the number of pattern searches decreases. In those cases (pattern length of a few thousand characters) Regex is not so good, especially if one has to Escape the entire sequence and instantiate the class on each search. Anything over 500 characters in search pattern length made Regex perform less than the most preprocessing BM I've used.

Update 24 Aug 2013: SyFy rejected the Blake's 7 idea. That may be a good thing, though, as it apparently was taken by Microsoft, to be made as an XBox series.

Update: The previous attempts to revive Blake's 7 have failed, but a new venture to do so was announced on July 23 2012: Martin Campbell And Georgeville TV Shop Reboot Of Cult U.K. Sci-Fi Series ‘Blake’s 7′. I just hope they don't screw it up.

When I was a very young boy, during the Romanian communist era, the only entertainment available was the Bulgarian television (also a communist country, but with a more relaxed regime) who's signal would reach Bucharest to the delight of many. I have always remembered vaguely a British series called Blake's 7, a sci-fi show that I've enjoyed tremendously at the time. Recently I was reminded of it and I was lucky enough to find the torrent for all four seasons. Having watched it now, I have mixed feelings and a new understanding of my child mind.


A short description of the show first. Imagine a team of space wanderers a little in the style of Farscape's crew (civilians, each one with their own ideas and motivations), stuck in a universe that resembles the Star Wars universe (an oppressive Federation ruling the galaxy with an iron fist) and has similar effects and inspiration as Star Trek TOS. All this with a budget that was probably several levels of magnitude smaller than that of ST TOS and also with effects and script a whole lot cheesier (and by that I mean that if I work out the percentages, more than half of the show was just cheese). The actors themselves were British and Welsh TV theater actors and they behaved as such the whole series. Not that it wasn't a refreshing perspective, even now. It was actually original enough and if it weren't for the production values, it might have been a world class classic.

Of course, I didn't watch it now because of the cinematographic value, but because it meant so much to me when I was a child. And I was stunned to see that the things that I remembered fascinated me were quite different in the show. Some weren't even there. For example I remembered that the show was called Blake's 7 but that one of them died in the second episode, which I attributed to British humour. But no, that happened at the beginning of season two. The introduction and music I remembered to be dark, impressive and scary. They were really funny now. There were scenes I remembered in a completely different way, with more emotion and action and the things that happened in the show had another sense altogether.

The structure of the series is funny to follow. The crew of seven was always only of six people. The computer counted as the 7th man. In the second season Gant dies so they are temporarily left with only 6. In the third season Blake leaves the show as well as others of the crew, only to be replaced by other actors and another computer. So they are 5 people and 2 computers and no Blake in Blake's 7. The only constant things are the ship, which is destroyed at the end of the third season, Avon and Vila. Oh, and sexy Servalan, the evil female villain. With a ship that can go anywhere in the galaxy, they always stumble in the same people! The ending was hilarious also, but you have to click here to see what I mean, I would hate to spoil it for you:
Click here for ending spoiler


Here is a sample of the show:



And here is a video from an interview with the actors interpreting Blake and Servalan, old now and talking fondly of the series:



But there are also good news, Blake's 7 could be revived! I found an April 2008 link that says Sky One has commissioned two hour-long pilots for a new Blake's 7 series! Here is also a BBC News entry.

Update: Blake's 7 will be back! I doubt it will pack the same punch, unless done right. BBC should have remade it, but it seems that it will be a SyFy show, which may not be a good idea. The news confirming the comeback can be found here: Blake's 7: Classic BBC sci-fi to return on Syfy channel

Well, I don't know who still uses it, but I had this old application that we reused and it had a Login control in the login page (obviously!). And I got tired of always entering the name and password every time I tested the site, so I went to the username and password TextBoxes and added a Text="something" bit. And it didn't work.

Why? First of all the TextBox control with TextMode="Password" ignores the Text property completely. Then the Login control only acknowledges the values of the two TextBoxes on change.

The solution: add a value="something" instead of Text="something" and it will be added like an oldfashioned HTML attribute. And it will also fire Changed since the value the .Net control is string.Empty.

That's all, folks, remember to remove this in the production site :)

and has 0 comments
Petru Jucovschi was nice enough to invite me to a software development training organised by Microsoft and partly presented by him. The first of the two days of training was about the theory behind software development practices like agile development and CMMI, part presented by Victor Mihail from Trilex. The second was about the Team System Foundation Server and Visual Studio 2008 Team Edition integrating for a better software development practice.

Well, I am working on remembering everything that was said and done and I will make some longer posts that will describe at length what was presented.
As a short summary, I was familiar with a lot of the concepts from the first part, since I've done a little research into agile development in order to pass it on to my managers. The theory and principles behind Agile were detailed, then the major Agile methodologies were described, including eXtreme Programming, Scrum and (very shortly) MSF. Also concepts of Test Driven Development.
The second part was also partly known to me as I have seen another similar presentation at the previous RONUA meeting, but this time it lasted for 8 hours, so I had the opportunity to ask questions and see things done step by step. Basically, TFS is the tool that combines project management, business analysis, architecture, development, debugging and testing into a single useful bunch. The issue tracking is linked to reporting, integrated with Microsoft Project and Microsoft Excel and concepts like Continuous Integration are directly available along a better source control solution than Visual Source Safe. Bottom line, I can barely wait to start work in a rational, managed way.

Stay tuned for the details.

Well, someone asked me today about why his dynamically generated GridView throws a 'Object reference not set to an instance of an object.' exception at DataBind when he sets AllowPaging to true. I replicated the error and looked at the stack trace, it looked like this:
   at System.Web.UI.WebControls.GridView.BuildCallbackArgument(Int32 pageIndex)
at System.Web.UI.WebControls.GridView.CreateNumericPager(TableRow row, PagedDataSource pagedDataSource, Boolean addFirstLastPageButtons)
at System.Web.UI.WebControls.GridView.InitializePager(GridViewRow row, Int32 columnSpan, PagedDataSource pagedDataSource)
at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource)
at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.GridView.DataBind()
at Malaka.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\ScrollableFixedHeaderGrid\Malaka.aspx.cs:line 14
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


So, the error occurs at the BuildCallbackArgument method in the GridView object. I used Lutz Roeder's Reflector to see the source of the GridView object and I got to this piece of code:
        private string BuildCallbackArgument(int pageIndex)
{
if (string.IsNullOrEmpty(this._sortExpressionSerialized))
{
this._sortExpressionSerialized = this.StateFormatter.Serialize(this.SortExpression);
}
return string.Concat(new object[] { "\"", pageIndex, "|", (int) this.SortDirection, "|", this._sortExpressionSerialized, "|\"" });
}


The error appears to be thrown by the StateFormatter property returning null. It's source is:
        private IStateFormatter StateFormatter
{
get
{
if (this._stateFormatter == null)
{
this._stateFormatter = this.Page.CreateStateFormatter();
}
return this._stateFormatter;
}
}


Got it? It assumes you already added the GridView to a Page. Well, this is the usual issue with the GridView.

Solution: Add the GridView to your Page (or to a fictive Page) and then DataBind it.

and has 0 comments
There are a lot of movies about aliens, creatures from another world, coming here for whatever reason and trying to communicate. They usually are well versed in English, but sometimes they use some other language like the Klingons or they snarl and rip you to pieces or, sometimes, have to find a protocol of communication first, by using mathematics, gestures or music (like in Close Encounters of the Third Kind). Yet none of those creatures astound me more than some of the people on Earth doing things I could never ever imagine doing and using it to communicate.

One of these people is Michael Moschen, who uses juggling as language of sorts in order to comunicate his perception of time, space and movement. You can watch a small demo he gave at TED and have your own say:



You can see that he uses separate elements to create, to build, larger ansembles. He uses juggling moves like a language, with structure and building blocks and architecture. Now, what would we do if aliens would want to talk to us by moving objects around and making sounds with their limbs? Would be build a computer that can be programmed by juggling? Would we immediately fly in Michael Moschen as the Earth ambassador? Or is it too science fiction to imagine alien creatures communicating in the same way some people do?

and has 0 comments
The level of satisfaction one gets from anything is inversely proportional with the level of expectation they have. I knew that in the RONUA meeting on the 9th there will be only two presentations, with subjects I can't use right now and with speakers I didn't exactly feel compelled to listen to. So, of course, I liked it!

But there was something more. Both speakers seemed more mature, more anchored on the subject than usual. It's not that Aurelian Popa did not seem overly arrogant or that the ever helpful Petru Jucovschi didn't have a lot more information than was humanly possible to present in the alloted time and resources, but their performance seemed way better than I was used to.

The subjects were pretty clear: WPF and VS TFS. If you are scared by acronyms you probably shouldn't be reading this :), but I did provide tooltips for them, so move the mouse over them.

The first presentation showed an ObservableCollection (new stuff from .Net 3.0 which allows notification on changing elements) containing SolarSystemItems, objects that encapsulated an image, a diameter, a name, an orbit and a temperature. It started from a simple listbox then, by changing only the presentation (Style) and the way data is presented (DataTemplate) in the XAML file, it gradually changed to a picture+details listbox, a combobox also with picture and everything, then with a details box next to it showing the current selected object, with filtering, sorting, grouping, etc. The grand finale was making the same listbox look like a solar system image, with selectable planets and the details on tooltip, with orbits and everything. The demo can be downloaded and seen at Beatriz Costa's blog.

The second presentation I was more interested in, since our company plans to use Visual Studio TFS to manage our work. Since that would mean a shift from the current Excel+Email+Messenger, I was glad to learn that the TFS learning curve is steep and usage can also start from source control only, moving ever so slightly towards a comprehensive development strategy, with testing, reporting, configurable XML files that describe any process (with out of the box or downloadable versions for MSF, Scrum, XP, CMMI) , etc.

I was surprised to see that not only the session was free, but we also received some gifts from Microsoft for attending. That included the MSDN subscription that I won, the WPF book that my colleague won, a kit with all kinds of goodies that I can't remember won by our boss and 40% discount for some Microsoft products for each. We cleaned house! No free food though :)

My conclusion was that the RONUA meetings are (as far as I have seen) the most techie, interesting and to the point Microsoft events. The MSDN briefings are nice, too, with more budget allocated to them and so on and so on, but they will never be able to replicate the sort of "gang of IT people" feel of the RONUA's meetings. And with people that are ever more implicated and interested in presenting, it can only get better.

and has 1 comment
Reading the BBC News today I've stumbled upon a fascinating article called "Great tits cope well with warming". Let me quote a little so you can understand what it is about: The research uses a long record of great tits in a breeding site at Wytham Woods near Oxford, where observations began in 1947. "We think it’s the longest running population study of wild animals anywhere in the world where animals are marked (ringed),"

So, warming doesn't negatively affect great tits! You can warm them yourselves or get someone else to do it. Isn't that wonderful? =))

Update 9 Sep 2009: Great tits found hunting bats for food

and has 0 comments
It started with web sites. They would put a small picture in the header of the site that on mouse over would fill the entire page with rubbish. We fixed it, usually, by using some utilities or by changing the ip of the offending ad to some non-sense ip.

Now they used the same ploy for Windows Live Messenger (formerly known as MSN). One could say that Microsoft doesn't need more money, but apparently they do. On YOUR expense! So, how can one get rid of the annoying flash ad at the bottom of MSN? Easy! Follow these steps (tested on version 8.5):
  1. Open folder Program Files\Windows Live\Messenger
  2. Copy file msgsres.dll to msgsres.dll.bak
  3. Find a text or hex editor that does not break a binary file on save (That means NO Notepad or Wordpad). Myself I used the text editor from FAR Manager, but there are tons of good freeware editors online. Just Google it.
  4. Open the msgsres.dll file with the text editor, look for
    <Element Id=Atom(AdBrowserCont) Layout=VerticalFlowLayout(0,0,3,0) Visible=false Padding=Rect(8,2,0,2)>
    and replace one letter from AdBrowserCont. I changed the A to an X, but it doesn't matter. What is important is not to change the length of the file; just replace, do not insert or delete anything.


That is all. The ad container will still appear and show the Windows Live Messenger window, but no ad will be loaded.

Of course, this is the do-it-yourself version. There is an utility that is largely recommended on the web to fix MSN, Windows Live Messenger and Yahoo Messenger ad issues, and that is A-patch, but I haven't tested it yet.