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 / 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 / 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;
@thomasdarimont
thomasdarimont / readme.md
Last active July 6, 2023 12:33
Kind with local registry

Create locale registry

create-podman-registry.sh

#!/bin/sh
reg_name='kind-registry'
reg_port='5000'
running="$(podman inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
@thomasdarimont
thomasdarimont / readme.md
Created July 6, 2023 11:25
Keycloak Nightly with Podman
podman run -it \
  -p 8080:8080 \
  -p 8443:8443 \
  -p 8787:8787 \
  -e KEYCLOAK_ADMIN=admin \
  -e KEYCLOAK_ADMIN_PASSWORD=admin \
  -e DEBUG=true \
  -e DEBUG_PORT='0.0.0.0:8787' \
 quay.io/keycloak/keycloak:nightly \
@thomasdarimont
thomasdarimont / App.java
Last active June 14, 2023 21:59
Simple example for configuring Spring Security's RoleHierarchy via YAML in Spring Boot, compatible with Java 7
package demo;
import static java.util.Arrays.asList;
import static org.springframework.security.core.authority.AuthorityUtils.createAuthorityList;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@thomasdarimont
thomasdarimont / ProxyProblemExample.java
Last active May 28, 2023 20:43
Hack for allowing dedicated proxy settings to be used for URL with http and https protocol handling in JavaFXs Webkit based WebView. Tested with JDK8
package de.tutorials.training.fx.proxy;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import java.net.InetSocketAddress;
@thomasdarimont
thomasdarimont / MainMethodFinder.java
Last active May 23, 2023 21:22
Main Method finder to discovery main methods in JDK jars or jmods
package wb.java21;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
@thomasdarimont
thomasdarimont / dedup.sql
Created July 30, 2018 20:56
Deduplicate results with ARRAY_AGG(..) in BigQuery
#standardSQL
# take the one name associated with a SKU
WITH product_query AS (
SELECT
DISTINCT
v2ProductName,
productSKU
FROM `data-to-insights.ecommerce.all_sessions_raw`
WHERE v2ProductName IS NOT NULL
)
@thomasdarimont
thomasdarimont / CustomReferenceTokenEncoder.java
Last active May 3, 2023 19:48
PoC for encoding ReferenceTokens with expirationDate and signature
package demo;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;