HP dm1z (with AMD E-350 APU) Unboxing

Here’s a bit of gadget pr0n. I just received my new computer, an HP Pavilion dm1, which sports the new AMD E-350 Fusion APU (combining a CPU and GPU on the same die) and a design refresh. Once I put it through the paces I plan on posting a review of sorts. For now, here’s the unboxing:

Loop the (WordPress) Loop

Somewhat recently, a client asked to create a way for visitors to submit content and rank said content for a site he was creating, much like the sites found on the cheezburger.com network. The site is powered by WordPress, so I installed and configured TDO Mini Forms for visitors to submit stuff, and GD Star Rating for the rating system. The site would have the posts in chronological order on a page, and the front page would have content ordered by ranking.

In the end, the front page simply displays content by ranking, which is easily accomplished with a page template and query_posts() with the GD Star Rating plugin’s parameters. My first attempt was over-engineered a bit for the client’s liking and was scrapped for the former option, but I thought it was a rather clever way of displaying posts – placing the WordPress loop within a loop.

I realize this has been done before, but here’s my twist on it:

<?php if (have_posts()) :
$daysBack = '0';
while ( $daysBack >= -7 ) :
$dateRange = getdate(strtotime($daysBack . "days"));
query_posts('year=' .$dateRange["year"] .'&monthnum=' .$dateRange["mon"] .'&day=' .$dateRange["mday"] .'&gdsr_sort=thumbs&gdsr_order=desc&showposts=1' );
<?php while ( have_posts() ) : the_post(); ?>
Do loop stuff...
<?php endwhile; // End the loop. Whew. ?>
<?php $daysBack--; ?>
<?php endwhile; ?>

Basically what this does is takes a look back through the last 7 days worth of posts, selects the highest-rated from each day, and displays them. Neat, huh?

So you may ask, “what if the site becomes derelict or just doesn’t get new content after a while…what then smart guy? The page won’t display any posts!” Sheesh, lay off! I already thought of this:

<?php rewind_posts(); ?>
<?php query_posts('orderby=rand&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
Do loop stuff again!
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>

Further down on the page, we display a random post. Now the front page will display at least one post, and at most 8 posts. Oh snap!

Of course, this isn’t a fully complete solution. We should modify the second loop so that it does not display a post already displayed above, to avoid duplicating content. Even though this is incomplete and was scrapped in favor of just showing posts by rank and completely ignoring chronology, I thought it was a neat solution and thought I would share for anyone who may be interested.

Upgrading a RAID1 array with Parted Magic

Over this past weekend, I was tasked with upgrading disk space on one of our servers, a Dell PowerEdge 860. It has SAS 5/iR, originally with 2 160GB SATA disks mirrored. The data partition was down to only a couple GB, so it was in bad need of an upgrade. A little over a year ago, I performed a similar upgrade on a Dell Precision 390 – that had 2 750GB disks mirrored which was upgraded to 1.5TB array. To conserve resources, I used the 750GB disks to upgrade the array on the PowerEdge, along with a copy of Parted Magic, an open-source partitioning tool.

In brief, here’s the steps I took to perform the upgrade:

  1. Perform a full backup and defragment the drive. This process could potentially hose all the data on the disks, so a backup is a must. This server is running Win 2k3, and NTFS partitions are happier being resized after being defragmented.
  2. Power down the server and remove the original disks – be sure to mark them, preferably taking note of the primary disk of the array.
  3. Install the new disks, boot into the controller bios and build the new array.
  4. Power down the machine again. Remove the secondary disk of the new array (mark it!) and install the primary disk of the old array on another channel. The PowerEdge had on-board SATA channels, so I hooked it up there.
  5. Boot into Parted Magic. I used a CD, but there are USB drive and PXE options.
  6. Start up G4L. Do a raw copy, and select your source and destination disks. The disks are listed in standard *nix nomenclature (e.g. /dev/sda) with the size in bytes. Start the clone process. This can take some time. In this case, it took about 1hr 15mins to clone the disk. When I did this earlier on the Precision workstation, it took about 12hrs.
  7. Shut down, remove the primary from the original array and restart, just to be sure everything works.
  8. Shut down again and reboot into Parted Magic. Run Gparted to resize the partition.
  9. Reboot. After resizing, Gparted marked the partition as dirty, so chkdsk will run to make sure nothing’s broken.
  10. If everything looks good, shut down one more time to install the secondary disk of the new array. Reboot and enjoy the added space.

After this process, the array will be degraded, and consequently the machine may be sluggish until the disks sync. Performing this upgrade on the PowerEdge 860 took about 3hrs from start to finish, which was much better than the 15hrs that it took for the Precision 390 a year ago. In the latter case, a 750GB disk was being cloned, with much of the time consumed with the cloning process. This process should work with just about any RAID1 configuration, though YMMV.