June 2006 - Posts - Jon Galloway

June 2006 - Posts

Mouseless Computing

The professional programmer encounters a variety of challenges and annoyances in the line of duty, but by far the top job hazard is Repetitive Stress Injury (RSI). We can muddle our way through less than optimal projects and coding blunders (hopefully learning as we go), but it's pretty hard to program if you can't type or double-click.

Jeff Atwood recently wrote about some great tips for caring for your hands and wrists - things like exercise, posture, breaks. I'd like to add to that by discussing some practical ways to avoid the most damaging motion in modern computing - mousing.

Step 1: Mouse Goofy

The simplest thing you can do is to just switch mouse hands. It's a bit frustrating at first, but it's the easiest change you can make and it can give you some immediate relief. I've worked with a few people over the years who switched to left handed mousing and haven't had any problems since then.

Step 2: Ditch the mouse for a better pointing device

If you have to use a pointing device, you can switch to something that puts less stress on your wrists. I switched to a trackball a few years ago (my current trackball is a Logitech Trackman Wheel); the only time I use a mouse is with left hand so I can give my right hand a break. But my primary pointing device is way better...

Wacom Graphire Tablet

I use a Wacom Graphire Tablet. It's great - pointing with a pen isn't nearly as repetitive as with any other pointing device I've used, since you can move around the screen by moving your arm without moving the wrist or hand at all. You can hold the pen in a lot of comfortable positions and easily move around in your chair. The one I've got is wireless (BlueTooth), which was a bit more expensive but a lot more flexible - I can lean back in my chair and work, for instance. Plus, an added bonus is that it's a much better pointing device for art and photo manipulation, so it's not such a conceptual shift to pop open an art program and retouch a website image when the need arises. I mapped one of the tablet function keys to right-click since my pen right-click button doesn't work that well.

There are a lot of other alternative pointing devices out there. I worked with a guy who's tried them all (howdy, Ted!) and settled on one that looks like a joystick. I'm happy with the tablet since it seems the most natural and flexible to me, but just about anything that can replace a mouse is a great step.

Here's a shot of my desk. You can see the tablet in front of the Microsoft ergo keyboard. I've got my left handed mouse a little out of reach on the left to keep me honest, and the trackball even further out of reach on the right. I don't really work with the bright yellow Wumpus sticker under the monitor; that's been known to induce siezures. I only put it there to fulfil the terms of my sweet product placement deal.

Desk

Step 3: Use your keyboard as much as possible

Browsing

I'll talk about some Windows and application specific shortcuts in a minute, but I'm going to start with the hard one first - browsing. The website is the last bastion of inaccessibility, with image buttons and AJAXified links strewn across the screen. What can you do?

Well, in Firefox, you've got some options. By far, the site I use most frequently is Google search, so the Search Keys extension helps quite a bit. Search Keys adds a number shortcut next to each search result, so you can just type the number to go to that result. One thing to be aware of - if you're in the middle of an incremental search, the number keys won't activate Search Keys (that's a good thing, otherwise you could never search a page for numbers). To close incremental search, just hit Ctrl-F, Escape. I've been using Search Keys a while now - maybe a year - and I like it a lot.
Firefox SearchKeys Extension

While using Search Keys  one day I started wondering if there was a way to avoid clicking links on other pages, which lead me to a great article on LifeHacker about Mouseless Firefox. It's got some great tips about Firefox shortcuts, but as is often the case the real goods are in the comments, which mention the Search Keys, Hit-A-Hint, and MouselessBrowsing extensions.

