First time here? You are looking at the most recent posts. You may also want to check out older archives or the tag cloud. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS. Thank you for visiting! (hide this)

September 2007 Blog Posts

Manage categories and tags of your blog

Blogging engines don't allow a quick way to change categories, or to add tags to many posts at the same time, so managing your old posts can be a lengthy process.

A friend of mine, Marco De Sanctis, had to add tags to all his old posts and to reorganize the categories of his blog, so he built a small tool that retrieves all the posts via MetaWeblog API, and allow to select many posts, and add tags or categories in batch.


More information about this wonderful tool, named "Blog Manager", on Marco's blog: A tool to manage your blog categories and Technorati Tags.

Blog Manager is available both in Italian and English, and support for other languages is coming soon.

You can download the tool and also the code (with the solution in VS2008 format) is available.

Technorati tags: , ,

To www or not to www?

When I started this blog back in December I advertised it as, but given the fact that Subtext always strips the www out of the domain name when building internal urls, my blog was being indexed by Google with two different domain names:

  • since it was the url I was giving around, that was linked from my post signatures and so on
  •, the url that was generated by Subtext for some of the internal links, and from the rss feed and the Google sitemap

So, to avoid shattering the PageRank and to have a unique identity I decided to switch the official url to without the leading www.

I loved the www since it was the way the Internet worked when I started using it, with www.something, ftp.something, mail.something, gopher.something, to identify which service was served by the url, but soon I understood that now the "trend" is to go without the www, as all cool guys are without it (well, not all).

Today, on an Italian blog, I read a post about this debate: "Do you like it with or without www?"

The author links to a news about the fact than the ICANN banned the use of the www because:

"Requiring employees to type 'WWW' cost companies over $25 billion last year," said ICANN representative Emil Scharnsdorf. "The average Internet surfer takes two seconds to type 'www' and visits 125 sites a day, add in typos like "qqq" and "ww," then wave your hands over your head three times and you're at $25 billion."

"We're only concerned with the Internet, but it takes Mandy Patinkin three seconds to say 'www' and during the Super Bowl that gets expensive."

Ok, this was a joke, but the debate whether to keep the www or drop it is still very relevant: someone prefer the www because it helps "non tech people" to understand it is a web site url, others don't like it because "That's so 1997".

Anyway, whether you like it with or without, decide one of the two, and stick with it, to avoid the duplicate urls and the Google PageRank problems. And if your site is configured to handle both, use some URL Rewriting technique to have all your urls mapped to your preferred one.

Technorati tags: , ,

Mac OS X Leopard Final Candidate and Office:mac2008

With October approaching, Apple released to the developers subscribed to the early access program a build that is said to be the first in the Release Candidate cycle, aiming at the Golden Master build by the end of October.

And together with this release, the Microsoft’s Macintosh Business Unit announced the release date and the pricing for the next version of Office for Mac: Office:mac2008.

The standard version, with Word, Excel, PowerPoint and Entourage with support for Exchange will be sold at US$ 400. But if you don't need to connect to an Exchange server you can save more than 50% of the price and get the Home/Student edition, which the same as the Standard without Exchange, for only US$ 150. Finally, the "Media Edition", which includes Microsoft Expression Media, will be available for US$ 500.

Compared to iWork '08, the Home edition costs almost double the price for the same features (word processor, presentation and spreadsheet), but will ease the pain of Windows' users migrating to the Mac, since it will support the same file formats as Office2007.

And is quite amazing to see a product from the Expression suite running on a Mac: I'm wondering when we will see XAML and Silverlight application developed on a Mac with Blend.

String to Enum

This might seems a pretty trivial problem, but every time I've to get an Enum given its name I forgot how to do it, and I've to look for it on Google.

So, is there a better way to remember something you always forget than writing a post about it?

Back to the problem: going from an Enum to its numeric value or its string representation is quite easy:

/* Enum to string */
string stringValue = enumVal.ToString();

/* Enum to numeric value */
int numericVal = (int) enumVal;

And going from a numeric value to the Enum is quite as easy:

/* Numeric value to Enum
int numericVal = 3;
MyEnum enumVal = (MyEnum) numericVal;

But going from the name to the Enum is a bit more complicate... well, if you don't remember the function call: the System.Enum class has a static method (Enum.Parse) that converts a string to the Enumerated type specified:

/* String to Enum */
MyEnum enumVal = (MyEnum) Enum.Parse(typeof(MyEnum), stringValue);

Too bad the need for the cast: they could have implemented a generic version of the Parse method.

I hope I'll remember this function call next time I need it... or at least I know where to look for it.

Technorati tags: , ,

Slides and demo of my presentation on Vista Sidebar Gadgets

