Moving the Blog

This time when having trouble with pasting fixed-format verbatim code into a blog draft, I remembered that The R-Podcast uses a static generator for its blog called Nikola.

I tried it and liked it.  You can use reStructuredText, and including code is easy.

The only thing I had trouble with was the rendering of mathematics formulas with mathjax.

Anyway, you can see the first post on Getting Started with BLAS there now.

Dan John’s 5 for the Bare Minimum Workout

Dan John is a strength and fitness guru, an autodidact with professional experience informing a passion for learning. He has broken down movements into categories in a way that makes it possible to think about the bare minimum workout: What’s the least you could do and still have a chance of being reasonably fit?

Not that I think the bare minimum is the ideal workout—I just realize that sometimes circumstances conspire to make it really hard to find time to work out. When excuses abound, what’s a workout that’s so easy and effective that none of the excuses seem good enough?

Here’s Dan John talking about the five movements:

They are, in a different order,

  • The Hinge
  • The Squat
  • The Pull
  • The Push
  • The Loaded Carry

I put the hinge first because if it is really understood, the hip movement can help you to sink down into a good bottom squat position like this:

The hinge looks like this:

… and is a basic movement in its own right that can be exercised with several movements, including the kettlebell swing:

Aside: This is a world champion doing a kettlebell swing with an 88 pound kettlebell. You will see some people doing swings that go above their head, but those are recent inventions by people who don’t seem to know the difference between a kettlebell snatch and swing.

Here’s the snatch, the original movement where the kettlebell swings above your head. Notice the control that is mandated by the form:

OK, the aside is over.

For the bare minimum workout, we’re going to rely on the big systemic stimulus that you get from doing many squats. Dan John presents this idea in “Mass Made Simple,” but don’t be afraid that squats will necessarily make you into The Rock if that’s not what you’re after. I think of it as a strong suggestion to your body that it use food to make you more healthy and strong, not … the opposite.

The details of the squat movement are important. I suggest Mark Rippetoe:

For the bare minimum workout, you’re going to do,

  • a squat (prefered) or hinge (for variety and practice) movement,
  • a pull, and
  • a push.

One set of each. (A set is a sequence of repetitions of a movement. E.g., if you’re doing pushups, a pushup is a “rep”, and if you do 10 in a row, that’s a “set of ten”.) Ideally you’ll do over ten reps of squats, so you have to figure out a weight that will start to feel difficult after ten reps.

The key with this workout is that it’s something you can do ridiculously quickly in your regular clothes. Doing the maximum weight is not the priority—Completing any somewhat difficult physical activity is. If you are so pressed for time that you have to do this workout, it will keep you going until your life settles down.

For each set, you just do enough to start to feel like it’s difficult, not nearly enough for you to fail to perform a repetition.

You might notice the absence of the loaded carry in the workout. It’s just deferred to the rest of the day. For the loaded carry, look for any excuse you can to carry heavy things (children, jugs of water, chairs, ladders, books, etc.) in your regular life. Make a habit of finding opportunities to carry heavy stuff. It’s pretty fun and takes no extra time.

So we’ve talked about the squat and hinge. Let’s talk a bit about the pull and push.

The pull is probably best performed with a pull up, which is like the movement in the video below but with the grip facing the other way. Chin ups (like the grip in the video) are good too.

But a lot of people haven’t yet cultivated the strength needed to do a pull up. Another pull exercise that comes highly recommended by my favorite strength gurus is the one-arm dumb bell row:

For the push, I like the kettlebell press. You’ll have to clean it into place first.

Other pushes are pushups, bench press (dumbbell bench press is easier to do alone), and other more whole-body pushes like the push press and the jerk. But the kettlebell press is just great.

Note: This post shares content and concepts with an earlier post on a Squat-Centric Workout, but it’s meant to stand alone and was written for someone specific.

Trying WebSockets with Gorilla and Knockout

Shared Form Demo

I have been wanting to try out a few technologies for a while and tried them all out in a demo that allows concurrent distributed users to edit the same web form.  All the users see edits happening in real time.  The code is on github, and the README there has more detail than I supply here. The demo works, but the README mentions things that a real-world shared form would need added or at least considered.

These are the technologies I used:

I also touched on a couple other primitives that would be needed to go beyond the demo stage:

I also used good old jQuery.

The amazing thing about this experience was that all these technologies worked wonderfully, without a hitch.  They were pretty easy to put together.  One reason is that each has great documentation, although the Gorilla WebSocket module’s best documentation is external to it, in a blog post by its author, Gary Burd:

While driving, I listened to a bunch of conference talks and tutorials on WebSockets.  I found out that about half of the presentations dwell on fall-back strategies, ways of supporting users with lame browsers or lame web proxies.  It turns out that there are a few libraries created expressly to provide transparent fall-back mechanisms when the client can’t use WebSockets.

Both have a two-part implementation: There is a client-side JavaScript library and a server-side part.

There isn’t any Golang server-side Socket.IO or Sock JS implementation that is “blessed” by either of the two projects or even stable at this time.  It leaves me wondering whether I could put Sock JS in the client and just provide support for long-polling AJAX in the Golang server as the sole fall-back mechanism.

Knockout JS was the most fun part of this experiment.  It does dynamically tracked dependencies between data in the running JavaScript and data in the DOM, allowing two-way binding between the DOM and the “ViewModel” in the JavaScript runtime.  You can manipulate the ViewModel based on messages coming through the WebSocket, and the data in the DOM gets automatically updated.  It is loads of fun to see in action.  The Knockout JS site has interactive tutorials where you can try it:

Python Review Surprises

I had to use Python for work again after a long time off, and during the time off from Python I had gotten used to Go.  A few of the things I had forgotten or never known about Python surprised me when I returned to it.

No Assignment Operator in Closures

It’s not like I make closures all the time, but I do take lexical scoping for granted when I’m in a high-level language.  This is a habit left over from perl.  In perl, you can create a closure without any special knowledge or techniques, just because lexical scoping works the normal way.

bash$ ./closure
bash$ cat closure
#! /usr/bin/env perl -w

use strict;

