diff --git a/.bashrc b/.bashrc index fdfdd92..dd1d044 100644 --- a/.bashrc +++ b/.bashrc @@ -14,8 +14,56 @@ alias push='git push origin master ; git push gitea master' alias francinette=/nfs/homes/tischmid/francinette/tester.sh alias paco=/nfs/homes/tischmid/francinette/tester.sh alias norm='alacritty -e sh -c '\''git rev-parse --show-toplevel || { echo "Exiting in 5" ; sleep 1 ; echo "Exiting in 4" ; sleep 1 ; echo "Exiting in 3" ; sleep 1 ; echo "Exiting in 2" ; sleep 1 ; echo "Exiting in 1" ; sleep 1 ; } && cd "$(git rev-parse --show-toplevel)" && watch -cn.5 date \&\& norminette -R CheckForbiddenSourceHeader'\'' & disown' -# alias zellij='zellij options --disable-mouse-mode' -alias z='zellij' +alias AH='cd /nfs/homes/tischmid/repos/42cursus/libft' +alias z='\zellij options --disable-mouse-mode' +alias zellij='\zellij options --disable-mouse-mode' + +__ftest_file () { + file="${1}" + tmp_dir="${2}" + + test_file_name="$($(type -P basename) -- "${file%.c}_test.c")" + test_file="$(find "${tmp_dir}" -name "${test_file_name}" -type f)" + if [ -z "${test_file}" ]; then + printf '\033[31m%s\033[m\n' "No test file for file '${file}'" + return 1 + fi + ${test_file} +} + +ftest () { + err="0" + if [ -z "${tmp_dir}" ]; then + tmp_dir="$(mktemp -dt -- '42tests-tischmid.XXXXXXXX')" + git clone --quiet 'https://git.timo.one/42berlin/42tests-tischmid.git' "${tmp_dir}" + fi + if [ -z "${@}" ]; then + for file in $(find . -mindepth 1 -type f -name '*.c'); do + __ftest_file "${file}" "${tmp_dir}" || err="1" + done + else + while [ -z "${1}" ]; do + if [ -f "${1}" ]; then + __ftest_file "${1}" "${tmp_dir}" || err="1" + else + printf '\033[31m%s\033[m\n' "File ${1} does not exist" + fi + shift + done + fi + rm -rf -- "/tmp/42tests-tischmid.*" + unset -v -- "tmp_dir" + return -- "${err}" +} + +dapt () { + ACTION="${1}" + shift + CMD="RUN apt ${ACTION} -yy ${@}" + echo "${CMD}" >> ~/repos-other/docker/Dockerfile + docker build -t ubuntu-bloated ~/repos-other/docker/ + docker rmi $(docker images -f "dangling=true" -q) 2>/dev/null +} norminette () { version="$($(type -P norminette) -v | cut -d" " -f2)" @@ -40,12 +88,18 @@ if [ ! -f ~/git-prompt.sh ] && [ "${GIT_PROMPT}" = "1" ] ; then curl --silent --location 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh' -o "/nfs/homes/tischmid/git-prompt.sh" fi +__norm () { + [ -z "${PWD##*ft*}" ] || { return 1; } + norminette 1>/dev/null 2>&1 && printf ' \033[92m%s\033[m' "[Norm: OK]" || printf ' \033[101;37m%s\033[m' "[䝝誒 ‼ NORM ‼ 屌誒]" + return 0 +} + if [ "${GIT_PROMPT}" = "1" ] ; then . ~/git-prompt.sh export GIT_PS1_SHOWDIRTYSTATE=1 - PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]$(__git_ps1 " (%s)")\[\033[m\]\n\[\033[35m\]~>\[\033[m\] ' + PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]$(__git_ps1 " (%s)")\[\033[m\]\[\033[36m\]$(__norm)\[\033[m\]\n\[\033[35m\]~>\[\033[m\] ' else - PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\n\[\033[36m\]~>\[\033[m\] ' + PS1='\[\033[31m\]\u\[\033[m\]@\[\033[32m\]\h\[\033[m\] \[\033[33m\][\w]\[\033[m\]\[\033[36m\]$(__norm)\[\033[m\]\n\[\033[36m\]~>\[\033[m\] ' fi ##----------------------------------------------------- @@ -284,3 +338,5 @@ clone42 () { printf '%s\n' "Could not clone repo!" fi } + +export MAIL='timo42@proton.me' diff --git a/autoslot.sh b/autoslot.sh deleted file mode 100755 index 95297ee..0000000 --- a/autoslot.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -ITERS=1000 -HEAD=20 -DELAY=2 - -for i in $(seq ${ITERS}); do - clear - printf '\033[36m%s\033[m\n' "AUTOSLOT: Query available slots periodically." - printf '\033[33m%s\033[m\n' "Iter: ${i} / ${ITERS}" - printf '\033[32m%s\033[m\n' "$(date)" - printf '\033[34m%s\033[m\n' "Next ${HEAD} Slots Open At:" - ls | - curl 'https://projects.intra.42.fr/projects/c-piscine-c-09/slots.json?team_id=4794452&start=2023-04-03&end=2023-04-10' \ - -H 'authority: projects.intra.42.fr' \ - -H 'accept: application/json, text/javascript, */*; q=0.01' \ - -H 'accept-language: en-US,en;q=0.5' \ - -H 'cookie: user.id=MTQ3ODQ1--2ed4a01852220e3253f40a3457511a8ae91ca457; _intra_42_session_production=d388a07c3b652d22cb38c0a479fd92c3' \ - -H 'if-none-match: W/"ee8b807b4fc232c12d6bcc25febf4edf"' \ - -H 'referer: https://projects.intra.42.fr/projects/c-piscine-c-09/slots?team_id=4794734' \ - -H 'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Brave";v="110"' \ - -H 'sec-ch-ua-mobile: ?0' \ - -H 'sec-ch-ua-platform: "Linux"' \ - -H 'sec-fetch-dest: empty' \ - -H 'sec-fetch-mode: cors' \ - -H 'sec-fetch-site: same-origin' \ - -H 'sec-gpc: 1' \ - -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36' \ - -H 'x-csrf-token: /jMPY039ROQ/9Kh17Oy23ixJ6iX70nRmy00o8F2ROZQcuCha0rjtlQ/zEon7X4MfAKXECBSS4ghsaRuDuj8xLQ==' \ - -H 'x-requested-with: XMLHttpRequest' \ - --compressed \ - -s | - jq '.[].start' -r | - tr 'T' ' ' | - sed 's/\.000+0[[:digit:]]:00//g' | - sort -n | - head -n${HEAD} - printf '\033[35m%s\033[m\n' "" - sleep ${DELAY} -done