hardscrabble 🍫

By Max Jacobson

Psst. Check out my RubyConf 2017 talk, There are no rules in Ruby.

blog posts

sleep timers

07 Sep 2014

Falling asleep is one of the weirdest things that everyone does every day. Many people struggle to do it all. They experiment and develop workflows that help cope with this necessary evil. Here’s mine.

If I’m very exhausted I simply lie down, close my eyes, and shortly thereafter I fall asleep. This isn’t very often due to my sedentary lifestyle, so I’m often lying in bed wondering what I’m supposed to be doing with my arms and/or mind. The recourse I usually take to is to play a podcast. Many would argue that listening to a podcast is counter-productive to the goal of falling asleep. I don’t completely disagree, but I like to do something to fill that time, even if doing nothing would mean less time falling asleep, podcasts make the longer time pass quicker, so it evens out.

One problem is that podcast clients often autoplay, such that when one episode ends, the next begins. If you combine this feature with the auto-download feature, this creates the risk that I will go into an infinite loop of listening to podcasts literally forever.

If I could somehow fall asleep while people were talking, I would wake up to hear them still talking, potentially about anything at all, which I imagine to be extremely disorienting.

To mitigate these risks, I’ll apply a sleep timer, which means that I’ll tell the podcast to stop playing after a specified number of minutes has passed. Here are the steps I take:

  1. I press play on a podcast
  2. I apply a sleep timer of 5-15 minutes depending on how sleepy I feel
  3. I listen to the podcast while relaxing my body and mind
  4. I sense the impending timer running out and a curious tension fills me
  5. The podcast fades out and stops and I immediately fall asleep

If I don’t fall asleep, I start over, maybe with a shorter timer. I never fall asleep before the sleep timer runs out. If I do that, I’ll miss part of the podcast, which I would hate.

It’s essential to my bedtime workflow that I have fine control over how many minutes the sleep timer will run, because I believe that I can predict how long it will take me to fall asleep based on my current level of sleepiness. It’s also important that the audio fades away because that signals my internal systems to prepare to do that last, most important step (falling asleep).

This is my main complaint about the otherwise terrific new podcast app Overcast which does offer a sleep timer, but one that can only be set in crude chunks of 5 minute increments, and which stops with no fade out at all. I won’t be switching back to Downcast, which set the standard for sleep timers for me, but I suspect my sleep will suffer.

How do you fall asleep?

vim will fix indentation mistakes

07 Sep 2014

Today I learned a neat vim trick (via the Aaron Paterson Play by Play interview):

vim auto indent gif

You can highlight some lines with visual mode and then press = and it will fix all of the indentation mistakes therein. If you’re in normal mode, you can press == to fix just the line you’re currently on.

Paterson cites this trick as an argument in favor of not indenting private methods an extra level, because vim doesn’t do that. For example:

# do this:
class Dog
  def bark
    barks.sample
  end

  private

  def barks
    ["woof", "yap", "ruff"]
  end
end

# NOT this:

class Cat
  def meow
    meows.sample
  end

  private

    def meows
      ["meow", "purr", "idk what else, cats are weird"]
    end
end

I generally do that extra indent but I might stop now :leaves:.