Learning How To Snowboard, In Engineer-Speak

This is going to be a slight departure from what I normally write about. This past winter, I've been learning how to snowboard and it's been fantastic! One of the new loves of my life, right up their with programming, fireworks, and Dark Side of the Moon. I was fortunate enough to have engineers teach me how to snowboard. That sounds silly, but some things are better expressed in engineer speak from one engineer to another; you can express ideas more succinctly and explain the underlying concept. This blog post is meant for engineers to quickly learn the fundamentals of how snowboarding works.

1. Standing up
Ok, the first thing you need to do is learn how to stand up. The important thing is that you position your board perpendicular to the slope of the hill! Remember, you move quickest along the long edge of your board, so you want the edge to be perpendicular to the slope vector of the hill to minimize downward motion. You want to stand up as fluidly as possible; kind of rock your upper torso back and forth, and then push your weight forward. As you stand up, remember that you're not putting the board flat down on the snow. If you do that, you'll start sliding and probably fall. Your back edge needs to dig into the snow, and your front edge should be raised slightly above the ground. All you're trying to do is balance here.

2. Sliding forward
Start from standing up and lean slightly forward, tilting your board down the slope you're going down. Do it slowly and you'll start inching forward. To stop, just lean back. The more you lean forward, the faster you will go, because your downward force on the hill will be distributed over a larger surface area and your board will have less ability to dig into the snow.

3. Leaf Falling
As you continue to slide forward, your board-to-slope will veer away from 90 degrees. You'll find yourself either moving more left or more right as your board starts turning slightly. Don't worry! You can easily correct this. If you start moving left, kick your right foot forward. The goal is to make the board closer to perpendicular to your motion vector. Once you correct, you will probably start sliding gradually towards the right. This is good! Kick your left foot forward and continue the process. You will look like a leaf wafting down from a tree, hence the name.

4. Stopping while Leaf Falling
This is all about getting your board perpendicular to the slope vector again. And if you can leaf fall, stopping is simple. When you go to change directions, don't kick your foot as far foward. Kick it far enough that you stop moving with respect to your motion vector, then immediately swoosh your feet so that the board is perpendicular to the slope vector of the mountain. This is a two step process: halt motion that is existing, and position the board to prevent more motion.

5. Faster!
As you become more comfortable with leaf falling, you can start aligning the edge of the board more with the direction vector; this will increase your velocity. When you think you're going to fast and want to stop, kick your trailing foot so that you're board is perpendicular to your motion vector. Get proficient at this before you move on.

6. Linking Turns
To graduate to linking turns is a natural progression -- if you're going fast enough. Carving an edge into the snow is much easier with a little bit of speed, so don't be too afraid of it. When you're sliding with your board flat on the ground, you have the least control -- your weight is being distributed over the maximum surface area. You only have control of the board when you're on your toe edge or your heel edge, because you're concentrating most or all of your force on that edge. So remember, carving == control. Going along with that, to go straight, you don't. As you go down the slope, you switch from toe edge to heel edge making "S" tracks in the snow. If you stard on your heel edge, you'll cut left across the mountain. Don't cut too sharply! When you've gone as far over as you want to, you shift weight from the heel edge to the toe edge. You'll briefly not have as much control when you're flat on your board, but as you continue leaning forward, you'll toe edge will engage and you'll curve to your right. Do the same thing in reverse when you get far to the right.

That's it! Like engineering, a solid understanding of the fundamentals and why certain things work will take you a long way. And just like engineering, you need practice, so hit the problem set (slopes)!


Using sed to remove deprecated function calls

I am super lazy. As a programmer, this is a good thing. For a project that I work on, I was recently given a code maintenance task of cleaning up assert statements. ASSERT_S_#_MED had been deprecated in favor of just ASSERT_S_# (where # is the number of informational parameters for logging purposes).

The caveats are that I don't know how many files have the deprecated call, and I didn't want to do a blind stripping of _MED because I wasn't sure if it was legitimately somewhere else in the code; so I needed to make sure a digit existed before it.

1 #!/bin/sh
2 LIST="`grep '_[1-9]_MED' *.C | awk '{print $1}' | sed 's/://g' |uniq`"
3 echo $LIST
4 for i in $LIST
5 do
6 cleartool co -nc $i
7 sed -i 's/_\([1-9]\)_MED/_\1/g' $i
8 cleartool ci -nc $i
9 done

Line 2: Populate a list of all files with the deprecated call. The awk takes the first part of the grep, then the sed strips the colon, and then uniq removes duplicates.
Line 7: The sed matches _[1-9]_MED, captures the digit, and uses a backreference to put it in the replacement. The -i flag means it edits in place.
Line 6,8: Version control that I'm using for the project

Hopefully this will be useful to someone! If you have a better way of doing it, I encourage you to post in the comments. We're all learning, after all!