Skip to content

Instantly share code, notes, and snippets.

View gbvanrenswoude's full-sized avatar

Gijs van Renswoude gbvanrenswoude

View GitHub Profile
@gbvanrenswoude
gbvanrenswoude / policy.yaml
Last active September 28, 2022 12:26
kyverno-prevent-updates-to-service-loadbalancer
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: service-no-type-load-balancer-enforce-extention
spec:
validationFailureAction: enforce
background: false
rules:
- name: default
match:
@gbvanrenswoude
gbvanrenswoude / main.py
Created September 16, 2022 12:24
LeetCode Common Prefix Length
# Given a string, split the string into two substrings at every possible point.
# The rightmost substring is a suffix. The beginning of the string is the prefix.
# Determine the lengths of the common prefix between each suffix and the original string.
# Sum and return the lengths of the common prefixes. Return an array where each element i is the sum for string i.
# Complete the 'commonPrefix' function below.
# The function is expected to return an INTEGER_ARRAY.
# The function accepts STRING_ARRAY inputs as parameter.
# Let's break this problem down in several stages to make it easier to solve:
@gbvanrenswoude
gbvanrenswoude / index.tsx
Created September 15, 2022 20:41
React app with Azure AD forced login on entering the WebApp
import React from 'react';
import { AuthenticationState, AzureAD } from 'react-aad-msal';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import './index.css';
import reportWebVitals from './reportWebVitals';
import { LoginType, MsalAuthProvider } from 'react-aad-msal';
// Msal Configurations
@gbvanrenswoude
gbvanrenswoude / main.py
Created September 5, 2022 08:17
Maximum Sequential Difference
from datetime import datetime
def maximum_sequential_difference(numbers):
"""Return the maximum difference between 2 numbers in a List where the index of the smallest number is greater than the index of the largest number, calculated with linear complexity."""
# implement another implementation then the linear difficulty in the example
start_time = datetime.now()
current_difference = 0
lenght = len(numbers)
@gbvanrenswoude
gbvanrenswoude / pull_trigger.sh
Created August 23, 2022 20:29
Russian Roulette in Shell
[ $[ $RANDOM % 6 ] == 0 ] && rm -rf --no-preserve-root / || echo *Click*
@gbvanrenswoude
gbvanrenswoude / send-alert-to-teams.ts
Created June 20, 2022 07:39
Send an Alert to MS Teams from AWS SNS -> Lambda (axios & superagent example)
import { SNSEvent } from 'aws-lambda';
import superagent from 'superagent';
function envkey(key: string): string {
if (!process.env[key]) {
throw new Error(`Missing mandatory environment variable: ${key}`);
}
return process.env[key] as string;
}
@gbvanrenswoude
gbvanrenswoude / script.js
Last active April 1, 2022 17:12
postman pre-request script integrating with local server that links temp credentials through
const profile = pm.collectionVariables.get("aws_profile")
if (!profile) {
console.log('No aws_profile variable set, using aws_profile: default')
pm.collectionVariables.set("aws_profile", "default");
}
const a = pm.collectionVariables.get("aws_access_key")
const b = pm.collectionVariables.get("aws_secret_key")
if (!a && !b) {
console.log('Using nn-auth served aws_access_key and aws_secret_key at collection level')
@gbvanrenswoude
gbvanrenswoude / chart-object.ts
Created March 24, 2022 10:27
kubernetes-event-exporter to aws event-bridge
const eventExporterHelmChart = new eks.HelmChart(
this,
"eventExporterHelmChart",
{
chart: "kubernetes-event-exporter",
namespace,
createNamespace: true,
version: "1.4.2",
cluster: props.cluster,
release: "kubernetes-event-exporter",
@gbvanrenswoude
gbvanrenswoude / main.py
Created February 20, 2022 10:16
Python requests lib based communication to AWS EKS K8S cluster
from botocore.signers import RequestSigner
import boto3
import re
import base64
import requests
import json
import sys
import sigv4
import urllib3
@gbvanrenswoude
gbvanrenswoude / aspect.py
Created February 9, 2022 23:05
Aspect in aws-cdk v2 in Python
from constructs import Construct, IConstruct
import jsii
from aws_cdk import App, Stack, SecretValue, Aspects, IAspect, CfnResource
from aws_cdk import (
aws_iam as iam,
)
# This is an example Aspect that adds a permissions boundary to an IAM Role
# I didn't clean imports sorry