Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
In the search for a new challenge!

Thabet Amer ThabetAmer

🎯
In the search for a new challenge!
View GitHub Profile
@ThabetAmer
ThabetAmer / s3-make-public-from-other.sh
Created Oct 5, 2020
AWS S3 bash script to make recent objects uploaded by other owners publicly accessible
View s3-make-public-from-other.sh
#!/bin/bash
BUCKET=
PROFILE_OTHER=
PROFILE_MINE=
DATE=$(date +%Y-%m-%dT%H:00:00)
IFS=$'\t'
@ThabetAmer
ThabetAmer / office365-enableSMTP.ps1
Created Jul 8, 2020
Enables SMTP Auth for Office365 emails
View office365-enableSMTP.ps1
#
# 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 / harbor-retag-all.sh
Created May 7, 2020
Copies all tagged images with defined tag to a new one - using Harbor Retag feature.
View harbor-retag-all.sh
#!/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 / mongo-export.sh
Created Apr 28, 2020
Mongo backup of whole database collections using mongoexport shell tool in json format
View mongo-export.sh
#!/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 ',' ' ')
@ThabetAmer
ThabetAmer / run-shell.groovy
Created Apr 8, 2020
Runs shell command and prints back stdout and stderr
View run-shell.groovy
#!/usr/bin/env groovy
/*
* Runs shell command and prints back stdout and stderr
*/
command='ls -al'
println new ProcessBuilder('sh','-c',command).redirectErrorStream(true).start().text
@ThabetAmer
ThabetAmer / create-jenkins-cred-harbor.sh
Last active Apr 8, 2020
Creates Jenkins credentials with username and password, made for Harbor Robot Accounts, but can be used for any username/password json file
View create-jenkins-cred-harbor.sh
#!/bin/bash
# Creates Jenkins credentials with username and password,
# made for Harbor Robot Accounts, but can be used for any username/password json file
# @author thabet.amer@gmail.com
# @since Jenkins 2.222.1
# @params json file with {"name":"","token":""} tags
# @output Jenkins credential with ID name "harbor-NAME"
View get-ecr-login.sh
#!/bin/bash
aws ecr get-login --no-include-email | sh
# to read the authentication string only, so it can be used in apps.
#aws ecr get-authorization-token --output text --query 'authorizationData[].authorizationToken' --region eu-central-1 \
# | base64 -d | cut -d: -f2
@ThabetAmer
ThabetAmer / docker-compose.yml
Last active Feb 6, 2020
Run SonarQube and SonarScanner in Docker-compose
View docker-compose.yml
#
# Based on https://hub.docker.com/_/sonarqube
#
version: "3.7"
services:
sonarqube:
container_name: sonarqube
@ThabetAmer
ThabetAmer / container-down.rules
Last active Feb 5, 2020
Prometheus rule for a container status
View container-down.rules
- alert: container_down
expr: absent(container_last_seen{job="cadvisor",name="rabbitmq"})
for: 30s
labels:
severity: critical
annotations:
summary: "Container down"
description: "{{ $labels.instance }} {{ $labels.name }} container is down for more than 30 seconds."
@ThabetAmer
ThabetAmer / Docker-dashboard.json
Created Feb 5, 2020
Grafana Docker Containers Dashboard
View Docker-dashboard.json
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",