This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.myapp | |
import org.scalatra._ | |
import javax.servlet.ServletContext | |
/** | |
* This is the Scalatra bootstrap file. You can use it to mount servlets or | |
* filters. It's also a good place to put initialization code which needs to | |
* run at application start (e.g. database configurations), and init params. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.pickling._ | |
import json._ | |
object Test extends App { | |
val x = (new X).pickle | |
println(x) | |
x.unpickle[X] | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def memoize[T,U](fn: (T, T => U) => U) = { | |
var map = HashMap.empty[T,U] | |
def memoedFn(t: T): U = { map.getOrElseUpdate(t, fn(t, memoedFn)) } | |
memoedFn _ | |
} | |
val memoedFib = memoize((i: Long, rec: Long => Long) => i match { case x @ (0|1) => x; case x => rec(x-1) + rec(x-2)}) | |
def time(fn: => Unit) = { | |
val start = System.currentTimeMillis() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.URI | |
import java.nio.file.{Files, Path, Paths} | |
val modPath = Paths.get(URI.create("jrt:/modules")) | |
def dig(p: Path): Unit = { | |
if(Files.isDirectory(p)) { | |
Files.list(p).forEach(dig) | |
} else { | |
println(p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{ByteArrayOutputStream, PrintWriter} | |
import java.util.spi.ToolProvider | |
enablePlugins(JavaAppPackaging) | |
//this allows us to run tools like jdeps and jlink from within the JVM | |
def runTool(name: String, arguments: Seq[String]): Either[String,String] = { | |
val maybeTool: Option[ToolProvider] = { | |
val _tool = ToolProvider.findFirst(name) | |
if(_tool.isPresent) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio._ | |
import zio.stream._ | |
import scala.scalanative.unsafe._ | |
import scala.scalanative.posix.unistd.{ | |
fork, | |
vfork, | |
pipe, | |
close, | |
dup2, | |
STDIN_FILENO, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
opaque type Option[T] = T | Null | |
object Option: | |
def apply[T](t: T): Option[T] = t | |
def None: Option[Nothing] = null | |
extension [T](t: Option[T]) | |
def map[U](fn: T => U): Option[U] = | |
if t == null then None else fn(t.asInstanceOf[T]) | |
def flatMap[U](fn: T => Option[U]): Option[U] = if t == null then None else fn(t.asInstanceOf[T]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.hammons.slinc.scripts | |
import bleep.rewrites.BuildRewrite | |
import bleep.model.BuildRewriteName | |
import bleep.model.Build | |
import bleep.model.CrossProjectName | |
import bleep.model.Project | |
import bleep.model.Options | |
import bleep.PathOps | |
import java.nio.file.Paths |