Sadly, life is not all vacations. The bugs, they spawn, and we must crush them.
Let us not forget that computers are mysterious, capricious, often cruel, just like the world they inhabit, but they reward the apt user tremendously.
I discovered a couple of interesting bugs last night, bugs which teach a broader lesson about computing when you look at them together. proved to be uncharacteristically easy to exterminate. They are related to each other and relevant to tasks in everyday computing. As any decent hacker will tell you, we can turn the tables and stomp out the bugs when we command the Terminal. Sometimes it's easy.
The Tale of the Gooey Fail
All I wanted was to unzip a file. Those who are less tech-savvy may not understand how this works, and so I must explain.
Most users use to compress many files into a single file, called a ZIP file. It saves space and makes multiple files easier to email. If you are a Mac user and right- or control-click a selection of files in the Finder, click "Compress X Items", and a compressed file named "Archive.ZIP" containing them appears. When you want your files again, you can unzip them with the same or any other zip-compatible utility.
Always in computers, sometimes things just don't work. It turned out that machines are far from perfect, and they can annoy their users worse when that fact is forgotten. Suppose some sector on your hard disk became magnetically corrupted, and part of the file was lost. The bits on the still-good sectors should be easy to get back, right? They can be, but not with OS X's native archiving utilities, the ones I am sure most Mac users use for archiving.
They failed because they are gooey, which they are called for their imprecise glamor. There's no excuse for their failure. Zipping things is age-old, by computer standards. It ought to be easy by now. Still, various implementations are shaky with bugs.
The built-in Archive Utility failed first:
The widely used cross-platform application called StuffIt also failed to recover any files:
It was a gooey mess. At first I suspected I needed to reset the permissions, but they turned out to be set correctly from the start. It occurred to me that the Terminal has archive utilities, which might be coded differently and bring different results than the user friendly graphical applications.
On a hunch, into my Terminal window I typed four characters, "zip ", drag-and-dropped the file, and pushed enter. The files were revived! Scanning the files in Serato ScratchLive 2.2. showed that only three of the one hundred audio files in the archive were corrupted. Their metadata tags were still readable, however, and so they were identifiable as songs from Cypress Hill, Mad Cobra and Crazy Town, if you're curious. Wait, but who on Earth is Mad Cobra? I forgot. Oh, hells yeah! Perfect.
The really astonishing thing was that the Terminal afforded me a 97% data recovery rate. That has to be bankable, somewhere. To one without a command of the Terminal and a decent intuition, those files might have seemed to be 4ever b0rked. Instead, with just a simple one-liner, they proved almost more than merely salvageable.
The Way to Wget
Later in the evening, I was probing through the fine-grained, always changing security and privacy settings on my Facebook profile. I wanted to know their public figures for developers, but Firefox seemed it would not complete the download. It kept leaving parts of files on the disk.
With an educated guess, I opened the terminal, typed "wget " and pasted in the URL of the file, but I got an error. OS X Terminal doesn't come with wget already installed. Downloading was easy, tho. On this page, there are excellent, very simple instructions to get it for free. Wget is cool. It's what hacker god Richard Stallman uses for the bulk of his web browsing outside of academia, for good reasons, probably.
The file downloaded through it was titled "index.html". Odd. Maybe I am doing something wrong. When I renamed it "index.pdf", as suggested in the URL, it opened perfectly, presenting the information I wanted. The same trick worked for Firefox.
Purpose-wise, Firefox and Wget programs are not exactly comparable. Firefox is what makes all the pretty internet sparkle; Wget is built to be robust and achieve good results for a much narrower set of tasks. I am growing to appreciate the terminal increasingly. It's speeding me up and making me more effective at computing, and it has saved me valued troves of thrash and booty music from the nineties.
Next up: learning Emacs.
No comments:
Post a Comment