Skip to content

Instantly share code, notes, and snippets.

View wongherlung's full-sized avatar

Delon Wong Her Laang wongherlung

View GitHub Profile
@wongherlung
wongherlung / rotate-access-key
Last active September 19, 2022 01:30
Bash script to rotate your IAM Access Keys
#!/bin/bash
set -eu
RED='\033[0;31m'
GREEN='\033[0;32m'
BOLD='\033[1m'
NC='\033[0m' # No Color
AWS_CREDENTIALS_FILE=~/.aws/credentials
@wongherlung
wongherlung / nric_generator.go
Last active December 12, 2017 07:23
Simple NRIC generator - Generate lines of fake NRIC
package main
import (
"bufio"
"flag"
"fmt"
"math/rand"
"os"
"strconv"
"time"
@wongherlung
wongherlung / orderedlist-sorter.py
Created October 25, 2017 15:02
Sorts a text file that uses ordered lists.
# This is a sorter to sort lines with a numbered list.
# e.g. of a unsorted ordered list
# 1.1 - Something
# 1.2.2 - Something
# 1.2.1 - Seomthing
import math
import sys
@wongherlung
wongherlung / check_expiring_password.py
Last active April 20, 2021 08:25
Python script to check for expiry accounts on Linux based OS
import subprocess
from datetime import datetime
BUFFER_DURATION = 30 # in days
def get_password_expiry_from_chage(account):
try:
chage = subprocess.Popen(('chage', '-l', account), stdout=subprocess.PIPE)
grep = subprocess.Popen(('grep', 'Password expires'), stdin=chage.stdout, stdout=subprocess.PIPE)
cut = subprocess.Popen('cut -d : -f2'.split(), stdin=grep.stdout, stdout=subprocess.PIPE)