Skip to content

Instantly share code, notes, and snippets.

Manuel Bernhardt manuelbernhardt

Block or report user

Report or block manuelbernhardt

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:2940c5d35c0d3e63806c
trait Command
trait Event
case class A(....) extends Command
case class B(....) extends Command
case class C(....) extends Command
case class D(....) extends Command
case class AA(...) extends Event
case class BB(...) extends Event
manuelbernhardt / gist:09cbfa52e466d0cd7ae1
Created May 7, 2015
jOOQ integration in a `build.sbt` file
View gist:09cbfa52e466d0cd7ae1
libraryDependencies ++= Seq(
"org.jooq" % "jooq" % "3.6.0",
"org.jooq" % "jooq-codegen-maven" % "3.6.0",
"org.jooq" % "jooq-meta" % "3.6.0"
val generateJOOQ = taskKey[Seq[File]]("Generate JooQ classes")
val generateJOOQTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (src, cp, r, s) =>
toError("org.jooq.util.GenerationTool", cp.files, Array("conf/authentication.xml"), s.log))
manuelbernhardt / CQRSEventHandler.scala
Created Jun 2, 2015
CQRS & jOOQ example in Scala
View CQRSEventHandler.scala
package actors
import java.sql.Timestamp
import{Actor, ActorLogging}
import helpers.Database
import generated.Tables._
import org.jooq.impl.DSL._
class CQRSEventHandler extends Actor with ActorLogging {
View gist:531261f954afc4342536
diff --git a/jOOQ/src/main/java/org/jooq/impl/ b/jOOQ/src/main/java/org/jooq/impl/
index 5231af3..fd19cce 100644
--- a/jOOQ/src/main/java/org/jooq/impl/
+++ b/jOOQ/src/main/java/org/jooq/impl/
@@ -720,6 +717,15 @@ public class DefaultDataType<T> implements DataType<T> {
if (dialect != null) {
result = TYPES_BY_TYPE[].get(type);
+ // check if we know about interfaces implemented by the type
View CHJson.scala
object CHJson extends com.codahale.jerkson.Json {
// this is where we setup out Jackson module for custom de/serialization
val module: SimpleModule = new SimpleModule("delving", Version.unknownVersion())
module.addSerializer(classOf[ObjectId], new ObjectIdSerializer)
module.addDeserializer(classOf[ObjectId], new ObjectIdDeserializer)
manuelbernhardt / gist:1249014
Created Sep 28, 2011
ObjectId de/serializer for Jerkson
View gist:1249014
class ObjectIdSerializer extends JsonSerializer[ObjectId] {
def serialize(id: ObjectId, json: JsonGenerator, provider: SerializerProvider) {
class ObjectIdDeserializer extends JsonDeserializer[ObjectId] {
def deserialize(jp: JsonParser, context: DeserializationContext) = {
if (!ObjectId.isValid(jp.getText)) throw context.mappingException("invalid ObjectId " + jp.getText)
View MongoCacheImpl.scala
package util
import play.cache.CacheImpl
import models.salatContext._
import scala.collection.JavaConversions.asJavaMap
import com.mongodb.casbah.Imports._
import com.mongodb.WriteResult
import{Every, Job}
import controllers.ErrorReporter
View constraints.scala
val fieldConstraints = => m.key -> m.constraints)
manuelbernhardt / gist:1868295
Created Feb 20, 2012
Session composition for action composition
View gist:1868295
val newSession = additionalSessionParams.foldLeft[Session](request.session) { _ + _ }
val r: PlainResult = action(request).asInstanceOf[PlainResult]
// workaround since withSession calls aren't composable it seems
val innerSession = r.header.headers.get(SET_COOKIE).map(cookies => Session.decodeFromCookie(Cookies.decode(cookies).find( == Session.COOKIE_NAME)))
if(innerSession.isDefined) {
// there really should be an API method for adding sessions
val combined = { _ + _ }
} else {
View gist:2694058
2012-05-14 15:41:08
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.6-b01-415 mixed mode):
"New I/O server worker #1-9" prio=5 tid=7fdc4308c000 nid=0x116fb9000 runnable [116fb8000]
java.lang.Thread.State: RUNNABLE
at Method)
- locked <79507ad18> (a$2)
You can’t perform that action at this time.