Skip to content

Instantly share code, notes, and snippets.

View stefco's full-sized avatar
😳

Stefan Countryman stefco

😳
View GitHub Profile
@stefco
stefco / donkey.sh
Last active April 25, 2016 06:12
Donkey, get back in the heap
#!/bin/bash
# install a powerful script with a special productivity advantage for mac users
(
cat <<-LAYERS
cat <<-OGRESARELIKELAYERS
,M, 7M=
= MMMM, M
@stefco
stefco / shibb-cas-get.sh
Created April 14, 2016 01:23 — forked from olberger/shibb-cas-get.sh
Connection to a web app protected via Shibboleth with curl
#!/bin/sh
#set -x
# Usage: shibb-cas-get.sh {username} {password} # If you have any errors try removing the redirects to get more information
# The service to be called, and a url-encoded version (the url encoding isn't perfect, if you're encoding complex stuff you may wish to replace with a different method)
DEST=https://myapp.example.com/
SP=https://myapp.example.com/index.php
IDP="https://myidp.example.com/idp/shibboleth&btn_sso=SSOok"
@stefco
stefco / three-fingered-claw.sh
Last active May 27, 2016 15:38
The Three Fingered Claw
#!/bin/sh
# good for error-logging and mixing safe/unsafe execution
LOGFILE=/dev/stderr # default
log() { echo "$(date +'%D %H:%M:%S:') $*" >> "$LOGFILE"; }
die() { log "$*"; exit 111; }
try() { "$@" || die "Invalid: $*"; }
@stefco
stefco / constants.py
Last active May 8, 2016 04:07
a buncha constants that come in handy while doin some calculations!!! use em for astrophysics or whatever, i don't care1!!!
# a buncha constants that come in handy while doin some calculations!!!
# just copy and paste this and run it in your ipython or julia interpreter,
# what are you worried about?? it's just a buncha constants, i didn't
# make em up, i'm just usin em!!!!!
alpha = 0.00729927 # fine structure constant
k = 1.38064852e-23 # boltzman constant (J/K)
keV = 8.6173324e-5 # boltzman constant (eV/K)
Na = 6.022140857e23 # avogadro constant (1/mol)
RgasJ = 8.3144598 # gas constant (J/(K mol))
atm = 1.013e5 # 1 atmosphere (N/m^2)
@stefco
stefco / sexpr.jl
Created May 10, 2016 00:36 — forked from toivoh/sexpr.jl
lispy AST printer and reader
# ---- @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)
#!/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
#------------------------------------------------------------------------------
@stefco
stefco / imessage
Created May 30, 2016 03:35 — forked from aktau/imessage
Send iMessage from the commandline
#!/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
@stefco
stefco / newblanksite
Created July 15, 2016 16:33
Make a new website from a template in some folder, and replacing a placeholder string with the customer's name
#!/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'
@stefco
stefco / macsetup.sh
Last active July 1, 2017 12:12
This installs everything you need to work with LIGO on a Mac
#!/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
#!/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