After coming back from my long weekend in Barcelona I finally uploaded the slides and demos of the presentation I held two weeks ago at the XeDotNet user group meeting about Developing Vista Sidebar Gadgets.

The presentation and the demos take you step by step in the creation of a Vista Sidebar Gadget, starting from a basic gadget to a full-blown localized gadget, with settings, flyout and undocked view:

  1. basic gadget
  2. adding transparent background
  3. adding a Settings page
  4. adding the Undocked view
  5. adding a Flyout
  6. getting ready for localization

Since I used a Mac, the main presentation is Keynote format, but I also have the Powerpoint version (even if it doesn't have the spinning cube transition).

Here are the links:

Subtext security patch

While I was leaving for Barcelona to visit a friend and to enjoy Les Festes de la Mercè, a user of Subtext found a security problem in our integration with the WYSIWYG editor FCKeditor. And only one day after it has been discovered Phil released a security patch that fixes the problem.

The vulnerability allowed a user to upload files in the images folder of a blog without being authenticated.

To secure your installation of Subtext just download the secured version of the FCKeditor provider dll, or, as workaround, remove the following folder: Providers\BlogEntryEditor\FCKeditor\editor\filemanager

Technorati tags: , ,

Yet another active community member joins Microsoft

After Scott Hanselman, Peli, Alex James and a lot more other active community member and opensource developers, also Phil Haack, founder of Subtext, is going to join Microsoft as Senior Program Manager in the ASP.NET team, and will be working on a MVC framework for a future version of ASP.NET.

Congratulations Phil: two big achievements in just one year.

Now, when is Microsoft coming to me for a job in the ASP.NET team as well? smile_regular

Exploiting Multi-Core Processors

As we all know the chip industry changed it's approach to performances increment: we will not see 10Ghz processors (not even 5Ghz ones), but now we have duo-core, quad-core and 8-core or 16-core processors coming in a near future.

But this is a problem for software developers: while it's easy to take advantage of a 10Ghz processor (just do what you always did, and your application will go faster because it will be run by a faster processor), it's more difficult to take advantage of four 2.4Ghz cores inside the same processor.

A few years ago, Volker Will said:

But how will users benefit from multiple cores? Will the apps run faster just because there a now 2 processors on a single chip? I guess not really. There are benefits for the OS that may relate to improved performance. But the app itself? Well, you can run multiple instances easier and better for one. But what about a single app? A single threaded (client) app that has been designed with a single processor and a single thread of execution in mind, will not benefit and therefore users will not benefit from multiple processors or multiple cores.

Which means that even if increasing the number of cores, if the OS is designed to handle them, will increase the overall performances of the computer (some apps running on one core, and others on the second), a single application that has not been designed with parallelism in mind will not benefit from multi cores processors.

But exploiting the advantages of a multi-core chip is not easy for all tasks: rendering, encoding, or scientific applications are the ones that are easier to modify to support parallelism, but what about the usual web pages or the usual WinForm applications that reads data from a DB, and than display them to the users? This is not as easy as parallelizing rendering or mathematical application, but it's something you have to start thinking about. Jeff Atwood a few years ago said:

One day, you won't be able to throw money at your hardware to make your app run faster. You'll have no choice but to pour that money into parallelizing the algorithms inside your app, which is a far more difficult proposition.

What can you do now to take advantage of multi-core chips? Try to use as much as possible async operations and threading even for something that you usually build as sequential operations, launch DB queries in parallel and wait for the results of both before going on with the page processing.

But to help the process of shifting to a more parallel way of programming, Microsoft Research developed a library to help all of us to easily exploit multi-cores chip: Task Parallel Library (TPL), which is part of the Parallel FX Library, which is going to be released in CTP in Fall '07.

I found about that in an article from the October 07 edition of the MSDN Magazine: Parallel Performance - Optimize Managed Code For Multi-Core Machines.

It is not another article about how to use the ThreadPool API (which is covered in another article on the same edition of the MSDN magazine), but it explains this new library designed to "automatically" optimize your managed application for multi-cores.

Let's see an example:

for (int i = 0; i < 100; i++) { 
  a[i] = a[i]*a[i]; 

Each iteration of the loop is independent, so theoretically you could optimize the for loop splitting it into 2 or 4 parallel tasks, each of them looping on different ranges (for example 1 to 50 and 51 to 100).

Using the TPL you could express the same for loop like this:

Parallel.For(0, 100, delegate(int i) { 
  a[i] = a[i]*a[i]; 

The library uses some advanced algorithms to split the task among the available cores, dynamically adapting to the workload and to the particular machine. For example on single-processor machines the loop will be executed sequentially, but on dual-core machines the library will use two worker threads.

The article then explains also all the other features of the library, so I high encourage everybody interested in parallel programming and in making the application faster for the future hardware to read it.

On the same edition of the MSDN Magazine there is also an article about a flavor of LINQ - PLINQ - that uses the TPL library to run queries in parallel.

PLINQ is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available. The change in programming model is tiny, meaning you don't need to be a concurrency guru to use it. In fact, threads and locks won't even come up unless you really want to dive under the hood to understand how it all works.

Unfortunately no download is available yet, but both articles say that they are going to release a CTP in Fall '07. I just subscribed to the blog of the Development Lead for the Parallel FX team, Joe Duffy so that I knew first hand when the library is released.

Developing Vista Gadgets: impressions and photo gallery

I just came back from the post-event dinner, and here some picture of the presentation on Vista Gadgets running on a MacBook.

IMGP1852  IMGP1854

IMGP1853  IMGP1857

Not many people attended the presentation: too close to the end of the summer season, and probably not many people likes Vista. But I think this evening I showed some good reasons why developing Vista Sidebar Gadgets matters.

I received some good questions from the elite that listened to my 2 hours long presentation, some of which are still unanswered. I promise I'll look for some answers and post them on my blog.

And last but not least, a big thank you to Andrea Boschin for having organized the meeting.

Technorati tags: , , , ,

Yet another iPod Nano Video (3G) unboxing gallery

Last Tuesday, for my birthday, 11th September, I received a gift from my wife: the new iPod Nano Video (3G) Red. Less then a week after it has been presented to the World by Steve Jobs.

So, even if not very .NET related, I wanted to post here the first impressions and some picture.

1-unboxed  2-clear-case1  3-clear-case2

Just a little bad experience: the gift message was printed only on the shipping notice, and the cardboard shipping box was still shaped to hold the old iPod Nano 2G (tall and thin).

As usual, iTunes display the exact model and color of the connected device. Please notice the Video and Games tabs.


Then I copied some songs on it, and here the new user interface: the about screen that tells you at a glance how much space is left on the 8Gb disk, the split of how the space is used, and the main music menu.

5-about  6-free-space  7-music-menu

And, going deeper in detail: the cover flow, the album list and the songs list.

8-coverflow  9-album 10-songs

And then, I also tried taking a picture of the Nike+ new interface: unfortunately the phone camera was not as good as the other digital camera.


I didn't use it so much for the moment, just listened to some songs, but the new UI is awesome. I still have to see how it is to watch a movie on a 2" display.

The cool thing is that the old lanyard headphones fits perfectly into the new iPod, so I can still walk around with the iPod hanging on my neck. And the new armband has 2 closing mode: one for the iPod only, and one for the iPod with the Nike+ receiver attached to the dock connector.

Technorati tags: , , ,

Developing Vista Sidebar Gadgets presentation in Venice

Tomorrow evening I'm going to do a presentation about Developing Gadgets for the Vista Sidebar at the XeDotNET user group in Venice.

  • What are Sidebar Gadgets
  • Why developing Sidebar Gadgets
  • Structure of a Gadget
  • How to develop a Gadget (with 6 demos)
  • Tips&Tricks

And since my laptop cannot run Vista, I'll do the presentation using my wife's MacBook, running Vista inside Parallels.

If you are interested in coming, you can register here: the presentation is in Mestre, on Friday September 16th starting from 7:30pm.

Next week I'll upload the slides (in Italian) and the demos.

Technorati tags: , ,

LinkLift control for ASP.NET revised

A few months ago I released a rough first version of an ASP.NET control to display text-links served by LinkLift.

Since then the control became the "de-facto" official control for ASP.NET (Italian, German, French and Spanish).

Today I found quite a subtle bug that never showed up before (since I never really had the control on my site for more than a few hour): I used the FileSystemInfo.CreationTime to keep track of the last time the local copy of the XML was saved. But the CreationTime is the first time the file was saved, because all the subsequent saves are only treated as updates, and the CreationTime is never changed again. This caused the control to download the XML definition every time it was loaded. So I changed it to FileSystemInfo.LastWriteTime, which is, as the name itself tells, the last time the file has been saved.

And the code for this control is also available on CodeClimber.Commons, my personal repository on Google Code.

Beware the Unicode Byte Order Mark when merging files

What is the Unicode Byte Order Mark (BOM)?

Every Unicode string starts with a "zero-width no-break space"; depending on its actual byte representation, a text processor understands the endianness of the characters that follow the BOM. For example, in UTF-16, if the first character of a string is represented as FE FF it means that the bytes in the string are represented using the Big Endian order, while if the string was using the Little Endian order, the first character would have been represented as FF FE. This rule apply only to UFT-16 and UTF-32 encoded strings, and not to UTF-8 (since there is just one byte per character, so no order to be specified).

Unfortunately for us it's common practice (many Windows programs do this) to add a Byte-Order Mark also to UTF-8 encoded files, just to mark it as UTF-8 (and in this case, the BOM is represented as EF BB BF).

Why am I telling you all of this, and why does it matter?

Because if you merge many UTF-8 files into one, and you do it the wrong way, you will include the BOM in the middle of the file, and, even though the UTF specification recommends to ignore them, some applications (like the CSS parser of Firefox) might treat them as "zero-width no-break spaces" or as other characters (like its ISO-8859-1 version ""), and possibility break something.

How I came into this problem

I was developing a new feature for Subtext, an HttpHandler to serve all the CSS files belonging to a skin as only one http response, and I run into the following issue: in Firefox the first CSS rule of each file was not interpreted at all (but everything was fine using IE).

Using Firebug I found out that Firefox was seeing the first line of each merged CSS as " .classname" (with a leading space) even if the physical line started with the dot (".classname").

The code I used to merge the files was: (this is the wrong way to merge UTF-8 files)

// styles is the list of all the files to be merged
// with the path relative to the root of the website
foreach (string style in styles)

The problem was that the WriteFile method wrote all of the file into the output stream, including the leading "EF BB BF". So when merged, the resulting file had this sequence of bytes also in the middle of the file, and the CSS parser of Firefox interpreted it as a space, and put it before the first rule breaking it (since all the rules must start at the beginning of the line).

So I changed the merging code the following:

// styles is the list of all the files to be merged
// with the path relative to the root of the website
foreach (string style in styles)
    string cssFile = File.ReadAllText(context.Server.MapPath(style));

The ReadAllText method reads all the text inside the file, and being UTF-8 aware, it strips the BOM out of the return string. So the final output doesn't include any Byte Order Mark, and all the CSS rules are interpreted correctly.

This issues is caused by two non-compliance to the UTF specifications:

  • first, the text editor used to save the CSS files should not have added the BOM at the beginning of the UTF-8 file
  • second, the CSS parser inside Firefox should have ignored it instead of treating it as space

Just to add more complexity to the issue, the problem happened only if the CSS file started with a comment (and the broken rule was the first after the comment), but not if it started directly with a CSS rule.

Technorati tags: , , ,

RIP Big Luciano

Just a quick note as tribute to the great Italian tenor, Luciano Pavarotti, who died this morning at the age of 71.

The World just lost one of the best singer ever. We will miss you.

Here is a link to a video where Luciano sings Nessun Dorma, and here with Bono singing Miss Sarajevo.

Technorati tags:

New Nike + iPod interface

Yesterday Steve Jobs announced the new version of the iPods (new colors for the Shuffle, 3G Nano "fatty", iPod "classic", iPod Touch). There are a lot of posts about this, so I'm not going to increase the echo chamber effect.

Just want to focus on one think that is very important to me: the Nike+ sport kit.

Steve Jobs itself announced during the keynote that the new iPod Nano is compatible with the current version of the Nike+ Sport Kit, and the product page on Apple site reflects this, and provides some images of the new Nike+ UI (Thanks to Podophile for bringing this to my attention):


  info_rocknrun_20070905 timed_rocknrun20070905

The new Nano looks awesome, for the same price you get double the storage, the ability to play videos, and you also get the cover flow, which is cool. And I love the new Nike+ UI. But I'm a bit concerned about all the Nike+ garments I've got: I still have to see a size comparison between the old and new Nano, but I really don't think the new one will fit into the t-shirts and armbands I own. But the new armband should have also some room for the Nike+ receiver... ORDERED smile_regular

One last comment about the iPod Touch: as Mauricio said, the iPod touch is not only the best iPod ever, but, IMHO, is also the best PDA ever (with Wi-Fi, the best portable web browser ever, music and video playback, and all the "usual" PDA applications). The only thing missing is the possibility to use 3rd party offline applications.

Technorati tags: , ,

Silverlight 1.0 goes live, and supports Linux

Silverlight 1.0 has been released tonight, and it will natively support Windows and Mac, and will officially support Linux via a partnership with Novell and Moonlight, which is part of the Mono Project.

Together with Silverlight 1.0 RTM, also the RTM of Expression Encoder has been released.

A lot of MS blogger already blogged about this announcement, here are a few posts where you can get more info:

You can check out the great Silverlight example that is Halo 3 Combat trailer in HD (720p).

And while I'm on this topic, I just found a great 20 parts tutorial by LiquidBoy: it's about the development of an iTunes clone build in Silverlight 1.1, complete with CoverFlow and themes.

Technorati tags: , ,

I've been Simponized

Thanks to Janky, I found out Simpsonizeme, a web app that analyze a picture, and makes a Simpson character based on it.

Here is me if I lived in Springfield:


Technorati tags: ,