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
@thomasdarimont
thomasdarimont / LocalOnceDemo.java
Created September 23, 2021 09:36
Go's sync.Once with Java 17
package wb.java17;
import java.util.function.Supplier;
public class LocalOnceDemo {
public static void main(String[] args) {
System.out.println(answer());
System.out.println(answer());
}
@thomasdarimont
thomasdarimont / Dockerfile
Created April 8, 2022 10:58
Keycloak.X JGroups JDBC Ping
FROM quay.io/keycloak/keycloak:17.0.1 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
@thomasdarimont
thomasdarimont / ExampleResource.java
Last active September 26, 2023 07:09
Example to reproduce RESTEASY-3384 with resteasy-reactive
package com.example;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@Path("/hello")
public class ExampleResource {
@POST
public String greet() {
@thomasdarimont
thomasdarimont / minispa.html
Created September 20, 2023 10:23
Example SPA for Keycloak Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Acme Mini SPA</title>
<style>
body {
background-color: #eaeaea;
@thomasdarimont
thomasdarimont / App.java
Created January 5, 2017 17:00
Simple AuthN & AuthZ example with Spring Boot / Security / Session
package demo;
import java.io.Serializable;
import java.security.Principal;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@thomasdarimont
thomasdarimont / MainMethodFinder.java
Last active September 8, 2023 22:28
Small tool to find classes with executable main methods in a given JDK.
import jdk.internal.org.objectweb.asm.*;
import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Consumer;
/**
@thomasdarimont
thomasdarimont / logit.sh
Created February 22, 2017 10:29
Simple bash script to demo logging to graylog via Gelf / UDP with netcat
#!/usr/bin/env bash
script_execution_id=$(uuidgen)
log_gelf(){
msg=$1
nc -w 1 -u logserver.tdlabs.local 12205 <<EOF
{
"version":"1.1"
@thomasdarimont
thomasdarimont / Continuation.java
Last active July 20, 2023 00:06
Java21 Continuations Demo
package demo.cont;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.function.Consumer;
public final class Continuation {
private final Object delegate;
@thomasdarimont
thomasdarimont / readme.md
Created August 29, 2019 19:57
Keycloak get client by clientId
KC_CLIENT_ID=admin-cli
KC_SERVER=http://localhost:8080/auth

KC_REALM=master
KC_ISSUER=$KC_SERVER/realms/$KC_REALM
KC_USERNAME=admin
KC_PASSWORD=admin

# Fetch ACCESS_TOKEN
@thomasdarimont
thomasdarimont / App.java
Last active July 10, 2023 12:19
How to use custom SpEL functions in @value with Spring Boot
package demo;
import static java.lang.reflect.Modifier.*;
import java.util.Arrays;
import java.util.Set;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanExpressionResolver;