Skip to content

Instantly share code, notes, and snippets.

View leszekgruchala's full-sized avatar

Leszek Gruchała leszekgruchala

View GitHub Profile
@MaximilianoFelice
MaximilianoFelice / builder-phantom-types.scala
Last active January 9, 2025 21:26
A Builder example in Scala using Phantom Types
case class Food(ingredients: Seq[String])
class Chef[Pizza <: Chef.Pizza] protected (ingredients: Seq[String]) {
import Chef.Pizza._
def addCheese(cheeseType: String): Chef[Pizza with Cheese] = Chef(ingredients :+ cheeseType)
def addTopping(toppingType: String): Chef[Pizza with Topping] = Chef(ingredients :+ toppingType)
def addDough: Chef[Pizza with Dough] = Chef(ingredients :+ "dough")
@fredericrous
fredericrous / pipeline.gdsl
Last active September 11, 2019 09:39 — forked from ggarcia24/pipeline.gdsl
GDSL supporting pipeline declarative
//The global script scope
def ctx = context(scope: scriptScope())
//What things can be on the script scope
contributor(ctx) {
method(name: 'pipeline', type: 'Object', params: [body: Closure])
property(name: 'params', type: 'org.jenkinsci.plugins.workflow.cps.ParamsVariable')
property(name: 'env', type: 'org.jenkinsci.plugins.workflow.cps.EnvActionImpl.Binder')
property(name: 'currentBuild', type: 'org.jenkinsci.plugins.workflow.cps.RunWrapperBinder')
property(name: 'scm', type: 'org.jenkinsci.plugins.workflow.multibranch.SCMVar')
@LGLO
LGLO / PingPong.scala
Created July 1, 2018 20:36
Ping app with Scalaz8 ZIO
import java.io.IOException
import scalaz.zio.console.putStrLn
import scalaz.zio.{IO, IOApp, IOQueue, Void}
import scala.concurrent.duration.Duration
sealed trait PongMessages
case class Ping(n: Int) extends PongMessages
case object Stop extends PongMessages
@gavvvr
gavvvr / visualvm-sdkman-osx.md
Last active May 19, 2023 01:59
Getting visualvm on OSX with SDKMAN!

UPDATE:

Now you can just install Liberica JDK pkg-distibution using brew and will never face the problem mentioned below:

brew tap bell-sw/liberica
brew cask install liberica-jdk11

@johnynek
johnynek / typed_record.scala
Created June 25, 2021 19:05
An example of zero cost addition of types on top of `Map[String, Any]` to model generic records in scala 3
package example
object RecMap {
object Record {
// use this scope to bound who can see inside the opaque type
opaque type Rec[A <: Tuple] = Map[String, Any]
object Rec {
type HasKey[A <: Tuple, K] =
@bilal-fazlani
bilal-fazlani / build.sbt
Created May 26, 2022 17:59
SBT - Reference local sbt project as dependency
lazy val other = ProjectRef(file("../../../my-other-project"), "otherSubProjectName")
lazy val myProject = project
.in(file("./my-project"))
.dependsOn(other)