Skip to content

Instantly share code, notes, and snippets.

View dependencySvg.sbt
import scala.sys.process.Process
Seq(Compile, Test).map { x =>
(x / TaskKey[File]("dependencySvg")) := {
val output = target.value / s"dependencies-${x.name}.svg"
Process(Seq(
"dot",
"-o" + output.getAbsolutePath,
"-Tsvg",
(x / sbt.plugins.DependencyTreeKeys.dependencyDot).value.getAbsolutePath
View scala-3-dependency-tree.txt
org.scala-lang:scala3-interfaces:3.0.1-RC1-bin-SNAPSHOT
org.scala-lang:scala3-library_3.0.0-RC2:3.0.1-RC1-bin-SNAPSHOT-nonbootstrapped..
org.scala-lang:tasty-core_3.0.0-RC2:3.0.1-RC1-bin-SNAPSHOT-nonbootstrapped
+-org.scala-lang:scala3-library_3.0.0-RC2:3.0.1-RC1-bin-SNAPSHOT-nonbootstra..
org.scala-lang:scala3-compiler_3.0.0-RC2:3.0.1-RC1-bin-SNAPSHOT-nonbootstrapped
+-org.jline:jline-reader:3.19.0
| +-org.jline:jline-terminal:3.19.0
|
+-org.jline:jline-terminal-jna:3.19.0
@xuwei-k
xuwei-k / holiday-scala-steward.yml
Created Apr 9, 2021
GitHub Actionsで祝日だったらcron実行をskipするサンプル
View holiday-scala-steward.yml
on:
schedule:
- cron: '0 0 * * *'
jobs:
scala-steward:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
@xuwei-k
xuwei-k / Converter.scala
Last active Apr 6, 2021
Google Cloud Functions with Scala unfiltered
View Converter.scala
package unfiltered_cloud_function
import com.google.cloud.functions.{HttpFunction, HttpRequest, HttpResponse}
import java.io.OutputStream
import scala.jdk.CollectionConverters._
import java.util.Collections
object Converter {
def request(req: HttpRequest): unfiltered.request.HttpRequest[HttpRequest] =
new unfiltered.request.HttpRequest[HttpRequest](req) {
View ZeroApplyScala3.scala
object ZeroApplyScala3 {
inline def tuple3[A1, A2, A3](a1: Option[A1], inline a2: Option[A2], inline a3: Option[A3]): Option[(A1, A2, A3)] =
if (a1.isEmpty) {
None
} else {
val x2 = a2
if(x2.isEmpty) {
None
View A.scala
class A {
println("scala 1 " + s)
val s = "hello"
println("scala 2 " + s)
}
View DirectoryAndPackageName.scala
package fix
import scalafix.Diagnostic
import scalafix.Patch
import scalafix.lint.LintSeverity
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import java.io.File
import java.nio.file.Path
import scala.meta.Pkg
@xuwei-k
xuwei-k / build.sbt
Created Mar 3, 2021
Apache Spark 3.2.0-20210303.014201-36
View build.sbt
scalaVersion := "2.13.5"
resolvers += "spark snapshot" at "https://repository.apache.org/content/repositories/snapshots"
val sparkVersion = "3.2.0-20210303.014201-36"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-mllib" % sparkVersion,
"org.apache.spark" %% "spark-repl" % sparkVersion,
View MatchTypeSort.scala
import scala.compiletime.ops.int._
sealed trait HList {
def ::[H](head: H): head.type :: this.type = new ::[head.type, this.type](head, this)
}
final case class ::[+H, +T <: HList](head: H, tail: T) extends HList
sealed trait HNil extends HList
case object HNil extends HNil
object MatchTypeSort {
View Main.scala
import scala.deriving.Mirror
import scala.compiletime.{erasedValue, summonInline}
object Macros {
inline def values[A](using inline A: Mirror.SumOf[A]): Values[A.MirroredElemTypes] =
summonValues[A.MirroredElemTypes]
type Values[T <: Tuple] <: Tuple = T match {
case EmptyTuple =>