Skip to content

Instantly share code, notes, and snippets.

View felher's full-sized avatar

felher felher

  • Olyro GmbH
View GitHub Profile
@felher
felher / PersistentVar.scala
Created March 13, 2024 14:34
leaking var laminar
package org.felher.crust.util
import com.raquo.laminar.api.L.*
import io.circe.*
import org.scalajs.dom
object PersistentVar:
/**
* This function should not be used for dynamically created values
* since it will never be cleaned up.
@felher
felher / input-wrapper.component.html
Created August 18, 2023 13:45
Angular ngModel infinite loop
<input [ngModel]="'freezing!'" />
@felher
felher / 00.yml
Created July 13, 2023 15:07
ansible parallelism
- name: Tests
hosts: study_hosts
gather_facts: false
become: false
tasks:
- name: A
ansible.builtin.command: sleep 1
loop: "{{ [1, 2] }}"
@felher
felher / SplitEnum.scala
Created October 18, 2022 15:23
Sum-Type Splitter for Laminar with Exhaustiveness-Checks
import com.raquo.laminar.api.L.*
import scala.deriving.*
import scala.compiletime.*
object SplitEnum:
final case class Splitter[A, Todo <: Tuple, O](sig: Signal[A], keyer: A => Int, handlers: Array[Any => O]):
inline def close: Signal[O] =
inline erasedValue[Todo] match
case _: EmptyTuple.type =>
sig.splitOne(keyer)((key, _, subSig) => handlers(key)(subSig))

What if the siganture of memoize would be def memoize: ZIO[R, E, A] instead of UIO[ZIO[R, E,A]]. Let's keep the intial definition.

**we asume that the first part of an for-comprehension can be a x = xyz, which it can't, but it doesn't change the point of this example. The first part of an for-comprehension has to be an x <- xyz **

Let's look at an example:

for {
    m1 <- putStrLn("hello").memoize
    m2 <- putStrLn("hello").memoize
import io.circe.generic.extras.ConfiguredJsonCodec
import io.circe.parser._
import scala.scalajs.js
import scala.scalajs.js.JSConverters._
import scala.scalajs.js.annotation.{JSExportAll, JSExportTopLevel}
@ConfiguredJsonCodec
sealed trait Node {}
@felher
felher / Main.scala
Last active March 20, 2020 10:25
example circe generic extra configured json codec adt
package org.felher.tmpNvkhHSWXMk
import io.circe.syntax._
import io.circe.parser._
import io.circe._
import io.circe.generic.extras._
import cats.implicits._
object Main {
def main(args: Array[String]): Unit = {
package org.felher.tmpc5C0ubzOfr
import shapeless._, syntax.singleton._, record._, shapeless.ops.record._
object Main {
def main(args: Array[String]): Unit = {
val a = ('name ->> "Alice") :: ('birthYear ->> 1980) :: HNil
val b = ('name ->> "Bob") :: ('birthYear ->> 1990) :: HNil
val ageAnnotater = makeAgeAnnotator(2020)

Hey folks. I'm a bit unsure about how to handle (doobie) database transactions in a FT style. Say I have a three small algebras and something using them

trait Users[F[_]] { ... }
trait Groups[F[_]] { ... }
trait Mails[F[_]] { ... }

def use[F[_]](implicit U: Users[F], G: Groups[F], M: Mails[F]) = for {
  _ <- U.doSomething
  _ <- G.doSomething
 _ &lt;- M.doSomething
function linePairContainerParser():P.Parser<M.FormteilContainer>{
return P.regexp(/[0-9]+/).map(num => (
{
"kind": M.ContainerKind.FormteilContainer,
uuid: UUID(),
children: []
}));
}