What a Loop!

As I tried to install Ubuntu 10.04 inside of Windows Virtual PC, I kept getting message:

(initramfs)mount:mounting/dev/loop0 on //filesystem.squashfs failed: Input/output error
can not mount/dev/loop0 (/cdrom/casper/filesystem.squashfs) on//filesystem.squashfs

Since I knew that anything with *nix in it’s name will be a problem for Virtual PC, I tried every switch there is and result was either this message or machine would turn itself off.

It took me a while to notice that my ISO file was only 200 MB. Since Ubuntu CD should be almost 700 MB, culprit was found. It was simple case of corrupt CD.

It always amazes me how quick I am to search for deeper issues without checking simplest reason for failure first.

P.S. Great guide on installing Ubuntu can be found at Scott Hanselman’s blog.

Visual Basic and Windows Phone 7

One thing that C# could do and Visual Basic could not was development for Windows Phone 7. I will not get too much into whether this is even an issue, but I will notice that it is no longer true.

Visual Basic developers can now download Microsoft Visual Basic CTP for Windows® Phone Developer Tools.

CTP stands for Community Technical Preview and it is closest to something in alpha stage. It will not be usable for production environment and it will take a while for final version to come. However, it is a big step forward.

Extracting Part of Mercurial Repository

As I started to work with Mercurial, I added almost everything in single repository. Time passed and I wanted to move some data to separate one. And this became a problem. There is no obvious way to split repository. However, there is something almost as good - exporting it.

Since I am Windows user, I will give instructions for Windows here. All things should work on Linux also but configuring it to work properly might (and will) differ. I will also assume that you have Mercurial already installed. I tested this with TortoiseHg but other clients should work also.

First step is to enable ConvertExtension on our computer. Just editing “mercurial.ini” under home folder and adding two lines will do:

[extensions]
convert =

If there is “[extensions]” sections inside already, just add “convert =” under it instead of creating new one. Home folder on Windows Vista and 7 is probably located at “C:\Users\YourName”. XP users should look under “C:\Documents and settings\YourName”. If you moved it somewhere else, search for it yourself. :)

Another file that we need to prepare is one used for filtering out things we do not need. Lets store it at “C:\map.txt” and add following text to it:

include "Electronics/Elsidi"
rename "Electronics/Elsidi" "."

Text in quotes is location of directory in original repository. First line includes only files at directory we wish to extract and second one moves those files to root directory (.) of new repository. Do notice that we use paths relative to root of repository and that path IS case sensitive.

I will assume here that “hg.exe” is somewhere in path so you can execute it without problem. In other cases, just write full path to it every time I write “hg”. In my case this is “C:\Program Files (x86)\TortoiseHg\hg”.

Last thing to do is executing conversion itself and update of new repository afterward:

hg convert C:\OriginalRepository C:\NewRepository C:\revmap.txt --filemap C:\map.txt
scanning source...
sorting...
converting...
18 Adding initial Android applications.
17 Initial push.
16 Elsidi rev3.
15 Moving Elsidi directories.
14 Elsidi rev6
13 Elsidi rev G.
12 Power (rev B).
11 Last version of UTF8.
10 Added As.
9 Adding Encoded.
8 Adding World.
7 Adding Unicode.
6 Adding In.
5 Adding Joint.
4 Adding Smokes.
3 Adding Device.
2 Adding Android.
1 Added Test.
0 Adding QText

cd C:\NewRepository

hg update
31 files updated, 0 files merged, 0 files removed, 0 files unresolved

With this you should have your new repository ready. Only files under desired path will be there (moved to root) and all history will be preserved.

Revmap.txt is here just so you can continue interrupted process. If you want to start whole process from start just delete both it (revmap.txt) and new repository’s directory (C:\NewRepository).

Hope this works for you.

P.S. If you see “C:\NewRepository” with just “.hg” folder inside and nothing else, you probably forgot to execute “hg update” command.

P.P.S. This procedure will leave exported data in original repository. You might remove it yourself but do notice that you will not recover any disk space - nothing is really deleted with Mercurial.

NEWID Vs NEWSEQUENTIALID

When GUIDs got introduced, people started using them as primary keys (which is ok) and, because of default, most of those GUIDs ended up as clustered index.

Clustered index itself tries to keep values that are close to each other in binary form also close in physical order. This is fine for data that is usually just increasing (like integer identity column) but it is not as good when you have random data. Unfortunately GUIDs (as created with NewId function) are closer to random than to any other order.

NewSequentialId function was introduced to solve this exact problem. It will return values in increasing order but with small catch - it is guarantied only until you restart Windows. Once you reboot Windows starting value might be lower than last one inserted.

Shit really hits the fan if you need to combine date from more than one server. Each one will generate completely different set of increasing GUIDs. This will wreak havoc for your clustered index. Fragmentation, here we come.

And what is result of this “fight”? Should one use NewId or NewSequentialId function?

It simply does not matter. Once you remove clustered index issue from decision process, either function works fine. And I cannot say that I see any scenario where clustered index on GUID is appropriate.

Am I missing something?

P.S. Personally, I would go for NewId - it is shorter to write and it is more user-friendly.

Straw That Broke the Camel's Back

I loved Windows Mobile 6.5 so at first I was looking forward to Windows Phone 7. Than rumors started that it will not support legacy applications. Fine I thought, I will just rewrite them as I need and at least I will get to do some refactoring.

Then multitasking was killed. Yes, platform does support it, Microsoft’s own applications can use it but mere third-party developers were not worthy of it. That also unfortunately meant that I would need to rethink some applications. I didn’t felt good about it but I still wanted to develop for it.

I thought that half of this things I hear around are just misunderstanding and everything will become clear once official development tools go out. This happened today. And it is clear…

Phone registration tool was last straw for me.

You see, once you buy phone, you cannot just do development on it - you MUST register it with Microsoft. They will than link your development phone to your MarketPlace account. That account costs $100 per year. This is little bit high but I was prepared to do it.

Only one small problem remains - I am from Croatia. That means that I CAN NOT register an account and I CAN NOT make any application for it. Even local debugging without any thoughts about selling is impossible for me.

I heard semi-official position on this: I should just find somebody that lives in “correct” country and he can apply instead of me. Never mind that I would break Windows Phone Marketplace Application Provider Agreement. This will just “result in possible revocation of your Marketplace Account, removal of your Applications from Marketplace, loss of Application ratings and reviews, and forfeiture of any associated Account Fee.”

I did my share of Windows Mobile development of both paid and freeware applications but love that started with Embedded Visual Basic and had it’s peek with C# and .NET Compact Framework is no longer there. And it is not because newest platform is bad. Technical aspects of Windows Phone 7 development allow for better things that any version before.

It is politics surrounding it that make me sad. Intentional crippling of platform, complicating development without any good reason and treating me as second class citizen are things I am not used to.

I cannot say anything for sure - life is too unpredictable for this - but I doubt that Windows Phone 7 will be visiting my pocket any time soon. So long, and thanks for all the fish.

P.S. No matter what tone of this post is, I will always value Microsoft’s programming tools. I can say, without any doubt, I’ve never had better working environment than Visual Studio and I will definitely continue to use .NET Framework. Microsoft did phenomenal job with them.