Skip to content

Instantly share code, notes, and snippets.

View Baccata's full-sized avatar

Olivier Mélois Baccata

View GitHub Profile
@Baccata
Baccata / repro.scala
Last active June 9, 2023 13:28
Reproduction of a http/2 specific problem with http4s-ember-server
//> using lib "org.http4s::http4s-ember-server:0.23.19"
//> using lib "org.http4s::http4s-dsl:0.23.19"
package foo
import cats.effect._
import cats.syntax.all._
import org.http4s.implicits._
import org.http4s.ember.server._
import org.http4s._
import org.http4s._
import org.http4s.syntax.all._
import smithy4s.kinds._
import smithy4s.Service
import smithy4s.http4s.SimpleRestJsonBuilder
import cats.data.OptionT
import cats.effect._
import cats.effect.syntax.all._
def precompileRoutes[Alg[_[_, _, _, _, _]]](service: Service[Alg])(
@Baccata
Baccata / tenet.scala
Created January 26, 2023 11:07
Wait for queue drain example
//> using lib "co.fs2::fs2-core:3.5.0"
import cats.effect.IOApp
import cats.effect._
import cats.effect.std.Queue
import scala.concurrent.duration._
import cats.effect.syntax.all._
import cats.syntax.all._
import cats.instances.queue
object Main extends IOApp.Simple {
@Baccata
Baccata / PolykindedMapper.scala
Last active October 24, 2022 09:33
Playing with kind-polymorphism to create a poly-kinded mapper construct.
//> using lib "org.typelevel::cats-core:2.8.0"
package foo
import cats.Functor
import cats.arrow.FunctionK
import cats.Id
import cats.ApplicativeError
import cats.MonadError
import scala.util.Try
import cats.syntax.all._
@Baccata
Baccata / TupleK.scala
Last active March 28, 2022 13:14
Generalised KTuple POC
//> using lib "org.typelevel::cats-core:2.7.0"
import cats.Applicative
import cats.syntax.all._
import cats.ContravariantMonoidal
import cats.InvariantMonoidal
import cats.InvariantSemigroupal
import cats.Show
import cats.~>
import cats.arrow.FunctionK
import cats.kernel.Monoid
@Baccata
Baccata / recursion.scala
Last active February 1, 2022 10:22
Baccata's recursion schemes microlib (to copy/paste when needed). Only depends on cats-core.
import cats._
import cats.syntax.all._
// format: off
/**
* A couple recursion-schemes, named in a less arcanic fashion than usual.
* These functions allow to decouple the recursive aspect of model construction
* and validation, from the domain-specific concerns.
*/
object recursion {
@Baccata
Baccata / compatibility.md
Created November 22, 2021 08:26
Data/API compatibility rules

Reasoning formally about data compatibility

Data compatibility in distributed systems is a problem that is often adressed in ad-hoc manners and suffer from bikeshedding. Developing a formal framework for reasoning about it is crucial to ensure a seamless evolution of complex systems and easy inter-connectivity of components.

Disclaimer

This gist talks specifically about backward compatibility rules. Intuitively, forward compatibility rules are the opposite of backward ones.

Defining the problem

@Baccata
Baccata / CryptoJSFacade.scala
Last active September 14, 2021 08:23
JVM/JS/Native Platform-specific implementations of crypto functions required for implementing the AWS signature algorithm.
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
/**
* @see https://nodejs.org/dist/latest-v7.x/docs/api/crypto.html#crypto_crypto
*/
@js.native
trait Crypto extends js.Object {
def createHash(algorithm: String): Hash = js.native
@Baccata
Baccata / Apple.scala
Last active April 16, 2021 08:57
Generic macros to get async/await UX for anything that has a cats' Apply associated to it
package baccata
import cats.Apply
import scala.annotation.compileTimeOnly
import scala.language.higherKinds
import scala.reflect.macros.blackbox
// format: off
// mostly stolen from mill's applicative macro
@Baccata
Baccata / Convert .mov or .MP4 to .gif.md
Created September 20, 2020 09:18 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.