Deleting the Cruft in Windows 2000

Windows tends to store a ton of temporary files that, over time, tend to fill up your hard drive.

There
are a number of places to look for these files and a couple of things
you can do to periodically purge your system of files you don’t need.

First, right-click on your C drive and select "Properties".  Then click on the "Disk Cleanup" button on the main tab.

You can also look in C:\Documents and Settings\Administrator\Local Settings\Temp

And look for bloated temp folders in here.

Search and Replace for a New Line Character in VI

For all of you out there who use vi on a regular basis . . . I recently needed to do a search and replace on a large document and needed to key off of the new line characters in the document.

After a bit of searching here’s what I found:

If you need to do something like, search for all new lines and add the new line plus "foo" do the following:

:1,%s/\n/^Mfoo/g

You get the ^M character by pressing ctrl-v and then hitting enter.

Embedding Flash with Valid Markup

Anyone who has tried to W3C validate a page with the default output from Flash knows you get a slew of errors.

Here’s a great article on modifying your <object> and <embed> tags so that your pages will validate.

Flash Satay: Embedding Flash While Supporting Standards by Drew McLellan

Here’s a quick example that you can run with that includes the markup for a transparent background:

<object type="application/x-shockwave-flash" width="368" height="201" data="icms_art/nbir5.hdr.anim.swf">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="icms_art/nbir5.hdr.anim.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
</object>

Mounting Logical Volumes Under Linux

Let’s say you have a disk that you want to put in an external USB enclosure, mount and read some files.  What if it’s a boot disk that uses LVM?  What if you have two LVM groups with the same name?

Here’s a quick how-to on mounting just this type of LVM volumes from a USB disk.

When you first attach your disk in it’s USB enclosure you should be able to see which device it is associated with by looking at /var/log/messages.  In my case, it was assigned to /dev/sdc

When you run an fdisk command on the drive you’ll get something like:

Disk /dev/sdc: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xd0f4738c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          13      104391   83  Linux
/dev/sdc2              14        9726    78019672+  8e  Linux LVM

The problem is a bit more complicated when both your existing OS and the disk that you want to mount have the same name for their logical volume.

Do a pvscan and you’ll be able to see the names of the logical volumes on the two disks.

# pvscan
  PV /dev/sdc2   VG VolGroup00   lvm2 [74.38 GB / 0    free]
  PV /dev/sda2   VG VolGroup00   lvm2 [74.31 GB / 32.00 MB free]

In this case, you will need to rename the volume group on the disk that you want to mount via the USB enclosure.  You’ll need to do one of two things:

  • Shutdown your existing computer, disconnect the drives from it, attach the erstwhile USB mounted disk and fire it up with some sort of boot/rescue CD
  • Put the disk in another box, and fire up with the aforementioned boot/rescue CD

I had an extra chassis lying around that I could use so instead of mucking around in my machine, I just used it.  I also used the Fedora Core 8 installation DVD, but you should be able to use any type of Linux rescue disk that contains the lvm binaries.

So once you’ve got your hardware all set up, boot using the rescue disk.  In this case, using the FC 8 install disk, when you get to the prompt where it asks if you want to search for and mount an exsiting partition/installation, select "Skip".

You’ll now be on the command line.  Keep in mind that in rescue mode, all lvm commands need to be preceded with "lvm".

Do a search/scan for your logical volumes with one of the following commands:

# lvm vgscan
# lvm lvscan
# lvm pvscan

# vgscan
Reading all physical volumes.  This may take a while…
Found volume group "VolGroup00" using metadata type lvm2

Then rename your volume group:

# lvm vgrename VolGroup00 VolGroup01

You could name it anything that you want, that’s just what I happened to use.

Shutdown your machine and put the newly renamed volume group disk back in it’s USB enclosure, attach to your computer and fire it up.

A vgscan should display the following:

# vgscan
Reading all physical volumes.  This may take a while…
Found volume group "VolGroup01" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2

Activate the volume:

# vgchange -a y /dev/VolGroup01
  2 logical volume(s) in volume group "VolGroup01" now active

Mount the volume group

# mount /dev/mapper/VolGroup01-LogVol00 /mnt

Done!

You may or may not have to include the "mapper/" entry in the path, check with your distro to see how it deals with paths to volume groups.  All I had to do was "tab" once I typed /dev/mapper/VolGroup01 and it scrolled through the available logical volumes in the group.

A Changing Political Lanscape Requires a Different Tune

Well, since Edwards has dropped out of the race and now it’s between Obama and Clinton, I’m changing my tune.

Obama is our best bet for a win, as a result I’m supporting him as the nominee.

