WhatOrganizing information. I tend to write stuff down a lot. Things that I learn, books I read, etc. and I found out that paper does not allow me to
Ctrl-R. Sorry I don’t
^W) and is hard to carry around. It’s not easy to replicate paper and even worse: I have observed that when you edit one paper copy, the content on the other copies stays the same.
My solution was to write all of my notes in google docs, and when I started doing so I naturally started to complicate what I needed from my digital pen and paper: I hardly ever find the time to go over my previous notes, so why not make it a little easier to read every piece of note that I take at least once?
My solution? I thought that it would be convenient to receive an email containing my newest notes every night.
HowAt first I was planning to wrap this into a web app that everyone could use, but I remembered how I think of app developers/users who require/give unnecessary access to personal data, and I decided not to create another information honeypot.
The first roadblock was that google drive api does not allow you to retrieve google docs revisions. That would leave me to either generate the diffs myself, or program to a browser engine to acquire the revisions through the UI (similar to this unbelievably amazing piece of code). I lack superpowers so I chose to go with the former. (But to save my ego I’m going to pretend that I did that to make the solution more versatile)
To access the drive api you have to use oauth2 and therefore need to go through the somewhat complex and slow process of creating a project in your google developer dashboard and enable the drive api key for it. You’ll obtain a
You can then download (includes waiting for google drive go api bindings to download the whole universe to satisfy its dependencies), compile and install digest by doing:
$GOPATH/binis in your
$PATH, you’ll be able to execute
credentials.jsonfile? put it here:
$GOOGLE_DRIVE_FOLDER_NAMEis the name of the folder which contains all of your notes and preferably nothing else. (If you are organized (read: obsessive) enough to write everything in Google docs, and more importantly are willing to review what you write in a systematic manner, I assume that you have 10+ levels of nesting in your documents structure. Just use the name of the top level folder).
viperallows you to seamlessly accept environment variables for the flags:
$DIG_SMTP_PASSconveniently can be set as an environment variable instead of passing in
And that’s it. This first execution takes the first snapshot, and does not yet send you an email. Your subsequent usages will probably look like this:
digestis successfully run. If no difference is found between two consecutive snapshots, you’ll enjoy some free panic in your email:
And the content of the email gets a little bit more interesting when you’ve actually applied some changes to your docs:
$ digestcommand on my pc everyday, just before I call it a night and read the emailed diff on my phone on my way back home. However if you only hang out with the very cool kids you may already be thinking about:
Anyway, if digest fits in your routine, do tell me about it! Specially if it involves crazy automation scenarios (Bonus points if you manage to trigger it with your office door lock).
UPD: Again if the following condition is true about you, you won’t need no mortal’s guidance but if you’re a
systemdfreak, you may want to use hooks to
digestyour notes before a shutdown/hibernate. Hint:
InternalsHere’s part of the project directory structure:
I have implemented the following services in their respective directories and have hooked everything up together (a little uglier than usual I must say) in
├── cmd │ └── digest │ ├── digest.go │ └── main.go ├── diff │ ├── diff.go ├── drive │ ├── auth.go │ ├── drive.go ├── smtp │ ├── smtp.go