import scalaz._
type Id[+A] = A
implicit val monadInstance: Monad[Id] = new Monad[Id] {
override def point[A](a: => A): Id[A] = a
override def bind[A, B](fa: Id[A])(f: (A) => Id[B]): Id[B] = f(fa)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xmldecoder | |
import scala.util.Try | |
import scala.xml.{Node, NodeSeq} | |
case class XMLDecodeException(path: String, message: String) extends Exception { | |
override def getMessage: String = s"[$path] - $message" | |
} | |
trait Decoder[A] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void authenticationFinished(AuthenticationSessionModel authSession, BrokeredIdentityContext context) { | |
String prompt = authSession.getClientNote(OIDCLoginProtocol.PROMPT_PARAM); | |
if (OIDCLoginProtocol.PROMPT_VALUE_LOGIN.equals(prompt)) { | |
UserSessionModel usm = session.sessions().getUserSessionByBrokerSessionId(authSession.getRealm(), context.getBrokerSessionId()); | |
if (!AuthenticationManager.isSessionValid(authSession.getRealm(), usm)) { | |
logger.debugf("User session '%s' is not valid, maybe creating a new one", context.getBrokerSessionId()); | |
EventBuilder event = new EventBuilder(authSession.getRealm(), session, session.getContext().getConnection()); | |
event.event(EventType.IDENTITY_PROVIDER_LOGIN); | |
ClientSessionContext ctx = AuthenticationProcessor.attachSession(authSession, usm, session, authSession.getRealm(), session.getContext().getConnection(), event); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package no.scalabin.http4s.directives | |
package routes | |
import cats.Monad | |
import linx._ | |
import Route.{MethodPartial, ResponseDirective} | |
import org.http4s.{Method, Response, Status} | |
import scala.language.higherKinds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package no.scalabin.http4s.directives | |
package routes | |
import cats.Monad | |
import linx._ | |
import Route.{MethodPartial, ResponseDirective} | |
import org.http4s.{Method, Response, Status} | |
import scala.language.higherKinds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example | |
import io.circe.{DecodingFailure, JsonNumber, Decoder => CD, Json => CJ} | |
import argonaut.{Json => AJ} | |
object ArgoCirc extends App { | |
case class Person(name: String, age: Int) | |
object Person { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ValueDirective[F[+_], A] = Directive[F, Response[F], A] | |
type ResponseDirective[F[+_]] = ValueDirective[F, Response[F]] | |
def directiveFor[F[+_]](resish: F[Response[F]])(implicit d: Directives[F]): ResponseDirective[F] = { | |
import d._ | |
import ops._ | |
for { | |
_ <- Method.GET | |
res <- successF(resish) | |
} yield { res } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sqldsl; | |
import java.sql.ResultSet; | |
import java.util.Iterator; | |
import java.util.function.Function; | |
public class ResultSetIterator implements Iterator<ResultSetRow> { | |
@SuppressWarnings("unchecked") | |
static <T extends Throwable> T sneakyRethrow(Throwable t) throws T { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.hamnaberg.json.examples; | |
import javaslang.collection.List; | |
import javaslang.control.Option; | |
import net.hamnaberg.json.Codecs; | |
import net.hamnaberg.json.DecodeResult; | |
import net.hamnaberg.json.Json; | |
import net.hamnaberg.json.JsonCodec; | |
import net.hamnaberg.json.io.JacksonStreamingParser; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argonaut._, Argonaut._ | |
object MergePatch { | |
def mergePatch(json: Json, patch: Json): Json = { | |
val target = json.objectOrEmpty.toMap | |
if (patch.isObject) { | |
patch.objectOrEmpty.toList.foldLeft(target) { case (map, (k, v)) => | |
if (map.isDefinedAt(k)) { | |
if (v.isNull) map - k else map + (k -> mergePatch(map(k), v)) | |
} else { |