WordPress Noindex

As I was checking search for my website I noticed that Google would return essentially same page multiple times in search results. One result pointed to post, second one pointed to same post but within categories and third would be same again but in archives. Not what you can call great search experience.

On WordPress platform (that is used here) solution is really simple. All pages that I don’t want shown I can block from Google via robots meta attribute with content “noindex,follow”. Simplest way to do this is to directly edit header.php file and, below

tag, just write:

<?php
    if (!is_singular()) {
        echo '&lt;meta name=&quot;robots&quot; content=&quot;noindex,follow&quot; /&gt;';
    }
?>

If page is singular in nature (e.g. post, page, attachment…) nothing will happen. If page is collection, one simple html attribute is written.

While this is simplest solution, it is not upgrade-friendly. For each new WordPress version, same change will be needed. Better solution would be to pack this into plugin so each new version can continue using it without any change. Creating plugin in WordPress is as easy as filling some data in comment (e.g. plugin name, author and similar stuff) and then attaching to desired action. In our case full code (excluding plumbing) would be:

add_action('wp_head', 'nonsingular_noindex_wp_head');

function nonsingular_noindex_wp_head() {
    if (!is_singular()) {
        echo '&lt;meta name=&quot;robots&quot; content=&quot;noindex,follow&quot; /&gt;';
    }
}

Whole plugin can be downloaded here. Just unpack it into wp-content/plugins directory and it will become available from WordPress’ administration interface.

VHD Attach 3.40

VHD Attach screen

Most noticeable change for this release will be new icon. Not a huge change, but a colorful one. Considering that last icon was gray-scale, I see it as a good change.

Other visible change would be New disk dialog. It is changed a bit in order to allow for more flexible size entry. Finally you can create 0.1337 GB hard drive that you always wanted.

Under the hood there were many changes. While some were bug-fixes, most of them were focused on drive management. This will finally give possibility of drive letter change in next version (currently being tested).

Download is available from within application or via program pages.

P.S. If someone is interested in checking drive letter management beta all you need to do is to send me a mail.

Old Fella Is Here to Stay

Illustration

Visual Basic 6.0 seems to be indestructible.

Windows 8 officially offers support for Visual Basic 6 run-time and limited support for it’s IDE (yes, believe it or not, it still works).

For those counting, that means end-of-life earliest at year 2022. Since it was created in year 1998 that gives an impressive 24 years of support. Name me one language that had longer support for single version. Yes, Marc, I know of Visual C++. Name me some other. :)

First program I ever sold (and quite a few afterward) was written in this beautiful language. It was not powerful. It was not fast. It was not even sensible at times. But it got job done and that is what counts.

While I am happy with my current choice of C# I cannot but smile at simpler times and language that marked them. May it live forever (or until Windows 9, whichever comes first).

Visual Studio 2012 RC

Illustration

First thing that you will notice when starting Visual Studio 2012 RC is that things got slower. It is not as bad as Eclipse but it is definitely not as speedy as Visual Studio 2010. Second thing you will notice is SCREAMING CAPITAL LETTERS in menu. This change was done in desire to Metro style everything and increase visibility. I can confirm success since it sticks out like a sore thumb.

Fortunately, once you get into editor, everything gets better. There are no major changes for users for old Visual Studio but evolution steps are visible. Find/Replace got major overhaul. Coloring is improved a bit. Pinning files is nice touch. That sums most of it. It was best editor and it remained as such.

Solution window now shows preview when you go through your files so just browsing around saves you a click or two. Beneath each item there is small class explorer. While this might works for small project, I have doubts that it will be usable on anything larger. But I give it a green light since it stays out of your way.

Beautiful change is that every new project automaticaly gets compiled for Any CPU. This is more than welcome change especialy considering utter stupidity from Visual Studio 2010. I just hope that Microsoft keeps it this way. Whoever is incapable of 64-bit programming these days should probably stick to COBOL.

Speaking of utter stupidities, there were rumors that Express editions will not support proper application development but only Metro subset. While I am not against Metro as such, I consider decision to remove Windows application development as good as Windows Phone is. Or, in other words, it might seem logical in head of some manager but in real life there is no chance of this working.

I see Visual Studio Express as a gateway drug toward other, more powerful, editions. Crippling it will just lead to folks staying on perfectly good Visual Studio 2010. Not everybody will have Windows 8 nor care about them. Since I schedule posts few days/weeks in advance, original post had continued rant here. However, there are still some smart guys in Microsoft so desktop application development is still with us in Express.

If I read things correctly it gets even better. It seems that unit testing and source control is now part of Express edition. That were the only two things missing! Now I am all wired up for Express to come. Judging from experience I should probably tone it down unless Microsoft management decides to take some/all stuff away.

All things considered, I am happy with this edition. It is stable, it has no major issues and it is completely compatible with Visual Studio 2010. For most time it feels like Visual Studio 2010 SP2. Try it out.

Mutex for InnoSetup

Illustration

If you are using InnoSetup for your installation needs you might be familiar with AppMutex parameter. You just give it SomeUniqueValue and make sure that Mutex with same value is created within your application. That way setup will warn you if your application is already running. Useful function indeed.

Simplest way to implement this would be:

static class App {
    private static Mutex SetupMutex;

    [STAThread]
    static void Main() {
        using (var setupMutex = new Mutex(false, @&quot;Global\SomeUniqueValue&quot;)) {
            ...
            Application.Run(myForm);
        }
    }
}

And this code will work if you deal with single user. In multi-user environment this will throw UnauthorizedAccessException. Why? Because Mutex is created within current user security context by default. To have behavior where any instance, no matter which user, will keep our Mutex alive, we need to adjust security a little.

Since making null security descriptor in .NET is real pain, we can do next best thing - give everybody an access. With slightly more code we can cover multi-user scenario.

static class App {
    static void Main() {
        bool createdNew;
        var mutexSec = new MutexSecurity();
        mutexSec.AddAccessRule(new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                                                   MutexRights.FullControl,
                                                   AccessControlType.Allow));
        using (var setupMutex = new Mutex(false, @&quot;Global\SomeUniqueValue&quot;, out createdNew, mutexSec)) {
            ...
            Application.Run(myForm);
        }
    }
}

P.S. No, giving full access to mutex that is used purely for this purpose is not a security hole…