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
ThisBuild / version := "0.1.0-SNAPSHOT" | |
ThisBuild / scalaVersion := "2.13.14" | |
lazy val root = (project in file(".")) | |
.settings( | |
name := "tools", | |
libraryDependencies += "org.scala-lang" %% "toolkit" % "0.5.0", | |
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "5.1.2", | |
// fs2: functional streams for Scala |
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 sbt._ | |
object Dependencies { | |
object Versions { | |
val cats = "2.1.1" | |
val catsEffect = "2.1.2" | |
val catsMeowMtl = "0.4.0" | |
val catsRetry = "1.1.0" | |
val circe = "0.13.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
while true; do date; sleep 5; done |
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 cats.{ ApplicativeError, MonadError } | |
import cats.data.{ Kleisli, OptionT } | |
import cats.effect.Sync | |
import cats.effect.concurrent.Ref | |
import cats.syntax.all._ | |
import io.circe.generic.auto._ | |
import io.circe.syntax._ | |
import org.http4s._ | |
import org.http4s.circe.CirceEntityDecoder._ | |
import org.http4s.circe._ |
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
// in buid.sbt """routesImport ++= Seq("com.nachinius.controllers.Binders._" """ | |
package com.nachinius.controllers | |
object Binders { | |
implicit def BigDecimalQueryStringBindable = new QueryStringBindable[BigDecimal] { | |
override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, BigDecimal]] = { | |
params.get(key).flatMap(_.headOption).map { value => | |
Try { BigDecimal(value) } match { | |
case Success(value) => Right(value) | |
case Failure(exception) => Left(exception.getMessage) |
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
#!/usr/bin/env amm | |
import $ivy.`org.apache.hadoop:hadoop-common:3.2.0`, org.apache.commons.codec.binary.Base32 | |
// HexBytesUtil from https://gist.githubusercontent.com/tmyymmt/3721117/raw/70af27f30df0ec0084e37e7fe3ff0a547bf8020b/HexBytesUtil.scala | |
object HexBytesUtil { | |
def hex2bytes(hex: String): Array[Byte] = { | |
if(hex.contains(" ")){ | |
hex.split(" ").map(Integer.parseInt(_, 16).toByte) | |
} else if(hex.contains("-")){ |
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 reactive programms edx course | |
// Utilities to temporarily have unimplemented parts of the program | |
private def unimplementedFlow[A, B, C]: Flow[A, B, C] = | |
Flow.fromFunction[A, B](_ => ???).mapMaterializedValue(_ => ??? : C) | |
private def unimplementedSink[A, B]: Sink[A, B] = Sink.ignore.mapMaterializedValue(_ => ??? : B) |
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
type A[E,T] = (E, Try[T]) | |
def seqOfFuturesRecovered[T, E](elems: Seq[E])(func: E => Future[T])(implicit executionContext: ExecutionContext): Future[Seq[A[E,T]]] = { | |
elems.foldLeft(Future(Seq.empty[A[E, T]])) { (acc, elem) => | |
acc.flatMap { prevSeq: Seq[(E, Try[T])] => | |
FutureOps(func(elem)).futureToTry.map( (elem, _)).map { prevSeq :+ _} | |
} | |
} | |
} |
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 java.util.concurrent.TimeoutException | |
import java.util.{Timer, TimerTask} | |
import play.api.Logger | |
import scala.collection.generic.CanBuildFrom | |
import scala.concurrent.duration.FiniteDuration | |
import scala.concurrent.{ExecutionContext, Future, Promise} | |
import scala.util.{Failure, Random, Success} | |
object FutureUtils { |
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
pragma solidity 0.5.2; | |
contract Contract_C { | |
address payable [5] public target = [address(0), address(0),address(0),address(0),address(0)]; | |
uint8 public max = 5; | |
uint public amountToPaid = 1; | |
event Sent(address destination, uint amount); | |
NewerOlder