Scott Hanselman

Three Monitors - I can't go back

August 15, 2007 Comment on this post [23] Posted in Musings
Sponsored By

I was just sitting here lavishing in the "three monitors of it all". I can truly say that the decision (well, not really a decision as Jeff absolutely insisted) to get a third monitor, specifically a Dell 20", has truly changed my work life. You can not have too much workspace until the monitors completely fill your field of vision.

ThreeMonitors

(Forgive the silly theme and lack of wallpaper...the book editors require a certain Windows theme)

I can absolutely see myself getting forth monitor, and either mounting it to the far right or possibly above the center.  The amount of time I'm saving by not Alt-Tabbing during a task is significant. 

Window management was taking up a lot my time - I had no idea until I had so much desktop space how much time I was spending just resizing windows. Not moving them around as much as moving them out of the way of others.

When you've got another monitor you can dedicate it to a single task. Right now I'm working on a book, so I've got a VM on one screen, Visual Studio on another, and Explorer on a third. For me, it comes down to this - turning my head is way easier than Alt-Tab.

I never would have believed it until I tried it. I encourage you to look at 2 monitors if you have one or 3 if you have two. With 20" flat panels going for $300, now's the time.

I was using a simple Three Monitor setup in December of 2003, but it never quite took off for me for a couple of reasons:

  • The laptop was the third monitor (via MaxiVista) and either my wife or I would walk away with it. I couldn't count on the third monitor.
  • The distance between the bezels was crazy wide. In this older picture the middle monitor was 17" at 1280x1024 and the one on the right was a 17" CRT. They were both 96dpi but...
  • ...the laptop was 120 dpi (really high-res screen) and the difference was very distracting.

And remember, when you go Multiple Monitor, you need to get Ultramon.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

dasBlog 2.0 Released

August 15, 2007 Comment on this post [7] Posted in ASP.NET | DasBlog
Sponsored By

Congratulations to the team, dasBlog 2.0 is out and it runs on Medium Trust. There are numerous small bug fixes, but the move to 2.0 and Medium Trust support is the major feature. However, the fact that we are on 2.0 (and many of us are building on 3.5) will allow us to do some pretty cool innovation pretty quickly. Clemens Vaster is back on the team and checking in some "dasBlog 3.5" architectural spikes that are worth looking at. They can be found, as always, in the source via anonymous Subversion to https://dasblogce.svn.sourceforge.net/svnroot/dasblogce/trunk.

Upgrading

The upgrade is simple, just back everything up, copy all DLLs and AS?X files. The only manual process is that you should merge your web.config with the new default one that includes a few ASP.NET 2.0 specific tags. Make sure your virtual directory is set in IIS to be an Application and that Application is set to ASP.NET 2.0.

Getting Help

If you need help with dasBlog, you've got a number of options.

Hosts that Support dasBlog

Works with dasBlog There are a number of commercial hosts that support dasBlog. That should mean that they won't say "huh?" when you ask them to setup your blog. Here's the ones we know about. If you're a host that supports or wants to support dasBlog, join our Developer Mailing List and start a dialog with us.

Medium Trust

From my previous post on our Medium Trust Issues:

Tony Bunce has a fine write-up on the issues we ran into with dasBlog on Medium Trust. Here's some highlights:

"The goal of medium trust is for hosting providers to provide functional ASP.NET 2.0 hosting while also protecting against rogue or malicious applications. Unfortunately that protection comes at the cost of application flexibility. ...There are a few features that are limited in a medium trust environment: SMTP on alternative ports and Mail to Weblog via POP3...dasBlog will let you know that you don't have these privileges by displaying warnings on the configuration page.

There is some good news though, these limitations won't affect most users.  Many hosting providers that run limited trust environments don't run in the default medium trust, but rather a "modified full trust".  In that case you may already have all the permissions you need for all of the features to work."

Go check out his post for more details. The most interesting issue we bumped into was that you aren't supposed to be able to call out via HTTP on the server side to any other connections unless they match your originURL in your web.config. In other words, my blog at www.hanselman.com can't call to any other site that isn't hanselman.com. However, you can set you originUrl to a regular expression like ".*" and then you can connect anywhere. Phil Haack noticed this and got the fix from Cathal Connollys.

The Future

There's also some cool stuff going on around our pluggable editors, with John Forsythe setting up a YUI Editor as well as Rich Comments support for the folks who want to live on the edge. Do checkout the dasBlog section on John's blog for extra add-on macros and cool patches if you're compiling dasBlog on your own.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Windows Update should hide HResults

August 15, 2007 Comment on this post [5] Posted in Musings
Sponsored By

Windows Update on Vista x64 Ultimate woke up today and told me I needed a new video driver.  Since I was being very careful to not install anything unsigned or controversial, I didn't download any new drivers from the manufacturer's website.  It seemed to me that when Windows Update told me it had a new driver available, they wouldn't be that big a deal to get this new driver.

Windows Update

Windows Help and SupportAfter much gnashing of teeth and flashing of my monitor, Windows Update announced that the update failed. Waa? That doesn't usually happen. I noticed the error code was a COM hResult with a link next to it. I though I was rid of those. Then I clicked the link and saw this.

This was a pretty interesting dialog because it told me:

"Go to the Discussions in Windows Update website to see if someone else has found a solution or to request help from other Windows users."

<sarcasm>Wow, that was helpful. </sarcasm> It also said:

"If you receive Windows Update error 80070103 while installing updates, you might be trying to install a driver that is already installed on your computer or a driver that has a lower compatibility rating than one you already have installed."

What's a driver compatibility rating? I would assume the Windows Update would only suggest compatible drivers that were the most not-controversial ones available.  In my experience Windows Update tends to be very conservative in these things.

Time to reboot and hope for the best.

P.S. I dictated this entire blog post using the Windows Vista to voice recognition feature.  Worked pretty well, and gave my hands a break. 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Preventing Comment, Trackback and Referral Spam in dasBlog

August 12, 2007 Comment on this post [5] Posted in ASP.NET | DasBlog
Sponsored By

Blog spam is a huge problem. If you don't spend time "tending" to the garden that is your blog, you'll return back after a short hiatus and find it completely overrun with weeds and spam.

Here's how to keep your dasBlog installation free of SPAM.

Easiest

