Skip to content

Instantly share code, notes, and snippets.

View dwickstrom's full-sized avatar
🐎

David Wickström dwickstrom

🐎
View GitHub Profile
@dwickstrom
dwickstrom / keycloak-get-idp-token.md
Created January 3, 2024 13:19
Keycloak - Get IDP Token using curl

Keycloak - Get IDP Token

Get Access Token

export TKN=$(curl -X POST 'http://127.0.0.1:8080/realms/your-realm/protocol/openid-connect/token' \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "username=your-user" \
 -d 'password=your-pass' \
 -d 'grant_type=password' \
@dwickstrom
dwickstrom / gist:e44ef97582e04d6a408a94c96fcfec3c
Last active January 4, 2024 20:09
Keycloak ECS logging format

Keycloak console log ECS format

Oh well, not sure how this is gonna play out, but giving it a try.

KC_LOG_CONSOLE_FORMAT: "{\"@timestamp\":\"%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}\",\"log.level\":\"%p\",\"log.logger\":\"%c{3.}\",\"process.thread.name\":\"%t\",\"message\":\"%s%e\"}%n"
@dwickstrom
dwickstrom / Either.java
Last active March 23, 2020 07:25
Scott encoded Either
package se.foo.bar;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
interface Either<L, R> {
<T> T either(Function<L, T> left, Function<R, T> right);
@dwickstrom
dwickstrom / Contravariant.java
Last active March 15, 2020 16:19
Contravariant Predicate Functor
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Scratch {
public static void main(String[] args) {
System.out.println(getCertainThings());
alias resp='echo -e "\033]50;SetProfile=Default\a"'
class Movie {
enum Type {
REGULAR(PriceService::getRegularPrice),
NEW_RELEASE(PriceService::getNewReleasePrice),
CHILDREN(PriceService::getChildrensPrice);
public final BiFunction<PriceService, Integer, Double> priceAlgo;
private Type(BiFunction<PriceService, Integer, Double> priceService) {
@dwickstrom
dwickstrom / logger.py
Created October 21, 2018 09:28
Python logging setup
import sys
import logging
from .config import LOG_LEVEL
def setup_logging():
@dwickstrom
dwickstrom / combinators.js
Last active June 13, 2018 12:13 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
const isThenable = val =>
val
&& typeof val === 'object'
&& typeof val.then === 'function'
const map = fn => arg =>
isThenable(arg) ? arg.then(fn)
: Array.isArray(arg) ? arg.map(fn)
: /* else */ ? fn(arg)
@dwickstrom
dwickstrom / tern.js
Last active January 1, 2018 12:03
ternary conditional formatting
const foo = a =>
a === 1 ? 'one'
: a === 2 ? 'two'
: a === 3 ? 'three'
: /* else */ 'more'
const hello = foo => bar =>
foo < bar ? foo * 2
: foo > bar ? bar * 2