Shallow Thoughts : : Sep

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

Tue, 18 Sep 2007

It's Spider Season

It's nearly autumn, and that's the time of year when a girl's heart turns to ...

   BIG FAT HAIRY SPIDERS!

That's right, the tarantulas are on the move.

[tarantula] Mostly, tarantulas are hard to see. They stay in their underground burrows for most of their lives; if they do come out of the burrow, it's likely to be at night.

But for a few weeks each fall, male tarantulas become more adventurous, when they emerge from their burrows and wander in search of females. The females stay snug underground, but the males can often be spotted on roads and trails, if you know where and when to look.

Ah, but where and when? I've seen tarantulas numerous times at Alum Rock Park (in San Jose) and at Arastradero (in Palo Alto) ... but not in the last four years. In recent years, Dave and I have gone out every October looking for spiders, and have struck out locally. (Fortunately we've had better luck on trips, so not all of these years were completely tarantuless -- we've found them in places like Arizona's Valley of the Gods and Utah's Kolob Canyon.)

This year, we got started early, in September. We had no luck at Alum Rock last weekend, so this evening we took a late-afternoon hike a little higher up in the east bay hills, at Grant Ranch.

On the trail by Grant Lake, we got rattled at by a fairly large western rattlesnake, saw an underground beehive as well as lots of small wasps, watched a flock of wild turkeys down by the parking lot, and found a lovely feather from the blue heron at the lake.

But ... no spiders. So we got back in the car and continued up Mt Hamilton Rd toward the upper parking lot (Twin Gates). About two-thirds of the way there, Dave spotted our quarry: a tarantula crossing the road. We found a pullout and ran back with cameras.

After the photo session, we continued up the road to Twin Gates for another mini-hike. Again, we saw no tarantulas on the trail -- just hawks and kites, an oak tree covered with acorn woodpecker holes (with the woodpeckers themselves darting among the branches), and another oak tree being killed by mistletoe.

We returned to the car and headed back down the road -- and bagged the day's second spider, scurrying across one of the roadside pullouts. A nice end to the day's spider hunt!

Photos of the two tarantulas are here.

Tags:
[ 23:16 Sep 18, 2007    More nature | permalink to this entry | ]

Fri, 14 Sep 2007

Science Complex

The new semester started last week. I'm taking a class that's held in a new building:

[Science Complex]

When Dave first saw the building, he laughed. "No wonder they're complaining that fewer students are taking science and math classes -- they're sending the wrong message! They ought to call it 'Science Simple'. Then they'd get lots of students signing up."

Tags:
[ 22:12 Sep 14, 2007    More humor | permalink to this entry | ]

Sat, 08 Sep 2007

Custom beep sounds

It's always amazed me that Linux doesn't let you customize the system beep. You can call xset b volume pitch duration to make it beep higher or lower, or you can turn it off or switch to "visual bell"; but there's nothing like the way most other OSes let you customize it to any sound you want. (Some desktops let you customize the desktop alerts, but that doesn't do anything about the beeping you get from vim, or emacs, or bash, or a hundred other programs that run in terminals.)

Today someone pointed me toward a Gentoo wiki page that led me to Fancy Beeper Daemon. This is a small kernel module that adds a device, /dev/beep, which outputs a byte every time there's a beep. You can write a very simple daemon (several samples in Python are included with the module) which reads /dev/beep and plays the sound of your choice.

I downloaded beep-2.6.15+.tar.gz, but it needed one tweak to build it under 2.6.23-rc3: I needed to add

#include <linux/sched.h>
among the includes at the beginning of beep.c. After that, it compiled and installed just fine. Since it's a kernel module, it works in consoles as well as under X.

/dev/beep is created with owner and group root, and readable/ writable only by owner and group, so to test it I had to chmod 666 /dev/beep to run the daemon. I fixed that by making a file in /etc/udev/rules.d called 41-beep.rules, containing:

KERNEL=="beep", GROUP="audio"

Finally, based on the nice samples that came with the module, I wrote my own very simple Python daemon, playbeepd, that uses aplay.

Lots of fun! I don't know how much I'll use it, but it's good to have the option of custom beep sounds.

Tags: , ,
[ 21:47 Sep 08, 2007    More linux | permalink to this entry | ]

Tue, 04 Sep 2007

Egg Timer in Python and TkInter

I left the water on too long in the garden again. I keep doing that: I'll set up something where I need to check back in five minutes or fifteen minutes, then I get involved in what I'm doing and 45 minutes later, the cornbread is burnt or the garden is flooded.

When I was growing up, my mom had a little mechanical egg timer. You twist the dial to 5 minutes or whatever, and it goes tick-tick-tick and then DING! I could probably find one of those to buy (they're probably all digital now and include clocks and USB plugs and bluetooth ports) but since the problem is always that I'm getting distracted by something on the computer, why not run an app there?

Of course, you can do this with shell commands. The simple solution is:

(sleep 300; zenity --info --text="Turn off the water!") &

But the zenity dialogs are small -- what if I don't notice it? -- and besides, I have to multiply by 60 to turn a minute delay into sleep seconds. I'm lazy -- I want the computer to do that for me!
Update: Ed Davies points out that "sleep 5m" also works.

A slightly more elaborate solution is at. Say something like: at now + 15 minutes and when it prompts for commands, type something like:

export DISPLAY=:0.0
zenity --info --text="Your cornbread is ready"
to pop up a window with a message. But that's too much typing and has the same problem of the small easily-ignored dialogs. I'd really rather have a great big red window that I can't possibly miss.

Surely, I thought, someone has already written a nice egg-timer application! I tried aptitude search timer and found several apps such as gtimer, which is much more complicated than I wanted (you can define named events and choose from a list of ... never mind, I stopped reading there). I tried googling, but didn't have much luck there either (lots of Windows and web apps, no Linux apps or cross-platform scripts).

Clearly just writing the damn thing was going to be easier than finding one. (Why is it that every time I want to do something simple on a computer, I have to write it? I feel so sorry for people who don't program.)

I wanted to do it in python, but what to use for the window that pops up? I've used python-gtk in the past, but I've been meaning to check out TkInter (the gui toolkit that's kinda-sorta part of Python) and this seemed like a nice opportunity since the goal was so simple.

The resulting script: eggtimer. Call it like this:

eggtimer 5 Turn off the water
and in five minutes, it will pop up a huge red window the size of the screen with your message in big letters. (Click it or hit a key to dismiss it.)

First Impressions of TkInter

It was good to have an excuse to try TkInter and compare it with python-gtk. TkInter has been recommended as something normally installed with Python, so the user doesn't have to install anything extra. This is apparently true on Windows (and maybe on Mac), but on Ubuntu it goes the other way: I already had pygtk, because GIMP uses it, but to use TkInter I had to install python-tk.

For developing I found TkInter irritating. Most of the irritation concerned the poor documentation: there are several tutorials demonstrating very basic uses, but not much detailed documentation for answering questions like "What class is the root Tk() window and what methods does it have?" (The best I found -- which never showed up in google, but was referenced from O'Reilly's Programming Python -- was here.) In contrast, python-gtk is very well documented.

Things I couldn't do (or, at least, couldn't figure out how to do, and googling found only postings from other people wanting to do the same thing):

I expect I'll be sticking with pygtk for future projects. It's just too hard figuring things out with no documentation. But it was fun having an excuse to try something new.

Tags: , ,
[ 14:35 Sep 04, 2007    More programming | permalink to this entry | ]