Random Zen Habits article


Lately, I came across the Zen Habits website. it's Leo Babauta's blog, he writes about minimalism, mindfulness and finding simplicity in everyday's life. Check his about section for more infos!

Everything looked interesting - big kudos to the very simple design- , the paradox of choice led me to think of a way where I don't have to choose what to read, and delegate this task to an automated process. You can find the source code here.


the starting point was to scrape the archive web page, and think of a way to return a random article in the page.

I have very basic knowledge in Python, but it was enough for what I needed to do.

the script does the following:

  1. gets the archive webpage.
  1. parses the file to get all the a tags.
  1. generates a number between 1 and the number of a tags in the page.
  1. returns the link in the a tag for the generated number.

You can then run this script from the command line:


And it opens a link in your web browser!


For a better UX, we can create a chrome extension which runs the the script above.

The problem with this, it's that Chrome Extension only support JavaScript code.

We have two options:

  1. Use the transpiler RapydScript to translate Python code to JavaScript.
  1. Rewrite it in Javascript :).

Happy coding!