Skip to content

Instantly share code, notes, and snippets.

View a-kbv's full-sized avatar

Atanas Korabov a-kbv

View GitHub Profile
@a-kbv
a-kbv / backup-env.md
Last active September 10, 2024 08:53

This Bash script is designed to recursively search for .env files starting from a specified directory and create a centralized backup structure for these files within a main backup directory called env-backup.

Features and Workflow

  1. Initial Setup:

    • The script identifies the directory from which it is run (the current working directory) using the pwd command.
    • It creates a main backup directory named env-backup in this current directory. All individual backups will be contained within this directory.
  2. Recursive Search:

  • The script accepts a directory path as an argument. It starts searching from this specified directory and recursively finds all files named .env.
#!/bin/bash
# Function to check SSL certificate on a domain and port
check_certificate() {
local domain=$1
local port=$2
echo "Checking SSL certificate for $domain on port $port..."
timeout 5 bash -c "echo | openssl s_client -connect ${domain}:${port} -servername ${domain} 2>/dev/null | openssl x509 -noout -dates"
}
@a-kbv
a-kbv / gist:5b98928b5358ae45602bf16a9be09963
Last active May 23, 2024 15:25
ubuntu/debian PHP version switcher
#!/bin/bash
# Ensure the script is not sourced
if [[ "$(basename -- "$0")" =~ ^(bash|sh)$ ]]; then
echo "Please run the script directly, not with 'source' or '.'"
return 1
fi
# Obtain the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd -P)"
cd "$SCRIPT_DIR"
@a-kbv
a-kbv / helper.sh
Last active August 20, 2023 12:27
helper.sh
#!/bin/bash
VERSION="0.0.2"
# Function to countdown and clear the screen
countdown() {
for (( i=$1; i>=1; i-- )); do
printf "\r$2 %02d seconds.. press any key to cancel" $i
read -s -n 1 -t 1 key
if [[ $key ]]; then
echo ""
return 1
@a-kbv
a-kbv / KMS.md
Last active July 2, 2025 22:37
Windows KMS Activate Guide

Install a product key

To install a client product key, open an administrative command prompt on the client, and run the following command and then press Enter:

slmgr /ipk <product key>

Set KMS machine address.

@a-kbv
a-kbv / gist:282d3af0424ec829352dc73f7865a284
Created April 27, 2023 07:53
Xdebug config on all versions
; Xdebug settings
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9000
;xdebug.discover_client_host=1
; xdebug.log=/var/log/xdebug.log
; Xdebug OLD settings
xdebug.remote_enable=1
xdebug.remote_port=9000
@a-kbv
a-kbv / WampHTTPS.md
Created March 8, 2023 08:44 — forked from danieldogeanu/WampHTTPS.md
How to enable HTTPS for WAMP Server.

After you've downloaded and installed WAMP Server, follow these steps:

  1. Generate SSL certificate using OpenSSL:
  • Add C:\wamp64\bin\apache\apache2.4.27\bin directory to the PATH so you can access openssl command from the command prompt (WAMP comes with its own version of OpenSSL already integrated, so you don't need to install it. You'll find it in this directory.).

    IMPORTANT: Please note that the path of your installation depends on your version of Apache! DO NOT copy and paste the paths presented in this gist as they will not match with yours!

  • Navigate to your user directory (C:\Users\%YOUR_USERNAME%\), create a new folder (.openssl), navigate to it with Powershell and run these commands:

    openssl genrsa -aes256 -out private.key 2048
    

openssl rsa -in private.key -out private.key