Skip to content

Instantly share code, notes, and snippets.

View MrHassanMurtaza's full-sized avatar
🎯
Focusing

Hassan Murtaza MrHassanMurtaza

🎯
Focusing
View GitHub Profile
@MrHassanMurtaza
MrHassanMurtaza / aws-k8s-cni.yaml
Created May 29, 2020 06:50
Set warm pool CNI var
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: aws-node
rules:
- apiGroups:
- crd.k8s.amazonaws.com
resources:
- "*"
@MrHassanMurtaza
MrHassanMurtaza / mongoconsole.sh
Created June 22, 2020 15:57 — forked from stanislavb/mongoconsole.sh
Backup and restore MongoDB running in a Docker container
#!/bin/bash
usage() {
echo "Usage $0 -c mongo_docker_container_name"
}
while [[ $# > 1 ]]
do
key="$1"
@MrHassanMurtaza
MrHassanMurtaza / buckets.tf
Created July 10, 2020 09:51 — forked from nagelflorian/buckets.tf
Terraform config for static website hosting on AWS
# AWS S3 bucket for static hosting
resource "aws_s3_bucket" "website" {
bucket = "${var.website_bucket_name}"
acl = "public-read"
tags {
Name = "Website"
Environment = "production"
}
@MrHassanMurtaza
MrHassanMurtaza / helper.py
Last active August 9, 2020 17:26
Python logging helper
import logging
from logging.handlers import TimedRotatingFileHandler
def get_logger(module_name):
"""
Get logger for all the modules
"""
logger = logging.getLogger(module_name)
@MrHassanMurtaza
MrHassanMurtaza / poller.py
Last active August 9, 2020 17:37
Poll Azure Storage Queue and Do Multiprocessing
import sys
from os import environ
from datetime import datetime
from multiprocessing import Pool
from azure.storage.queue import QueueServiceClient
CONNECTION_STRING = environ.get('CONNECTION_STRING')
@MrHassanMurtaza
MrHassanMurtaza / log.sh
Created August 13, 2020 07:10
Log bash output in containers
#!/bin/sh
log_message()
{
MSG=$@
LOGTIMESTAMP=`date "+%Y-%m-%d-%H:%M:%S"`
LOG_MSG="${LOGTIMESTAMP} Back-up from container $(hostname): ${MSG}"
echo "${LOG_MSG}"
}
@MrHassanMurtaza
MrHassanMurtaza / keycloak-import-docker.sh
Last active February 9, 2022 14:33
Keycloak Import in Docker and Exit
#!/bin/sh
# If something goes wrong, this script does not run forever but times out
TIMEOUT_SECONDS=300
# Logfile for the keycloak export instance
LOGFILE=/tmp/standalone.sh.log
# destionation export file
JSON_IMPORT_FILE=/opt/jboss/keycloak/imports/realm-export.json
@MrHassanMurtaza
MrHassanMurtaza / keycloak-export-docker.sh
Last active July 8, 2024 19:51
Keycloak export in Docker and Exit
# If something goes wrong, this script does not run forever but times out
TIMEOUT_SECONDS=300
# Logfile for the keycloak export instance
LOGFILE=/tmp/standalone.sh.log
# destionation export file
JSON_EXPORT_FILE=/tmp/realms-export-single-file.json
rm -f ${LOGFILE} ${JSON_EXPORT_FILE}
# Start a new keycloak instance with exporting options enabled.
@MrHassanMurtaza
MrHassanMurtaza / s3-latest-object.sh
Last active June 16, 2021 10:26
Getting latest s3 bucket's object
#!/bin/bash
set -x
set -e
S3_BUCKET=""
S3_PREFIX=""
OBJECT="$(aws s3 ls s3://$S3_BUCKET/$S3_PREFIX | sort | tail -n 1 | awk '{print $4}')"
[ -z "$OBJECT" ] && echo "Object not found in S3 Bucket." && exit 1
@MrHassanMurtaza
MrHassanMurtaza / reboot-ec2.py
Created June 16, 2021 10:58
reboot ec2 instance using lambda
import json
import boto3
EC2_INSTANCE_ID="i-xxxxxx"
ec2_handle = boto3.client(
'ec2'
)
def lambda_handler(event, context):