Skip to content

Commit

Permalink
Update 8/18/2020
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Thomas committed Aug 18, 2020
1 parent 161cb63 commit 34910ec
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 15 deletions.
1 change: 1 addition & 0 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ PATH="${PATH}:$HOME/scripts/git-scripts"
PATH="${PATH}:$PYENV_ROOT/bin"
PATH="${PATH}:/usr/local/sbin"
PATH="$PYENV_ROOT/bin:${PATH}"
PATH="${PATH}:/home/evan/github.com/tempoautomation/talos-tools"
export PATH

# ================================= ALIASES =================================
Expand Down
40 changes: 26 additions & 14 deletions .vim/.vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,6 @@ let g:SignatureForceRemoveGlobal = 1 " See https://github.com/kshenoy/vim-signat
" Plug 'https://github.com/jiangmiao/auto-pairs'
call plug#end()


"





autocmd BufRead,BufNewFile *go setlocal filetype=go

set noswapfile
Expand Down Expand Up @@ -280,14 +273,27 @@ let g:fzf_layout = {'down': '45%'}
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>, fzf#vim#with_preview('right:35%'))


" command! -nargs=* -complete=dir Rg
" \ call fzf#vim#grep(
" \ "rg --column --line-number --no-heading --fixed-strings --smart-case --hidden --color=always --glob '!.git/**' --glob '!.hg/**' --glob '!**/*.ico' --glob '!**/*.png' --glob '!**/*.jpg' --glob '!**/*.jpeg' --glob '!**/*.zip' --glob '!**/*.tar.gz' --glob '!**/*.gif' --glob '!**/*.avi' --glob '!**/*.mp4' --glob '!**/*.mp3' --glob '!**/*.ogg' --glob '!**/*.tgz' --glob '!**/*.gz' --glob '!**/*.ctg.z' --glob '!**/*.bcmap' ".<q-args>, 1,
" \ fzf#vim#with_preview('right:35%'),
" \ )

command! -nargs=* -complete=dir Rg
\ call fzf#vim#grep(
\ "rg --column --line-number --no-heading --fixed-strings --smart-case --hidden --color=always ".<q-args>, 1,
\ fzf#vim#with_preview('right:35%'),
\ )

command! -bang -nargs=* Lines
\ call fzf#vim#lines(<q-args>, fzf#vim#with_preview('right:35%'))

" Immediately trigger a search for the current keyword if there is one
nnoremap <expr> <leader>g (expand("<cword>") ==? "") ? ":Ag " : ":Ag \<C-r>\<C-w><CR>"
nnoremap <expr> <leader>g (expand("<cword>") ==? "") ? ":Rg " : ":Rg \<C-r>\<C-w><CR>"
" Immediately trigger a search for the current selection if there is one
xnoremap <leader>g "zy:exe "Ag ".@z.""<CR>
xnoremap <leader>g "zy:exe "Rg ".@z.""<CR>
let g:prettier#exec_cmd_path = "~/.config/yarn/global/node_modules/.bin/prettier"
let g:prettier#exec_cmd_async = 1
Expand Down Expand Up @@ -400,6 +406,9 @@ set clipboard^=unnamedplus

" from https://stackoverflow.com/questions/4256697/vim-search-and-highlight-but-do-not-jump
nnoremap <silent> <Leader>s :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
xnoremap <silent> <Leader>s "zy<CR>:let @/='<C-R>z'<CR>:set hls<CR>
" xnoremap <silent> <Leader>s "/y<CR>:let @/='<C-R>z'<CR>:set hls<CR>
" xnoremap <silent> <Leader>s "zy:let @/='\<<C-R>z'<CR>
nnoremap <silent> <Leader>h :set nohls<CR>

Expand All @@ -420,8 +429,11 @@ xnoremap <leader>gn :g/./norm<space>
nnoremap <leader>gvn :v/./norm<space>
xnoremap <leader>gvn :v/./norm<space>
" function! Black()
" silent execute ":!black " . expand("%:p")
" silent execute ":e"
" endfunction
" command! -nargs=0 Black call Black()
command! -nargs=0 FoldPython :%g/^\s*def/norm f)jzfii

command! -nargs=* JQ :%!jq <args>
command! -nargs=* Jq :%!jq <args>

command! -nargs=1 Ft :set ft=<args>

