Thursday, August 24, 2006

Console Text Selection Via the Keyboard

I was hanging out with some Pluralsight guys last weekend. Dan Sullivan was talking about SQL Service Broker, so I was already paying close attention, but then he did something that made me sit straight up my seat…he selected text in a console window using only the keyboard!

 

I've said it many times before: I'm a keyboard kind of guy. So it has always bugged me when I have had to take my hands off the keyboard to select text in a console window. Well, now I don't have to any more. Maybe I'm the last guy to figure this out, but apparently when you go into mark mode in a console window, you can use the arrow keys to move the selection point, and shift-arrows to extend the selection. Way cool!

 

Just to summarize, here's how I'd select some text in a console window, using only the keyboard:

 

Alt-Space, e, k  [Enter mark mode]

Down, down, down, right, right, right [Move the cursor]

Shift-right, shift-down, shift-right [Extend the selection]

Enter [Copy the selection to the clipboard]

 

Yay! Thanks Dan!

Friday, July 28, 2006

Producing Open Source Software - A Review

I just now finished reading "Producing Open Source Software: How to Run a Successful Free Software Project". It was, in a word, excellent. Really, really good. And it's available in its entirety for free online.

 

I definitely learned a lot reading this book, despite having had a couple of years' experience helping to run FlexWiki now. I was happy to see that we already follow many of his recommedations, but I also know I'll be changing a few things we do based on what I read.

 

Even setting aside the fantastic advice about how to set up the technical infrastructure, I found Mr. Fogel's insight into the culture of free/open source to be truly insightful. It's no wonder that Subversion rocks so hard with guys like this behind it.

 

If you haven't already, read this book soon.

Thursday, July 27, 2006

Getting CLR Security Right - Seeing Double

This one bit me the other day. Fortunately Dominick was able to straighten me out rather quickly.

 

What I was trying to do was to update a build script to run off of a shared drive (don't ask). Of course, when running .NET code like NAnt and the other 90 tools we use in the build, you need to elevate privileges or your tools are unlikely to work with the decreased permissions they get by default when running from a network drive. That much I knew. Where I got burned was that some of our tools are compiled for .NET 1.1, and some for 2.0. Well, policy for 1.1 is completely separate from policy for 2.0. So I had to change it in both places.

 

Luckily, I didn't waste too much time on this. It helps to be willing to bother your friends. :)

Tuesday, July 25, 2006

It's (sort of) Alive!

Just a few minutes ago, I fired up my web browser and pointed it at the FlexWiki code I've been hacking on. To my complete amazement, the home page actually rendered! It was riddled with errors, and it crashed when I tried to edit a page, but the blasted thing actually showed me HTML that wasn't the ASP.NET error page…I practically peed myself.

 

As you may have read here before, I've been working on refactoring FlexWiki for quite a while. I started tracking my hours in October of 2005, but I really started this effort a few months before that. I generally try to work on it every day, but the realities of work and family mean it's much less often than that. Still, I see I've put in over 100 hours on it. If nothing else, that makes me feel pretty good about having "paid" for all the open source software I use. :)

 

There's a metric boatload of things to be done before FlexWiki 2.0 is ready to go, of course. I think my next few months will look something like this:

 



  1. Fix the 10,000 bugs I introduced.

  2. Develop a performance test suite to characterize the behavior of the application.

  3. Run the test suite.

  4. Analyze the results.

  5. Make improvements, including the caching provider that was part of the original reason for doing this massive refactorization.

  6. Goto 3 a lot of times.

  7. Write the security module that got me started on this hellroad.

  8. Goto 1 a lot of times.

  9. Release!

  10. Goto 1 a lot of times.

  11. Take a break from FlexWiki. Maybe to work on FlexWikiPad. :)

 

Still, this really feels like turning a corner. Yay me.

Wednesday, June 21, 2006

Ian Launches WpfMsdn

Running with the msdnman ball, Ian has launched WpfMsdn, a GUI browser for the content coming out of the MTPS Content Service.



WPF MSDN Reader


Cool. :)

Monday, June 19, 2006

Mixing Forms and Windows Authentication in ASP.NET 2.0

Almost two years ago, I blogged about how to mix Forms and Windows authentication in an ASP.NET application. It was something I figured out for a client, and they've been using the basic idea ever since. It worked pretty well up until a month or two ago. Then it broke pretty hard. What changed? We upgraded to ASP.NET 2.0.

 

Well, I finally got a chance to sit down and chase the problem, and I figured out what looks like a solution. We have yet to integrate my idea into the product, but I wrote a quick prototype, and it looks like it's going to work, so I thought I would blog it here.

 

The kernel of the problem is that the ASP.NET 2.0 Forms Authentication Module appears to stomp on the "Response.StatusCode = 401" that you need to set in order to make mixed authentication work. I'm not sure exactly where this happens: I got lost in Reflector when I tried to chase it down. But you can easily observe the effect - your login page will redirect back onto itself, with the ReturnUrl query string parameter double-escaped. That is, you'll see something like this in your address bar:

 


 

instead of this

 


 

Notice how the ReturnUrl is actually pointing back to the login page itself, rather than to Default.aspx the way it should be. Again, I haven't chased down exactly where this behavior is coming from, but it's easy enough to observe.

 

My solution was simply to attach a handler to the Application's EndRequest event by putting the following in Global.asax:

 

protected void Application_EndRequest(object sender, EventArgs e)

{

    if (Context.Items["Send401"] != null)

    {

         Response.StatusCode = 401;

         Response.StatusDescription = "Unauthorized";

    }

}

 

Then, in order to trigger this code, all I have to do is put a

 

Context.Items["Send401"] = true;

 

somewhere in my login page when I determine that I need redirection to pick up on the user's Windows credentials. Because Application_EndRequest runs much later in the page lifecycle than the code in my login page, Forms Authentication can't get in the way and screw up my status change.

 

I thought I'd try to be really clever and attach my handler in the page itself by doing something like this:

 

Context.ApplicationInstance.EndRequest += LoginPage_EndRequest;

 

but it doesn't work. I'm not sure why (the page lifecycle is not my strong suit these days), and I'm out of time to chase it down.  If you happen to know what I'm doing wrong, drop a comment. In the meantime, the Global.asax thing works well enough for us.

Friday, June 16, 2006

msdnman Moves To CodePlex

Now that msdnman is public, I need to find a home for it that isn't two zipfiles in a directory somewhere. I said I was going to move it to SourceForge, but Brad Wilson suggested that I host it at CodePlex instead. So I did: msdnman lives here now.

 

CodePlex is part Microsoft's answer to SourceForge, part spiritual successor to GotDotNet. As you know, I was pretty a pretty vocal detractor of GotDotNet, but that's exactly why I wanted to try out CodePlex - I wanted to see if Microsoft had gotten it right this time.

 

Well, I'd say they're on the right track. Having worked with CodePlex for all of two days now, I'm reasonably impressed. To start with, it has a real source control system - TFS. Aspects of the command-line support are slightly annoying (the need to constantly reauthenticate, specifically), but it's a totally modern tool, with support for lots of interesting and useful features (e.g. shelving). Other touches of the site - wiki editing for the project's home page, export of work items to Excel, linking checkins to work items, etc. - are really nice, and a step above what SourceForge provides.

 

My only major complaint is that there's no email support on the site right now. I believe email to be the lifeblood of open source projects. It's certainly how I do everything. Right now CodePlex uses RSS, which I think will serve well enough until email is available (it's on their list).

 

All in all, CodePlex is a pretty good effort for a v1 release. I expect it will improve rapidly, too, given that they have people like Brad and Jim Newkirk (of NUnit fame) on the team.