Skip to content

Instantly share code, notes, and snippets.

@mahrous-amer
mahrous-amer / git_cheat_sheet.md
Created January 13, 2025 03:59
This cheat sheet serves as a quick reference guide for developers of all levels. It covers essential commands for version control, including file comparison (diff and patch), repository management, committing, branching, remote operations, and security features like GPG signing. It also includes tips for viewing logs, handling file changes acros…

Git and GitHub

Diff and Patch

diff

diff is used to find differences between two files. For easier usage, combine it with -u:

diff -u file1 file2
@mahrous-amer
mahrous-amer / aws_ebs_comliance.sh
Created January 7, 2025 04:31
This script calculates total IOPS for the volumes, compares it with the instance's maximum allowed IOPS, and provides a compliance status based on EBS optimization support.
#!/bin/bash
PROFILE=""
INSTANCE_ID=""
echo "Instance ID: $INSTANCE_ID"
echo "Fetching instance details..."
instance_details=$(aws --profile $PROFILE ec2 describe-instances --instance-ids "$INSTANCE_ID" --query 'Reservations[0].Instances[0]' --output json)
echo "Instance details fetched successfully."
@mahrous-amer
mahrous-amer / aws_scrape.sh
Created January 7, 2025 04:29
Gather detailed information about various AWS resources in a specific region, using a specified AWS CLI profile.
#!/bin/bash
# Define variables
REGION="eu-west-1"
PROFILE="default"
OUTPUT_FORMAT="json"
# Helper function to fetch and print results
function fetch_and_print {
local description=$1
#!/bin/bash
# Define variables
REGION="eu-west-1"
PROFILE="default"
OUTPUT_FORMAT="json"
PERIOD_IN_SECONDS=3600
STATISTIC="Maximum"
END_TIME=$(date -u "+%Y-%m-%dT%H:%M:%SZ")
START_TIME=$(date -u -v-7d "+%Y-%m-%dT%H:%M:%SZ")
@mahrous-amer
mahrous-amer / postgres-dev.sh
Created October 29, 2024 06:29
A Bash utility script for managing a local PostgreSQL Docker container with ease.
#!/bin/bash
# Environment Variables
CONTAINER_NAME="dev-postgres"
POSTGRES_IMAGE="postgres"
POSTGRES_PASSWORD="dev_password"
DATA_DIR="${HOME}/dev_postgres/"
# Display Help
Help()

Docker default address pooling

Default settings

{
 "default-address-pools" : [
 {
 "base" : "172.17.0.0/12",
 "size" : 16