From time to time, I want to copy just the minimum files for a VMware virtual machine: the two .vmdk files and the .vmx file. After moving those files to a new location or deleting a snapshot file, attempting to boot the virtual machine returns the following error message:

Cannot open the disk ‘XXXXXX.vmdk’ or one of the snapshot disks it depends on.
Reason: The system cannot find the file specified.

I’ve found that following the steps below fixes the problem and allows me to boot the virtual machine as it existed at the time of creation. DO NOT USE these steps if you need to retain any changes to the machine:

Open the *.vmx file in a text editor and find the line that refers to the old snapshot file, which will look something like:
scsi0:0.fileName = “XXXXXX-000002.vmdk”
or
ide0:0.fileName = “XXXXXX-000002.vmdk”

Change the value to the filename of the ~1kb .vmdk file (which happens to be the same as the name of the VM). For example, if your virtual machine was named “Windows XP Professional”, the line would read:

scsi0:0.fileName = “Windows XP Professional.vmdk”

Power on the VM. It should boot normally, but because the snapshot file is missing, the machine will boot to an earlier state.

For a new project, I needed to combine two or more associative arrays and sum the values of any keys that exist in common. I was a little surprised to find that there wasn’t a built-in function to do this in PHP. So I wrote my own. It can accept any number of arrays as arguments, and goes through each array one key at a time, comparing the keys to those in an output array. Where the keys match, the values are summed. If the key does not exist in the output array, it’s appended to it.

The function returns an array that contains all of the unique keys in the input arrays.

If anyone has any ideas about how to optimize this, please post a comment. One thought would be to use the first array as the output array, avoiding the key-by-key comparison of the first array against an empty array.

function array_mesh() {
	// Combine multiple associative arrays and sum the values for any common keys
	// The function can accept any number of arrays as arguments
	// The values must be numeric or the summed value will be 0
	
	// Get the number of arguments being passed
	$numargs = func_num_args();
	
	// Save the arguments to an array
	$arg_list = func_get_args();
	
	// Create an array to hold the combined data
	$out = array();

	// Loop through each of the arguments
	for ($i = 0; $i < $numargs; $i++) {
		$in = $arg_list[$i]; // This will be equal to each array passed as an argument

		// Loop through each of the arrays passed as arguments
		foreach($in as $key => $value) {
			// If the same key exists in the $out array
			if(array_key_exists($key, $out)) {
				// Sum the values of the common key
				$sum = $in[$key] + $out[$key];
				// Add the key => value pair to array $out
				$out[$key] = $sum;
			}else{
				// Add to $out any key => value pairs in the $in array that did not have a match in $out
				$out[$key] = $in[$key];
			}
		}
	}
	
	return $out;
}

If you want to test it out, here’s some additional code.

$a = array('abc' => '100.000', 'def' => '50', 'ghi' => '25', 'xyz' => '10');
$b = array('abc' => '100.333', 'def' => '75', 'ghi' => '50', 'jkl' => '25');
$c = array('abc' => '100.111', 'def' => '75', 'ghi' => '50', 'uvw' => '5');

echo "<pre>";
print_r(array_mesh($a, $b, $c));
echo "</pre>";

I hope you find it helpful.

I’ve been using Dreamweaver for years. One thing that has always bothered me is that it wants to change my lowercase JavaScript event attributes to camelCase, but it only does this after I close the file. So when I wrote the code, it was valid XHTML 1.0 Strict, but after I saved the file, it no longer was. Dreamweaver was messing up my validation and it was making me furious.

So, if I have typed

<body onload="init()">

Once I’ve closed the file, it’s changed to

<body onLoad="init()">

It will do this for all the tags: onload, onblur, onfocus, etc…

I’ve tried setting my default document type, the validation fallback, everything I could find to XHTML 1.0 Strict, which requires lowercase attributes, but Dreamweaver isn’t smart enough to realize that I mean for this to apply to all of my files, even .php includes.

Finally, I’d had enough and started looking for a solution. I found two different ways of getting this done.

First method: click on Edit -> Preferences -> Code Format. Change “Default tag case” to lowercase, “Default attribute case” to lowercase=’value’, and in “Override case of”, place checkmarks next to Tags and Attributes.

You can also modify each of these attributes in the Tag Library Editor.

Second method: click on Edit -> Preferences -> Code Hints, and under the Menus area, click on the Tag Library Editor link.

A Tag Library Editor window will open. If you wanted to change the body’s onload attribute, for example, you would expand the HTML folder, then the body folder. Highlight onLoad and in the “Attribute case:” menu, select Lowercase, then click “Set default”.

At long last, valid XHTML code from Dreamweaver, even if I shouldn’t be using body onload and inline event handlers in the first place.

