Skip to content

Instantly share code, notes, and snippets.

View kubukoz's full-sized avatar
😱
I might take a week to respond. Or a month.

Jakub Kozłowski kubukoz

😱
I might take a week to respond. Or a month.
View GitHub Profile
@kubukoz
kubukoz / compile.sh
Created January 13, 2024 00:46
Primitive Playdate game built with clang
#!/bin/bash
set -euo pipefail
# You'll have to change this, also see note about caveat below
SDK_PATH=/Users/kubukoz/Developer/PlaydateSDK/C_API
rm -rf HelloWorld.pdx || true
rm Source/pdex.elf || true
@kubukoz
kubukoz / slides.md
Last active November 11, 2023 10:34
Let's build an IDE!

Jakub Kozłowski | Scala in the city | 26 X 2023

Code | Recording


Why build an IDE?

  1. For fun
  2. For your proprietary DSL
@kubukoz
kubukoz / scala3tailrec-inline.sc
Created October 15, 2023 21:40
Scala 3 inlines before tailrec analysis
// compiles
//> using scala "3.3.1"
import scala.annotation.tailrec
case class Opt[A](value: A | Null) {
inline def flatMap[B](inline f: A => Opt[B]): Opt[B] =
if (value == null)
Opt(null)
else
@kubukoz
kubukoz / ngrams.scala
Created May 4, 2023 18:24
My solution to the "top n-grams" problem for my mock interview on Marcin Krykowski's channel
//> using scala "3.2.2"
//> using lib "co.fs2::fs2-io:3.6.1"
//> using lib "io.circe::circe-core:0.14.5"
//> using lib "io.circe::circe-parser:0.14.5"
import cats.data.NonEmptyList
import cats.effect.IO
import cats.effect.IOApp
import cats.implicits.*
import cats.kernel.Order
import fs2.io.file.Files
@kubukoz
kubukoz / Demo.scala
Created April 19, 2023 13:50
Using `getAndDiscreteUpdates` and `mapN` and it still works
//> using lib "co.fs2::fs2-core:3.7.0-RC4"
import cats.effect.IOApp
import cats.effect.IO
import scala.concurrent.duration._
import cats.effect.std.UUIDGen
import cats.implicits._
import scala.util.Random
import fs2.concurrent.Signal
object Demo extends IOApp.Simple {
@kubukoz
kubukoz / fs2zip.scala
Created January 22, 2023 04:03
Example of using fs2 + ZipInputStream to open a zipfile in Scala. Probably buggy and maybe leaky.
//> using scala "2.13.10"
//> using lib "co.fs2::fs2-io:3.5.0"
//> using option "-Wunused:imports"
import cats.effect.IO
import cats.effect.IOApp
import cats.effect.kernel.Resource
import cats.implicits._
import fs2.io.file.Files
import fs2.io.file.Path
https://www.usenix.org/legacy/events/hotos07/tech/full_papers/dolstra/dolstra.pdf
https://edolstra.github.io/pubs/phd-thesis.pdf
https://nixos.org/manual/nix/stable/
https://nixos.org/guides/nix-pills/index.html
https://nix.dev/
https://wiki.nikitavoloboev.xyz/package-managers/nix
https://edolstra.github.io/pubs/nixos-jfp-final.pdf
https://nixos.org/docs/SCR-2005-091.pdf
https://medium.com/@MrJamesFisher/nix-by-example-a0063a1a4c55
https://scrive.github.io/nix-workshop/01-getting-started/01-introduction.html
@kubukoz
kubukoz / demo.scala
Created December 15, 2022 01:25
Smithy's NeighborProvider and unit shapes
//> using lib "software.amazon.smithy:smithy-model:1.26.4"
//> using scala "2.13.10"
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.neighbor.NeighborProvider
import software.amazon.smithy.model.shapes.ShapeId
import scala.jdk.CollectionConverters._
object demo extends App {
@kubukoz
kubukoz / main.scala
Created December 14, 2022 21:45
IdRefVisitor used in a neighbor provider
//> using lib "software.amazon.smithy:smithy-model:1.26.4"
//> using lib "com.disneystreaming.smithy4s:smithy4s-protocol:0.17.1"
//> using scala "2.13.10"
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.neighbor.Walker
import software.amazon.smithy.model.shapes.ShapeId
import scala.jdk.CollectionConverters._
import software.amazon.smithy.model.neighbor.NeighborProvider
import software.amazon.smithy.model.neighbor.Relationship
import software.amazon.smithy.model.shapes.Shape
@kubukoz
kubukoz / advent-type-level.scala
Created December 4, 2022 02:49
Scala's type system solution of Advent of Code 2022 day 1 part 1
import scala.compiletime.ops.int.{>, +, *}
import scala.compiletime.ops.string.{Length, Substring, CharAt}
import Tuple.Map
object StringOps {
type IndexOfRec[Haystack <: String, Needle <: String, I <: Int] =
((I + Length[Needle]) > Length[Haystack]) match {
case true => -1
case false =>
Substring[Haystack, I, I + Length[Needle]] match {