Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bertrandmartel's full-sized avatar
💤
👀

Bertrand Martel bertrandmartel

💤
👀
View GitHub Profile
@bertrandmartel
bertrandmartel / keytool_java_import.sh
Created January 16, 2024 12:34
Extract certificates from a truststore and import them into an existing keystore (jre security cacerts)
#!/bin/bash
keystore=$JAVA_HOME/lib/security/cacerts
certs=$(keytool \
-list \
-keystore generic-truststore.jks \
-storepass "" | grep trustedCertEntry | grep -Eo "^[^,]*")
while read -r cert
@bertrandmartel
bertrandmartel / gitlab-ci.yml
Last active January 4, 2024 14:18
[gitlab-ci] increment package.json version from gitlab-ci + commit & push from a specific branch (after MR). SSH_PRIVATE_KEY variable must be defined as deploy key & CI variable
stages:
- versioning
versioning:
stage: versioning
image:
name: amazonlinux:latest
entrypoint: [""]
before_script:
- yum install -y jq git
@bertrandmartel
bertrandmartel / stsdecode.sh
Created May 30, 2023 13:15
Script used to decode sts encoded message
#!/bin/bash
if [ -z $1 ]; then
echo "encoded message required"
exit 1
fi
aws sts decode-authorization-message --encoded-message "$1" | jq -r '.DecodedMessage' | jq '.'
@bertrandmartel
bertrandmartel / delete_k8s_resources.sh
Created October 24, 2022 13:12
Script to delete all resources of a specific type, in a specific namespace in a kubernetes cluster
#!/bin/bash
usage() { echo "Usage: $0 [-n <string>] [-t <string>]" 1>&2; exit 1; }
while getopts ":n:t:" o; do
case "${o}" in
n)
namespace=${OPTARG}
;;
t)
@bertrandmartel
bertrandmartel / drain.sh
Created September 19, 2022 10:38
Delete all stuck pods from a list of pod in a file
#!/bin/bash
while IFS= read -r pod; do
echo $pod
namespace=$(kubectl get pods -o wide --all-namespaces -o custom-columns=":metadata.name, :metadata.namespace" | grep $pod | awk '{print $2}')
if [ -n "$namespace" ]; then
echo "deleting $pod on namespace $namespace"
kubectl delete pod $pod --grace-period=0 --force -n $namespace
else
echo "$pod was not found."
@bertrandmartel
bertrandmartel / github_action_dispatch_runid.py
Created October 8, 2021 18:31
Get the run_id associated to a dispatch in Github actions
import random
import string
import datetime
import requests
import time
# edit the following variables
owner = "YOUR_ORG"
repo = "YOUR_REPO"
workflow = "dispatch.yaml"
@bertrandmartel
bertrandmartel / mfa.sh
Created April 17, 2021 23:41
re-enable mfa device in aws
aws iam deactivate-mfa-device --user-name MFA_NAME --serial-number "arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME"
aws iam delete-virtual-mfa-device --serial-number arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME
aws iam create-virtual-mfa-device --virtual-mfa-device-name MFA_NAME --outfile mfa --bootstrap-method QRCodePNG
aws iam enable-mfa-device --user-name MFA_NAME --serial-number "arn:aws:iam::ACCOUNT_ID:mfa/MFA_NAME" --authentication-code1 "CODE1" --authentication-code2 "CODE2"
@bertrandmartel
bertrandmartel / cursor.py
Created March 31, 2021 17:55
Github Graphql API cursor decoding
import requests
import base64
token = "YOUR_TOKEN"
query = """
query {
search(type:ISSUE, query:"repo:mui-org/material-ui is:issue", first: 100){
nodes {
... on Issue {