Skip to content

Instantly share code, notes, and snippets.

View jmatth11's full-sized avatar

Joshua Matthews jmatth11

  • United States
View GitHub Profile
@jmatth11
jmatth11 / git_show_bash.sh
Last active February 7, 2018 04:04
convenient git show in bash
# allows user to git show by the number the commit appears in git log
# 1 is the first commit, 2 is the second, etc...
git_show() {
re='^[0-9]+$'
if ! [[ $1 =~ $re ]]; then
return
fi
sha="$(git log -$1 --format="%H")"
shaSplit=(${sha//\n/ })
git show ${shaSplit[$(($1 - 1))]}
@jmatth11
jmatth11 / defer
Last active December 2, 2022 18:16
simple defer in C
#define macro_var(name) name##__LINE__
#define defer(start, end) for ( \
int macro_var(_i_) = (start, 0); \
!macro_var(_i_); \
(macro_var(_i_) += 1), end) \
/**
Example usage: