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 / 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]]
@keynmol
keynmol / README.md
Last active June 18, 2024 13:13
Scala example of using htmx
@keynmol
keynmol / scala-http-postgres-html-docker.scala
Created September 28, 2023 11:43
Sample gist showing how to run a HTTP server with Typelevel Scala libraries, and a postgres docker container
//> using dep "org.http4s::http4s-scalatags::0.25.2"
//> using dep "org.http4s::http4s-dsl::0.23.23"
//> using dep "org.http4s::http4s-ember-server::0.23.23"
//> using dep "org.tpolecat::skunk-core::0.6.0"
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0"
//> using dep "com.outr::scribe-slf4j::3.12.2"
import skunk.*, codec.all.*, syntax.all.*
import cats.effect.*
import scalatags.Text.all.*
@keynmol
keynmol / file-proxy-basic-auth.scala
Created July 24, 2023 15:37
Basic auth file proxy
//> using dep org.http4s::http4s-ember-server::0.23.23
//> using dep org.http4s::http4s-dsl::0.23.23
//> using dep com.outr::scribe-cats::3.11.8
/** This script implements a file proxy, which puts basic auth username and
* password challenge, in order to simulate password-protected artifactory
*
* To run it, use Scala CLI: https://scala-cli.virtuslab.org/
*
* Run `scala-cli run test.scala` and follow instructions
@keynmol
keynmol / postgres.scala
Created July 10, 2023 10:24
Postgres server bindings
package libtest
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[libtest] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]
@keynmol
keynmol / llvm_bindings.scala
Created July 3, 2023 09:16
LLVM-C bindings for Scala 3 Native
package llvm_bindings
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[llvm_bindings] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]
@keynmol
keynmol / README.md
Last active June 5, 2023 12:19
Example of contextual logging with IOLocal and Scribe in Cats Effect

Run with scala-cli run context-logging.scala

Screenshot 2023-06-05 at 13 18 17

@keynmol
keynmol / librdata.scala
Created June 4, 2023 08:25
Librdata bindings
package librdata
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[librdata] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]