iOS shortcut to convert the contents of a tweet to Markdown

I often find myself wanting to grab the contents of a tweet in Markdown format to post on my blog, so I’ve created an iOS shortcut that takes the URL to a tweet, grabs the contents via the public Twitter API, expands URLs, and copies the content to the clipboard.

Here’s an example tweet:

And here’s what the output of the Shortcut looks like:

Storing and retrieving passwords in bash scripts from the macOS keychain

It's often convenient to store a password in the macOS system keychain and retrieve it inside a shell script.

Here's the bash command for setting a password:

security add-generic-password -s "Keychain item name here" -a "username here" -p

Then enter your password when prompted.

After you run this once, you can retrieve the password in a script like this:

PASSWORD=`security find-generic-password -s "Keychain item name here" -a "username here" -w`

You can then use $PASSWORD whenever you need the password in your script.

Backing up OneNote notebooks

By default, OneNote stores notebooks on OneDrive in a “Documents/“ folder. But the notebooks are not downloaded locally by the OneDrive sync client — the sync client simply downloads “.url” link files that take you to the notebook on

However, there is an easy way to grab a backup. Use the “Download” option on to download a .zip file of the entire “Documents/“ folder. This .zip will have all your notebooks in the open, documented OneNote file format.

Update (November 7, 2019): Thanks to David Mytton for pointing out that this only works for personal Office365 accounts. If you have a business account, OneDrive will store your OneNote notebooks in a "Notebooks/" folder rather than a "Documents/" folder, and it will not let you download this folder. This is a known issue and Microsoft is working to resolve it.

Using Pipenv with R Markdown and reticulate

R Markdown is very nice way to write literate R code. Recently, reticulate became available, which bridges R and Python in R Markdown documents.

If you use Pipenv for Python dependency management, here's how you get reticulate to use the proper Python executable:

venv <- system("pipenv --venv", inter = TRUE)
use_virtualenv(venv, required = TRUE)

The py_config() command should print out the path to the Python executable in the virtualenv created by Pipenv.