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
masnick / private.xml
Created May 9, 2016
Disable Command-F1 with Karabiner
View private.xml
<?xml version="1.0"?>
<root>
<item>
<name>Disable Command-F1</name>
<identifier>private.disable.command.f1</identifier>
<autogen>--KeyToKey-- ConsumerKeyCode::BRIGHTNESS_DOWN, ModifierFlag::COMMAND_L, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
<autogen>--KeyToKey-- ConsumerKeyCode::BRIGHTNESS_DOWN, ModifierFlag::COMMAND_R, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
</item>
</root>
@masnick
masnick / compare_2_sirs.py
Last active Apr 28, 2016
Compare 2 SIRs in Python
View compare_2_sirs.py
"""
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: http://www.cdc.gov/nhsn/sas/binom.sas
Author: Max Masnick, PhD (https://masnick.org/contact)
Last modified: 2016-04-28
@masnick
masnick / move.sh
Created Apr 22, 2016
Move newest file in Downloads folder to the frontmost Finder window
View move.sh
#! /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
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
View icd9_transform.py
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:])
else:
return icd9
@masnick
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
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 / 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="http://placekitten.com.s3.amazonaws.com/homepage-samples/408/287.jpg" />');;
View compress_all.do
cap log c
clear
set more off
cd "/path/to/folder/"
local files : dir "`c(pwd)'" files "*.dta"
clear
foreach f in `files' {
You can’t perform that action at this time.