# Now we see the violence inherent in Hooke’s Law

This is the post where I explain how I avoided shooting my older son with the head of a screw. Two heads of screws, actually, but we’ll get into the details later. The underlying topic is strain energy, its potential1 for harm, and the respect it should be paid.

As I said a few days ago, the inspiration for this post—apart from the actual incident in which I avoided shooting my son—was this episode of Gabe Weatherhead and Erik Hess’s Generational podcast, in which they talked about the dangers of their respective former professions—Gabe as a research chemist and Erik as a fighter pilot. The dangers associated with being a fighter pilot are pretty obvious; those associated with being a research chemist are probably less obvious, but you can get a good sense of them from the title of the episode: “What Happened When Gabe Set Himself on Fire.”

Like chemistry labs, mechanical testing labs have their own set of dangers, most of which involve the sudden, unexpected release of strain energy. You learned about strain energy in high school physics, although your teacher probably didn’t call it that. Shortly after learning about the forces in springs and Hooke’s Law, $F = kx$ (a topic we’ve looked at here once or twice), you learned that the potential energy2 stored in a spring is expressed by this formula:

The $k$ in the formula is the spring constant, which is a measure of how stiff the spring is. It’s measured in units like pounds per inch or newtons per millimeter—force per length—and is always a positive value. The $x$ is the amount, as measured in inches or millimeters or some other unit of length, the spring has stretched from its natural, unloaded length. The sign convention for $x$ is arbitrary, but it’s usually taken that positive values of $x$ represent lengthening of the spring and negative values represent shortening.

You see, then, that because $x$ is squared, the potential energy in the spring is either zero (when the spring is at its natural length) or positive. This makes sense because potential energy is defined as the ability to do work. A compressed spring is able to do just as much work as a stretched spring, so their potential energies should be the same and should have the same sign. And a spring that’s neither stretched nor compressed can’t do any work, so its potential energy should be zero. So far, so good.

The reason Hooke’s Law works on a macro scale for things like coiled springs is that a very similar sort of law works on a micro scale within the spring wire. On the micro scale, the force-displacement relationship, $F = kx$, is replaced by a similar relationship between stresses (which are like forces) and strains (which are derived from deformations). In the same way that the potential energy stored in a spring is a function of its stretch, the potential energy in any deformed body is a function of its strain. Hence the term “strain energy.”

The details I’ve glossed over in the previous paragraph would fill, and do fill, volumes. My shoulders are sore from all the hand-waving, but I’ll push on.

When it comes to the ability to do harm, not all strains are created equal. It’s only the elastic strains—those which can be reversed when the load is removed—that present a danger. If you stretch a rubber band in front of your face and let go, it’ll snap back and hit you in the nose. That won’t happen if you do the same thing with a ring of Play-Doh. In a mechanical testing lab, we’re usually applying very large forces to parts and materials that have a lot of reversable elastic strain. And when things break, whether intentionally or unintentionally, the huge strain energy that’s built up as the parts have been loaded is suddenly released and turned into kinetic energy. Lab safety is all about directing that kinetic energy to where it won’t hurt anyone.

Which brings us, finally, to my son and the screw heads. One weekend a few months ago he was helping me finish up a few tests. The tests were intended to break things, and I had barriers set up to block any pieces that might come flying out at us. And of course we were wearing goggles. The tests went smoothly and no one came close to getting hurt.

We ran into a snag while taking the equipment apart. One of the pieces of the test fixture was a pipe clamped in place by four capscrews like this one:

Source: littlemachineshop.com

A side view of the clamping arrangement looked like this, with two screws on the top and two on the bottom (you see only one in each position because its mate is behind it). The screws passed through unthreaded holes in the blue piece and screwed into threaded holes in the green piece.

I had clamped and loosened this pipe many times over the previous month of testing, and internal hex surfaces of the capscrews had rounded out. Finally, after the testing was over, the Allen wrench wouldn’t grip in the screwheads and I couldn’t loosen the clamp and remove the pipe.

