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XQ7NWN2I25XROSZIFLF6PT5AVZOAC I2WI2EWK3OXLC47KJJMXKLFDTHZLHAUXFVQCET26NMXODEHY244AC V7RZRPMQYYGRPEWE5UOJ74FGC6IWRWXKQHS7CR6SL4FBEWB7OVYQC AFJJ42LKJYUUPNSL22AUXUCFWXE4T4732YYXEJUEY2SJO6HHJUWAC 3YPPQLTAKKPK5CLJUZEH3A55Z76EUAXCOCGWW6XLRXSDQKKJCWOQC RLKZ33HEPHQ6EAYJTQDHYOG7KE34XBH7V7TQ37BIU2DBCAFRPRJQC 5M2FYS5GTEPSCGLG6VPUMFXTKCP7ETDIOVOC2YSEGQHGKG3IFMKQC AT4I3XSN3KN4K56GP5ZV55NKYDZ7LFV4AHKMB3PHQCXN56SADVTAC {"discount": {"fields": [{"name": "code","caseSensitive": false,"maxLength": 0,"minLength": 3,"type": "whitelist"}]},"regex-example-rule": {"fields": [{"name": "first","pattern": "\\w+","caseSensitive": false,"maxLength": 0,"minLength": 1,"type": "regex"},{"name": "last","pattern": "\\w+","caseSensitive": false,"maxLength": 0,"minLength": 1,"type": "regex"},{"name": "email","pattern": "[a-z]+@[a-z]+\\.[a-z]+","caseSensitive": false,"maxLength": 0,"minLength": 6,"type": "regex"}]}}"pattern": "@.-_!abcdefghijklmnopqrstuvwxyz1234567890",
Metadata-Version: 1.0Name: csvcheckVersion: 0.0.1Summary: UNKNOWNHome-page: UNKNOWNAuthor: UNKNOWNAuthor-email: UNKNOWNLicense: UNKNOWNDescription-Content-Type: UNKNOWNDescription: UNKNOWNPlatform: UNKNOWN
lib.pymain.pycsvcheck.egg-info/PKG-INFOcsvcheck.egg-info/SOURCES.txtcsvcheck.egg-info/dependency_links.txtcsvcheck.egg-info/entry_points.txtcsvcheck.egg-info/requires.txtcsvcheck.egg-info/top_level.txt
from __future__ import division, absolute_import, print_functionfrom collections import OrderedDictimport csvimport jsonimport osimport reimport sixclass FileNewLineError(Exception):passclass RuleDoesNotExist(Exception):passclass RuleCannotBeParsed(Exception):passclass RuleField():def __init__(self, field):# TODO set these attributes in stone and make this explicitfor k, v in six.iteritems(field):setattr(self, k, v)if not self.caseSensitive:self.pattern = self.pattern.lower()def errors(self, check):return [e for e in self.errors_iter(check)]def errors_iter(self, check):if self.type in ('whitelist', 'blacklist'):check = check if self.caseSensitive else check.lower()return self._iter_chars(check)elif self.type in ('regex', 'regular expression'):return self._iter_regex(check)def is_valid(self, check):'''returns true on the first error encountered'''return not any(self.errors_iter(check))def _iter_chars(self, check):for c in check:matches = c in self.patternif self.type == 'whitelist' and not matches:yield celif self.type == 'blacklist' and matches:yield cdef _iter_regex(self, check):flags = 0if not self.caseSensitive:flags = re.IGNORECASEpattern = re.compile(self.pattern, flags)does_not_match = pattern.sub('', check)if does_not_match != '':yield does_not_matchdef __repr__(self):return 'RuleField({}) -> Pattern: {}'.format(self.name, self.pattern)class Rule():def __init__(self,rule_name=None,rules='rules.json',required_rule_fields=None):if required_rule_fields is None:required_rule_fields = set(['name', 'pattern', 'caseSensitive', 'maxLength', 'minLength','type'])self.name = rule_name or ''self._field_map = self.create_field_map(self.parse_json(rules), rule_name, required_rule_fields)def __getitem__(self, key):index = Nonetry:index = int(key)except ValueError:return self._field_map[key]keys = self._field_map.keys()return self._field_map[keys[index]]def __iter__(self):for rule_field in six.itervalues(self._field_map):yield rule_fielddef __len__(self):return len(self._field_map)def __repr__(self):return '<Rule({}) -> fields: {}>'.format(self.name,self._field_map.keys())@staticmethoddef create_field_map(rules_object, rule_name, required_rule_fields):field_map = OrderedDict()field_list = rules_objecttry:field_list = rules_object[rule_name]['fields']except KeyError:raise RuleDoesNotExist()except AttributeError:# assume a single rule - object is a list of the fieldspassfor field in field_list:# assure each field has everything needed to validateif set(field.keys()) < required_rule_fields:raise ValueError('Rules must contain these keys for validation: %s' %required_rule_fields)field_map[field['name']] = RuleField(field)return field_map@staticmethoddef parse_json(rules):'''returns parsed json from string or file'''if os.path.exists(rules):with open(rules) as f:rules = f.read()try:return json.loads(rules)except ValueError:raise RuleCannotBeParsed()class Validator():'''Validates the contents of a csv file against a set of rules. The rules should be in json format andcan be read in a string or file.PARAMS:csv_file_path: STRING a filepath to a csv file to validaterules: (Optional) STRING a string or filepath to json data that contain rules. see rules.json for formattingrule_name: (Optional) STRING select a rule from the rules json to use for validationfix_line_endings: (Optional) BOOL write a fixed version of the file if it contains non-unix line endingsNOTES:arbitrary key word arguments are passed to the csv readerUSAGE:Validator('~/Desktop/discounts.csv').errorsv = Validator('~/Desktop/discounts.csv', rule_name='Event Upload', rules='~/Desktop/my_rules.json')errs = v.errorsfor err in errs:print(err)print(v.line(err['line_num']))'''def __init__(self, csv_data, rules, rule_name=None, **kwargs):self.rule = Rule(rule_name=rule_name, rules=rules)self.csv_data = self._clean_lines(csv_data)self.csv_iter = csv.reader(self.csv_data, **kwargs)self.errors = self._all_errors()def line(self, num):'''returns the contents of the line at the given index (not 0 indexed) and error inormation for that line'''num = num - 1line = self.csv_data[num]errors = filter(lambda e: e.get('line_num') == num, self.errors)return (line, errors)def _all_errors(self):'''iterates through all of the csv data and computes the errors, returns a list dict objects containingerror information'''return [{'line_num': line_num,'col_num': col_num,'errors': errs} for line_num, col_num, errs in self._errors_iter()]def _errors_iter(self):'''lazily iterates through the csv data yielding errors for each column'''for line_num, row in enumerate(self.csv_iter):for col_num, (col, rule) in enumerate(zip(row, self.rule)):errors = rule.errors(col)if errors:yield line_num, col_num, errorsdef _clean_lines(self, csv_data):non_unix_line_ending_char = '\r'if non_unix_line_ending_char in csv_data:raise FileNewLineError('File has a mix of non-unix line endings which cannot be parsed as csv')else:# remove literal newline from each linereturn [l.replace('\n', '') for l in csv_data]def __repr__(self):return '<Validator(csv) Rule({}) -> {} Errors>'.format(self.rule.name, len(self.errors))
from traceback import format_excimport clickfrom lib import Validator, RuleDoesNotExist, RuleCannotBeParsed, FileNewLineError@click.group(invoke_without_command=True)@click.option('--rules-string', type=click.STRING)@click.argument('csv', type=click.File('r'))@click.argument('rule_name', type=click.STRING, required=False)@click.pass_contextdef run(context, csv, rule_name, rules, rules_string):'''csvcheck accepts a path to a csv file and will validate it against rules'''if rules_string:rules = rules_stringcontext.obj = {'file': csv,'validator': get_validator(csv, rules, rule_name)}if not context.invoked_subcommand:errors = pretty_errors(context.obj['validator'].errors,context.obj['validator'].csv_data)if not errors:click.echo('there are no errors in {}'.format(csv.name))else:print_csv_errors(errors)@run.command()@click.option('-l', '--line-endings/--no-line-endings', default=False)@click.option('-e', '--remove-errors/--no-remove-errors', default=False)@click.pass_contextdef fix(context, line_endings, remove_errors):handle_fix(line_endings, remove_errors)@click.pass_contextdef handle_fix(context, line_endings, remove_errors):fixed_file_name = ''if line_endings:fixed_file_name = fix_line_endings(context.obj['file'])elif remove_errors:csv_data = context.obj['validator'].csv_dataerrors = context.obj['validator'].errorserr_explaination = '''CONTENTS OF LINE: {line}INVALID CHARACTERS: {invalid}'''initial_msg = '''There are {count} errors in {file_name}.The first error is:{first_err}'''.format(count=len(errors),file_name=context.obj['file'].name,first_err=err_explaination.format(line=csv_data[errors[0]['line_num']],invalid=errors[0]['errors']))strategy_prompt = '''Choose a strategy:delete - remove the line completelyfix - remove the invalid characters, but keep the valid onesskip - skip this line'''invalid_input_msg = '"{}" is not a valid strategy. Please choose from above.'strategy = Noneblock_on_each_iteration = TrueREMOVE_LINE = 1STRIP_ERRORS = 2SKIP_LINE = 3allowed_inputs = {'d': REMOVE_LINE,'delete': REMOVE_LINE,'f': STRIP_ERRORS,'fix': STRIP_ERRORS,'s': SKIP_LINE,'skip': SKIP_LINE}click.echo(initial_msg)for index, err in enumerate(errors):line_contents = csv_data[err['line_num']]if block_on_each_iteration:if index != 0:click.echo(err_explaination.format(line=line_contents, invalid=err['errors']))click.echo(strategy_prompt)strategy = get_user_input(allowed_map=allowed_inputs, invalid_msg=invalid_input_msg)if index == 0:block_on_each_iteration = not click.confirm('Do you want to do this for the rest of the errors?')if strategy == STRIP_ERRORS:csv_data[err['line_num']] = fix_line(line_contents, err, strip=True)elif strategy == REMOVE_LINE:csv_data[err['line_num']] = fix_line(line_contents, err)click.echo('--------------------')fixed_file_name = 'fixed-{}'.format(context.obj['file'].name)with open(fixed_file_name, 'w') as f:new_csv_data = ''.join('{}\n'.format(l) for l in csv_dataif len(l) > 0)f.write(new_csv_data)click.echo('{} saved to current directory'.format(fixed_file_name))def fix_line(line_contents, error, strip=False):'''returns the line without invalid characters or an empty string if strategy == "line"'''result = ''if strip:errors = error['errors']result = ''.join(c for c in line_contents if c not in errors)return resultdef get_validator(csv, rules, rule_name):csv_data = csv.readlines()try:return Validator(csv_data, rules, rule_name=rule_name)except FileNewLineError:handle_file_new_line_error(promt_fix=True)except RuleDoesNotExist:handle_rule_does_not_exist_error(rule_name)except RuleCannotBeParsed:handle_rule_cannot_be_parsed_error()except Exception:print_prog_error('There was a fatal error, the file was not processed.',tb=format_exc())def handle_file_new_line_error(context, prompt_fix=False):err_message = 'CSV file has non-standard line endings and cannot be parsed as csv.'suggestion = 'Use the fix command to fix line endings.'example = 'csvcheck /path/to/file.csv rule_name fix -l'click.echo(err_message, err=True, color='red')if prompt_fix:if click.confirm('Save new file with fixed line endings to the current directory?'):handle_fix(True, False)else:click.echo(suggestion, err=True, color='yellow')click.echo(example, err=True)raise click.BadParameter('csv file contains malformed line ending characters')def handle_rule_does_not_exist_error(rule_name):err_message = 'Rule "{}" does not exist in rules json.'.format(rule_name)raise click.BadArgumentUsage(err_message)def handle_rule_cannot_be_parsed_error():raise click.BadOptionUsage('invalid json passed into --rules-string')def pretty_errors(errors, csv_data):'''returns a list of end-user friendly formatted strings describing the errors '''err_lines = []for error in errors:line_number = error['line_num']column_number = error['col_num']contents = csv_data[line_number]err_lines.append('L{line}:{col} ({errors}) --> "{contents}"'.format(line=line_number + 1,col='' if column_number == 0 else 'C{}:'.format(column_number),contents=contents,errors=error['errors']))return err_linesdef fix_line_endings(csv_file, out_path=None):'''accept file object, remove bad line endings, write to a file of the samebasename with fixed- as a prefixoptionsout_path: write file to a specific path instead of the same path as csvwindows line endings can have a carriage return in additionto the \n char - csv has trouble parsing these line endingsso just remove them here instead of opening the file inuniversal line endings mode since it's a big reason uploads fail'''contents = ''.join(line.replace('\r', '\n') for line in csv_file.readlines())out_file_name = 'fixed-{}'.format(csv_file.name)with open(out_file_name, mode='w') as out_file:out_file.write(contents)return out_file_namedef get_user_input(prompt_str='>>> ',allowed_map=None,invalid_msg='{} is invalid input please try again.'):choice = Nonewhile not choice:user_input = click.prompt(prompt_str, prompt_suffix='').lower().strip()choice = allowed_map.get(user_input) if allowed_map else user_inputif not choice:formatted = invalid_msg.format(choice) if '{}' in invalid_msg else invalid_msgclick.echo(formatted)return choicedef print_csv_errors(errors):for error in errors:click.echo(error)def print_prog_error(msg, tb=None):click.echo(msg, err=True)if tb:for line in tb:click.echo(line)@click.option('--rules', type=click.Path(exists=True), default=DEFAULT_RULES_PATH)DEFAULT_RULES_PATH = path.expanduser('~/dotfiles/csv_validator/rules.json')DEFAULT_RULES_PATH = DEFAULT_RULES_PATH if path.exists(DEFAULT_RULES_PATH) else 'rules.json'from os import path
from setuptools import setupsetup(name='csvcheck',version='0.0.1',py_modules=['main', 'lib'],install_requires=['Click', 'six'],entry_points='''[console_scripts]csvcheck=main:run''')
################# PATH SETTINGS################export GOPATH=$HOME/go_projects######################################################################## to make sure global python packages are only installed intentionally, limit pip to running only in venvexport PIP_REQUIRE_VIRTUALENV=true# auto-activate pyvenv python versions when entering that direxport PYENV_ROOT=$HOME/.pyenvexport PYENV_VIRTUALENV_DISABLE_PROMPT=1eval "$(pyenv init -)"eval "$(pyenv virtualenv-init -)"# terminal promptPS1=' \u @ \[\033[0;35m\]\h\[\033[0m\]\n| \[\033[1;34m\]\w\[\033[0;32m\]$(__git_ps1)\[\033[0m\]\n└─ $ 'export PATH="$HOME/.cargo/bin:$PATH"export PATH="$HOME/.poetry/bin:$PATH"# IMPRTANT STUFF TO LOAD LAST#############################if [ -d "$HOME/eventbrite_github" ]; thenexport EBPATH=~/eventbrite_github/eventbriteexport ARCANIST_INSTALL_DIR=/Users/ccummings/.evbdevtoolsexport ARCANISTHELPERS=~/.evbdevtools/devtools/scripts/devenv_bash/arcanist_helpers.shtest -f $ARCANISTHELPERS && source $ARCANISTHELPERSexport BAY_HOME=/Users/ccummings/eventbrite_github/eventbrite/docker-devexport DM_START=/Users/ccummings/.evbdevtools/devtools/scripts/install_devenv/dm_start.shsource $DM_STARTfi# Eventbrite Stuffexport RUSTPATH=$HOME/.cargo/binexport RUST_SRC_PATH=$HOME/.multirust/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/srcexport PATH=/usr/local/bin:$GOPATH/bin:$RUSTPATH:$PATHexport YARNPATH=/usr/local/bin# Load brew git completion and git prompt scriptselseecho brew git not installed at expected location, to install it, run: brew install gitfiexport EDITOR=`which nvim`if [ -d "/usr/local/Cellar/git/2.13.3" ]; thensource /usr/local/Cellar/git/2.13.3/etc/bash_completion.d/git-completion.bashsource /usr/local/Cellar/git/2.13.3/etc/bash_completion.d/git-prompt.shexport CLICOLOR=1 # enable colorstest -f ~/.bashrc && . ~/.bashrc
set -o vi[ -d ~/dotfiles ] && for f in ~/dotfiles/bash/functions/*; do source $f; done##########################################################[ -f ~/.fzf.bash ] && source ~/.fzf.bash# use ripgrep (default is find)export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"bind -x '"\C-p": vim $(fzf);'_fzf_compgen_path() {rg -g "" "$1"}###################### GENERAL USE ALIASES#####################alias cp='cp -iv' # copy a file with the verbose and warning flagsalias mv='mv -iv' # move a file/dir with verbose and warning flagsalias mkdir='mkdir -pv' # make directory with the path and verbose flagsalias cd..='cd ../' # Go back 1 directory levelalias finder='open -a Finder ./' # Open current directory in MacOS Finderalias path='echo -e ${PATH//:/\\n}' # Echo all executable Pathsalias numFiles='echo $(ls -1 | wc -l)' # Count of non-hidden files in current diralias staticip='dig +short myip.opendns.com @resolver1.opendns.com' # get the static ip of the current network# lr is a full recursive directory listing piped to lessalias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'#################### QUICK NAV Aliases###################export GOCODE=$GOPATH/src/github.com/mistahchris/######################## GENERAL USE FUNCTIONS######################## Always list directory contents after 'cd'cd () {builtin cd "$@"; ls -a;}# moves a file to the macOS Trashtrash () {command mv "$@" ~/.Trash ;}# opens a file in the macOS previewpreview () {qlmanage -p "$*" >& /dev/null;}# creates a zip archive folderzipf () {zip -r "$1".zip "$1" ;}# make a directory and change into itmcd () {mkdir -p $1;cd $1;}# cdfinder changes the directory to the frontmost open finder windowcdfinder () {currFolderPath=$( /usr/bin/osascript <<EOTtell application "Finder"tryset currFolder to (folder of the front window as alias)on errorset currFolder to (path to desktop folder as alias)end tryPOSIX path of currFolderend tellEOT)echo "cd to \"$currFolderPath\""cd "$currFolderPath"}# sets the contents of a file to the macOS clipboardcopy () {cat $1 | pbcopy}# kill a process by namedie () {name=$1firstChar=${name:0:1}rest=${name:1:${#name}}pid=`ps aux | grep "[$firstChar]$rest" | awk '{print $2}'`kill $pid}# extracts the git branch nameparseBranch() {git branch | grep "^\* " | sed "s/\* //g"}# useful for extracting compressed foldersextract () {if [ -f $1 ] ; thencase $1 in*.tar.bz2) tar xjf $1 ;;*.tar.gz) tar xzf $1 ;;*.bz2) bunzip2 $1 ;;*.rar) unrar e $1 ;;*.gz) gunzip $1 ;;*.tar) tar xf $1 ;;*.tbz2) tar xjf $1 ;;*.tgz) tar xzf $1 ;;*.zip) unzip $1 ;;*.Z) uncompress $1 ;;*.7z) 7z x $1 ;;*) echo "'$1' cannot be extracted via extract()" ;;esacelseecho "'$1' is not a valid file"fi}PATH=$HOME/dotfiles/bin:$PATHcomplete -C /usr/local/bin/terraform terraform# Enable fzf cool stuffexport EDITOR="emacsclient -t"export VISUAL="emacsclient -n"
function srch() {RG_ARGS=""N_LARGEST=0for arg in $@docase "$arg" in-n*)RG_ARGS="$RG_ARGS -c" # add count flag to rgN_LARGEST=$numfi;;*)RG_ARGS="$RG_ARGS $arg"esacdonefrom heapq import nlargestfrom sys import stdinfi}if [ -f $PY_FILE ]; thenrm $PY_FILEeval $COMMANDfor match in nlargest($N_LARGEST, stdin.readlines(), key=lambda l: l.split(':')[-1]):print(match.strip())" > $PY_FILECOMMAND="$COMMAND | python $PY_FILE"fiif ((USE_FZF > 0)); thenFILTER_FILE_NAME='cut -f 1 -d :'FZF_COMMAND="fzf --preview 'cat {}'"COMMAND="$COMMAND | $FILTER_FILE_NAME | $FZF_COMMAND"fiCOMMAND="rg $RG_ARGS"if ((N_LARGEST > 0)); thenPY_FILE=$(mktemp /tmp/srch_py.XXXXXXXXXXXXX)printf "--print)USE_FZF=0;;num=$(echo "$arg" | rg --replace '$1' -- '-n(\d+)')if ((num > 0)); thenUSE_FZF=1# wrapper around ripgrep and fzf.# USAGE: find top 5 files by num of matches:# $ srch PATTERN -g GLOB -n5
emacs() {if ! ps aux | grep -v grep | grep -q 'emacs.* \-\-daemon'; then/usr/local/bin/emacs --daemon > /dev/null 2>&1fi;passed_args="$@"if [ $(echo -n "$passed_args" | wc -c) -lt "1" ]; thenecho "USAGE: emacs [PATH TO FILE] [OPTIONAL ARGS PASSED TO EMACS CLIENT]"return 1fi;# create an emacsclient frame if one does not exist otherwise use existing framepassed_args="-c $passed_args"fi;/usr/local/bin/emacsclient "$passed_args" > /dev/null &}if ! ps aux | grep -v grep | grep -q 'emacsclient'; then
export VISUAL="/usr/local/bin/emacsclient -c"export PATH="$HOME/.cargo/bin:$PATH"export PATH="$HOME/.poetry/bin:$PATH"export PATH="/usr/local/bin/:$HOME/.cargo/bin:$PATH"
" --- the plugins are between the call plug begin and endcall plug#begin('~/.vim/plugged')Plug 'tpope/vim-surround'call plug#end()" -- LOOK AND FEELfiletype onsyntax enable " enable syntax processingset showcmd " show command in bottom barset lazyredraw " redraw only when needed. (speeds things up)set showmatch " highlight matching braces, brackets, parensset autowrite" -- SEARCHINGset ignorecase " ignore case for searchesset incsearch " search as characters are inputset hlsearch " highlight search matchesset magic" -- INDENT SETTINGSautocmd Filetype html setlocal ts=2 sw=2 expandtabautocmd Filetype ruby setlocal ts=2 sw=2 expandtabautocmd Filetype c setlocal ts=4 sw=4 expandtab cindentautocmd Filetype swift setlocal ts=4 sw=4 expandtab cindentautocmd BufNewFile,BufRead *.go setlocal noexpandtab ts=4 sw=4filetype indent onimap <S-tab> <C-d>set smartindentset autoindentset nowrap" -- KEY BINDINGS / REMAPS" \pp - paste into buffernnoremap <leader>pp :r !pbpaste<CR>set tabstop=4set shiftwidth=4set softtabstop=4set expandtabfiletype plugin indent onautocmd Filetype javascript setlocal ts=4 sw=4 sts=0 expandtabautocmd Filetype css setlocal ts=2 sw=2 expandtabset hiddenset history=30set scrolloff=8 " scroll down when 8 lines away from being off screenset sidescrolloff=20 " scroll sideways when 20 columns away from being off screenset sidescroll=1set nocompatible
{"Profiles": [{"Ansi 0 Color" : {"Green Component" : 0,"Blue Component" : 0,"Red Component" : 0},"Tags" : [],"Ansi 12 Color" : {"Green Component" : 0.6352941176,"Blue Component" : 0.7450980392,"Red Component" : 0.5058823529000001},"Guid" : "B9C5A152-BFD5-4B7D-B311-903D39F3EE4A","Normal Font" : "PTMono-Regular 14","Bold Color" : {"Green Component" : 0.7843137255,"Blue Component" : 0.7764705882,"Red Component" : 0.7725490196},"Horizontal Spacing" : 1.104939288403614,"Link Color" : {"Red Component" : 0.023,"Color Space" : "Calibrated","Blue Component" : 0.678,"Alpha Component" : 1,"Green Component" : 0.27},"Ansi 4 Color" : {"Green Component" : 0.6352941176470588,"Blue Component" : 0.7450980392156863,"Red Component" : 0.5058823529411764},"Rows" : 45,"Default Bookmark" : "No","Cursor Guide Color" : {"Red Component" : 0.65,"Color Space" : "Calibrated","Blue Component" : 1,"Alpha Component" : 0.25,"Green Component" : 0.91},"Non-ASCII Anti Aliased" : true,"Use Bright Bold" : true,"Ansi 10 Color" : {"Green Component" : 0.7411764706,"Blue Component" : 0.4078431373,"Red Component" : 0.7098039216000001},"Ambiguous Double Width" : false,"Jobs to Ignore" : ["rlogin","ssh","slogin","telnet"],"Ansi 15 Color" : {"Green Component" : 0.9999743700027466,"Blue Component" : 0.9999912977218628,"Red Component" : 1},"Foreground Color" : {"Green Component" : 0.7843137254901961,"Blue Component" : 0.7764705882352941,"Red Component" : 0.7725490196078432},"Working Directory" : "\/Users\/chris","Blinking Cursor" : false,"Disable Window Resizing" : true,"Sync Title" : false,"Prompt Before Closing 2" : false,"BM Growl" : true,"Command" : "","Description" : "Default","Mouse Reporting" : true,"Screen" : -1,"Selection Color" : {"Green Component" : 0.2313725490196079,"Blue Component" : 0.2549019607843137,"Red Component" : 0.2156862745098039},"Columns" : 90,"Idle Code" : 0,"Ansi 13 Color" : {"Green Component" : 0.5803921569,"Blue Component" : 0.7333333332999999,"Red Component" : 0.6980392157},"Custom Command" : "No","ASCII Anti Aliased" : true,"Non Ascii Font" : "Monaco 12","Vertical Spacing" : 1,"Use Bold Font" : true,"Option Key Sends" : 0,"Selected Text Color" : {"Green Component" : 0.7843137255,"Blue Component" : 0.7764705882,"Red Component" : 0.7725490196},"Background Color" : {"Green Component" : 0.1215686276555061,"Blue Component" : 0.1294117718935013,"Red Component" : 0.1137254908680916},"Character Encoding" : 4,"Ansi 11 Color" : {"Green Component" : 0.7764705882,"Blue Component" : 0.4549019608,"Red Component" : 0.9411764706},"Use Italic Font" : true,"Unlimited Scrollback" : false,"Keyboard Map" : {"0xf700-0x260000" : {"Text" : "[1;6A","Action" : 10},"0x37-0x40000" : {"Text" : "0x1f","Action" : 11},"0x32-0x40000" : {"Text" : "0x00","Action" : 11},"0xf709-0x20000" : {"Text" : "[17;2~","Action" : 10},"0xf70c-0x20000" : {"Text" : "[20;2~","Action" : 10},"0xf729-0x20000" : {"Text" : "[1;2H","Action" : 10},"0xf72b-0x40000" : {"Text" : "[1;5F","Action" : 10},"0xf705-0x20000" : {"Text" : "[1;2Q","Action" : 10},"0xf703-0x260000" : {"Text" : "[1;6C","Action" : 10},"0xf700-0x220000" : {"Text" : "[1;2A","Action" : 10},"0xf701-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x42","Action" : 11},"0x38-0x40000" : {"Text" : "0x7f","Action" : 11},"0x33-0x40000" : {"Text" : "0x1b","Action" : 11},"0xf703-0x220000" : {"Text" : "[1;2C","Action" : 10},"0xf701-0x240000" : {"Text" : "[1;5B","Action" : 10},"0xf70d-0x20000" : {"Text" : "[21;2~","Action" : 10},"0xf702-0x260000" : {"Text" : "[1;6D","Action" : 10},"0xf729-0x40000" : {"Text" : "[1;5H","Action" : 10},"0xf706-0x20000" : {"Text" : "[1;2R","Action" : 10},"0x34-0x40000" : {"Text" : "0x1c","Action" : 11},"0xf700-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x41","Action" : 11},"0x2d-0x40000" : {"Text" : "0x1f","Action" : 11},"0xf70e-0x20000" : {"Text" : "[23;2~","Action" : 10},"0xf702-0x220000" : {"Text" : "[1;2D","Action" : 10},"0xf703-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x43","Action" : 11},"0xf700-0x240000" : {"Text" : "[1;5A","Action" : 10},"0xf707-0x20000" : {"Text" : "[1;2S","Action" : 10},"0xf70a-0x20000" : {"Text" : "[18;2~","Action" : 10},"0x35-0x40000" : {"Text" : "0x1d","Action" : 11},"0xf70f-0x20000" : {"Text" : "[24;2~","Action" : 10},"0xf703-0x240000" : {"Text" : "[1;5C","Action" : 10},"0xf701-0x260000" : {"Text" : "[1;6B","Action" : 10},"0xf702-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x44","Action" : 11},"0xf72b-0x20000" : {"Text" : "[1;2F","Action" : 10},"0x36-0x40000" : {"Text" : "0x1e","Action" : 11},"0xf708-0x20000" : {"Text" : "[15;2~","Action" : 10},"0xf701-0x220000" : {"Text" : "[1;2B","Action" : 10},"0xf70b-0x20000" : {"Text" : "[19;2~","Action" : 10},"0xf702-0x240000" : {"Text" : "[1;5D","Action" : 10},"0xf704-0x20000" : {"Text" : "[1;2P","Action" : 10}},"Window Type" : 0,"Background Image Location" : "","Blur" : false,"Badge Color" : {"Red Component" : 1,"Color Space" : "Calibrated","Blue Component" : 0,"Alpha Component" : 0.5,"Green Component" : 0},"Scrollback Lines" : 1000,"Send Code When Idle" : false,"Close Sessions On End" : true,"Terminal Type" : "xterm-256color","Visual Bell" : true,"Flashing Bell" : false,"Silence Bell" : false,"Ansi 14 Color" : {"Green Component" : 0.7450980392,"Blue Component" : 0.7176470588,"Red Component" : 0.5411764706},"Name" : "Default","Cursor Text Color" : {"Green Component" : 0.1215686276555061,"Blue Component" : 0.1294117718935013,"Red Component" : 0.1137254908680916},"Shortcut" : "","Cursor Color" : {"Green Component" : 0.7843137255,"Blue Component" : 0.7764705882,"Red Component" : 0.7725490196},"Transparency" : 0,"Ansi 1 Color" : {"Green Component" : 0.4,"Blue Component" : 0.4,"Red Component" : 0.8},"Ansi 2 Color" : {"Green Component" : 0.7411764705882353,"Blue Component" : 0.407843137254902,"Red Component" : 0.7098039215686275},"Ansi 3 Color" : {"Green Component" : 0.7764705882352941,"Blue Component" : 0.4549019607843137,"Red Component" : 0.9411764705882353},"Custom Directory" : "No","Right Option Key Sends" : 0,"Use Non-ASCII Font" : false,"Ansi 7 Color" : {"Green Component" : 0.9999743700027466,"Blue Component" : 0.9999912977218628,"Red Component" : 1},"Ansi 8 Color" : {"Green Component" : 0,"Blue Component" : 0,"Red Component" : 0},"Ansi 9 Color" : {"Green Component" : 0.4,"Blue Component" : 0.4,"Red Component" : 0.8},"Ansi 6 Color" : {"Green Component" : 0.7450980392156863,"Blue Component" : 0.7176470588235294,"Red Component" : 0.5411764705882353},"Ansi 5 Color" : {"Green Component" : 0.580392156862745,"Blue Component" : 0.7333333333333333,"Red Component" : 0.6980392156862745}},{"Ansi 2 Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0,"Blue Component" : 0},"Tags" : [],"Ansi 12 Color" : {"Green Component" : 0.3333333432674408,"Red Component" : 0.3333333432674408,"Blue Component" : 1},"Normal Font" : "Monaco 12","Ansi 4 Color" : {"Green Component" : 0,"Red Component" : 0,"Blue Component" : 0.7333333492279053},"Bold Color" : {"Green Component" : 1,"Red Component" : 1,"Blue Component" : 1},"Right Option Key Sends" : 0,"Ansi 6 Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0,"Blue Component" : 0.7333333492279053},"Rows" : 50,"Default Bookmark" : "No","Non-ASCII Anti Aliased" : true,"Use Bright Bold" : true,"Ansi 10 Color" : {"Green Component" : 1,"Red Component" : 0.3333333432674408,"Blue Component" : 0.3333333432674408},"Ambiguous Double Width" : false,"Jobs to Ignore" : ["rlogin","ssh","slogin","telnet"],"Ansi 15 Color" : {"Green Component" : 1,"Red Component" : 1,"Blue Component" : 1},"Foreground Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0.7333333492279053,"Blue Component" : 0.7333333492279053},"Working Directory" : "\/Users\/chris","Blinking Cursor" : false,"Disable Window Resizing" : true,"Sync Title" : false,"Prompt Before Closing 2" : false,"BM Growl" : true,"Command" : "","Description" : "Default","Mouse Reporting" : true,"Screen" : -1,"Selection Color" : {"Green Component" : 0.8353000283241272,"Red Component" : 0.7098000049591064,"Blue Component" : 1},"Columns" : 172,"Idle Code" : 0,"Ansi 13 Color" : {"Green Component" : 0.3333333432674408,"Red Component" : 1,"Blue Component" : 1},"Custom Command" : "No","ASCII Anti Aliased" : true,"Non Ascii Font" : "Monaco 12","Vertical Spacing" : 1,"Use Bold Font" : true,"Option Key Sends" : 0,"Selected Text Color" : {"Green Component" : 0,"Red Component" : 0,"Blue Component" : 0},"Background Color" : {"Red Component" : 0,"Color Space" : "Calibrated","Blue Component" : 0,"Alpha Component" : 1,"Green Component" : 0},"Character Encoding" : 4,"Ansi 11 Color" : {"Green Component" : 1,"Red Component" : 1,"Blue Component" : 0.3333333432674408},"Use Italic Font" : true,"Unlimited Scrollback" : false,"Keyboard Map" : {"0xf700-0x260000" : {"Text" : "[1;6A","Action" : 10},"0x37-0x40000" : {"Text" : "0x1f","Action" : 11},"0x32-0x40000" : {"Text" : "0x00","Action" : 11},"0xf709-0x20000" : {"Text" : "[17;2~","Action" : 10},"0xf70c-0x20000" : {"Text" : "[20;2~","Action" : 10},"0xf729-0x20000" : {"Text" : "[1;2H","Action" : 10},"0xf72b-0x40000" : {"Text" : "[1;5F","Action" : 10},"0xf705-0x20000" : {"Text" : "[1;2Q","Action" : 10},"0xf703-0x260000" : {"Text" : "[1;6C","Action" : 10},"0xf700-0x220000" : {"Text" : "[1;2A","Action" : 10},"0xf701-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x42","Action" : 11},"0x38-0x40000" : {"Text" : "0x7f","Action" : 11},"0x33-0x40000" : {"Text" : "0x1b","Action" : 11},"0xf703-0x220000" : {"Text" : "[1;2C","Action" : 10},"0xf701-0x240000" : {"Text" : "[1;5B","Action" : 10},"0xf70d-0x20000" : {"Text" : "[21;2~","Action" : 10},"0xf702-0x260000" : {"Text" : "[1;6D","Action" : 10},"0xf729-0x40000" : {"Text" : "[1;5H","Action" : 10},"0xf706-0x20000" : {"Text" : "[1;2R","Action" : 10},"0x34-0x40000" : {"Text" : "0x1c","Action" : 11},"0xf700-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x41","Action" : 11},"0x2d-0x40000" : {"Text" : "0x1f","Action" : 11},"0xf70e-0x20000" : {"Text" : "[23;2~","Action" : 10},"0xf702-0x220000" : {"Text" : "[1;2D","Action" : 10},"0xf703-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x43","Action" : 11},"0xf700-0x240000" : {"Text" : "[1;5A","Action" : 10},"0xf707-0x20000" : {"Text" : "[1;2S","Action" : 10},"0xf70a-0x20000" : {"Text" : "[18;2~","Action" : 10},"0x35-0x40000" : {"Text" : "0x1d","Action" : 11},"0xf70f-0x20000" : {"Text" : "[24;2~","Action" : 10},"0xf703-0x240000" : {"Text" : "[1;5C","Action" : 10},"0xf701-0x260000" : {"Text" : "[1;6B","Action" : 10},"0xf702-0x280000" : {"Text" : "0x1b 0x1b 0x5b 0x44","Action" : 11},"0xf72b-0x20000" : {"Text" : "[1;2F","Action" : 10},"0x36-0x40000" : {"Text" : "0x1e","Action" : 11},"0xf708-0x20000" : {"Text" : "[15;2~","Action" : 10},"0xf701-0x220000" : {"Text" : "[1;2B","Action" : 10},"0xf70b-0x20000" : {"Text" : "[19;2~","Action" : 10},"0xf702-0x240000" : {"Text" : "[1;5D","Action" : 10},"0xf704-0x20000" : {"Text" : "[1;2P","Action" : 10}},"Window Type" : 0,"Background Image Location" : "","Blur" : false,"Scrollback Lines" : 1000,"Send Code When Idle" : false,"Close Sessions On End" : true,"Terminal Type" : "xterm-256color","Visual Bell" : true,"Flashing Bell" : false,"Silence Bell" : false,"Ansi 14 Color" : {"Green Component" : 1,"Red Component" : 0.3333333432674408,"Blue Component" : 1},"Name" : "tmux","Cursor Text Color" : {"Green Component" : 1,"Red Component" : 1,"Blue Component" : 1},"Shortcut" : "","Cursor Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0.7333333492279053,"Blue Component" : 0.7333333492279053},"Transparency" : 0,"Ansi 1 Color" : {"Green Component" : 0,"Red Component" : 0.7333333492279053,"Blue Component" : 0},"Custom Directory" : "No","Ansi 3 Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0.7333333492279053,"Blue Component" : 0},"Horizontal Spacing" : 1,"Ansi 5 Color" : {"Green Component" : 0,"Red Component" : 0.7333333492279053,"Blue Component" : 0.7333333492279053},"Use Non-ASCII Font" : false,"Ansi 7 Color" : {"Green Component" : 0.7333333492279053,"Red Component" : 0.7333333492279053,"Blue Component" : 0.7333333492279053},"Ansi 8 Color" : {"Green Component" : 0.3333333432674408,"Red Component" : 0.3333333432674408,"Blue Component" : 0.3333333432674408},"Ansi 9 Color" : {"Green Component" : 0.3333333432674408,"Red Component" : 1,"Blue Component" : 0.3333333432674408},"Ansi 0 Color" : {"Green Component" : 0,"Red Component" : 0,"Blue Component" : 0},"Guid" : "E1DF35B7-1587-48F8-A8DE-708E75D9D9EB"}]}
# python relatedexport PYENV_ROOT=$HOME/.pyenvexport PYTHON_2_PATH=$PYENV_ROOT/versions/misc2/binexport PYTHON_3_PATH=$PYENV_ROOT/versions/misc3/binPYENV_SHIMS=/Users/ccummings/.pyenv/shimsPYENV_VENV_SHIMS=/usr/local/Cellar/pyenv-virtualenv/1.1.1/shimsfi# rust relatedif [ -d $HOME/.cargo/bin ]; thenexport RUSTPATH=$HOME/.cargo/binexport PATH=$PATH:$RUSTPATHfi# go relatedif [ -d $HOME/go ]; thenexport PATH=$PATH:$HOME/gofiexport RUST_SRC_PATH=$HOME/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/srctest -f $HOME/.zfunc && fpath+=~/.zfuncPOETRY_PATH="$HOME/.poetry/bin"export PATH=$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PYENV_VENVSHIMS:$PYENV_SHIMS:$PYTHON_2_PATH:$PYTHON_3_PATH:$POETRY_PATH:$PATHif [ -d $HOME/.pyenv ]; thenexport PATH=$DOTFILES/bin:/usr/local/bin:/usr/local/sbin:$PATH
export DOTFILES=$HOME/dotfilesexport EDITOR="emacsclient -t"export LESS="-SRXF"fzf_bin=$HOME/.fzf/bintest -f $fzf_bin && export PATH=$PATH:$fzf_bin# broken out configssource $DOTFILES/zsh/path_setupexport WORKON_HOME=$HOME/.local/share/virtualenvs/
# Path to your oh-my-zsh installation.# Set name of the theme to load. Optionally, if you set this to "random"# it'll load a random theme each time that oh-my-zsh is loaded.# See https://github.com/robbyrussell/oh-my-zsh/wiki/ThemesZSH_THEME="bira"# Set list of themes to load# Setting this variable when ZSH_THEME=random# cause zsh load theme from this variable instead of# looking in ~/.oh-my-zsh/themes/# An empty array have no effect# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )DISABLE_UNTRACKED_FILES_DIRTY="true"# Would you like to use another custom folder than $ZSH/custom?# ZSH_CUSTOM=/path/to/new-custom-folder# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/# Example format: plugins=(rails git textmate ruby lighthouse)# Add wisely, as too many plugins slow down shell startup.plugins=()source $ZSH/oh-my-zsh.sh# User configurationexport LANG=en_US.UTF-8# vi mode configbindkey -vexport KEYTIMEOUT=1#################################### below here are things appended to# automatically by various tools###################################if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi# pip zsh completion startfunction _pip_completion {local words cwordread -Ac wordsread -cn cwordreply=( $( COMP_WORDS="$words[*]" \COMP_CWORD=$(( cword-1 )) \PIP_AUTO_COMPLETE=1 $words[1] ) )}compctl -K _pip_completion pip# pip zsh completion endautoload -U +X bashcompinit && bashcompinitcomplete -o nospace -C /usr/local/bin/terraform terraform# broken out configssource $DOTFILES/zsh/fzf_configsource $DOTFILES/zsh/os_specific_configsource $DOTFILES/zsh/general_aliasestest -f $HOME/.zfunc && fpath+=~/.zfunctest -f ~/.fzf.zsh && source ~/.fzf.zsh # this is here cause fzf looks here on install# lazy load functions defined in dotfiles/zsh/functionsmy_funcs=$DOTFILES/zsh/functionsfpath=($my_funcs $fpath)for func in $(ls $my_funcs); do autoload $func; done;gitpyenvrubypoetryexport ZSH=$HOME/.oh-my-zsh
# try to find it by name explicitlylocal lpass_result=$(lpass show -p -G "$@" 2> /dev/null)local multiple_matches=$(echo "$lpass_result" | grep -io "multiple matches found")if [[ multiple_matches = "" ]];thenecho $lpass_resultelse# otherwise list all lastpass entries filtered by grep regex and fuzzy find multiple matches in fzfif [[ "$@" = "" ]];thenlpass show -p "$(lpass ls | fzf | grep -Eo 'id: [0-9]+' | cut -d ' ' -f 2)"elselpass show -p "$(lpass ls | grep -i -E "$@" | fzf | grep -Eo 'id: [0-9]+' | cut -d ' ' -f 2)"fifi
if test "$(uname)" = "Darwin";thenscript_lpass | pbcopyelsescript_lpass | xclip -i -selection clipboardfi
#! /usr/bin/env python3import jsonimport osimport sysfrom stat import S_ISFIFOdef extract_email_objects(notmuch_blob):for email in notmuch_blob:e = emailemail_object = Nonewhile email_object is None:try:e.get('body')except AttributeError:e = e[0]continueemail_object = eyield email_objectdef parse_emails(blob):emails = (e for e in extract_email_objects(blob) if e['headers']['From'] != 'ccummings@eventbrite.com')for email in emails:tags = email['tags']try:except:passyield {"tags": tags, "date": date, "to": to, "from": from_address, "subject": subject, "body": body}def run(blob):print(json.dumps(list(parse_emails(blob))))if __name__ == "__main__":try:blob = Noneif S_ISFIFO(os.fstat(0).st_mode):blob = json.loads(sys.stdin.read())else:with open(sys.argv[1], mode='r') as f:blob = json.load(f)except FileNotFoundError:print('argument must be a path to a json file', file=sys.stderr)sys.exit(1)except IndexError:print('filename argument is required', file=sys.stderr)sys.exit(2)except json.decoder.JSONDecodeError:print('content is not json encoded', file=sys.stderr)sys.exit(3)run(blob)body = str(body).replace('\n', ' ').replace('\t', '').replace(' ', ' ')body = body[0].get('content')[0].get('content')date = email.get('headers').get('Date') or ""to = email.get('headers').get('To') or ""from_address = email.get('headers').get('From') or ""subject = email.get('headers').get('Subject') or ""body = email.get('body') or ""
#! /usr/bin/env fishfunction script_lpass# if logged out, log inif not lpass status -q/usr/local/bin/lpass login $EB_LAST_PASS_USER > /dev/nullendset result (/usr/local/bin/lpass show -p -G "$argv")if echo $result | grep -iq "multiple matches found"set result (lpass show -p (lpass ls | grep -i -E "$argv" | fzf | rg -o --replace '$1' '\[id: (\d+)\]'))endecho $resultendscript_lpass $argv
import globimport osimport systemplate = """# -*- mode: snippet -*-# name: {name}# key: phab {name}# --{name}"""prefix = "phabricator_username_"with open(load_path) as f:users = f.readlines()for old_snippet_file in glob.glob("{}{}*".format(save_dir, prefix)):os.remove(old_snippet_file)for name in users:name = name.strip()save_path = f"{save_dir}{prefix}{name}"with open(save_path.format(name=name), mode="w") as f:f.write(name)print(f"Updated snippets for {len(users)} users.")home = os.environ.get("HOME")dotfiles = os.environ.get("DOTFILES")load_path = f"{home}/.evbdevtools/phabricator_users.txt"save_dir = f"{dotfiles}/spacemacs/snippets/phabricator/"if not os.path.exists(load_path):print("phabricator_users.txt is required, but does not exist.", file=sys.stderr)sys.exit(1)#! /usr/bin/env python3