command! -nargs=0 Ws :w !sudo tee %
19 changes: 19 additions & 0 deletions .vim/plugin/mystuff/header.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function! MakeHeader()
let l:text = trim(getline('.'))
let l:textlen = strlen(l:text)
let l:headerlen = 79
let l:row1 = repeat(join(['#'], ''), l:headerlen)
let l:row2BeginLen = (l:headerlen - l:textlen - 2 + 1) / 2
let l:row2EndLen = (l:headerlen - l:textlen - 2) / 2
let l:row2 = repeat(join(['#'], ''), l:row2BeginLen) .
\ ' ' . l:text . ' ' .
\ repeat(join(['#'], ''), l:row2EndLen)

call append(line('.'), l:row1)
call append(line('.'), l:row2)
call append(line('.'), l:row1)
" for some reason internet says not to use normal in vimscript
normal! dd
endfunction

command! -nargs=0 Header call MakeHeader()
1 change: 1 addition & 0 deletions .vim/plugin/mystuff/snippets.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ inoremap <C-j>hist <Esc>!!cat ~/.vim/snippets/hist<CR>}i
inoremap <C-j>tbl <Esc>!!cat ~/.vim/snippets/tbl<CR>}}}o<esc>o
inoremap <C-j>table <Esc>!!cat ~/.vim/snippets/tbl<CR>}}}o<esc>o
inoremap <C-j>prof <Esc>!!cat ~/.vim/snippets/prof<CR>}o<esc>0i
inoremap <C-j>sep ------------------------------------------------------------------------------

inoremap <C-j>pset \pset null 'Ø'
Expand Down
10 changes: 9 additions & 1 deletion scripts/bootstrap-python
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/bash

/home/evan/.pyenv/shims/python3.8 -m venv venv
echo "source venv/bin/activate" > .envrc
echo "source venv/bin/activate" >> .envrc
source venv/bin/activate
pip install flake8
pip install mypy
pip install black
pip install jedi

cat <<EOF >> pyproject.toml
[tool.black]
line-length = 79
EOF
31 changes: 31 additions & 0 deletions scripts/pihole
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# https://hub.docker.com/r/diginc/pi-hole/

# IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
# IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{for(i=1;i<=NF;i++) if ($i=="src") print $(i+1)}')" # May not work for VPN / tun0
# IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
# IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP
# DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever.

ServerIP=$(curl api.ipify)
WEBPASSWORD=muttley1
DOCKER_CONFIGS=$(pwd)

echo "### Make sure your IPs are correct, hard code ServerIP ENV VARs if necessary\nIP: ${IP}\nIPv6: ${IPv6}"
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp \
-p 67:67/udp \
-p 80:80 \
-p 443:443 \
-v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \
-v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \
-e ServerIP="${IP}" \
# -e ServerIPv6="${IPv6}" \
--restart=unless-stopped \
--cap-add=NET_ADMIN \
diginc/pi-hole:latest

echo -n "Your password for https://${IP}/admin/ is "
docker logs pihole 2> /dev/null | grep 'password:'
6 changes: 6 additions & 0 deletions scripts/quickdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

docker run --rm -it \
-e POSTGRES_PASSWORD=password -e POSTGRES_USER=evan -e POSTGRES_DB=evan \
-p 5432:5432 \
postgres:12.2
8 changes: 8 additions & 0 deletions scripts/shuffle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
import sys
import random

lines = [line.strip() for line in sys.stdin.readlines()]
random.shuffle(lines)
for line in lines:
print(line)
4 changes: 4 additions & 0 deletions scripts/stopwatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# stolen from https://stackoverflow.com/questions/37986523/how-can-i-create-a-stopwatch-in-bash
now=$(date +%s)sec; watch -n0.1 -p TZ=UTC date --date now-$now +%H:%M:%S.%N
3 changes: 3 additions & 0 deletions scripts/tfwrapper
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ fi

if [ -z "$TFWRAPPER_WORKING_DIR" ]; then
terraform "$ARG1" "$@"
elif [ ! -d "$TFWRAPPER_WORKING_DIR" ]; then
echo -e "\033[31mInvalid directory $TFWRAPPER_WORKING_DIR\033"
exit 1
else
(
cd $TFWRAPPER_WORKING_DIR
Expand Down
2 changes: 2 additions & 0 deletions scripts/timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
now=$(date +%s)sec; watch -n0.1 -p TZ=UTC date --date now-$now +%H:%M:%S.%N
1 change: 1 addition & 0 deletions scripts/today
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date +%Y%m%d

0 comments on commit 34910ec

Please sign in to comment.