Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Masnick masnick

View GitHub Profile
@masnick
masnick / emails.md
Last active Jun 3, 2020
A strategy for writing clearer emails
View emails.md

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.

@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 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
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.

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 / loadsql.ado
Last active Dec 8, 2017
Stata: load and execute SQL from a file on disk
View loadsql.ado
/*
Copyright 2017 Max Masnick
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OT
@masnick
masnick / trim.scpt
Created Nov 8, 2017
Trim whitespace with AppleScript
View trim.scpt
on trimThis(pstrSourceText, pstrCharToTrim, pstrTrimDirection)
-- http://macscripter.net/viewtopic.php?id=18519
-- pstrSourceText : The text to be trimmed
-- pstrCharToTrim : A list of characters to trim, or true to use default
-- pstrTrimDirection : Direction of Trim left, right or any value for full
set strTrimedText to pstrSourceText
-- If undefinied use default whitespaces
if pstrCharToTrim is missing value or class of pstrCharToTrim is not list then
View ipython_pickle.applescript
tell application "Keyboard Maestro Engine"
--- GET VARIABLE ---
-- IF KM Variable does NOT exist, the AS Variable will be set to empty string --
set the_path to getvariable "Path"
end tell
tell application "iTerm"
activate
create window with default profile
You can’t perform that action at this time.