I tried MouselessBrowsing (didn't work for me for some reason) and settled on Hit-A-Hint. It's simple to use - in any web page, you tap the spacebar twice, holding the second time. Small numbers appear on top of every link and form field; just type the number in and release the spacebar to click the link. It takes about 30 seconds to get used to it, and you can easily browse without a mouse. Nice! I use it a lot and highly recommed it.

Firefox Hit-A-Hint Extension

The LifeHacker Mouseless Firefox article runs through a bunch of shortcuts. Here are the ones I use most often:

Control-T (new tab)
Alt-D pops you in the address bar, and Alt-D, Tab puts you in the search box
Alt-Left (Broswe Back) and Alt-Right (Browse Forward)
Control-Tab (next tab) / Shift-Control-Tab (previous tab)

IE6 doesn't seem to work as well without a pointing device. There are shortcuts (IE6, IE7), but they're really just shortcuts for controlling IE, not for clicking links in a page. The official IE solution to clicking a page link seems to be "keep clicking on the tab key". There's an addon from the University of Illinois - IEAccessible - that supposedly improves accessibility for IE. I haven't tried it.  [please recommend any options for IE in the comments below and I'll update this]

Opera has great mouseless support built in.

General Windows Shortcuts

The System Tray (oops, I mean Notification Tray) is a bit tough to get to if you don't know the trick, and it seems like everything wants to minimize there nowdays.
Win-B / Enter to show hidden icons (if necessary) / Right arrow / Right-click button (or Shift-F10)

Quick Launch also requires some keyboard trickery:
WinKey (press and release) / Tab / Right arrow

Use Alt-Tab to switch between applications. I recommend using Task Switch XP (free) to beef up the task switcher interface.

Alt-Space brings up the window command menu, which allows you to move or resize windows with the arrow keys. Very few people seem to know about or use these features, which can cut way down on mouse usage.

Use Alt-F4 to close an application

You can get to any program on your Start Menu by hitting the WinKey and using your arrow keys

Microsoft lists some general Windows shortcuts here.

The Windows Key can do so much it really demands its own post. Luckily Jeff already took care of that - see his Celebration of the Windows Key on Coding Horror.

Right clicking can make you want to reach for your mouse. Instead, use the Context Menu Key to right-click on standard Windows keyboards. You can use Shift-F10 if it's not available (laptop, etc.).

You can do quite a bit with Start / Run commands. There's a great list here.

Use a utility that allows you to copy a file's full path to the clipboard. I like ClipPath. Julie Lerman has a good list of them here. It's a simple little chore I find myself doing all the time, and ClipPath cuts down on mousing and keystrokes.

The Alt Key is your friend
Some applications show accelerator keys undelined by default, others hide them until you hit the Alt key.
Example - in most applications, Alt-F X will exit an application. Look around!

MouseKeys (built into Windows) allows you to move and click the mouse using the number keys. You can enable it by pressing Alt-Left Shift-NumLock. You can change the settings (such as how fast it moves) via the Accessibility control panel widget, which you can launch directly with Start / Run / Access.cpl.

Find shortcuts for applications you use the most

Outlook / Office - Outlook 2003 has keyboard shortcuts for just about everything you'd want to do. The Go Menu (Alt-G) lists the major areas with their shortcuts (Ctrl-2 = calendar, etc.). Office 12 enhances the keyboard sortcuts by making them a lot more obvious, using the same shortcut overlay UI technique Hit-A-Hint does.

Visual Studio - Again, Jeff's got us covered with a nice rundown of keyboard shortcuts for Visual Studio.

SQL Server 2000 Query Analyzer - See the nice list of Query Analyzer shortcuts on OdeToCode. I bet I'm in the minority here, but I always liked the Query Analyzer UI, especially because the the keyboard shortcuts were so comprehensive.

Windows Media Player - Windows Media Player 11 and I aren't really on speaking terms at the moment, but that's the subject of another post. The only way I've found to go from Now Playing to Library view involves hitting the Tab key 16 times. I'm sure there's a better way, but the fact that it's pretty well hidden is unfortunate. Another example - you can play at half speed, normal, and double speed, but in order to do anything else you're camping on the tab key. There are shortcuts to get around in Library mode (Ctrl-7, 8, and 9, Ctrl-E for search). The Media Player site has a list of shortcuts (for WMP 10); it's okay, but I can't picture using WMP without a mouse.

 

Got any tips you'd like to pass along?

Google TechTalks (EngEdu)

Google's been posting videos of some interesting Tech Talks on video.google.com. Most of them focus on computer science topics, but there are also some general informational videos on topics like astronomy, biotech and biofuels. I haven't had the time to watch too many of them, but the topics sure are interesting!

Posted by Jon Galloway | with no comments
Filed under:

Avoid IISRESET in ASP.NET applications (added bonus: ASPRESET)

I'm always a bit worried when I work with developers or system admins that still think you should "throw in an IISRESET just in case" when deploying ASP.NET applications. Cargo cult server administration at its worst ("Not sure why, but it always seems to help if I throw in an IISRESET after pushing code. If that don't get it, a reboot will!").

This is very rarely necessary now, and it's terrible to take all websites on a server offline "just in case". It was often needed back in the ASP / COM days (you needed to free the reference to COM objects to allow overwriting the files), but ASP.NET code runs under the ASP.NET worker process and runs with side-by-side support, which completely obviates the IISRESET step. Copy the files and go!

If your changes include files which will restart the web application (such as DLL's or the web.config file), the site will automatically restart. You're done.

If, on the other hand, you've edited other files which don't cause a website restart (such as .config files referenced from web.config, etc.) you'll have to trigger the site to reload manually. There are at least 4 ways to force an ASP.NET website to recycle:

  1. Edit web.config - open it in notepad, add a space, remove the space, and save. The change to the file timestamp will cause the site to reload.

  2. "Touch" the file to change the file timestamp. I wrote a reg file that adds a "right click / Touch" menu item a while ago for just this purpose. There are other more advanced Touch utilities such as the one Scott Hanselman mentions here.

  3. Kill ASPNET worker process manually. Don't be scared - it will automatically restart on the next request.1 It will dump the current requests (and possibly session state if you're inproc), but so will all of these. The ASPNET worker process is a cockroach; it keeps coming back. You just bring up the task manager, go to the Processes tab, find your ASP.NET worker process (aspnet_wp.exe for XP and W2K, w3wp.exe for W2K3 and Vista), right-click it and select "End Process". It will restart on the next request to an ASP.NET page.

  4. A new one - ASPRESET. All the above methods are more work than Start / Run / IISRESET, which means people will be more likely to fall back to their old habits and run that IISRESET. The following code (compiled and saved as ASPRESET.exe and saved in a folder in your path) will kill the ASP.NET worker process and restart it immediately by requesting a phony page with a .ASPX extention. That's expecially handy if you build ASP.NET in Visual Studio as non-web projects, since you need a running process to attach to when you debug. I keep the compiled executable in a

I built this in SnippetCompiler, but it will work just fine in Visual Studio 2003 and 2005 as well.

using System;
using System.Diagnostics;
using System.Net;

public class AspReset
{
 
public static void Main()
 {
  KillAspNetProcess();
  StartAspNetProcess();
 }
 
 
private static void KillAspNetProcess()
 {
  
string processName = "aspnet_wp";
  System.OperatingSystem os = System.Environment.OSVersion;

  
//Longhorn and Windows Server 2003 use w3wp.exe
  
if((os.Version.Major == 5 && os.Version.Minor > 1) || os.Version.Major ==6)
   processName = "w3wp";
   
  
foreach(Process process in Process.GetProcessesByName(processName))
  {
   Console.WriteLine("Killing ASP.NET worker process (Process ID:" + process.Id + ")");
   process.Kill();
  }
 }

 
private static void StartAspNetProcess()
 {
  
try
  
{
   
string phonyURL = "http://localhost/directory/does/not/exist/" 
    + Guid.NewGuid().ToString() 
    + "/start.aspx";
   WebClient myWebClient = 
new WebClient();
   
byte[] myDataBuffer = myWebClient.DownloadData(phonyURL);
  }
  
catch(System.Net.WebException)
  {
   Console.WriteLine("ASP.NET worker process restarted.");
  }
  
catch(Exception ex)
  {
   Console.WriteLine(ex.ToString());
  }
 }
}

1Caveat: Killing a process is a bit more risky than restarting the application by touching web.config, since it prevents ASP.NET from shutting down gracefully. If you've got non-transactional work going on (a really bad idea), you could theoretically leave things in a bad state. Any decent database system  shouldn't have any problems - I'm talking about code which edits text file, etc. I've never had a problem with this, and I've been merciless to aspnet_wp for the past 3 years, but this is primarily something I use in my dev and stage environments. If your site can't handle a loss of power, you just might want to fix that...

I considered a phony edit to machine.config, which would have the same effect as editing all web.config files on the system, but I feel like that's higher risk than just killing ASP.NET worker process, since messing up machine.config will bring the server down until you fix it.

Of course, none of this is required with VS 2005 projects running under Cassini.

UPDATE:  For another reason to avoid  IISRESET, see Ken Robertson's post:  IISReset corrupting the IIS metabase
Posted by Jon Galloway | 41 comment(s)
Filed under:

The easiest way to see your site in IE7 and Safari

                

Like many web developers before me, I've become a conscripted webservant in my wife's quest to launch a website - Rachel's setting up a store for high end children's clothing. She's got an incredible eye for design, which makes her one of the toughest clients I've had.

When her sister viewed the site in Safari the links all appeared red. Strange, as the CSS bade it otherwise (hello, LoVe / HAte rule). Well, iCapture came to the rescue. I didn't have to sidle up to the genius bar with a wad of cash; I just entered the URL and saw a screenshot. Be sure to chop the http:// off your URL - the site chokes on that, and it's also got an address length limit that caused problems deep into my DotNetNuke site. Still, a nice way to spot check Safari rendering on the cheap.

And while you're at it, check out ieCapture - the easiest way to see how your site will render in IE7. I suggested this kind of thing to the IE team at Mix06 and haven't heard anything since, but Dan Vine's got us covered.

 

 

Make MS codenames cool again: WinCom, WinPrez, WinFlow

A letter read on this week's DotNetRocks (Kimberly Tripp on SQL Server) reiterated the common complaint that our cool codenames have been replaced with exquisitely boring names. I agree - Windows Communication Foundation sounds like an ailment, and WCF sounds like a part number.

Well, William Randlett has the solution - we can at least pronounce come up with cooler pronunciations:
WCF = WinCom
WPF = WinPrez
WF = WinFlow

I'm with William. Join us! Let's make these new technologies cool again with unsanctioned badboy nicknames!

Posted by Jon Galloway | 3 comment(s)
Filed under: ,
More Posts