So I grabbed a hacksaw, slid its blade down the gap between the blue and green pieces, and drew it back to start cutting. That’s when I noticed my son standing to the left, directly in line with the screw heads.

Let me digress at this moment of high tension3 and explain how bolts and screws work. Most people know that bolted joints4 require sufficient torque to do their job. Many of you have probably used a torque wrench at one time or another. But most people don’t realize that torque, in and of itself, is meaningless. Bolted joints work because of the tension in the bolts, not the torque. The purpose of applying torque to a bolt is to use the mechanical advantage of the thread (which is essentially an inclined plane wrapped around in a helix) to stretch the bolt and induce tension in it. There are, in fact, bolting systems in which a hydraulic machine stretches a bolt directly by pulling on its tail and then spins the nut up tight to maintain that stretch—no torque of any significance is ever applied.

The word “stretch” in the previous paragraph should prick up you ears. Strain energy is stored in every fully tightened bolt because that bolt has been stretched. When such a bolt breaks or is cut, that strain energy gets released somehow, often by sending the bolt head flying.

In this case, there’s even more strain energy available. The flanges on the two clamp pieces are bent under the load of the screws. When the screws are cut, they’ll straighten back out, acting as a catapult to fling the screw heads.

“You need to move around to the other side,” I said.

“Why?”

“Because when I cut through, these screws are going to shoot out like bullets, and you’re standing in the way.”

“Really?” I should mention that my son is sixteen years old and therefore assumes that I’m full of shit. But he moved anyway.

I did a suprisingly good job of cutting evenly through the two top screws, and they snapped almost simultaneously. The screw heads shot across the lab and hit a piece of plywood leaning against the opposite wall with a loud th-thunk. I was vindicated; when I had to cut another recalcitrant screw a few minutes later, he stayed well out of the line of fire.

While I was happy to have proved myself not entirely full of shit, I was annoyed at my brief lapse. I’d been careful during the test but let my guard down briefly during disassembly. I should never have even picked up the hacksaw before clearing him out of the way. Strain energy is not to be messed with.

1. You may not get that joke yet, but Ben Deaton is laughing his ass off right now.

2. Yes, that was the joke.

3. I slay me.

4. There is a technical difference between bolts and screws, but it has nothing to do with this discussion, so I’m going to use the words interchangably from now on.

# A simple Drafts work diary

Topics for posts are piling up and I don’t have time to write them up. I’ve recently plotted out posts on

1. The dangers of stored strain energy and how I avoided shooting my older son with the head of a screw when he helped me run some load tests a couple of months ago. This topic was inspired by the May 4 episode of the Generational podcast, in which Erik Hess and Gabe Weatherhead discussed the dangers of their former workplaces and Gabe’s propensity for setting himself on fire.
2. Thermal stresses and why Katie Floyd’s glass baking dish blew up on Mother’s Day. This one would harken back to Dan Rutter’s post on Pyrex, which I read through a link from Marco Arment.
3. The alleged design and craftsmanship in this artisanal bottle opener which Justin Blanton made the unforgivable mistake of ordering.
4. How revisiting the comic books I loved as a teen has left me disappointed in both the writing and the artwork. The one exception is the early Conan series by Roy Thomas and Barry Windsor-Smith, and that’s probably because I’ve always seen myself as a latter-day Conan—black-haired, sullen-eyed, sword in hand, a thief, a reaver, a slayer, with gigantic melancholies and gigantic mirth.

And that doesn’t include more topical posts that I’ve given up on writing because their time has passed.

So tonight I’m taking the easy way out, with a short post about the iOS Drafts app inspired by David and Katie’s recent iOS Automation episode of Mac Power Users and by the Generational episode with Greg Pierce,1 the developer of Drafts.

Y’know what’d be great? If @draftsapp could append to a Dropbox file named according to the date, creating the file if necessary.
Dr. Drang (@drdrang) Mon May 13 2013 8:16 PM CDT

It was stupid because Drafts can already do what I was asking for, as several kind people told me without snickering. Here’s the Dropbox action I came up with:

