Skip to content

Instantly share code, notes, and snippets.

xuwei-k /
Created September 19, 2021 03:40 — forked from xavdid/
Python script to find ENV_VAR keys on your travis projects
import argparse
import os
from math import ceil
from typing import List
import requests
from requests import HTTPError
except ImportError:
print("This script uses the `requests` package")
View Sbt0_13BuildSyntax.scala
package sbt
package internal
package fix
import scalafix.v1._
import scala.meta._
class Sbt0_13BuildSyntax extends SyntacticRule("Sbt0_13BuildSyntax") {
private def maybeOldSyntax(tree: Tree): Boolean = {
tree match {
xuwei-k /
Created December 23, 2020 12:43 — forked from mala/



  • この文章と、それに含まれる考察や各サービスへの脆弱性報告などはmala個人の活動であり、所属している企業とは関係ありません。
  • 一方で私は、企業が閲覧履歴を収集して何をしたいのか、所属してる企業や他社事例について、ある程度詳しい当事者でもあります。
  • 一般論として書けることは書けるが、(業務上知り得た知識で開示されてないものなど)個別具体的なことは書けないこともあり、また観測範囲に偏りがある可能性もあります。



Proposed Cross-Publication Guidelines

What follows is my opinion on how we should tame all of this complexity. Specifically, how can we make it as easy as possible to keep everyone's builds and releases in-sync with the latest Dotty as we approach Scala 3. This is a very complex undertaking with a lot of moving parts. I'm attempting to draw on our experience doing this for prior Scala 2 versions, as well as personal scars from previous upgrade efforts across various Scala versions. In other words, this is a bit of a "lessons learned" phrased as "please everyone do this".

Any projects I have any control over will be following these steps to the best of our ability.

1. Cross-Publish Your Latest for Two Scala 3 Milestones

Breaking upgrades are always much easier when you can break them apart into the smallest possible steps. Publishing for the previous Scala 3 release in addition to the latest one is a very easy thing to do (since your library was already building on that version!) and it eases the

xuwei-k /
Created October 13, 2020 23:29 — forked from AlainODea/
Exception in thread "main" java.lang.NoSuchMethodError: java.util.concurrent.ConcurrentHashMap.keySet()Ljava/util/concurrent/ConcurrentHashMap$KeySetView;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class HelloCovariance {
public static void main(String[] args) {
ConcurrentHashMap<String, String> properties = new ConcurrentHashMap<>();
Set<String> keySet = properties.keySet();
xuwei-k /
Created October 13, 2020 08:06 — forked from gregberns/
The Algebra of Algebraic Data Types, Part 1, by Chris Taylor

Principled Meta Programming for Scala

This note outlines a principled way to meta-programming in Scala. It tries to combine the best ideas from LMS and Scala macros in a minimalistic design.

  • LMS: Types matter. Inputs, outputs and transformations should all be statically typed.

  • Macros: Quotations are ultimately more easy to deal with than implicit-based type-lifting

  • LMS: Some of the most interesting and powerful applications of meta-programming

View ExpandPolymorphicLambdas.scala
import scalafix.v1.{Patch, SyntacticDocument, SyntacticRule}
import scala.meta.{Name, Term, Transformer, Tree, Type, XtensionQuasiquoteType}
class ExpandPolymorphicLambdas extends SyntacticRule("ExpandPolymorphicLambdas") {
override def description: String = "Expand kind-projector's syntax for polymorphic lambda values"
override def isLinter: Boolean = false
private def replacePlaceholder(tree: Term, param: Term.Name): Option[Term] = tree match {
case Term.Select(Term.Placeholder(), method) => Some(Term.Select(param, method))
case Term.Select(select @ Term.Select(_, _), method) =>
xuwei-k / dotty_list.scala
Created January 12, 2020 13:43 — forked from johnynek/dotty_list.scala
Implementation of linked list using dotty features (opaque type, union types, extension methods, type lambda).
View dotty_list.scala
// unfortunately
// opaque type Fix[F[_]] = F[Fix[F]]
// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOf
object FixImpl {
type Fix[F[_]]
inline def fix[F[_]](f: F[Fix[F]]): Fix[F] = f.asInstanceOf[Fix[F]]
inline def unfix[F[_]](f: Fix[F]): F[Fix[F]] = f.asInstanceOf[F[Fix[F]]]
xuwei-k / RuntimeUtils.scala
Created October 14, 2019 08:33 — 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);