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
//> using dep "org.typelevel::spire:0.18.0" | |
import spire.math._ | |
import spire.implicits._ | |
case class Distro[A](entries: Map[A, Rational]): | |
require(entries.values.qsum == Rational(1), s"Not normalized: $entries") | |
def apply(value: A): Rational = entries.getOrElse(value, Rational(0)) |
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 flattening | |
import scala.annotation.implicitNotFound | |
object Flattener { | |
def flatten[A]: PartiallyAppliedFlattener[A] = new PartiallyAppliedFlattener | |
final class PartiallyAppliedFlattener[A] { | |
def apply[B](value: B)(implicit ev: Flattenable[A, B]): List[A] = ev(value) | |
} |
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
{ | |
"file_version": "2.0", | |
"preferences": { | |
"custom_engines": { | |
"ggl": { | |
"name": "Google Search", | |
"url": "https://www.google.co.in/search?q={searchTerms}", | |
"category": "", | |
"description": "Google Search" | |
}, |
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
#!/bin/bash | |
CONNECT_URL=${1:-${CONNECT_URL:-http://localhost:8083}} | |
CONNECTOR_LIST=$(curl -s -L -X GET $CONNECT_URL/connectors | jq -r '.[]') | |
for CONNECTOR in $CONNECTOR_LIST; do | |
curl -s -L -X GET $CONNECT_URL/connectors/$CONNECTOR/status \ | |
| jq -r "(.tasks[] | [\"task\", \"$CONNECTOR\", .id, .state, .worker_id]), [\"connector\", \"$CONNECTOR\", .type, .connector.state, .connector.worker_id] | @csv" & | |
done | |
wait |
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
#!/bin/bash | |
set -e | |
MODULES=`find . -name '*.tf' -print0 | xargs -0 -n1 dirname | sort --unique | grep -v .terraform` | |
echo -n "fmt check" | |
for MODULE in $MODULES; do | |
(terraform fmt -check && echo -n ".") & | |
done | |
wait | |
echo " OK" |
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 mentoring | |
object CodingExercise { | |
final case class Pos(x: Int, y: Int) { | |
def +(other: Pos) = Pos(x + other.x, y + other.y) | |
} | |
object Pos { | |
val Origin = Pos(0, 0) | |
} |
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 ConnectedStreamsApp extends App { | |
def writer(outputStream: OutputStream): Unit = { | |
val writer = new PrintStream(outputStream) | |
(1 to 1000).foreach { i => | |
writer.println(s"line $i") | |
Thread.sleep(50) | |
} | |
writer.close() | |
} |
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 fp.typeclasses | |
import org.apache.commons.text.StringEscapeUtils | |
sealed abstract class Json | |
object Json { | |
type JField = (String, Json) | |
case object JNull extends Json { |
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 day22 | |
import scalaz._, Scalaz._ | |
object Day22 extends App { | |
sealed trait Equipment | |
object Equipment { | |
case object Climbing extends Equipment | |
case object Torch extends Equipment |
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 sandbox.futures | |
import scala.collection.generic.CanBuildFrom | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import scala.language.higherKinds | |
import scala.util.{Random, Success} | |
import scala.util.control.NoStackTrace | |
object FailFastTraverse { |
NewerOlder