Skip to content

Instantly share code, notes, and snippets.


Max Masnick masnick

View GitHub Profile
masnick / fix_dates.R
Last active Jul 13, 2020
Fix up date columns in R
View fix_dates.R
df_messy_dates <- tribble(
~col1_dt, ~col2_dt, ~other_data,
"2019-01-01", "2019-01-02", "a",
"2019-01-03", "1/4/2019", "b",
"01/05/2019", "2019-01-06", "c"
# A tibble: 3 x 3
# col1_dt col2_dt other_data
# <chr> <chr> <chr>
masnick /
Last active Jun 3, 2020
A strategy for writing clearer emails

From this HBR article:

  • Start email with single sentence summary:

    Bottom line: This is a better way to write emails informed by US Military practices.

  • Then have a Background section that succinctly provides the necessary context for the "bottom line."

  • Keep the whole thing as short as possible, ideally to avoid the reader having to scoll.

# Based off of
import io
import os
from notebook.utils import to_api_path
_script_exporter = None
_html_exporter = None
def script_post_save(model, os_path, contents_manager, **kwargs):
masnick / output.txt
Created Dec 28, 2019
Output of tweet to Markdown shortcut
View output.txt
[Max Masnick on Twitter](
> It’s surprisingly hard to find a tweet with multiple URLs in it for API response testing purposes.
> So here are my two favorite non-Google search engines:
> 1. <>
> 2. <>
> 👍
masnick / safari_to_chrome.applescript
Created Dec 27, 2019
Open Safari tabs in Google Chrome
View safari_to_chrome.applescript
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set url_list to {}
tell application "Safari"
set w to window 1
repeat with t in (tabs of w)
masnick / batch_convert_docx_to_pdf.applescript
Last active Dec 17, 2019
Batch convert Word files (.docx) to PDF
View batch_convert_docx_to_pdf.applescript
-- Based on (thanks, VikingOSX!)
property word_docs : {"org.openxmlformats.wordprocessingml.document", ""}
property default_path : (path to desktop) as alias
property Delim : {".docx", ".doc"}
property PDF : ".pdf"
set outPDF to {}
set selected_files to (choose file of type word_docs default location default_path with multiple selections allowed without invisibles and showing package contents)
masnick /
Created Nov 18, 2019
CiteAs bookmarklet

This is the code for a bookmarklet to open the current page in CiteAs.

masnick / phone_format.rb
Created Jan 27, 2015
Phone number format script for TextExpander snippet
View phone_format.rb
#! /usr/bin/env ruby
# Source: tadman on StackOverflow -
def formatted_number(number)
digits = number.gsub(/\D/, '').split(//)
if (digits.length == 11 and digits[0] == '1')
# Strip leading 1

Proceed at your own risk. Back up. Don't blame anyone but yourself if you lose all your email or send your personal information to a nefarious third party.


  1. On a VPS to increase speed (I used a Digital Ocean VPS):

  2. Create a text file called map with the following contents:

View choose_speakers.scpt
tell application "iTunes" to activate
tell application "System Events"
tell window "iTunes" of process "iTunes"
click (first UI element whose help is "Choose which speakers to use.")
end tell
end tell
You can’t perform that action at this time.