Skip to content

Instantly share code, notes, and snippets.

Erlend Hamnaberg hamnis

  • Arktekk
  • Norway
Block or report user

Report or block hamnis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:547c550a532be7e8235aa653725b2ba2
@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);
View Route.scala
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
View Routes.scala
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
View ArgoCirc.scala
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 {
View gist:a14e7d16c82df292833121b3f6088328
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 }
@hamnis
hamnis / Replsession.md
Last active Jan 10, 2017
Odd scala 2.12 problem
View Replsession.md

This code works in scala 2.11

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)
View ResultSetIterator.java
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 {
View Main.java
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;
@hamnis
hamnis / MergePatch.scala
Last active Jul 20, 2016
Implementation of rfc7396
View MergePatch.scala
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 {
View gist:d4dcac2345ff57415723
public static <A, B> B foldLeft(Stream<A> iterable, B identity, BiFunction<B, A, B> bf) {
return foldLeft(iterable.iterator(), identity, bf);
}
public static <A, B> B foldLeft(Iterable<A> iterable, B identity, BiFunction<B, A, B> bf) {
return foldLeft(iterable.iterator(), identity, bf);
}
public static <A, B> B foldLeft(Iterator<A> iterator, B identity, BiFunction<B, A, B> bf) {
B result = identity;
You can’t perform that action at this time.