Saturday, December 13, 2008

Backups, Re-installation, Free Software Checklist

I feel like a post like this is a number of years overdue for me. Especially for those of you I've done computer work for, this is basically a copy of the mental checklist I use when reformatting and reinstalling a Windows PC.

To quickly summarize, many computers can benefit from an occasional reformat and re-installation - especially if it seems to be running slow or if a computer virus or other malware is suspected. Given the complexity of much of today's malware, you can't realistically rely on your anti-virus software to catch everything, much less properly undo and repair things after an infection - no matter what the manufacturers claim. The best solution is to never get infected in the first place. Following "safe computing" practices is critical, which I'll save another post for. Even without an infection, reinstalling from the operating system-up can help by getting the latest features and other updates for all your software.

This is primarily meant as a list of items to consider and be aware of, and is not meant to be a complete step-by-step guide. Things will vary by your computer, desired software, and your needs. If you're not confident in what you're doing, get some assistance. If you don't already know someone who can help, ask around - word-of-mouth references are the best. A local computer repair shop is the next best-bet. I personally do not recommend Best Buy's Geek Squad or other similar services by other large, chain retailers. For anyone in the area of my previous home in Green Lake, WI, I'd recommend Badgerland Computer Systems. In Eau Claire, WI, I'd recommend RAM Technologies.

Backing Up

The first, and most important step is ensuring you have a proper, up-to-date backup of anything you want to save. Typically, you only need to worry about data, or files that are user-created. Programs can be reinstalled from CD/DVD or downloaded online. Backing up everything in the "Documents and Settings" folder is a good starting point, which is usually "C:\Documents and Settings", or "C:\Users" under Windows Vista.

Be aware some of these files will usually be in use, especially for the current user, and can't simply be copied while in-use. Use one of the following options:

  • Boot from a Live CD, such as Ubuntu's LiveCD or BartPE (direct).
  • Remove the hard drive, connect it to another computer, and use that computer's operating system to copy the files. (Don't simply boot the hard drive on another computer's hardware.) A Disk enclosure or other adapter may be helpful / required for this. Sunbeam's SATA IDE to USB Adapter has worked well for me, and can be purchased from Newegg and elsewhere for only about $20.
  • Use backup software that supports Shadow Copy, which includes Microsoft's NTBackup and Vista's Windows Backup applications.
  • As a last resort, backup using a secondary user account. Logging-out the first user doesn't always sufficiently close all open files, particularly ntuser.dat, so rebooting before logging in as the second user is recommended.

Writable DVDs are cheap and usually work well. Just be aware that they are quite fragile. USB flash drives and external hard drives can also be used. I've often considered trying Iomega's REV Drive (Wikipedia). Regardless of the media, consider and choose a backup rotation scheme. Especially, consider if something were to happen while a back-up was in progress - is there a previous and suitable backup available? Keeping one or more recent off-site copies is also a necessity.

Review other considerations and concepts at Wikipedia's Backup article.

Re-installation

1) Verify that you have a proper backup (above), re-installation CD/DVDs for all your programs, and any critical drivers on a CD or other removable media for reinstalling the network drivers, etc.

2) Check for and apply any BIOS updates.

3) Reinstall the operating system.

  • Use a slipstreamed installation disk with the latest service pack and updates if possible. For Microsoft Windows XP, I recommend using RyanVM. Additional guides are readily available via a Google search: "slipstream windows xp sp3".
  • Consider partitioning the drive into separate partitions, at least one for the operating systems / programs, and one for user data. This allows for the possibility of reformatting and reinstalling the OS partition in the future without loosing user data - though this should not replace backing up.

4) Use Windows Update/Microsoft Update to install any available security and other critical updates. The process may need to be repeated until no further updates are available.

5) Install any needed device drivers and other system utilities.

6) Re-install any needed applications / programs.

7) Restore data from backup.

Free Software Checklist

Finally, make sure your computer can do everything you expect it to do by getting the necessary software. Everything below is "free" as in zero-cost. Additionally, a significant portion of this list is Free Software / Open Source, meaning that it "is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction".

