Skip to content

Instantly share code, notes, and snippets.

@Daenyth
Daenyth / keybase.md
Last active August 25, 2021 12:48
keybase.md

Keybase proof

I hereby claim:

  • I am daenyth on github.
  • I am daenyth (https://keybase.io/daenyth) on keybase.
  • I have a public key ASCSw0W8Kr-JKKaGIAxIIOqY3h1MuLZzNqx2epHUbiLD4Qo

To claim this, I am signing this object:

@Daenyth
Daenyth / monad-li-seme.md
Last active May 11, 2023 15:12
What's a monad

"Monad" is a word that describes a set of behaviors

In scala, we use the Monad[Foo] typeclass from cats to define instances of this behavior.

The essence of its behavior is the ability to describe a series of computations, where one computation depends on the result of the computation that came before it.

For example, Monad[Option] shows that the Option[A] data type can be used to describe computations of A which may result in no value.

twitter.com##div[aria-label="Timeline: Trending now"]
twitter.com##aside[aria-label="Who to follow"]
twitter.com##div[data-testid="sidebarColumn"]
@Daenyth
Daenyth / .scalafmt.conf
Created December 2, 2020 18:08
My scalafmt preference (for now)
version = "2.7.1"
align = some
align.arrowEnumeratorGenerator = true
align.openParenCallSite = true
align.tokens = [caseArrow]
binPack.parentConstructors = true
comments.wrap = standalone
@Daenyth
Daenyth / DoobieSlickCompat.scala
Last active June 16, 2023 14:02
Slick Database => doobie Transactor
import cats.effect.Async
import doobie.util.transactor.Transactor
import scala.concurrent.ExecutionContext
trait DoobieSlickCompat {
/** Create a Doobie Transactor backed by the same Jdbc DataSource as the live slick Database */
def transactorFromSlick[F[_]: Async](
slickDb: slick.jdbc.JdbcBackend#Database,
@Daenyth
Daenyth / scala-aws.md
Created October 10, 2020 14:40
Scala AWS library index

Notes

There's a lot of libraries with overlapping support. This tries to index the ones I've seen.

I only care about / list the ones that support cats-effect/fs2 in some way or another.

I'll list some project status:

  • Dead = fully abandoned or archived
  • Inactive = no changes for over a year (as of oct 2020)
@Daenyth
Daenyth / DoobieImplicits.scala
Last active December 14, 2020 17:12
DoobieImplicits
/** Convenience imports for doobie, to make it easier to remember
*
* @example {{{
* import DoobieImplicits.all._
* // is equal to all of:
* import doobie.postgres.implicits._
* import doobie.implicits._
* import doobie.implicits.legacy.instant._
* import doobie.implicits.legacy.localdate._
* import io.chrisdavenport.fuuid.doobie.implicits._
@Daenyth
Daenyth / config.py
Created August 21, 2020 13:47
Pytest postgres fixtures
# in myapp/
import os
from pathlib import Path
from typing import Mapping, NamedTuple, Optional
from datetime import timedelta
class DbConfig(NamedTuple):
dbname: str
@Daenyth
Daenyth / DoobieTest.scala
Last active June 10, 2020 15:39
DoobieTest scalatest helper for doobie
import cats.effect.{Blocker, ContextShift, IO}
import doobie.util.testing.Analyzable
import doobie.util.transactor.Transactor
import org.scalactic.source
import org.scalatest.Succeeded
import org.scalatest.funspec.AsyncFunSpecLike
import scala.concurrent.{ExecutionContext, Future}
trait DoobieTest extends AsyncFunSpecLike with doobie.scalatest.IOChecker {
@Daenyth
Daenyth / AkkaHttp4s.scala
Created May 18, 2020 18:29
POC akka-http to http4s layer
package akkahttp4s
import akka.http.scaladsl.model.{
ContentType,
ContentTypes,
HttpEntity,
HttpHeader,
HttpMethod,
HttpMethods,
HttpProtocol,