In my defense, the reason I didn’t realize I could use a date tag (the thing inside the doubled square brackets) in the name of the file is the name of the option that must be chosen with it: Predefined. It just didn’t seem right to me that a file with a predefined name could have its name defined on the fly. Also, it seemed superfluous to have a Timestamp option for the file name if a timestamp could be provided through tags. Still, the ability to use tags in file names goes back to version 2.5.3—I should have known about it.

Anyway,2 this action is intended to help me keep track of what I’m doing at work, what the action described at the end of this post should’ve been. The idea is to launch Drafts when I switch from one task to another, tap in (or dictate) what I’m about to start working on, and invoke this action. Each time, a pair of lines will be added to a diary file for that day, one with the timestamp and the other with the note I wrote for it. Like this:

1:14 PM
Started 200° test

1:45 PM
Ended 200° test

1:54 PM
Started 300° test


The improvement over the old system is that now I’ll have a separate file for each day, all in the same Diary folder in Dropbox. To me, this is a more natural way to organize diary entries, rather than having them all with time and date stamps in a single big file. Each day’s file will have a name like 2013-05-14.txt.

This is, in many ways, the same sort of thing Katie Floyd is doing with Day One. I like Day One, but I prefer using plain text files in case there comes a time when I want to run some script over my diary files to extract information. I have no plans to do that, but I want leave open the possibility.

Of course the real trick isn’t coming up with a Drafts action, it’s developing and maintaining the discipline to make an entry every time I switch contexts. I’m working on that.

1. Gabe and Erik have been killing it on Generational. You really should make room for it in your listening schedule.

2. Have I ever mentioned how much I hate the non-word “anyways”? Once limited to the sort of people who say “irregardless,” it’s now everywhere, tormenting me.

# Cleaning out Clean My Mac

I just got a notification on my computer from Clean My Mac 2, a utility I bought as part of the recent MacHeist nanoBundle. I have nothing against CMM2—it does a fine job of scanning my disk and finding files that might be good to delete—but I don’t want it nagging me to do so. So I went searching for how that notification was sent.

I didn’t have to look far. The natural place for scheduled, periodic tasks to live is in your ~/Library/LaunchAgents folder. And that’s exactly where I found a couple of Launch Agent plist files from CMM2.

A quick review of the plist file shows that the scheduled scan is set to run on the 12th and 19th of the month. I installed CMM2 late last month, so it’s not surprising that today was the first day I saw the notification.

I didn’t want to delete the plist files (they might be useful later), but I did want to stop them, so I ran

launchctl unload -w ~/Library/LaunchAgents/com.macpaw.CleanMyMac2Helper.scheduledScan.plist


and

launchctl unload -w ~/Library/LaunchAgents/com.macpaw.CleanMyMac2Helper.trashWatcher.plist


from the Terminal. Running the launchctl command to look for other MacPaw processes

launchctl list | grep macpaw


showed that there was still a CMM2 Helper process running, so I opened Activity Monitor and killed it.

I suppose I could’ve edited the plist files to add a Disabled key, but I find running launchctl easier. I’m always worried that I’ll add an item at the wrong nesting level when I edit XML files.

I’m not going to rant against MacPaw for installing processes without telling me, because it’s entirely possible it did tell me and I didn’t pay attention. Either way, I shouldn’t get that unwanted notification again.

# Bite me

Earlier today, Gabe Weatherhead recommended a very powerful compact flashlight. It’s a nice product, I’m sure, but it’s missing one feature that I’ve come to find very important in a flashlight: biteability.

You know what I mean. You’re working in the dark and need both hands free. Where does your flashlight go? In your mouth, of course. And to keep it pointed in the right direction, you need to be able to grip it between your teeth, so a metal barrel is out of the question. For several years now, I’ve been using a Brinkmann 3-watt LED Armor Max flashlight that runs on 3 AAA batteries. It has a plastic body with a rubbery grip around the barrel that makes it very tooth-friendly. It’s nowhere near as bright as Gabe’s, but it’s always been more than bright enough for my needs.

