Skip to content

Instantly share code, notes, and snippets.

View mvanholsteijn's full-sized avatar

Mark van Holsteijn mvanholsteijn

View GitHub Profile
@mvanholsteijn
mvanholsteijn / show-jwt
Created April 15, 2025 13:25
Show JWT token content
#!/bin/bash
# pad base64URL encoded to base64
paddit() {
input=$1
l=`echo -n $input | wc -c`
while [ `expr $l % 4` -ne 0 ]
do
input="${input}="
l=`echo -n $input | wc -c`
@mvanholsteijn
mvanholsteijn / filter-datadog-ips
Created November 30, 2024 19:31
remove datadog ip addresses from flow log records
#!/usr/bin/env python3
import json
import sys
import urllib3
from ipaddress import ip_network, IPv4Network, ip_address
http = urllib3.PoolManager()
AWSTemplateFormatVersion: 2010-09-09
Description: bucket
Resources:
Bucket:
Type: AWS::S3::Bucket
@mvanholsteijn
mvanholsteijn / bulk-update-gitlab-repositories
Created December 22, 2022 12:03
bulk update of gitlab repositories. search desired repositories, checkout, update and push to origin as merge request
#!/bin/bash
CHECKOUT_DIR=/tmp/checkout
COMMIT_MESSAGE=
BRANCH_NAME=
UPDATE_SCRIPT=
SEARCH=
GROUP_NAME=
PUSH=no
@mvanholsteijn
mvanholsteijn / rdp-to-ec2
Last active October 26, 2022 05:49
simple script to rdp into an EC2 Windows server
#!/bin/bash
#
# Copyright 2022 - Binx.io B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@mvanholsteijn
mvanholsteijn / push-to-image-registry.yaml
Last active July 7, 2022 18:12
generic Github Action workflow to create and publish a container image to ghcr.io
---
name: Create and publish a Docker image
"on":
push:
tags:
- '*'
branches:
- 'main'
@mvanholsteijn
mvanholsteijn / inspect-the-python-call-stack.py
Last active March 15, 2022 07:48
Inspects the Python call stack searching for a specific object type performing this call
import botocore
from typing import Optional
def get_boto_caller_client_meta() -> Optional[botocore.client.ClientMeta]:
"""
returns the ClientMeta of the boto calling boto client.
"""
for frame in map(lambda f: f.frame, inspect.stack()):
s = frame.f_locals.get('self')
if s and hasattr(s, "meta") and isinstance(s.meta, botocore.client.ClientMeta):
@mvanholsteijn
mvanholsteijn / gcp-least-privileged
Last active October 22, 2022 11:09
lists all Google IAM roles which contain the specified permission sorted by the number of permissions
#!/bin/bash
#
# NAME
# gcp-least-privileged - lists all Google IAM roles which contain the specified permission
#
# EXAMPLE
# gcp-least-privileged compute.disks.delete
#
main() {
local permission
@mvanholsteijn
mvanholsteijn / enable-private-ip-google-access
Created February 7, 2022 10:06
enable private ip google access on the default network
gcloud compute networks subnets list --network default --format 'value(region)' | \
sed -e 's^.*regions/^^' | \
xargs -P 8 -n 1 gcloud compute networks subnets update default --enable-private-ip-google-access --region
@mvanholsteijn
mvanholsteijn / test.js
Last active February 16, 2023 12:38
simple k6 performance test script for privatebin installations
import http from 'k6/http';
import {
sleep,
check
} from 'k6';
import {Trend} from 'k6/metrics';
import privatebin from 'k6/x/privatebin';
let createMetric = new Trend('01 - create-paste');
let getMetric = new Trend('02 - get-paste');