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 / 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 / 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 / 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 / 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 / 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 / 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 / script.sh
Created May 27, 2020 07:36 — forked from pigri/script.sh
ENI cleaner
@export ENIS=$$(aws ec2 describe-network-interfaces --filters "Name=status,Values=available" | jq ".NetworkInterfaces[] | select(.VpcId == \"$${VPC_ID}\") | .NetworkInterfaceId"); \
if [[ ! -z $${DRY_RUN} ]]; then \
echo "Running in dry run mode! No changes will be made. The following ENIs would be deleted:"; \
echo $${ENIS}; \
exit 0; \
else \
for eni in $$(echo $${ENIS}| tr -d "\""); \
do \
aws ec2 delete-network-interface --network-interface-id $${eni}; \
done; \
@MrHassanMurtaza
MrHassanMurtaza / ec2-ssh.sh
Last active May 29, 2020 06:54
SSH to ec2 using session manager
#!/bin/bash
# Wrapper around AWS session manager for instance access using public ip and private ip
scriptname=$0
# Defaults
region='us-east-1'
profile=''
################################################################################
@MrHassanMurtaza
MrHassanMurtaza / introrx.md
Created February 24, 2020 13:24 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@MrHassanMurtaza
MrHassanMurtaza / install_ncdu_amazon_linux.sh
Created February 11, 2020 07:29
Install ncdu on amazon linux 2
#!/bin/bash
# install packages/dependencies for compilation
sudo yum -y install gcc make ncurses-devel
cd /tmp
# the latest version of ncdu is published here: http://dev.yorhel.nl/ncdu
# update the link below if necessary:
wget -nv http://dev.yorhel.nl/download/ncdu-1.10.tar.gz