Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
Python!

mattmc3 mattmc3

🐍
Python!
View GitHub Profile
@mattmc3
mattmc3 / colorize_tap.awk
Last active Jan 22, 2021
awk TAP colorizer
View colorize_tap.awk
#!/usr/bin/env -S awk -f
# https://testanything.org
BEGIN {
CYAN="\033[0;36m"
GREEN="\033[0;32m"
RED="\033[0;31m"
BRIGHTGREEN="\033[1;92m"
BRIGHTRED="\033[1;91m"
NORMAL="\033[0;0m"
@mattmc3
mattmc3 / .zshrc
Created Dec 24, 2020
ZSH - .zshrc that emulates fish's conf.d and functions dirs
View .zshrc
# zprof if we ever need to profile
alias runzprof="RUNZPROF=1 zsh"
alias zbench='for i in $(seq 1 10); do; /usr/bin/time zsh -i -c exit; done'
[[ $RUNZPROF -ne 1 ]] || zmodload zsh/zprof
# use functions directory for zsh functions
fpath=("$ZDOTDIR"/functions $fpath)
for _fn in "$ZDOTDIR"/functions/*(.N); do
autoload -Uz "$_fn"
done
@mattmc3
mattmc3 / split.zsh
Last active Feb 12, 2021
ZSH - split string into array
View split.zsh
str=part1/part2/part3
# part1
echo ${str%%/*}
# part1/part2
echo ${str%/*}
# part2
echo ${${str%/*}#*/}
# part2/part3
echo ${str#*/}
# part3
@mattmc3
mattmc3 / brew_export.sh
Last active Dec 2, 2019
Brew - better Brewfile creation (without the file)
View brew_export.sh
brew_export() {
# brew bundle is a pain... it dumps to a forced Brewfile, and is not
# consistently sorted, making version controling your Brewfile in a dotfile
# repo tricky. #FixedIt
# makes a Brewfile
brew bundle dump --force
# add custom sort column
awkcmd='
@mattmc3
mattmc3 / tampermonkey-stackoverflow.js
Last active Nov 18, 2019
Tampermonkey - my scripts
View tampermonkey-stackoverflow.js
// ==UserScript==
// @name stackoverflow tampering
// @namespace http://tampermonkey.net/
// @version 0.1
// @description StackOverflow - hide #hot-network-questions and deleted stuff.
// @author mattmc3
// @grant none
// @require http://code.jquery.com/jquery-latest.js
// @match https://*.stackoverflow.com
// @match https://*.stackexchange.com
@mattmc3
mattmc3 / example.zsh
Created Nov 4, 2019
ZSH - array contains value
View example.zsh
# http://zsh.sourceforge.net/Doc/Release/Parameters.html#Subscript-Flags
# https://unix.stackexchange.com/questions/411304/how-do-i-check-whether-a-zsh-array-contains-a-given-value/411306
array=(foo bar baz foo)
# 'I' is the subscript flag for index
pattern=f*
if (($array[(I)$pattern])); then
echo array contains at least one value that matches the pattern
fi
@mattmc3
mattmc3 / .zshrc_part.zsh
Created Oct 22, 2019
ZSH - manually manage plugins
View .zshrc_part.zsh
# assumes github and slash separated plugin names
github_plugins=(
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-history-substring-search
rupa/z
# theme
miekg/lean
# must be last
zdharma/fast-syntax-highlighting
@mattmc3
mattmc3 / 01 - test_834.edi
Last active Oct 21, 2019
AWK - convert HIPAA 5010 X12 834 Benefit Enrollment to TSV
View 01 - test_834.edi
ISA*01*0000000000*01*0000000000*ZZ*ABCDEFGHIJKLMNO*ZZ*123456789012345*101127*1719*U*00400*000003438*0*P*>
GS*PO*4405197800*999999999*20101127*1719*1421*X*004010VICS
ST*834*0179
BGN*00*1*20050315*110650****4
REF*38*SAMPLE_POLICY_NUMBER
DTP*303*D8*20080321
N1*P5*COMPAN_NAME*FI*000000000
INS*Y*18*030*20*A
REF*0F*SUBSCRIBER_NUMBER
NM1*IL*1*JOHN DOE*R***34*1*0000000
@mattmc3
mattmc3 / fish_string.md
Last active Oct 20, 2019
ZSH - string functions
View fish_string.md

fish string utility

string - manipulate strings

Synopsis
   string escape [(-n | --no-quoted)] [--style=xxx] [STRING...]
   string join [(-q | --quiet)] SEP [STRING...]
   string join0 [(-q | --quiet)] [STRING...]
   string length [(-q | --quiet)] [STRING...]
@mattmc3
mattmc3 / .zshrc
Created Oct 17, 2019
zsh: example of zgen + oh-my-zsh setup
View .zshrc
# .zshrc
# setup zgen
export ZGEN_DIR="${ZDOTDIR:-$HOME}"/.zgen
[[ -d "$ZGEN_DIR" ]] || git clone https://github.com/tarjoilija/zgen.git --depth=1 "$ZGEN_DIR"
ZGEN_RESET_ON_CHANGE=(
${ZDOTDIR:-$HOME}/.zshrc
${ZDOTDIR:-$HOME}/zsh_plugins
)
# decide if you want to do compinit yourself
# ZGEN_AUTOLOAD_COMPINIT=false