Day 48: A Lockdown Cliché

I’ve never been a serious baker, but in the past I have dabbled a bit with bread making. Mostly I made simple whole grain loaves that were meant to be consumed for daily meals. I came upon a recipe for challah, and remembered how much I liked that kind of bread when I had eaten it at friends’ homes as a kid. It turned out not to be very difficult to make, and I got good at the braiding. I was hosting a New Year’s Eve party to welcome in 1981, and made this as the centerpiece of the food spread:

Happy New Year!

But over the years I pretty much stopped baking, mostly due to time constraints. But this past spring the dual whammy of getting laid off at the beginning of the pandemic lockdown left me with lots of time on my hands.

I have always been fascinated by sourdough bread: using the natural yeast and bacteria in the air around us to not only introduce air into the dough, but to transform the nutrients locked up in the wheat kernel into a form that we humans can digest. In particular, the book Cooked by Michael Pollan (now also a Netflix series) really made me want to learn how to do this myself.

So I googled around to compare different techniques for making a sourdough starter, and settled on one that seemed the best (they’re all pretty much the same, though). Within a week I had a pretty healthy batch of starter, and made my first loaves from it. They tasted fine, but were very flat, and lacked that killer crust that is the hallmark of a good sourdough. I read various articles on different techniques, and what I seemed to be missing was the entire shaping process that builds the structure of the dough. Who knew that dough needed structure?

I watched a lot of videos, and liked this one the best. I’ve made many loaves since then, and they’ve always come out delicious! They look pretty good, too:

Crispy, crunchy crust with lots of flavor!

Besides the taste, I love to see the intricate structure of the bread – it’s amazing to think of the millions and millions of cells that went into generating the gas to raise the bread, and the intricate structure of the wheat to trap that gas. Just look at that detail!

Sourdough close-up

I have taken lots of macro photos of these loaves, and created a gallery on my website called Sourdough Porn that is filled with shots like these.

So while baking sourdough bread during the lockdown is a bit of a cliché, it’s definitely a fun and delicious cliché!

Day 47: Python Virtualenvs

If you’re not a Python programmer, you probably won’t find much in this post. Sorry.

If you are a Python programmer, then you probably know about virtualenvs, or virtual environments. They allow you to create several different Python environments to work in: each can have it’s own version of Python, as well as its own installed packages. This means I can work on a project that has particular requirements, and then switch to a project with completely different requirements, and the two won’t affect each other.

A while ago I used to use vitualenvwrapper, which made working with virtualenvs a lot easier. But as I switched to Python 3 over the past few years, I started to have some issues where it didn’t work correctly (sorry, I no longer recall precisely what those issues were). I’m sure a lot had to do with the addition of the venv module into Python 3, which allowed you to create a virtualenv by running python -m venv /path/to/virtualenv.

For a while I ran all the commands manually, but I have the quality that makes for good programmers: I’m lazy. A lazy person doesn’t want to do any more work than they have to, so if I can automate something to save time over the long run, I will. And here’s what I came up with:

export VENV_HOME=$HOME/venvs

function workon { 
    if [ -z $1 ]
    then
        ls -1 $VENV_HOME
    else
        source $VENV_HOME/$1/bin/activate
    fi
}

function mkvenv {
    python3 -m venv $VENV_HOME/$1
    workon $1
    pip install -U pip setuptools wheel
    pip install ipython pytest-pudb requests
}

function rmvenv {
    command -v deactivate
    rm -rf $VENV_HOME/$1
}

_venvdirs()
{
    local cur="$2"
    COMPREPLY=( $(cd $HOME/venvs && compgen -d -- "${cur}" ) );
}
complete -F _venvdirs workon rmvenv 
Code language: Bash (bash)

These lines should be added to your .bashrc in Linux, or your .bash_profile for Macs. I haven’t tried them with zsh yet, so no guarantees there. Let’s go over what these lines do.

Line #1 defines the directory where the virtualenvs will be stored. You can store them anywhere; it doesn’t make any difference.

Lines #3–10 define the workon function, which activates the specified virtualenv, or lists all virtualenvs if none is specified. Lines 12–17 define the mkvenv function, which creates a new venv, and lines 19–22 define rmvenv, which deletes virtualenvs when you no longer need them.

I’d like to point out 2 lines in mkvenv that you can customize. Line #15 updates the installed versions of pip, setuptools, and wheel. If for some reason you don’t want the latest versions of these, edit or remove that line.

Line #16 is more interesting: nearly every virtualenv I create needs these packages installed. Rather than install them one-by-one, I add them when I create the virtualenv. If you have different packages you always want available, edit this line.

Finally, lines #24–29 are of utmost importance to someone lazy like myself: they provide auto-completion for the other commands. I had to learn about bash completion to get that working, but it turned out to be much easier than I had imagined.

Here is a gif showing it in action:

Try it out! Let me know if you find this useful, or if you have suggestions for improvement.

Day 46: The First Emergence

Today was very busy, but doing lot a lot of different things rather than one main task. So it’s the early evening and I’m finally sitting down to write.

