Skip to content

Instantly share code, notes, and snippets.

View ThabetAmer's full-sized avatar
🎯
In the search for a new challenge!

Thabet Amer ThabetAmer

🎯
In the search for a new challenge!
View GitHub Profile
@ThabetAmer
ThabetAmer / docker-compose.yml
Last active December 26, 2023 03:18
Run SonarQube and SonarScanner in Docker-compose
#
# Based on https://hub.docker.com/_/sonarqube
#
version: "3.7"
services:
sonarqube:
container_name: sonarqube
@ThabetAmer
ThabetAmer / get-route53-domain-records.sh
Created August 26, 2023 05:49
Retrieves DNS zone records for a domain on AWS Route53
#!/bin/bash
# @description : retrieves DNS zone records for a domain hosted on AWS Route53
# @usage : bash get-route53-domain-records.sh example.com
# @requirements: proper awscli v2 setup
# @input : domain name, you own!
# @output : text formatted records
DOMAIN=$1
test -z "$DOMAIN" && { echo "ERROR: no domain value is set" && exit -1; }
@ThabetAmer
ThabetAmer / list-git-branches.groovy
Last active February 9, 2023 16:08
Jenkins Groovy script to read Git repo branches and list them in an array, can be suited with Active Choice Jenkins Plugin
#!/usr/bin/env groovy
/**
* List all Git branches of a repo.
* @author thabet.amer@gmail.com
* @since Jenkins 2.204.1
* @params String url for Git repo URL, String credentialID, Bool activeChoice if ActiveChoice plugin used, String defaultBranch
* @return String array of branch names
*
* Dependencies:
@ThabetAmer
ThabetAmer / harbor-retag-all.sh
Created May 7, 2020 07:46
Copies all tagged images with defined tag to a new one - using Harbor Retag feature.
#!/bin/bash
# Copies all tagged images with defined tag to a new one - using Harbor Retag feature.
# config vars
SRC_TAG="latest"
DST_TAG="v1"
HARBOR_API_URL="https://hostname/api"
HARBOR_USR="username"
HARBOR_PSW="password"
@ThabetAmer
ThabetAmer / get-last-successful-build-no.groovy
Last active June 17, 2022 15:34
Groovy/Jenkins function to return the ID number of last successful build for a specific Jenkins job
#!/usr/bin/env groovy
/**
* Gets last successful build number
* @author thabet.amer@gmail.com
* @since Jenkins 2.204.1
* @param String job name
* @return String number of build number
*
*/
@ThabetAmer
ThabetAmer / get_aws_account_no.sh
Created December 8, 2021 07:58
Returns AWS account number from cli
aws sts --profile "${PROFILE:=default}" get-caller-identity --output text --query 'Account'
@ThabetAmer
ThabetAmer / get_tables_counts.sql
Created November 22, 2021 12:51
SQL query to list numbers of rows in each table in a db schema
# tested on Mysql 5.7-8
# set database schema name to run against
SET @db_name = "DBNAME";
# actual query, two columns resulted: table name and its rows count
SELECT
TABLE_NAME,
SUM(TABLE_ROWS) as c
FROM
@ThabetAmer
ThabetAmer / s3-make-public-from-other.sh
Created October 5, 2020 09:34
AWS S3 bash script to make recent objects uploaded by other owners publicly accessible
#!/bin/bash
BUCKET=
PROFILE_OTHER=
PROFILE_MINE=
DATE=$(date +%Y-%m-%dT%H:00:00)
IFS=$'\t'
@ThabetAmer
ThabetAmer / office365-enableSMTP.ps1
Created July 8, 2020 17:52
Enables SMTP Auth for Office365 emails
#
# Enables SMTP Auth for Office365 emails, so you can send emails via a script for application.
# Shall be run via Powershell terminal.
#
# Define your email address that will send emails via SMTP auth
$emailAddress = 'test@test.com'
# asks for email/password
$UserCredential = Get-Credential
@ThabetAmer
ThabetAmer / mongo-export.sh
Created April 28, 2020 16:08
Mongo backup of whole database collections using mongoexport shell tool in json format
#!/bin/bash
# tested on Mongo 3.6
DB='test'
USR='admin'
PSW='admin''
BACKUP_FOLDER="$DB-backup"
COLLECTIONS=$(mongo localhost:27017/$DB -u $USR -p $PSW --authenticationDatabase admin --quiet --eval "db.getCollectionNames()" | tr -d '\[\]\"[:space:]' | tr ',' ' ')