Nothing Undone

A weblog, by Peter Jaros.

A Distraction-Free Presentation Viewing Environment

I’ve just watched Rich Hickey’s talk Simple Made Easy, which has been waiting in my queue for a very long time. It’s a brilliant talk. Watch it.

Unfortunately, we won’t be able to watch it for Bentoconf. InfoQ, which hosts the talk, has a fancy playback system which syncs a video feed of just the presenter with a separate slide display, rather than editing the two together into a single video. Thus, we can’t play it through Synchtube, which powers Bentoconf. That’s a shame.

It also means that you can’t full-screen the talk. That is, you can full-screen the presenter, but then you can’t see the slides. That’s no good. And just full-screening the browser window leaves something to be desired. The chrome of the page is bright, messy, and distracting. I’m here to watch a talk, thank you.

Luckily, userstyles.

Presentation with userstyle applied

Process Substitution: The Coolest Shell Trick You Didn’t Know

The syntax in the blog post is compatible with bash and zsh. With other shells, YMMV.

Well, maybe you know about it. I didn’t. It amazes me that after all this time the shell can still surprise me.

You probably know about the man command. I sure hope you do. Give it a topic, and it’ll tell you all about it. The topics are usually commands. For instance, ssh is a fairly complex and full-featured command. I wonder how it works. Let’s find out:

$ man ssh
SSH(1)                    BSD General Commands Manual                   SSH(1)

     ssh -- OpenSSH SSH client (remote login program)

     ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
         [-D [bind_address:]port] [-e escape_char] [-F configfile] [-I pkcs11]
         [-i identity_file] [-L [bind_address:]port:host:hostport] [-l login_name]
         [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
         [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
         [-w local_tun[:remote_tun]] [user@]hostname [command]

     ssh (SSH client) is a program for logging into a remote machine and for executing com-
     mands on a remote machine.  It is intended to replace rlogin and rsh, and provide secure
     encrypted communications between two untrusted hosts over an insecure network.  X11 con-
     nections and arbitrary TCP ports can also be forwarded over the secure channel.

Awesome, everything we need to know about ssh. But sometimes you don’t know what command to look up. Maybe we just know that we want to log in remotely. How would we find the right command for that?

Enter whatis:

$ whatis "remote login"
rlogin(1)                - remote login
rlogind(8)               - remote login server
ssh(1)                   - OpenSSH SSH client (remote login program)

Cool, we even see that there’s an older remote login system we can look into.

That’s cool, but what’s this process substitution thing?

Okay, okay. I knew about whatis. I also knew about a command called apropos. In fact, my understanding the two was the same; I wasn’t sure what the difference was. They both searched for man pages based on keywords. So I looked at man whatis and man apropos. Very similar entries. (Go ahead, take a look for yourself.)

I wondered, is there a good way to see the differences between these pages? Well, diff should do that for us. But diff wants to take two files. We can pipe text into it, but that can only serve as one of the files; you can’t pipe two things into the same program.

Or can you?

Benchmarking My Dotfiles.

I’m a huge fan of Gary Bernhardt’s Destroy All Software. If you’re not a subscriber, I highly recommend it. It’s $9 per month. Pay the $9, watch as many videos as you can in a month, and see if it’s not worth staying subscribed.

The things Gary teaches explicitly are wonderful, but there’s a lot to be learned implicitly from watching his screencasts. His patterns of working with Vim and editing files are often quite different from mine. For instance, Gary often opens Vim to edit a single file, closes it to get back to the shell, and reopens it to edit another file. I rarely do that. I keep Vim alive as long as possible, like an IDE. Why is that?

Because my Vim takes ages to boot up.

Let’s Not Teach the Fundamentals First.

This weekend I TAed at RailsBridge Boston. RailsBridge is a day-long Ruby on Rails workshop for women of all backgrounds. It is awesome.

I can’t express the joy that comes from seeing the lightbulbs go off in someone’s head for the first time as they learn to program. The magic in the moment when they become visibly excited at the prospect of what they’re doing.

“So, "Hello, world" doesn’t do anything on its own, but if I put puts in front of it, I see Hello, world in the Terminal. Can I put something else after puts? Why is it in double-quotes? Will single-quotes work? What about no quotes?”

So many amazing questions. So much beautiful, exciting learning. To be honest, I’m not sure I enjoy programming nearly so much as I enjoy learning to program, and helping someone else find that joy is just as fun.

While I was there, I began to crystalize a theory of how we learn to program, and it goes something like this: You can’t teach someone to program. We each need to learn it for ourselves. All you can do is make the right information available at the right time. It’s like a gardener fertilizing a flowerbed. You can’t make the flower. That’s the seed’s job. Your job is to provide the right conditions.

Toward a Culture of Pairing

I learn best when I work directly with other people.

Books are great. Talks are great. Screencasts are great. I encourage everyone to take advantage of the one-way, work-at-your-own-pace educational resources available, because in the world of software development there are a lot of awesome ones.1

But there’s something those lessons can never give you.

In Zen, there is a notion of Dharma transmission. Dharma, in Buddhism, is the teaching of the Buddha. It is Buddhist wisdom, and it is revered as a holy thing. It is improper to place a book containing Dharma teaching on the ground; instead it is placed on a cushion.

Zen strains of Buddhism tend to take pride in the source of their teachings, tracing their lineage back to the Buddha. To be accepted into this lineage is to receive Dharma transmission. It is not only the learning of facts and sayings; in fact it is not truly those things at all. What is truly transmitted as Dharma is something more abstract. It is akin to a flame passing from one candle to another.

How My Mac Became Horribly Fragmented, and How I Fixed It.

A tale of caution:

Sometime last year, long after most everyone else, I finally upgraded my Mac to Lion. And yes, I had to get used to the scrolling, and the buttons looking different, and fullscreen working differently, but I got used to all of that. There’s one thing I didn’t get used to, though.

My Mac got really, really slow.

Usually I noticed it when I switched applications, but I also noticed it any time I used the disk a lot or swapped out a lot of memory. I was worried my disk was dying.

I asked folks on, once about why my computer was sluggish, and once about why my menu bar blacked out the application name when I switched applications and looked like this:

Menu bar with oddly blacked out application name

Let’s Talk About Jobs.

Get ready for hotness in a tiny package. This one’s a habenero.

Sometimes you’re in the terminal, editing a file. Oh, your editor doesn’t run in the terminal? Okay, maybe you’re looking at a man page. Or playing Nethack. Whatever. You’re doing something that’s taking up your terminal, but you want to use the shell to go check something out, like look up a man page or look at a file or run a test.

You could quit, do your thing, and come back. You could open a whole new terminal and get your new shell in the state the old one had. Or maybe the app you’re running will even let you shell out to run something. But I’m going to tell you about something that’s often even neater, something that’s been a part of your shell since perhaps before you knew what a shell was, but which most people I work with have no idea exists.

I’m going to tell you about job control.

Another Whac-a-mole Strategy.

If you write software and you’re not watching Gary Bernhardt’s Destroy All Software, do yourself a favor and subscribe. It’s not expensive, it’s fun, and it’s good for you.

A couple of weeks ago, he posted episode #69, Conditional Whac-A-Mole, which describes several ways of removing a conditional.

In the example, a user needs to be followed in a different way if they’re marked “private” than if they’re not. (Think of Twitter users who have “private” accounts. The user needs to approve any new followers.) One of Gary’s solutions was to have two different types of users, PublicUser and PrivateUser. Each implements #follow differently. Gary says he doesn’t like this version because fundamentally they aren’t different things: they’re both Users.

I agree, but I think we can tighten up the polymorphism to something more flexible: