Compare commits

..

7 Commits

4 changed files with 142 additions and 43 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.venv

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Print out escape sequences usable for coloured text on tty.
# shellcheck disable=2016
printf 'Colour escapes are %s\n' '\e[${value};...;${value}m'
printf 'Values 30..37 are \e[33mforeground colours\e[m\n'
printf 'Values 40..47 are \e[43mbackground colours\e[m\n'
@ -17,17 +18,58 @@ for fgc in {30..37}; do
fgc=${fgc#37} # white
bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}"
vals="${fgc:+$fgc};${bgc}"
vals=${vals%%;}
seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}"
echo -e -n " ${seq0}TEXT\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}2mDIM\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}3mITA\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}4mUND\e[m"
echo -e -n " \e[${vals:+${vals+$vals;}}5mBLI\e[m"
echo -en " ${seq0}TEXT\e[m"
echo -en " \e[${vals:+${vals+$vals}};1mBOLD\e[m"
echo -en " \e[${vals:+${vals+$vals}};2mDIM\e[m"
echo -en " \e[${vals:+${vals+$vals}};3mITA\e[m"
echo -en " \e[${vals:+${vals+$vals}};4mUND\e[m"
echo -en " \e[${vals:+${vals+$vals}};5mBLI\e[m"
done
echo; echo
done
rainbowColor() {
local h=$(($1 / 43))
local f=$(($1 - 43 * h))
local t=$((f * 255 / 43))
local q=$((255 - t))
if [ $h -eq 0 ]
then
echo "255 $t 0"
elif [ $h -eq 1 ]
then
echo "$q 255 0"
elif [ $h -eq 2 ]
then
echo "0 255 $t"
elif [ $h -eq 3 ]
then
echo "0 $q 255"
elif [ $h -eq 4 ]
then
echo "$t 0 255"
elif [ $h -eq 5 ]
then
echo "255 0 $q"
else
# execution should never reach here
echo '0 0 0'
fi
}
rf(){ echo "$1" 0 0; }; gf(){ echo 0 "$1" 0; }; bf(){ echo 0 0 "$1"; }
for f in rf gf bf rainbowColor; do
for s in "$(seq 0 127)" "$(seq 255 -1 128)"; do
for i in $s; do
# shellcheck disable=2183,2046
printf '\x1b[48;2;%s;%s;%sm ' $($f "$i")
done
echo -en "\x1b[0m\n"
done
done

65
docker_build Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh
repeat_char(){
end="$1"
for _ in $(seq 1 "$end") ; do
printf '%s' "$2";
done
}
header(){
env printf "┌$(repeat_char 40 ─)┐\n"
env printf '│ %-38s │\n' "$1"
env printf "└$(repeat_char 40 '─')┘\n"
}
base_images_cache=''
pull_base_images(){
base_images=$(echo "$1" | sed 's/ /\n/g' | rg -v "^($(printf '%s' "$base_images_cache" | sed -s 's/ /\|/g'))$" | paste -sd ' ')
# echo "BASE: $base_images"
# echo "CACHE: $base_images_cache"
if [ -n "$base_images" ]; then
base_images_cache="$base_images_cache $base_images"
echo 'Downloading base images'
echo "$base_images" | xargs -n1 docker pull
fi
}
build(){
[ ! -d "$1" ] && return 0
header "$(basename "$1")"
pull_base_images "$(fd Dockerfile "$1" -x rg FROM | cut -d ' ' -f 2 | sort | uniq | paste -sd ' ')"
echo 'Building...'
if [ -z "$2" ]; then
(cd "$1" && docker compose pull)
(cd "$1" && docker compose build)
else
(cd "$1" && docker compose build "$2")
fi
}
if ! rc-service docker status > /dev/null; then
echo 'Docker is not started, exiting'
return 1
fi
build /home/_aspil0w/git/3d-playground
build /home/_aspil0w/git/CoverLetter
build /home/_aspil0w/git/CurriculumVitae
build /home/_aspil0w/git/dotfiles
build /home/_aspil0w/git/ESP32Manager
build /home/_aspil0w/git/haskell_playground
build /home/_aspil0w/git/IntershipReport
build /home/_aspil0w/git/notebook
build /home/_aspil0w/git/portfolio no_ssl
build /home/_aspil0w/git/portfolio_ivo no-ssl
build /home/_aspil0w/git/SimpleGradientDescent
build /home/_aspil0w/git/sorting_algorithms
build /home/_aspil0w/git/VariationalAutoEncoder
build /home/_aspil0w/git/ViolaJones
build /home/_aspil0w/git/wgan-gp
build /home/_aspil0w/git/WGAN-GP_Pytorch
build /home/_aspil0w/git/workspace/Data\ analysis/Speed\ dating\ experiment
build /home/_aspil0w/git/workspace/Miage/M2/Implementation\ de\ l\'IA
build /usr/local/src/Ventoy

View File

@ -1,40 +1,31 @@
#!/bin/sh
set -e
repeat_char(){
end="$1"
for _ in $(seq 1 "$end") ; do
printf '%s' "$2";
done
}
header(){
env printf "$(repeat_char 150)┐\n"
env printf '│ %-148s │\n' "$1"
env printf "$(repeat_char 150 '─')┘\n"
}
VENV_PATH='./.venv'
update(){
fd requirements.txt ~ | while read -r filename; do
echo "Updating : $filename"
python -m venv --upgrade-deps "$VENV_PATH"
# shellcheck disable=1091
if [ -f "$VENV_PATH"/Scripts/activate ]; then . "$VENV_PATH"/Scripts/activate
elif [ -f "$VENV_PATH"/bin/activate ]; then . "$VENV_PATH"/bin/activate
else exit 1; fi
grep -e '^[^#]' "$filename" | cut -d = -f 1 | xargs pip install -U
TEMP_FILE=$(mktemp)
pip freeze | grep -E "($(grep -e '^[^#]' "$filename" | cut -d = -f 1 | paste -sd \|))=" > "$TEMP_FILE"
nvim -d "$filename" "$TEMP_FILE"
deactivate
rm -rf "$VENV_PATH" "$TEMP_FILE"
done
}
download(){
python -m venv --upgrade-deps "$VENV_PATH"
if [ -f "$VENV_PATH"/Scripts/activate ]; then . "$VENV_PATH"/Scripts/activate
elif [ -f "$VENV_PATH"/bin/activate ]; then . "$VENV_PATH"/bin/activate
else exit 1; fi
pip install --disable-pip-version pur
fd requirements.txt ~ | while read -r filename; do
echo "Downloading : $filename"
grep -e '^[^#]' "$filename" | cut -d = -f 1 | xargs pip download
rm *.whl
header "$(realpath "$filename" | sed "s,$HOME,~,")"
pur -r "$filename"
done
deactivate
rm -rf "$VENV_PATH"
}
update