Skip to content

Instantly share code, notes, and snippets.

🐍
Python!

mattmc3 mattmc3

🐍
Python!
Block or report user

Report or block mattmc3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 / 1-setopts.zsh
Last active Nov 4, 2019
ZSH - options by framework
View 1-setopts.zsh
## ZSH Options
# http://zsh.sourceforge.net/Doc/Release/Options.html
# Changing Directories
# http://zsh.sourceforge.net/Doc/Release/Options.html#Changing-Directories
setopt auto_cd # if a command isn't valid, but is a directory, cd to that dir
setopt auto_pushd # make cd push the old directory onto the directory stack
setopt pushd_ignore_dups # don’t push multiple copies of the same directory onto the directory stack
setopt pushd_minus # exchanges the meanings of ‘+’ and ‘-’ when specifying a directory in the stack
@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
@mattmc3
mattmc3 / zstyle_examples.zsh
Last active Oct 15, 2019
zsh: zstyle examples
View zstyle_examples.zsh
# reference: http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fzutil-Module
# https://unix.stackexchange.com/questions/214657/what-does-zstyle-do
# list all zstyle settings
zstyle -L
# set a string value
zstyle :example:favorites fruit apple
# set an explicit string value
@mattmc3
mattmc3 / csv_to_yaml.py
Last active Sep 30, 2019
Python: csv examples
View csv_to_yaml.py
#!/usr/bin/env python3
import yaml
import csv
data = []
with open('data.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
header=next(csv_reader)
for row in csv_reader:
@mattmc3
mattmc3 / modern_sql_style_guide.md
Last active Sep 26, 2019
Modern SQL Style Guide
View modern_sql_style_guide.md
layout author title revision version description
default
mattmc3
Modern SQL Style Guide
2019-01-17
1.0.1
A guide to writing clean, clear, and consistent SQL.

Modern SQL Style Guide

@mattmc3
mattmc3 / tasks.json
Created Apr 6, 2017
VSCode tasks for Golang
View tasks.json
// See http://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
// ${workspaceRoot} the path of the folder opened in VS Code
// ${file} the current opened file
// ${fileBasename} the current opened file's basename
// ${fileDirname} the current opened file's dirname
// ${fileExtname} the current opened file's extension
// ${cwd} the task runner's current working directory on startup
{
"version": "0.1.0",
You can’t perform that action at this time.