VSCode: Add "cmd-shift-m" keyboard shortcut for "%>%" (pipe operator) for R development

RStudio uses the "cmd-shift-m" keyboard shortcut to insert the tidyverse pipe operator (%>%). If you are using VSCode to write R code, it's nice to have this there too. Here's what you need to add to keybindings.json to get this into place:

    {
        "key": "shift+cmd+m",
        "command": "-workbench.actions.view.problems"
    },
    {
        "key": "shift+cmd+m",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "snippet": "%>% "
        }
    },
    {
        "key": "shift+cmd+m",
        "command": "workbench.action.terminal.sendSequence",
        "when": "terminalFocus",
        "args": {
            "text": "%>% "
        }
    }

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 t.co 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 onenote.com.

However, there is an easy way to grab a backup. Use the “Download” option on onedrive.com 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.