Skip to content

Instantly share code, notes, and snippets.

View dwickstrom's full-sized avatar
🐎

David Wickström dwickstrom

🐎
View GitHub Profile
@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 / 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 / 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 / nightmare.sh
Last active December 22, 2018 01:27
NightmareJS - install Electron on Ubuntu 14.04
apt-get -y update
apt-get -y upgrade
apt-get -y --force-yes install make unzip g++ libssl-dev git xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps clang libdbus-1-dev libgtk2.0-dev libnotify-dev libgnome-keyring-dev libgconf2-dev libasound2-dev libcap-dev libcups2-dev libxtst-dev libxss1 libnss3-dev gcc-multilib g++-multilib
npm -f init
npm i -S nightmare
xvfb-run nodejs index.js
@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)));
@dwickstrom
dwickstrom / $.js
Last active May 19, 2018 18:43
Little DOM query thing
export const $ = (selector, scope=document) =>
Array
.of(scope.querySelector(selector))
.filter(x => x)
export const $$ = (selector, scope=document) =>
Array.from(scope.querySelectorAll(selector))