« June 2011 | Main | March 2012 »

August 5, 2011

netselect-if

If you're like me, you've wondered which Interactive Fiction Archive mirror is fastest for you. Wonder no more!


#!/usr/bin/env ruby

require 'open-uri'
require 'hpricot'

doc = Hpricot(open("http://www.ifarchive.org/"))
mirrors =(doc.search("div.ArchiveMirrors")/"a").map {|a| a['href'].strip.match(/^[^\/]+\/\/([^\/]+)/)[1]}.reject {|m| m == "mirror.ifarchive.org"}.uniq
system(*(%w(netselect -v -s 5) + mirrors))

Things I learned

Perl's DateTime module can (usually) figure out the local timezone on its own. Don't know why I didn't know this -- it's right there in the docs.


our $App::LocalTZ = DateTime::TimeZone->new( name => 'local' );

... # then everywhere else

my $dt = DateTime->new( ..., time_zone => $App::LocalTZ );

It's straightforward to convert a static library to a shared one

ar -x mylib.a
gcc -shared *.o -o mylib.so

catdoc converts doc and rtf files to text, and, so far in my brief acquaintance with it, does so better than antiword and unrtf. And it comes with xls2csv and catppt as well.

axi-cache is a lot more useful than apt-cache for searching through debian package info. It's part of apt-xapian-index which uses Xapian to index the data.

August 4, 2011

Status bar datestamps made easy

Suppose you want to represent the days of the week with one character each.

MTWTFSS

Oops, two ambiguities in a domain of just seven. Tuesday and Thursday may begin with the same letter, but not the same sound, so we can just throw in the IPA for the voiceless dental fricative, one of the sounds represented in English by the digraph /th/.

MTWθFSS

But we still have to disambiguate Saturday and Sunday. OK, Sun is for Sunday -- what could be more clear?

MTWθFS☼

That's the Unicode "white sun with rays". It's a little hard to distinguish from a snowflake or a squashed bug at regular text sizes. But if you tend toward light text on a dark background, like me, the "black sun with rays" works better.

MTWθFS☀

Black Sun was also an X-Men miniseries. Black Sun was also a Wildstorm character. Now that Wildstorm is being rolled into the DC Universe, there could be a Black Sun with rays series.

But a sun-eater is cooler.

I seem to have digressed. Anyway, there's a perfectly good alternative symbol for the Sun lying around, the alchemical symbol.

MTWθFS☉

But if we're going alchemical, why should Saturday get the S? Saturn's got its own alchemical symbol.

MTWθF♄☉

And Saturn's not the only one. Just look at the days of the week.

Moon day
Tyr's day
Wotan's day
Thor's day
Freya's day
Saturn's day
Sun day

In the interpretatio germanica, Tyr is Mars; Wotan is Mercury; Freya is Venus; Thor is... well, Thor is Hercules, but Thor's Day is Jupiter's day. So now we have:

☽♂☿♃♀♄☉

I expect strftime to support this any day now. In the meantime, this convenient Perl one-liner breaks it down.

perl -e binmode STDOUT,":utf8";print chr((0,0x263D,0x2642,0x263F,0x2643,0x2640,0x2644,0x2609)[(localtime(time))[6]])'

August 3, 2011

New netbook. But mostly Windows-bashing.

I finally bought a netbook, an Asus EEE PC 1015PEM-PU17. Purportedly, there should be EEE PCs available with Linux, but I don't see those actually for sale, so I ended up paying the Microsoft tax and receiving it with Windows 7.

I decided to leave it there, both because it's a useful beard (no one's going to suspect you're concerned with security if your machine boots into Windows), and because it would be difficult or impossible (it didn't come with OS CDs) to restore it after the fact, which I might want to do to resell it. Some people would actually want it that way. Takes all kinds to make a world.

So I planned to do the minimally intrusive thing and install Linux to the 100+ GB empty D: drive it was set up with. But I wasn't sure whether Windows would end up confused if I simply reformatted that out from under it, so I wanted to delete the partition within Windows. Which meant interacting with it.

This was my first experience with Windows 7. I never used Vista, and I'd heard a lot of good things about 7. From my brief and shallow interaction with it, I couldn't see much difference from XP. You're still not prompted to make a separate admin account from your ordinary user account. That was a bad call ten years ago, and it's a bad call now. I tried to figure out how to delete the partition, and I could find a couple of places to get at info about the drives, but no luck, so I resorted, of course, to Googling.

Start Menu -> Control Panel -> All Items View -> Administrative Tools -> Computer Management -> Storage -> Disk Management. Mmm, can't you just smell the discoverability? The intuitiveness? I'm not suggesting that this is harder than it would be in Linux, of course, where you'd also need to google to find that you wanted parted. But once things are so complicated you're resorting to web searching to figure out how to do what you want, I'm hard-pressed to see how navigating through 7 levels of interface is any easier, either. Sure does involve more pointing and clicking, though -- gotta give it that.

I did the web-searching in MSIE. Had a wonderful Windows moment in which it immediately prompted me for whether I wanted the Bing bar. I said no. Another box popped up saying the Bing Bar wanted to run some software. Did I want to let it? I said no. Back to the first box. You see, you have to say yes to the second box to let it run software (which is actually an uninstall program, but you're not told that) in order to effect your no to the first box.

Meanwhile, there were things popping up all over the place with Trend Micro this and Asus Warrantee that. These aren't directly Windows' fault, but they are of a piece with the software ecosystem of irritation that has grown around Windows. I made the mistake of walking away from the computer and lying down on the couch, and nearly as soon as the kitty had settled on my chest, it started playing annoying music. The default screensaver was some sort of instructional/advertisement video.

As usual, I wondered how people could live this way.

So I deleted the partition and installed Ubuntu 11.04. I thought I'd try another Debian Unstable derivative, but I shopped around and really didn't see that anything else offered a comparably attractive combo of currency, stability, and support. Maybe tomorrow I'll dist-upgrade to the 11.10 Alpha 3.

And then I spent several hours installing software and in a couple of important cases, like for my window manager and terminal emulator, downloading the source so I could have the latest versions compiled with exactly the options I wanted, and generally did a lot of things that would leave most people wondering how I could live that way.

But absolutely nothing pops up.

Not even when the battery runs dry.

Yeah, I need to do something about that one.

Updated: Lest I mislead anyone, the defaults for most of the Linux installations in this modern world already take care of laptop battery warnings without thought or effort on the user's part. It's because of my extreme customization that I'll need to do something myself.