Sunday, February 23, 2014

Asus Vivobook X202E DH31T: Quick review

I mostly love my Asus Vivobook X202E DH31t.  It's almost an ultrabook, for a netbook price.  There are just a few things that bother me about it.  Perhaps I can fix some of them...

Friday, December 13, 2013

1&1.com Fail

Today we have a consumer alert for 1&1.com - domain registrar and site host. Lots of people complain about their service, and now I know why.

A domain of mine expired on 11/30/2013. Okay, my bad.

HOLY COW! Within 5 business days, it was cancelled and sent to auction, my 1&1.com account was deleted, and the issue was sent to their collections agency - all without a single attempt to notify me via phone, e-mail, or letter. Called and paid the collections agency plus an extra $12 fee. Collections agency said they would notify 1&1 immediately. Days later, no status update from 1&1. Called billing department, the person who answered had no idea what was going on and said I just have to keep waiting. My site has been down for 13 days now and I have no estimate as to when this is going to get fixed. The first thing I will do if I ever get my domain back is transfer it to Godaddy. Thanks 1&1!

And I used to complain because Godaddy sends out a half-dozen e-mails reminding me about products that are expiring.

Saturday, November 02, 2013

Perl script for comparing files: List missing lines, regardless of order

The other day, I was comparing two different sitemap files of the same site. One had more links than the other, and I was trying to get a list of what was missing from the shorter one. However, since they were from different sitemap generators, the order of the links were completely different in each file.

Surprisingly, this turned out to be a much bigger challenge than I thought. I figured I could use some variation of a grep command line, or diff, but I wasn't able to find a simple combination of command line options for either that would do what I was looking for. It seems like everything I found was more geared toward comparing files that were in the same order. Diff simply dumped a large list of all the lines in file2; since the order was different than file1, every line was considered a mismatch.

Knowing this was a fairly trivial operation to do in Perl, I decide to write a quick script to do it. I'm sharing it here in case it can benefit anyone else:

#!/usr/bin/perl

# The purpose of this script is to print the lines in file2 that are not present in file1, regardless of order.

unless ($#ARGV>=1) {die "Usage: different-lines.pl [file1.txt] [file2.txt]";}

open (FILE1,$ARGV[0]) || die "Unable to open $ARGV[0]: $!\n";
open (FILE2,$ARGV[1]) || die "Unable to open $ARGV[1]: $!\n";

# Store the contents of file1 in array
while (<FILE1>) {push (@lines_one,$_);}

close FILE1;

# Iterate through each line of file2, checking for presence in file1, and setting a flag if it's found.
while (<FILE2>) {
        $flag=0;
        foreach $line (@lines_one) {
                $line=~s/\s+$//g;
                s/\s+$//g;

                if ($line =~ /$_/) {$flag=1; last;}
        }
        unless ($flag) {push (@missing_from_1, $_);}
}

close FILE2;

# Dump the results (missing lines)
foreach $line (@missing_from_1) {
        print $line."\n";
}