Skip to content

Instantly share code, notes, and snippets.

View stefco's full-sized avatar
😳

Stefan Countryman stefco

😳
View GitHub Profile
@stefco
stefco / vigit.sh
Created November 3, 2016 21:36
Vim edit, git add, commit, push loop functions
# 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
@stefco
stefco / navigate.sh
Last active January 31, 2017 17:27
Navigate forward and backward in bash like a browser
# functions for navigating forward and backward
NAVIGATION_FWD=()
NAVIGATION_BWD=()
navigate_forward () {
if [ ${#NAVIGATION_FWD[@]} -gt 0 ]; then
NAVIGATION_BWD+=("$(pwd)")
cd "${NAVIGATION_FWD[${#NAVIGATION_FWD[@]}-1]}"
unset NAVIGATION_FWD[${#NAVIGATION_FWD[@]}-1]
fi
}
@stefco
stefco / matlab_dependency_defs.sh
Created March 27, 2017 19:54
Little GNU/Linux shell scripts for finding MATLAB code dependencies real quick 'n dirty
# 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' \
@stefco
stefco / decorators.py
Created July 10, 2017 15:06
Some useful decorators and classes for Python
# (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:
@stefco
stefco / run-python-command-in-shell.sh
Last active September 13, 2017 17:40
Run indented python code in a shell function so that things look nice and readable.
# a template that does nothing. the actual python script is 100% indented.
foo() {
python -c 'import textwrap; exec(textwrap.dedent(r"""
import sys
# remove the first argument, since it will just be '-c'
sys.argv.pop(0)
# put your actual code below
"""+" "*4))' "$@"
}
@stefco
stefco / spacemacs-keybindings
Created September 18, 2017 03:15 — forked from adham90/spacemacs-keybindings
spacemacs keybindings that i need to learn
SPC s c remove highlight
**** Files manipulations key bindings
Files manipulation commands (start with ~f~):
| Key Binding | Description |
|-------------+----------------------------------------------------------------|
| ~SPC f c~ | copy current file to a different location |
| ~SPC f C d~ | convert file from unix to dos encoding |
| ~SPC f C u~ | convert file from dos to unix encoding |
@stefco
stefco / aliases
Created September 25, 2017 15:12 — forked from kaleb/aliases
Gmail on Mutt
#~/.mutt/aliases
alias nick Nicholas Levandoski <[email protected]>
alias tim Timothy Pitt <[email protected]>
alias steven Steven Jackson <[email protected]>
alias kaleb Kaleb Hornsby <[email protected]>
alias alug-admin nick, tim, steven
@stefco
stefco / New-iTerm-Window.scpt
Created October 1, 2017 20:42 — forked from reyjrar/New-iTerm-Window.scpt
AppleScript to Open a New iTerm Window and bring it to the front
(*
* New-iTerm-Window.scpt
*
* Intended for use with QuickSilver
* I mapped option-y to running this script to create
* a new iTerm window on the current workspace
*
* Based on much Googling - very little "original" code here
* Comments/Suggestions to [email protected]
*)
@stefco
stefco / camphor.scss
Created December 4, 2017 05:12 — forked from bdno86/camphor.scss
camphor
$camphor300:'d09GMgABAAAAAQ5UABIAAAAEn0QAAQ3tAAEZmQAAAAAAAAAAAAAAAAAAAAAAAAAAG4SkahzOKgZgFotgAIosCCIJgnMRCAqLlgCKvTwBNgIkA5lwE4GnDguZdAAEIAW7bwcgDHJb0WS0WUXZkokWaBHx4wKbY7TigANIU/t980QCGzI/IkCsdbqJZwY1ZOgWDngIamw3I43435Dd+zJ1kNmKVp/DvXNAwaNm//////////////////+/NZkMZ5cAl0CpbZ3oiwloFA5GyIWNzOYVLt1bpXPX+pABI2fo5rMZpgVYIzYqgxt92ajECqUKh2G9gaOCVRC23VSRVypHfbvb7wYcwEM25WArF0esm1yKzDixrJRdcBGtcpBZTFbFbIl8LIU4gWOnEdSITqkoGrHWJ8ywn9eVFWWk3lC6m07qp1TXntHaWp6ekYHLrFoyzOXYiQnn2kWX2zqMaFBTca25vHKndPhJV66HRhQzL9lB3OT20KGTXuFHu62wm1qzoV/iTnaiLdc8o/D7B+1O94BrjSE3cia6U1A5XNp0kHmUj8IMBaeiGaiNJV7b1csb0bq8EWYo2h1TuipR+7hmYjxeZsonGLNcmgsKp5EUDCEj9SvRyxX2uMUNfINmfNqglBYNNtjtNmdwWV2ly4uQKheyDyka2RTRoQ3IEfs+0BNcGJ4Z5AnmHNpFbCKW5PsXkAzJ6VVzzVMo0fwIUpQQT67itTNRE946/NxDashl9KuAFUbZ6yW91vObh+WAMZ1mQ1J4wotF6KXHuo65X6wSz406hW/T6XZMf/6W+HGYUxCDfhyjPaoMGcWccmbYM/H35NdHTOd79Jg0ho/BDBvRy2vcg8pHsv07UYiKrDFeqzL0Qk7qCkXLuukl2EKuR3xS6VtsLEaT0BfWoDYoQ1YvEjjT729XNMYoCX3j+2ApedBG/UHLOJ7AAnfPSqdmmePsY+522MpfPaf7kf6fIJMn0/4SE6PmuI3yjyeGjWn+1qj/ukf09DE
@stefco
stefco / instagram_id_to_url.php
Created May 28, 2018 08:10 — forked from stirtingale/instagram_id_to_url.php
Simple PHP function to convert an Instagram ID into a URL.
// based on ggwarpig stackoverflow anwser to
// "Where do I find the Instagram media ID of a image"
// @ https://stackoverflow.com/a/37246231
function instagram_id_to_url($instagram_id){
$url_prefix = "https://www.instagram.com/p/";
if(!empty(strpos($instagram_id, '_'))){