For some time, I’ve felt that Ardamis.com was being pulled in two directions. It started out as something of a business card, then it landed me a job, and so the focus changed and it became more of a personal blog. A few years later, I found myself posting mainly code snippets from personal projects and announcements of new site launches.

So, I’ve determined that I’ll keep Ardamis.com as a place for experimentation and create a new site to handle the web development business – Aleph Studios. It’s so new that I have to think sometimes about how Aleph is spelled as I type it.

I’ll be migrating some of the pages away from Ardamis over the next week or two.

Just so there’s no confusion, Chromium is an open source web browser project. Google Chrome is a web browser from Google, based on the Chromium project. If you are familiar with Google Chrome in Windows, the Chromium browser looks very similar, but lacks the Google branding. Right now, there is no Google Chrome for Linux.

Here’s how I installed Chromium on Fedora 11.

Download the latest Chromium and v8 files for your OS (32 or 64 bit) from http://spot.fedorapeople.org/chromium/F11/ Save them to ~/Download or whatever location is convenient for you.

At the time of this post, these two files were
“chromium-4.0.204.0-0.1.20090827svn24640.fc11.x86_64.rpm” and
“v8-1.3.8-1.20090827svn2777.fc11.x86_64.rpm”, but they are certain to change frequently.

Open up a terminal window (Applications > System Tools > Terminal). You will probably need to switch to root for the entire installation process. To do this, type:

su

First, install two dependencies:

yum install minizip

minizip manipulates files from a .zip archive.

yum install nss-mdns

nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) providing host name resolution via Multicast DNS (aka Zeroconf, aka Apple Rendezvous, aka Apple Bonjour), effectively allowing name resolution by common Unix/Linux programs in the ad-hoc mDNS domain .local. nss-mdns provides client functionality only, which means that you have to run a mDNS responder daemon separately from nss-mdns if you want to register the local host name via mDNS (e.g. Avahi).

Once those installs are complete, stay in the terminal window, navigate to the folder containing the Chromium and v8 downloads and then type:

rpm -ivh v8* chromium*

This will run the installer on the two downloads. If you see any other dependencies, just handle them as they come.

That’s it, you should see Chromium Web Browser under Applications > Internet.

Installing Chromium via YUM

If you want to install Chromium via YUM, you just need to add a new repository file to the /etc/yum.repos.d directory. I’m partial to gedit, so I’ll use that editor in the instructions.

Open a terminal and type:

sudo bash

This will give you root privileges for launching gedit (and other GUI apps). Launch gedit by typing:

gedit

Copy and paste the following lines into the new document:

[chromium]
name=Chromium Test Packages
baseurl=http://spot.fedorapeople.org/chromium/F11/
enabled=1 
gpgcheck=0

Save the file as chromium.repo to /etc/yum.repos.d/. (If you are running Fedora 10, change the F11 to F10 in the baseurl path.)

Back in the terminal window, type:

yum update

YUM will pick up the new chromium file. You’re now ready to install Chromium with the line:

yum install chromium

Update 2/22/2010: It looks like changing .htaccess is no longer necessary. After you select PHP 5.x, your site will begin using version 5.2.5 without any further configuration.

The following applies to older domains. As of early 2009, newly purchased linux hosting plans are running PHP 5.2.8, while older plans, once updated, only go up to PHP 5.2.5. I’ve had Ardamis.com hosted at GoDaddy since 2005, and quite awhile ago I thought I had upgraded to PHP version 5 from 4.3.11, but tonight I happened to check with phpinfo and found I was still on version 4.

In the unheard of ten minutes that I was on hold waiting for technical support, I figured out how to really run my pages on PHP 5.x (in this case, 5.2.5).

Log in and go to your Hosting Control Center. You must be running Hosting Configuration 2.0 to go any further, so if you haven’t touched your domain in years, do that first.

Click on Content, then Add-On Languages. Next to PHP Version, select PHP 5.x and click Continue. You’ll get a message that “Changing to PHP 5.x may make your PHP files run incorrectly.” Highly unlikely these days, but OK, you’ve been warned. Notice, too that it says “PHP 5.x will be activated“. Click Update.

It may take awhile for this change to be processed by the server, but once your Account Summary is displaying PHP Version: 5.x, it’s time for the really important part.

You see, you’ve only made PHP 5.x available at this point. Your *.php files are still running in 4.x. Go ahead and check phpinfo again.

Now, you could simply edit .htaccess to change the extensions, like so:

AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

More details at http://help.godaddy.com/article/1082

But if you’re squeamish about changing .htaccess yourself, there’s another way to set 5.x to be the default handler for *.php files. All the following does, strangely enough, is to add the AddHandler x-httpd-php5 .php to the beginning of your .htaccess file.

Back in the Hosting Control Center, click on Settings, then File Extension. If the change to 5.x has been completed, you’ll see at the bottom of the available extensions list, “Extension -> .php | Runs Under -> PHP 5.x” If it’s not there, stop here and come back in an hour or so.