sub closuretest() {
    my $n = $_[0];

    return sub {
	return $n += 1;

my $fn = &closuretest(2);
print $fn->() . "\n";
print $fn->() . "\n";

If you try the same in python, though, it won’t work, because the innermost subroutine gets its own namespace—so far so good—using an outer-scope variable as an R-value works as expected—OK—but because assigning to a variable inside that namespace creates a completely new variable, you cannot just use the assignment operator on a variable from the outer scope.

Using the += operator means you’re assigning (creating a new variable) but also reading (a variable in the new namespace that hasn’t been created yet), so you get an error. So because the variable appears as both R-value and L-value, Python won’t assume you’re trying to use the variable from the outer scope that already does exist, even though it would have done that if the variable only appeared as R-value.

bash$ ./
Traceback (most recent call last):
  File "./", line 10, in 
    print fn()
  File "./", line 5, in inner
    num += 1
UnboundLocalError: local variable 'num' referenced before assignment
bash$ cat !$
cat ./
#! /usr/bin/env python2.7

def closuretest(num):
    def inner():
	num += 1
	return num
    return inner

fn = closuretest(2)
print fn()
print fn()

There are ways to use the assignment operator and create a closure, but not without using some Python techniques that would likely baffle your peers. I doubt this is a big deal, but it was a surprise about Python for me.

User-Requested Name Mangling

There is a name-mangling feature you get when you use two leading underscores and at most one trailing underscore in the variable name. The Python Tutorial states that this feature allows a class to protect itself from its descendants when there’s a method it needs to rely on for its own integrity. There’s no other way in Python for the base class to prevent derived classes from overriding it. (Strictly speaking, it doesn’t prevent it. But it does make accidental overrides less likely.)

bash$ ./ 
hi B
hi B
hi A
{'__module__': '__main__', '__doc__': None, 'fn': <function fn at 0x1004960c8>, '_B__fn': <function __fn at 0x1004967d0>}
bash$ cat
#! /usr/bin/env python2.7

class A():
    def fn(self):
        print 'hi A'
    def __fn(self):
        print 'hi A'

class B(A):
    def fn(self):
        print 'hi B'
    def __fn(self):
        print 'hi B'

b = B()
print b.__class__.__dict__

See how Python has a special case for method names that start with two underscores and end with at most one underscore? It prepends ‘_’ + self.__class__.__name__ + ‘__’ behind the scenes. Surprise!

One-time Default Keyword Parameter Evaluation

What do you think this will print? Maybe three lines of ‘[0]’?

bash$ cat
#! /usr/bin/env python2.7

def fn(mylist=[]):
    print mylist


You might think that because each invocation of the function creates a fresh namespace, you’d get a new empty list assigned to mylist each time it is called with no parameter.

That’s not how it works, though. There’s persistent state. See:

bash$ ./ 
[0, 1]
[0, 1, 2]

Where’s the state? It appears to live in an attribute called func_defaults. Here I am inside the interactive REPL:

>>> def fn(mylist=[]):
def fn(mylist=[]):
...   mylist.append(len(mylist))
...   print mylist
  print mylist

>>> fn()
>>> fn()
[0, 1]
>>> print fn.func_defaults
print fn.func_defaults
([0, 1],)

This surprise also appears in the tutorial in the form of a warning: Default Argument Values.

Building gccgo on Solaris 11 x86_64

I wanted to jot down what happened Friday night.  I tried out gccgo on Solaris 11, and it seems to work.  It turns out if you want to use Go (the toolchain) on Solaris, you can use the Go language support that is part of recent versions of gcc.

bash:~/tmp$ cat first.go
package main

import "fmt"

func main() {
bash:~/tmp$ gccgo first.go
bash:~/tmp$ LD_LIBRARY_PATH=~/opt/gcc-4.8.2/lib ./a.out

I’ll use bash, the Bourne Again Shell, to allow a kind of short hand in the recipe below. If I made a typo, please let me know in the comments. Here’s a brief key to the bashisms:

bashism meaning example
!$ the last thing (rightmost argument) on the previous command bash$ echo one two three
bash$ echo !$
!$:t the basename of the last thing from the previous command bash$ echo one/two/three
bash$ echo !$:t
!$:t:r the extension removed from the basename of the last thing bash$ echo one/two.three
bash$ echo !$:t:r

Here’s the recipe. First it builds and installs two libraries that gcc needs. Then it does the same for gcc itself. The installation goes into ~/opt.


mkdir -p packages build opt
cd packages
cd ~/build && xzcat ~/packages/!$:t | tar xf -
cd gmp-5.1.3 && mkdir ~/opt/gmp-5.1.3
./configure --prefix=$HOME/opt/gmp-5.1.3 && make install


cd ~/packages
cd ~/build && xzcat ~/packages/!$:t | tar xf - && cd !$:r:r && mkdir ~/opt/!$:r:r
./configure --prefix=$HOME/opt/!$:t --with-gmp=$HOME/opt/gmp-5.1.3 && make install


cd ~/packages
cd ~/build && tar xf ~/packages/!$:t && mkdir ~/opt/!$:t:r:r && mkdir !$:t:r:r-objdir && cd !$:t:r:r-objdir && echo !$:t:r:r
../!$/configure --prefix=$HOME/opt/!$ --enable-languages=c,c++,go --prefix="$HOME"/opt/gcc-4.8.2 --with-gmp=$HOME/opt/gmp-5.1.3 --with-mpfr=$HOME/opt/mpfr-3.1.2
gmake install

mkdir ~/opt/bin
cd ~/opt/bin
for i in ../gcc-4.8.2/bin/*; do echo ln -s "$i"; done | sh -x

Squat-centric Workout

In the spirit of Crossfit, I’d like to name this workout.  I can’t think of a good one, yet.


In brief, here’s the routine.  It is not timed.

One round consists of the following movements:

  • pullups
  • alternating one-hand clean and press with 20 kg kettlebell (abbreviated KB C&P)
  • rippetoe squat off sawhorses with approximately 1/3 1-rep-max weight
  • alternating hand turkish get up with light kettlebell

Last time, I did this series of rounds:

  • 3 pullups, 2/2 KB C&P, 4 squats, 1/1 getup
  • 4 pullups, 3/3 KB C&P, 8 squats, 1/1 getup
  • 5 pullups, 4/4 KB C&P, 12 squats, 1/1 getup

The focus is really increasing the reps for squats.  The inspiration is Dan John.  Even though the focus of the article I’m drawing on was gaining mass, and that’s not my goal, it’s generally true that high-rep squats are a powerful stimulus.  One of my goals is to have a safe workout that has a high impact-to-time-spent ratio, and I think this workout hits that mark.

My rep count is lower than those in the article, but I plan to go a bit higher as long as it doesn’t get tedious.  Here’s a link to the Dan John article:

Some notes:

The pullup is a great exercise, but often when describing my workouts to friends, they say they cannot really do a pullup.  For that I think the best option is probably to use bands for assisted pullups.  Here’s a video to give you the idea.

The one-arm kettlebell clean and press looks like this:

The squat I’m talking about is the one that strength expert Mark Rippetoe recommends.  It’s at least as low as the video shows, and it’s somewhere between a powerlifting squat and an olympic-style squat.  When using saw horses as a poor-man’s squat rack, there is an extra initial movement to get the bar to the standing position.  The towel protects my clothes.

The getup is kind of an active rest that keeps the workout pleasant, helps coordination and balance, and is also a Dan John favorite.  Here is a video showing the movement.  I am not nearly so particular about how I do this movement, so long as I start out lying on my back, wind up standing up straight, and go back down to lying, with the weight fully extended the whole time.

No, Mom, That’s SMS

Today my mother got her first smartphone.  I want it to be as simple and pleasant as possible for her to take this leap, but she’s going to be on my plan, so I covered some basics.  Here’s what I told her.  I’d like to know if I lied, so comments are encouraged.  But I already know that this version of the facts is AT&T specific.

The Parts

We get service from AT&T, our carrier.  Other carriers include Sprint, Verizon, and T-Mobile.  The cell towers talk to our phones.  AT&T makes everything outside our phone work for us.  Because of the way our plan works, we need to consider three different services that AT&T provides.

The Three Services

  1. voice – The voice service is a shared, limited number of minutes for calls.  My wife will use most of these.  Calling each other on our cell phones doesn’t count toward the limit.
  2. SMS – This is an old, limited way to send text messages.  It is expensive compared to sending text messages over data.  Mom doesn’t text, so I’ll get into details later about how she can send texts over data.
  3. data – Mom will have 300 MB per month of data usage.  When her phone accesses the Internet via the cell towers, that’s using the data plan.  If she just uses navigation and occasional web browsing, the 300 MB will seem large.  If she watches videos or listens to music when out and about, it won’t be enough.  For that, she can use wifi (see below).

Using the Phone

This will be a refurbished Samsung Note II, nice for her because it’s larger and because of its stylus.  Also its Google integration will be useful to her, I think, for navigating, her main reason for upgrading to a smartphone.

I only covered two uses of the phone, and she asked about a third.

  1. calling – In the AT&T store, she tried calling me while I stood outside.  I had her use the speaker phone, too.
  2. navigation – We used Google Maps to see Boulder, Colorado, and to get directions and start navigation.  She liked it.
  3. bridge – She asked whether she could play (the card game) bridge on the phone, and I said that there were probably a bunch of bridge games in the Play Store.  This led to a discussion of apps and the Play Store.

I told her that AT&T only provides a few apps.  By far, most of the apps she’ll get are from independent third parties.  I told her a story about how I looked for a nice French-English dictionary app last night.  I found some free ones, some great looking ones for $24.99, and one that I almost got for $5.49, but I finally remembered Google Translate and noticed that it has gotten a whole lot nicer since I last used it, and it’s free.


We talked about Google a bit, and I summarized by saying that they release things early and then note the reaction of consumers before launching again, bigger and better, or pulling the plug.  They offer useful things for free and figure out some way to make money off it at leisure, while addicting everyone to Google.  Often I will curse Google when a familiar app or service suddenly changes, but usually things generally move in a direction of general improvement.