Skip to content

Instantly share code, notes, and snippets.

kenji yoshida xuwei-k

Block or report user

Report or block xuwei-k

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
xuwei-k / RuntimeUtils.scala
Created Oct 14, 2019 — forked from jvican/RuntimeUtils.scala
Some Scala code that uses Java APIs present in tools.jar (only JDKs) to programmatically produce a jstack-like thread dump. Useful to debug application and test deadlocks.
View RuntimeUtils.scala
object RuntimeUtils {
def requestThreadDump: String = {
// Get the PID of the current JVM process
val selfName =
val selfPid = selfName.substring(0, selfName.indexOf('@'))
// Attach to the VM
val vm = VirtualMachine.attach(selfPid);
xuwei-k /
Last active Oct 14, 2019


  • sbt-sonatypeのversion 3.8時点の話
  • 最近のsbt-sonatypeは、一旦全部ローカルの特定のディレクトリにjarやpomをpublishして、それをまとめてuploadするという、bundle releaseという方式が導入された
  • sonatypeBundleDirectoryはその際のディレクトリのためのSetting Key
  • "まとめてupload" なので、もちろん基本的には、一つのディレクトリに全部一旦publishして、1回だけuploadするのが通常の使い方として想定されているはず
  • (なぜか同名の未使用のTaskKeyが定義されているが?)sonatypeBundleReleaseはcommandとして定義されている
  • SettingKeyやTaskKeyは、sub project毎に違う値や動作を持てる。一方Commandは、(単純に言えば)指定されたものを順次sbtのconsoleから実行するイメージに近い
  • versionもSettingKey
  • つまり、sonatypeBundleDirectoryの値は、versionを使って定義されているが、sub project毎にversionが違えば、sonatypeBundleDirectoryの値も異なることになるはず
View Main.scala
package example
case class IO[A](private val run: () => A) {
def unsafeRun(): A = run()
def map[B](f: A => B): IO[B] = IO(() => f(run()))
def flatMap[B](f: A => IO[B]): IO[B] = IO(() => f(run()).run())
case class Ref[A](private var value: A) {
def get: IO[A] = IO(() => value)
View CatsRefUnsafeExample.scala
package example
import cats.effect.concurrent.Ref
import cats.effect._
import cats.syntax.traverse._
import cats.instances.list._
object CatsRefUnsafeExample extends IOApp {
override def run(args: List[String]) = {
View runAll.sbt
val runAll = taskKey[Unit]("run all main")
def runAllIn(config: Configuration) = {
runAll in config := {
val r = (runner in run).value
val classpath = (fullClasspath in config).value
val log = streams.value.log
(discoveredMainClasses in config).value.foreach(c =>
xuwei-k / scala_2.13.1_binary_incompatibilities.txt
Created Sep 18, 2019
Scala 2.13.0 => 2.13.1 binary incompatibilities
View scala_2.13.1_binary_incompatibilities.txt
* abstract method result(scala.concurrent.duration.Duration,scala.concurrent.CanAwait)java.lang.Object in interface scala.concurrent.Awaitable has a different signature in current version, where it is (Lscala/concurrent/duration/Duration;Lscala/concurrent/CanAwait;)TT;^Ljava/util/concurrent/TimeoutException;^Ljava/lang/InterruptedException; rather than (Lscala/concurrent/duration/Duration;Lscala/concurrent/CanAwait;)TT;^Ljava/lang/Exception;
filter with: ProblemFilters.exclude[IncompatibleSignatureProblem]("scala.concurrent.Awaitable.result")
* static method result(scala.concurrent.Awaitable,scala.concurrent.duration.Duration)java.lang.Object in class scala.concurrent.Await has a different signature in current version, where it is <T:Ljava/lang/Object;>(Lscala/concurrent/Awaitable<TT;>;Lscala/concurrent/duration/Duration;)TT;^Ljava/util/concurrent/TimeoutException;^Ljava/lang/InterruptedException; rather than <T:Ljava/lang/Object;>(Lscala/concurrent/Awaitable<TT;>;Lscala/concurrent/duration/Duration;)TT;
View A.javap
Classfile /Users/kenji/structural-subtype-javap/A.class
Last modified Aug 12, 2019; size 2453 bytes
MD5 checksum dc2e1948b339005c82b1948b25e9356f
Compiled from "A.scala"
public class A
minor version: 0
major version: 52
Constant pool:
#1 = Utf8 A
xuwei-k / A.javap
Created Aug 11, 2019
Boolean + String
View A.javap
Classfile /Users/kenji/boolean-plus-string/A.class
Last modified Aug 11, 2019; size 1859 bytes
MD5 checksum 45a441997ea15f8a84c80f23f1f0bfe1
Compiled from "A.scala"
public class A
minor version: 0
major version: 52
Constant pool:
#1 = Utf8 A
View replace-symbol-literal-global-build.sbt
val Scalafix = "Scalafix"
val removeCommand = "removeTemporaryScalafix"
def tempPluginDotSbtFile (base: File) =
base / "project" / ("temporaryScalafix.sbt")
xuwei-k / InjectorOps.scala
Last active Jul 29, 2019
guice TypeLiteral macro in Scala
View InjectorOps.scala
package scala_guice_macro
import scala.reflect.macros.blackbox
import scala.language.experimental.macros
object InjectorOps {
implicit def toInjectorOps(i: Injector): InjectorOps = new InjectorOps(i)
You can’t perform that action at this time.