Click on Custom Extensions at the left. This should be empty, with a message stating “No custom extensions have been created.”

Click on Default Extensions and then click on the Edit button (it looks like a piece of paper and a pencil) to the right of .php | PHP 5.x. Click on Continue.

Click again on the Custom Extensions button on the left, and you should now see “Extension -> .php | Runs Under -> PHP 5.x”. Check your phpinfo page one more time, and it should report PHP 5.x.

It’s unfortunate we even have to do this for our older domains, but I asked the tech support guy if I could somehow get on to PHP 5.2.8, and he said nope, that the newer servers have the more recent version but the older servers are stuck back in 2007.

A friend who does a lot of selling on eBay asked me to develop a web application for generating HTML templates that could be copied and pasted into his auctions. He wanted to be able to add a title, a description, and some terms and conditions, and also to be able to upload images so the auction template would display thumbnails that could be clicked to display full-sized versions in a new window or tab. The more we talked, the more it sounded like something that would be both useful for a good number of people, and potentially a source of ad revenue for us. And so was born Simple Auction Wizard, an online HTML template generator for auction websites like eBay.

I was looking for just this kind of a project because I wanted a reason to play with TinyMCE, an Open Source, platform independent, web-based JavaScript HTML WYSIWYG editor control, and SWFUpload, a small JavaScript/Flash library that does very neat things with file uploads.

The most difficult part was actually getting the templates to look good in a variety of browsers. Because the template HTML appears inside of a larger page, I couldn’t rely on Doctype switching to place IE into standards mode. This meant the templates would have to be developed so that they would look approximately the same in standards-compliant browsers like Firefox, Chrome, and Safari, as well as horrible browsers like IE6 in quirks-mode. I tried very hard to minimize the use of tables, but they eventually crept in. I was able to use CSS, for the most part, though if any more issues come up, I’m going to throw in the towel and just do inline styles.

The web app is open to the public, but realize that it’s very early in its development and I intend to continue making changes.

We’ve outgrown our two-bedroom condo in the incomparable Oak Park and have put it up for sale.

200 N. Kenilworth Ave. Apt. 2, Oak Park, Illinois, 60302 - Exterior

200 N. Kenilworth Ave. Apt. 2, Oak Park, Illinois

200 N. Kenilworth Ave. #2 is a sunny, vintage two bedroom end unit nestled among churches, trees and million-dollar homes. At over 1200 square feet, this condo has lots of flexible living space, including an over-sized dining room and an enormous living room that could be easily split to add an office or den. The bathroom has been tastfully remodeled with subway tiles, a pedestal sink, and water-saving dual-flush toilet. The kitchen has a new stove and is full of charm with a vintage porcelain sink and a huge walk-in pantry. All of the plumbing and much of the electric in the unit was replaced in ‘08. There is Benjamin Moore zero- and low-VOC paint throughtout the unit and all of the windows have newer triple track storms. Other details include refinished hardwood floors, 9 foot ceilings, original ‘wavy’ glass windows, and solid wood doors with original hardware.

200 N. Kenilworth Ave. Apt. 2, Oak Park, Illinois, 60302 - Living Room

200 N. Kenilworth Ave. Apt. 2, Oak Park, Illinois

This condo is surrounded by trees and overlooks a church, providing a quiet and relaxing perch in an ideal “walk-to-everything” location. Green line and Metra trains, state-of-the-art library, Whole Foods and Trader Joes, boutiques and cafes, and restaurants serving every cuisine are mere steps away. You can enjoy live music and art fairs in Scoville Park, theatre performances in Austin Gardens, and all that downtown Oak Park has to offer. The location is also a convenient commute to local universities (Concordia, Dominican, Loop and medical campus) and walking distance to Holmes Elementary, Gwendolyn Brooks Middle School, and OPRF High School. The unit is only one block from a quaint bed and breakfast and two blocks from a hotel, which is perfect when friends and family visit.

This is not a short sale. We need to relocate and have priced the condo below market. The building is FHA-approved and pet-friendly up to 25 lbs. Association fees ($350) include heat and cooking gas, water, scavenger, common insurance, exterior maintenance, lawn care, and snow removal. 2008 taxes were $5005.


Walk Score mapThe condo gets a Walk Score rating of 97/100. Only 1% of Oak Park residents have a higher Walk Score. The Oak Park Public Library is a block away, as is Unity Temple. The Green Line is about three blocks away (~20 minutes to Clark and Lake) and the Oak Park Metra stop is about four blocks away. There is a Trader Joe’s three blocks away and a Whole Foods just on the other side of Harlem Avenue. Of course, there are all the downtown Oak Park shops (lots of boutiques and book stores, as well as Gap, Old Navy, Ann Taylor, Borders, etc.) and restaurants, too. And there are three Starbucks and two Caribou Coffees within a quarter-mile. Basically, you can walk to anything you might need.


