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 static java.lang.System.*; | |
import java.util.function.BiFunction; | |
import java.util.function.Function; | |
// Implementation of a pseudo-GADT in Java, translating the examples from | |
// http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf | |
// The technique presented below is, in fact, just an encoding of a normal Algebraic Data Type | |
// using a variation of the visitor pattern + the application of the Yoneda lemma to make it | |
// isomorphic to the targeted 'GADT'. |
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 com.typesafe.config.Config | |
implicit class ImplicitConfigHelper(val c: Option[Config]) extends AnyVal { | |
import scala.reflect.ClassTag | |
import scala.util.control.NonFatal | |
import ImplicitConfigHelper._ | |
implicit def valueOf[T : ClassTag](prop: String)(implicit ev: ClassTag[T]) : T = | |
ev.runtimeClass match { // you need stable identifiers here | |
case String_ => c.get.getString(prop).asInstanceOf[T] | |
case Int_ => c.get.getInt(prop).asInstanceOf[T] |
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
// SimpleCounter demo | |
// A simple distributed counter example | |
// | |
// On startup, blinks are dim BLUE which shows they are in IDLE mode waiting for a master | |
// | |
// Button press a blink to make it master of the cluster. The master will show the current count | |
// using the 0-342 display format decribed below under showNumber()... | |
// | |
// While a blink is actively part of a counting cluster, it will show dim GREEN on the face | |
// that points to its parent. All parent faces eventually lead back to the master. |
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
fun RepositoryHandler.enableMirror() { | |
all { | |
if (this is MavenArtifactRepository) { | |
val originalUrl = this.url.toString().removeSuffix("/") | |
urlMappings[originalUrl]?.let { | |
logger.lifecycle("Repository[$url] is mirrored to $it") | |
this.setUrl(it) | |
} | |
} | |
} |