summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlucasskvn <lucas.sangkhavongs@epitech.eu>2025-07-07 14:49:21 +0200
committerlucasskvn <lucas.sangkhavongs@epitech.eu>2025-07-07 14:49:21 +0200
commitd7302236417e3e88a715583f286e218493199dd3 (patch)
tree77d6f9163ca4d99f76ce69db7ec780519da298fb
init
-rwxr-xr-xcoding-style71
-rwxr-xr-xcpool6
-rwxr-xr-xcs40
-rwxr-xr-xgitignorent13
-rw-r--r--include/libmy.h45
-rwxr-xr-xlib9
-rwxr-xr-xmoulixd10
-rwxr-xr-xnvimedit13
-rwxr-xr-xopentech24
-rwxr-xr-xwebtech24
10 files changed, 255 insertions, 0 deletions
diff --git a/coding-style b/coding-style
new file mode 100755
index 0000000..7de4891
--- /dev/null
+++ b/coding-style
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+
+function my_readlink() {
+ cd $1
+ pwd
+ cd - > /dev/null
+}
+
+function cat_readme() {
+ echo ""
+ echo "Usage: $(basename $0) DELIVERY_DIR REPORTS_DIR"
+ echo -e "\tDELIVERY_DIR\tShould be the directory where your project files are"
+ echo -e "\tREPORTS_DIR\tShould be the directory where we output the reports"
+ echo -e "\t\t\tTake note that existing reports will be overriden"
+ echo ""
+}
+
+if [ $# == 1 ] && [ $1 == "--help" ]; then
+ cat_readme
+elif [ $# == 1 ] || [ $# = 2 ];
+then
+ if [ $# == 1 ];
+ then
+ REPORTS_DIR=$(my_readlink ".")
+ elif [ $# = 2 ];
+ then
+ REPORTS_DIR=$(my_readlink "$2")
+ fi
+
+ DELIVERY_DIR=$(my_readlink "$1")
+ DOCKER_SOCKET_PATH=/var/run/docker.sock
+ HAS_SOCKET_ACCESS=$(test -r $DOCKER_SOCKET_PATH; echo "$?")
+ GHCR_REGISTRY_TOKEN=$(curl -s "https://ghcr.io/token?service=ghcr.io&scope=repository:epitech/coding-style-checker:pull" | grep -o '"token":"[^"]*' | grep -o '[^"]*$')
+ GHCR_REPOSITORY_STATUS=$(curl -I -f -s -o /dev/null -H "Authorization: Bearer $GHCR_REGISTRY_TOKEN" "https://ghcr.io/v2/epitech/coding-style-checker/manifests/latest" && echo 0 || echo 1)
+ BASE_EXEC_CMD="docker"
+ EXPORT_FILE="$REPORTS_DIR"/coding-style-reports.log
+ ### delete existing report file
+ rm -f "$EXPORT_FILE"
+
+ ### Pull new version of docker image and clean olds
+
+ if [ $HAS_SOCKET_ACCESS -ne 0 ]; then
+ echo "WARNING: Socket access is denied"
+ echo "To fix this we will add the current user to docker group with : sudo usermod -a -G docker $USER"
+ read -p "Do you want to proceed? (yes/no) " yn
+ case $yn in
+ yes | Y | y | Yes | YES) echo "ok, we will proceed";
+ sudo usermod -a -G docker $USER;
+ echo "You must reboot your computer for the changes to take effect";;
+ no | N | n | No | NO) echo "ok, Skipping";;
+ * ) echo "invalid response, Skipping";;
+ esac
+ BASE_EXEC_CMD="sudo ${BASE_EXEC_CMD}"
+ fi
+
+
+ if [ $GHCR_REPOSITORY_STATUS -eq 0 ]; then
+ echo "Downloading new image and cleaning old one..."
+ $BASE_EXEC_CMD pull ghcr.io/epitech/coding-style-checker:latest && $BASE_EXEC_CMD image prune -f
+ echo "Download OK"
+ else
+ echo "WARNING: Skipping image download"
+ fi
+
+
+ ### generate reports
+ $BASE_EXEC_CMD run --rm --security-opt "label:disable" -i -v "$DELIVERY_DIR":"/mnt/delivery" -v "$REPORTS_DIR":"/mnt/reports" ghcr.io/epitech/coding-style-checker:latest "/mnt/delivery" "/mnt/reports"
+ [[ -f "$EXPORT_FILE" ]] && echo "$(wc -l < "$EXPORT_FILE") coding style error(s) reported in "$EXPORT_FILE", $(grep -c ": MAJOR:" "$EXPORT_FILE") major, $(grep -c ": MINOR:" "$EXPORT_FILE") minor, $(grep -c ": INFO:" "$EXPORT_FILE") info"
+else
+ cat_readme
+fi
diff --git a/cpool b/cpool
new file mode 100755
index 0000000..508d0d2
--- /dev/null
+++ b/cpool
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+if [ -n "$@" ];
+then
+ cd ~/delivery/B-CPE-100-LYN-1-1-cpoolday$1-lucas.sangkhavongs/
+fi
diff --git a/cs b/cs
new file mode 100755
index 0000000..4e9cc95
--- /dev/null
+++ b/cs
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+ruleset_dir="$HOME/scripts/banana-coding-style-checker/vera"
+
+start_time=$(date +%s)
+if [ -z "$1" ]; then
+ project_dir=$(pwd)
+else
+ project_dir="$1"
+fi
+echo "Running norm in $project_dir"
+
+count=$(find "$project_dir" \
+ -type f \
+ -not -path "*/.git/*" \
+ -not -path "*/.idea/*" \
+ -not -path "*/.vscode/*" \
+ -not -path "bonus/*" \
+ -not -path "tests/*" \
+ -not -path "/*build/*" \
+ -not -path "\#*\#" \
+ -not -path "*\~" \
+ | vera++ \
+ --profile epitech \
+ --root $ruleset_dir \
+ --error \
+ 2>&1 \
+ | sed "s|$project_dir/||" \
+ | tee /dev/tty | wc -l
+)
+
+end_time=$(date +%s)
+
+echo "Found $count issues"
+echo "Ran in $((end_time - start_time))s"
+
+if [ $count -gt 0 ]; then
+ exit 1
+fi
+exit 0
diff --git a/gitignorent b/gitignorent
new file mode 100755
index 0000000..b5c9056
--- /dev/null
+++ b/gitignorent
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ -n "$@" ];
+then
+ if [ $1 == "edit" ]
+ then
+ nvim .gitignore
+ else
+ cp /home/lucasskvn/delivery/my_scripts/.gitignore $1
+ fi
+else
+ echo "J'ai besoin d'un fichier en paramètre ou écrivez edit pour editer le gitignore."
+fi
diff --git a/include/libmy.h b/include/libmy.h
new file mode 100644
index 0000000..e1ba9b2
--- /dev/null
+++ b/include/libmy.h
@@ -0,0 +1,45 @@
+/*
+** EPITECH PROJECT, 2024
+** libmy.h
+** File description:
+** libmy.h for lib
+*/
+#include <unistd.h>
+
+#ifndef LIBMY_H
+ #define LIBMY_H
+
+void my_putchar(char c);
+int my_isneg(int nb);
+int my_put_nbr(int nb);
+void my_swap(int *a, int *b);
+int my_putstr(char const *str);
+int my_strlen(char const *str);
+int my_getnbr(char const *str);
+void my_sort_int_array(int *tab, int size);
+int my_compute_power_rec(int nb, int power);
+int my_compute_square_root(int nb);
+int my_is_prime(int nb);
+int my_find_prime_sup(int nb);
+char *my_strcpy(char *dest, char const *src);
+char *my_strncpy(char *dest, char const *src, int n);
+char *my_revstr(char *str);
+char *my_strstr(char *str, char const *to_find);
+int my_strcmp(char const *s1, char const *s2);
+int my_strncmp(char const *s1, char const *s2, int n);
+char *my_strupcase(char *str);
+char *my_strlowcase(char *str);
+char *my_strcapitalize(char *str);
+int my_str_isalpha(char const *str);
+int my_str_isnum(char const *str);
+int my_str_islower(char const *str);
+int my_str_isupper(char const *str);
+int my_str_isprintable(char const *str);
+int my_showstr(char const *str);
+int my_showmem(char const *str, int size);
+char *my_strcat(char *dest, char const *src);
+char *my_strncat(char *dest, char const *src, int nb);
+char *my_strdup(char const *src);
+char **my_str_to_word_array(char const *str);
+
+#endif // LIBMY_H
diff --git a/lib b/lib
new file mode 100755
index 0000000..71cb986
--- /dev/null
+++ b/lib
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ -n "$@" ];
+then
+ cp -r ~/delivery/my_lib/lib $1
+ cp -r ~/delivery/my_lib/include $1
+ cp -r ~/delivery/my_lib/Makefile $1
+ cp -r ~/delivery/my_lib/.gitignore $1
+fi
diff --git a/moulixd b/moulixd
new file mode 100755
index 0000000..42979f3
--- /dev/null
+++ b/moulixd
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+if [ -n "$@" ];
+then
+ echo $1 >> temp1
+ diff $1 $2
+ rm temp1
+else
+ echo "J'ai besoin de 2 arguments pour comparer les résultats."
+fi
diff --git a/nvimedit b/nvimedit
new file mode 100755
index 0000000..aeb9e2f
--- /dev/null
+++ b/nvimedit
@@ -0,0 +1,13 @@
+if [ $1 == backup ];
+then
+ cp -r ~/.config/nvim/* ../../Backup
+ echo "init.vm a été mis dans le dossier Backup"
+elif [ $1 == vimscript ];
+then
+ nvim ~/.config/nvim/vimrc.vim
+elif [ $1 == lua ];
+then
+ nvim ~/.config/nvim/init.lua
+else
+ echo "ARGS = vimscript, lua, backup"
+fi
diff --git a/opentech b/opentech
new file mode 100755
index 0000000..4c868ba
--- /dev/null
+++ b/opentech
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ $1 == cstyle ];
+then
+ firefox https://intra.epitech.eu/file/public/technical-documentations/C/epitech_c_coding_style.pdf
+ clear
+elif [ $1 == intra ];
+then
+ firefox https://intra.epitech.eu/
+ clear
+elif [ $1 == mouli ];
+then
+ firefox my.epitech.eu
+else
+ # Récupérer le nom du répertoire courant
+ DIR_NAME=$(basename "$PWD")
+
+ # Construire l'URL
+ URL="https://github.com/EpitechPGEPromo2029/${DIR_NAME}/tree/main"
+
+ # Ouvrir l'URL dans Firefox
+ firefox "$URL"
+ clear
+fi
diff --git a/webtech b/webtech
new file mode 100755
index 0000000..4c868ba
--- /dev/null
+++ b/webtech
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ $1 == cstyle ];
+then
+ firefox https://intra.epitech.eu/file/public/technical-documentations/C/epitech_c_coding_style.pdf
+ clear
+elif [ $1 == intra ];
+then
+ firefox https://intra.epitech.eu/
+ clear
+elif [ $1 == mouli ];
+then
+ firefox my.epitech.eu
+else
+ # Récupérer le nom du répertoire courant
+ DIR_NAME=$(basename "$PWD")
+
+ # Construire l'URL
+ URL="https://github.com/EpitechPGEPromo2029/${DIR_NAME}/tree/main"
+
+ # Ouvrir l'URL dans Firefox
+ firefox "$URL"
+ clear
+fi