Unless otherwise noted, everything here should work on Windows XP 32-bit, and both the 32-bit and 64-bit versions of Windows Vista. (I'm using the 64-bit version of Windows Vista, and have everything below installed and working.)

First are some applications that should probably be installed on any new computer, regardless of user. These are frequently required on the web and for opening common file formats, and will eliminate a near-future need to find and install the necessary program later.

  • Mozilla Firefox (web browser) [direct].
    • Especially for more technical users / developers, review my previous post of Firefox extensions.
  • Adobe: (all proprietary)
  • The latest Java Runtime Environment [direct].
    • Developers should also install the Java Development Kit (JDK).
  • Apple QuickTime (media player) [direct] (proprietary).
  • VLC media player [direct]. Plays DVDs, and just about any other media format.
  • The Xvid video codec [direct], for playing Xvid, DivX, and similarly-encoded video files.
  • The GIMP image editor [direct].
  • 7-Zip file archiver [direct].
    • While Windows provides built-in support for regular .zip files, 7-Zip provides extended options and better performance, and supports a wide variety of additional archive formats.
  • InfraRecorder CD/DVD writing (burning) software [direct].
  • OpenOffice.org office suite [direct].
  • Avast! anti-virus home edition [direct] (proprietary).
    • Alternatively, AVG Anti-Virus Free Edition (proprietary).
  • For Windows XP only, the Microsoft PowerToys for Windows XP. Particularly: Tweak UI, Image Resizer, Power Calculator, Open Command Window Here, and the Alt-Tab replacement (all proprietary).
    • In Windows Vista, the Windows XP-version of Tweak UI will not work. Look at the basic version of TweakVI instead.
    • In Windows Vista, the "Open Command Window Here" is already included. Just hold-down the shift key while right-clicking on or in a folder.
    • In Windows Vista, the "Alt-Tab replacement" is essentially built-in to Windows Aero.
  • The Sysinternals suite (proprietary). Download the "Sysinternals Suite" .zip file [direct], and extract is somewhere like "C:\Program Files\Sysinternals". Many users will never use this, but it makes many useful Windows tools available when needed. (I use Process Explorer all the time.)

Here are some more essentials for more technical users/developers:

Wednesday, December 3, 2008

Resizing the Blogger Edit Box

If you compose in Blogger at all, you may be frustrated with the relatively small size of the text area provided for writing. It defaults to only about 15 lines!

Here's a fix.

I started out by using Firebug's Inspect feature to find what I wanted to resize, and to initially tweak the size on-demand. However, this is a bit tedious, and requires further tweaking if the window is resized.

I then wrote a JavaScript Bookmarklet to automate the task. When run, it automatically resizes the Blogger edit boxes for both the "Edit Html" and "Compose" tabs to just a bit smaller than the current size of the browser window, leaving just enough margin for the scrollbars and other editor components, etc. Additionally, it also listens for window resize events, and resizes the edit boxes along with the browser window.

Here is the human-friendly source code:

// Mark A. Ziesemer, www.ziesemer.com.
javascript:(
  function(){
    // http://www.quirksmode.org./js/events_advanced.html
    var attachEvent = function(obj, evType, handler){
      if(obj.addEventListener){
        obj.addEventListener(evType, handler, true);
        return true;
      }else if(obj.attachEvent){
        return obj.attachEvent("on" + evType, handler);
      }else{
        return false;
      }
    },
    getDim = function(dim){
      // http://www.howtocreate.co.uk./tutorials/javascript/browserwindow
      return window["inner" + dim] || document.documentElement["client" + dim] || document.body["client" + dim];
    },
    getH = function(){
      return getDim("Height");
    },
    getW = function(){
      return getDim("Width");
    },
    editSize = function(dim, size){
      document.getElementById("textarea").style[dim]
        = document.getElementById("richeditorframe").style[dim]
        = size + "px";
    },
    lastH, lastW,
    resize = function(){
      var newH = getH(), newW = getW();
      // http://webbugtrack.blogspot.com./2007/10/bug-104-resize-event-firing-errors-in.html
      if(newH != lastH || newW != lastW){
        editSize("height", newH - 250);
        editSize("width", newW - 100);
        lastH = getH();
        lastW = getW();
      }
    };
    resize();
    attachEvent(window, "resize", resize);
  }
)();

This is cross-browser compatible, and was tested against Mozilla Firefox 3 and Microsoft Internet Explorer 7. Not surprisingly, it could be much shorter if it didn't need to work-around a few IE bugs, as commented above:

  1. Supporting a non-standards event registration model.
  2. Difficulties in obtaining the size of the browser window, including differences between "strict" and "quirks" modes.
  3. The resize event being called repeatedly, which usually resulted in infinite loops and hanging IE.

Here's the same code, condensed as a usable bookmarklet:

javascript:(function(){var%20attachEvent=function(obj,evType,handler){if(obj.addEventListener){obj.addEventListener(evType,handler,true);return%20true;}else%20if(obj.attachEvent){return%20obj.attachEvent('on'+evType,handler);}else{return%20false;}},getDim=function(dim){return%20window['inner'+dim]||document.documentElement['client'+dim]||document.body['client'+dim];},getH=function(){return%20getDim('Height');},getW=function(){return%20getDim('Width');},editSize=function(dim,size){document.getElementById('textarea').style[dim]=document.getElementById('richeditorframe').style[dim]=size+'px';},lastH,lastW,resize=function(){var%20newH=getH(),newW=getW();if(newH!=lastH||newW!=lastW){editSize('height',newH-250);editSize('width',newW-100);lastH=getH();lastW=getW();}};resize();attachEvent(window,'resize',resize);})();

(Bookmarklet - Either right-click and choose to bookmark, or drag to your bookmarks menu or links toolbar.)

I've not yet found a decent tool to compress JavaScript into bookmarklets. The best I've found is at http://chris.zarate.org./projects/bookmarkleter/. However, one issue it has in particular is failure to properly handle comments. While it is the tool I used to condense to the above, I manually removed the comments first and converted the double-quotes to single-quotes.

This script could easily be modified for similar functionality on other sites. Additionally, the need to initially enable the resizing by manually activating the bookmarklet could be avoided by converting this to a Greasemonkey script.

Update (2009-08-29):

Now also provided as a Greasemonkey script: http://userscripts.org/scripts/show/56651

Update (2009-01-26):

As discussed in the comments below, I'm avoiding Blogger's "updated editor" for now, due to many other unresolved issues with that editor itself. My scripts are only designed to work with the "old editor". Some details about the different editors are available from Google's Blogger Help.

If you have an issue with the bookmarklet, please post a comment here. If you have an issue with the Greasemonkey script, please report it at http://userscripts.org/scripts/issues/56651. In either case, be sure to include which browser and version is being used. Please also include any other possible factors that are visible, such as JavaScript errors or warnings in the browser.