Skip to content

Instantly share code, notes, and snippets.

View keynmol's full-sized avatar
🏠
choosing the lowest hill to die on

Anton Sviridov keynmol

🏠
choosing the lowest hill to die on
View GitHub Profile
@keynmol
keynmol / labeled-breaks.scala
Created September 6, 2024 15:06
Labeled nested breaks in Scala
object lib:
import scala.annotation.implicitNotFound
import scala.util.boundary, boundary.*
opaque type Lab[T <: Singleton] >: Unit = Unit
object Lab:
inline def apply[T <: Singleton]: Lab[T] = ()
inline def label[T <: Singleton & String](
inline f: Label[Lab[T]] ?=> Unit
@keynmol
keynmol / README.md
Last active July 19, 2024 13:52
Using smithy4s-curl to call smithy4s-defined services from Scala Native using libcurl

https://github.com/neandertech/smithy4s-curl

This scala-cli script has two entrypoints, so you can produce two binaries from it - one using curl, and one using http4s Ember.

Because native dependencies are required for both entrypoints, I prefer to build them using my sn-vcpkg CLI:

To produce a binary using curl:

$ sn-vcpkg scala-cli curl --rename curl=libcurl -- package . -f -o ./native-curl -M helloCurl
@keynmol
keynmol / roach-gears-postgres-multi-threading.scala
Created July 13, 2024 12:58
Scala Native 0.5, Gears, Roach, Postgres, multi-threading
//> using dep "ch.epfl.lamp::gears::0.2.0"
//> using dep "com.indoorvivants.roach::core::0.1.0"
//> using nativeVersion 0.5.4
//> using option -Wunused:all
//> using platform "scala-native"
//> using repository sonatype:snapshots
//> using scala 3.5.0-RC4
import gears.async.*, default.given
import roach.*, codecs.*
@keynmol
keynmol / README.md
Last active July 5, 2024 15:45
Render a yak shaving page to keep track of your side projects

This small script exists only to render a HTML page for the various yaks you are working on.

scala-cli run yak-render.scala -- sample-projects.yml > index.html

CleanShot 2024-07-05 at 16 37 38

Copy and adapt for your needs.

My personal page is huge: image

@keynmol
keynmol / README.md
Created April 17, 2024 19:54
Logging interpolator for Scala 3

CleanShot 2024-04-17 at 20 50 26@2x

file Lines Tokens Tasty Complexity/Line Directory
[info] package.scala 3 31 8 2.67 moderate /Users/velvetbaldmime/projects/indoorvivants/smithy4s-aws-only/src/main/scala/generated/hello
[info] InferenceUnitsInteger.scala 13 112 11 0.85 low /Users/velvetbaldmime/projects/indoorvivants/smithy4s-aws-only/src/main/scala/generated/com/amazonaws/comprehend
[info] NumberOfDocuments.scala 13 112 11 0.85 low /Users/velvetbaldmime/projects/indoorvivants/smithy4s-aws-only/src/main/scala/generated/com/amazonaws/comprehend
[info] EntityTypeName.scala 13 112 11 0.85 low /Users/velvetbaldmime/projects/indoorvivants/smithy4s-aws-only/src/main/scala/generated/com/amazonaws/comprehend
[info] AnyLengthString.scala 13 112 11
@keynmol
keynmol / deriving-order.scala
Last active March 26, 2024 20:26
Deriving Ordering in Scala 3, slow and fast versions
//> using scala 3.4.0
package bla
import scala.deriving.*, scala.compiletime.*
// change this to FASTER to go brrr
import EVEN_FASTER_SOMETIMES.*
// MAGIC
@keynmol
keynmol / demo.scala
Created March 20, 2024 08:57
TODO macro in Scala 3
def myLazyWork(str: String) =
str match
case "hello" => println("yo")
case "world" => TODO("world is unhandled")
@main def hello =
myLazyWork("hello")
myLazyWork("world")
@keynmol
keynmol / README.md
Last active February 29, 2024 13:34
Byte pair encoding algorithm in Scala
@keynmol
keynmol / gdextension.scala
Created October 14, 2023 12:58
GDExtension bindings
package godot
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[godot] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]