Skip to content

Instantly share code, notes, and snippets.

View thomasdarimont's full-sized avatar
🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
@bowbahdoe
bowbahdoe / Continuation.java
Created July 17, 2023 15:46
Continuation Proxy Classes
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
public final class Continuation {
final Object impl;
static final Class<?> IMPL_CLASS;
static final MethodHandle NEW;
static final MethodHandle YIELD;
@dasniko
dasniko / upgrade_keycloak_database_settings.md
Created May 10, 2023 05:06
Upgrade Keycloak Database #settings

Because of Arjuna timeout / closing the connection after 5 mins, setting following additional JAVA_OPTS might help:

-Dquarkus.transaction-manager.default-transaction-timeout=3600
-Dkeycloak.migration.batch-enabled=true
-Dkeycloak.migration.batch-size=1000
@GavinRay97
GavinRay97 / Makefile
Created December 8, 2022 21:21
A Makefile to compile a Maven/Gradle-style project layout using a custom JDK (for use w/ IE, Valhalla)
# Makefile to compile and run Java sources manually
# because JDK 20 Valhalla support is not yet available in IntelliJ IDEA
JAVA_VERSION = 20
JAVAC = /home/user/downloads/jdk-20-vahalla-20-75/bin/javac
JAVA = /home/user/downloads/jdk-20-vahalla-20-75/bin/java
JAVA_COMPILE_OPTIONS = --enable-preview --release $(JAVA_VERSION)
JAVA_OPTIONS = --enable-preview
JAVA_MAIN_CLASS = org.example.Database
@fsmv
fsmv / pass.go
Last active October 9, 2022 21:15
A runnable go script that creates an http basic auth password hash compatible with .htaccess (this is just the password part, you have to add username:<hash>)
/*?sr/bin/env go run "$0" "$@"; exit $? #*/
// This is actually not a shebang, the first line is both valid shell script and valid go code
// Just run: chmod +x pass.go; ./pass.go
package main
import (
"bufio"
"crypto/sha256"
"encoding/base64"
"fmt"
@xgp
xgp / Dockerfile
Last active October 23, 2023 10:28
Keycloak 17 example using JGroups JDBC_PING discovery protocol for Infinispan
FROM quay.io/keycloak/keycloak:17.0.0 as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=preview
ENV KC_DB=postgres
ENV KC_HTTP_RELATIVE_PATH=/auth
# specify the custom cache config file here
ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml
# copy the custom cache config file into the keycloak conf dir
@IwoHerka
IwoHerka / naming_guidelines.md
Last active April 1, 2024 15:39
Naming Guidelines

Naming guidelines

1. Syntax

1.1 Be consistent

Consistency in naming makes reading and memory retrieval much, much easier. Conversely, changing rules and mixing conventions are very confusing and significantly increase cognitive load. Follow language, company, and project conventions for names, even if you don't like them.

1.2 Follow conventions

  1. Generate the file:
$ awk 'BEGIN { for(c=0;c<10000000;c++) printf "<p>LOL</p>" }' > 100M.html
$ (for I in `seq 1 100`; do cat 100M.html; done) | pv | gzip -9 > 10G.boomgz
  1. Check it is indeed good:
var s="var s={0}{1}{0};Console.Write(s,(char)34,s);";Console.Write(s,(char)34,s);
# Referenced videos:
# - Argo CD - Applying GitOps Principles To Manage Production Environment In Kubernetes: https://youtu.be/vpWQeoaiRM4
# - kind - How to run local multi-node Kubernetes clusters: https://youtu.be/C0v5gJSWuSo
# - GitHub CLI - How to manage repositories more efficiently: https://youtu.be/BII6ZY2Rnlc
# - Argo Workflows and Pipelines - CI/CD, Machine Learning, and Other Kubernetes Workflows: https://youtu.be/UMaivwrAyTA
# - Running Jenkins In Kubernetes - Tutorial And Review: https://youtu.be/2Kc3fUJANAc
# - Github Actions Review And Tutorial: https://youtu.be/eZcAvTb0rbA
# - Tekton - Kubernetes Cloud-Native CI/CD Pipelines And Workflows: https://youtu.be/7mvrpxz_BfE
# - Environments Based On Pull Requests (PRs): Using Argo CD To Apply GitOps Principles On Previews: https://youtu.be/cpAaI8p4R60
# - How To Apply GitOps To Everything - Combining Argo CD And Crossplane: https://youtu.be/yrj4lmScKHQ
@b0bu
b0bu / haproxy_whitelists.md
Last active June 16, 2021 22:44
Whitelists in haproxy (the right way)

tldr; Don't just test a whitelist based on an initial pass/fail. An update to that whitelist or addition of a parameter to a use_backend statement alone can cause a routing mess.

I don't normally say things like "the right way" but in this case attention to detail is usually always the right way. We had two use_backend statements in haproxy shown below where when an IP address wasn’t in the whitelist it would be routed straight to production. The proposed fix for this meant that traffic in the whitelist would always be routed to production. Which is the opposite of what I believe was intended in both cases.

  use_backend b1 if host-site worldpay_callback worldpay_whitelist worldpay_env_dev worldpay_auth
  use_backend b2 if host-site worldpay_callback worldpay_whitelist worldpay_env_prd worldpay_auth

This works, you can put whitelist evaluation in a use_backend statement but if it's nested inside a larger scope and the logic falls through it's going to bite you. Troubleshooting this par