Skip to content

Instantly share code, notes, and snippets.

@jmatsushita
jmatsushita / README
Last active October 26, 2025 02:53
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.

Understanding Comparative Benchmarks

I'm going to do something that I don't normally do, which is to say I'm going to talk about comparative benchmarks. In general, I try to confine performance discussion to absolute metrics as much as possible, or comparisons to other well-defined neutral reference points. This is precisely why Cats Effect's readme mentions a comparison to a fixed thread pool, rather doing comparisons with other asynchronous runtimes like Akka or ZIO. Comparisons in general devolve very quickly into emotional marketing.

But, just once, today we're going to talk about the emotional marketing. In particular, we're going to look at Cats Effect 3 and ZIO 2. Now, for context, as of this writing ZIO 2 has released their first milestone; they have not released a final 2.0 version. This implies straight off the bat that we're comparing apples to oranges a bit, since Cats Effect 3 has been out and in production for months. However, there has been a post going around which cites various compar

@Daenyth
Daenyth / KeyedEnqueue.scala
Created October 9, 2019 14:22
fs2 groupBy / KeyedEnqueue
import cats.Monad
import cats.effect.concurrent.{Ref, Semaphore}
import cats.effect.{Concurrent, Resource}
import cats.implicits._
import fs2.{Pipe, Stream}
import fs2.concurrent.{NoneTerminatedQueue, Queue}
/** Represents the ability to enqueue keyed items into a stream of queues that emits homogenous keyed streams.
*
@txsmith
txsmith / TreesThatGrow.scala
Last active August 21, 2023 08:26
An attempt at Trees That Grow in Scala
import scala.annotation.{implicitAmbiguous, implicitNotFound, showAsInfix}
import scala.language.higherKinds
/**
* This is an attempt to replicate Trees that Grow by Shayan Najd and Simon Peyton Jones in Scala.
* Paper at: https://www.microsoft.com/en-us/research/uploads/prod/2016/11/trees-that-grow.pdf
* The main mechanisms demonstrated in the paper can be recreated in Scala but at a significant boilerplate cost.
* The best approach to improve this would be to automatically generate the appy and unapply methods for each AST term
* (e.g. with a macro or code generation)
*/
@SystemFw
SystemFw / example.scala
Last active May 24, 2023 15:13
Running fs2 streams in parallel and collect their result in sequence, with queues
object Example {
import cats._, implicits._
import cats.effect._
import fs2._
import scala.concurrent.ExecutionContext
// start N streams concurrently, and stream their results in order
// e.g. download a file from a server in N parts concurrently, and stream it
abstract class Channel[F[_], A] {
@jto
jto / Demo.scala
Created August 26, 2016 12:38
Automatic case class to CSV derivation using shapeless
case class Foo(i: Int)
case class Bar(foo: Foo, g: String)
val b = Bar(Foo(1), "toto")
val h = ToHList(b) // List[shapeless.::[Int, shapeless.::[String, shapeless.HNil]]] = List(1 :: toto :: HNil)
Ser.toCSV(h) // "1,toto"
@okumin
okumin / akka-persistence.md
Created September 28, 2014 08:55
akka-persistenceのプラグインをつくろう