Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
xuwei-k / 11
Last active September 22, 2023 07:48
public java.lang.String x(java.lang.String);
descriptor: (Ljava/lang/String;)Ljava/lang/String;
flags: (0x0001) ACC_PUBLIC
Code:
stack=1, locals=2, args_size=2
0: aload_1
1: invokedynamic #27, 0 // InvokeDynamic #0:makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;
6: areturn
@xuwei-k
xuwei-k / FunctorPolyFunction.scala
Created July 29, 2023 01:39
impl Functor use PolyFunction
package example
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
object Functor {
def fromPolyFunction[F[_]](x: [A, B] => (fa: F[A]) => (f: A => B) => F[B]): Functor[F] =
new Functor[F] {
def map[A, B](fa: F[A])(f: A => B): F[B] = x(fa)(f)
scalaVersion := "3.3.0"
libraryDependencies += "org.openjdk.jol" % "jol-core" % "0.17"
@xuwei-k
xuwei-k / Main.scala
Last active October 5, 2023 22:27
playframework Scala 3 hello world
import play.api.BuiltInComponents
import play.api.Mode
import play.api.mvc._
import play.api.routing._
import play.api.routing.sird._
import play.core.server.NettyServer
import play.core.server.ServerConfig
object Main {
// 1つのScalaファイルで済むので、
package a {
object X
package b {
object Y
}
}
package b {
object Z
# checkoutその他は省略
- run: sbt compileなどの他のタスク色々 writeExternalDependencies
- name: upload dependencies.txt
if: github.event_name == 'push'
run: |
# いい感じにuploadとdownloadできれば、
# github actionsのartifactでもなんでも良い。
# 最近某所ではS3の方が便利というか楽なので、それ使ったりもしているので、その場合の例
aws s3 cp target/dependencies.txt s3://適当なURI/${{github.ref_name}}/dependencies.txt
- id: get_previous_dependencies
commands += {
def getProjects(s: State): Seq[String] = {
val extracted = Project.extract(s)
val currentBuildUri = extracted.currentRef.build
val buildStructure = extracted.structure
val buildUnitsMap = buildStructure.units
val currentBuildUnit = buildUnitsMap(currentBuildUri)
val projectsMap = currentBuildUnit.defined
projectsMap.values.map(_.id).toVector
}
trait Functor[F[_]]
def map [A, B](fa: F[A])(f: A => B ): F[B]
trait Applicative[F[_]]
def ap [A, B](fa: F[A])(f: F[A => B]): F[B]
trait Monad[F[_]]
def bind [A, B](fa: F[A])(f: A => F[B]): F[B]
trait Contravariant[F[_]]
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.18" exclude ("com.typesafe.play", "twirl-api_2.12"))
resolvers += Resolver.sbtPluginRepo("releases")
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(
@xuwei-k
xuwei-k / gist:eda3bcb11e919734069642486b91e4d0
Created October 21, 2022 08:42
Binary compatibility org.slf4j slf4j-api 1.7.36 2.0.3
* class org.slf4j.event.EventRecodingLogger does not have a correspondent in current version
filter with: ProblemFilters.exclude[MissingClassProblem]("org.slf4j.event.EventRecodingLogger")
* abstract method getMarker()org.slf4j.Marker in interface org.slf4j.event.LoggingEvent does not have a correspondent in current version
filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("org.slf4j.event.LoggingEvent.getMarker")
* abstract method getArguments()java.util.List in interface org.slf4j.event.LoggingEvent is present only in current version
filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.slf4j.event.LoggingEvent.getArguments")
* abstract method getMarkers()java.util.List in interface org.slf4j.event.LoggingEvent is present only in current version
filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("org.slf4j.event.LoggingEvent.getMarkers")
* abstract method getKeyValuePairs()java.util.List in interface org.slf4j.event.LoggingEvent is present only