vim tricks

If you’re cool like me, you spend a decent amount of time in vi editing files. Despite all the fancy IDEs and the like, nothing beats uploading your PHP script to the webserver and editing in place. I don’t profess to be a vi expert. I’m far from it, in fact. But for those that are like me–comfortable working in it but far from being a master–here are a few tips:

  • Typing “G” (in command mode, but not as a : command!) takes you to the last line of the file.
  • ma, where a is a letter a-z, sets a as a ‘mark’. You can then issue commands reflecting that mark. For example, I wanted to delete about 500 lines from a file. But I didn’t know how many lines there were, so “500dd” wasn’t a viable option. In my case, I marked the last line I wanted to delete with a, went up to the first line I wanted to delete, and then typed d’a to delete from the current line to mark a. Note that, as you’re doing this, there’s no indication of it.
  • . (a single period) runs the last command again. Handy way more often than I’d expect!
  • :wq is probably the most well-known command. But ZZ (not :ZZ) is easier and does the same thing!

This is a handy reference, by the way. So isn’t the O’Reilly book, but you can’t Google your way through that.

Tech Tricks

Here are a few low-tech computer tricks I’ve started doing lately:

  • I’ll periodically bump the wrong keys and find keyboard shortcuts that I didn’t know existed for sending an e-mail mid-sentence. It’s one thing when you’re e-mailing a friend ramblings about cheese (they may even be glad the e-mail got cut short?), but when you start e-mailing important people, it becomes a bigger deal. The last thing you want to do is e-mail the chief of police and say, “I’m working on an article and I’d like to mee”… The simple ‘fix’ is to not let your e-mail program dictate how you compose a message. The “To:” line comes first. Do it last, so you can’t mess up.
  • When attaching files, do it before you write the e-mail. I can’t believe how often people (myself very much included) send e-mails referring to attachments, but forget to add the attachment. If you can get in the habit of making attaching the file first, it’s a lot harder to mess up.
  • When downloading things from the Internet, always, always, always click “Save” instead of “Open.” I tend to do Open instead, because it seems like a needless step to save it to the Desktop and then open it. But in the past week I’ve lost two files because I click “Open” on a draft someone sends me. I spend a long time revising it, and hit Save every minute or so. But it gets saved to a temp directory that’s virtually impossible to find. Today I spent considerable time poking around the directories, and found that what’s stored is VERY limited. If you’ve visited any sites after you last saved the file, it’s practically assured that your file is 100% gone, because the cache will get purged. As I’ve said before, I’d consider this a fatal design flaw, and I can’t believe more people don’t have problems with this. So always, always, always save to your Desktop and then open. And, if you’re working on a file and about to close, don’t close it unless you’re positive you know where the file is being saved.

All of these are things that take some time getting used to. But I think they’re like, say, using a PDA: you have to commit to doing it 100%, or it’s utterly useless. If your calendar doesn’t contain everything you’re doing, it’s worse than having no calendar at all. I need to work on automatically clicking that “Save” box when downloading a file, and I need to work on re-ordering, into a non-intuitive way, the way I write e-mails. But if I can get the habit down right, the first time, in mid-sentence, I get an error that I can’t send an e-mail with no recipient named, it’s paid off. And the first time I don’t lose an hour’s worth of revisions and additions, it’s paid off.

Wireless Networking

I’m yet to see an OS get wireless networking right. I’ve now worked pretty extensively with configuring and fixing wireless network configurations on XP (SP2) and Linux (Ubuntu). And frankly, both are disappointing. A few comments…

  • (Linux) I can see three wireless networks. Why am I connected to none of them, even after clicking on one of them?
  • (Both) I have a good connection, and all of a sudden, I have no network connection. I spent fifteen minutes fiddling and it still won’t come back. Windows includes a “Repair” function, and I’ve seen lots of people use it. I have never had it do anything, nor have I have ever seen it work for someone. I’m fairly certain it’s an inside joke at Microsoft or something.
  • (Both) You reboot and the wireless usually comes back up just fine. What the heck is going on? Why, with all the amazing developers working on both platforms, has no one ever figured a way to just bring the network down and back up? (Actually, you could argue that both OSs provide this — Linux lets you disable it and re-enable it, and Windows lets you “Repair” it. And yet neither of them works.)
  • (Windows) Why, when you can’t connect, do you give me a fake IP? There’s some bizarre netblock that Windows users get put on when they don’t actually have a network connection. What gives?

You’d think that WiFi was some technology that had only been out for a few months… But there have been years to get it right. Why has no one ever made it work right?

First-Impression Reviews

Flock Web Browser:

