Skip to content

Instantly share code, notes, and snippets.

View domdorn's full-sized avatar

Dominik Dorn domdorn

View GitHub Profile
Interface Settings
{
"locale": "en-US"
}
Graphics Settings
{
"qualitySettings": [
{
"enabled": true,
"isAdaptive": true,
@domdorn
domdorn / sample.json
Created August 30, 2021 20:09
JQ flatten / flatMap nested structure
{
"correlationId": "83937bab-e23c-465f-9708-5c0a0030cc6e",
"items": [
{
"jobId": "7601ebfa-fb17-41ad-815e-a7b6339952df",
"status": "Waiting",
"variants": [
{
"variantId": 1,
"status": "Waiting",
@domdorn
domdorn / HMacSha256.scala
Created November 21, 2020 16:43
Create a HMac Sha256 hash from a given string
object HMAC {
def generateHMAC(sharedSecret: String, input: String): String = {
val secret = new SecretKeySpec(sharedSecret.getBytes, "HmacSHA256") //Crypto Funs : 'SHA256' , 'HmacSHA1'
val mac = Mac.getInstance("HmacSHA256")
mac.init(secret)
val hashString: Array[Byte] = mac.doFinal(input.getBytes)
// this makes sure that the string is 64chars long and gets padded with 0 if its shorter
String.format("%064x", new BigInteger(1, hashString))
}
@domdorn
domdorn / Animal.scala
Created September 18, 2020 12:54
Play Json Inheritance
import play.api.libs.json._
sealed trait Animal {
val `type`: String
}
case class Cat(name: String) extends Animal {
override val `type`: String = "cat"
}
@domdorn
domdorn / VavrToScalaConverters.scala
Created September 15, 2020 16:24
Vavr To Scala Converters
import cats.data.EitherT
import io.vavr.concurrent.{Future => VavrFuture}
import scala.concurrent.{ExecutionContext, Future, Promise}
object VavrToScalaConverters {
implicit class VavrFutureToScala[T](future: VavrFuture[T]) {
def asScala: Future[T] = {
@domdorn
domdorn / OpenAPIConfiguration.java
Created July 29, 2020 06:57
Spring + SpringDoc + Vavr-Collections
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.vavr.concurrent.Future;
import io.vavr.jackson.datatype.VavrModule;
import org.springdoc.core.converters.ConverterUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@domdorn
domdorn / OpenAPIConfiguration.java
Created May 25, 2020 22:42
Spring + SpringDoc + VAVR + Future + OpenAPI
package com.dominikdorn.sample.configuration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.vavr.concurrent.Future;
import org.springdoc.core.GroupedOpenApi;
import org.springdoc.core.converters.ConverterUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@domdorn
domdorn / ControllerNew.java
Last active June 14, 2022 07:52
spring boot / web: allow vavr javaslang future as return type
import io.micrometer.core.annotation.Timed;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.vavr.concurrent.Future;
import io.vavr.control.Option;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
@domdorn
domdorn / ahc-default.properties
Created March 9, 2017 14:46
Workaround for issue https://github.com/playframework/playframework/issues/7056 and https://github.com/playframework/play-ws/issues/87 . Copy the ahc-default.properties file into your conf/ folder
play.shaded.ahc.org.asynchttpclient.threadPoolName=AsyncHttpClient
play.shaded.ahc.org.asynchttpclient.maxConnections=-1
play.shaded.ahc.org.asynchttpclient.maxConnectionsPerHost=-1
play.shaded.ahc.org.asynchttpclient.connectTimeout=5000
play.shaded.ahc.org.asynchttpclient.pooledConnectionIdleTimeout=60000
play.shaded.ahc.org.asynchttpclient.connectionPoolCleanerPeriod=1000
play.shaded.ahc.org.asynchttpclient.readTimeout=60000
play.shaded.ahc.org.asynchttpclient.requestTimeout=60000
play.shaded.ahc.org.asynchttpclient.connectionTtl=-1
play.shaded.ahc.org.asynchttpclient.followRedirect=false
{
"ignition": { "version": "2.0.0" },
"storage": {
"disks": [
{
"device": "/dev/sda",
"wipeTable": false,
"partitions": [{
"label": "raid.1.1",
"number": 10,