Skip to content

Instantly share code, notes, and snippets.

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

Ulrich VACHON ulrich

🏠
Working from home
View GitHub Profile
@ulrich
ulrich / PatternMatching.java
Last active April 6, 2021 12:50
Pattern matching in Java 8+
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import static java.util.Optional.empty;
import static java.util.Optional.of;
public class PatternMatchingExample {
public static void main(String[] args) {
@ulrich
ulrich / gist:aa04a793d54703998ecb015a0e2ff803
Created June 23, 2022 14:27
Simple health check for Keycloak
For more explanation you can take a look on this article : https://dev.to/ulrich/simple-health-check-for-keycloak-259p
#!/bin/bash
login_access=$(curl -k -X POST \
-H "Content-Type:application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=admin-cli" \
-d "username=alive" \
-d "password=[REDACTED]" \
@ulrich
ulrich / QuickSort.java
Created December 2, 2022 15:54 — forked from djitz/QuickSort.java
Quick Sort Algorithm in Java
package com.djitz.sort;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* Quick sort algorithm (simple)
* based on pseudo code on Wikipedia "Quick Sort" aricle
*

Add Starship custom module to display Git user and signkey

If you want to print the git user/singkey for a local repository in the prompt:

Edit the ~/.config/starship.toml file.

[custom.gituser]
style = "bold fg:220"
detect_folders = ['.git']

Export Keycloak realms and users from H2 database

docker exec -it my_keycloak sh -c \
  "cp -rp /opt/keycloak/data/h2 /tmp ; \
  /opt/keycloak/bin/kc.sh export --dir /opt/keycloak/data/import --realm MY_REALM \
    --db dev-file \
    --db-url 'jdbc:h2:file:/tmp/h2/keycloakdb;NON_KEYWORDS=VALUE'"