Hey Oh!

Song of the night: “Snow (Hey Oh)” by the Red Hot Chili Peppers. Incredibly awesome musically, the music video is pretty neat too: I’m not really sure who we’re seeing, but, among the cliche video of them singing on stage, you get ‘video portraits’ of probably hundreds of seemingly-random people. Simple, and yet strangely novel.

Unlike some of their other songs, this one didn’t find its way into Guitar Hero or Rock Band. I think that the first people in charge of making the decision of what songs made the cut got distracted and are still in an office somewhere, playing the video over and over again, singing along quietly. Unable to break them from their trances, the others decided the song was simply too awesome to be fit for general consumption.

I’m on my fourth time in a row. And when it’s done, I’m probably going to go for #5. Roommates, I apologize in advance if I advertently wake you up tonight while I mumble about snow and the cover of another public wonder in my sleep.  You might play this song to drown me out.

A Big Day

John Edwards has dropped out, leaving the Democratic race between Obama and Hillary.

The news from today that really shocks me, though, is that Giuliani:

  • Dropped out of the race, and
  • Endorsed McCain (!)

Giuliani scared me the most, but I think McCain is the one Republican that stands a chance of winning in 2008, which is equally as scary.

If the race had come down to Obama versus, say, Giuliani, I think it would be a landslide victory for Democrats. But if it comes down to Clinton versus McCain as early signs are showing? Clinton’s disliked enough, and McCain’s moderate enough, that he might just win it.

McCain is a rather interesting candidate. On one hand he’s taken many issues I like, such as speaking out against torture, among others. On the other hand, he’s part conservative, part lunatic…

Web Design

I’ve redone ttwagner.com. It’s no longer a random integer between 0 and 255, but instead, a decent-looking site. I’ve integrated some of the cool things I’m hosting there as well. I came across a few interesting things I wanted to point out.

The world DNS page is incredibly intensive, and, since it’s not dynamic, there’s no sense in “generating” it each time. So I used the command wget http://localhost/blah/index.php -O index.html to “download” the output, and save it as index.html in the web directory. Viola, it serves the HTML file rather than executing the script.

But the HTML output was frankly hideous. The page was written as a, “You know, I bet I could do…” type thing, written to fill some spare time (once upon a time, I had lots of it). So I’d given no attention to outputting ‘readable’ HTML. It was valid code and all, it just didn’t have linebreaks or anything of the sort, made it a nightmare to read. But I really didn’t want to rewrite my script to clean up its output so that I could download it again….

So I installed tidy (which sometimes goes by “htmltidy,” including the name of the Gentoo package). A -m flag tells it to “modify” the file in place (as opposed to writing it to standard output). The code looks much cleaner; it’s not indented, but I can live with that!

I also found that mod_rewrite is useful in ways I hadn’t envisioned using it before. I developed everything in a subdirectory (/newmain), and then just used an htaccess override to make it “look” like the main page (at ttwagner.com/ ). This simplifies things greatly, as it would complicate my existing directory structure. (It’s imperfect: you “end up” in /newmain anyway, but my goal isn’t to “hide” that directory, just to make the main page not blank.)

I’ve also found I Like Jack Daniel’s. (Potential future employers: note the missing “that” in that sentence, which changes the meaning completely!) The site is a brilliant compendium of useful information, focusing on, well, Apache, PHP, MySQL, and gzip, generally. The “world DNS” page was quite large, so I decided to start using gzip compression. He lists a quick, simple, and surefire way to get it working. (The one downside, and it’s really a fundamental ‘flaw’ with compression in general, is that you can’t draw the page until the whole transfer is complete. This has an interesting effect as you wait for the page to load: it just sits there not doing much of anything, and then, in an instant, displays the whole page.) It may be possible to flush the ‘cache’ more often, resulting in “progressive” page loading, but this would be complicated, introduce overhead, and, if done enough to be noticeable, also defeat the point of compression. (Extreme example: Imagine taking a text file, splitting it into lots and lots of one-byte files, and then compressing each of them individually. Net compression: 0. Net overhead: massive!)