Here's the absolute easiest way to clean your dasBlog installation of spam.

  • Turn off TrackBacks and Pingbacks
    • Trackbacks and Pingbacks are the way that blogs let YOU know that you're being talked about. For example, if I mention Greg, like I just did, dasBlog will send him a Trackback and a Pingback when I submit this blog post and there's an endpoint on his blog, listening over HTTP that will receive it. Then his web server will load up my page and check to see if there's really a new link. A pingback is the same thing, without the back-check.
    • However, more and more I believe the Trackback spec is broken. There's just no decent way to prove that the Trackback is legitimate.
    • Therefore, I've stopped collecting them. 7 out of 10 Trackbacks I get are spam, so I've turned off the service in DasBlog. Instead, I check Technorati for references to my blog in order to see if anyone's mentioned a topic I've blogged about.
      image
  • Turn off Referrals
    • Referrals are created when someone simply arrives at your site from another site. They are created by the HTTP Referer (yes, it's misspelled) Header and it's the easiest of the spams to fake. It also grows forever. I've turned it off by un-checking "Save Referrals Along with Entries." This is especially important if you run a high-traffic blog. Quickly you'll find that Referrals will take up more space than your blog content!
  • Remove All your old Referrals
    • If you run the dasblogupgrader.exe (you can run it as many times as you like) on your content folder, there is an option to remove all referrals. I suggest you do just that, then turn off this option. It'll tidy up your XML files, make your whole blog faster and referral spam free.
    • You download your entire content folder to your local machine, and run:
      dasblogUpgrader.exe c:\myfolder\content
      and follow the prompts.
  • Stop Displaying Trackbacks and Referrals
    • Posts (items) in dasBlog are formatted according to the "itemTemplate.blogtemplate" file using well-known macros. Go into your theme's itemTemplate.blogtemplate and remove both <%TrackbackList%> and <%ReferralList%>. Both of them take processing time to load up the referrals and trackbacks you've collected, and if your blog is spammy, these will only display naughty things you don't want.
    • Instead, consider replacing them with a call to Technorati like this:
      <li class="technorati"><script src="http://embed.technorati.com/linkcount" type="text/javascript"></script><a class="tr-linkcount" href="http://technorati.com/search/<%PermalinkUrlRaw%>">Blog reactions</a></li>
    • Or, use the FeedBurner service and include their Technorati "FeedFlare" option. Here's how to add FeedBurner Flare to dasBlog.
  • Turn off Comments or turn on CAPTCHA
    • I personally wouldn't suggest this, but you could always turn off comments all-together. I would argue that at this point you have a pamphlet, rather than a blog, but it's your blog.
    • Alternatively, you could make sure that CAPTCHA (those funny letters you have to type in to prove you're a human) is enabled.
    • You could also turn on explicit comment approval but if you have a high-traffic blog this will get old fast.
  • Close your Comments after some period of time
    • This is a little controversial, but I found that a lot of really old posts were getting spammed a lot. I started turning off comments for posts over 60 days old and my incoming spam dropped a LOT.

Slightly Harder (and still effective)

Ok, so you're not willing to do the easy stuff. Here's some more tricky things, that give you the best of both worlds

  • Start using Akismet
    • Go visit the WordPress.com site and sign up for a free account.
    • IMPORTANT: At the bottom, click "Just a username, please." You don't want a blog, remember, you're using dasBlog.
    • They will email you a welcome and in that email will be an API KEY. That's what you want and why you signed up for a free account.
      WordPress.com - Windows Internet Explorer
    • Go into the dasBlog configuration page at the VERY bottom and click "Enable spam blocking service." DasBlog uses Subkismet, from Subtext. Enter your API Key and click either "Save suspected SPAM" or "Delete Suspected SPAM immediately."
    • Akismet is very very accurate in my experience, so I just delete SPAM. It will block comment spam and TrackBack spam, so you could keep Trackbacks up with this solution if you like.
    • I would also greatly encourage you to pay them $5 a month or $55 a year via PayPal for preferred service. Your response from their servers will be faster. I've been very happy with them.
  • Add a Referral Blacklist
    • Still not ready to give up referrals? Enable the Referral Blacklist and enter in a ';' separated list of naughty words that appear in your referrals. Be warned, this list will be used to create a Regular Expression, so keep it simple.
    • Also, click "Send 404s to blacklisted referrals" and dasBlog will lie to the spammers and tell then the page is gone.
  • Block Specific IPs
    • If a particular IP Address is a problem, make a blockedips.config file in your /SiteConfig folder and put each IP on a different line. Then make sure this line in is the httpModules section of your web.config:
      <add type="newtelligence.DasBlog.Web.Core.IPBlackList, newtelligence.DasBlog.Web.Core" name="IPBlackList"/>
  • Install ReverseDOS
    • Still not satisfied? Install AngryPet's ReverseDOS and fight back. It's a fairly sophisticated HttpModule that lets you determine what's legit and what's not. Tony uses it under dasBlog and SubText ships with ReverseDOS. We likely will add this in the future, but you can always add it now.

These are the ways I know of to fight blog SPAM. If you have more, add them to the comments!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

A vCard Preview Handler using the Coding4Fun DevKit

August 12, 2007 Comment on this post [5] Posted in Coding4Fun | Programming
Sponsored By

ExplorerForm I sat down with the Coding4Fun Developer Kit and immediately noticed the Preview Handler stuff. I got addicted to Preview Handlers back when Tim wrote one for PDFs. They are darned useful and it seems to me that any application that adds a new file type should add a preview handler for it. They are used in the Vista Explorer, in Outlook 2007 and in Windows Desktop Search. If you or your company makes an explorer replacement, you can also host a Preview Control and add Preview functionality to your own File Explorer application.

I wanted to make a vCard Preview Handler so I could see what's inside a vCard on systems that don't have Outlook. Here's the process to create your own Preview Handler in no time (keeping in mind that the kit is BETA).

  • After installing the C4F Developer Kit, make new Class Library project and add a reference to the PreviewHandlerFramework.
  • Create a new class like below and add the [PreviewHandler] attribute with a name for your project, the extension or extensions (like .foo;.bar), and another Guid for the COM Stuff.
    • You can get new GUIDs either via GuidGen.exe included with the Windows SDK or online at http://www.guidgen.com/ or in PowerShell via [Guid]::NewGuid().ToString()
  • Also, include a ProgId for your new class. I just used the namespace.classname.
  • Notice that I derived from FileBasedPreviewHandler. You'll need to override CreatePreviewHandlerControl and return a new instance of your own Control that is derived from FileBasedPreviewHandlerControl. The boilerplate is below. It's inside Load() where you create whatever WinForms controls you need to and add them to the this.Controls collection.
using C4F.DevKit.PreviewHandler.PreviewHandlerFramework;

namespace C4F.DevKit.PreviewHandler.PreviewHandlers
{
    [PreviewHandler("Hanselman Silly vCard Preview Handler", ".vcf", "{42810C0B-FEA8-4dbf-A711-5634DFBA9F3B}")]
    [ProgId("C4F.DevKit.PreviewHandler.PreviewHandlers.vCardPreviewHandler")]
    [Guid("D193B258-AC07-4139-B334-C20F18F4FC7C")]
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]
    public sealed class vCardPreviewHandler : FileBasedPreviewHandler
    {
        protected override PreviewHandlerControl CreatePreviewHandlerControl()
        {
            return new vCardPreviewHandlerControl();
        }

        private sealed class vCardPreviewHandlerControl : FileBasedPreviewHandlerControl
        {
            public override void Load(FileInfo file)
            {
//ADD STUFF HERE } } } }

vCards are funky things, and there's multiple versions of the format. The general format is like this:

BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-us:Hanselman;Scott
FN:Scott Hanselman
ORG:Microsoft
TITLE:Senior Program Manager
TEL;WORK;VOICE:+1 (503) 766-2048
TEL;HOME;VOICE:+1 (503) 766-2048
TEL;CELL;VOICE:+1 (503) 766-2048
ADR;WORK;PREF:;;One Microsoft Way;Redmond;WA;11111;United States of America
LABEL;WORK;PREF;ENCODING=QUOTED-PRINTABLE:One Microsoft Way=0D=0A=
Redmond, WA  11111
ADR;HOME:;;5 Main Street;Main Town;OR,;12345;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:5 Main Street=0D=0A=
Main Town, OR, 12345
URL;WORK:
http://www.hanselman.com
EMAIL;PREF;INTERNET:firstname@lastname.com
REV:20070810T050105Z
END:VCARD

But there's a million extensions to this format and things can get very complex very fast. I set myself a goal of getting something passable working in a few hours, so I decided to preview the vCard in a DataGrid. That made Load() look like this:

public override void Load(FileInfo file)
{
    DataGridView grid = new DataGridView();
    grid.DataSource = ConvertVCardToDataTable(file);
    grid.ReadOnly = true;
    grid.Dock = DockStyle.Fill;
    grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
    Controls.Add(grid);
}

Next, I took the FileInfo and spun through it, breaking up each line and sticking it into a static DataTable, the format most friendly to the DataGridView.

private static DataTable ConvertVCardToDataTable(FileInfo file)
{
    DataTable table = new DataTable();
    table.Locale = System.Threading.Thread.CurrentThread.CurrentCulture;
    table.TableName = file.Name;

    using (StreamReader sr = file.OpenText())
    {
        table.Columns.Add("Data");
        table.Columns.Add("Value");

        string line;
        while ((line = sr.ReadLine()) != null)
        {
            if (line.Length > 3)
            {
                string[] parts = ProcessVCardLine(line);
                if (parts != null && parts.Length == 2)
                {
                    table.Rows.Add(parts);
                }
            }
        }
    }
    return table;
}

ProcessVCardLine just returns a string array of "name,value" given a single vCard line. Again, I never said it was pretty, I just said it worked.

private static string[] ProcessVCardLine(string line)
{
    //This is by no means a complete or even passable parsing of the fairly complex vCard format.
    List<string> nameValue = new List<string>();

    if (line.StartsWith("BEGIN:VCARD")) return null;
    if (line.StartsWith("VERSION:")) return null;
    string[] parts = line.Split(':');
    if (parts.Length == 2)
    {
        AddVCardLine(parts, ref nameValue, "TZ", "TimeZone");
        AddVCardLine(parts, ref nameValue, "NICKNAME", "Nickname");
        AddVCardLine(parts, ref nameValue, "N", "Name");
        AddVCardLine(parts, ref nameValue, "FN", "Friendly Name");
        AddVCardLine(parts, ref nameValue, "ORG", "Organization");
        AddVCardLine(parts, ref nameValue, "TITLE", "Title");
        AddVCardLine(parts, ref nameValue, "TEL", "Phone");
        AddVCardLine(parts, ref nameValue, "ADR", "Address");
        AddVCardLine(parts, ref nameValue, "URL", "Website");
        AddVCardLine(parts, ref nameValue, "EMAIL", "Email");
        AddVCardLine(parts, ref nameValue, "X-MS-IMADDRESS", "IM");
    }

    return nameValue.ToArray();
}

private static void AddVCardLine(string[] parts, ref List<string> nameValue, string name, string friendlyName)
{
    if (parts[0].StartsWith(name) && parts[1] != null)
    {
        nameValue.Add(friendlyName);
        nameValue.Add(parts[1].Replace(";", ",").Trim().Trim(','));
    }
}

Registry Editor Because this is a .NET assembly that will be called by an app expecting a COM dll, you'll need to put it in the GAC and run Regasm on it.

I made this easier during development by adding these two lines to the Post-build event command line. You may need to search your system to find where Gacutil.exe and Regasm.exe are on your system, or you can download the .NET Framework 2.0 SDK.

"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\Gacutil.exe" /i "$(TargetPath)"
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\Regasm.exe" /codebase "$(TargetPath)"

Once registered, the new vCard Preview Handlers is available all over Windows to any app that cares to use it.

I've looked at this code a couple of times, not just because it's poopy, but because I felt there must be at least a few clean ways I could have made the code cleaner/terser using some of the new C# 3.0 features like Anonymous Types, and yield. Any ideas?

Here's the real tragedy. After I wrote this very sad little "just barely good enough" vCard parser, I discovered that the Coding4Fun DevKit already included a very complete vCard parsing implementation.

Curse my metal body! The vCard sample is in the Contacts project within C4FDevKit and it's scrumptious. Well, live and learn. Anyway, I had fun and it took less than an hour to get a useful (to me) PreviewHandler working. The C4FDevKit includes samples and compiled PreviewHandlers for CSV, generic binary, Icons, XML files via IE, MSIs, PDFs, Resx and Resources, SNK (keys) and Zip Files. Sweet.

You can more easily test your Preview Handlers using the PreviewHandlerHost control on a simple WinForms app, or even easier by using the already-written PreviewHandlerHost at Coding4Fun\C4FDevKit2008v1\Preview Handlers\Samples\VB\PreviewHandlerHostSample as seen in the screenshot above.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.