Command Line Zip for Windows

Windows doesn't have a command line utility for compressing files (that I know of), and I had to come up with a way to automate some file transfers today. So I whipped up a tiny Perl script that will zip up a file. I figure someone else might need it. (Or someone might know how to do this in one line.) You'll need the Archive::Zip module, and the following code—which is pretty much right out of the documentation:
# Grab the incoming file
my $argv = join(' ', @ARGV) or die "Usage: zipme.pl [file location]\n";

# Grab the file name
my($dir, $file) = $argv =~ m/(.*\\)(.*)$/;

# Create a Zip file
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
my $zip = Archive::Zip->new();

# Add the file
my $file_member = $zip->addFile($argv, $file);

# Save the Zip file
unless ( $zip->writeToFileNamed($argv.'.zip') == AZ_OK ) {
    die 'couldn\'t zip';
}
Save this code as zipme.pl, and you'll be set. Pass in a filename, and you'll get a compressed file of the same name plus the .zip extension. So:

C:\>perl zipme.pl C:\path\to\giant.file

will give you C:\path\to\giant.file.zip. It works well with Windows batch files, and will save me a bunch of bandwidth.
  • Remap your Home and End keys on a Mac so they operate on the current line rather than the current document. This has been bugging me forever!
    filed under: mac, software, hacks

My Year in Cities, 2006

Kottke did it, and here I go. 2006 was an interesting year for me because it was the first time I traveled outside of North America. International travel gave me a new perspective on the US that's hard to describe. I came back both loving it more, and wanting it to be more. (But that's a topic for another post.) Anyway, here's my list of cities I visited in 2006:

Corvallis, OR (Home)
Nelson, New Zealand
Kaikoura, New Zealand
Christchurch, New Zealand
Queenstown, New Zealand
Te Anau, New Zealand
San Diego, CA
New York City, NY
New Paltz, NY
Bend, OR *
Newport, OR *
Portland, OR *
Lincoln, NE
San Francisco, CA
Sebastopol, CA

As the rules state: one or more nights spent in each place. Those cities marked with an * were visited multiple times on non-consecutive days.

I don't have any international travel planned for the foreseeable future, but I'd like to make it back to New Zealand someday.
  • Cleans up your Mac desktop (or any folder) based on rules you write. Handy! [via 43 Folders]
    filed under: mac, productivity, software
  • Leonard Richardson and Sam Ruby are writing a book about designing REST web services.
    filed under: webservices, books, programming

Google Stops Supporting Search API

The O'Reilly Radar picked up on an internal conversation I was involved with about Google's decision to stop supporting their Search API. There's more at the Radar: Google Deprecates Their SOAP Search API.

I can't help but think of the lawyerly phrase arbitrary and capricious to describe the decision because no one from Google has explained the move in a public forum. I'm sure there were some black hat SEO types using the Search API for nefarious purposes—and I'm guessing the decision to shut it down stems in part from that. (Not to mention that SOAP has fallen out of favor.) But that's like throwing the baby out with the bathwater. Why such a limited alternative? (The API has been "replaced" by the Ajax API, a very limited cousin of the Search API.) And why not move to a REST API if that's where the developer preference winds have blown? In one of my emails I mentioned that this decision reminds me of Microsoft's decision to scrap their MVP program (which was later reinstated). Why alienate future potential power users?

Also, the new Hackzine blog picked up a tip I stumbled on for grabbing an API Key while the grabbing is good: Get a Google SOAP API Key.

Update: Slashdot weighs in. For them it's all about the failure of SOAP, not a misstep by Google.

When the Lights Go Out

I'm on hour 16 without power thanks to a wind storm that blew through Oregon last night. I'm speaking to you live from my laptop, connected to my cell phone via bluetooth, using a Cingular data connection. I love living on the edge of a small town—the positives outweigh the negatives. But one of the drawbacks is that power seems to take a little longer to come back for us once it goes out, and the power even occasionally blinks on and off for no apparent reason. So I've had to do some contingency planning for situations just like these.

A couple weeks ago I talked about planning for hard drive failure, so I thought I'd talk about planning for power failure now that I'm in the middle of dealing with it.

One of the best investments I've made is an APC battery back-up (aka Uninterruptible Power Supply) for the main computers and monitors in the house. (I picked up two APC ES 650s, available at Amazon.) Basically a UPS will give you about 15 minutes to save everything you're working on and shut down the computer once the power goes out. But I've really found it useful for those power blips where it just goes out for a minute or so. The UPS keeps your computer humming along, and you won't lose any work.

I also picked up a smaller UPS for my less-power-hungy cable modem and router. Typically if the power goes out, the cable connection will still work as long as my modem and router have power. So in those 15 minutes of power I have for my computer, I can still access the Internet and power blips won't force a modem/router reboot.

And finally that bluetooth modem connection has been a lifesaver. Not only can I still check email and surf the web during a blackout, but I can use the connection whenever I travel. I pay Cingular $20/month for unlimited data transfer, but it also means I don't pay access fees at airports, hotels, or greedy coffee shops (I'm looking at you Starbucks). Granted, the connection is painfully slow, but at least I can check websites, send emails, and post long-winded messages to my blog.

Unfortunately I can't turn on my main computer now, so I can't get much done. But at least I didn't have to worry about losing data. I guess the next level of redundancy is some sort of portable generator. Luckily these long power outages are few and far between, so I'm not sure it's worth it.

My laptop is at 46% power so I better sign off. No telling when the lights will come back on.
« Older posts  /  Newer posts »