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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Manual opt parsing example | |
# | |
# Features: | |
# - supports short and long flags (ie: -v|--verbose) | |
# - supports short and long key/value options (ie: -f <file> | --filename <file>) | |
# - supports short and long key/value options with equals assignment (ie: -f=<file> | --filename=<file>) | |
# - does NOT support short option chaining (ie: -vh) | |
# - everything after -- is positional even if it looks like an option (ie: -f) | |
# - once we hit an arg that isn't an option flag, everything after that is considered positional | |
function optparsing_demo() { |
Example splitting string on slash character in ZSH.
$ str=part1/part2/part3
$ parts=(${(@s:/:)str})
$ echo $parts
part1 part2 part3
$ echo ${#parts[@]}
3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Clone or update all a user's gists | |
# curl -LJO https://gist.githubusercontent.com/mattmc3/b9f314f29add32330b2ee359e2ad5aba/raw/0068945bf19bc50b9847d5938286c74953aa97e3/gist-backup.py | |
# chmod 755 ./gist-backup.py | |
# USER=mattmc3 python3 gist-backup.py | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
import json | |
import urllib | |
from subprocess import call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert piped input to args | |
if [[ ! -t 0 ]] && [[ -p /dev/stdin ]] && (( $# == 0 )); then | |
set -- "${(@f)$(cat)}" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder