Skip to content

Instantly share code, notes, and snippets.

Max Masnick masnick

Block or report user

Report or block masnick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jupyter_notebook_config.py
# Based off of https://github.com/jupyter/notebook/blob/master/docs/source/extending/savehooks.rst
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
masnick / output.txt
Created Dec 28, 2019
Output of tweet to Markdown shortcut
View output.txt
[Max Masnick on Twitter](https://twitter.com/masnick/status/1209899493048639488):
> 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. <https://t.co/jFqkR0eo8x>
> 2. <https://t.co/UZD9mmtzEH>
>
> 👍
@masnick
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
try
repeat with t in (tabs of w)
@masnick
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 https://discussions.apple.com/thread/250068127 (thanks, VikingOSX!)
property word_docs : {"org.openxmlformats.wordprocessingml.document", "com.microsoft.word.doc"}
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
masnick / fix_dates.R
Last active Dec 12, 2019
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
masnick / README.md
Created Nov 18, 2019
CiteAs bookmarklet
View README.md

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

@masnick
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 - http://stackoverflow.com/a/5913838
def formatted_number(number)
digits = number.gsub(/\D/, '').split(//)
if (digits.length == 11 and digits[0] == '1')
# Strip leading 1
digits.shift
View gmail_to_fastmail.md

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.

Source: http://hynek.me/articles/fleeing-from-gmail/

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

     wget http://imaputils.googlecode.com/svn-history/r5/trunk/imapcopy.pl
    
  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
@masnick
masnick / gist:380d067da1f521b01cb0
Last active Dec 17, 2017
Find FastMail tab(s) in Safari
View gist:380d067da1f521b01cb0
-- original from http://hea-www.harvard.edu/~fine/OSX/safari-tabs.html
-- Last updated January 16, 2015 1:22 PM
set searchpat to "fastmail.com"
tell application "Safari"
activate
set winlist to every window
set winmatchlist to {}
set tabmatchlist to {}
set tabnamematchlist to {}
You can’t perform that action at this time.