Skip to content

Instantly share code, notes, and snippets.

View guizmaii's full-sized avatar
🏄‍♂️

Jules Ivanic guizmaii

🏄‍♂️
View GitHub Profile
@pierangeloc
pierangeloc / doobie_newtype.scala
Last active November 23, 2021 13:25
Doobie instances for NewType
import io.estatico.newtype.ops._
import io.estatico.newtype.macros.newtype
import eu.timepit.refined.api.Refined
import doobie.implicits._
import doobie.postgres.implicits._
import doobie.refined.implicits._
/**
* Derive a Put (so it can be interpolated in doobie sql expressions) for any newtype backed by a type that is
* supported by doobie (e.g. any wrapper of String, UUID, Boolean etc)
@stettix
stettix / things-i-believe.md
Last active March 20, 2024 17:45
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@mrugacz95
mrugacz95 / awk_actions.awk
Created December 19, 2019 10:22
AWK actions
echo "failure is the greatest teacher" | awk '{print $3, $4, $5, $1, $2}'
@mpilquist
mpilquist / big3.scala
Last active September 25, 2019 00:40
Example encoding of Functor / Applicative / Monad using dotty 0.15
/* Example of encoding Functor/Applicative/Monad from cats with Dotty 0.15 features.
* Derived in part from Cats -- see https://github.com/typelevel/cats/blob/master/COPYING for full license & copyright.
*/
package structures
import scala.annotation._
trait Functor[F[_]] {
def (fa: F[A]) map[A, B](f: A => B): F[B]
def (fa: F[A]) as[A, B](b: B): F[B] =
import cats.effect.ExitCode
import monix.eval.{Task, TaskApp}
import monix.execution.atomic.Atomic
class MtCache[A](ref: Atomic[Map[String, Task[A]]]) {
def cache(key: String)(task: () => A): Task[A] = {
ref.transformAndExtract { current =>
current.get(key) match {
@fanf
fanf / ZioExecSemantic.scala
Last active April 22, 2019 21:00
Show how ZIO behave with/without fiber fork.
/*
* This test shows that without a fork, execution is purely mono-fiber and sequential.
*/
object TestZioExecSemantic {
val rt = new DefaultRuntime {}
trait LOG {
def apply(s: String): UIO[Unit]
}
def makeLog = UIO(new LOG {
val zero = System.currentTimeMillis()
/*
This piece of commented code aims to clarify some
misconceptions between several advanced concepts
in pure functional programming/category theory:
free monads, finally tagless approach, algebraic
effects.
These concepts are actually very close. They rely
on similar concepts and even represent the "same"
object (up to isomorphism!) from the theoretical
@enebo
enebo / ast.txt
Created December 10, 2018 20:09
jruby -S ast -e 'i += 1; i = i + 1'
AST:
RootNode 0
BlockNode 0
LocalAsgnNode:i 0
CallNode:+ 0
LocalVarNode:i 0
ArrayNode 0
FixnumNode 0
, null
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 3, 2024 22:55
set -e, -u, -o, -x pipefail explanation
@non
non / seeds.md
Last active April 12, 2024 09:18
Simple example of using seeds with ScalaCheck for deterministic property-based testing.

introduction

ScalaCheck 1.14.0 was just released with support for deterministic testing using seeds. Some folks have asked for examples, so I wanted to produce a Gist to help people use this feature.

simple example

These examples will assume the following imports: