Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Asymmetric Finance
  • /dev/null
View GitHub Profile
@malzzz
malzzz / CallbackExecutionContext.scala
Created October 31, 2017 14:22 — forked from viktorklang/CallbackExecutionContext.scala
Creates an ExecutionContext inside an Actor that will execute the runnables inside the Actor receive block, so that the risk of closing over Actor internals is less problematic.
//Warning: Uses Akka internal APIs (not binary compatible),
//can be written not to depend on that but implemented like this for brevity.
package akka.util
trait CallbackExecutionContext { this: akka.actor.Actor
// Defines our signal for callback execution
case object Execute
// ``SerializedSuspendableExecutionContext`` is Akka-internal
private[this] final val ssec: SerializedSuspendableExecutionContext = {
@malzzz
malzzz / Future-retry.scala
Created October 31, 2017 14:20 — forked from viktorklang/Future-retry.scala
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@malzzz
malzzz / gist:15639fc36d069490b7709be2f3a4d522
Last active March 27, 2023 16:21 — forked from Frozenfire92/gist:3627e38dc47ca581d6d024c14c1cf4a9
Install Scala 2.12.3 and SBT using apt-get on Ubuntu 16.04
## Java
sudo apt-get update
sudo apt-get install default-jdk
## Scala
sudo apt-get remove scala-library scala
sudo wget https://downloads.lightbend.com/scala/2.12.3/scala-2.12.3.deb
sudo dpkg -i scala-2.12.3.deb
sudo apt-get update
sudo apt-get install scala