Skip to content

Instantly share code, notes, and snippets.

Adam Bartosik codesurf42

Block or report user

Report or block codesurf42

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 opt_onlyMap.scala
// case class Rel3(id: Int, vals: Option[Map[String, Set[Int]]])
val setm1 = Map(1 -> Some(Map("a" -> Set(1,2))))
val setm2 = Map(1 -> Some(Map("a" -> Set(2,3))))
val setm3 = Map(1 -> None)
val setm4 = Map(2 -> Some(Map("b" -> Set(5,6))))
val all = Set(setm1, setm2, setm3, setm4)
import scalaz._
import Scalaz._
View opt_caseClass.scala
case class Rel3(id: Int, vals: Option[Map[String, Set[Int]]])
val setm1 = Set(Rel3(1, Some(Map("a" -> Set(1,2)))))
val setm2 = Set(Rel3(1, Some(Map("a" -> Set(2,3)))))
val setm3 = Set(Rel3(1, None))
val setm4 = Set(Rel3(2, Some(Map("b" -> Set(5,6)))))
val all = (setm1 ++ setm2 ++ setm3 ++ setm4)
all.groupBy( =>
// Rel3(, Some(s.flatMap(_.vals).toList.reduce(_|+|_)))).values
Rel3(, Some(s.flatMap(_.vals).toList.reduce((h1, h2) => (h1 ++ h2).map{ case (k,v) => k -> (v ++ h1.getOrElse(k,Set())) })))).values
codesurf42 / play_filter_dump_body.scala
Last active Aug 29, 2015
Scala Play filter to dump body / everything
View play_filter_dump_body.scala
import play.api.Logger
import play.api.libs.iteratee.Iteratee
import play.api.mvc.{ Result, RequestHeader, Filter }
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import scala.concurrent.Future
object LoggingFilter extends Filter {
override def apply(nextFilter: (RequestHeader) => Future[Result])(rh: RequestHeader): Future[Result] = {
val startTime = System.currentTimeMillis()
View types_infer_ruby_foo+bar
>> foo = "aaa"
=> "aaa"
>> bar = 123
=> 123
>> foo + bar
TypeError: no implicit conversion of Fixnum into String
from (irb):3:in `+'
from (irb):3
from /home/ab/.rbenv/versions/2.0.0-p247/bin/irb:12:in `<main>'
You can’t perform that action at this time.