Skip to content

Instantly share code, notes, and snippets.

🐍
Python!

mattmc3 mattmc3

🐍
Python!
View GitHub Profile
@mattmc3
mattmc3 / modern_sql_style_guide.md
Last active Jun 26, 2020
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 / import_xml_to_dataframe_to_sql.py
Created Jan 8, 2018
Python: Import XML to Pandas dataframe, and then dataframe to Sqlite database
View import_xml_to_dataframe_to_sql.py
import xml.etree.ElementTree as ET
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
# do this if running in jupyter
# pd.set_option('display.max_columns', None)
# convert XML to dataframe (assumes only one layer of nesting)
def xml2df(xml_data):
@mattmc3
mattmc3 / commit-emojis.md
Last active Jan 11, 2020
Commit message emojis
View commit-emojis.md
@mattmc3
mattmc3 / 1-setopts.zsh
Last active Jan 9, 2020
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 / tasks.json
Created Apr 6, 2017
VSCode tasks for running a Makefile
View tasks.json
// Makefile
// ${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",
"command": "bash",
@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
You can’t perform that action at this time.