Day 2 — Some bash and then the memex

For the past one month, I've been trying to adjust to Eastern Time based on the assumption that I might miss out on RC activities if I'm not up at the same time as everyone else. As a result, I've been sleeping at 6am Indian Standard Time. After spending two days at RC, I feel that this has been a yuge premature optimization! Today I woke up at 3pm my time, right before early checkins with the Europe/Asia crew. Over the next few days, I plan to fix my sleep cycle because the days don't feel as long! (literally, since I don't get as much sun)

I want to talk about my website's setup for a bit. This is a static website which gets generated from a lot of markdown using pelican. I was using GitHub pages up until last month, but moved to Netlify as it is more reliable (and has more features!). The whole migration took less than 5 minutes, and I'm still using the same GitHub repo as before. In June, I added a now page which gets updated every day at 9pm. This update uses a bash script (scheduled with cron), which pulls data from the Strava and Spotify APIs, updates the now markdown, builds the whole website, and pushes all changes to the GH repo.

With the whole "one blog post per day" thing, I've been adding a draft in the GitHub repo at the start of the day, and updating it as and when I do things. I don't want unfinished drafts to get pushed to the website at 9pm. One way to solve this would be to set the cron job's time to 11:59pm and make sure I have the blog post ready by then! I could also try pelican's draft feature, I assume it won't add the draft post to the RSS feed, and also not display it on the front page. Hmm, maybe later. For now I've added a snippet to the bash script, which checks if the git status contains "Changes" or "Untracked" in it, and exits if this condition is true. I also used notify-send to notify me when this happens from the cron job, which is a nice reminder for me to finish my blog post for the day!

  git_status=$(git status)
  if echo $git_status | grep -q -E "(Changes|Untracked)"; then
      notify-send "There are unfinished drafts!"
      echo "There are unfinished drafts!"
      exit 1

I've also been pushing these posts manually after 9pm. In this case, I want to see a list of all the feeds that will update after the push, and also have an option to cancel the push if required. git diff --name-only to the rescue! It lists all the files that have been modified. For the "option to cancel" part, I used a feature of shell parameter expansion and the select construct!

I added support for a command-line argument to specify if I want an "option to cancel" prompt or not. Since it's going to be the first argument, I can access it in the script using $1. And with this nifty shell expansion feature ${1:-yes}, I can set its default value to "yes" if the argument is not passed! This means that it will always give me a prompt as I invoke the script with ./, but not do that when the script is called by the cron job using ./ no. I also learned that select can easily generate an option menu for you, from which you can then choose the option number you want.

  git diff --name-only

  if [ "$prompt" = "yes" ]; then
      echo "These files will be pushed. Do you wish to proceed?"
      select yn in "yes" "no"; do
          case $yn in
              yes ) break;;
              no ) echo "Files not pushed"; exit;;

  git add .
  git commit -m "Add files"
  git push origin master

In the late checkins, I found that Andrew is working on building a Memex! It got me really excited as I've been looking to build something similar for some time. Incidentally, I'd added the Memex wiki article to the "links to read" file I maintain, some days before. I watched his RubyConf 2018 talk and was amazed by all the features he has built. The beautiful user-interface and query language look really useful for accessing the Memex (think of it as a mind palace of sorts). He has connected literally everything (data which would otherwise be siloed in different services) to his Memex, with archives going back to 2005. I want to build a simpler (only for notes and bookmarks) command-line version of this later in the batch, or maybe just use the version Andrew open-sources! Here are some links related to "a personal API" / Memex in case you're interested.

I've also subscribed to the chat-bot, which pairs two Recursers for a coffee chat every day. You can choose the days you want to be paired, I'm going with the default (all!) for now. Also, I recently changed the new-tab view on my browser from BrainyTab (which loads a cognitive bias / mental model) to Planet View (which loads a Planet Labs image). H/T Michael.

I ended the day by building this in Virtual RC!