slides for a talk
This file contains 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
object Puzzles { | |
/** | |
* 8 queens | |
* https://en.wikipedia.org/wiki/Eight_queens_puzzle | |
* generalized to any N | |
*/ | |
object Queens { | |
/** |
This file contains 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
implicit val decodeResultMonad: Monad[DR] = new Monad[DR] { | |
override def flatMap[A, B](fa: DR[A])(f: A => DR[B]): DR[B] = fa.flatMap(f) | |
override def tailRecM[A, B](a: A)(f: A => DR[Either[A, B]]): DR[B] = f(a) match { | |
case DR.Value(Left(aa)) => tailRecM(aa)(f) | |
case DR.Value(Right(b)) => DR.Value(b) | |
case failedDecodeResult => | |
// scalastyle:off null | |
failedDecodeResult.map(_.getOrElse(null.asInstanceOf[B])) // stays DR.failure - map is not applied | |
// scalastyle:on null | |
} |
This file contains 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 com.hochgi | |
package object util { | |
sealed trait Value | |
case class Attribute(k: String, v: String) extends Value | |
case class Content(s: String) extends Value | |
case class Tree(label: String, values: List[Value], children: List[Tree]) |
This file contains 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 akka.stream.{Attributes, FlowShape, Inlet, Outlet} | |
import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler} | |
import com.typesafe.scalalogging.Logger | |
object StreamEventInspector { | |
def default[T](logger: Logger, context: String, printElem: T => String): StreamEventInspector[T] = { | |
val ctx = "[" + context + "] " | |
new StreamEventInspector[T]( | |
() => logger.info(ctx + "upstream completed"), | |
ex => logger.error(ctx + "upstream failure", ex), |
This file contains 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
from typing import Optional | |
class Tree: | |
def __init__(self, value: int, children: list): | |
self.value = value | |
self.children = children # list of Tree | |
def format_tree(t: Tree) -> str: | |
pass |
This file contains 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 scratch.example; | |
import java.util.List; | |
public class Tree { | |
int value; | |
List<Tree> children; | |
public Tree(int value, List<Tree> children) { |
This file contains 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 com.sparkbeyond.engine.util.logging.eventslogger | |
import java.nio.charset.StandardCharsets | |
import akka.Done | |
import ch.qos.logback.core.rolling.{ | |
FixedWindowRollingPolicy, | |
RollingFileAppender, | |
SizeBasedTriggeringPolicy | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder