Skip to content

Instantly share code, notes, and snippets.

View masnick's full-sized avatar

Max Masnick masnick

View GitHub Profile
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
@masnick
masnick / modified-zotselect-link.js
Last active November 13, 2023 08:16
Zotero export translator for getting zotero:// link and article information

May 2023 Webinar References

  • Brandt PS, Pacheco JA, Adekkanattu P, Sholle ET, Abedian S, Stone DJ, et al. Design and validation of a FHIR-based EHR-driven phenotyping toolbox. Journal of the American Medical Informatics Association 2022;29:1449–60. https://doi.org/10.1093/jamia/ocac063.
  • Cheng AC, Banasiewicz MK, Johnson JD, Sulieman L, Kennedy N, Delacqua F, et al. Evaluating automated electronic case report form data entry from electronic health records. J Clin Trans Sci 2023;7:e29. https://doi.org/10.1017/cts.2022.514.
  • Lobach DF, Boxwala A, Kashyap N, Heaney-Huls K, Chiao AB, Rafter T, et al. Integrating a Patient Engagement App into an Electronic Health Record-Enabled Workflow Using Interoperability Standards. Appl Clin Inform 2022;13:1163–71. https://doi.org/10.1055/s-0042-1758736.
  • Strasberg HR, Rhodes B, Del Fiol G, Jenders RA, Haug PJ, Kawamoto K. Contemporary clinical decision support standards using Health Level Seven International Fast Healthcare Interoperability Resources. Journal of
This file has been truncated, but you can view the full file.
{
"resourceType": "CapabilityStatement",
"id": "56f84ad0-40bd-47ec-a5fa-d8b116137939",
"name": "RestServer",
"status": "active",
"date": "2023-04-23T18:27:32.431+00:00",
"publisher": "Not provided",
"copyright": "This server is **Open Source Software**, licensed under the terms of the [Apache Software License 2.0](https://www.apache.org/licenses/LICENSE-2.0).",
"kind": "instance",
"software": {
@masnick
masnick / trim.scpt
Created November 8, 2017 18:06
Trim whitespace with AppleScript
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
@masnick
masnick / move.sh
Created April 22, 2016 12:50
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\""

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:

@masnick
masnick / fix_dates.R
Last active July 31, 2022 00:11
Fix up date columns in 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 / balance.scpt
Last active March 31, 2022 19:04
macOS: Set sound output balance to middle
-- Based on the AppleScript posted here: https://secure.macscripter.net/viewtopic.php?pid=190067
tell application "System Preferences"
activate
reveal anchor "output" of pane id "com.apple.preference.sound"
delay 0.5 -- If you get an error, it's possible this delay isn't long enough.
end tell
tell application "System Events"
tell slider 1 of group 1 of tab group 1 of window 1 of process "System Preferences"
set value to 0.5
end tell
@masnick
masnick / ipython_notebook_config.py
Created July 17, 2015 17:42
IPython post hook for saving `.py` and `.html` files from notebooks
# http://stackoverflow.com/questions/29329667/ipython-notebook-script-deprecated-how-to-replace-with-post-save-hook
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':