Skip to content

Instantly share code, notes, and snippets.


Max Masnick masnick

View GitHub Profile
masnick /
Created Jul 17, 2015
IPython post hook for saving `.py` and `.html` files from notebooks
import os
from subprocess import check_call
c = get_config()
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py scripts"""
if model['type'] != 'notebook':

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:

masnick / How I Do
Created Nov 25, 2020 — forked from jerieljan/How I Do
PlantUML with Style -- How I do PlantUML
View How I Do

I use PlantUML a lot. It's what I use for drawing all sorts of diagrams and it's handy because of its easy markup (once you get used to it) while making things easy to maintain as projects grow (thanks to version control)

This gist explains how I do my PlantUML workspace in a project.

  • The idea is to keep a globals directory for all diagrams to follow (like the "stylesheet" below) to keep things consistent.
  • I use a stylesheet.iuml file that keeps the use of colors consistent through use of basic FOREGROUND, BACKGROUND and ACCENT colors.
  • The style-presets.iuml file defines these colors so you can make "presets" or "themes" out of them.
  • As stated in the stylesheet.iuml, you'll need the Roboto Condensed and Inconsolata fonts for these to work properly.
  • You can choose to either run the PlantUML jar over your file/s, or use an IDE like VSCode with the PlantUML extension. Here's a preview of example-sequence.puml for example:
masnick / gist:1291199
Created Oct 16, 2011
jQuery inject one-liner
View gist:1291199
var a=document.createElement("script");a.type="text/javascript";a.async=true;a.src="";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b);
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)