Skip to content

Instantly share code, notes, and snippets.

@developerck
developerck / show the disk usage
Last active August 30, 2021 15:55
show the disk usage
#!/bin/sh
df -Ph | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5,$1 }' | while read output;
do
max=40%
echo $output
used=$(echo $output | awk '{print $1}')
partition=$(echo $output | awk '{print $2}')
if [ ${used%?} -ge ${max%?} ]; then
echo "The partition \"$partition\" on $(hostname) has used $used at $(date)"
fi
@developerck
developerck / nginx for moodle 2.7 with caching and ssl and differnet caching pattern for different media
Last active August 30, 2021 15:55
nginx for moodle 2.7 with caching and ssl and differnet caching pattern for different media
server {
listen 443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
// ssl cert
ssl_certificate /etc/ssl/certs/nginx/client_ssl.chained.crt;
ssl_certificate_key /etc/ssl/certs/nginx/client_ssl.key;
server_name client.com; // servername
@developerck
developerck / AWS ec2 start using lambda
Last active August 30, 2021 17:46
AWS ec2 start using lambda
import boto3
import json
import os
import logging
region = ''
region = os.environ['region'];
if not region :
logger.error('Missing region');
raise
@developerck
developerck / aws resize ec2 through lambda
Created August 30, 2021 17:50
aws resize ec2 through lambda
import boto3
import json
import os
import logging
region = ''
region = os.environ['region'];
if not region :
logger.error('Missing region');
raise
@developerck
developerck / README.md
Last active April 1, 2022 05:24
Bitbucket API implementation to validate the changefiles in a Pull Request

bit bucket pipeline for and code validation and change pull request status with comment.

  • Replace < BITBUCKET REPO URL > with your bitbucket repo URL in lib.php and pull-build.php
  • This is also validating coding standard as per PHPCS, please change the path accordingly in lib.php
  • pull-build.php get the changelogs and lib.php have the function to accept/decline/post comment on PR
  • PHPCS is optional and maintained with a repository variable, and also some of the variables needed   $BB_USERNAME $BB_PASSWORD $BB_PHPCS $BB_DECLINE
  • Make a user in bitbucket, create an app password and use that username and password for this. that user must have access to the repo and shoudl be able to read and write to accept and decline the Pull request   
@developerck
developerck / README.md
Last active May 15, 2023 06:41
aws lambda for executing run command using python

aws lambda for executing run command using python

you must have following pre-requsite

instance_id = '' # hard-code for example

document_name = '<>' # run command document name

command_param = {'commands': ['sh /root/shellscript.sh '+ shellparam]}, # shell script path

s3_bucket = 'mybucket' # to store the logs

This will create the base environment which is required to run moodle.

codebase root

data root

docker run -it /bin/bash --hostname d01 --name d01 -d -p 8081:80 --volume=:/var/www/html/app --volume=:/var/www/data lms/d01

@developerck
developerck / sg-check.py
Created September 16, 2022 11:56
check security groups in a region if linked to a instance or not
#!/usr/local/bin/python3
import re
from collections import OrderedDict
from pprint import pprint
import boto3
ec2 = None
# define your region and run in cloud shell
@developerck
developerck / README.md
Last active May 15, 2023 06:40
add email to ses supression list to avoid next bounce, subscribe this lambda on bounce notification

Add email into SES suppression list through lambda function , hooked on ses bounce SNS

@developerck
developerck / README.md
Last active May 15, 2023 06:40
create jira ticket and add comment from email

lambda function for creating Jira ticket and comment through Email forwarding