Initial chezmoi commit

This commit is contained in:
2019-04-15 00:05:48 -04:00
parent 69bb713ff4
commit fda3907f92
106 changed files with 8 additions and 562 deletions

View File

@@ -0,0 +1,5 @@
function carsim
printf '\033c'
# and ./carsim stop $argv[1] $argv[2]
and ./carsim light $argv[1] $argv[2]
end

View File

@@ -0,0 +1,15 @@
function gdb-a2
# gdb -ex "b safeStopSign.c:96" -ex "run" \
# gdb -ex "b safeTrafficLight.c:98" -ex "run" \
gdb -ex "run" -ex "bt" \
# gdb -ex "run" \
# -ex "p cur_lane_queue.count" \
# -ex "p cur_front->car->index" \
# -ex "p cur_front->car" \
# -ex "p cur_front" \
# --args ./carsim stop 1 4
# --args ./carsim stop 3 20
# --args ./carsim light 1 4
--args ./carsim light 1 20
# gdb -ex "b safeStopSign.c:86" -ex "run" --args ./carsim stop 1 10
end

View File

@@ -0,0 +1,30 @@
function gdb-a3-break
# 1 = trace file, 2 = alg
set trace_file 'traceprogs/tr-custom.ref'
set memsize 3
set swapsize 10
if test $argv[1] = 's'
set trace_file 'traceprogs/tr-simpleloop.ref'
set memsize 50
set swapsize 3000
end
set alg 'rand'
switch $argv[2]
case f
set alg 'fifo'
case l
set alg 'lru'
case c
set alg 'clock'
end
printf '\033c'
and bear make
and gdb \
# -ex "b pagetable.c:69" \
# -ex "b sim.c:158" \
-ex "b clock.c:29" \
-ex "run" \
--args ./sim -f $trace_file -m $memsize -s $swapsize -a $alg
end

View File

@@ -0,0 +1,49 @@
function run-a3
# 1 = alg, 2 = trace file, 3 = output
set memsize 3
set swapsize 10
set alg 'rand'
switch $argv[1]
case f
set alg 'fifo'
set trace_file 'traceprogs/tr-fifo.ref'
case l
set alg 'lru'
set trace_file 'traceprogs/tr-lru.ref'
case c
set alg 'clock'
set trace_file 'traceprogs/tr-clock.ref'
end
switch $argv[2]
case c
set trace_file 'traceprogs/tr-custom.ref'
case s
set trace_file 'traceprogs/tr-simpleloop.ref'
set memsize 50
set swapsize 3000
case m
set trace_file 'traceprogs/tr-matmul.ref'
set memsize 100
set swapsize 3000
end
printf '\033c'
# and bear make clean
and bear make
switch $argv[3]
case f
./sim -f $trace_file -m $memsize -s $swapsize -a $alg > a3.out 2>&1
case g
gdb -ex "run" -ex "bt" -ex "q" \
--args ./sim -f $trace_file -m $memsize -s $swapsize -a $alg
case o
./sim -f $trace_file -m $memsize -s $swapsize -a $alg
end
if test (count swapfile.*) -gt 0
rm swapfile.*
end
end

View File

@@ -0,0 +1,5 @@
function block-to-line
set block_size 1024
set bytes_per_line 16
math "($block_size*$argv[1])/$bytes_per_line + 1"
end

View File

@@ -0,0 +1,15 @@
function revert-image
set img_file 'emptydisk.img'
switch $argv[1]
case 1
set img_file 'onefile.img'
case m
set img_file 'multilevel.img'
case l
set img_file 'largefile.img'
case s
set img_file 'symlink.img'
end
cp imgs{-cp,}/$img_file
end

View File

@@ -0,0 +1,12 @@
function hex
switch $argv[1]
case h
# print dec/bin.
printf "%d " (echo "ibase=16;obase=A;$argv[2]" | bc)
printf "%d\n" (echo "ibase=16;obase=2;$argv[2]" | bc)
case d
# print hex/bin.
printf "%s " (echo "obase=16;$argv[2]" | bc)
printf "%d\n" (echo "obase=2;$argv[2]" | bc)
end
end

View File

@@ -0,0 +1,3 @@
function mount-image
sudo mount $argv[1] /mnt/369-a4
end

View File

@@ -0,0 +1,35 @@
function run-a4
# 1 = ex, 2 = img
printf '\033c'
# and bear make clean
bear make
set img_file 'imgs/emptydisk.img'
switch $argv[2]
case 1
set img_file 'imgs/onefile.img'
case m
set img_file 'imgs/multilevel.img'
case l
set img_file 'imgs/largefile.img'
case s
set img_file 'imgs/symlink.img'
end
switch $argv[1]
case h
./ext2_helpers_tester $img_file
case hg
gdb -ex "run" -ex "bt" -ex "q" \
--args ./ext2_helpers_tester './imgs/multilevel.img' '/level1/level2/level3//'
case m
./ext2_mkdir $img_file '/'
# ./ext2_mkdir 'imgs/multilevel.img' '/level1/level2/bfile'
case rg
./readimage $img_file
gdb -ex "run" -ex "bt" -ex "q" \
--args ./readimage './imgs/symlink.img'
case '*'
./readimage $img_file
end
end

View File

@@ -0,0 +1,3 @@
function grep-c
grep -nr --include \*.c $argv[1] ./
end

View File

@@ -0,0 +1,3 @@
function grep-headers
grep --color=auto -nr --include \*.h $argv[1] ./
end

View File

@@ -0,0 +1,3 @@
function rg-headers
rg $argv[1] *.h
end

View File

@@ -0,0 +1,3 @@
function rgc
rg $argv[1] *.c
end

View File

@@ -0,0 +1,3 @@
function benq-brightness
xrandr --output HDMI-0 --gamma 1:0.8:0 --brightness (math $argv[1] / 100)
end

View File

@@ -0,0 +1,53 @@
#
# Wrap the builtin cd command to maintain directory history.
#
function cd --description "Change directory"
set -l MAX_DIR_HIST 25
if test (count $argv) -gt 1
printf "%s\n" (_ "Too many args for cd command")
return 1
end
# Skip history in subshells.
if status --is-command-substitution
builtin cd $argv
return $status
end
# Avoid set completions.
set -l previous $PWD
if test "$argv" = "-"
if test "$__fish_cd_direction" = "next"
nextd
else
prevd
end
return $status
end
# allow explicit "cd ." if the mount-point became stale in the meantime
if test "$argv" = "."
cd "$PWD"
return $status
end
builtin cd $argv
set -l cd_status $status
if test $cd_status -eq 0 -a "$PWD" != "$previous"
set -q dirprev
or set -l dirprev
set -q dirprev[$MAX_DIR_HIST]
and set -e dirprev[1]
set -g -a dirprev $previous
set -e dirnext
set -g __fish_cd_direction prev
set -U last_dir $PWD
lsd -a
end
return $cd_status
end

View File

@@ -0,0 +1,9 @@
function certbot-ssl
set domain_args ""
for domain in $argv
set -a domain_args "-d" $domain
end
echo sudo certbot certonly --manual --preferred-challenges=dns \
--email kevin.mok@live.ca --server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos $domain_args
end

View File

@@ -0,0 +1,3 @@
function copy
$argv[1] $argv[2] | xclip -selection clipboard
end

View File

@@ -0,0 +1,5 @@
function create-fish-function
printf 'function %s\nend' $argv[1] > $fish_fxn_dir/$argv[1].fish
and cd $fish_fxn_dir
and $EDITOR $argv[1].fish
end

View File

@@ -0,0 +1,3 @@
function evince-silent
evince $argv[1] > /dev/null 2>&1&
end

View File

@@ -0,0 +1,3 @@
function find-vim-filetype
fd $argv[1] /usr/share/nvim/runtime/ftplugin
end

View File

@@ -0,0 +1,5 @@
function git-amend-push
git add -A .
and git commit --amend --no-edit -S
and git push --force
end

View File

@@ -0,0 +1,4 @@
function git-delete-branch
git push origin --delete $argv[1]
and git branch -D $argv[1]
end

View File

@@ -0,0 +1,3 @@
function git-diff-files
git diff --name-only $argv[1] $argv[2]
end

View File

@@ -0,0 +1,5 @@
function git-mult-remotes
git remote set-url --add --push origin $argv[1]
and git remote set-url --add --push origin $argv[2]
and git remote -v
end

View File

@@ -0,0 +1,5 @@
function git-push-multiple
git remote set-url --add --push origin $argv[1]
and git remote set-url --add --push origin $argv[2]
and git remote -v
end

View File

@@ -0,0 +1,5 @@
function grep-aliases
set key_aliases /home/kevin/linux-config/aliases/key_aliases
rg $argv[1] $key_aliases
# rg "^$argv[1]" $key_aliases
end

View File

@@ -0,0 +1,4 @@
function grep-pdf-file
pdfgrep -n $argv[1] -B $argv[2] -A $argv[3] (fd -e pdf --no-ignore-vcs) > grep-$argv[1].txt
and nvim grep-$argv[1].txt -c "/$argv[1]"
end

View File

@@ -0,0 +1,3 @@
function grep-pdf
pdfgrep -n $argv[1] (fd -e pdf --no-ignore-vcs)
end

View File

@@ -0,0 +1,3 @@
function pastebin
cat $argv[1] | curl -F 'sprunge=<-' http://sprunge.us
end

View File

@@ -0,0 +1,3 @@
function redshift-set
redshift -x && redshift -O (math "$argv[1] * 100")
end

View File

@@ -0,0 +1,7 @@
function scan-history
sudo systemctl start postgresql.service
# and systemctl status postgresql.service
and source $spv_dir/src/api-keys.sh
and $spv_dir/src/scripts/update-history.sh
and cat $spv_dir/src/api/management/commands/update-history.log | tail -n 1
end

View File

@@ -0,0 +1,3 @@
function shred-rm
shred $argv && rm $argv
end

View File

@@ -0,0 +1,3 @@
function ssh-bandit
sshpass -f p/$argv[1] ssh -p 2220 bandit$argv[1]@bandit.labs.overthewire.org
end

View File

@@ -0,0 +1,4 @@
# convert unix timestamp
function unix-timestamp
date -d @$argv[1]
end

View File

@@ -0,0 +1,4 @@
function unzip-rm
unzip $argv[1]
and rm $argv[1]
end

View File

@@ -0,0 +1,4 @@
function vsnp
set snips_dir "/home/kevin/.vim/plugged/vim-snippets/UltiSnips"
$EDITOR $snips_dir/$argv[1].snippets
end

View File

@@ -0,0 +1,3 @@
function wc-pdf
pdftotext $argv[1] - | wc -w
end