This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (c) Stefan Countryman 2017 | |
# useful classes and decorators for Python code, particularly python 2.7 | |
def multiprocessing_traceback(func): | |
"""A decorator for formatting exception traceback into a string to aid in | |
debugging when using the ``multiprocessing`` module.""" | |
import traceback, functools | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find filenames of MATLAB functions called in a given script or function; call | |
# from the MATLAB working directory where functions are defined. takes the | |
# script to be searched as its argument. | |
matlab-files-called () { | |
if (! [ $# -eq 1 ]) || [ "$1"c = -hc ]; then | |
echo "ERROR: 1 argument required" | |
echo "Usage: matlab-files-called MATLAB_Script_To_Search.m" | |
return 1 | |
fi | |
find . -maxdepth 1 -iname '*.m' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git add, commit, and push | |
gadcmtpu () { | |
if ! [ $# -eq 1 ]; then | |
echo "ERROR: 1 argument required" | |
echo "Usage: gadcmtpu filename" | |
exit 1 | |
fi | |
echo 'COMMITTING AND PUSHING.' | |
echo 'CURRENT STATUS:' | |
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo port install bash bash-completion | |
sudo port install vim | |
sudo port install git | |
sudo port install julia | |
sudo port install py27-jupyter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# ligo stuff taken from https://wiki.ligo.org/DASWG/MacPorts and other sources | |
# run this as an admin but not as root. | |
# Use shellcheck for linting: http://www.shellcheck.net/# | |
set -o errexit | |
set -o nounset | |
set -o noclobber | |
cat <<NOTES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#------------------------------------------------------------------------------ | |
# HELP INFO | |
#------------------------------------------------------------------------------ | |
# | |
# example usage: make a new web site in a folder called "new_site" for someone | |
# named Rachel Bronstein: | |
# | |
# newblanksite new_site 'Rachel Bronstein' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi | |
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit | |
-- another way of waiting until an app is running | |
on waitUntilRunning(appname, delaytime) | |
repeat until my appIsRunning(appname) | |
tell application "Messages" to close window 1 | |
delay delaytime | |
end repeat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#------------------------------------------------------------------------------ | |
# bash script template by Stefan Countryman | |
# fill in the blanks as you go, crossing out todos as you finish them | |
# check your code for common mistakes with ShellCheck linter! | |
# browser-based: http://www.shellcheck.net/# | |
# install: https://github.com/koalaman/shellcheck#user-content-installing | |
# TODO: WRITE SCRIPT SUMMARY HERE | |
#------------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- @sexpr: S-expression to AST conversion ---- | |
is_expr(ex, head::Symbol) = (isa(ex, Expr) && (ex.head == head)) | |
is_expr(ex, head::Symbol, n::Int) = is_expr(ex, head) && length(ex.args) == n | |
macro sexpr(ex) | |
esc(sexpr_to_expr(ex)) | |
end | |
sexpr_to_expr(ex) = expr(:quote, ex) |