The day started off early: I had just put water on for our morning coffee, and while it was heating I checked out the caterpillar enclosures. I saw a lot of fluttering in one, and sure enough, there was a male butterfly trying to find its way out.

First butterfly of the brood

When the butterflies emerge, they typically hang out for a couple of hours until their wings are fully expanded and dry before they try to fly away. This guy must have emerged a few hours earlier, because he was raring to go. I took the above picture as he was crawling up the side of the enclosure. Once he reached the top, off he flew!

This was the first adult butterfly that came from this large crop of eggs that I found a few weeks ago:

29 swallowtail eggs!

The enclosures have been filling up with pupas from that brood. Here are a few of them:

Lots of pupas!

You might recognize the contraption made of sticks from an earlier post; there are now 7 pupas attached to it! the five unattached pupas are either caterpillars that attached to a sprig of parsley, which will dry up in the enclosure. Notice that the one on the right still has a bit of parsley stalk attached to it. Other caterpillars sometimes give up trying to find a place to attach themselves, and just curl up on the ground. I’ve had that happen before, and they result in normal butterflies, so I’m feeling positive that these will too.

There are only a few caterpillars left who are still munching away and getting bigger. The rest have pupated, so in the coming days I’m sure I’ll find a lot more butterflies emerging from those pupas. I just hope that they have the decency to wait until I’ve had my coffee before doing so!

Day 45: Composing Music and Code

I am not a musician. Yeah, I was a vocalist in a couple of bands in high school and college, but all I really did is copy the original song. The notion of coming up with a new approach to a song was way beyond my imagination.

I am amazed by people who can write their own original songs. How can you create a melody from… nothing? It really is beyond my ability to comprehend. Lyrics seem straightforward enough, but the music?

A few years ago at a conference I was hanging around in the evening with some friends, several of whom were musicians that had brought their guitars. One of them played a song, and I asked him where the song was from. He replied that it was one of his own. “Wait: you wrote that yourself?” That surprised the hell out of me!

Now that my curiosity was piqued, I couldn’t help but ask him how he does it. He replied that sometimes he has some little bits of music in his head, just a couple of notes. When he’s practicing his guitar, he’d just sit around playing some small riffs; just a few notes here and there. He’ll play one, then change it up a little bit, and if it sounds better, he’ll start working with that. Over time he’ll have a few more such bits floating around in his head, and every now and then he’ll play a few that just start to flow together. At that moment he can hear the overall melody, and he has to write it down, or record it – anything to capture it before it fades. It doesn’t matter what time of day it is, or what else is happening; he can’t do anything else until he has it down on paper/tape/whatever.

Now I understood: his process for composing music was very similar to what I experience when coming up with a coding design to a given problem. I’ll play around in my mind with a few approaches I’ve used in the past, changing them around as needed to see if that would work. At some point, though, the pieces seem to align themselves into the solution I need, and I can see it clearly in my mind. At that point, I have to write down what I’m seeing before I lose it. I can remember times when I missed appointments because I was heads-down writing such a solution.

The act of creation is remarkably similar for both cases: playing around with ideas/riffs, and once the solution “appears”, a furious effort to record it. And it’s that “playing around” part that is really hard to explain to others: to them, it just looks like you’re screwing around instead of working.

I do my best thinking when I’m walking, not when I’m planted in front of a keyboard. If you’re ever stuck trying to come up with a solution, try changing what you’re doing. Go for a walk, work on your garden, vacuum the floor – anything to move away from the computer and get your body moving. That act alone helps free the brain to make connections that it might otherwise never make.

Day 44: Employed Once More!

After 3 1/2 months of unemployment, during which I submitted countless job applications, became a regular on LinkedIn, learned the routines of the Texas Unemployment Benefits system, and sat through numerous interviews, I’m excited to report that I have a new job!

In a couple of weeks I will be starting at Nvidia as a Senior Python Developer, working on the tools for their GPU cloud. I’ve met the other people on my team during the video interview process, and they all seem like a bright bunch, so I can’t wait to start working with them!

It’s been difficult these last few months. It started with the pandemic and subsequent lockdown, which has affected everyone. Then came the layoff, with DataRobot letting 25% of its workforce go, including yours truly. It really wasn’t much consolation that I was only 1 of the 40 million or so in the US who lost their job in those few weeks – it still hurt.

Still, I have had it better than most. My wife still had her job, which was super-important financially. We also had some savings, so we weren’t living paycheck-to-paycheck like so many Americans have to. And it did give me some free time to work on my photoviewer software, and practice my newly-discovered sport of disc golf. It also gave me the chance to perfect my sourdough bread technique (yeah, I know – how cliché!). But there is only so much to do when largely confined to the house.

Which is why I started this daily writing exercise. Not just to fill the time, but to get down some of the thoughts that have been in my head for a while, and polish my rusty writing skills. And while it’s been difficult to always find something to write about, I have noticed that writing itself is feeling more fluid.

I will continue this daily project until I start the job on July 20. After that, I will continue to write, but just not on a daily basis. Going through this exercise has helped me enjoy writing more, and improved my ability to let a piece out into the wild without first obsessing with endless editing. That is probably the best thing I’ve gotten out of it.