Wow! It’s replaced Firefox on both Windows and Linux for me. (And it runs on OS X, too.) It’s actually built on Firefox, so I’ve got all my favorite extensions added in. I’m not going to do it the injustice of trying to describe it. Download it and spend five minutes with it. You’ll thank yourself.

Verizon Juke

(Link here). It sucks less than I expected. Our first reaction to seeing the commercial was, “That must be impossible for a left-handed person to use.” So when Kyle was given one to review, we called over a left-handed friend. Sure enough, it’s virtually impossible for him to use. There are some other problems: it comes in three colors, and Navy is the only one that’s not hideously ugly. The way you hold it closed (I’m not sure what you do when it’s closed; I couldn’t get it to do anything but it apparently has media features) is upside-down from how it opens. And when it’s open, there are two things on the back: the camera and the antenna. You cover both with your hand. The antenna has a big warning not to do that. But there’s no other way to hold it that’s not incredibly awkward. But otherwise, I was pretty impressed. Despite a tiny keyboard, I could dial fine. And despite a tiny screen, I could see the screen fine. The picture I took seemed to come out okay, once I figured out that it was all black because my hand was covering the lens.

Would I buy one? No way. But would I relentlessly mock someone who had one? Despite what I thought after seeing the commercials, no.

Butterfinger Bars

Pros: Delicious. Great texture. Cons: I’ve never opened one and not have it spill crumbs all over my lap

Overcoming Errors

I just updated PHP and Apache on this machine. Gentoo seems to have changed the way they do some things… But a few notes along the way, since there isn’t much in the way of helpful links out there…

  • I kept getting this error:
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    No Listening Sockets Available, shutting down.
    Unable to open logs
    The usual suggestion with the “No listening sockets available” is that port 80 is being used by something else. Maybe Apache hasn’t actually shut down and you’re trying to restart it. However, in my case, I had made very certain that nothing was on port 80. The problem is actually caused by the fact that, after an upgrade, the “Listen” directive randomly goes missing. Tucking “Listen 80” into the top of a virtual host fixed everything.
  • Keep backups of all your config files. I screwed up and let them be rewritten as I upgraded Apache.

Mirror Idea

My server is allowed 1 terabyte of transfer a month. I would be shocked if I exceeded 10 GB any month.

Lots of services need mirrors. I’m becoming re-interested in streaming radio stations. Some of the good ones have limited bandwidth and fill up. Most open-source packages have a series of mirrors, too. Most distributions have elaborate mirror networks, in fact.

Here’s what someone should do. Set up a mirror ‘controller.’ I hit a generic name like us.something.com wanting to download something from a US mirror. This goes on all the time, and DNS does round-robin ‘load balancing’ across mirrors.

But you take it a little further. As a site admin with 900+ GB of bandwidth going unused each year, I can sign up and say, “I’ll take up to 25 GB a day,” and “I can spare 6 GB of disk space for mirrors,” and select a list of matching projects. I might end up hosting an Ubuntu mirror. I install a daemon on my server that communicates with the mirror network, but when someone someone hits the us.whatever.com pool, I’m in the list. But, it’ll detect that it’s forwarded me enough traffic for the day and pull me out. Furthermore, the daemon on my machine can also send a “temporarily remove me” notice, either for a duration of time or until further notice. That alleviates my final fear: that I won’t exceed disk quotas or bandwidth, but that serving all those files will really tax my system. When to send the signals is entirely up to me.

I’d like to volunteer to help, but I don’t want to blindly commit to something. And because I don’t see any good way to let me commit to help within my means, I have at least 20 GB of disk space and 900 GB of bandwidth that the community can’t use.

It seems like it wouldn’t be that hard, either. It might require a little more CPU power on the part of the mirror network management, but it’s not exceedingly complex. I think a simple PHP script might be easiest… You load, say, us.project.com/project/latest.tar.gz, but latest.tar.gz is actually a script that grabs a list of available mirrors and throws a redirect to the file on one of the mirrors.

The irony is that the argument against this idea — that it’d require more servers — is exactly what the problem is trying to solve.

E-mail Gates

This is surely not a revolutionary idea, but I’ve never seen references to it before. I forward my mail to my GMail account. I do own two domain names with mail services, though, but I just forward what I need to my GMail account.

Some sites require an e-mail address to sign up, and they send you a confirmation e-mail, so it needs to be real. However, I have no interest in letting them e-mail me long-term. The general solution is a “throw-away address.” You use it once and then delete it.

Here’s an idea that seems a little less wasteful to me. I call it an e-mail gate. I can set up a forwarder pretty easily. As long as I’m logged in, it’s just a few seconds of work. I can also remove a forwarder in a few second’s time.