Yes, you can buy headband-mounted flashlights, but the great thing about this Brinkman is that it works perfectly well as a regular flashlight, and under normal circumstances you won’t look like a dork using it. And while you will look like a dork when you put it in your mouth, you only need to do that when there’s no one around to hold the flashlight for you and, therefore, no one around to see how dorky you look. Self-correcting!

I didn’t set out to find a biteable flashlight. I just happened to buy a Brinkmann because it was bright, compact, and water-resistant (O-rings seal the screw-on caps at either end) and learned later how helpful it was to have a flashlight I could hold comfortably in my teeth.

# TextExpander date snippets via bash

You have, presumably seen this post by David Sparks, in which he provides a bunch of TextExpander snippets for showing dates and times in different formats, some of which involve calendrical calculations. That’s a combination of topics I simply cannot resist commenting on.

First, if you download his snippet collection and double-click on the file, it’ll be imported into its own folder in TextExpander. If you already have some date snippets—and I suspect most of you do—you don’t have to worry that David’s will overwrite or get mixed in with the ones you already have.

Second, you’ll notice that most of David’s abbreviations start with x. He uses that the same way I use the semicolon: as a signal character that makes it easy to come up with meaningful abbreviations that don’t conflict with real words. By using a letter instead of a punctuation character, David can sync his snippets between his Mac and his iOS devices and not have to worry about his abbreviations requiring a trip to a secondary iOS keyboard. I’d use this except for the fact that I often use variable names that start with x,1 and my fear of conflicts is greater than my desire for snippet harmony.

Finally, and most interestingly, David has a few snippets for inserting dates that are for some date in the future. I’ve made similar snippets, but mine have always been for a fixed number of days from today. David’s are more subtle. As you can see from the screenshot, he has snippets for things like “next Monday” and “next Friday.” TextExpander’s built-in date calculation commands can’t handle things like that, so David’s snippets use AppleScript (written by Ben Waldie).

I wrote a post about these kinds of calculations last fall, discussing both AppleScript and Python solutions. In the comments to that post, David Cross (@roguemonk) pointed out a clever use of the date command that blew me away. It manages to do these same calculations in way that’s both more compact and easier to understand at a glance. The technique relies on the use of date’s -v option.

Let’s say you want to replicate the “Next Monday” snippet shown above. The date invocation that’ll do it is

bash:
date -v +1d -v +mon +"%Y-%m-%d"


Like the AppleScript in the screenshot, this gives you the next Monday (-v +mon) after (-v +1d) today.2 3 The formatting of the date is done through the familiar strftime library used by lots of Unix utilities and programming languages.

To make this command work in TextExpander, you need to add the shebang line for bash and you probably want to use echo -n to suppress the linefeed that date adds to the end. Your final snippet would look like this:

bash:
#!/bin/bash
echo -n date -v +1d -v +mon +"%Y-%m-%d"


Next Friday would look like this:

bash:
#!/bin/bash
echo -n date -v +1d -v +fri +"%Y-%m-%d"


And so on. The great advantage of this approach is that the strftime format is much more flexible than what you can get out of AppleScript. Just look at the contortions poor Ben had to go through to get a simple year-month-date format. If you wanted a format like “8 May 2013,” the date specifier would be easy to change:

bash:
#!/bin/bash
echo -n date -v +1d -v +mon +"%-d %b %Y"


I realize that writing this post so close on the heels last week’s gentle poke at Merlin Mann makes it look like I’m taking on the role of TextExpander policeman. But if I could control my obsessions they wouldn’t be obsessions, would they?

1. Contrary to popular opinion, variable names that start with x aren’t necessarily a recipe for obscure code. I write scripts that do coordinate calculations, and the variables that represent the x-, y-, and z-coordinates of points often start with those letters.

2. The order of the -v options is important, as they’re applied sequentially. In this case, we start by moving forward a day and then look for the “next” Monday. If the order of the -v’s were reversed, we’d go to the next Monday and then step forward a day, landing on a Tuesday.

3. If tomorrow is a Monday, that’s the date that’ll be returned. The + sign for day-of-week searches works more like than >