Shallow Thoughts : : 2006

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Fri, 29 Dec 2006

The Joys of Shell Pipelines ...

A friend called me for help with a sysadmin problem they were having at work. The problem: find all files bigger than one gigabyte, print all the filenames, add up all the sizes and print the total. And for some reason (not explained to me) they needed to do this all in one command line.

This is Unix, so of course it's possible somehow! The obvious place to start is with the find command, and man find showed how to find all the 1G+ files:

find / -size +1G

(Turns out that's a GNU find syntax, and BSD find, on OS X, doesn't support it. I left it to my friend to check man find for the OS X equivalent of -size _1G.)

But for a problem like this, it's pretty clear we'd need to get find to execute a program that prints both the filename and the size. Initially I used ls -ls, but Saz (who was helping on IRC) pointed out that du on a file also does that, and looks a bit cleaner. With find's unfortunate syntax, that becomes:

find / -size +1G -exec du "{}" \;

But now we needed awk, to collect and add up all the sizes while printing just the filenames. A little googling (since I don't use awk very often) and experimenting led to the final solution:

find / -size +1G -exec du "{}" \; | awk '{print $2; total += $1} END { print "Total is", total}'

Ah, the joys of Unix shell pipelines!

Update: Ed Davies suggested an easier way to do the same thing. turns out du will handle it all by itself: du -hc `find . -size +1G` Thanks, Ed!

Tags: , , , ,
[ 17:53 Dec 29, 2006    More linux | permalink to this entry | ]

Thu, 21 Dec 2006

On the Twelfth Day of Christmas, My True Love Gave to Me ...

At dinner last night, amid the ubiquitous miasma of egregious Christmas music which is inescapable in public places starting in mid November, during "The Twelve Days of Christmas" Dave got a faraway expression in his eyes. My mother asked why, and he explained that he was thinking about the mathematics of the song: how many items of each type have been given by the end, and which items are more numerous?

There are two ways to interpret the song.

On the second day of Christmas, my true love gave to me
Two turtle doves
And a partridge in a pear tree.

So by the second day, you have two turtle doves, and you have the original partridge -- but do you also have a second partridge, as a literal interpretation of the song implies? Or is the song simply repeating all the previous gifts, not implying that they're given again?

Most people seem to assume the latter, but let's take the song literally and assume that on the third day, you get three french hens, plus two more turtle doves (that makes four) and one new partridge (for a total of three).

My first thought was that at time step T, you double what you had in step T-1 (you're getting all the same stuff yet again) and add T for the new gifts. But that's not right: you get a new load of each item (one partridge, two doves, three hens, and so forth) but you don't double all the accumulated extras who are now crowding your back yard. Time to start writing down the sums.

At each time T, the quantity you have of the Jth item is:
T
NJ,T = Σ J
i=J

That's easy: it's just NJ,T = J*T- J*(J-1) (pretend you've given J of the Jth object at each time step; but since you didn't give it before timestep J, subtract all the ones up to timestep J-1).

NJ,T = J * (T - J + 1)

If all you want to know is how many of each item you have at the end (on the 12th day), plug in T-12:

NJ,12 = J * (13 - J)

A quick sanity check: that means you'll have 12 of item 1 (partridges in pear trees), because you've gotten one new one each time, and 12 of item 12 (drummers drumming), which you got in one big noisy box on the last day. Likewise, you'll have 22 each of items 2 (turtle doves, of which you got two every day except the first day) and 11 (pipers piping), which you got on day 11 and again on day 12.

So the curve which interested Dave is an inverted parabola; you get the least number of the first and last gifts, and the largest quantity of the two middle gifts: six geese a'laying and seven swans a'swimming. How many geese and swans do you get in the end? Here's the surprising answer:

N6,12 = N7,12 = 6 * 7 = 42

Douglas Adams fans will immediate recognize this as the solution to the ultimate question of Life, the Universe, and Everything. Now you know what the question was!

One last question: how many items, total, of all types will you have by the end of the twelfth day?

Since you already know how many of each item you have, just add them all up:
12 12 12 12
Ntot = Σ j * (13-j) = Σ (j * 13 - j2) = 13 * Σ j - Σ j2
j=1 j=1 j=1 j=1

Fortunately, we know that
A
Σ i = A (A + 1) / 2
i=1
and
A
Σ i2 = A (A + 1) (2A + 1) / 6
i=1
so we can use those identities to figure out how many total items we'll have:
Ntot = { 13 * (12 * 13) / 2 } - { 12 * 13 * 25 / 6 }
= 364

So it turns out that true love packs a present for just about every day of the year into those twelve days!

(And I found an excuse to play with using HTML tables to display equations.)

Tags:
[ 12:59 Dec 21, 2006    More science | permalink to this entry | ]

Sat, 09 Dec 2006

Getting a Wacom Tablet Working under Edgy

Another person popped into #gimp today trying to get a Wacom tablet working (this happens every few weeks). But this time it was someone using Ubuntu's new release, "Edgy Eft", and I just happened to have a shiny new Edgy install on my laptop (as well as a Wacom Graphire 2 gathering dust in the closet because I can never get it working under Linux), so I dug out the Graphire and did some experimenting.

And got it working! It sees pressure changes and everything. It actually wasn't that hard, but it did require some changes. Here's what I had to do:

  1. Install wacom-tools and xinput
  2. Edit /etc/X11/xorg.conf and comment out those ForceDevice lines that say "Tablet PC ONLY".
  3. Reconcile the difference between udev creating /dev/input/wacom and xorg.conf using /dev/wacom: you can either change xorg.conf, change /etc/udev/rules.d/65-wacom.rules, or symlink /dev/input/wacom to /dev/wacom (that's what I did for testing, but it won't survive a reboot, so I'll have to pick a device name and make udev and X consistent).

A useful tool for testing is /usr/X11R6/bin/xinput list (part of the xinput package). That's a lot faster than going through GIMP's input device preference panel every time.

I added some comments to Ubuntu's bug 73160, where people had already described some of the errors but nobody had posted the steps to work around the problems.

While I was fiddling with GIMP on the laptop, I decided to install the packages I needed to build the latest CVS GIMP there. It needed a few small tweaks from the list I used on Dapper. I've updated the package list on my GIMP Building page accordingly.

Tags: , , , ,
[ 16:12 Dec 09, 2006    More linux | permalink to this entry | ]

Thu, 23 Nov 2006

GIMP JPEG 2000 Plug-In

People keep showing up on GIMP's IRC channels and asking about JPEG 2000 support. There was a Summer of Code "Wavelet" project last summer which implemented JPEG 2000 support (among other things) but no one ever seems to know where to find it.

So I asked Simon, who was the mentor for that project. Turns out he had tarballs, but didn't think it was appropriate to link them from his own site, especially as they were somewhat tricky to compile.

The consensus among the developers was that it would be nice to have jp2 and the other wavelet plug-ins available on the GIMP Plug-in Registry. So I fiddled with them, fixed a couple of Makefile issues, added READMEs with author credit and building instructions, and uploaded them to the registry. The plug-ins are:

jp2
JPEG 2000 support
denoise
A noise removal plug-in
ihalf
Inverse halftoning -- remove halftones from printed images.

I haven't actually used these plug-ins (couldn't find a JPEG2k file to test) -- I just wanted to help make them available for people who need them.

While I was at it I updated my vastly out-of-date registry entries for Pandora and added an entry for my label/business card script.

Tags:
[ 13:54 Nov 23, 2006    More gimp | permalink to this entry | ]

Mon, 20 Nov 2006

Ubuntu "Edgy Eft" Installation Pitfalls

I just tried Ubuntu's newest release, "Edgy Eft", on the laptop (my trusty if aging Vaio SR17). I used the "xubuntu" variant, in order to try out their lighter weight xfce-based desktop.

So far it looks quite good. But the installation process involved quite a few snags: here follows an account of the various workarounds I needed to get it up and running.

Live CD Problems

First, I tried to use the live CD, since I've heard it has a nice installer. But it failed during the process of bringing up X, and dumped me into me a console screen with an (initramfs) prompt. I thought I had pretty good Linux creds, but I have to confess I don't know what to do with an (initramfs) prompt; so I gave up and switched to the install CD. Too bad! I was so impressed with Ubuntu's previous live CDs, which worked well on this machine.

Guessing Keyboard Layout

Early on, the installer gives you the option to let it guess your keyboard layout. Don't let it! What this does is subject you to a seemingly infinite list of questions like:

Does your keyboard have a squiggle key?
where each squiggle is a different garbled, completely illegible character further mangled by the fact that the installer is running at a resolution not native to the current LCD display. After about 15 of these you just give up and start hitting return hoping it will end soon -- but it doesn't, so eventually you give up and try ctl-alt-del. But that doesn't work either. Pulling the power cord and starting over seems to be the only answer. Everyone I've talked to who's installed Edgy has gone through this exact experience and we all had a good laugh about it. Come to think of it, go ahead and say yes to the keyboard guesser, just so you can chuckle about it with the rest of us.

Once I rebooted and said no to the keyboard guesser, it asked three or four very straightforward questions about language, and the rest of the installation went smoothly. Of course it whined about not seeing a network, and it whined about my not wanting it to overwrite my existing /boot, and it whined about something to do with free space on my ext3 partitions (set up by a previous breezy install), but it made it through.

X Hangs on the Savage

On the first reboot after installation, it hung while trying to start X -- blank screen, no keyboard response, and I needed to pull the plug. I was prepared for that (longstanding bug 41340) so I immediately suspected dri. I booted from another partition and removed the dri lines from /etc/X11/xorg.conf, which fixed the problem.

Configuring the Network

Now I was up and running on Xubuntu Edgy. Next I needed to configure the network (since the installer won't do it: this machine only has one pcmcia slot, so it can't have a CDROM drive and a network card installed at the same time). I popped in the network card (a 3com 3c59x cardbus card) and waited expectantly for something to happen.

Nada. So I poked around and found the network configuration tool in the menus, set up my IP and DNS and all that, and looked in vain for a "start network" or "enable card" or some similar button that would perform an ifup eth0.

Nada again. Eventually I gave up, called up a terminal, and ran ifup eth0, which worked fine.

Which leads me to ask:

Given that Ubuntu is so committed to automatic hardware detection that it forces you to run hal, which spawns large numbers of daemons that poll all your disks a couple of times a second -- why can't it notice the insertion of a cardbus networking card? And configure it in some easy way without requiring the user to know about terminals and networking commands?

Ubuntu Still Wins for Suspend and Hibernate

Around this point I tested suspend and hibernate. They both worked beautifully out of the box, with no additional twiddling needed. Ubuntu is still the leader in suspending.

sudo: Timestamp Woes

Somewhere during these package management games, I lost the ability to sudo: it complained "Timestamp too far in the future", without telling me which file's timestamp was wrong so that I could fix it. Googling showed that lots of other people were having the same problem with Edgy, and found an answer: use the GUI Time and Date tool to set the time to something farther in the future than the timestamp sudo was complaining about, then run sudo -k to do some magic that resets the timestamp. Then you can set the time back to where it belongs. Why does this happen? No one seems to know, but that's the fix. (I found some discussion in bug 43233.)

vim isn't vim?

I restored my normal user account, logged in as myself with my normal fvwm environment, and went to edit (with vim) a few files. Every time, vim complained:

"E319: Sorry, the command is not available in this version: syntax on"
after which I could edit the file normally. Eventually I googled to the answer, which is très bizarre: by default, vim-common is installed but vim is not. There's a binary named vim, and a package which seems to be vim, but it isn't vim. Installing the package named vim gives you a vim that understands "syntax on" without complaining.

Conclusion

That's the list. Edgy is up and running now, and looks pretty good. The installer definitely has some rough edges, and I hope my workarounds are helpful to someone ... but the installer is only a tiny part of the OS, something you run only once or twice. So don't let the rough installer stop you from installing Edgy and trying it out. I know I look forward to using it.

Tags: ,
[ 20:30 Nov 20, 2006    More linux | permalink to this entry | ]

Wed, 08 Nov 2006

Mercury Transits and Titan Occultations

Mercury transited the sun today. The weather forecast predicted rain, and indeed, I awoke this morning to a thick overcast which soon turned to drizzle. But miraculously, ten minutes before the start of the transit the sky cleared, and we were able to see the whole thing, all five hours of it (well, we weren't watching for the whole five hours -- the most interesting parts are the beginning and end).

I had plenty of practice with solar observing yesterday, showing the sun to a group of middle school girls as part of an astronomy workshop. This is organized by the AAUW, the same group that runs the annual Tech Trek summer science girls' camps. (The Stanford Tech Trek has a star party, which is how I got involved with this group.) It's the second year I've done the astronomy workshop for them; this year went pretty smoothly and everybody seemed to have a good time observing the sun, simulating moon phases, learning about the Doppler effect and plotting relative distances of the planets on a road map.

But what I really wanted to write about was the amazing video shown by last weekend's SJAA speaker, Dr. Ivan Linscott of Stanford. As one of the team members on the New Horizons mission to Pluto, he was telling us about Pluto's tenuous atmosphere. There isn't a lot of information on Pluto's atmosphere yet, but one of the goals of New Horizons is to take readings as Pluto occults the sun to see how sunlight is refracted through Pluto's atmosphere.

But that's no problem: it turns out we've already done more challenging occultation studies than that. Back in December 2001, Titan occulted a binary star, and researchers using Palomar's Adaptive Optics setup got a spectacular video of the stars being refracted through Titan's atmosphere as the occultation progresses.

This is old news, of course, but most of us hadn't seen it before and everyone was blown away. Remember, this is a video from Earth, of the atmosphere of a moon of Saturn, something most Earth-based telescopes would have trouble even resolving as a disk. Watch the Titan occultation video here.

Tags: ,
[ 23:38 Nov 08, 2006    More science/astro | permalink to this entry | ]

Tue, 24 Oct 2006

New "Amabot" Phishing Scam Spoofing Amazon

I get tons of phishing scam emails spoofing Amazon. You know, the ones that say "Your Amazon account may have been compromised: please click here to log in and verify your identity", and if you look at the link, it goes to http://123.45.67.8/morestuff instead of http://www.amazon.com/morestuff. I get lots of similar phishing emails spoofing ebay and various banks.

But yesterday's was different. The URL was this:
http://www.amazon.com/gp/amabot/?pf_rd_url=http://211.75.237.149/%20%20/amazon/xec.php?cmd=sign-in

Check it out: they're actually using amazon.com, and Amazon has a 'bot called amabot that redirects you to somewhere else. Try this, for example: http://www.amazon.com/gp/amabot/?pf_rd_url=http://bn.com -- you start on Amazon's site and end up at Barnes & Noble.

When a family member got tricked by a phish email a few months ago (fortunately she became suspicious and stopped before revealing anything important) I gave her a quick lesson in how URLs work and how to recognize the host part. "If the host part isn't what you think it should be, it's probably a scam," I told her. That's pretty much the same as what Amazon says (#6 on their "Identifying Phishing or Spoofed E-mails" page). I guess now I need to teach her how to notice that there's another URL embedded in the original one, even when the original one goes to the right place. That's a bit more advanced. I suspect a lot of anti-phishing software uses the same technique and wouldn't have flagged this URL.

I reported the phish to Amazon (so far, just an automated reply, but it hasn't been very long). I hope they look into this use of their amabot and consider whether such a major phishing target really needs a 'bot that can redirect anywhere on the net.

Tags: , ,
[ 11:34 Oct 24, 2006    More tech/web | permalink to this entry | ]

Sun, 01 Oct 2006

Frisky Fall Squirrelets

The cool, overcast fall weather is here (first rain of the season, too), and it's amazing how much difference it makes in the squirrels' behavior and appetites. They're hungry again! Just as Notch dropped from thirteen or fifteen nuts in a day last winter to one or two during summer (of course, she probably has plenty of other food sources aside from us), now that fall is here we had to make an emergency run to the nut store to satisfy the hordes.

The kids, Chiquita and Scrape (as Dave took to calling Ringlet after she got a scrape on her shoulder), are friskier in addition to being hungrier. Today Scrape spent most of the morning running up and down the guava tree, bounding in the air or doing front-flips for no reason, and starting tussles with Chiquita. When not tussling with her sibling, Chiquita spent most of the morning eating -- she's noticably bigger than Scrape and it's not hard to see why.

Ringtail drops by periodically to check on how the kids are doing in day care. Then she'll dig up a nut and move on. She never lingers. We try to feed her, but she has an amazing inability to see food even when she's standing right on top of it. She looks sleek and robust, so I guess she's getting plenty to eat somewhere else, but watching her nose around and still miss a nut right in front of her face, I sometimes wonder how she survives.

Notch usually doesn't drop by until afternoon, and seems to avoid the kids. Squirrels must have inhibitions about fighting youngsters (even those not their own), since she's never been hesitant to chase away any interloping adult squirrel. It'll be interesting to see how long the truce lasts between Notch and Ringtail's kids -- and how long the kids will stick together before going their separate ways.

Tags: , ,
[ 16:20 Oct 01, 2006    More nature/squirrels | permalink to this entry | ]

Thu, 21 Sep 2006

Squirrel Babies: Chiquita and Ringlet

A few days ago, I saw our neighbor squirrel, "Ringtail", struggling along the fence with a baby in her mouth, and hoped that she was moving closer to us so we'd get to see the babies when they got older.

My wishes were answered: the very next morning a new young squirrel appeared to play on the fence. Dave called "her" (we're not sure about gender yet) Chiquita.

It's easy to tell squirrel youngsters: not only are they much smaller than adults, but they're quite klutzy and cautious about the aerial feats that the adults do without hesitation. Chiquita was fairly klutzy, once falling out of the red oak onto the motorcycle shed (a drop of maybe five feet, which didn't seem to hurt her).

Then the following day, both Ringtail and Chiquita showed up ... with another baby. This one has a ringed tail like "his" odd-looking mom, but otherwise looks like an ordinary young grey squirrel. Ringtail took a few nuts then disappeared, leaving the kids at nursery school (a role which we're only too happy to fill). We think they hang out in the atlas cedar in the front yard when they leave here.

We've been greatly entertained for the last few days, watching how fast the kids learn the business of being a squirrel. On the first day, they had a lot of trouble moving head-first downward on the fence: while Notch will scamper right down then leap to the deck, Chiquita stretches as far down as she can get with her rear claws hooked over the top of the fencepost, then stays there for many minutes, evidently trying to work up the nerve to move downward. When she does move, it's carefully, step by step, and making the leap over to the deck (only about six inches) also takes time and nerve. When squirrels are fearful of something, they lash their tails wildly, like an angry cat.

A red oak tree gives much better purchase for your claws. Neither squirrelet shows any hesitation about leaping the couple of feet from the fence to the tree trunk, though sometimes Chiquita misses and has to run around the tree trunk before she gets a secure hold. And when they're both in high spirits they'll chase each other at high speed through the tree's branches.

Their antics can be pretty funny -- like when Chiquita was nerving herself to drop from the deck to the ground, but her wildly-swinging tail dislogdged a rock on the deck, which fell next to her and sent her into a panic causing her to drop off the deck.

Both of them, but especially Ringlet, love the potted fuscia I have sitting on the kayak stand. They stand on their hind legs, reach down into the pot and dig: they'll bury a nut, then immediately dig it out again. Sometimes they eat the fuscia, too. The fuscia is not looking at all healthy now, and I've written it off as a squirrel toy.

Even from one day to the next, it's easy to see their skills improve. Yesterday afternoon Ringlet even made the jump from the roof to the fence -- only a few feet, but the landing is tricky since the top of the fence is less than an inch wide. They do still stumble and fall pretty often -- Ringlet fell from the tree to the ground yesterday, making an audible thump, then lay there for a few minutes before getting up. But they're looking more graceful every day. Ringtail still brings them by in the morning and drops them off, then heads off to work (or wherever it is she goes once the kids are safely in day care).

Notch hasn't been around much, though I can't imagine she's been scared off by Ringtail and the kids. I did catch sight of her yesterday. I was sitting in the yard watching Chiquita. (The kids are fairly tolerant of our presence as long as we move slowly, but we're still trying to get them accustomed to moving about the yard and finding nuts in the right places.) She'd finally moved from the tree across the fence to the post nearest the office, and I was hoping she'd come down and take a drink of water and notice the nut I'd put there for her. After about five minutes on the fencepost, looking longingly down at the water but evidently not feeling confident enough for a head-down descent, she finally started to make a move -- then froze. I caught movement out of the corner of my eye: Notch was ambling along the deck right past my chair. While Chiquita watched, rapt and motionless, Notch went decisively to the nut hole, pulled out the whole walnut (she dislikes all pre-shelled walnuts -- we've tried bulk ones from the local fruit stand and bagged ones from Trader Joe's, but Notch and I both agree that neither taste as good as the walnuts in the shell) and marched back the way she'd come.

That was enough for Chiquita: as soon as Notch was safely out of sight, Chiquita came straight down the fencepost and onto the deck, sniffed at the shelled nut (not hungry) and had a long drink of water. I still don't know if Notch knew Chiquita was there -- squirrels don't seem to have territorial battles with youngsters, so maybe Notch was just being nice to the kid. (And she obviously wasn't hungry anyway, or she would have eaten the walnut and asked for more.)

Pictures of Ringtail and Chiquita (no Ringlet yet) here.

Tags: , ,
[ 19:00 Sep 21, 2006    More nature/squirrels | permalink to this entry | ]

Sat, 16 Sep 2006

Ringtail's baby

One of our occasional visitors is a very odd squirrel. She's very large, with powerful hindquarters (enough so that she walks differently from most squirrels, in a sort of waddle) and a long, long tail that's ringed like a raccoon. We call her "Ringtail".

She doesn't visit often: Notch usually chases her off. And she's not very good at finding the nuts we set out for the squirrels, let alone being bold enough to come to the door.

We hadn't seen her for several weeks when today I heard a nut-crack noise out in the yard, peered out and saw Ringtail on the fence -- with a baby squirrel in her mouth. Go Ringtail!

Carrying baby squirrels usually means it's time to change dens, I believe. Grey squirrels apparently keep several dens, and change from one to another when one den gets too dirty and full of parasites.

With any luck she and her babies are moving to a more nearby den, and we'll be seeing them more often now.

Tags: , ,
[ 13:25 Sep 16, 2006    More nature/squirrels | permalink to this entry | ]

Mon, 04 Sep 2006

Internet Explorer under WINE

I've been updating some web pages with tricky JavaScript and CSS, and testing to see if they work in IE (which they never do) is a hassle involving a lot of pestering of long suffering friends.

I've always heard people talk about how difficult it is to get IE working on Linux under WINE. It works in Crossover Office (which is a good excuse to get Crossover: the company, Codeweavers, is a good open source citizen and has contributed lots of work to WINE, and I've bought from them in the past) but most people who try installing IE under regular WINE seem to have problems.

Today someone pointed me to IEs 4 Linux. It's a script that downloads IE and installs it under WINE. You need wine and cabextract installed. I was sure it couldn't be that simple, but it seemed easy enough to try.

It works great! Asked me a couple of questions, downloaded IE, installed it, gave me an easy-to-run link in ~/bin, and it runs fine. Now I can test my pages myself without pestering my friends. Good stuff!

Tags: , ,
[ 15:21 Sep 04, 2006    More tech/web | permalink to this entry | ]

Fri, 25 Aug 2006

Pluto is too a planet

The BBC had a good article today about the International Astronomical Union vote that demoted Pluto from planet status.

It was fairly obvious that the previous proposal, last week, that defined "planet" as anything big enough that its gravity made it round, was obviously a red herring that nobody was going to take very serious. Fercryinoutloud, it made the asteroid Ceres a planet, as well as Earth's moon (in a few billion years when it gets a bit farther away from us and ceases to be considered a moon).

But apparently there were several other dirty tricks played by the anti-Pluto faction, and IAU members who weren't able to be in the room at the time of the vote are not happy and are spoiling for a rematch. The new definition doesn't make much more sense than the previous one, anyway: it's based on gravitationally sweeping out objects from an orbit, but that also rules out Earth, Mars, Jupiter and Neptune, all of which have non-satellite objects along their orbits.

And of course the public is pretty upset about it for sentimental, non-scientific reasons. Try searching for Pluto or "Save Pluto" on Cafe Press to see the amazing selection of pro-Pluto merchandise you can buy barely a day after the IAU decision. (Personally, I want a Honk if Pluto is still a planet bumper sticker.)

It'll be interesting to see if the decision sticks.

So do I have a viable definition of "planet" which includes Pluto but not Ceres or the various other Kuiper belt objects which are continually being discovered?

Why, no, I don't. But the discussion is purely semantic anyway. Whether we call Pluto a planet doesn't make any difference to planetary science. But it does make a difference to an enormous collection of textbooks, museum exhibits, and other science-for-the-public displays.

Pluto is big enough to have been discovered in 1930, back in the days before computerized robotic telescopes and satellite imaging; it's been considered a planet for 76 years. There's no scientific benefit to changing that, and a lot of social and political reason not to -- especially now with New Horizons headed there to give us our first up-close look at what Pluto actually looks like.

There are two possible bright notes to the Pluto decision. First, Mark Taylor pointed out that it has become much easier to observe all the planets in one night, even with a very small telescope or binoculars.

And second, maybe Christine Lavin will make a new updated version of her song Planet X and go on tour with it.

Tags: ,
[ 22:56 Aug 25, 2006    More science/astro | permalink to this entry | ]

PyTopo 0.5

Belated release announcement: 0.5b2 of my little map viewer PyTopo has been working well, so I released 0.5 last week with only a few minor changes from the beta. I'm sure I'll immediately find six major bugs -- but hey, that's what point releases are for. I only did betas this time because of the changed configuration file format.

I also made a start on a documentation page for the .pytopo file (though it doesn't really have much that wasn't already written in comments inside the script).

Tags: , , , , ,
[ 22:10 Aug 25, 2006    More programming | permalink to this entry | ]

Sun, 20 Aug 2006

The Long-Awaited Microsoft Rebate

I finally got my Microsoft Rebate voucher!

Remember the California Microsoft antitrust case, oh so many years ago? A bit over three years ago (seems longer) it was determined in a class-action suit that Microsoft had been abusing their monopoly in order to overcharge for their software. Any Californian who had purchased Microsoft products between February 1995 and December 2001 could apply for a rebate based on the number of MS products purchased.

(Curiously, no one ever seemed to point out that Microsoft did not reduce its prices after this decision, nor did I ever see anyone question why it's okay for them to overcharge now when it wasn't okay then. That has puzzled me for some time. Perhaps questions like that show why I'm a programmer instead of a lawyer or corporate exec.)

Over the years since the decision I've periodically wondered what ever happened to the rebate vouchers we were supposed to get. But a few weeks ago they started appearing. I got mine late last week.

The voucher is only redeemable for purchased software (from anyone, not just Microsoft) or a fairly restrictive list of hardware: computers (but not components to build a computer), printers, monitors, scanners, keyboards, mice or trackballs. For a Linux user who builds computers from parts (to avoid paying the "Microsoft Tax" or to get a better price), it's a little tough to use up that voucher. Now where did I put the receipt for that printer I bought a few years ago? Or maybe it's time to buy a copy of Crossover Office for testing web sites against IE.

In any case, if you sent in your rebate claim way back when and haven't heard anything, watch your mailbox. They say most people should receive their vouchers this month (August). If you don't, you can find more information at microsoftcalsettlement.com.

Tags:
[ 10:58 Aug 20, 2006    More tech | permalink to this entry | ]

Sat, 19 Aug 2006

A Week of Linux Get-Togethers

It's been a week jam-packed with Linuxy stuff.

Wednesday I made my annual one-day trip to Linuxworld in San Francisco. There wasn't much of great interest at the conference this year: the usual collection of corporate booths (minus Redhat, notably absent this year), virtualization as a hot keyword (but perhaps less than the last two years) and a fair selection of sysadmin tools, not much desktop Linux (two laptop vendors), and a somewhat light "Dot Org" area compared to the last few years.

I was happy to notice that most of the big corporate booths were running Linux on a majority of show machines, a nice contrast from earlier years. (Dell was the exception, with more Windows than Linux, but even they weren't all Windows.)

Linuxworld supposedly offers a wireless network but I never managed to get it to work, either in the exhibit hall or in the building where the BOFs were held.

Wednesday afternoon's BOF list didn't offer much that immediately grabbed me, but in the end I chose one on introducing desktop Linux to corporate environments. Run by a couple of IBM Linux advocates, the BOF turned out to be interesting and well presented, offering lots of sensible advice (base your arguments to management on business advantages, like money saved or increased ability to get the job done, not on promises of cool features; don't aim for a wholesale switch to Linux, merely for a policy which allows employees to choose; argue for standards-based corporate infrastructure since that allows for more choice and avoids lock-in). There was plenty of discussion between the audience and the folks leading the BOF, and I think most attendees got something out of it.

More interesting than Linuxworld was Friday's Ubucon, a free Ubuntu conference held at Google (and spilling over into Saturday morning). Despite a lack of advertising, the Ubucon was very well attended. There were two tracks, ostensibly "beginner" and "expert", but even aside from my own GIMP talk being a "beginner" topic, I ended up hanging out in the "beginner" room for the whole day, for topics like "Power Management", "How to Get Involved", and "What Do Non Geeks Need?" (the last topic dovetailing into the concluding session Linux corporate desktops).

All of the sessions were quite interactive with lots of discussion and questions from the audience. Everyone looked like they were having a good time, and I'm sure several of us are motivated to get more deeply involved with Ubuntu.

Ubucon was a great example of a low-key, fun, somewhat technical conference on a shoestring budget and I'd love to see more conferences like this in the bay area.

Finally, the week wrapped up with the annual Linux Picnic in Sunnyvale, a Silicon Valley tradition for many years and always a good time. There were some organizational glitches this year ... but it's hard to complain much about a free geek picnic in perfect weather complete with t-shirts, an installfest, a raffle and even (by mid-afternoon) a wireless network. Fun stuff!

Tags: , , , ,
[ 20:52 Aug 19, 2006    More conferences | permalink to this entry | ]

Tue, 15 Aug 2006

GIMPing a "favicon"

"Favicons" are those little icons you see to the left of the URLbar in a browser, and for each site in the bookmarks menu or toolbar. They're just a file named favicon.ico in the top level of a web site, and they're a nice addition to a site. (More details in the Wikipedia entry.)

I'd made a few favicons in the distant past by creating a 32x32 image, saving it as ppm, then using ppmtowinicon. But when I tried it in GIMP recently, I ran into trouble.

GIMP can save ICO files: Save As, click Select File Type and choose "Microsoft Windows icon (ico)". That gets you a dialog where you have to choose a color depth and palette. I tried different settings, but the resulting images never showed up properly in Firefox.

But then I tried saving as ppm and using ppmtowinicon and that no longer worked either. Argh! What's up?

The silly answer, it turns out, is that it had nothing to do with how GIMP was saving the images. The problem was that Firefox caches favicons, and shift-reload or Clear Cache doesn't help. When you're testing a new favicon, you have to load the url for the favicon.ico itself (and reload it if necessary). Success at last! It even handles transparency, so you can make shaped favicons that show up nicely against a tab, menu or toolbar background.

Of course, editing a 32x32 pixel image is a fun exercise in itself. I recommend using a second view (View->New View). Expand one view a lot (800x works well) so you can edit individual pixels, while the other view remains at normal size so you can see your final icon as others will see it in the browser.

Tags:
[ 11:57 Aug 15, 2006    More gimp | permalink to this entry | ]

Fri, 04 Aug 2006

Disabling mailto links

Every time I click on a mailto link, Firefox wants to bring up Evolution. That's a fairly reasonable behavior (I'm sure Evolution is configured as the default mailer somewhere on my system even though I've never used it) but it's not what I want, since I have mutt running through a remote connection to another machine and that's where I'd want to send mail. Dismissing the dialog is an annoyance that I keep meaning to find a way around.

But I just learned about two excellent solutions:

First: network.protocol-handler.warn-external.mailto
Set this preference to TRUE (either by going to about:config and searching for mailto, then doubleclicking on the line for this preference, or by editing the config.js or user.js file in your firefox profile) and the next time you click on a mailto link, you'll get a confirmation dialog asking whether you really want to launch an external mailer.

"Ew! Cancelling a dialog every time is nearly as bad as cancelling the Evolution launch!" Never fear: this dialog has a "Don't show me this again" checkbox, so check it and click Cancel and Firefox will remember. From then on, clicks on mailto links will be treated as no-ops.

"But wait! It's going to be confusing having links that do nothing when clicked on. I'm not going to know why that happened!" Happily, there's a solution to that, too: you can set up a custom user style (in your chrome/userContent.css directory) to show a custom icon when you mouse over any mailto link. Shiny!

Tags: , , ,
[ 21:19 Aug 04, 2006    More tech/web | permalink to this entry | ]

Tue, 01 Aug 2006

Javascript Warnings Everywhere

I'm working on some little Javascript demos (for a workshop at this summer's Get SET girls' technology camp) so I've had the Javascript Console up for most of my browsing over the last few days. I also have Mozilla's strict Javascript checking on (user_pref("javascript.options.strict", true); in prefs.js or user.js) since I don't want to show the girls code that generates warnings. (Strict mode also reports errors in CSS.)

It's been eye opening how many sites give warnings. You know that nice clean ultra-simple Google search page? One CSS error and one JS warning. But that's peanuts to the pages of errors I see on most sites, and they're not all missing "var" declarations. I have to hit the "Clear" button frequently if I want to be able to see the errors on the pages I'm working on.

And my own sites? Yes, I admit it, I've seen some errors in my own pages too. Though it makes me feel better that there aren't very many of them (mostly CSS problems, not JS). I'm going to keep the JS Console visible more often so I'll see these errors and correct them.

Tags:
[ 00:06 Aug 01, 2006    More programming | permalink to this entry | ]

Sat, 29 Jul 2006

What's that chlorine smell in the woods?

A few weeks ago, hiking in the woods, I noticed it was happening again: the smell of chlorine in a forest far away from pools or other likely sources of chlorine smell. This happened about this time last summer, too. It only lasts for a few weeks: apparently there's something that blooms briefly in deep redwood forests which smells like pool chlorine.

Whatever it is, it's pervasive and not very localized. I never notice it getting stronger near any of the trails where we hike -- it's more a general odor one notices while driving along forest roads. That makes it hard to narrow it down to a specific plant.

Googling wasn't entirely enlightening, but it did suggest that the most likely culprit is a mushroom. Various species of Mycena mushrooms apparently emit a chlorine-like odor, especially when they're growing on wood. Chlorine smells are also reported from Marasmius oreades, the "fairy ring" or "scotch bonnet" mushroom, and from Amanita chlorinosma and A. polypyramis. But I didn't find anything about widespread seasonal blooms of any of these mushrooms.

So the mystery remains, and I guess all that's left is to remember, when hiking in the redwood forest at this time of year, to stop and smell the mushrooms.

Tags: ,
[ 11:36 Jul 29, 2006    More nature | permalink to this entry | ]

Wed, 26 Jul 2006

Shallow Thoughts URLs changing

Administrivia: I've switched over to using static files with pyblosxom, instead of generating everything from a CGI, to save some load on the server.

That means that URLs on this blog are changing to be a bit cleaner. For instance, this entry, instead of being http://shallowsky.com/blog/index.cgi?blogging/tostatic.html, becomes http://shallowsky.com/blog/blogging/tostatic.html instead. The RSS URL changes from http://shallowsky.com/blog/?flav=rss to http://shallowsky.com/blog/index.rss

The best top level URL to use is http://shallowsky.com/blog/

I've hacked up a python CGI script that will try to remap the URLs appropriately, so old feeds will continue to work for a while. But it probably isn't very robust, and I'd like to get rid of the script eventually, so please update any bookmarks you might have to this blog.

Tags:
[ 23:38 Jul 26, 2006    More blogging | permalink to this entry | ]

Math Skills

I just got back from the local Safeway, where a one-pound box of sugar cubes costs $1.49.

A two-pound box, same brand, is $3.99.

What a deal!

Even better, the two-pound price is up: it used to be $3.49 a few months ago (no change in the one-pound price).

I guess too many people were jumping on that incredible $3.49 deal, so they had to raise it.

Tags: ,
[ 17:25 Jul 26, 2006    More misc | permalink to this entry | ]

Tue, 18 Jul 2006

Slashdotted!

I got slashdotted yesterday -- a positive Slashdot book review of Beginning GIMP. Hooray!

The comments were mostly the usual mix of flames from Photoshop users saying "GIMP sucks because it isn't like Photoshop", with hardly anything about the book; no surprise there. I don't know why Photoshop users seem so compelled to attack the GIMP, but obviously they do since this happens so often. They don't seem to be willing to accept "Some people like one style of user interface, other people like another style, and a highly complex application like GIMP or Photoshop is going to take some time to learn no matter how it's designed."

Slashdot linked to Barnes & Noble rather than Amazon, which is understandable since BN has a killer 40% off sale in progress on Apress books (they have

at $26.99 for BN members, $29.99 otherwise).

Apress also pointed me toward a couple other reviews that I hadn't seen yet, so I created a review page to link to them.

Tags:
[ 18:37 Jul 18, 2006    More gimp | permalink to this entry | ]

Mon, 10 Jul 2006

Screen Blanking Under X

An unexplained change in the screen blanking timeout sent me down the primrose path of learning about dpms, vbetool and screen blanking. I guess it had to happen eventually.

It started when my laptop, which normally can sit for about ten minutes before the screen goes black, suddenly started blanking the screen after only two minutes.

After a few days of sporadic research, I now know what pieces are involved and how to fix the timeout. But it turns out not everything works the way it's supposed to. I've written up my findings: A Primer on Screen Blanking Under Xorg.

Tags: ,
[ 12:55 Jul 10, 2006    More linux | permalink to this entry | ]

Sun, 09 Jul 2006

Precision

On my wall I have a calendar with pretty pictures of wolves, and assorted wolf facts for each month. July features a wolf howling. In the lists of facts is:
If conditions are right a wolf's howl can carry 10 miles / 16.09 kilometers.

I wonder why wolves are so much more precise when they're howling in metric?

Tags:
[ 18:09 Jul 09, 2006    More misc | permalink to this entry | ]

Fri, 07 Jul 2006

Carrot Nanotubes

I put a "baby carrot" out on the door ledge to see if the squirrels might like it. (In summer, we're not getting many squirrel visits. There must be something pretty yummy growing in the neighborhood. Notch comes by every second or third day, eats a few pieces of walnut then waits expectantly for take-up (a whole walnut she can take away and bury). A male youngster we suspect is Notch's also comes by every day or two, to eat a few nuts and drink water. We haven't seen Nonotchka for months, and I fear the worst.)

Turns out squirrels have zero interest in carrots. We put the carrotlet into the nut dish and forgot about it for a few days, and discovered something interesting: carrot raisins!

[carrot nanotube]

Turns out carrots are mostly water, and they shrink even more than grapes when you let them dry out.

I'm going to let it dry out some more and see what happens. I'm hoping for fame and fortune as the first person to create carrot nanotubes.

Tags:
[ 10:32 Jul 07, 2006    More misc | permalink to this entry | ]

Thu, 06 Jul 2006

Was the 2004 Election Stolen?

Anyone following the voting machine controversy in the last presidential election -- or, even more, anyone who wasn't following it and might not be aware of the issues -- should check out Robert F. Kennedy, Jr's article in Rolling Stone, Was the 2004 Election Stolen?

The article is long, detailed and well researched article, and it will make you question whether we really live in a democracy.

Apparently Kennedy is considering filing whistleblower lawsuits against two of the voting machine companies. This won't do anything to change our national elections, but at least it might help get the word -- and the evidence -- out into the public eye.

Tags: , , ,
[ 12:36 Jul 06, 2006    More politics | permalink to this entry | ]

Sat, 03 Jun 2006

Cleaner, More Flexible Python Map Viewing

A few months ago, someone contacted me who was trying to use my PyTopo map display script for a different set of map data, the Topo! National Parks series. We exchanged some email about the format the maps used.

I'd been wanting to make PyTopo more general anyway, and already had some hacky code in my local version to let it use a local geologic map that I'd chopped into segments. So, faced with an Actual User (always a good incentive!), I took the opportunity to clean up the code, use some of Python's support for classes, and introduce several classes of map data.

I called it 0.5 beta 1 since it wasn't well tested. But in the last few days, I had occasion to do some map exploring, cleaned up a few remaining bugs, and implemented a feature which I hadn't gotten around to implementing in the new framework (saving maps to a file).

I think it's ready to use now. I'm going to do some more testing: after visiting the USGS Open House today and watching Jim Lienkaemper's narrated Virtual Tour of the Hayward Fault, I'm all fired up about trying again to find more online geologic map data. But meanwhile, PyTopo is feature complete and has the known bugs fixed. The latest version is on the PyTopo page.

Tags: , , , , ,
[ 18:25 Jun 03, 2006    More programming | permalink to this entry | ]

Thu, 01 Jun 2006

The Secret to the CUPS Web Interface

On Dapper, whenever I tried to add a new printer or make any modifications to the existing printer's settings, I would eventually come to a dialog prompting me to enter username and password for 'CUPS'. There seemed to be no right answer: there is no user called "cups" (there's a "cupsys", but that's not what it was asking for), and trying either my own username and password, or root's, just popped up the dialog again. A second attempt always led to a blank white page.

But Carla knew the answer. You're supposed to read:

zless /usr/share/doc/cupsys/README.Debian.gz
then skip to the end of the file where there's a brief hint about this problem, stating that "Administration over the web interface is disabled by default since it requires the CUPS daemon to be able to read /etc/shadow." Note that they don't actually disable it in a way that tells users it's disabled. CUPS apparently doesn't check for read permission on the shadow file before opening it, or check whether there was an error in reading it; it just silently bombs out with no indication what went wrong.

To fix it:

adduser cupsys shadow
adduser yourname lpadmin
You may not need the second line if you're already in group lpadmin (type groups to find out).

Then reboot. (Restarting cups and logging out and back in might be enough: you need to get cups and your login session seeing their new group permissions.)

Now, magically, the CUPS web interface works!

Tags: ,
[ 23:15 Jun 01, 2006    More linux | permalink to this entry | ]

Mon, 29 May 2006

Aid for Java Victims

Over dinner, I glanced at the cover of the latest Dr. Dobb's (a new article on Ruby on Rails), then switched to BBC World News. The first Beeb headline was Aid flow begins for Java victims.

I guess I was a little distracted from dinner preparations ... my first thought was "Are they going to give them all copies of Ruby and Rails?"

Then, of course, I remembered the earthquake. Oh, right, those Java victims!

(Not to make light of the situation there, which sounds grim. And just as I was writing this, I got email from the USGS Earthquake Notification Service reporting another aftershock in Indonesia, this one magnitude 5.6. I hope it doesn't make matters worse.)

Tags:
[ 22:05 May 29, 2006    More programming | permalink to this entry | ]

Sat, 27 May 2006

New Pandora, Reversing Layers, and Script-Fu Booleans

Dave thought I wasted too much presentation time reversing the layers in my panorama example prior to running Pandora. I'm sure he's right.

The problem is that GIMP's "Open as Layers", if you select multiple layers, opens them in the opposite direction from the way you'd generally expect to use them in a panorama, with the lexigraphically first layer on the top of the stack rather than the bottom.

The very next day, someone showed up on IRC asking how to reverse layers, because "Open as Layers" opened them in the wrong order to use for an animation.

At Mitch's suggestion, I wrote a reverse-layers script-fu (which Mitch improved by pointing out that it didn't handle the possible error case of a floating layer. As it happens, re-ordering floating layers works fine in current CVS, but apparently it's not supposed to. I suspect being able to move layers without alpha off the bottom position in the stack may also be a bug, so I added a guard against that). (Update: No, it turns out it's intentional that non-alpha layers can be moved anywhere in the stack in 2.3.)

Layer->Stack->Reverse Layer Order is now included in CVS GIMP, but for users of earlier versions I've made it available: reverse-layers.scm.

Meanwhile, I made a new version of Pandora which can build a panorama in either direction. I still find it slightly jarring to assemble a panorama from right to left after building them from left to right for so long, but maybe I'll get used to it.

I caught another bug at the same time: I was testing one of the parameters set in the GIMP dialog (which sets a toggle to either TRUE or FALSE) like this: (if use-mask (do-stuff))

That doesn't work in script-fu. Turns out TRUE is just an integer, while if apparently only tests for Lisp nil or non-nil. So you have to say (if (= use-mask TRUE) (do-stuff)) if you want tests to work against booleans coming from GIMP dialogs.

Tags:
[ 23:22 May 27, 2006    More gimp | permalink to this entry | ]

Fri, 26 May 2006

"Beginning GIMP" is shipping!

It's been a busy couple of weeks. My book (Beginning GIMP: From Novice to Professional) finally started arriving on people's doorsteps.

I first found out it was shipping from an email from a reader in Ohio: "I just received your book, and I have a question ..." He was the first of the Amazon shipments.

Over the next few days, more Amazon shipments started trickling in -- my mom got hers, a couple of friends got their copies. But it was nearly a week before either I or the home office of Apress received our copies, so in the meantime I was pumping everyone I knew for information -- "How does it look?"

Finally my copies arrived. It's beautiful! I'm so happy with the printing job Apress arranged. Bright colors on thick glossy paper. The colors are surprisingly different from what I saw on the PDF that went to the printer -- the active window borders on all the screenshots (royal blue on my screen) are almost purple! Now I can better appreciate why people who print professionally care so much about details like ICC color profiles. Fortunately, I knew there might be some color shift, so none of the figures in the book depend on exact colors (the RGB color circles aren't precisely Red, Green and Blue, but I'm sure readers will understand them).

So now I'm on the lecture/booksigning circuit. What fun! I've only given a couple of talks so far; last night was a PenLUG talk that went well, with lots of audience questions. The audience ranged from beginners to experienced graphics programmers to someone who's interested in using GIMP in a scientific context (comparing images; I told him about the geologist I talked to a few months ago who was doing just that, using Difference or Subtract layer modes to compare two aerial photos of the same area) to a professional photographer who uses GIMP in his work. One of the great side benefits of speaking about GIMP is getting a chance to hear all the ways people use it for different purposes.

I made some business cards to hand out, but no one takes them. That's okay: it was a good excuse to fiddle with my gimplabels script-fu and learn how to print really nice business cards from GIMP. Making business cards is easy with gLabels, but since it uses gnome-print it can only print using the system's default settings, which makes for really chintzy looking, pixellated cards. Gimp-print, on the other hand, can print in high resolution to nice glossy photo-quality card stock.

I'm gradually learning how to give a better GIMP talk, collecting interesting examples to show and minimizing the time spent fumbling over menus or waiting for progress bars. And dealing with the occasional glitch: last night, SIOX for some reason refused to select my flower image, after working perfectly the hundred or so previous times I've used it on that image. (What timing! Just last week I also received my ATM-B award from Toastmasters. Too bad outside GIMP talks don't count toward the next level.)

Fortunately GIMP is very visual, so it's easy and fun to find whizzy examples and techniques that most people haven't seen before. People have lots of interest in GIMP and image editing in general, and they want to hear more about it and have lots of questions. It's a topic everyone can appreciate. After all, who doesn't like looking at cool images?

Tags:
[ 11:32 May 26, 2006    More gimp | permalink to this entry | ]

Sun, 14 May 2006

Linkifying with Regular Expressions

I had a page of plaintext which included some URLs in it, like this:
Tour of the Hayward Fault
http://www.mcs.csuhayward.edu/~shirschf/tour-1.html

Technical Reports on Hayward Fault
http://quake.usgs.gov/research/geology/docs/lienkaemper_docs06.htm

I wanted to add links around each of the urls, so that I could make it part of a web page, more like this:

Tour of the Hayward Fault
http://www.mcs.csu hayward.edu/~shirschf/tour-1.html

Technical Reports on Hayward Fault
htt p://quake.usgs.gov/research/geology/docs/lienkaemper_docs06.htm

Surely there must be a program to do this, I thought. But I couldn't find one that was part of a standard Linux distribution.

But you can do a fair job of linkifying just using a regular expression in an editor like vim or emacs, or by using sed or perl from the commandline. You just need to specify the input pattern you want to change, then how you want to change it.

Here's a recipe for linkifying with regular expressions.

Within vim:

:%s_\(https\=\|ftp\)://\S\+_<a href="&">&</a>_

If you're new to regular expressions, it might be helpful to see a detailed breakdown of why this works:

:
Tell vim you're about to type a command.
%
The following command should be applied everywhere in the file.
s_
Do a global substitute, and everything up to the next underscore will represent the pattern to match.
\(
This will be a list of several alternate patterns.
http
If you see an "http", that counts as a match.
s\=
Zero or one esses after the http will match: so http and https are okay, but httpsssss isn't.
\|
Here comes another alternate pattern that you might see instead of http or https.
ftp
URLs starting with ftp are okay too.
\)
We're done with the list of alternate patterns.
://
After the http, https or ftp there should always be a colon-slash-slash.
\S
After the ://, there must be a character which is not whitespace.
\+
There can be any number of these non-whitespace characters as long as there's at least one. Keep matching until you see a space.
_
Finally, the underscore that says this is the end of the pattern to match. Next (until the final underscore) will be the expression which will replace the pattern.
<a href="&">
An ampersand, &, in a substitute expression means "insert everything that was in the original pattern". So the whole url will be inserted between the quotation marks.
&</a>
Now, outside the <a href="..."> tag, insert the matched url again, and follow it with a </a> to close the tag.
_
The final underscore which says "this is the end of the replacement pattern". We're done!

Linkifying from the commandline using sed

Sed is a bit trickier: it doesn't understand \S for non-whitespace, nor = for "zero or one occurrence". But this expression does the trick:
sed -e 's_\(http\|https\|ftp\)://[^ \t]\+_<a href="&">&</a>_' <infile.txt >outfile.html

Addendum: George Riley tells me about VST for Vim 7, which looks like a nice package to linkify, htmlify, and various other useful things such as creating HTML presentations. I don't have Vim 7 yet, but once I do I'll definitely check out VST.

Tags: , , , , ,
[ 13:40 May 14, 2006    More linux/editors | permalink to this entry | ]

Sat, 29 Apr 2006

The Hayward Fault -- Exposed!

Today was opening day for the Hayward fault!

Well, okay, the fault itself has been there a while, but it was opening day for the Hayward Fault: Exposed! exhibit in Fremont. They've dug a trench into the Hayward fault as part of the 1906 San Francisco Earthquake Centennial activities, so people can walk a stairway and stand right in a fault and see what it looks like.

I'm a volunteer docent for the exhibit: one of the people who help answer questions about the fault, the trench, and earthquakes in general, and who also help with details such as setup, safety, and getting people to sign the liability waiver as they enter the exhibit. (My photos and fault facts here.)

Opening day was a bit hectic even aside from the usual opening-day flutters because it was a big day in Fremont Central Park: there was a huge manga festival at the Teen Center right next to the fault trench, complete with live band all day, and over at Lake Elizabeth at the other end of the park was the annual "Splashdown" rubber ducky race.

We expected chaos. But we didn't get it: everything went surprisingly smoothly. We got lots of visitors who were there specifically to see the fault, not just spillover from the other events: apparently it had gotten press on the TV news and several newspapers. There may also have been word of mouth advertising: a surprising number of the visitors I talked to were CERT volunteers or otherwise actively involved in bay area disaster preparedness programs. They were already very well informed about seismic hazards and earthquakes, and eager to see the fault for themselves.

We ended up with about 600 visitors (perhaps a fourth to a third of them teens from the manga festival). Everyone was very well behaved, asked good questions and seemed to appreciate the exhibit. It's lovely to volunteer at exhibits where you spend all your time answering questions, chatting with people and explaining the exhibit, not worrying about policing people and enforcing rules.

(Well, maybe there was a little bit of chaos. The band at the manga festival included karaoke. It's not every day that one gets the opportunity to try to explain paleoseismology and radiocarbon dating while someone a few feet away is belting out "Bohemian Rhapsody" over a loudspeaker but forgetting the words.)

We were pleased to see that everyone spent a lot of time around the (excellent) poster displays from the USGS, which cover everything from earthquake preparedness to stratigraphy of this particular trench to geologic maps of the Hayward fault and the bay area. Most people missed the parking lot displays on the way in (a sign pointing to cracks in the pavement and an offset curb, highlighted with orange spray paint), but we told them what to look for so they could catch them on the way out.

The exhibit will get more press tonight: two or three different TV channels showed up today and interviewed Heidi Stenner, the USGS geologist organizing the exhibit, as well as some of the visitors. So with any luck we'll continue to get good turnouts. The trench will be open through the end of June.

Most of the other docents are either seismologists or seismology graduate students. It wasn't a problem: the questions most people were asking were straightforward questions I could answer easily. But it was fun listening to the other docents and learning from them, and when someone asks a tricky question, you sure can't beat being able to turn to the researcher who did the original study on this trench in 1987 (Jim Lienkaemper) and get the straight scoop! (He also developed the USGS Virtual Tour of the Hayward Fault web site).

The Hayward fault last let go in 1868, a magnitude-6.9 event called "The Great San Francisco Quake" until the 1906 earthquake on the San Andreas took over that title. Trench studies like Lienkaemper's have shown that historically this fault has a large earthquake every 130 to 150 years. Our visitors didn't need a calculator to do the math.

Tags: ,
[ 23:46 Apr 29, 2006    More science/geology | permalink to this entry | ]

Tue, 25 Apr 2006

Firefox for Presentations: Hiding the URLbar

I've long been an advocate of making presentations in HTML rather than using more complex presentation software such as PowerPoint, Open Office Presenter, etc. For one thing, those presentation apps are rather heavyweight for my poor slow laptop. For another, you can put an HTML presentation on the web and everyone can see it right away, without needing to download the whole presentation and fire up extra software to see it.

The problem is that Mozilla's fullscreen mode doesn't give you an easy way to get rid of the URL/navigation bar, so your presentations look like you're showing web pages in a browser. That's fine for some audiences, but in some cases it looks a bit unpolished.

In the old Mozilla suite, I solved the problem by having a separate profile which I used only for presentations, in which I customized my browser to show no urlbar. But having separate profiles means you always have to specify one when you start up, and you can't quickly switch into presentation mode from a running browser. Surely there was a better way.

After some fruitless poking in the source, I decided to ask around on IRC, and Derek Pomery (nemo) came up with a wonderful CSS hack to do it. Just add one line to your chrome/userChrome.css file.

In Firefox:

#toolbar-menubar[moz-collapsed=true] + #nav-bar { display: none !important; }

In Seamonkey:

#main-menubar[moz-collapsed=true] + #nav-bar { display: none !important; }

This uses a nice CSS trick I hadn't seen before, adjacent sibling selectors, to set the visibility of one item based on the state of a sibling which appears earlier in the DOM tree.

(A tip for using the DOM Inspector to find out the names of items in fullscreen mode: since the menus are no longer visible, use Ctrl-Shift-I to bring up the DOM Inspector window. Then File->Inspect a Window and select the main content window, which gets you the chrome of the window, not just the content. Then you can explore the XUL hierarchy.)

This one-line CSS hack turns either Firefox or Seamonkey into an excellent presentation tool. If you haven't tried using HTML for presentations, I encourage you to try it. You may find that it has a lot of advantages over dedicated presentation software.

Addendum: I probably should have mentioned that View->Toolbars->Navigation Controls turns off the toolbar if you just need it for a one-time presentation or can't modify userChrome.css. You have to do it before you flip to fullscreen, of course, since the menus won't be there afterward, and then again when you flip back. I wasn't happy with this solution myself because of the two extra steps required every time, particularly because the steps are awkward since they require using the laptop's trackpad.

Tags: , , ,
[ 17:59 Apr 25, 2006    More tech/web | permalink to this entry | ]

Sun, 23 Apr 2006

Easy Duplex Printing

Firefox' print system doesn't know how to print just even or just odd pages of a document, so when I need to print out a web page and want it double sided, I've been doing the Duplex Dance: hover over the printer ready to grab each page as it comes out the front so that I can quickly flip it and feed it back into the top of the printer fast enough that the printer doesn't time out with "Out of Paper".

Of course, more often I just sigh and let it print single sided because that's just way too much hassle. But today is Earth Day, so I decided it was time to find a better solution. The solution, obviously, begins with telling the browser to print to a Postscript file. Then the challenge is to find a way to print only the odd pages of the Postscript file, put the pages back in the printer, then print only the even pages.

First I tried to use mpage, which claims to be able to do this. It looked like this command should do it:

mpage -j 1%2 file.ps | lpr
But it didn't work -- it said it was spooling something to the printer, but nothing ever came out. Upon saving the mpage output to a file, I found that gv couldn't show it, citing postscript errors.

But it turns out there's a much easier way: the CUPS lp program has an option called page-set precisely for this purpose, and it's smart about detecting postscript input. This command did the trick:

lp -o page-set=odd file.ps
Then flip the sheets, insert back into the printer, and repeat with even instead of odd. Lovely!

This is documented in http://localhost:631/help/options.html?QUERY=odd#PAGESET -- and the CUPS in-browser help has a search function that took me right to it, I'm happy to note.

Other programs which may to be able to split postscript files into odd and even pages include psselect and perhaps dviduplex.

With a smarter print dialog (one that allowed specifying a custom print command, like Mozilla's used to) you could even define several custom printers, one that printed even pages and one that printed odd. Alas, Firefox' print dialog doesn't allow such things, or even allow defining extra printers. (The Mozilla bug asking for odd/even printing is bug 35228).

From a quick search of about:config, it looks like you might be able to set up something by hand using the print.printer_CUPS/printername.print_command preference (by default mine was set to lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}) but I notice something even more interesting: two variables called print.printer_CUPS/printername.print_evenpages and print.printer_CUPS/printername.print_oddpages (both set to true by default). Also interesting are plex.0.name and plex.count. Might be an easy way to get duplex printing straight from the browser, after doing a little hand-editing to try and persuade Firefox that there's more than one printer. I'll try it next time I need to print something. (It seems wrong to spend Earth Day printing more pages than I actually need.)

Tags: ,
[ 20:21 Apr 23, 2006    More linux | permalink to this entry | ]

Tue, 18 Apr 2006

Mr. Sid Meets Linux

Every now and then I search for a map (usually a geologic map) and end up at a USGS page like this one.

The web viewer is impossible, so that link over on the left -- Download Image Now (16M) -- looks awfully tempting, and I always go for it.

What they don't tell you is what sort of image you're getting; after you download that 16M, you end up with a file called something like q250_1388a_us_c.sid, which no image viewer I've ever found considers to be an image file. Even ImageMagick, which can handle almost anything, is baffled by .sid files.

It turns out that .sid stands for "Mr. Sid", a file format for very large raster images. The format is controlled by a company called LizardTech, and it's apparently so scary that no one has ever managed to reverse engineer it. The only way to read a Mr. Sid file is to use one of the programs (available in binary form only) from LizardTech.

Fortunately LizardTech does provide at least one of their programs, mrsisddecode, as a Linux binary. Get it from their download page. Then you can type a command like mrsiddecode -i q250_1388a_us_c.sid -o q250_1388a_us_c.jpg to convert the file into some other image format (which will be quite large -- this particular map is 17170 x 9525).

(Apparently there's an SDK which is also available for Linux, available here. The gdal toolkit used by MapServer and certain other GIS applications make use of this SDK. I hear it's somewhat picky about GCC version, but otherwise works.)

I'm happy that I've found something that will convert MrSid files to a format I can use, but it's a little discouraging that the USGS is restricting its public maps to a format that can be read only with software from a single company. I wonder if the USGS has a contingency plan concerning all these Mr. Sid maps in case anything ever happens to LizardTech? Aren't open formats safer in the long run?

Tags: ,
[ 22:50 Apr 18, 2006    More science/geology | permalink to this entry | ]

Sat, 15 Apr 2006

Peregrine Cam Only Available to High Bandwidth Microsoft Users

Today's SF Chronicle had a story about the nesting peregrine falcons on a building in San Francisco. In past years, they've had a "Peregrine Cam" allowing people to watch the falcons as they raised their chicks.

Well, this year the Peregrine Cam is back -- only now it's streaming video that requires a fast broadband connection and Microsoft's Windows Media Player.

If you just want to see the falcons, you're out of luck if your connection isn't up to streaming a full video feed, or if you're on a platform like Linux where Windows Media Player isn't offered.

Linux does have several video player applications which can play WMV format, but that's not enough. When I visited the page, what I got was a streamed video advertisement for the company that provides the streaming technology (in stuttering jerks that left no doubt that their bandwidth requirement is higher than the wimpy DSL available in this part of San Jose can provide). But that was all; the video ended after the ad, with no glimpse of falcons.

(I suppose I should be grateful that their Viewing FAQ even mentions Linux, if only to say "Linux users can't view the Peregrine Cam because it needs WMP." Other folks who can't use the camera are people with earlier versions of WMP, Mac users using Safari or Opera or who don't have Stuffit, and people behind corporate firewalls.)

The site doesn't have a Contact or Feedback link, where one might be able to ask "Could you possibly consider posting an photos, for those of us who would love to see the falcons but can't use your whizzy Microsoft-dependant streaming video technology?" Not everyone even wants high-bandwidth streaming video. Alas, the closest they offer is the 2006 Diary, updated irregularly and only with 200x200 thumbnail images.

Update: mplayer users with the appropriate codec can view the camera with the following command:

mplayer "http://powerhost.live.powerstream.net/00000113_live1?MSWMExt=.asf"
Thanks to Guillermo Romero for poking through the source to find a URL that works.

Tags: ,
[ 12:25 Apr 15, 2006    More nature/birds | permalink to this entry | ]

Fri, 14 Apr 2006

Glancing Through Web Stats

I'm not very consistent about looking at the statistics on my web site. Every now and then I think of it, and take a look at who's been visiting, why, and with what, and it's always entertaining.

The first thing I do is take the apache log and run webalizer on it, to give me a breakdown of some of the "top" lists.

Of course, I'm extremely interested in the user agent list: which browsers are being used most often? As of last month, the Shallowsky list still has MSIE 6.0 in the lead ... but it's not as big a lead as it used to be, at 56.04%. Mozilla 5.0 (which includes all Gecko- based browsers, as far as I know, including Mozilla, Firefox, Netscape 6 and 7, Camino, etc.) is second with 20.31%. Next are four search engine 'bots, and then we're into the single digit percentages with a couple of old IE versions and Opera.

AvantGo (they're still around?) is number 11 with 0.37% -- interesting. It looks like they're grabbing the Hitchhiker's Guide to the Moon; then there are a bunch of lines like:

sync37.avantgo.com - - [05/Apr/2006:14:29:25 -0700] "GET / HTTP/1.0" 200 4549 "http://www.nineplanets.org/" "Mozilla/4.0 (compatible; AvantGo 6.0; FreeBSD)"
and I'm not sure how to read that (nineplanets.org is The Nine Planets, Bill Arnett's excellent and justifiably popular planetary site, and he and I have cross-links, but I'm not sure what that has to do with avantgo and my site). Not that it's a problem: of course, anyone is welcome to read my site on a PDA, via AvantGo or otherwise. I'm just curious.

Amusingly, the last user agent in the top fifteen is GIMP Layers, syndicating this blog.

Another interesting list is the search queries: what search terms did people use which led them to my site? Sometimes that's more interesting than other times: around Christmas, people were searching for "griffith park light show" and ending up at my lame collection of photos from a previous year's light show. I felt so sorry for them: Griffith Park never puts any information on the web so it's impossible to find out what hours and dates the light show will be open, so I know perfectly well why they were googling, and they certainly weren't getting any help from me. I would have put the information there if I'd known -- but I tried to find out and couldn't find it either.

But this month, no one is searching on anything unusual. The top searches leading to my site for the past two months are terms like birds, gimp plugins, linux powerpoint, mini laptops, debian chkconfig, san andreas fault, pandora, hummingbird pictures, fiat x1/9, jupiter's features, linux photo, and a rather large assortment of dirt bike queries. (I have very little dirt bike content on my site, but people must be desperate to find web pages on dirt bikes because those always show up very prominently in the search string list.)

Most popular pages are this blog (maybe just because of RSS readers), the Hitchhiker's Guide to the Moon, and bird photos, with an assortment of other pages covering software, linux tips, assorted photo collections, and, of course, dirt bikes.

That's most of what I can get from webalizer. Now it's time to look at the apache error logs. I have quite a few 404s (missing files). I can clean up some of the obvious ones, and others are coming from external sites I can't do anything about that for some reason link to filenames I deleted seven years ago; but how can I get a list of all the broken internal links on my site, so at least I can fix the errors that are my own fault?

Kathryn on Linuxchix pointed me to dead-links.com, a rather cool site. But it turns out it only looks for broken external links, not internal ones. That's useful, too, just not what I was after this time. Warning: if you try to save the page from firefox, it will start running all over again. You have to copy the content and paste it into a file if you want to save it.

But Kathryn and Val opined that wget was probably the way to go for finding internal links. Turns out wget has an option to delete each file after downloading it, so you can wget a whole site but not actually need to use the local space to duplicate the site. Use this command:

wget --recursive -nd -nv --delete-after --domains=domain.com http://domain.com/ | tee wget.out 2>&1

Now open the resulting file in an editor and search repeatedly for ERROR to find all the broken links. Unfortunately the errors are on a separate line from the filenames they reference, so you can't just use a grep. wget also gets some things wrong: for instance, it tries to download the .class file of a Java applet inside a .jar, then reports an error when the class doesn't exist. (--reject .class might help that.) Still, it's not hard to skip past these errors, and wget does seem to be a fairly good way of finding broken internal links.

There's one more check left to do in the access log. But that's a longer story, and a posting for another day.

Tags: ,
[ 21:43 Apr 14, 2006    More tech/web | permalink to this entry | ]

Wed, 12 Apr 2006

Dream Jobs and Mars Rocks

Driving home from dinner, watching the alpenglow fade from the gleaming domes of Lick Observatory, I found myself thinking about the talk last night: a wonderful geology seminar by Michael Carr of the USGS on the subject of "Water on Mars".

I had a chance to chat briefly with the speaker before the meeting. We got to talking about the moon. It turns out that he spent some of his early career at Lick, working with a few colleagues to make a geologic map of the moon. How? By sketching the terminator every night from the eyepiece of the 36" refractor, and trying to deduce the geology from the topography they sketched. Talk about dream jobs!

It was interesting to compare Carr's talk to the SJAA talk on the same subject earlier this year by Jeff Moore of NASA/Ames (always one of my favorite SJAA speakers). Carr's talk was quite a bit more detailed and heavier on the geologic details, not surprising since he was speaking to a room full of geologists and geology students. He even showed a stratigraphic column of the Burns Cliff area that the Opportunity rover investigated near Meridiani.

I learned quite a bit that I can apply toward my "Mars Rock" collection. I have a set of rocks that are similar to the various interesting rocks on the moon (I finally found some anorthosite a few months ago). I use them when I give presentations on the moon. It goes over very well: I think people get a better idea of what the moon is made of and how its surface looks when they get a chance to handle the rocks and look at them up close.

I have a start on a similar collection for Mars, but of course the most interesting Mars-like rocks to show people aren't the boring black and red basalts; they're the ones the Rovers have been discovering that point to a history of water. So those are the rocks I'm most interested in adding: the sulfates and other evaporites, sandstones made of evaporite sediments, hematite "blueberries" (Moqui Marbles, on Earth), and jarosite.

I'd never heard of jarosite before, but from a bit of web research the day after the talk, it turns out to be one of the minerals implicated in the controversy that was in the news last year about modern-day generation of methane on Mars. Some people attributed the extra methane to the presence of biological organisms, though others were quick to point out that there are plenty of non-biological ways to release methane.

Interestingly, one of the audience members at the talk commented that in the Sierras jarosite is a weak biological indicator (because the biological organisms prevent formation of carbonates, if I understood him correctly). So it's a pretty interesting mineral even for someone who doesn't hold out much hope for finding life on Mars.

Here's a good summary of the rocks found in the Burns Cliffs.

Tags: ,
[ 22:27 Apr 12, 2006    More science/geology | permalink to this entry | ]

Thu, 06 Apr 2006

Squirrel Territory Skirmishes

We were travelling for a week, so we left the squirrels with plenty of nuts to bury. (I'm sure our backyard will be a maze of walnut and hazelnut sprouts once the spring weather arrives.)

On our return, we found Nonotchka nursing an injury, limping on her left rear leg and sporting two wounds on that haunch. We're guessing she had a close encounter with a cat or similar predator.

(Dave saw Notch face off with a cat just a few days ago. Notch was crossing the street back to the place where we think she has her nest, when a cat came out of someone's yard. Notch stopped and sat up in the middle of the street, facing the cat. The cat stopped, too, and they sized each other up. Finally Notch turned and casually sauntered off the way she'd been going, obviously having decided she had enough escape options and wouldn't have trouble outrunning the cat. The cat turned and stalked off the other way: "Oh, I wasn't hungry ayway.")

Since our return Nonotchka has gotten steadily gotten better. She seemed very hot for a few days, constantly running off to flop onto the cold concrete in the shade, and the soles of her paws were hot when she came over to take nuts. We suspect she was fighting an infection. But her temperature is better now, and the fur is growing back over the wounded area. She's walking better every day, and it's hard to see that anything is wrong, until she jumps. She can't jump as high as before, and climbing the fence is harder. With any luck it's just stiffness, and she'll get over that in a few days.

We've made a special effort to make sure she gets plenty of nuts, despite Notch's frequent presence. But today they had an encounter that makes me wonder if we need to worry about that any more. I was feeding Notch some breakfast nuts when Nonotchka appeared on the fence. Normally Nonotchka would stay there, or retreat across the street, when Notch is around; but today she causually walked down the fencepost and sniffed around under the deck where we often leave nuts.

Notch stopped eating and turned to look. They eyed each other for a bit. Eventually Notch rushed Nonotchka, who retreated back under the deck -- but not very far. Notch hopped a few feet over to the grass under the orange tree and began to roll, dig, and pull herself through the grass (to leave her smell there?) After about a minute, Nonotchka appeared from under the deck and began rolling/digging/pulling herself through a patch of grass under the guava tree, not more than four feet away from Notch. Notch tolerated it for maybe half a minute, then it got to be too much and she rushed Nonotchka again with a little bark. Nonotchka retreated again, but still not very far, and they spent the next few minutes eying each other, circling slowly around the yard, in a slow chase that ended with them exiting into the cedar in the front yard, where I lost sight of them.

Five minutes later Nonotchka showed up at the office door to take a nut I'd left there, but she took it up to the fence and wouldn't come back to eat anything more.

I guess squirrel territory isn't immutable. It's nice to see Nonotchka asserting herself a little.

Tags: , ,
[ 12:36 Apr 06, 2006    More nature/squirrels | permalink to this entry | ]

Sat, 01 Apr 2006

Silly, Pictures Aren't Executable!

When I plug in my camera (or flash card reader) to upload photos, they always upload as executable. I knew there must be an easy way to fix it, and finally got around to it.

I'm sure you are fully capable of reading man pages and figuring this out, just like I was. (Hint: the solution is in man mount.) But wouldn't you rather have it just spoon-fed to you? (I know I would have.) So here it is: you need the fmask option to mount. It's a mask, so you set it to the bits you don't want set when you mount the filesystem (on top of your normal umask).

My /etc/fstab entry for my camera or other flash card device now looks like this:

/dev/sda1  /pix  vfat  rw,user,fmask=111,noauto  0 0
(On the laptop it's sdb1 because the built-in memory stick reader always grabs sda.)

Tags: ,
[ 22:39 Apr 01, 2006    More linux | permalink to this entry | ]

Wed, 29 Mar 2006

Emacs: Typing dashes in html mode

What to do with a few extra hours in a boring motel with no net access? How about digging into fixing one of Emacs' more annoying misfeatures?

Whenever I edit an html file using emacs, I find I have to stay away from double dashes -- I can't add a phrase such as this one. If I forget and type a phrase with a double dash, then as soon as I get to the end of that line and emacs decides it's time to wrap to the next line, it "helpfully" treats the double dashes as a comment, and indents the next line to the level where the dashes were, adding another set of dashes. I've googled, I've asked on emacs IRC help channels, but there doesn't seem to be any way out. (I guess no one else ever uses double dashes in html files?)

It's frustrating: I like using double dashes now and then. And aside from the occasional boneheaded misfeature like this one, I like using emacs. But the dash problem been driving me nuts for a long time now. So I finally dug into the code to cure it.

First, the file is sgml-mode.el, so don't bother searching anything with html in the name. On my system it's /usr/share/emacs/21.4/lisp/textmodes/sgml-model.el. Edit that file and search for "--" and the first thing you'll find (well, after the file's preamble comments) is a comment in the definition of "sgml-specials" saying that if you include ?- in the list of specials, it will hork the typing of double dashes, so that's normally left out.

A clue! Perhaps some Debian or Ubuntu site file has changed sgml-specials for me, and all I need to do is change it back! So I typed

M-x describe-variable sgml-specials
to see the current setting.

Um ... it's set to "34". That's not very helpful. I haven't a clue how that translates to the list of characters I see in sgml-mode.el. Forget about that approach for now.

Searching through the file for the string "comment" got me a few more hits, and I tried commenting out various comment handling lines until the evil behavior went away. (I had to remove sgml-mode.elc first, otherwise emacs wouldn't see any changes I made to sgml-mode.el. If you haven't done much elisp hacking, the .el is the lisp source, while the .elc is a byte-compiled version which loads quicker but isn't intended to be edited by humans. For Java programmers, the .elc is sort of like a .class file.)

Commenting out these four lines did the trick:

  (set (make-local-variable 'font-lock-syntactic-keywords)
       '(("\\(<\\)! *--.*-- *\\(>\\)" (1 "!") (2 "!"))))
  ;; This will allow existing comments within declarations to be
  ;; recognized.
  (set (make-local-variable 'comment-start-skip) "\\(?:\\)?")

To regenerate the .elc file so sgml-mode will load faster, I ran emacs as root from the directory sgml-mode.el was in, and typed:

M-x byte-compile-file sgml-mode.el

All better! And now I know where to find documentation for all those useful-looking, but seemingly undocumented, keyboard shortcuts that go along with emacs' html mode. Just search in the file for html-mode-map, and you'll find all sorts of useful stuff.

For instance, that typing Ctrl-C Ctrl-C followed by various letters: u gets you an unordered list, h gets you an href tag, i an image tag, and so on, with the cursor positioned where you want to type next.

It doesn't seem to offer any basic inline formatting (like <i> or <em>), alas; but of course that's easy to add by editing the file (or maybe even in .emacs). To add an <em> tag, add this line to html-mode-map:

    (define-key map "\C-c\C-ce" 'html-em)
then add this function somewhere near where html-headline-1 and friends are defined:
(define-skeleton html-em
  "HTML emphasis tags."
  nil
  "" _ "")

Of course, you can define any set of tags you use often, not just <em>.

HTML mode in emacs should be much more fun and less painful now!

Update: If you don't want to modify the files as root, it also works fine to copy sgml-mode.el to wherever you keep personal elisp files. For instance, put them in a directory called ~/.emacs-lisp then add this to your .emacs:
(setq load-path (cons "~/.emacs-lisp/" load-path))

Tags: ,
[ 22:48 Mar 29, 2006    More linux/editors | permalink to this entry | ]

Mon, 20 Mar 2006

Getting rid of all those .serverauth.???? files

Dave has been complaining for a long time about the proliferation of files named .serverauth.???? (where ???? is various four-digit numbers) in his home directory under Ubuntu. I never saw them under Hoary, but now under Breezy and Dapper I'm seeing the same problem.

I spent some time investigating, with the help of some IRC friends. In fact, Carla Schroder, author of O'Reilly's Linux Cookbook, was the one who pinned down the creation of the files to the script /usr/bin/startx.

Here's the deal: if you use gdm, kdm, or xdm, you'll never see this. But for some reason, Ubuntu's startx uses a program called xauth which creates a file containing an "MIT-MAGIC-COOKIE". (Don't ask.) Under most Linux distributions, the magic cookie goes into a file called .Xauthority. The startx script checks an environment variable called XENVIRONMENT for the filename; if it's not set to something else, it defaults to $HOME/.Xenvironment.

Ubuntu's version is a little different. It still has the block of code where it checks XENVIRONMENT and sets it to $HOME/.Xenvironment if it isn't already set. But a few lines later, it proceeds to create the file under another, hardwired, name: you guessed it, $HOME/.serverauth.$$. The XENVIRONMENT variable which was checked and set is never actually used.

Programmers take note! When adding a feature to a script, please take a moment and think about what the script does, and check to see whether it already does something like what you're adding. If so, it's okay -- really -- to remove the old code, rather than leaving redundant and obsolete code blocks in place.

Okay, so why is the current code a problem? Because startx creates the file, calls xinit, then removes the file. In other words, it relies on xinit (and the X server) exiting gracefully. If anything else happens -- for example, if you shut your machine down from within X -- the startx script (which does not catch signals) can die without ever getting to the code that removes the file. So if you habitually shut down your machine from within X, you will have a .serverauth.???? file from each X session you ever shut down that way.

Note that the old setup didn't remove the file either, but at least it was always the same file. So you always have a single .Xauthority file in your home directory whether or not it's currently in use. Not much of a problem.

I wasn't seeing this under Hoary because under Hoary I ran gdm, while with Dapper, gdm would no longer log me in automatically so I had to find another approach to auto-login.

For Ubuntu users who wish to go back to the old one-file XAUTHORITY setup, there's a very simple fix: edit /usr/bin/startx (as root, of course) and change the line:

xserverauthfile=$HOME/.serverauth.$$
to read instead
xserverauthfile=$XAUTHORITY

If you want to track this issue, it's bug bug 35758.

Tags: , ,
[ 21:24 Mar 20, 2006    More linux | permalink to this entry | ]

Sun, 19 Mar 2006

Pandora Now in Script-Fu

Periodically I get requests from people without C compilers (which usually means Windows users) who are interested in using my GIMP plug-in Pandora, which helps with making panoramic images by loading all the images, positioning them approximately, and adding layer masks. I always regret that I don't have a Windows binary to offer people.

I've been thinking for a while that it would be easy to do a Pandora plug-in in script-fu, so that any GIMP user could run it. The only reason Pandora was written in C is that it provides a modified file selection dialog allowing you to choose the files you want in sequence. But it's not like the UI for that dialog is any great shakes (it's always been confusing, even to me, and I wrote it), and of course it uses the old gtk file selector, which has been orphaned for quite some time.

The way to work around this in script-fu is to let the user open all the images as layers in a single image using the normal Open and Open as Layers functions, then transform that image into a panorama by resizing it bigger and moving the layers to the right place. Easy! It's been on my list to do for a long time, but I didn't get motivated to write it until this morning when I wasn't doing anything else and another Windows user showed up on #gimp asking about panoramas.

I should have done it earlier. It only took an hour or two, and works as well as the old C version. It's available on the Pandora page. Feedback or bug reports appreciated!

Tags:
[ 19:02 Mar 19, 2006    More gimp | permalink to this entry | ]

Sat, 18 Mar 2006

Linux Can't Print Envelopes?

I needed to send a formal letter, so I thought, as a nice touch, I'd print the address on the envelope rather than handwriting it.

I felt sure I remembered glabels, that nice, lightweight, straightforward label printing program, having envelope options. But nope, it doesn't have any paper sizes corresponding to envelopes. (It has a size called A10 but it's 1.0236 x 1.4567 inches, not the 4.13 x 9.50 I'd expect for a number-ten envelope.) Darn, that would have been perfect.

OpenOffice doesn't have anything in its templates list that corresponds to an envelope, nor does it have anything in the Wizards list. But googling showed me -- aha! -- that it's hidden in the Insert menu, Insert->envelope -- so if you want to create a new envelope document, create some other type of document first, go to Insert and bring up the envelope dialog, click New to get the envelope, then close the blank dummy document.

But then it doesn't offer a choice of envelope sizes, and puts the text in odd places so you have to fiddle with the margins to get the recipient and return address in normal places. Then, when you go to Preview or Printer Settings, it has forgotten all about the fact that it's doing an envelope and now tries to print in the middle of a sheet of paper. In theory you could fix this by setting the paper size to the size of the envelope -- except that OOo doesn't actually have any envelope sizes in its paper list.

Okay, let's try abiword instead. Abiword has a nice selection of paper sizes, including some common envelope sizes. Choosing A10 envelope and Landscape mode lets me compose a nice looking envelope. But then when I go to Print Preview, it turns out it wants to print it in portrait mode, with the addresses going across the short dimension of the envelope. The Print dialog offers a Paper tab which includes an Orientation dropdown, but changing that from Landscape to Portrait makes no difference: the preview still shows the addresses disappearing off the short dimension of the envelope.

I suppose I should try kword. But it depends on nine other packages, and I was tired of fighting. I gave up and wrote the address out by hand.

The next day, though, I went back to gLabels, poked around for a bit and found out about "Template Designer" (in the File menu). It's almost there ... it's easy to set up custom sizes, but it prints them in the middle of a US-letter page, rather than lined up against the edge of the printer's feeder. I'm dubious that you could feed real envelopes this way with any reliability. Still, it's a lot closer than the word processing programs could get.

Tags: ,
[ 18:36 Mar 18, 2006    More linux | permalink to this entry | ]

Fri, 17 Mar 2006

The Notch Gang

Our little squirrel family has grown to four. Notch has returned, after being gone for over a month, and now displays nipples like Nonotchka's. Turns out they were both females!

Notch is still as graceful, strong, and dominant as ever, and hangs around keeping Nonotchka from feeding. But we've found a solution: give Notch a nut in the shell, and she will take it off to bury it, which gives us a little time to sneak some nuts to Nonotchka before Notch flies back like a furry bolt of lightning.

Sometimes the ruse doesn't work. Once Dave went outside and chased Notch across the yard, over the fence and into the cedar while I communed with Nonotchka. Dave though he had her; but Notch vanished into the cedar branches, ran down the trunk and snuck under the gate while Dave was still watching the upper branches. Nonotchka only got a few nuts that time.

But that's not all. We have two other squirrels now, both apparently youngsters (they're scruffy, skinny, slightly smaller than our established squirrels, and markedly less graceful). One has white tufts between his ears, so I'm calling him Tuft; the other doesn't have a name yet and doesn't come by very often. They're both males, and yes, it is possible to tell when they're sitting up, contrary to some web pages I've seen.

Both of the kids are very nervous about us, and won't feed when we're anywhere in sight. But they're not nervous about Notch; the three of them sometimes eat at the same time, sitting on different parts of the fence, something Notch would never allow Nonotchka to do. Dave is convinced that they're Notch's kids from last year, and that he sees a family resemblance. The two kids sometimes quarrel mildly between themselves, and chatter at each other, but only when Notch isn't around; when she is, they're respectful and submissive.

Since the Notch Gang of three all tolerate each other, this makes it difficult to get any food to Nonotchka. She's taken to coming by later in the afternoons; the kids get up early in the morning, and Notch likes coming by around lunchtime.

Dave taped a little wooden shelf at the bottom of the office door where we can put nuts. Notch and Nonotchka learned it pretty quickly: not because they're any good at finding new nut sources (it takes them forever to notice a nut that's in a place where they don't normally find any; sometimes I wonder how the species survives) but because they're both bold enough to come to the door and look in when they're hungry, and eventually they bump their noses into the nuts on the shelf. Tuft is starting to notice the door-nuts, too, and will take one, then run off when he notices he's being watched.

I was able to get some photos of Nonotchka at the door (plus a few new shots of her outside in interesting poses). I tried to photograph Tuft today but he's too nervous.

Tags: , ,
[ 19:27 Mar 17, 2006    More nature/squirrels | permalink to this entry | ]

MySQL Losing its Socket!

This morning I was all ready to continue working on an ongoing web project when I discovered that mysql wasn't running.

That's funny, it was running fine yesterday! I tried /etc/init.d/mysql start, but it failed. The only error message was, "Please take a look at the syslog."

So I hied myself over to /var/log, to discover that mysql.log and mysql.err were both there, but empty.

Some poking around /etc/mysql/my.cnf revealed that logging is commented out by default, because: "# Be aware that this log type is a performance killer."

I uncommented logging and tried again, but /var/log/mysql.err remained blank, and all that was in mysql.log was three lines related basically giving its runtime arguments and the name of the socket file.

Back to the drawing board. I was well aware that I had changed the mysql settings yesterday. See, mysqld on Ubuntu likes to create its socket as /var/run/mysqld/mysqld.sock, but other apps, like Ruby, all expect to find it in /tmp/mysql.sock. It's easy enough to change Ruby's expectations. But then I found out that although the cmdline client mysql also expects the socket in /var/run/mysqld, it depends on something called mysqladmin that wants the socket in /tmp. (I may have those two reversed. No matter: the point is that you can't use the client to talk to the database because it and the program it depends on disagree about the name of the socket. This is probably a Dapper bug.)

Okay, so I had to pick one. I decided that /tmp/mysql.sock was easier to remember and more standard with non-Debian setups. I knew where to change it in the server (/etc/mysql/my.cnf is there and well commented) but the mysql client doesn't use that, and it took some googling and help from clueful friends to find out that what it wanted was a new file called /etc/my.cnf (how's that for a nice clear configuration file name?) containing one line:

socket          = /tmp/mysql.sock

That done, mysql started and ran and everything worked. Woo!

Except that it didn't the following morning after a reboot, and didn't give any error messages as to why.

Off I went on a merry chase across init files: /etc/init.d/mysql calls /etc/mysql/debian-start (which made me realize that debian has added yet another config file, debian.cnf, which has yet another copy of the line specifying the socket filename) which calls /usr/share/mysql/debian-start.inc.sh as well as calling various other programs. But those were all red herrings: the trick to debugging the problem was to run mysqld directly (not via /etc/init.d/mysql start: it actually does print error messages, but they were being hidden by using the init.d script.

The real problem turned out to be that I had changed the location of the socket file, but not the pid file, in /etc/mysql/my.cnf, which was also located by default in /var/run/mysqld. Apparently that directory is created dynamically at each boot, and it isn't created unless it's needed for the socket file (whether the pid file needs it doesn't matter). So since I'd moved the socket file to /tmp, /var/run/mysqld wasn't created, mysqld couldn't create its pid file and it bailed. Solution: edit my.cnf to use /tmp for the pid file.

Tags:
[ 13:29 Mar 17, 2006    More programming | permalink to this entry | ]

Wed, 15 Mar 2006

The Amazing Disappearing Nameservers

I updated my Ubuntu "dapper" yesterday. When I booted this morning, I couldn't get to any outside sites: no DNS. A quick look at /etc/resolv.conf revealed that it was empty -- my normal static nameservers were missing -- except for a comment indicating that the file is prone to be overwritten at any moment by a program called resolvconf.

man resolvconf provided no enlightenment. Clearly it's intended to work with packages such as PPP which get dynamic network information, but that offered no clue as to why it should be operating on a system with a static IP address and static nameservers.

The closest Ubuntu bug I found was bug 31057. The Ubuntu developer commenting in the bug asserts that resolvconf is indeed the program at fault. The bug reporter disputes this, saying that resolvconf isn't even installed on the machine. So the cause is still a mystery.

After editing /etc/resolv.conf to restore my nameservers, I uninstalled resolvconf along with some other packages that I clearly don't need on this machine, hoping to prevent the problem from happening again:

aptitude purge resolvconf ppp pppconfig pppoeconf ubuntu-standard wvdial

Meanwhile, I did some reading. It turns out that resolvconf depends on an undocumented bit of information added to the /etc/network/interfaces file: lines like

dns-nameservers 192.168.1.1 192.168.1.2
This is not documented under man interfaces, nor under man resolvconf; it turns out that you're supposed to find out about it from /usr/share/doc/resolvconf/README.gz. But of course, since it isn't a standard part of /etc/network/interfaces, no automatic configuration programs will add the DNS lines there for you. Hope you read the README!

resolvconf isn't inherently a bad idea, actually; it's supposed to replace any old "up" commands in interfaces that copy resolv.conf files into place. Having all the information in the interfaces file would be a better solution, if it were documented and supported.

Meanwhile, be careful about resolvconf, which you may have even if you never intentionally installed it. This thread on a Debian list discusses the problem briefly, and this reply quotes the relevant parts of the resolvconf README (in case you're curious but have already removed resolvconf in a fit of pique).

Tags: , ,
[ 15:22 Mar 15, 2006    More linux | permalink to this entry | ]

Tue, 14 Mar 2006

Quick GIMP Tips: Centering a Layer, or Preventing Centering

People are forever turning up on #gimp to ask (quite reasonably) how to center a layer, since GIMP offers no built-in way to do that.

There are Python and Perl scripts around somewhere (and it's easy to write, a great project if you're thinking about learning how to write GIMP scripts in any language). And the new Align tool can probably center, for those using GIMP 2.3, but the tool is a bit difficult for most people to figure out (fear not, the UI is still being developed).

But for those who want a quick solution:

Center a Layer:

Cut, then paste. The pasted layer comes out centered. (Unfortunately this loses text information, so if it's a text layer this isn't an ideal solution.)

Paste a layer on top of a copy of itself:

Do a Layer to Imagesize before copying. Then copies of the layer will overlap the original.

Tags:
[ 19:51 Mar 14, 2006    More gimp | permalink to this entry | ]

Mon, 13 Mar 2006

Ruby on Rails on Ubuntu

Back when I laboriously installed Ruby and Rails on Ubuntu "Hoary Hedgehog" (which involved basically ignoring all the Ubuntu packages and building everything, including Ruby itself, from source), I was cheered by the notes in Ubuntu's forums and bugzilla indicating that as of the next release ("Breezy Badger") all the right versions would be there, and all this source compilation would no longer be necessary.

I didn't get around to trying it until today. Breezy and its successor "Dapper Drake" do indeed have a rails package as well as a Ruby package, and I happily installed them. All looked great -- until I actually tried to use them on a real-world application. It turns out that the Ruby and Rails packages don't include gems, Ruby's package manager (similar to the CPAN system familiar to Perl programmers). And gems is required for doing anything useful in Rails.

Drat! After several false starts, I eventually found the instructions on this page. Except that installs way more than seems necessary for what I need to do, and if you copy/paste lines from that page you may end up with a bunch of packages you don't want, like an out of date version of mysql.

So here are simplified instructions for using Ruby on Rails on Ubuntu Breezy or Dapper.

As yourself:

wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar zxvf rubygems-0.8.11.tgz
As root:
cd rubygems-0.8.11
ruby setup.rb
gem install rubygems-update
gem install rails

Say yes to all dependency questions during the gem install of rails. Add your web server and database of choice (you probably already have them installed, anyway) and you should be good to go.

You may note that the page I referenced tells you to install two versions of rails: the Ubuntu package plus the one from gems. At least on Dapper, you don't need both. Installing rails pulls in the packages:
irb irb1.8 libpgsql-ruby1.8 libreadline-ruby1.8 libredcloth-ruby1.8 libruby1.8 rake rdoc rdoc1.8 ruby ruby1.8
I haven't experimented with which of these packages are and are not needed. If you run into problems, some set of packages from this list may solve them.

Update: it seems that none of these are required. Many of them are dummy packages anyway, which contain no files related to the actual package name. For instance, the rake package contains, not rake, but a single bash completion file related to rake. So you should be fine ignoring all of them, installing just Ruby and nothing else.

(I filed bug 34840 requesting that Ubuntu ship a usable version of Rails, since it didn't seem to be filed already.)

Tags:
[ 22:56 Mar 13, 2006    More programming | permalink to this entry | ]

Tue, 07 Mar 2006

Nonotchka has had her litter

Nonotchka has had her litter. Or at least she lost the tummy and regained her old svelte and graceful form as of yesterday afternoon. Of course, we haven't seen any squirrelets; she'll have them stashed away in a nest somewhere safe.

We're slightly worried about her. She came to eat today as usual (ravenously: she ate ten hazelnuts all at once then took several more away to bury), and although she seemed friendly and energetic, she left blood spots on Dave's jeans. I hope this is just some sort of normal postpartum condition and not an injury. She didn't seem to be in pain. (I get this from Dave; I was away when she made her visit. She's definitely spending less time here now that she has a family to take care of.)

So we'll keep an eye on her, make sure she's well fed and hope that she's okay and that in a few months she might start bringing the kids by. Apparently grey squirrels nurse for an amazing three months before they're ready to go out on their own. There are usually four to a litter.

(Update the following day: She seems fine. She's still energetic and hungry, and there's been no more blood.)

Meanwhile, Notch is gone. We haven't seen him at all since getting back from our trip. We're getting occasional visits from a new squirrel: scruffy, young-looking and not terribly well coordinated. Dave thinks the newcomer is a male. He's confused about nuts, or well fed from someone else's yard: he'll sniff at a hazelnut in the shell then leave it where it lies. Perhaps he just doesn't like hazelnuts and is holding out for a walnut.

It seems odd that this scrawny newcomer could have chased the burly, graceful and confident Notch away from his territory. My guess is that Notch decided there was some other yard he liked better, since even before the trip we'd been seeing him only infrequently.

Tags: , ,
[ 23:30 Mar 07, 2006    More nature/squirrels | permalink to this entry | ]

Thu, 02 Mar 2006

Nonotchka is going to be a mom!

We went away for a week, to visit family for my grandmother's 100th birthday (yay, Grandma!) Of course, before we left we made sure our squirrels had lots of nuts buried, so they weren't dependent on the shelled nuts we've been feeding them.

When we got back, Nonotchka wasted little time in visiting us, and she's just as friendly as ever (to someone with a walnut in hand). But there are some other changes. At first, we weren't sure if she seemed fatter; but eventually we saw her from angles that left no doubt. And her belly fur has changed; instead of the brownish grey, now it's white like Notch's, except for six dark spots arranged in pairs down her abdomen.

Looks like we guessed right about Nonotchka's gender (well, we had a 50% chance) and she's going to be a mom!

I hope we get to see the baby squirrels when they're old enough to leave the nest. Maybe she'll even bring them by when they're old enough to be weaned.

We haven't seen Notch at all since we got back. I hope he's all right. He'd been spending a lot of time across the street anyway, so perhaps he's found a territory he likes better than our yard.

Tags: , ,
[ 12:29 Mar 02, 2006    More nature/squirrels | permalink to this entry | ]

Sun, 05 Feb 2006

Auto-Login, and X Without gdm

I've been unable to persuade Ubuntu's "Dapper Drake" to log me in automatically via gdm. My desktop background flashes briefly during the login process, then vanishes; it appears that it actually is logging me in briefly, then immediately logging me out and presenting me with the normal gdm login screen.

I never liked gdm much anyway. It's heavyweight and it interferes with seeing shutdown messages. The only reason I was using it on Hoary was for autologin, and with that reason gone, I uninstalled it.

But that presented an interesting problem: it turns out that Dapper doesn't actually allow users to run X. The error message is:

Unable to open wrapper config file /etc/X11/Xwrapper.config
X: user not authorized to run the X server, aborting.
The fix turned out to be trivial: make the X server setuid and setgid (chmod 6755 /usr/bin/X). Mode 4755 (setuid only, no setgid) also works, but other Debian systems seem to set both bits.

The next question was how to implement auto-login without gdm or kdm. I had already found a useful Linux Gazette article on the subject. The gist is that you compile a short C program that calls login with your username, then you call getty with your new program as the "alternate login program". Now, I have nothing against C, but wouldn't a script be easier?

It turns out a script works too. Replace the tty1 line in /etc/inittab with a line like:

1:2345:respawn:/sbin/getty -n -l /usr/bin/myloginscript 38400 tty1
where the script in question looks like:
#! /bin/sh
/bin/login -f username

At first, I tried an even simpler approach:

1:2345:respawn:/bin/login -f username

That logged me in, but I ended up on /dev/console instead of /dev/tty1, with a message that I had no access to the tty and therefore wouldn't be able to use job control. X didn't work either. The getty is needed in order to switch control from /dev/console to a real virtual terminal like /dev/tty1.

Of course, running X automatically once you're logged in is trivial, just a line or three added to .login or .profile (see the Linux Gazette article referenced above for an example).

It works great, it's very fast, plus I can watch shutdown messages again. Nice!

Update 9/9/2006: the Linux Gazette article isn't accessible any more (apparently Linux Journal bought them and made the old articles inaccessible). But here's an example of what I do in my .login on Dapper -- this is for tcsh, so bash users subtitute "fi" for "endif":

    if ($tty == tty1) then
        startx
    endif

Tags: , ,
[ 11:53 Feb 05, 2006    More linux | permalink to this entry | ]

Sat, 04 Feb 2006

Ubuntu "Dapper Drake"

I've been meaning to upgrade my desktop machine from Ubuntu's "Hoary Hedgehog" release for some time -- most notably so that I can get the various packages needed to run GTK 2.8, which is now required to build the most current GIMP.

Although I'm having good success with "Breezy Badger", the stable Ubuntu successor to "Hoary", on my laptop, Breezy is already borderline as far as GIMP requirements, and that can only get worse. Since I do more development on the desktop, I figured it was worth trying one of the pre-released versions of Ubuntu's next release, "Dapper Drake".

Wins over hoary and breezy: it handles my multiple flash card reader automatically (on hoary and breezy I had to hack the udev configuration file to make it work).

I've had a few glitches, starting with the first auto-update wanting to install a bunch of packages that didn't actually exist on the server. This persisted for about a week, during which I got a list of 404s and "packages held back" warnings every time I updated or installed anything. It didn't seem to hurt anything -- just a minor irritant -- and it did eventually get fixed. That's life with an unstable distribution.

Dapper has the same problem that hoary and breezy have with hald polling the hard disk every few seconds (bug 27323). In addition, hald seems to spawn a rather large number of hald-addon-storage processes (probably to handle the built-in multi flash card reader). (Uncommenting the storage.automount_enabled_hint in /etc/hal/fdi/policy/preferences.fdi didn't help.) Killing hald (and nuking /usr/sbin/hald so it won't restart) solves both these problems, but it also stops hotplugged USB devices from working: apparently Dapper has switched to using hal instead of hotplug for USB. Ouch! In any case, hald came back on a dist-upgrade so it looks like I'll have to find a more creative solution.

The printing packages have problems. I tried to add my printer via the CUPS web interface, but apparently it didn't install any printer drivers by default, and it's not at all obvious where to get them. The drivers are there, in /usr/share/cups/model/gutenprint/5.0/en, but dapper's cups apparently isn't looking there. I eventually got around the problem by uncompressing the ppd file and pointing CUPS directly at /usr/share/cups/model/gutenprint/5.0/en/stp-escp2-c86.5.0.ppd. (Filed bug 30178.)

Dapper's ImageMagick has a bug in the composite command: basically, you can't combine two images at all. So I have to generate web page thumbnails on another machine until that's fixed.

gdm refuses to set up my user for auto-login, and I hit an interesting localization issue involving GIMP (I'll report on those issues separately).

Most other things work pretty well. Dapper has a decent set of multimedia apps and codecs, and its kernel and udev setup seem to work fine (it can't suspend my desktop machine, but neither can any other distro, and I don't really need that anyway). Except for the hald problem, Dapper looks like a very usable system.

Tags: ,
[ 19:27 Feb 04, 2006    More linux | permalink to this entry | ]

Thu, 02 Feb 2006

Suburban Squirrels

In early December, a squirrel staked out our yard as part of his territory. We encouraged him with nuts. He has a notch in one ear, so I called him "Notch".

Later that month, another squirrel showed up. Sometimes Notch chased the new squirrel (especially when food was involved), but at other times they seemed to be playing in a friendly way. Apparently December is breeding time for squirrels.

There's no easy way to identify the gender of grey squirrels (at least from a distance), so we arbitrarily decided that the larger, tougher and more territorial Notch was a male, and the newcomer must be female. Dave dubbed her "Nonotchka".

(Of course we're hoping that in a few months it will become obvious which one is actually the female, and soon afterward we will have little squirrels to watch.)

Both Notch and Nonotchka have become rather tame (though not quite to the point of taking food from our hands), and we've been able to get some decent (though not spectacular) photos while feeding them. Unfortunately, the final review process for the GIMP book got in the way of organizing the photos or writing squirrel essays, and I'm only now starting to catch up.

So here they are: our Suburban Squirrels.

Tags: , ,
[ 15:57 Feb 02, 2006    More nature/squirrels | permalink to this entry | ]

Mon, 30 Jan 2006

The GIMP Book is Done!

Although I haven't been writing about it here, for most of the past year I've been working on a new GIMP book for Apress, called Beginning GIMP: From Novice to Professional.

Today the work was over: the last bits shipped to the printer! The rest is just waiting (... and waiting ... and waiting ...)

Amazon has a page on it already (complete with typo in the description; sigh) for folks who like to pre-order their books months early. Scheduled release date is currently late April. (I think they have to grow the trees first.)

In case you haven't already heard other authors say it, writing a book is a lot more work than you think it will be. Even if other authors have already told you that it's more work than you think it will be, it's more work than that. If you thought you already knew the subject you were writing about, think again. You'll find out how little you really knew. You'll discover all sorts of options you never noticed in your favorite tools, and new (and often better) ways to do things than the methods you'd been using for years. You'll discover bugs in plug-ins no one's used in a while, and why things you always thought were bugs really aren't.

That's the good sort of "too much work": the kind that keeps you learning, so that you come away from it with more than you started with. It's been fun. But I confess that I'll be glad to take a rest for a while and work on some long neglected coding projects.

I celebrated ship-to-printer with a little GIMP hacking (adding that feature list to configure that I wished for last week, so now GIMP will warn you of any missing features before you start your 45-minute build); and with lamb kebab with zereshk polo at Chatanoga.

Tags:
[ 22:38 Jan 30, 2006    More gimp | permalink to this entry | ]

Tue, 24 Jan 2006

What Features will be Disabled in this GIMP?

I've been frustrated for some time at GIMP 2.3's inability to save EXIF data whenever I save a JPEG image. There were several bugs report on the problem, and I just assumed that this was something which had broken somewhere along the line and hadn't been fixed yet.

It turns out it was a stupid build problem on my machine: I didn't have libexif-dev installed on either of my Ubuntu systems, and GIMP's configure script wasn't warning me about it in any obvious way. (Of course, had I taken the time to read through the 3679 lines of config.log, the information was buried in there around line 2199.)

So now I have EXIF again, at least on the laptop (hooray!) but I also learned something more important: after running configure for the first time on any new system, before running make, do this:

grep -i "will not" config.log

That may not flag everything, but at least it's a start at getting a list of features that have been disabled because of dependencies you forgot to install (anything which configure is smart enough to tell you "will not be built").

Schumaml had the great idea of putting a list of enabled features in the About box. Maybe I'll look into doing that in a week or two (when the current crunch is over and I have more time to upgrade my development machine so that it can use gtk 2.8 and I can actually build GIMP again).

Update: I added a printout similar to the one I thought I remembered, so there should be no further need to grep for "will not".

Tags:
[ 15:11 Jan 24, 2006    More gimp | permalink to this entry | ]

Thu, 12 Jan 2006

The New Rootkit Technology

Anyone who's been following the Sony CD rootkit story -- the one where Sony audio CDs come infected with a program which, when the CD is played on Windows PCs, installs a rootkit which is virtually impossible to uninstall and which makes the PC susceptible to all sorts of third-party attacks -- won't want to miss Trend Micro's information page regarding Sony's rootkits.

Highlight:

This tool works by applying a relatively new technology called rootkit technology. Rootkits are used to hide system information, such as running processes, files, or registry entries.

As a standalone application, it is non-malicious. However, certain malware applications use it [ ... ]

Good thing Trend Micro is there to give us the lowdown on this new (and non-malicious) rootkit technology!

In a vaguely related note: a speaker at my Toastmasters club today planned a Powerpoint presentation. (This is unusual in Toastmasters, but does happen occasionally.) He diligently showed up early to set up his computer and the projector so he'd be ready before the meeting started. As we were about to begin the meeting, with the projector showing his first slide, suddenly a dialog popped up on top of the slide, informing him that his system auto-update was finished, and he needed to reboot. It offered two buttons: [Reboot now] [Reboot later]. The later button was greyed out.

Isn't it nice when your system helpfully gives you automatic updates?

He fiddled for a while but finally gave up and rebooted. I couldn't help noticing that the first screen that appeared upon reboot was a Trend Micro screen.

Tags:
[ 21:17 Jan 12, 2006    More tech | permalink to this entry | ]

Sat, 07 Jan 2006

Who Says GIMP Skills Can't be Profitable?

Slate's "Today's Papers" column brings us word of a Wall Street Journal article (alas, subscribers-only) describing a new service: Friends Beyond the Wall Photos. For a small fee, an image from a prison photo can be combined with photos of families, vacations, or posh cars to make it look like you've been on holiday with the kids rather than behind bars! No more need to explain why those visiting room photos have such a drab background!

And here I thought learning GIMP skills was just an amusing hobby.

Tags:
[ 21:41 Jan 07, 2006    More humor | permalink to this entry | ]

Wed, 04 Jan 2006

Ubuntu "Breezy Badger"

I installed the latest Ubuntu Linux, called "Breezy Badger", just before leaving to visit family over the holidays. My previous Ubuntu attempt on this machine had been rather unstable (probably not Ubuntu's fault -- 2.6 kernels and this laptop don't get along very well) but Ubuntu seems to have some very sharp kernel developers, so I was curious to see whether there'd been progress.

Installation: Didn't go well. I had most of the same problems I'd had installing Hoary to this laptop (mostly due to the installer assuming that a CDROM and network must remain connected throughout the install, something that's impossible on a laptop where both of those functions require sharing the single PCMCIA port). The Breezy installer has the additional "feature" that it tends to hang if you change things like the CDROM while the install is in progress, trashing everything and forcing you to restart from the beginning. (Filed bug 20443.)

Networking: But eventually I found a sequence that let me get a network-less Breezy onto the laptop, and I'm happy to report that Breezy's built-in networking tools were able to add networking after the first boot (something that hadn't worked in Hoary). Well, admittedly I did have to add a script, /etc/hotplug/pci/3c59x, to call ifup when my cardbus network card is plugged in; but every other distro needs that too, and Breezy is the first 2.6-based distro which correctly calls the script every time.

Suspend: Once up and running, Breezy shows impressive laptop savvy. Like Hoary, it can suspend either to disk or to RAM; unlike Hoary, it can do this without my needing to hack any config files except to uncomment the line enabling suspend to RAM in /etc/default/acpi-support. It does print various error messages on stdout when it resumes from sleep or hibernate, but that's a minor issue.

Not only that, but it restores both network and usb when resuming from suspend (on hoary I had to hack some of the suspend scripts to make that work).

(Kernel flakiness: Well, mostly it suspends fine. Unplugging a usb mouse at the wrong time still causes a kernel hang. That's a 2.6 bug, not an Ubuntu-specific problem. And the system also tends to hang and need to be power cycled about one time out of five when exiting X; perhaps it's an Xorg bug.)

Ironically, my "safe" partition on this laptop (a much- modified Debian sarge) mysteriously stopped seeing PCMCIA on the first day away from home, so I ended up using Breezy for the whole trip and giving it a good workout.

Hal: One problem Breezy shares with Hoary is that every few seconds, the hald daemon makes the hard drive beep and whir. Unlike Hoary, which had an easy solution, Breezy ignores the storage_media_check_enabled and storage_automount_enabled hints. The only way I found to disable the beeping was to kill hald entirely by renaming /usr/sbin/hald (it's not called from /etc/init.d, and I never did find out who was starting it so I could disable it). Removing hald seems to have caused no ill effects; at least, hotplug of pcmcia and usb still works, as do udev rules. (Filed bug 21238.

Udev: Oh, about those udev rules! Regular readers may recall that I had some trouble with Hoary regarding udev choking on multiple flash card readers which I solved on my desktop machine with a udev rule that renames the four fixed, always present devices. But with a laptop, I don't have fixed devices; I wanted a setup that would work regardless of what I plugged in. That required a new udev rule. Here's the rule that worked for me: in /etc/udev/permissions.rules, change

BUS=="scsi", KERNEL=="sd[a-z]*", PROGRAM="/etc/udev/scripts/removable.sh %k 'usb ieee1394'", RESULT="1", MODE="0640", GROUP="plugdev"
to
BUS=="scsi", KERNEL=="sd[a-z]*", NAME{all_partitions}="%k", MODE="0640", GROUP="plugdev"
Note that this means that whatever scripts/removable.sh does, it's not happening any more. That doesn't seem to have caused any problem, though. (Filed bug 21662 on that problem.)

Conclusion: Overall, Breezy is quite impressive and required very little tweaking before it was usable. It was my primary distro for two weeks while travelling; I may switch to it on the desktop once I find a workaround for bug 352358 in GTK 2.8 (which has been fixed in gnome cvs, but that doesn't make it any less maddening when using the buggy version).

Tags: , ,
[ 22:43 Jan 04, 2006    More linux | permalink to this entry | ]