Transform a Seq of case class to a group by a key

case class Glicose(day : String, inputed :String)
val r = Seq(Glicose(“2017-02-02”, “22”), Glicose(“2017-02-03”, “44”), Glicose(“2017-02-03”, “76”))

Transform this r Seq to a Seq( date -> Seq(inputed1, inputed2), date2 -> Seq(inputed3)) { gl => Seq( -> r.filter( ==}
//res8: Seq[Seq[(String, Seq[String])]] = List(List((2017-02-02,List(22))), List((2017-02-03,List(44, 76))), List((2017-02-03,List(44, 76))))

Or a solution that groups the duplicates from @tpolecat

r.groupBy( { case (k, v) => k -> }


Java and Scala Dynamic Load of a Class

I was in the need to dynamically create a Object from the Database and execute a method to run a task. This object can be different based on the requirements from user input.

  * Handle Execution returned from database
  * @param ex
  * @param text
  * @param sender
def handleExecution(ex: Execution, text: String, sender: Sender): Unit = {

  if (ex.execution.split(":").size == 3 ) {
    val cname = ex.execution.split(":")(1)
    val fname = ex.execution.split(":")(2)

    try {
      val theclass = Class.forName(cname).newInstance().asInstanceOf[TExecutionService]

      if (theclass.isInstanceOf[TExecutionService]) {
        val output =
        Logger.debug("Output from " + cname + ".run " + text + " -- " + output)
        handleOutput(output, sender)
    } catch {
      case exception: Throwable => {
        Logger.debug("Error in HandleExecution " + ex + " with exception " + exception)
        throw exception


Although Scala is a Typed Language it was not difficult to assure that I would have a run method for the returned class and execute this code dynamically.


Scala Playframework connect to mysql

I’m writting this because I had issues following the documentation that comes with playframework
the docs are wrong or at least for me it gave me an error.

The docs states that to connect to a mysql database server you have to do the following:

If you need to connect to another JDBC-compliant database, first add the corresponding driver library to your application dependencies in build.sbt e.g.:

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.18"

This above works ok, I had no problems.

Then add the corresponding JDBC configuration to the conf/application.conf file:


This above now has problems namely the db.driver section it returned me an error
java.lang.ClassNotFoundException: org.mysql.Driver

Searching the internet I found this answer

So the correct working version is:



Maybe for others this is easy to spot but for me it wasn’t.

Java, Scala

Reading about scala I could only be curious about it, went to read details about the language and how it works. I get the idea that this is happening:

PHP is moving in the Java style direction… (Not trying to compare anything.)

Java is moving into a simpler coding Groovy, Scala ( in some cases harder) has Gosling him self professed. Both languages are being used in the financial markets( scala 1, scala 2, scala 3, Groovy ) for trading algorithms and social network Twitter , LinkedIn, it is said that Actors in Scala are a great way for Async communication Akka.Actors is said to be even better. Would like to have seen this two years ago, could have used this instead of Perl for a daemon I wrote. Both Scala and Groovy can use imported Java code.

James Gosling:

“I like Scala, but my big problem is that the type theory has gotten really complicated. The language lawyers are driving the bus. It’s turning into something that journeyman developers and even people like me… I started getting into the Scala stuff and my head starts to spin and I go, “what?””

Some Scala comments.

Gosling is listed as an advisor at the Scala company Typesafe Inc.[13] and Strategic Advisor for Eucalyptus.[14]

Clearly I’m more curious about Scala although Groovy has company’s supporting it but at the moment I’m just looking and playing not using. Scala Puzzlers