Friday, August 15, 2008

Kevin Kempter

I met Kevin Kempter at a CLUE Installfest.

Kevin was hauling around gear in a great, Marine Corps bag. I thought, "Hah! Another jarhead. Hey ... how can I get one of those bags?"

He'd had the same thought. On a visit to MCRD, he saw a guard with the same bag, and asked him where he could get one.

"They're only for active-duty Marines, so I'm not allowed to tell you that if you go down that way one block and over two, you'll find the PX. Sir."

"Interested in giving a BLUG talk?" I asked Kevin.


"What would you talk about?"


Turns out, people are interested in Postgres.

Kevin played to a standing-room-only crowd last night.

He told us he has one client who's now pulling in a terabyte of data a day, and expects to expand this by a factor of 100.

Thursday, August 14, 2008

Apache Status

You can get your apache2 (and, I suspect, apache) server to display status information on prefab server-status and server-info pages by loading the status and info modules and tweaking the configuration files to pay attention to them.

Having done that, http://localhost/server-info and http://localhost/server-status
will tell you what modules are loaded and what they do. With little more work, you can also permit access to these pages by other boxes.

I set this up yesterday at work, but haven't done it at home because this laptop isn't serving up web pages at all.

Monday, August 11, 2008


I spent part of the weekend playing with gitosis, a tool for administering remotely-accessible git repositories.

Access revolves around ssh and public/private key pairs. You give me your public key, and I can grant you selective permissions, repo-by-repo, if I'm the gitosis administrator. Once I do, it's painless to check stuff in and out, since all the permissions stuff is under-the-covers. Much nicer than Subversion's cacheing of passwords in plain text.

One of the coolest things is that the administrative data, including public keys, are kept in a git database. If I'm the (or an) administrator, I can administer access remotely, with git pull and git push -- including adding new users and their keys -- using gitosis itself for the repo access.

Sunday, August 10, 2008

Error-handling, again.

Here's a better version of my error-handling shell functions. Maybe I am educable, after all.
# common error-handling functions

if [ $_gripe ]; then return 0; else _gripe=1; fi # include guard

warn() { printf "$* at line %s file %s: $msg\n" $(caller) 1>&2 ; }
die() { printf "$* at line %s file %s: $msg\n" $(caller) 1>&2 ; exit -1; }
I have an include guard so I can include it in other shell functions that may be included with one another. I use if, rather than a [test] || alternative construct because I'm often running set -e, and don't want to die because of the test itself.

I have die() printing its own message, instead of calling warn(), so that it reports where it's invoked. Otherwise, warn() announces it's being called by die(). Duh.

It amazes me that after doing this for so long, I can still be fixing bugs in my own code -- and code as basic as this.

Saturday, August 9, 2008

Making Makefiles Behave: Loops

The last command in a shell for loop determines whether the loop succeeds or fails.

This succeeds:
$ for i in false true; do echo $i; $i; done
$ echo $?
This fails
$ for i in true false; do echo $i; $i; done
$ echo $?
When does this matter? In Makefiles. Suppose you have a make rule that looks like this:
for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done
A failure of one of the subdirectory makes will not cause the make to fail!

How do you solve this? There are several sophisticated ways, but the dead-easy way is to start the Makefile like this:
SHELL := /bin/bash -e
This will cause all shell commands to be executed with the -e flag, which causes any simple command to terminate the shell.
$ ( set -e; for i in false true; do echo $i; $i; done )
$ echo $?
(I have to put the command and the set -e in parens here -- though not in the Makefile -- because any failure causes the command to fail and the shell to exit, so the following "echo $?" would never be reached.

Tuesday, August 5, 2008


For fun, I've set up CruiseControl on my laptop.

It's annoyingly hard to configure, and there seems not to be an rpm for Ubuntu, but it works.

I have it set up to watch a git repository, and build "hello, world." I can push to the repository from elsewhere and trigger a new build.


Sunday, August 3, 2008

Google Chat-Bots for Translation

I use the Google chat-bots for quick translations. Here's an illustration from a note to a friend:
For whatever reason, I looked at the story you gave me, saw "laberintos," and thought, "Shouldn't that be 'labArintos'?"

So I popped up a chat window in gmail, invited <> to chat, and typed in "labyrinth." It responded,

I said, "thank you," to which it replied "Gracias." :-)

Now that Google has group chat, you can invite a pair of simultaneous translators to join, and have chats with people you don't even share a language with. Mostly, though, I use them for quick translation: it's easier than going to a website.

Update: I just looked, and Google has added many more translation-bots.

Monday, July 28, 2008

Sort-of Techical Problems, Sort-of Technical Solutions

I subscribe to the Boulder Linux Users' Group mailing list. It's my local LUG, it carries announcements of local events, and the posts are mostly technical.

Plus, when you know folks, it's fun to see what they think and how they write. I read the stuff Sean Reifschneider posts even when I have no clue what he's talking about.

The opposite's true, too. I started going to Dave Anselmi's Installfests just to meet him and Collins Ritchie. I'd been so impressed by their steady, helpful contributions to the mailing list that I wanted to see what they looked like.

Oh, sure, there's an occasional call to boycott a large company because they buy closed-source software.

In some cases, these move me to action. As soon as I learned Microsoft uses Microsoft products in-house, I stopped buying stuff from Microsoft.

In other cases, not so much. King Soops? I still shop there.

And, once in a while, some poster decides it's important we all read about their far-left political views. But what do you expect from the People's Republic of Boulder Linux Users' Group?

Mostly, though, the signal-to-noise ratio is high.

Just now, however, we've had a couple of back-to-back flamefests running that swamp out the parts I find useful.

At first, I thought, "Oh well. If this is going to turn into Slashdot, I'll unsubscribe."

Then I realized that I have a technical solution at hand. Gmail lets me, with a single keypress ('m'), mute threads I'm not interested in: they no longer show up in my mailbox. As long as no one hijacks the thread, by changing the subject line, I can go back to reading the stuff I'm interested in.

The thread, meanwhile, continues to go into my archives, so if I suddenly become passionate and want to flame, too, I can retrieve it.

I suppose there's a chance my mailbox will fill up with the stuff, but even if Google stopped giving me more space today, a quick back-of-the-envelope calculation says I'll be 72 before my mailbox fills up.

I can live with that.

I Need Google Gears, not Prism

The Lifehacker list of favorite software and hardware is mostly non-Linux or things like Gmail that I already use. Prism, however, is neither.

I've looked and I don't want it.

Prism, from Mozilla Labs, is a single-app browser. For example, it lets you create something that will run only RememberTheMilk. They call this a "customized webapp."

The advantage? It's distraction-free. The disadvantage? It's still a browser.

Unfortunately, mostly what I want isn't freedom from distractions, it's performance. My major annoyances aren't the icon that says I have new mail -- I put that icon there, after all -- but network slowdowns.

Unfortunately, the best solution I've seen, Google Gears, often isn't available for the webapps I use. I mean, there's no Google Gears for Gmail!

And often, it's broken. Every new Firefox seems to break Gears.

If Mozilla Labs wants to help me, I hope they put some time into fixing the last of these problems.

Sunday, July 27, 2008

Exporting HTML from Tomboy Notes

I've now tried Tomboy Notes, so I know what it can do.

spent part of yesterday fussing with a little Java/Design Patterns project. I made some progress, but the most practical benefit was taking notes on what I was doing with Tomboy -- not because the notes helped, but because I'd never really tried Tomboy out.

