Skip to content

Instantly share code, notes, and snippets.

View jadlr's full-sized avatar

Jonas Adler jadlr

View GitHub Profile
defmodule BatailleRoyale do
@cards 0..7 |> Enum.to_list |> List.duplicate(4) |> List.flatten
def times(n) do
results =
1..n
|> Enum.map(fn _ -> play() end)
|> Enum.map(fn {_, _, moves} -> moves end)
@jadlr
jadlr / StateTest.scala
Created February 17, 2020 08:13
Experimenting with the state monad to have a context in https4
import cats.data._
import cats.effect.ExitCode
import cats.implicits._
import cats.~>
import org.http4s.dsl.Http4sDsl2
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.{ Http, Request, Response }
import zio._
import zio.clock.Clock
import zio.interop.catz._
@jadlr
jadlr / CryptoApp.scala
Created June 26, 2020 13:51
Using AES256GCM to encrypt and decrypt a text
import cats.effect.{ ExitCode, IO, IOApp }
import tsec.cipher.symmetric.{ AAD, AADEncryptor, IvGen }
import tsec.cipher.symmetric.jca.{ AES256GCM, SecretKey }
import tsec.common._
import tsec.cipher.symmetric._
object CryptoApp extends IOApp {
private val aad: AAD = AAD("KnQCxy4rW4KuxMRcvkVvAs9KufF7XR4b".utf8Bytes)
@jadlr
jadlr / FS2TaskInterop.scala
Created October 2, 2020 12:36
Unexpected behaviour when using zio with fs2
import fs2.Stream
import zio.interop.catz._
import zio.{ Runtime, Task }
object FS2TaskInterop extends App {
val runtime = Runtime.default
val nonStream = Task(123).map(_ => BigDecimal("16:19:25.242056065Z"))
val stream = Stream.eval(nonStream)