Gnome’s Trash Folder

Gnome (the desktop environment, not the creepy garden fixtures) has a “Trash Folder,” which is the functional equivalent of the Windows Recycle Bin. This is slightly problematic for those of us who are used to file “deletion” on Linux instantly unlinking the file, who don’t expect that the files are being moved somewhere. Especially as the developers made the icon a little more obscure, putting it in the very bottom right corner of the taskbar, where I overlooked it for quite some time. Now that I know it’s there, it’s easy to purge, just like I empty the trash bin.

But for geeks like me, you’ll be happy to know that the “Trash Bin” is nothing more than a directory, ~/.Trash. Thus you can empty it fairly easily, with “rm -rf ~/.Trash/*”  And you can use all the routine Linux filesystem tools: “ls” to show what’s in it, and “du -sh ~/.Trash” to list its contents and show the total size.

Update: Newer distros are putting it in ~/.local/share/Trash/files/ instead of ~/.Trash

Flash Plugin for Ubuntu

In the hopes of helping someone else…  Ubuntu has two options for a plugin for Firefox to play Flash. There’s the open-source Gnash and “the real thing” from Adobe. Of course what Adobe provides is closed-source, so there seems to be a tendency to push Gnash. But having used Gnash, it’s awful. I give them enormous credit for their work, but when I have a load average of 2.5 playing a 2-minute YouTube video, get lots and lots of dropped frames, and have random 0’s (a big ‘zero’) superimposed over the video, it’s alpha-level code. It’s not usable.

In theory, Ubuntu makes it easy to install the proprietary one, too. They can’t distribute the player itself, per Adobe’s license terms. So they have a package, flashplugin-nonfree, which downloads it from Adobe. The problem is that Adobe updated their version, so the script fails, citing an MD5 mismatch. (The file’s signature has changed, since it’s, you know, a different version.) Worst of all, it doesn’t handle this error appropriately: it tells you that the package installed successfully, when, in actuality, it aborts due to the error.

This happened in early December. The Ubuntu developers have been squabbling, yet to release an update: apparently the new version doesn’t work in Konquerer. As one person on the developers’ list points out, status quo is the worst case: Flash doesn’t work for anyone. But the developers seem unwilling to use a simple patch to handle the new version, because then Konqueror wouldn’t work. So some grandiose task is under way to try to integrate it with Konqueror, apparently. Meanwhile, no one can use Ubuntu’s package manager to install Flash player.

Fortunately, it’s easy to do yourself. Download the .tar.gz file here, and extract it somewhere. Pull up a terminal, go into the extracted directory, and type “sudo flashplayer-installer,” and follow the on-screen instructions. It’ll take about fifteen seconds. When asked for the location, you probably want /usr/lib/firefox (assuming you use Firefox, and are on Gutsy). You have to close your browser to do this.

Letters to the Editor

In the local newspaper that mysteriously appeared on our kitchen counter, there are two letters to the editor in a row. (Actually, the second reads more like an article and has no name signed, but is under the “Letters to the Editor” section.)

The first starts off, “Granite Staters have always been among the first to stand up against discrimination of any kind, including opposing slavery, expanding women’s suffrage and supporting the Equal Rights Amendment. Adopting civil unions continues this proud tradition of standing up for what is just and fair.” It’s short, concise, and just praises voters for standing up for the rights of same-sex couples.

The next is about a Right to Life march. What an ironic pair of letters!

What I find strange is that the second letter/article never once mentions, “Killing unborn babies is wrong,” but is instead comes across as a rant on a slew of unrelated issues. One person is quoted as saying, “We’ve got to put the moral order back the way it should be… Reverse Roe v. Wade. Reverse civil unions…” He goes on to add, “There are more people coming in from Mexico and other places, and we’re killing ourselves off. That changes the voting demographic… They’ll wipe out the Constitution.” He goes on to complain about how “birth control has been proven to be extremely detrimental to those who use it… You have sex to have babies. If you don’t want  babies, don’t have sex.”

A second person mentions, “I heard on EWTN that after an abortion, females can get sick–cancer of the breast, cancer of the uterus.” The problem is that she says this right after the article includes a big paragraph about how no one has ever found a link between cancer and abortions.

Reasons to oppose abortion, then:

  • Gay marriage is immoral.
  • We need lots of babies to dilute the effects of those darned Mexicans who are coming into our country so that they can destroy our Constitution.
  • People who use birth control go on to lead miserable lives.
  • Despite a lack of any evidence claiming this, you might get cancer if you have an abortion.

Never mentioned:

  • They think abortion is killing babies and should thus be stopped.

To me, the latter argument would be a little more convincing. I really can’t understand what they were thinking with this letter. It’s also not as if I skipped over the section with the good arguments. I’ve basically given you a recap of the article, minus peoples’ personal backgrounds (neither of which involve abortion.) They just rant about irrelevant stuff, throw in a lot of incorrect statements, and even resort to some arguments dripping with racist sentiment. And yet, it’s very easy to present a strong case against abortion. They just fail–miserably–to do so.

Easy Backups on Linux

It’s good to keep backups, especially of servers in remote data centers using old hard drives.

rsync -vaEz --progress user@remote:/path /local/path

In my case, I’m doing it as root and just copying /, although, in hindsight, I think I should have used the –exclude=… option… It doesn’t make any sense to me to “back up” /proc or /dev, /tmp is iffy, and /mnt is usually not desired.

A few notes: I use –progress because otherwise it wants to just sit there, which is irritating.

-a is archive, which actually maps to a slew of options. -z enables compression. Note that this may or may not be desirable: on a fast link with a slower machine, this may do more harm than good. There’s also a –bwlimit argument that takes KB/sec as an argument. (–bwlimit=100 would be 100KB/sec, or 800kbps.)

Using rsync for backups is nothing new, but it’s still not used as widely as it could be. A seemingly-common option is to create a huge backup with tar, compress it, and then download the massive file. rsync saves you the overhead of making ludicrously-large backup files, and also lets you just download what’s changed, as opposed to downloading a complete image every time. It’s taking forever the first time, since I’m downloading about 40GB of content. But next time, it’ll be substantially quicker.

With backups this easy, everyone should be making backups frequently!

DNS Dork

The real geeks in the room already know what the root zone file is, but for those of you with lives… DNS (Domain Name Service) is the service that transforms names (blogs.n1zyy.com) into IPs (72.36.178.234). DNS is hierarchical: as a good analogy, think of there being a folder called “.com,” with entries for things like “amazon” and “n1zyy” (for amazon.com and n1zyy.com, two sites of very comparable importance.) Within the amazon ‘folder’ is a “www,” and within “n1zyy” is a “blogs,” for example. A domain name is really ‘backwards,’ then: if it were a folder on your hard drive, it would be something like C:.com.n1zyyblogs.

Of course, this is all spread out amongst many servers across the world. When you go to connect to blogs.n1zyy.com, you first need to find out how to query the .com nameservers. The root servers are the ones that give you this answer: they contain a mapping of what nameservers are responsible for each top-level domain (TLD), like .com, .org, and .uk.

So you get your answer for what nameservers process .com requests, and go to one of them, asking what nameserver is responsible for n1zyy.com. You get your answer and ask that nameserver who’s responsible for blogs.n1zyy.com, and finally get the IP your computer needs to connect to. And, for good measure, it probably gets cached, so that the next time you visit the site, you don’t have to go through the overhead of doing all those lookups again. (Of course, this all happens in the blink of an eye, behind the scenes.)

Anyway! The root zone file is the file that the root servers have, which spells out which nameservers handle which top-level domains.

Yours truly found the root zone file (it’s no big secret) and wrote a page displaying its contents, and a flag denoting the country of each of the nameservers. The one thing I don’t do is map each of the top-level domains to their respective country, since, in many cases, I don’t have the foggiest clue.

What’s interesting to note is that a lot of the data is just downright bizarre. Cuba has six nameservers for .cu. One is in Cuba, one in the Netherlands, and four are in the US. Fiji (.fj) has its first two nameservers… at berkeley.edu. American universities hosting foreign countries’ nameservers, however bizarre, isn’t new. .co (Colombia) has its first nameservers in Colombia (at a university there), but also has NYU and Columbia University (I think they did that just for the humor of Columbia hosting Colombia).

In other news, it turns out that there’s a list of country-to-ccTLD (Country-Code Top Level Domain) mappings. I’m going to work on incorporating this data… Maybe I can even pair it up with my IPGeo page with IP allocations per country…

Stomatron

I’ve been working on my resume as I seek to apply for a job that’s a neat blend of multiple interests–managing web projects (even in my preferred LAMP environment), politics, and even a management potential. And as I do it, I’m remembering all the stuff I did at FIRST, and reflecting on how much better it could be.

I was “fluent” in SQL at the time, but didn’t know some of the neater functions of MySQL. For example, when I wrote the web management interface to the Stomatron, I didn’t know that I could make MySQL calculate times. So I’d retrieve a sign-in and sign-out time and use some PHP code to calculate elapsed time. This wasn’t terrible, really, but it just meant that I did more work than was necessary.

More significantly, I didn’t know about the MySQL query cache. (Actually, I don’t know when it was introduced… This was five years ago.) Some of the queries were quite intense, and yet didn’t change all that often. This is exactly where the query cache is indicated.

Worse yet, I really didn’t do much with the idea of caching at all. Being the stats-freak that I am, I had a little info box showing some really neat stats, like the total number of “man hours” worked. As you can imagine, this is a computation that gets pretty intense pretty quickly, especially with 30+ people logging in and out every day, sometimes repeatedly. Query caching would have helped significantly, but some of this stuff could have been sped up in other ways, too, like keeping a persistent cache of this data. (Memcache is now my cache of choice, but APC, or even just an HTML file, would have worked well, too.)

And, 20/20 hindsight, I don’t recall ever backing up the Stomatron box. (I may well be wrong.) Especially since it and our backup server both ran Linux, it’d have been trivial to write a script to run at something like 3 a.m. (when none of us would be around to feel the potential slowdown) to have it do a database dump to our backup server. (MySQL replication would have been cool, but probably needless.) If I were doing it today, I’d also amend that script to employ our beloved dot-matrix logger, to print out some stats, such as cumulative hours per person, and maybe who worked that day. (Which would make recovery much easier in the event of a catastrophic data loss: we’d just take the previous night’s totals, and then replay (or, in this case, re-enter) the day’s login information.)

I’m not sure it was even mainstream back then, but our website could have used a lot of optimization, too. We were admittedly running up against a really slow architecture: I think it was a 300 MHz machine with 128MB RAM. With PostNuke, phpBB, and Gallery powering the site, every single pageload was being generated on the fly, and used a lot of database queries. APC or the like probably would have helped pretty well, but I have to wonder how things would have changed if we used MySQL query caching. Some queries (like WordPress’s insistence on using exact timestamps in every one) don’t benefit. I wonder if phpBB is like that. I have a feeling that at least the main page and such would have seen a speedup. We didn’t have a lot of memory to play with, but even 1MB of cache probably would have made a difference. As aged as the machine was, I think we could have squeezed more performance out of it.

I’m still proud of our scoring interface for our Lego League competition, though. I think Mr. I mentioned in passing a day or two before the competition that he wanted to throw something together in VB to show the score, but hadn’t had the time, or something of that sort. So Andy and I whipped up a PHP+MySQL solution after school that day, storing the score in MySQL and using PHP to retrieve results and calculate score, and then set up a laptop with IE to display the score on the projector. And since we hosted it on the main webserver, we could view it internally, but also permitted remote users to watch results. It was coded on such a short timeline that we ended up having to train the judges to use phpMyAdmin to put the scores in. And the “design requirements” we were given didn’t correctly state how the score was calculated, so we recoded the score section mid-competition.

I hope they ask me if I have experience working under deadlines.