Skip to content

Instantly share code, notes, and snippets.

View mahi424's full-sized avatar

Mahaveer Chouhan mahi424

View GitHub Profile
@mahi424
mahi424 / rds-password-rotate.py
Created May 30, 2024 05:49
Rotate Password of RDS by lambda on scheduled basis
import boto3
import mysql.connector
from sendgrid.helpers.mail import Mail, Email, To, Content
from sendgrid import SendGridAPIClient
import certifi
import string
import random
import os
from urllib3 import disable_warnings, exceptions
@mahi424
mahi424 / debug-typeorm-query-builder.ts
Created May 27, 2024 12:09
debug-typeorm-query-builder.ts
function printQueryBuilderSql(query: SelectQueryBuilder<any>) {
const sql = query.getSql();
const parameters = query.getParameters();
console.log("SQL:", sql);
console.log("Parameters:", parameters);
}
printQueryBuilderSql(query);
Include ~/.ssh/fixed/fixed-config
https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/
@mahi424
mahi424 / typeorm-circular-dependency.md
Created November 17, 2023 05:17
typeorm-circular-dependency.md
// in module
forwardRef(() => OrganisationModule)


// in service
    @Inject(forwardRef(() => OrganisationService))
    private readonly organisationService: OrganisationService,
 
@mahi424
mahi424 / rename-org.sh
Created October 20, 2023 06:31
if you have moved repos from one account to other. this changes the git origin links to new.
#!/bin/bash
# Prompt the user for the old and new organization names
# read -p "Enter your old organization name: " old_org
# read -p "Enter your new organization name: " new_org
old_org=old_org
new_org=new_org
# Find all git directories recursively from the current directory
repos=$(find . -name ".git" -type d)
#!/bin/bash
install_snap_redis () {
sudo snap install redis
}
install_apt_redis () {
sudo apt install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
#!/bin/bash
checkout_latest_branch() {
# Fetch all remote branches
git fetch --all
# Get the remote branch with the latest commit
latest_branch=$(git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/remotes/origin/ | head -n 1)
if [ -n "$latest_branch" ]; then
curl https://get.docker.com | sh
sudo sh -eux <<EOF
# Install newuidmap & newgidmap binaries
apt-get install -y uidmap
EOF
./create-role.sh
ROLE_ARN = arn:aws:iam::<YOUR_ACCOUNT_ID>:role/ec2SchedulerRole
function install_docker {
echo 'installing Docker...'
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"