Skip to content

Instantly share code, notes, and snippets.

@usrbinkat
usrbinkat / README.md
Created June 13, 2024 18:53
Delete Stuck Namespace

Delete Stuck Namespace

Here be dragons. Use with extreme caution.

About

This script is designed to accept namespaces as a list of arguments and will perform a namespace child resource delete loop before terminating the namespace and any finalizers.

Motivation

@AlexBaranowski
AlexBaranowski / centos-stream-8-vault-repos.sh
Last active March 28, 2025 17:14
Replace CentOS Stream 8 repos with CentOS Stream 8 VAULT repos
cat > /etc/yum.repos.d/CentOS-Stream-AppStream.repo << EOF
# CentOS-Stream-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client. You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.
@yorickdowne
yorickdowne / yawn.md
Last active January 30, 2025 10:30
Debian 12 bookworm upgrade

Debian 12

To start, read the official release notes.

If your install fits into "vanilla Debian plus maybe a handful of 3rd-party repos", then this guide for a simple upgrade to Debian 12 "bookworm" from Debian 11 "bullseye" can be helpful. 3rd-party repos are handled with a find command.

Note upgrade is only supported from Debian 11 to Debian 12. If you are on Debian 10, upgrade to Debian 11 first and make sure to change the security repo as per the release notes. Then once on Debian 11, you can upgrade to Debian 12.

  • Check free disk space
@sergsoares
sergsoares / Makefile
Created April 11, 2023 00:12
Makefile for select specific resource inside a main.tf
target:
SELECTED=`cat main.tf | grep resource | tr -d '"' | awk '{ print $$2 "." $$3 }' | fzf` ; \
terraform apply -target=$$SELECTED
@Ocramius
Ocramius / handling-optional-input-fields-with-type-safe-abstractions.md
Last active January 22, 2025 09:32
Handling optional input parameters in PHP with `vimeo/psalm` and `azjezz/psl`

Handling optional input parameters in PHP with vimeo/psalm and azjezz/psl

I had an interesting use-case with a customer for which I provide consulting services: they needed multiple fields to be marked as "optional".

Example: updating a user

We will take a CRUD-ish example, for the sake of simplicity.

For example, in the following scenario, does a null $description mean "remove the description",

using OpenTelemetry;
using OpenTelemetry.Logs;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var appResourceBuilder = ResourceBuilder.CreateDefault()
.AddService(serviceName: Telemetry.ServiceName, serviceVersion: Telemetry.ServiceVersion);
@yodermk
yodermk / centos8-9.sh
Created February 13, 2022 19:08
Commands to live-upgrade CentOS Streams 8 -> 9
# The general procedure here is adapted from the 7->8 guide here. https://www.tecmint.com/upgrade-centos-7-to-centos-8/
#
# It is a curated list of my bash history. I entered other commands so hopefully I got the right ones here.
yum upgrade
reboot
dnf install epel-release
dnf install rpmconf
dnf install yum-utils
rpmconf -a # answer "n" to both things
@thomasdarimont
thomasdarimont / app.py
Last active May 6, 2025 12:40
Example for a simple Python flask webapp that uses Authlib to act as an OpenID Connect client for Keycloak
import json
import os
import certifi
import requests
from authlib.oauth2.rfc6749 import OAuth2Token
from flask import Flask, url_for, session
from flask import render_template, redirect
from authlib.integrations.flask_client import OAuth, token_update
@degitgitagitya
degitgitagitya / .env
Last active April 28, 2025 06:34
Next JS + Next Auth + Keycloak + AutoRefreshToken
# KEYCLOAK BASE URL
KEYCLOAK_BASE_URL=
# KEYCLOAK CLIENT SECRET
KEYCLOAK_CLIENT_SECRET=
# KEYCLOAK CLIENT ID
KEYCLOAK_CLIENT_ID=
# BASE URL FOR NEXT AUTH
@frankdejonge
frankdejonge / paginated-generator.php
Created May 25, 2021 18:12
Generate use-case: paginated API call example
<?php
/**
* Imagine this is an API call
*/
function listPage(int $i): array
{
$next = $i >= 9 ? null : $i + 1;
return ['cursor' => $next, 'items' => array_fill(0, 5, $i)];
}