Skip to content

Instantly share code, notes, and snippets.

View TimWSpence's full-sized avatar

Tim Spence TimWSpence

View GitHub Profile

Keybase proof

I hereby claim:

  • I am timwspence on github.
  • I am timwspence (https://keybase.io/timwspence) on keybase.
  • I have a public key ASA8HHXZfi9repE2J0wYPFhsvAN92JPgCSLct5zdGJTg4go

To claim this, I am signing this object:

@TimWSpence
TimWSpence / gist:2980c37ad38827af369c42dce34fecf4
Created November 5, 2018 12:33
Ensime scalameta paradise error
ERROR akka://ENSIME/user/ensime-main/project/scalac/root_compile a.a.OneForOneStrategy - Method org/scalameta/paradise/typechecker/HijackAnalyzer$$anon$1.scala$tools$nsc$typechecker$Macros$_setter_$scala$tools$nsc$typechecker$Macros$$macroClassLoadersCache_$eq(Lscala/tools/nsc/classpath/FileBasedCache;)V is abstract
akka.actor.ActorInitializationException: akka://ENSIME/user/ensime-main/project/scalac/root_compile: exception during creation
at akka.actor.ActorInitializationException$.apply(Actor.scala:193)
at akka.actor.ActorCell.create(ActorCell.scala:671)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:525)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:547)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
at akka.dispatch.Mailbox.run(Mailbox.scala:223)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
@TimWSpence
TimWSpence / StackMultistageDockerfile
Created July 15, 2019 15:31
A minimal Docker multi-stage build for a Haskell stack application
# Loosely based on https://www.fpcomplete.com/blog/2017/12/building-haskell-apps-with-docker
FROM fpco/stack-build:lts-13.27 as build
RUN mkdir /opt/build
WORKDIR /opt/build
# GHC dynamically links its compilation targets to lib gmp
RUN apt-get update \
&& apt-get download libgmp10
RUN mv libgmp*.deb libgmp.deb
@TimWSpence
TimWSpence / build.sh
Last active July 31, 2019 17:14
Build script for optimized multistage Docker build for Haskell Stack
docker pull ns/app-dependencies:latest || true
docker build --target dependencies --cache-from ns/app-dependencies:latest -t ns/app-dependencies .
docker build --target app --cache-from ns/app-dependencies:latest -t ns/app .
docker push ns/app-dependencies:latest
docker push ns/app:latest
@TimWSpence
TimWSpence / Dockerfile
Last active August 16, 2022 08:03
Optimized multistage Dockerfile for Haskell Stack builds
# Loosely based on https://www.fpcomplete.com/blog/2017/12/building-haskell-apps-with-docker
FROM fpco/stack-build:lts-13.27 as dependencies
RUN mkdir /opt/build
WORKDIR /opt/build
# GHC dynamically links its compilation targets to lib gmp
RUN apt-get update \
&& apt-get download libgmp10
RUN mv libgmp*.deb libgmp.deb
def map[A, B](s: STM[A], f: A => B): STM[B]
def orElse[A](attempt: STM[A], fallback: STM[A]): STM[A]
def check(check: => Boolean): STM[Unit]
def get: STM[A]
def set(a: A): STM[Unit]
def modify(f: A => A): STM[Unit]
def atomically[F[_], A](s: STM[A]): F[A]
import cats.effect.{ExitCode, IO, IOApp}
import io.github.timwspence.cats.stm.{TVar, STM}
import scala.concurrent.duration._

object Main extends IOApp {

  override def run(args: List[String]): IO[ExitCode] =
    for {
      accountForTim   <- TVar.of[Long](100).commit[IO]
@TimWSpence
TimWSpence / blockOn.scala
Last active April 28, 2023 13:42
Cats effect 2 nested evalOn/blockOn gotcha
import cats.implicits._
import cats.effect.{Blocker, IO, IOApp, ExitCode}
import java.util.concurrent.Executors
object Test extends IOApp {
override def run(args: List[String]): IO[ExitCode] = {
val blocker = Blocker.liftExecutorService(Executors.newCachedThreadPool())
blocker.blockOn(
for {
_ <- printThread