Skip to content

Instantly share code, notes, and snippets.

View mvanholsteijn's full-sized avatar

Mark van Holsteijn mvanholsteijn

View GitHub Profile
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');
@mvanholsteijn
mvanholsteijn / locustfile.py
Created June 11, 2021 21:19
A simple locust performance test script to load test a privatebin installation
from locust import SequentialTaskSet, HttpUser, between, task
from locust.contrib.fasthttp import FastHttpUser
from pbincli.api import PrivateBin
from pbincli.format import Paste
class SequenceOfTasks(SequentialTaskSet):
def on_start(self):
self.payload = "hello world"
self.url = None
@mvanholsteijn
mvanholsteijn / privatebin.tf
Created May 24, 2021 13:08
A Cloud Run deployment of PrivateBin
variable "region" {
type = string
default = "europe-west4"
}
variable "project" {
type = string
}
variable "image" {