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
masnick /
Last active May 23, 2016
pyenv setup instructions

OS X ships with an old version of Python 2. Here's how I set up my system:

brew install pyenv pyenv-virtualenv

Then add to .zshrc or .bashrc:

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

Then restart, and build the newest version of Python:

masnick / private.xml
Created May 9, 2016
Disable Command-F1 with Karabiner
View private.xml
<?xml version="1.0"?>
<name>Disable Command-F1</name>
<autogen>--KeyToKey-- ConsumerKeyCode::BRIGHTNESS_DOWN, ModifierFlag::COMMAND_L, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
<autogen>--KeyToKey-- ConsumerKeyCode::BRIGHTNESS_DOWN, ModifierFlag::COMMAND_R, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
masnick /
Last active Apr 28, 2016
Compare 2 SIRs in Python
Compare 2 SIRs by exact binomial and mid-p
This is a conversion of SAS code written by Minn Soe and published by the CDC.
The original SAS code is available here:
Author: Max Masnick, PhD (
Last modified: 2016-04-28
masnick /
Created Apr 22, 2016
Move newest file in Downloads folder to the frontmost Finder window
#! /usr/bin/env bash
current_folder=`osascript -e 'tell application "Finder"' -e "if (${1-1} <= (count Finder windows)) then" -e "get POSIX path of (target of window ${1-1} as alias)" -e 'else' -e 'get POSIX path of (desktop as alias)' -e 'end if' -e 'end tell'`
newest_file=`mdls -name kMDItemFSName -name kMDItemDateAdded -raw /Users/YOUR_USERNAME_HERE/Downloads/* | xargs -0 -I {} echo {} | sed 'N;s/\n/ /' | sort --reverse | head -1 | sed -E "s/^.*\\+0000 //"`
mv "/Users/YOUR_USERNAME_HERE/Downloads/$newest_file" "$current_folder"
osascript -e "display notification \"$newest_file$current_folder\" with title \"File moved\""
masnick / stata_examples.ipynb
Last active Oct 13, 2016 — forked from ChadFulton/stata_examples.ipynb
SARIMAX - Stata Examples
View stata_examples.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View path_to_selected_finder_item.applescript
tell application "Finder"
set finderSelList to selection as alias list
end tell
if finderSelList {} then
repeat with i in finderSelList
set contents of i to POSIX path of (contents of i)
end repeat
set AppleScript's text item delimiters to linefeed
def icd9_transform(icd9):
l = len(icd9)
if l == 3:
return "%s000" % icd9
elif l == 4:
return "%s00%s" % (icd9[0:3], icd9[-1:])
elif l == 5:
return "%s0%s" % (icd9[0:3], icd9[-2:])
return icd9
masnick / URL from Chrome.applescript
Created Mar 22, 2016
Get the URL from the active Chrome tab/window for TextExpander
View URL from Chrome.applescript
tell application "Google Chrome"
set frontIndex to active tab index of front window
set theURL to URL of tab frontIndex of front window
end tell
return theURL
# 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 / gist:b1c5bf9c8972ae643321
Created Feb 22, 2016
Bookmarklet for removing GIFs from a webpage
View gist:b1c5bf9c8972ae643321
javascript:$('img').filter(function() { if( this.src.indexOf('.GIF') >= 0 || this.src.indexOf('.gif') >= 0) return this; }).replaceWith('<img src="" />');;
You can’t perform that action at this time.