So you might have an address like matt@gate01.ttwagner.com. (This sub-domain doesn’t even exist right now, so don’t bother trying it.) I can “open the gate” (turn the forwarder on), sign up on the site, get my confirmation e-mail, and then “close the gate” by turning the e-mail off. Consequentially, any crap they send will bounce back with a “No such address” message. But when I want to get e-mail or a lost password reminder, I can just turn the gate on for a minute. Unless you’re getting inundated with spam (e.g., tens of thousands a day), opening the gate for under a minute won’t be enough time for much crap to get through. Unlike throwaway addresses, you can use the same address as multiple sites, making it easy to remember what address you used.

It’d be neat to write some code to give a web-based interface to this. I think I need to get it working with some mail daemon that supports a MySQL database of users, though, since it currently involves putting the address in a text file, updating the address cache, removing it, and then updating the cache again. It’s quick if you’ve got a shell open, but it’s a bit of a pain to script.

I Live in a Web Browser

I don’t know why I keep eying quad-core systems. With the exception of playing music, copying files from my camera, some word processing, and IM, I live in a web browser. Here are some of the big uses:

  • GMail, my mail client. When I’m at my computer, I almost always have GMail up. I have a client for my Treo that lets me check it there. My school e-mail forwards to GMail. My ttwagner.com and n1zyy.com mail forwards to there.
  • Google and Wikipedia. I rely on Wikipedia way too much. But between Google and Wikipedia, I feel like I can do anything.
  • Google Docs is slowly winning me over. I move between my laptop, ‘public’ Office 2007 computers, and an office computer with Office 2003, so I’m hardly sold on any one particular interface. Google Docs is word processing (and spreadsheets) without the crap, although sometimes I do prefer to have it locally. But honestly, my life depends on the Internet, so ‘safety’ of files (in case I lose Internet access) really isn’t even one of the big issues.
  • Google Calendar has proved way more useful than I expected. It integrates nicely with GMail, sending me reminders and offering to let me schedule things that get e-mailed to me. And Goosync gives me an app on the Treo to sync my Treo calendar with my Google calendar. Bliss!
  • All my good photos end up on Flickr, and I buy and sell stuff on eBay often. I get my news through BBC and Google News.
  • I run a private Wiki. This is more useful than I ever imagined. I’m not quite as committed to it as I’d like, but I’m trying to keep all my class notes up there, which has a lot of benefits. During research, it’s a handy link dump. When drafting a constitution for a club here, I used that to allow collaborative editing.
  • I host a few mailing lists. Trying to keep a text file with 90 names and e-mail them and remove bounces and find people is a pain. Mailman is a savior.
  • I host multiple blogs. These are obvious, but there are some more I’m starting.
    • One, that never caught on, takes a pretty literal definition: a web log. I wanted a way for us to keep track of petty things that were going on, and have everything logged somewhere and searchable.
    • I’m also drafting one for the Democrats. A big part of what we do is outreach/publicity, and a blog is ideal for this.
  • Tonight I realized that none of my ‘task management’ systems worked. So I set up Mantis. It’s not perfect, but it works pretty well. Setting up Bugzilla is pretty intense, but no so with Mantis. The “problem” is that it was intended for software bug tracking, not keeping track of work I have to do, so I have fields like “Reproducibility” and other holdovers from software. I may do a little tweaking. But my plan is that anything I have to do should end up in there. Everything is in one place, and I can slice the data a million different ways, by priority, by category (one for each class, one for each club, one for each major class project, one for “Life”), etc.

Truly, without Firefox and a browser on my Treo, I don’t think I could get by. And I sometimes wonder if it’s worth paying monthly for a dedicated server. But I get so much benefit from the services I host for myself that it definitely is.

A Partial Upgrade

My AthlonMP system is aging. Actually, it’s aged. It’s down to 512MB RAM (the other 512MB went bad a long time ago). BIOS updates ended 4 years ago, and the thing doesn’t seem to support drives over 137 GB or USB keyboards, two things that have worked for a long time. (Hint: it seems like a good idea at the time, but don’t buy a server-grade motherboard for your desktop. It seems better, but it’s all these little things that will get you.)

I have a decent enough graphics card, a nice HDTV tuner, a DVD burner, 500/200/60/40 GB drives, a nice keyboard, and a monitor. So all I need, really, is a new motherboard, CPU, and RAM.

So here’s a motherboard. Here’s the processor. Here’s the RAM, times two. Net cost? A little under $500. For a quad-core processor, 4 GB RAM, and a motherboard with GigE. Assuming, of course, that all you need is motherboard + processor + RAM. Which is the case for me. Granted, it also assumes that you have $500 to spend on computer upgrades….

Edit: Seems that the RAM might not be the best. Don’t take my word on it being the right thing.