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 / curl-7.87.0.scala
Created March 24, 2023 09:41
Scala 3 Native Curl bindings + example program
package curl
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[curl] trait CEnum[T](using eq: T =:= Int):
given Tag[T] = Tag.Int.asInstanceOf[Tag[T]]
package libhandler
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[libhandler] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]
@keynmol
keynmol / unit-1.29.1.scala
Created March 17, 2023 15:41
NGINX Unit bindings (
package unit
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object aliases:
import _root_.unit.aliases.*
import _root_.unit.structs.*
@keynmol
keynmol / lmdb.scala
Created March 7, 2023 20:16
LMDB bindings for Scala 3 Native
package lmdb
import _root_.scala.scalanative.unsafe.*
import _root_.scala.scalanative.unsigned.*
import _root_.scala.scalanative.libc.*
import _root_.scala.scalanative.*
object predef:
private[lmdb] trait CEnumU[T](using eq: T =:= UInt):
given Tag[T] = Tag.UInt.asInstanceOf[Tag[T]]
This file has been truncated, but you can view the full file.
package libnotify
import scala.scalanative.unsafe.*
import scala.scalanative.unsigned.*
import scalanative.libc.*
import scalanative.*
object predef:
trait CEnum[T](using eq: T =:= Int):
@keynmol
keynmol / libnotify.scala
Created February 3, 2023 15:41
Libnotify and transitively glib bindings
This file has been truncated, but you can view the full file.
//> using platform "scala-native"
//> using nativeVersion "0.4.10"
//> using scala "3.2.2"
package t
import scala.scalanative.unsafe.*
import scala.scalanative.unsigned.*
import scalanative.libc.*
import scalanative.*
@keynmol
keynmol / lsp.scala
Created August 25, 2022 17:10
Langoustine Scala Native Example
//> using scala "3.1.3"
//> using platform "scala-native"
//> using lib "tech.neander::jsonrpclib-core::0.0.3-16-0d40b9-DIRTYce833c81"
//> using lib "tech.neander::langoustine-lsp::0.0.8"
//> using lib "com.lihaoyi::os-lib::0.8.1"
import langoustine.lsp.LSPBuilder
import scala.concurrent.Future
@keynmol
keynmol / build.sbt
Created July 2, 2022 10:40
Try Doobie modernised
libraryDependencies ++= Seq(
"org.xerial" % "sqlite-jdbc" % "3.36.0.3",
"org.tpolecat" %% "doobie-core" % "1.0.0-RC2",
"org.tpolecat" %% "doobie-hikari" % "1.0.0-RC2", // HikariCP transactor.
"org.tpolecat" %% "doobie-specs2" % "1.0.0-RC2", // Specs2 support for typechecking statements.
"org.tpolecat" %% "doobie-scalatest" % "1.0.0-RC2", // ScalaTest support for typechecking statements.
)
@keynmol
keynmol / README.md
Last active May 11, 2022 11:44
Scala 3 nightly bisector

This script does the following:

  1. Downloads the listing of Scala 3 nightly versions from https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/
  2. Parses and sorts them in a really silly way
  3. Runs binary search, invoking scala-cli with a given file and different versions, until it hits the earliest version where the file fails to compile

E.g. if you have a file like this (from scala/scala3#15160):

example.sc

@keynmol
keynmol / SDL-native.c
Created March 16, 2022 12:52
SDL bindings automatically generated
#include <string.h>
void __sn_wrap_libsdl_SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, SDL_GameControllerButtonBind *____return) {
SDL_GameControllerButtonBind ____ret = SDL_GameControllerGetBindForAxis(gamecontroller, axis);
memcpy(____return, &____ret, sizeof(SDL_GameControllerButtonBind));
}
void __sn_wrap_libsdl_SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, SDL_GameControllerButtonBind *____return) {
SDL_GameControllerButtonBind ____ret = SDL_GameControllerGetBindForButton(gamecontroller, button);