One useful feature is its "Export to HTML" option. I spent a few hours noting what I was doing, as I was doing it, then exported the note. Here's the result, with no editing. After the export, it puts up a web page in the browser. From there, getting it here took three keystrokes: mark all (^A), cut (^C), and paste (^V).

HFP-July 26

  • Unpacked a bunch of stuff from the book's web site. It includes code for all examples.
  • Learned, from one of the downloaded textfiles, that I can run using a classpath with java -cp.
  • Hacked their ant build.xml file to works with my weatherstation data.
  • Verified that ant, like make, notices times.
  • Fixed an eclipse installation hiccup by paying attention to eclipse's output, which told me how to fix it.
  • Put weatherstation under git, and tried out git commit --interactive
  • Put all this into Tomboy Notes in a notebook called hfp-diary, for an excuse to play with TN. Tried out fonts, exporting to HTML, navigating menus with the keyboard.
  • Successfully, though unintentionally, removed my entire project, including the git repository. :-( After my hacking build.xml, ant clean wiped the entire directory.
  • Copy the code over from the book, and experiment with various things in git, to try to keep from wiping out the code again.
  • Get rid of the project lines, so that the sucker will compile and run.
  • Figure out how to get a run configuration set up. This is tedious, but I suppose I'll get used to it.

Saturday, July 26, 2008

Character Mis-placement in Firefox

Can anyone tell me why the diacriticals in Hebrew-character fonts, like the ones in this article, are misplaced, when I look at it in Firefox?

If you look at words containing alephs, you'll see that most of them have a little mark underneath the character to its left. The mark should be under the aleph itself. This makes the words hard to read, and is a bit like having the dots on every 'i' appear over the following character.

Background info, not directly relevant.
  • The text is in Yiddish, not Hebrew. Yiddish is a Germanic language, like English, but uses the Hebrew alphabet for the same reason we use the Latin alphabet: the people who started writing the language picked an alphabet they already knew. Hebrew-language text has the same problem.
  • The diacriticals are under the following character, not the preceding one. Hebrew script, like this, is written right-to-left, not left-to-right.
  • The diacriticals change the character -- just like drawing a horizontal line across the top of an 'l' turns it into a 'T'. One of the characters is silent, a second is an 'o', a third is an 'a'.

Friday, July 25, 2008


ReviewBoard seems to be getting some interest as an open-sourced code-review tool. I like the slogan:

Code reviews are fun again! ...almost.

Wednesday, July 23, 2008

3 Things

Get CC stuff reproducible.
Fix LF build.
Read through Randy's document.

Monday, July 21, 2008


The newest "Plutoid" (almost a planet) is called makemake. The claim is that it's named after "a Polynesian creator of humanity and god of fertility."

Oh, nonsense.

Eclipse and Design Patterns

I'm learning design patterns. Frank Stahl told me, about a similar subject, "You sure do know how to have fun."

Marcia Derr and I went to Caffe Sole yesterday, in the heat, and tried to slog through the very beginning of Head First Design Patterns by Eric Freeman, et al. (O'Reilly and Associates).

The book is a little verbose and cutesy for all our tastes, but it's what we had. Mostly, we just tried figuring out how to compile and run Java programs and how to use Eclipse.

In the end, we got an example to run. The second example, we're still stuck on; they seem to use a class they don't supply a definition of.

Still, it was a pleasant way to spend a Sunday afternoon. Frank Stahl told me, about a similar subject, "You sure do know how to have fun."

Sunday, July 20, 2008

Command-Line Tricks

I got diverted by a presentation by Simon Myers this morning and have spent time messing around with the shell.

I've used these before, and particularly like shell-expand-line for editing my path.

Put this into ~/.inputrc and arrange to re-read it (say, by starting a new shell).
$if Bash
Control-x: shell-expand-line
Now you get this behavior from the shell (which is giving you command-line editing throug readline(3) ).
# now type control-x
$ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/jsh/bin/bash_functions:/home/jsh/bin:/usr/local/libexec/git-core:
# and the path is there, ready for editing
I can get a lot of his tricks to work, but I can't bind "yank-last-arg" in vi mode. Works fine in emacs mode (Meta-.), but I'm a vi guy. I'm doing something wrong, but I don't know what.

Friday, July 18, 2008

A Tool With Many Uses: The Local Yum Server

I've set up a yum server, at work. This achieves several ends:
  • It lets us mirror the Fedora distro we're using locally, so we can pull and update packages faster.
  • It gives us a single place to stick third-party rpms. No more asking developers to "go out and get package X from web site Y."
  • It gives me a single distribution point for things I produce. I don't have to give developers a login on my box, or find a common server to ftp things to and from, I can just stick an rpm on the server and have them install it with yum.

Thursday, July 17, 2008

Expanding Windows, a Mouse-Click at a Time

I accidentally learned how to maximize my windows in just one direction: click a different mouse button.

At least in Gnome, clicking the "maximize window" decoration with the left mouse button expands it to the size of the screen (if the app permits).

However, clicking the same decoration with the right mouse button expands it horizontally, to the width of the screen, and clicking with the middle mouse button maximizes it vertically.

Paired, sequentially (right click, middle click) they act like a single left click. Indeed, they work the way you'd think in all combinations.


Wednesday, July 16, 2008

Setting Defaults Properly

Problem: I have a new developer who wants to check something into Subversion. He tries, and is mystified by svn's message, telling him he has to set the environment variable $EDITOR.

Solution: I tell him to set the environment variable.

(Okay, this should read "Problem: My software developers can't read." It's still a problem.)

git, in contrast, has this one figured out. From the git-config man page:
Commands such as commit and tag that lets you edit messages by
launching an editor uses the value of this variable when it is set,
and the environment variable GIT_EDITOR is not set. The order of
preference is GIT_EDITOR environment, core.editor, VISUAL and
EDITOR environment variables and then finally vi.
Yes, it isn't quite grammatical. The author's Finnish. Give him a break. "... and then finally vi." This because every Posix-conforming system is required to have a text editor named vi that acts according to the IEEE spec. (It can be a superset, like gvim, but it has to respond correctly to the basic commands.)

Richard Stallman and the FSF were asked for an emacs spec to put into Posix (Stallman named Posix, by the way), but they refused, so there's no guarantee that a Posix-conforming system will have it, out of the box.

A Twisty Maze of Symlinks, All Different: readlink -f

Which of the vi clones on your system are you using? Do you know?

In Linux, when more than one installed executable could reasonably have the same name a common solution is to make the executable in /bin or /usr/bin a symlink to an entry in /etc/alternatives.

The /etc/alternatives entry, in its turn, symlinks to the real executable. Or, maybe to another symlink to ...

Finding the ultimate executable in this twisty maze of symlinks, all different, can be an Adventure. The solution? readlink.

Here's an example, with java:
$ which java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2007-11-05 15:14 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 36 2008-04-26 07:10 /etc/alternatives/java -> /usr/lib/jvm/java-6-sun/jre/bin/java
$ ls -l /usr/lib/jvm/java-6-sun/jre/bin/java
-rwxr-xr-x 1 root root 47116 2008-03-25 03:01 /usr/lib/jvm/java-6-sun/jre/bin/java
$ readlink -f /usr/bin/java
$ readlink -f $(which java)
Beware: readlink won't warn you if something's not a symlink (okay) or doesn't exist (not okay):
$ ls -l /home/jsh/java
ls: cannot access /home/jsh/java: No such file or directory
$ readlink -f /home/jsh/java
$ echo $?

Friday, July 11, 2008

Tom Tromey and Stormy Peters

Tom Tromey did a fun BLUG talk about emacs last night, with slides he did in, well, you know, emacs.

As you can see from the pictures, it's all downhill from here.

He recommends the emacs wiki, which is created with EmacsWikiMode.

Tom's worked on a pile of stuff over the years, including the Gnu Java compiler, and both automake and autoconf.

Perhaps the video will be up soon. I hope it does as much for his career as her recent talk at BLUG did for Stormy Peters.

What's the hardest thing about switching from emacs? Getting the deposit back when you return a garage full of empty Alt-Meta-Cokebottles.

Wednesday, July 9, 2008

It's Dead, Jim

When one of my machines, at work, died, I announced, "It's dead, Jim." (Damnit, Jim, I'm a doctor, not a system administrator!)

Bob Percival said, "... and it wasn't even wearing a red shirt."

Well, I knew how to fix that.

Seeing Colors when Colorblind, and an Admonition on Bug Reports

Here's a site that lets you fix your color presentations so the colorblind can see them, too.

Many folks don't realize that 8% of northern-European, white males are red-green colorblind. One in thirteen.

When I worked for a printer company, I tried to persuade them to make a color space that would transform images in the way this site does, but didn't make any headway. With frequencies like that, I figured we could make sales just by showing large-company CIOs the results. Once in every dozen or so, we'd get a guy who said, "At last!"

A former co-worker, Gary Stormo, got so fed up with presentations he couldn't follow that he made his point in a talk he was giving about his research. He put up a complicated graph, with half a dozen lines, all the same color, and said, "The red line shows ...."

I pointed some of my friends at "Daltonize," and Tom Schneider immediately found and reported a bug.
Here's his note.

Unfortunately, the image, which accompanies this post, bounced because their mail system decided it was too big.

Always make your mail system limits big enough to accept bug reports.
Dear Vischeck:

I tried your nice Daltonize program at

and was surprised one time to get the top two images from some other image, while the bottom two were from my image.

Looks like a bug where your system got the images confused.

Since this doesn't always happen I assume it means that two requests can end up in the same image space sometimes if they are made nearly at the same time. My guess is that this will be easy to fix in your code.

Tuesday, July 8, 2008

Hyperlinks to the CPAN

My resume now has hyperlinks.

My pal, Marcia, observed that now that you can put resumes on-line, you can have links in them.

I have one on Google Docs (not available for public consumption), so I spent time last night playing with that. In the process, I was pleased to discover that someone has put a few things I've done up on the Comprehensive Perl Archive Network.

Makes me think I should put more things on-line so I can link to them.

Monday, July 7, 2008

Portland Pics

I just went to visit my sisters, in Portland, for their birthdays. Hooray.

Here are some pictures. The first two are poppies. The next two are roadside weeds.

Sunday, June 29, 2008


Here are three species of Oenothera. Left to right, we see a yellow O. missouriensis, a white O. pallida, and a pink O. speciosa.

Oenothera generates so many dramatic variants, so frequently (for interesting reasons) that Hugo DeVries coined the word "mutation" when working with it.

We now know that these aren't mutations in the current sense of that word; it was the right idea for the wrong reason.

Better Error Reporting in Shell Scripts

In the spirit of Perl Best Practices, here's improved error-reporting functions for shell scripts:
warn() { printf "$* at line %s file %s\n" $(caller) 1>&2 ; }
die() { warn $*; exit -1;}

Friday, June 27, 2008

Blog Photos in Picasa

I just discovered that all pictures I upload into a blog post are automatically tossed into a Picasa album.

I see them all if, for example, I'm in Gmail and click on the link to "Photos," in the list of services along the top.

This is quite clever of Google, I think.

Searches in Firefox 3

It's now easier to do keyword searches for search engines.

Search, above everything else, was what I remember noticing when I first switched to Firefox. What a good idea! I search a lot, from my browser.

I added a couple, and then discovered it's easier to add search engines than it used to be, so I added the Weather channel, with a keyword, too.

Thursday, June 26, 2008

The CPAN is a Mixed Blessing

The Comprehensive Perl Archive Network (CPAN) was the first serious package manager I ever saw. It seems to have stagnated.

When I first saw it, it seemed miraculous. If you asked it for something, not only did it get what you want and install it, it also got everything the package you'd asked for depended on! Amazing.

Yesterday, I got a Debian package, for one of my Ubuntu boxes, that had some Perl stuff. I'd already gotten pieces of it (maybe all of it) from the CPAN, at some forgotten point in the past. The versions clashed.

Ah! No problem. The new version's right. I'll just remove the CPAN version.

Oops! There is no CPAN "uninstall." My choices now are to update via the CPAN in addition to everything else, or to un-install my box and start over.


Wednesday, June 25, 2008

Perlcritic Whines at Me

I spent the evening playing with perlcritic, which criticizes my code based on the rules in Damian Conway's Perl Best Practices.

Every violation points to a page number, which turns out to be very useful.

Warnings come in levels: --gentle, --stern, --harsh, --cruel, and --brutal. It took me all evening to get a (very) simple Perl program to pass "brutal," but I did learn a lot.

Tuesday, June 24, 2008

New (to me) Desktop Tricks

Sometimes, just knowing a new desktop trick makes my day.

I offer three I learned in the last 24 hours:
  • F11, in Firefox, gives "full-screen mode." When you need the decoration, move your mouse up to the top of the screen and it reappears so you can use it. If you want to come out of full-screen mode, press F11 again.
  • A new set of updates appeared for Compiz Fusion, which made me go look at the options (System -> Preferences -> Advanced Desktop Effects Setting). Turn on 3-D menus, then you spin the cube.
  • Also, I like setting the cube to be transparent during rotation. ( set ... -> Desktop Cube -> Transparent Cube->Opacity During Rotation to 0)
Okay, time to reboot my box with a new kernel.

Monday, June 23, 2008

I can Write MathML, I just Can't Use It.

I want an equation-writing tool that will let me write equations in posts and email. I'm making progress, but still don't have something that's as easy as I want.

I found OpenOffice Math (oomath) will let me do stand-alone equation generation, and gives me the option to save the result as MathML. If I name the output file "whatever.xhtml" it displays just fine as a web page, in Firefox.

It won't, however, let me cut-and-paste into email or into blogger posts.

Friday, June 20, 2008

Execute Permissions on Directories

Tom Schneider, who does cool stuff at the NIH, just passed me this question:
> Ok I used chmod a+X regulon. Didn't know that directories had to be
> executable, that's kinda odd.

I agree, it is odd. It would be interesting to know why that is the case.

I'll cc this to Jeff Haemer, my friend who may know.
Sho 'nuff.

It doesn't make sense to "execute" a directory, so Unix used the extra bit for something else: searchability. Watch:
$ mkdir /tmp/foo
$ echo Molecular machines > /tmp/foo/toms
$ chmod -r /tmp/foo
$ ls -l /tmp/foo
ls: cannot open directory /tmp/foo: Permission denied
$ chmod +r-x /tmp/foo
$ ls -l /tmp/foo
ls: cannot access /tmp/foo/toms: Permission denied
total 0
-????????? ? ? ? ?
? toms

Thursday, June 19, 2008

Seeing Digital Diffs with Firefox Downloads

Well, it's nice that Firefox set a new world record -- out of the gate they got 4% of the browser share -- but, to be fair, anything would have been a new Guiness world record. It's a category that never existed before.

This, however, is an interesting graph. Who'd have thought Lithuania would see three times as many downloads as Russia, and that Austria would be an also-ran?

Wednesday, June 18, 2008

Dead-Tree Lists

I've been keeping to-do lists in RememberTheMilk, and recommend it.
But lately, I seem to have shifted to pen and paper. I don't know what that's about, but yesterday I went to the supply room and got a bound notebook to do it in. I don't really like the feel of the paper, but I'll try that for a while.

Tuesday, June 17, 2008

On the Other Hand ... Google Docs Does PDF

On the other hand, Google Docs now does PDF, too. Still, just read, but let's see if they beat Open Office to letting me write it. :-)

Yesterday, I got email with an attached .odt document. Gmail asked whether I wanted to look at it as a Google document. I said "Yes," and it came up fine. Another recipient asked for a copy in Word format "so people could read it."

I saved it in "Word format" -- Word 6, Word 95, and Word 97 -- and sent him all three. The first two were only 6 times the size of the .odt document. The third was ten times the size.

Saturday, June 14, 2008

Gears Back in Firefox 3

Gears seems to be working in Firefox 3, finally.

It was said that Firefox 3 was going to create its own "Google-Gears-like" stuff, whatever that means. That's nice. I want Gears now, and it was irksome that it stopped working in Firefox 3.

It's back, and I'm glad. It looks like Gears could turn into a bigger deal than I'd imagined, and I thought it was a big deal.

PDF in OpenOffice

You can now edit PDFs in OpenOffice.

Adobe's been noxiously reluctant to give us a PDF writer for Linux. Perhaps this'll fix it. Unfortunately, the extension needed for this requires PDF3.0, and I'm still at 2.4.

Thursday, June 12, 2008

Little, Scratch Spreadsheets

I want to do some experiments to time my access to CVSDude. Google Spreadsheets gives me a good place to stash the data.

Access speed for CVSDude has been very slow, in bursts. Is it our internet access, or is it CVSDude? I want to do a bunch of experiments, both at home and at work. Not earth-shaking data, but it's nice to have a place to stash them while I'm doing the work.

Google Docs lets me pop them into one spreadsheet, either place. Nice.

Wednesday, June 11, 2008

Sharing Equations

Well, now I know one way to cut-and-paste equations into Blogger and Gmail.

  1. Create the equations in Open Office, as "Formula Objects" (Insert->Object->Formula and go from there.)
  2. Send the to myself as email attachments.
  3. Open the attachments as Google Documents. The formulae show up as images.
  4. Cut-and-paste the image of the formula from the Google Doc to Blogger or Gmail.
Here's an example:

There are undoubtedly ways to simplify this process, but it's a start.

Tuesday, June 10, 2008

Is There an Easy Way to Put Equations in Posts?

I've spent yesterday evening figuring out how to create equations on my computer.

Lyx, which is supposed to be easy, just crashed. OpenOffice is a little more clumsy, but useable.

Having done it, I now can't figure out how to cut-and-paste from them into things like email or this post. I can attach documents or take screenshots, but that's pretty clunky.

Some forms are, however, clunkier than others. A simple equation that takes 10K in .odt (OpenOffice) format is 104K in Windows-97 format: a factor of 10 explosion.

If you're reading, and know how I can get equations into gmail or blogger posts, speak up.

Monday, June 9, 2008

Computer Algebra Bleg

Anyone reading have any experience with symbolic algebra packages on Ubuntu? I'm not seeing much posted out there -- a bunch of launchpad entries and one recommendation of maxima and wxmaxima.

I want something that makes it dirt-easy to type in equations and get symbolic answers: I type in something like this

x**2 - 2*s*x + s**2 = 0

and I get back

x = s

I do want, however, to be able to do systems of equations.

[Bumped, to get some other posts in the correct order. Besides, this didn't get any replies anyway. :-) ]

Bumblees: Installing the Nest

To finish up, here's K installing the "nest" next to the house. (This second post's because Blogger wouldn't let me put all of them in one post.)

All this just completed yesterday evening.

She says there's no guarantee it'll work, but she's done it successfully before.

Bumblebees: Making the Nest

Here are pix my friend Joyce demanded I take. I only got my thumb in two of them. :-)

You'll see K taking stuffing from an old mattress in our garage, lining a flower pot, putting a little honey into it, adding the queen bumblebee she caught (which she'd stuck in the fridge, and is still alive), and putting backing on it.

Thursday, June 5, 2008

3-D Printers

This article, on self-replicating machines, echoes a conversation I had when I worked at a printer company.

On a tour of the NCAR shop, arranged by an old pal, and fine fiddler, Charlie Martin, I saw a 3-D printer they were using to prototype parts.

I went back to work the next day, and said, "We ought to be building these."

I explained that, if nothing else, once we got good at them, we could have the printers print us copies of themselves.

Someone I was explaining this to, I think Louis Krupp, said this was short-sighted. We should, instead, have them print customers.

Wednesday, June 4, 2008

Goosh: the Google Shell

I've been on vacation off and on for weeks. Fun, but time to get back in the saddle. Here's a cute site I wish I'd done, Goosh, the Google shell.

Several comments about it at Lifehacker are interesting and useful.

Wednesday, May 28, 2008

Public Google Forms and Spreadsheets for Dummies

Here's step-by-step instructions on how to create and publish a Google spreadsheet, together with a web-based form that makes entries into it.

You could use this for everything from arranging rides to scheduling a party.
  • Go to
  • Click on New and choose spreadsheet.
  • Click on the title, "Unnamed Spreadsheet", and enter a title.
  • Enter column headings into row 1, across the top.
  • Click on the "Share" tab.
  • Under "Invite people:" choose "to fill out a form."
  • Click on "Start editing your form..."
You'll now see a form with the title you gave the spreadsheet, and a slot for each column.
  • Fill in the box below the title, which says "You can include any text or info that will help people fill this out."
  • Press "Next, choose recipients."
If you want email the form, fill in the To: list. Otherwise, just go on.

Now to embed the form in a web page,
  • Click on "Embed", in the upper-right-hand corner.
  • Copy the link location to that web page, as instructed.
Next, we publish the spreadsheet, which will change as folks fill out the form:
  • Go back to the spreadsheet and click the "Publish" tab.
  • Press "Publish now".
It will give you a URL where folks can see the spreadsheet, but that's not what you want yet.
  • Click the bottom link, "More publishing options."
A window will pop up called "More published formats."
  • Click "Generate URL."
  • Copy the link location and paste it into whatever web page you want to display the spreadsheet on.
You now have one web page with a form folks can enter data into, and another that's the spreadsheet to display the data.


What are That Spreadsheet and Form About?

A couple of posts back, I have a spreadsheet and a form, with no explanation.

Here's why I posted them, and a how-to:

Last weekend, I went to a music festival put on by the New Mexico Folk Music and Dance Society (FolkMADs), in Socorro, NM. The weekend before, I went to a local festival, the Colorado Planters' Moon Festival, in Gold Hill, CO.

I had to arrange airport transportation for both. Last weekend, I had to get between Albuquerque to Socorro. The weekend before, I helped out-of-town folks get from DIA to Gold Hill and back. My arrangements for the MoonFest were ad hoc, but Lisa Bertelli published a spreadsheet with ride arrangements for New Mexico: one sheet with riders, one sheet with folks offering rides.

Lisa's scheme seemed much better.

I wanted to see how easy it would be to set up something like hers with a Google spreadsheet, because doing so would make it possible to embed the spreadsheet right in the website for a festival, where folks could fill in their needs or offers themselves.

It was dead easy, and the posts are a demo. The next post is a step-by-step.

Thursday, May 15, 2008

Working Under Test-Driven Development

We're trying to submit some u-boot patches at work. The maintainer, Wolfgang Denk, has given us several useful suggestions about formatting.

First-cut, I wrote a utility that, I thought, would reformat code correctly. Not enough.

Yesterday, Jim Black, who's making the fixes, told me that instead of a pretty-printer, he wanted something that would just tell him when there were problems. I can do that.

"Also, there's a lot more rules," he said, showing me his growing list.

This time, I decided to create the screening tool using test-driven development:
I'd write a test case and a test, then write the code. I'm not done yet, but I have a growing suite of tests that test a tool of growing capability.

And, as we learn new rules, I'll just add tests as I add the capabilities.

This morning, in the shower, I thought of a fundamental design change I want to make to the overall tool. When I do it, I'll just run it through the test suite, to make sure it works.

Stay tuned.

Wednesday, May 14, 2008

Interesting Blog Spam

I got two interesting pieces of blog spam today, on an older blog. Both looked like email from a real person, but with links to ads. Either someone's typing these in, or there's a marvelous piece of code out there.

Both were comments on google-calendar-related posts. The first reads only

italian property has left a new comment on your post "Google Embeddable Calendar Helper":

I use this and must say it is a great resouce.

The second is
Helen Siff has left a new comment on your post "Calendaria":

I use an electronic calender with reminders today it beeped to tell me of my doctors appointment and again about one and half hours later that I need to buy my home base furniture, I could not live without my calender it is so useful.
They're really different from one another -- one only has a link in the commenter's name, the other right in the comment. The second message also has much more content.

Both are calendar-related. Both have spelling mistakes. Still, they're pretty interesting pieces of work.

Tuesday, May 13, 2008

Git Stash Lets You Snapshot All Your Stuff

I keep the home directory on my laptop under git.

Last night, I read a trick in a good article, Git from the bottom up, by John Wiegley, that I tried out this morning.

git stash stashes away the current state of your world (the index), and replaces it with the HEAD. git stash apply restores the stash. The pair snapshots your work, but leaves it unchanged.

I now run this command as an hourly cron job:
# snapshot the current repository

git stash
git stash apply
Here's the crontab entry:
# | hour (0-23)
# | | day of the month (1-31)
# | | | month of the year (jan-dec)
# | | | | day of the week (sun-mon, with 0=sun)
# | | | | | command
# | | | | | |

01 * * * * ~/bin/snapshot &> /dev/null
The snapshots, however, are all accessible through the reflogs, which means that my states are stashed, hourly, invisibly to me, but I can get them back pretty easily.

If there have been no changes, git stash notices, and does nothing, so the hourly job doesn't fill my logs with irrelevant entries.

Very nice.

Monday, May 12, 2008

FontStruct Lets You Build Your Own Fonts

I'm hoping for a review of the free, font-design service, FontStruct, from my font guru, Jeff Copeland.

I found out about it from LifeHacker, which is always chock-a-block full of useful tips.

Sunday, May 11, 2008

Open Office Breaks Out

Now that I've started seeing OpenOffice being pimped on everyday blogging sites, I know that the battle's over.

It's not being advertised as cheaper than Word, it's being advertised as better.

Can't get better than a plug on Instapundit. I think the OpenOffice folks should give him a free copy.


Stephe Walli reminds me to post this link.

Saturday, May 10, 2008

Bash "nohup"s Background Jobs

In the old days, if you had a background job running, and you accidentally killed your terminal window, the job was killed with it. A special command, nohup ("no hangup"), would prevent this; it detached the job from the terminal's process group.

You can still find /usr/bin/nohup, but bash now automatically nohups all background jobs. Try this from a new terminal window:
$ { sleep 20; echo DONE > /tmp/OUT; } & sleep 1; exit
The window will die, but if you look in another window (or, after 20 seconds, in /tmp/OUT), you'll see the backgrounded job continues.

I say this because I still see admonitions to nohup jobs.

Friday, May 9, 2008

Firefox 3.05beta Grayout

My Firefox 3 beta goes gray annoyingly often. Last night, at BLUG, Kevin Fenzi said that it's a bug related to SQLite, and the workaround is to uncheck the tracking of problem sites, in the Preferences menu.

I haven't decided whether to give that a try, or just wait for the upgrade.

I also notice that someone, on the Google Group used to track Gears tasks inside Google, claims to have fixed the Gears/Firefox 3 incompatibility. I'll believe that one when it shows up. I like the idea of Gears, so it's a pity I can't use it now.

Wednesday, May 7, 2008

Patching U-boot: an Excursion Into the Open Source Process

Yesterday, Jim Black had our first open-source patch rejected -- this one to u-boot.

We'd expected it to be rejected, since we don't know what we're doing yet. We're climbing the learning curve.

Our troubles began when we discovered we needed a public ftp site, which the company didn't yet have. (You could argue that our troubles began when we started doing software, but that's too snarky.)

Dean Johnson, our sysadmin, spent some time Monday night getting one set up, and it was down by the next morning. We couldn't figure out why, so we set up another, on a different box and used it to submit the patch. By the time Denks picked it up, an hour or so later, it was down, too.

He asked us to submit the patch via email, and immediately pointed out a variety of style-and-formatting problems -- spaces instead of tabs, lines that are over 80 characters, and so on.

We think we've fixed those, and will re-submit another try this morning. Stay tuned.

Sunday, May 4, 2008

My New, Easy-to-Use, Mac ftp Client

"Can you show me how to do ftp on my Mac?"

That was the question from my pal, Spider, which popped up in my "chat-in-gmail" window yesterday afternoon.


I don't happen to know the GUI Mac ftp clients, but that's no barrier. Just go to the "ftp://" URL in firefox. Works for me.

For her, it hangs.

Back to basics. Let's see if she has /usr/bin/ftp.

"Open a terminal window."

"How do I do that?"

Now she's fumble-fingering things because of time pressure. Turns out she's asking for help in a panic, because she's got to get out the door and she needs to retrieve some publications from the web.

I have a Mac next to me, so now I'm trying everything out before I tell her, so as not to miss any steps.

She has ftp. Good. She can make the connection. Good. She miss-types a few things, but finally gets in. Good. Something's still not working. She's ready to give up.

"Wait," I say. "I know how to do this."

I do the ftp. I attach the files to an email message. I send it to her.

"Thank you, honey," she says, as she prints them and heads out the door.

I think I'll call it jftp: Jeff-tp.

Saturday, May 3, 2008

Github and Lighthouse

Since Git is the new hotness, and all, I needed to start expanding my brain.

One thing I need to do is play with the hosting services that are coming out -- the analogues to CVSDude for CVS/SVN.

There are a couple, so I started with Github, which is hosting Ruby on Rails, the old hotness. Unsurprisingly, their site is built on Rails, and looks very web-2.0-y.

Github boasts integration with both Lighthouse and Basecamp, two services folks might want to use to track defects and other project-related information, so I wanted to give it a shot. I started with Lighthouse, because I'd used Basecamp before.

Mmmf. The documentation sucks. It took a couple of hours of playing to get even the simple stuff to work. You need to set up a post-commit hook, which they provide -- they offer a pair of choices, actually, but I don't yet know the difference. You download the code, install it in .git/hooks/post-commit, and fill in the blanks. But with what? The directions aren't clear at all, either to me or to other folks using them. And, because it's two independent sites interacting, it's not even clear who to ask for help.

The verdict: potentially nice stuff, which I'll try out some more, but certainly not yet cooked.

Friday, May 2, 2008

Git Delta Chains

I've been playing with git, the new hotness.

One thing I've been puzzled by is the packs; they seem to be almost undocumented. Git stores objects, at request and periodically, in compressed form, in packs. (It also looks like it packs before doing transfers among clones.) These packs are indexed, for better access, but it's a standard, space-time tradeoff.

What's explained in even less detail is the delta chains. Some files in the pack are stored as deltas against other files. These deltas aren't history-based, they're just done by-guess-and-by-golly, and how compressed the pack is depends on how much time you give git to generate them.Link

This all sounds cool, but I wish I could find more documentation. If you see any, let me know.

Thursday, May 1, 2008

Hardy Heron Work-Arounds

I got my world clock to work by choosing "Denver" as my location, instead of "Boulder." I suspect it just knows about airports, since there's a list of sub-places for Denver, and they all look like airports. Still, that doesn't completely explain it, since Boulder has an airport, too -- it's just smaller.

Checking Place Windows, to select that compiz-fusion plugin (System->Preferences->Advanced Desktop Effect Settings) fixes the "windows open under the panel" problem.

After a huge amount of unsuccessful hacking, I finally made my desktop box at work completely unuseable. adamk, in #compiz-fusion, on Freenode (IRC), showed me what to remove and install to get the right drivers. "Then reboot and cross your fingers." When it came back up, it all just worked.

Well, except for printing, but that never works. :-) Maybe today.

Wednesday, April 30, 2008

Hardy Problems

As I continue to explore Hardy, I find things wrong.

As with any distro, all is not roses, yet.

I accidentally deleted some pictures, and discovered that there's no ~/.trash. Nor do I see a trashcan icon. Where did they go? Luckily, "locate trash" found ~/.local/share/Trash/files.

The "world clock" (click on the calendar) seems to work, but doesn't display my weather, even though it's supposed to.

Monday, April 28, 2008

Dinner 2

Dinner deserved seconds. So do the photos.


Not enough photo-blogging lately. Here's dinner.

Sunday, April 27, 2008

Hardy Hedgehog

I spent the last day upgrading to Hardy Hedgehog.

The upgrade takes about twelve hours. (I've done it twice, now.) This may speed up when the servers aren't getting hammered, but the second time, I just started it before I went to bed and let it run all night. By the time I got up the next morning, everything left to do (clicking to accept a handful of installation choices) was local.

On the first box, a desktop, tracker crashed and complains. I filed a bug. On my laptop, I turned off the pretty screen-saver because it kept freezing. Also, on the laptop, compiz fusion keeps opening my windows under the panel, so to move them, I have to use Alt-left-click. I filed another bug.

On the good side, the laptop, which I'd had to fuss around with some on Gutsy, just came up and worked. The new default settings are for full, compiz-fusion eye candy, which is nice. I suspect an interaction with the screen-saver to be the "freeze" problem, so I'm willing to live with the trade.

I haven't tried the wireless yet -- maybe it's improved, too. :-)

It all seemed pretty painless.

Friday, April 25, 2008

Github: A Git-Repository Hosting Site

I started poking at github this week. At first, I thought, "What's the point of a centralized, hosting site for git, which is inherently distributed?" Then
I remembered that I'm already using a git repository at

This is useful stuff. Even if I don't host anything important there, it helps me re-think some of my SCM assumptions and clear up my mis-conceptions.

Tuesday, April 22, 2008

This is Only a Test

Here and there, you'll see the syntax
if [ -f scriptname -a -x scriptname ]
if [ -f file1 -o -f file2 ]
These should, nowadays, be re-written like this:
if [ -f scriptname ] && [ -x scriptname ]
if [ -f file1 ] || [ -f file2 ]
Here's an opportunity for a little shell archaeology. In the old days, when men were men and giants walked the earth, test was a stand-alone executable. ( [ foo ] is a synonym for test foo ).

Actually, it still is:
$ ls /usr/bin/test
-rwxr-xr-x 1 root root 23036 2007-09-29 06:51 /usr/bin/test
In fact,
$ ls -l /usr/bin/[
-rwxr-xr-x 1 root root 25024 2007-09-29 06:51 /usr/bin/[
(Now you see how [ foo ] works in older shells.)

Old shells weren't nearly as powerful as newer ones, and in order to do even a simple test operation, you had to invoke a separate executable.

You can argue this is clean and minimalist, giving the shell only the roles that it has to have -- indeed, people make analogous arguments about microkernels -- but it's not efficient: to invoke the test sub-process, the kernel needs to fork() a subshell, and then exec() a new executable. To make things even messier, both these are kernel calls, which offers the risk of a process swap. All for a simple test.

Still, if you have to do that, it's more efficient to do both tests inside the new, test process than to return and invoke a second sub-process to do the second test. That is, [test1 -a test2 ] means "Do test1 and test2, and make me use an ugly syntax to tell you that while you're at it."

In fact, the syntax of test can get quite messy, but never mind that: you don't need it any more. The shell now offers its own, built-in versions of test, &&, and || .
$ type test
test is a shell builtin
Moreover, || and && both provide short-cut evaluation, just as in C.

Monday, April 21, 2008

xclip: A Cut-and-Paste Aid

I'm forever cutting and pasting, snarfing-and-barfing, Jake Edge calls it. What's that you say? You too?

Do you know about xclip? I didn't.

I just saw a post somewhere that suggested using
cat big-file-name | pbcopy
to put a large file into the clipboard. "Ooooh!" I thought. "A command that captures stdin and slaps it into the clipboard? I could use that for a lot of things."

First, I tried apt-get install pbcopy. No such package. How about apt-cache search pbcopy? Nothing.

When I Googled "pbcopy ubuntu" I learned why: pbcopy is an OS/X tool. For Ubuntu, the analogue is xclip. (And sudo apt-get install xclip works.)

By default, xclip puts its input into the X Windows clip buffer (duh), but I've also defined an alias to get me used to using pbcopy:
alias pbcopy='xclip -selection clipboard'
I've found that if I have a work-alike to a command in another distro, making an alias with the same name is a good didactic tool; it helps me get used to the command and makes it portable. Your mileage may vary.

So, fabulous stuff. I'll just write this post in vi, cat it into pbcopy, and use ^V to paste it into Blogger. Um. No. Neither that, nor a simple xclip seems to work. I can paste it into a text file, but not into blogger.

More investigation is needed.


Ah. xsel (from the package of the same name) works much better.

Friday, April 18, 2008

Everybody Makes Mistmakes

There are mistakes I make over and over and over. One of them is forgetting that every command in a make rule is a separate shell.

Make is the tool that makes the most use of shell scripts. Makefiles are full of shell commands. In a make rule, though, every command line is executed by a separate subshell. This won't work:

for i in *
echo $i

The good news: you'll get an error message, because only the echo is a shell command by itself. You have to write it like this:

for i in *; do echo $i; done

Even when you lay it out nicely, you need the semicolons, because the shell has to think it's one line.

for i in *; \
do \
echo $i; \

The bad news is that if it's not a syntax error, you won't see an error message.

But wait. It gets worse. If I start in my home directory, and make with this Makefile:

cd /tmp/foo.d
rm -rf *

One subshell will do the cd, but the rm -rf will be done in my home directory, by a separate subshell.

$ cd
$ make
$ ls
$ # Um. All my files are gone.

I should have written it like this:

cd /tmp/foo.d; rm -rf *

I make this kind of mistake in crontabs, too. Enumerating the times I've made these was a primary motivation for Georg Cantor's invention of transfinite cardinals.

Thursday, April 17, 2008

${VAR:-}: Mystery Solved

I was mystified, yesterday, to find that nearly 5% of the lines in /etc/init.d/functions, in my Fedora 8 distro, had a construct that looked like this: ${VAR:-}.

I use ${VAR:-value} a lot; it provides a default value if $VAR is empty or unset. But without a value? "If it's unset or empty, make it empty."


I posted to the Boulder Linux Users Group mailing list, and Sean Reifschneider, of, jumped in promptly, with the answer.

If you run the script under bash -u (or with set -u), unset variables cause the script to fail. This construct ensures that the variables will be set, though to null
, so the script completes.

The sound you hear is my palm smacking my forehead.

(Thanks, Sean!)

Wednesday, April 16, 2008

Things I Forget: Loop Variables Are Global, Persistent

In the shell, loop variables, like diamonds, are forever.

Even though I "just meant 'for this loop' ," the shell thinks I really wanted it. This lies in the large class of "things I always forget."
$ for i in {0..5}
     > do
     >  echo $i
     > done
     $ echo $i

Tuesday, April 15, 2008

Setting Up a git Server

I set up my first git server with little trouble, yesterday.

There is no single, reasonable book on git, but there's a wiki. The design and implementation are more complicated than SVN or CVS, but it looks useable, and it's the sine qua non of kernel source code management.

In theory, my users could do it all themselves, since git is distributed. In practice, they can't and won't.

They need it, it goes up. And now, they need it.

Monday, April 14, 2008

Setting the Default Printer

People at work come to me with their printouts. I have CUPS broadcast my printers -- understand, everyone actually shares the same printer, so this is just my printer setup -- and, until they configure their systems, mine are the ones they get when they print.

Their jobs come out with my banner page, which says, "Please bring to Jeff Haemer."

CUPS is still a little confused about setting default printers from the GUI, so even after they set up their own printers, they often get mine by default.

The fix is lpoptions -d , or a direct, hand-edit of the file ~/.cups/lpoptions
$ cat ~/.cups/lpoptions
Default Phaser_6120
The default printer is customizable, per-user, and comes up first in all printing menus.

Friday, April 11, 2008

Jordan Crouse

OLPC fans and curiosity seekers turned out for Jordan Crouse last night a the Boulder Linux User's Group meeting last night. (The guy lounging next to an OLPC is Neal McBurnett.)

Jordan skipped right past "the children," Sugar, and other things you read about in the press, or watch on YouTube. He went right for the throat; his third overhead was a picture of the board. The rest of the talk was things like BIOSes (or the lack thereof) and power management.

The office he works for, in Fort Collins, is AMD's Center for Excellence for CoreBoot, the Linux, Open-Source bootloader for X86 architectures: a good resource to know about.

Thursday, April 10, 2008

Mirroring Trees: rsync --archive vs. cp -a

I did a quick, informal test, and it looks like cp -a is actually faster than rsync --archive for copying hierarchies.

Even this works fine:
$ cd /dev
$ sudo cp -a zero foo

[sudo] password for jsh:
$ ls -l zero foo
crw-rw-rw- 1 root root 1, 5 2008-03-20 20:05 foo
crw-rw-rw- 1 root root 1, 5 2008-03-20 20:05 zero
$ head /dev/foo | od -c
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
Go figure. It's a long way from the old tar piped to tar.

Wednesday, April 9, 2008

Playing With My Router

My web access was particularly slow yesterday morning, so I took a look at my router. My neighbors were eating my bandwidth.

It's okay by me if my neighbors use my router -- I'm paying a flat rate -- but when it starts to slow me down, I guess I should do something.

I set up an access policy to block the offending box from the internet, and timed out the DHCP leases.

Last night, same thing. Half the boxes on my LAN were my neighbors. Okay, new policy: only our boxes can access the internet.

This morning, there was a neighbor's box on my LAN even though it can't get on the net. At 4:30 in the morning.

Time for bruter force. I added WPA2. The test? It immediately knocked my iBook off, and I was able to log back in with the password. I'll look again tonight, just to reassure myself that I don't have a cracker problem.

Looking on the bright side, I'm more familiar with my router. A year ago, I'd never have messed with it. Now, I do it without trepidation, and even know which security scheme to pick.

Tuesday, April 8, 2008

Firefox Day: Bookmark Keywords and Wedged Add-Ons

It was a Firefox day.

"Bookmark keywords" are convenient, little aliases that substitute their arguments for %s in the URL line. When I get tired of typing, I set them up. I typically use them for searches, and they come and go based on what I use frequently. They're more convenient for me than adding stuff to the search bar.

Yesterday, I cleaned up, and today I have two: Wikipedia, and a search for whether the public library has a book on the shelf that I want.

To set one up, I drill down to the page that I'm looking for, then do this:

  • ^L^C -- to capture the URL
  • Bookmarks->Organize bookmarks->New Bookmark->Location->^V -- to paste it into the right place.
  • Edit the URL to replace the specific things I was looking for by the parameter %s
  • Type in a Name and Keyword
  • Use them. For Wikipedia, I use the URL, wp . For library searches, I type bpl .
I also spent a few minutes un-wedging some helpers that weren't updating properly. They wouldn't remove themselves or update, announcing that they'd appear or go away "the next time I restarted Firefox." Nope.

I solved this by going into safe mode, invoking firefox --safe-mode, and removing/updating them there. Why's this work? I dunno, but it does. I got back up, re-started firefox the normal way, and all was well again.

Monday, April 7, 2008

Even Nurseries Need Spreadsheets

I went to Harlequin Gardens yesterday, to buy an American plum and a gooseberry. (I ended up getting a tastiberry instead.) I just found Harlequin on the web, looking for a local nursery that specializes in things that grow here in our dry climate.

We rushed to get there before it closed, at 5:00, and ran into Eve Reshetnik. I hadn't seen Eve for years, but I've known her for decades -- she's a fine concertina player and one of my favorite singers.

As it turns out, Eve and her husband own Harlequin Gardens.

Eve was locked in a struggle with her computer, trying to figure out how to freeze row and column headers in her spreadsheet, so they wouldn't disappear when she scrolled to see data that wasn't on the screen.

I said, "Kristina just showed me how to do that. Have her show you." They disappeared into Eve's office while I bought plants. A few minutes later, they emerged, Eve announcing, "She's a genius!"

Friday, April 4, 2008

Setting Up a Yum Repository

My desktops and laptop are Ubuntu boxes, but I'm working on manufacturing a Fedora-8 based product, so I've spent a couple of weeks at work learning about various aspects of the Red Hat Package Manager (RPM) and the Yellow Dog Updater (Yum).

Documentation is sometimes spotty, sometimes out-of-date, and sometimes absent.

Here, though, is quite a nice post on how to set up a local yum repository.

It's missing a createrepo in the step on how to set up an updates directory, the directory that mirrors Fedora's new and updated packages. However, that step's completely analogous to the earlier step for the Everything directory, which holds all the RPMs from the original distro, and the error message I got when I left it out was helpful.

Cron Doesn't Read Minds: Customizing My Crontab

Some mistakes I make over and over again.

In part, I automate so I can fix stuff once -- so I don't have to smack my forehead and say, "I knew that."

I (all too) often forget that cron jobs don't have my environment, and may not even have my shell or my email address.

I solve this with a template crontab header. My crontabs start like this:
     $ crontab -l
     ## my crontab


     # minute (0-59)
     # |      hour (0-23)
     # |      |      day of the month (1-31)
     # |      |      |    month of the year (jan-dec)
     # |      |      |    |     day of the week (sun-mon, with 0=sun)
     # |      |      |    |     |        command
     # |      |      |    |     |        |
       0     23      *    *     *        crontab -l > ~/bin/crontab.txt 2>/dev/null
The column indicators are good reminders and visual indicators of what goes where.

Here's what the variable settings give me:

$SHELL ensures I won't use cron's default: /bin/sh
$PATH means I won't accidentally get command versions I don't want.

My .bash_env is typically a link to .bashrc. Bash sources $BASH_ENV at
startup when it's a non-interactive, non-login shell, so I get all the stuff I come to assume.

$MAILTO says where to send me error messages. I use gmail's plus addressing so I can search for my cron-job errors when I have to. I put this into root's crontabs on my boxes, too, so errors won't go to root's mailbox, which I never read.

Thursday, April 3, 2008

Pipelines Create Subshells: A Demo

Pipelines create subshells. This example shows that each end of the pipeline is in a subshell
$ x=42
$ x=6 | x=9
$ echo $x
If you want to be fancier,
$ x=42
$ { echo $x>/dev/tty; x=6; } | { echo $x>/dev/tty; x=9; }
$ echo $x 42 

Tuesday, April 1, 2008

I Shoulda Stood in Bed

Some days, I can't win for losing.

Yesterday, a colleague who was doing a new installation of Fedora 8, came to ask me for help setting up his printing. Nothing else I was doing was working, so I thought, "Sure. At least I can do that. How hard can CUPS be?"

After struggling through SE Linux, adding an unsupported printer, and worked around the vagaries of naming and specifying URIs, I hand-hacked the PPD, and CUPS was finally willing to print a test page without complaint. We rushed to the printer in eager anticipation.

It was out of magenta toner.

The job's still sitting in the print queue, wating for its chance to create a paper jam.

Monday, March 31, 2008

Old Dogs, New Tricks: Brace Expansion

I revisit my habits a lot.

It's a sentinel. You can't teach an old dog new tricks, so when I start being able to learn new things, I'll know I'm entering my second childhood.

For years, I used square brackets to match filenames. Now, I use the newer, Berkeley-esque, curlies more often.
$ echo x.[ab]
x.a x.b
$ echo x.{a,b}
x.a x.b
They're different. For curlies, order counts:
$ echo x.[ba]
x.a x.b
$ echo x.{b,a}
x.b x.a
Also, x.[ba] must match something.
$ mkdir /tmp/FOO; cd /tmp/FOO
$ ls # nothing there
$ touch x.[ba]
$ ls
x.[ba] # one file!
$ rm -f *
$ touch x.{b,a}
$ ls
x.a x.b
They're conceptually different. While square brackets are a file-name-match operation, curlies are text-substitution. When you use square brackets, you're asking for existing files that match the pattern; when you use curlies, it's a typing shorthand that the shell expands for you before it does anything else.

The items can nest, and they don't even have to have anything in them.
$ echo x{,a,b{s,t}}
x xa xbs xbt
Curly-expansion is officially called brace expansion, and square-bracket expansion is part of pathname expansion, or (more commonly) globbing.

Friday, March 28, 2008

(a)Time Is On My Side

When I'm developing and debugging, It helps me to know when files were read and commands were executed.

I take debugging advice from the Rolling Stones.

Linux, like Unix, gives you this information as a file's "atime" (access time). I do ls -ulrt several times a week -- often several times a day -- to find out what files were used most recently.

Think of "-u" as the "useful" flag.

Here's an example experiment:
$ echo hello > foo
$ sleep 120; cat foo; date; ls -l foo; ls -ul foo
$ sleep 120; cat foo; date; ls -l foo; ls -ul foo
Note that ls -l says when the file was created, but ls -ul matches the output of date.

Executing a command requires the system read it, so that, too, updates the command's atime.

I find things being used in a subtree like this:
$ touch /tmp/sentinel
# do some stuff
$ find . -anewer /tmp/sentinel
When I was trying to find out which files were read by kickstart, I just ran kickstart and did an ls -ulrt on my kickstart server ... and found out that Fedora-8 has broken atime.

It's added a real-time hack, relatime (relative atime), in which the *first* ls -ul works, but later ones don't. This gives better performance on running systems, but takes away a traditional, and handy, debugging tool.


Reading documentation, Googling, and begging for help on the BLUG mailing list all failed. Finally, Kevin Fenzi cheerily gave me the solution:
$ sudo bash -c 'echo 0 > /proc/sys/fs/default_relatime'
$ sudo mount -o remount,atime /
Nice. Thanks Kevin.

How did Kevin figure it out? He read the kernel code.

Thursday, March 27, 2008

Checking a Serial Cable -- The Coolest Trick Ever

Yesterday afternoon, Jim Black showed me how to check a serial cable.

I was having trouble connecting to a board over a serial port, and thought it might be my cable. Jim showed me that if you connect pins 2 & 3, it will connect transmit to receive, and if you type at it, the characters will echo to the screen.

Here, Jim's connecting the pins with a screwdriver. When he first showed me, he used a pair of scissors that were lying around.

Jim says it's one of his "old man tricks."

He also taught me not to touch the case with the connector, since that will ground the connector and send my transmissions to /dev/dirt .

"Serial cables: the most non-standard standard, ever." -- Jim Black

Wednesday, March 26, 2008

Mounting File Systems with Ssh and Fuse

Yesterday, I mounted my laptop, at home, from my desktop, at work, with ssh. Not NFS, not Samba: ssh. Different domain, different location. Secure, fast, hassle-free.

I started with a recipe out of a book I got for Christmas, Carla Schroeder's Linux Networking Cookbook, then Googled around until I found a mount table entry that would do the trick. Now, I can just say mount /mnt/sshfs from my desktop, at work, and my home directory from my laptop at home appears.

Here's the fstab entry from the work box:

sshfs#user@laptopname:/home/user /mnt/sshfs fuse port=portnumber,user,noauto 0 0

You also need to install FUSE, the "filesystem in user space" module, (apt-get install fuse), and, of course, ssh, but I'd already done those for other reasons.

The whole shebang goes by the name sshfs.

(Wikipedia's FUSE entry, linked to above, says there's even user-space filesystem built on Gmail.)

Monday, March 24, 2008

Freezing Lines in Oocalc

We got our bikes serviced, so they're ready for the season, so I added a new column to Vital_statistics.ods, the spreadsheet I'm keeping my daily steps and weight data in: Bike Miles.

She was watching over my shoulder as I was putting in the first entry -- the trip we took to Baseline and Broadway -- and she said, "You know, you can make the column headers stay in the window when you scroll."

She showed me how. Click on the number of the blank row below the column headers, to mark it, then Window->Freeze. Now, as I scroll, the headers stay visible.

Learning one trick at a time.

Sunday, March 23, 2008

Constant As a Northern Star: Read-only Variables in Bash

I didn't know bash had read-only variables.

I found out by peeking at the code for s3-bash.

Well, I guess I did know, since I can't make assignments to variables like $1, or $UID. I just didn't know I could create them. Well, I can.
$ PI=3.14159
$ echo $PI
$ PI=3
$ echo $PI
$ readonly PI=3.14159
$ PI=3.14159
$ echo $PI
$ PI=3
./constant: line 11: PI: readonly variable
$ echo $PI
Caveat programmor: In a scripts, they're great for creating constants; however, once you make a variable readonly, there's no way to change it back to read/write. If you make a variable readonly in an interactive shell, you have to exit the shell to get rid of it.

"Adult supervision required. Don't try this at home, kids."