Skip to content

Instantly share code, notes, and snippets.

View hajowieland's full-sized avatar

Hans-Jörg Wieland hajowieland

View GitHub Profile
@philfreo
philfreo / README.md
Created February 3, 2020 21:08
Lambda@Edge function for setting HSTS header for Cloudfront+S3 sites

Set this up as an "Origin Response" Cloudfront Trigger.

@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active May 20, 2025 11:55
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@seanmavley
seanmavley / sensible basic form.validation.react.tsx
Last active October 30, 2023 16:23
Material UI Form with React Hook Form with Validation using Yup
import React from "react";
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import { Button } from '@material-ui/core';
import { useForm } from 'react-hook-form';
import * as yup from 'yup';
@Zibri
Zibri / gitclean.sh
Last active July 17, 2025 00:30
Bash script to remove all revisions from github or gist repository.
#!/bin/bash
#
# By Zibri (2019)
#
# Usage: gitclean username password giturl
#
gitclean ()
{
odir=$PWD;
if [ "$#" -ne 3 ]; then

How to setup a practically free CDN using Backblaze B2 and Cloudflare

⚠️ Note 2023-01-21
Some things have changed since I originally wrote this in 2016. I have updated a few minor details, and the advice is still broadly the same, but there are some new Cloudflare features you can (and should) take advantage of. In particular, pay attention to Trevor Stevens' comment here from 22 January 2022, and Matt Stenson's useful caching advice. In addition, Backblaze, with whom Cloudflare are a Bandwidth Alliance partner, have published their own guide detailing how to use Cloudflare's Web Workers to cache content from B2 private buckets. That is worth reading,

@garethr
garethr / kubernetes.rego
Last active June 23, 2025 13:04
Collecting together Kubernetes rego examples, including porting the https://kubesec.io rules to rego
package kubernetes
name = input.metadata.name
kind = input.kind
is_service {
kind = "Service"
}
@jparrill
jparrill / Prow_hands_on.md
Last active February 5, 2025 10:12
How to install and Play with CI/CD Prow from Kubernetes test-infra project.

Prow and Quickstart

Prow is a Kubernetes based CI/CD system. Jobs can be triggered by various types of events and report their status to many different services. In addition to job execution, Prow provides GitHub automation in the form of policy enforcement, chat-ops via /foo style commands, and automatic PR merging.

NOTE|WARNING: In order to make Prow work fine with your repo, the Kubernetes cluster MUST be reachable by GitHub Webhook.

Articles to read and understand

@kekru
kekru / 01nginx-tls-sni.md
Last active June 2, 2025 07:15
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@rafaeljesus
rafaeljesus / monzo-alertmanager-receiver.yaml
Created March 7, 2019 23:18 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
receivers:
###################################################
## Slack Receivers
- name: slack-code-owners
slack_configs:
- channel: '#{{- template "slack.monzo.code_owner_channel" . -}}'
send_resolved: true
title: '{{ template "slack.monzo.title" . }}'
icon_emoji: '{{ template "slack.monzo.icon_emoji" . }}'
color: '{{ template "slack.monzo.color" . }}'
@trondhindenes
trondhindenes / .gitlab-ci.yml
Last active May 16, 2025 11:48
Run KinD (Kubernetes in Docker) as part of Gitlab CI job
#Spin up Kubernetes control plane as part of before_script, and destroys it using after_script
#Some custom logic to get to the right ip address
#Requres the gitlab docker runner, with "pass-thru" to the host docker socket.
stages:
- test
image: python:3.6.6 #the docker image you run in needs Docker installed, and access to the host docker socket.
test_integration_k8s:
tags: