Scratches

Blinded by Science!

Python Loop over List and swap elements

To get a list of all listening TCP ports with lsof type: sudo lsof -nP -iTCP -sTCP:LISTEN Copy The options used are as follows: -n - Do not convert port numbers to port names. -p - Do not resolv...

Git Rebase to Squash Commits

you can squash multiple commits on a local branch into a single commit using the git rebase command with the -i or –interactive option. Steps: First, make sure that you’re on the branch that you w...

AWS SystemsManager CLI Examples

Ubuntu install only security updates apt-get install -y --only-upgrade $( apt-get --just-print upgrade | awk 'tolower($4) ~ /.*security.*/ || tolower($5) ~ /.*security.*/ {print $2}' | sort | uniq...

AWS SystemsManager CLI Examples

Loop over many users with paginate self.iam_client = self.session.client("iam") paginator = self.iam_client.get_paginator('list_users') for page in paginator.paginate(): for us...

Python Loop over List and swap elements

Terraform module aws_lb_listener_rule oidc the module accepts a variable called lb_listener_rules which is a list of objects containing the rule name, type, and endpoint. The aws_lb_listener_rule ...

Jenkinsfile using AWS assumed-role

Jenkinsfile using AWS assumed role to deploy a docker container stage('Deploy - Prod') { when { branch 'main' } steps { git(url: 'https:/...

Python Loop over List and swap elements

Swap elements in a list of any size assign length variable with the current list’s length for convenience for loop runs through body length // 2 times, to leave middle element of odd lists unt...

Python Bubble Sort

Bubble Sort a List of Numbers Check adjacent elements and swap them if right element < left element my_list = [8, 10, 6, 2, 4] # list to sort swapped = True # flag variable to mark when to ...

AWS SystemsManager CLI Examples

Run yum update against specific Patch Group Tag PATCH_GROUP=development aws ssm send-command --document-name "eXp-YumUpdateSecurityOnly" --document-version "1" --targets '[{"Key":"tag:Patch Group"...

AWS CodeBuild Sample buildspec.yaml

CodeBuild buildspec.yaml example version: 0.2 phases: pre_build: commands: - echo Logging in to Amazon ECR... - aws --version # - REPOSITORY_URI=<>ACCOUNT-ID>.dkr....