Skip to content

Instantly share code, notes, and snippets.

Avatar

Dominik Dorn domdorn

View GitHub Profile
@domdorn
domdorn / Animal.scala
Created Sep 18, 2020
Play Json Inheritance
View Animal.scala
import play.api.libs.json._
sealed trait Animal {
val `type`: String
}
case class Cat(name: String) extends Animal {
override val `type`: String = "cat"
}
View VavrToScalaConverters.scala
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 Jul 29, 2020
Spring + SpringDoc + Vavr-Collections
View OpenAPIConfiguration.java
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
Spring + SpringDoc + VAVR + Future + OpenAPI
View OpenAPIConfiguration.java
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 May 25, 2020
spring boot / web: allow vavr javaslang future as return type
View ControllerNew.java
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 / Filters.scala
Last active Feb 14, 2020
PlayFramework 2.5: Global CSRF Protection – Disable CSRF selectively
View Filters.scala
package framework
import javax.inject.Inject
import play.api.http.HttpFilters
import play.filters.csrf.RouteCommentExcludingCSRFFilterFacade
import play.filters.gzip.GzipFilter
class Filters @Inject()(
routeCommentExcludingCSRFFilterFacade: RouteCommentExcludingCSRFFilterFacade,
@domdorn
domdorn / SGBeanPersistController.java
Created Jan 1, 2012
JPA2 EntityListener Annotations for EBean
View SGBeanPersistController.java
package models.sgcore;
import com.avaje.ebean.event.BeanPersistAdapter;
import com.avaje.ebean.event.BeanPersistRequest;
import javax.annotation.PreDestroy;
import javax.persistence.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
View ahc-default.properties
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
View raidconfig.ignition
{
"ignition": { "version": "2.0.0" },
"storage": {
"disks": [
{
"device": "/dev/sda",
"wipeTable": false,
"partitions": [{
"label": "raid.1.1",
"number": 10,
@domdorn
domdorn / playframework
Created Oct 15, 2011
Upstart Script for the PlayFramework 1.x
View playframework
# Upstart script for a play application that binds to an unprivileged user.
# put this into a file like /etc/init/playframework
# you can then start/stop it using either initctl or start/stop/restart
# e.g.
# start playframework
# http://dominikdorn.com
description "Description of your app"
author "Dominik Dorn <dominik@studyguru.eu>"
version "1.0"
You can’t perform that action at this time.