You can find even more pictures and information about the unit and the Historic Manor building on Trulia, Redfin and in the Postlet.

I completely hosed a few SanDisk Cruzer Micro USB 2.0 2 GB Flash Drives at work when I deleted the original contents of the drives, installed the CruzerPro software that had shipped with some older Cruzer Professional drives, and then used the CruzerPro application to password protect the drives. This process rendered the drives completely unusable and unable to be formatted.

The problems

Clicking the drive letter in Windows Explorer returns the following error message:

Please insert a disk into drive X:.

Attempting to format the drive returns the warning:

There is no disk in drive X.
Insert a disk, and then try again.

This is what the drives looked like once I’d thoroughly broken them.

SanDisk U3 Cruzer Micro USB Device Properties

SanDisk U3 Cruzer Micro USB Device Properties

The drive properties show:
Type: Removable Disk
File system: Unknown
Used space 0 bytes
Free space 0 bytes
Capacity 0 bytes

The Volumes tab shows:
Type: Removable
Status: No Media
Partition style: Not Applicable
Capacity: 0 MB
Unallocated space: 0 MB
Reserved space: 0 MB

Opening the Disk Management component of the Computer Management console shows that the drive is connected, but there is no unallocated space to partition or format.

Other things about the disk look normal. It shows up in the Device Manager as working correctly, without any warnings, for example.

I Googled around and found that many, many people were running into this problem where the drive starts reporting 0 bytes capacity and can not be formatted. Of the dozens of pages that I read, no one found a fix for the problem. The most common solution offered was to return the drive to the manufacturer for replacement. Well, I wasn’t going to publicize my mistake and return the drives, I was going to repair them.

Software that didn’t help

Feel free to skip this part if you’re not interested in reading about the many dead-ends I explored.

I knew of one nifty program that had helped me out a few times before, so I tried running the HP USB Disk Storage Format Tool v2.1.8, but attempting to format the drive with this utility returned the following error message:

There is no media in the specified device.

Someone suggested using this thing called “Apacer Repair v2.9.1.1″ to reformat the drive, so I tried that, but the software only reported “USB Flash Disk not found!” when I ran it.

Someone else recommended FreeCommander, but that failed to open the drive, too.

I tried the free trial of the utility from http://www.flashmemorytoolkit.com/, but it reported the same information as Windows XP – that the device contained a disk with 0 bytes capacity. Maybe the full version could have done more, but I put that on the back burner.

A number of people suggested attacking it with partitioning software, which I wasn’t looking forward to doing, but was willing to try.

Another last resort was going to be using the Windows XP Recovery Console’s fixboot and fixmbr commands, which got me out of a pinch when I screwed up a partition.

What I should have tried to begin with

Then I had an idea. I had a clean drive that had escaped my earlier bungling. I plugged it in, copied the contents to my desktop and tried to run the U3 LaunchPad software. Nothing happened, so I started looking more closely at the files. One of the files was called SanDiskFormatExtension.dll, which sounded promising. Now I just needed to figure out how to run the SanDisk installer to reformat the drive. I tried all of the .exe’s and .msi’s that shipped with the drive, but nothing wanted to run from the folder on my desktop.

Just as I was running out of options, I opened the autorun.inf file and found a very interesting entry:

[Update]
URL=http://u3.sandisk.com/download/lp_installer.asp?custom=1.6.1.2&brand=PelicanBFG

The fix

So, with nothing to lose, I pasted http://u3.sandisk.com/download/lp_installer.asp?custom=1.6.1.2&brand=PelicanBFG into Internet Explorer, thinking that it would at least get me some new files that might allow me to reformat the drive. I followed a few prompts and lo, the U3 Launchpad Installer software launched and restored the drive to its factory settings of 2 GB capacity formatted as FAT. It even replaced the original U3 files, making it truly good-as-new.

I’m astonished that this information isn’t more widely available, particularly on the SanDisk support site and forums, as this 0 capacity problem seems to affect a good number of drives and there are many threads where this issue remains unresolved.

Note that the page at http://u3.sandisk.com/download/lp_installer.asp?custom=1.6.1.2&brand=PelicanBFG requires you to install an ActiveX component, so you must use Internet Explorer.

Otherwise, you can download the latest version of the U3 Launchpad Installer executable from the Sandisk KB.

Of course, if you’re not using a SanDisk drive, it’s rather unlikely that this software will fix your drive, but maybe your device’s manufacturer has something similar. There are also a number of good ideas in the comments below, so definitely read through them for more options.

If you’re trying to restore the drive’s contents or recover files, the all of the methods described on this page will format (erase) the drive and are not for you. Good luck.