Skip to content

Instantly share code, notes, and snippets.

@amineHY
amineHY / convert_asciidoc_to_txt.sh
Created February 4, 2024 18:40
This Bash script converts an AsciiDoc file to plain text using Asciidoctor and Pandoc. It takes the AsciiDoc file as a command-line argument, generates an intermediate XML file, converts it to plain text, opens the text file for analysis, and then deletes the intermediate XML file. The script can be executed from any directory by providing the f…
#!/bin/bash
# This Bash script converts an AsciiDoc file to plain text using Asciidoctor and Pandoc. It takes the AsciiDoc file as a command-line argument, generates an intermediate XML file, converts it to plain text, opens the text file for analysis, and then deletes the intermediate XML file. The script can be executed from any directory by providing the full or relative path to the AsciiDoc file.
# usage: ./convert_asciidoc_to_txt.sh /path/to/your/input_file.adoc
# Install Asciidoctor and Pandoc if not already installed
if ! command -v asciidoctor &> /dev/null; then
gem install asciidoctor
fi
if ! command -v pandoc &> /dev/null; then
@amineHY
amineHY / password_generator_mac.sh
Created December 22, 2023 09:00
This script generates and outputs a 15-character password that includes symbols and is secure
#!/bin/bash
# This script generates and outputs a 15-character password that includes symbols and is secure
# It uses the pwgen utility, which needs to be installed first (e.g., with brew install pwgen)
# To run this script, save it as password.sh and make it executable with chmod +x password.sh
# Then execute it with ./password.sh
# Check if pwgen is installed
if ! command -v pwgen &>/dev/null; then
# If not, install it with brew install pwgen
echo "pwgen is not installed. Installing it now..."
@amineHY
amineHY / convert_asciidoc_to_markdown.sh
Last active February 4, 2024 18:40
Convert Asciidoc file to Markdown
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <input_file.adoc>"
exit 1
fi
# Input AsciiDoc file
input_file="$1"
@amineHY
amineHY / chatgpt_prompt_corrector_from_asciidoc.txt
Created April 22, 2023 11:03
Chatgpt_prompt_corrector_from_asciidoc.txt
Vous êtes mon assistant professionnel de vérification et de mise en forme en français. Vous devez corriger les erreurs de syntaxe et de grammaire et fournir une version professionnelle. Je vais vous donner le compte rendu rédigé en Asciidoctor. Donc faites attention au format. J’insiste sur le fait que le texte est écrit en Asciidoctor
@amineHY
amineHY / convert_asciidoc_to_pdf.sh
Last active February 4, 2024 18:41
Converts an AsciiDoc file to PDF using asciidoctor-pdf
#!/bin/bash
# Help function to display usage instructions
function usage() {
echo "Usage: $0 <filename>"
echo "Converts an AsciiDoc file to PDF using asciidoctor-pdf."
echo ""
echo "Options:"
echo " -h, --help Display this help message."
}
@amineHY
amineHY / convert_asciidoc_to_docx.sh
Last active February 4, 2024 18:41
Convert an AsciiDoc file to HTML and then to DOCX.
#!/bin/bash
usage() {
echo "Usage: $0 [-h] FILENAME" >&2
echo "Convert an AsciiDoc file to DOCX" >&2
echo "" >&2
echo "positional arguments:" >&2
echo " FILENAME path to the AsciiDoc file" >&2
echo "" >&2
echo "optional arguments:" >&2
@amineHY
amineHY / disk_usage.sh
Created April 16, 2023 12:45
This is a bash script that can be used to analyze the disk usage of a directory and its subdirectories.
#!/bin/bash
# define the directory to analyze (default is the current directory)
DIR=${1:-.}
# run the du command to get disk usage information
du -ah $DIR | sort -rh | head -n 20
# explain the output
echo ""
@amineHY
amineHY / clean_update_ubuntu.sh
Created April 15, 2023 17:07
The script you provided updates and upgrades packages, removes unused packages, cleans up old kernels and temporary files, and cleans up the package cache. It also upgrades snap and flatpak packages and refreshes the snap-store.
#!/bin/bash
# update package lists
sudo apt-get update
# upgrade packages
sudo apt-get upgrade -y
# upgrade distribution (if available)
sudo apt-get dist-upgrade -y
@amineHY
amineHY / password_generator_linux.sh
Last active December 21, 2023 18:25
This script generates and outputs a 16-character password that includes symbols and is secure # It uses the pwgen utility, which needs to be installed first # To run this script, save it as password_generator.sh and make it executable with chmod +x password.sh # Then execute it with ./password_generator.sh
#!/bin/bash
# This script generates and outputs a 15-character password that includes symbols and is secure
# It uses the pwgen and xclip utilities, which need to be installed first
# To run this script, save it as password.sh and make it executable with chmod +x password.sh
# Then execute it with ./password.sh
# Check if pwgen is installed
if ! command -v pwgen &>/dev/null; then
# If not, install it with sudo apt-get install pwgen
echo "pwgen is not installed. Installing it now..."
@amineHY
amineHY / setup_pipenv_env.sh
Last active April 9, 2023 13:29
Setup python projet using pipenv, do not gorget to make it executable `chmod +x setup_pipenv_env.sh` then run `./setup_pipenv_env.sh`
#!/bin/bash
echo "Checking if pip3 is installed..."
if ! command -v pip3 &> /dev/null
then
echo "pip3 is not installed. Please install it first."
exit 1
else
echo "pip3 is installed."
fi