Skip to content

Instantly share code, notes, and snippets.

View TonioGela's full-sized avatar
🐈

Antonio Gelameris TonioGela

🐈
View GitHub Profile
@TonioGela
TonioGela / Game.scala
Created August 10, 2024 13:53
Goose Game - I should refactor tests!
//> using scala 3.4.2
import scala.util.Random
import scala.io.StdIn
import scala.annotation.tailrec
@main def main = gameLoop(State.empty)(StdIn.readLine())
@tailrec
def gameLoop(state: State)(s: String): Unit =
//> using scala 3.4.2
//> using platform native
//> using nativeVersion 0.4.17
//> using packaging.output checkLineLenght
//> using nativeMode debug
//> using nativeLto none
//> using nativeGc none
//> using toolkit typelevel::latest
import cats.syntax.all.*
//> using scala 3.4.2
//> using toolkit typelevel::latest
import cats.effect.{IO, IOApp}
import cats.effect.std.Random
import fs2.concurrent.SignallingRef
import scala.concurrent.duration.*
object Main extends IOApp.Simple:
@TonioGela
TonioGela / in.scala
Last active May 31, 2024 13:19
Just type `in 20m Have a pause and rest` (on MacOs) and in 20 minutes a reminder notification saying "Have a pause and rest" will appear
//> using scala 3.4.2
//> using platform native
//> using packaging.output in
//> using nativeMode release-full
//> using nativeLto full
//> using nativeGc none
import scala.concurrent.duration.*
@main def main(durationString: String, text: String, others: String*): Unit =
@TonioGela
TonioGela / calico.scala
Created May 6, 2024 09:51
Calico web app to convert file in page
//> using scala 3.4.1
//> using platform js
//> using packaging.output main.js
//> using jsMode dev
//> using dep com.armanbilge::calico::0.2.2
import calico.IOWebApp
import calico.html.io.{*, given}
import cats.effect.*
import cats.syntax.all.*
@TonioGela
TonioGela / dev.toniogela.dotfiles.plist
Created May 6, 2024 09:48
Dotfiles persisting script launched by a launchd service (actually the launchd service is bugged, as it continuosly runs the script)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>Save dotfiles at every change</string>
<key>ProgramArguments</key>
<array>
@TonioGela
TonioGela / pdf.scala
Created May 6, 2024 09:41
How to create a simple pdf using a wrapper of a wrapper of a wrapper of a Java library with a strange licensing model
//> using scala 3.3.1
//> using dep com.github.librepdf:openpdf:1.3.33
//> using dep co.fs2::fs2-io::3.9.3
import cats.effect.*
import com.lowagie.text.*
import com.lowagie.text.pdf.PdfWriter
import com.lowagie.text.pdf.PdfPageEventHelper
import fs2.io.file.Files
import fs2.io.file.Path
@TonioGela
TonioGela / Excel.scala
Last active May 6, 2024 09:38
Autoderivation of typeclasses in Scala 3
//> using scala 3.4.0
//> using dep com.norbitltd::spoiwo::2.2.1
//> using dep org.typelevel::cats-core::2.10.0
//> using dep com.softwaremill.magnolia1_3::magnolia::1.3.4
import spoiwo.model.*
import spoiwo.natures.xlsx.Model2XlsxConversions.XlsxSheet
import cats.kernel.Monoid
import cats.syntax.all.*
import scala.compiletime.*
@TonioGela
TonioGela / stty.scala
Created November 13, 2023 08:40
Fancy JLine inspired way of handling single stdin keypresses on tty based terminals
//> using dep co.fs2::fs2-io::3.9.3
import fs2.*
import fs2.io.process.*
import cats.effect.*
import cats.syntax.all.*
import sun.misc.*
import cats.effect.std.Dispatcher
object Foo extends IOApp.Simple:
//> using scala "3.2.1"
//> using lib "com.monovore::decline-effect::2.4.1"
//> using lib "co.fs2::fs2-io::3.4.0"
//> using packaging.output "mkString"
//> using platform "scala-native"
//> using nativeMode "release-fast"
//> using nativeGc "none"
import cats.effect.*
import cats.effect.std.*