Why? Hillary can’t win a general election and here are what I think are the reasons why:

  • There are many people who will cast a vote against her vs. for McCain
  • If she is the nominee it will galvanize the Republicans behind McCain and will bring them together. Our best bet is to keep them fractured and complaining about McCain not being a real conservative. Hillary on the ticket will cause the folks who would otherwise stay home to run, not walk, to the polls to vote for McCain
  • She won’t get a single Republican vote and will get very few Independents
  • She doesn’t energize the youth vote like Obama. Obama will turn out the 18-25 like never before
  • She can’t say that she was against the war to begin with

So, unless you want to help put McCain in the White House and have four more years of a pseudo Bush administration, I would strongly suggest voting for Obama in the primaries.

I would much rather have a Democrat in the oval office when the next Supreme Court Justice retires.

“Under Construction” means “I’ll never get to it”

When people see a website with an “Under Construction” or similar message it typically translates to “This site will never be updated, don’t bother coming back”.

A much better approach is to publish whatever content you have, and add to it later.
There are two main reasons why the “Under Construction” message has turned into the kiss of death for a website:

  • It’s so over used
  • and in many cases that message will sit on a website for years before anyone gets around to updating that page

You are much better off having a single page with a paragraph about your business with a contact form and phone number than having a bunch of empty pages with “Under Construction” messages on them.

There is no good reason to advertise what you haven’t yet done on your site, so just add those pages later.

One of the things that will make it more likely that you’ll actually add those pages is using a content management system or focusing on writing the content and then handing it off to a web developer to make the updates for you.

Remember, there is nothing wrong with having a one page website as long as it tells visitors something about you, what you can do for them, and gives them an easy way to get in touch with you.

Your website is (and should be) an ever evolving resource for your prospects and clients, so don’t stress about it being “finished” or “perfect”.  It’s better to go with what you have, than advertise to people what they are missing.

— Ryan Chapin

Kerry’s Trying to Screw Things Up . . . Again

Dear Mr. Kerry,

It wasn’t bad enough that you choked on defending yourself from Bush’s swift-boating and your huge gaff just before the ’06 election, now you are supporting Obama?

Dude, please, for the good of the country, just go home and keep your mouth shut.

The Democrats best bet for a win in ’08 is Edwards and you seem to have turned your back on him.

Hopefully, your reputation will help pull Obama out of the top tier and let Edwards go on to a nomination.

More proof positive that you have no clue what you doing.

A Quick How-To on Installing IIS and .NET under Windows XP Pro

I’ve got a client that needs a site with a simple navigational program to be hosted under IIS with ASP.NET.

So, I put together IIS on a VMWare XP install and here’s the quick how-to:
1. Go to Add/Remove programs
2. Put the WinXP Pro install CD in the machine.
3. Click on Add/Remove Windows Components and click on the check box next to Internet Information Services (IIS)
4. After installation you should be able to open up a browser and type "localhost" and get the default welcome page.
5. If you get either a You are not authorized to view this page" or a user name and password prompt, make sure that the user account with which you are currently logged in has administrator rights and that you have a password set for that account.
6. Install .NET
7. Register .NET with IIS

Open a CMD window, change dir to
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727(or whatever other version you are registering)

Run the following commands in sequence:
aspnet_regiis -i
aspnet_regiis -s W3SVC/
8. Make sure to include the .aspx extension on your files and you should be all set to start developing .NET applications.

Dynamically Instantiating New Objects in ActionScript 3.0

Let’s say you are building an application and want to be able to dynamically instantiate new objects in AS 3.0 (Flash CS3)?

Read on for the answer . . .

The syntax for doing this has drastically changed from AS 2.0, however there is still one gotcha that remains the same.

In my case, I’m not only dynamically instantiating class names, but also their reference names.

Here’s how I figured out how to do it:

// Import the getDefinitionByName util and your class
import flash.utils.getDefinitionByName;
import com.example:ExampleClass;

// Create a variable to store a reference to your new class
var classReference:ExampleClass;

// Create a class object and use getDefinitionByName to specify the name of the class you are instantiating.
var class_tempClass:Class = Class(getDefinitionByName("com.example:ExampleClass"));
classReference = new class_tempClass();

This works great.  However, what if you don’t know what classes you’ll be instantiating and want to be able to leave that open at runtime?  This is where it’s the same in 2.0.  If you don’t include the reference to the class at compile time (var classReference:ExampleClass; ) you cannot dynamically instantiate this class, regardless of whether or not it is in your class path.

As a result, you are left with having to decide which classes you might want to instantiate at runtime and somewhere in your code, include a reference to each class such that it’s included at compile time.

Another AS 3.0 programmer indicated that it might be possible to dynamically load a swf that includes a reference to that class, but you would have to load and make sure that that swf has initialized before attempting to instantiate the object.

Maybe a way to go about it is to keep a library of swf files that have the same name as the class that you want to instantiate and write a utility that will dynamically instantiate objects.  The first thing it would do is load a swf with a reference to the class, then it would instantiate the object, returning to the calling code a reference to the newly created instance.

I think I’ll give that a try and then post and update to this thread with my findings.