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
xuwei-k / big3.scala
Created May 29, 2019 — forked from mpilquist/big3.scala
Example encoding of Functor / Applicative / Monad using dotty 0.15
View big3.scala
/* Example of encoding Functor/Applicative/Monad from cats with Dotty 0.15 features.
* Derived in part from Cats -- see https://github.com/typelevel/cats/blob/master/COPYING for full license & copyright.
*/
package structures
import scala.annotation._
trait Functor[F[_]] {
def (fa: F[A]) map[A, B](f: A => B): F[B]
def (fa: F[A]) as[A, B](b: B): F[B] =
View A.java
import java.util.Arrays;
public class A {
public class B {
public class C1 {
public C1(int a1) {}
}
public class C2 {
public C2(String a1) {}
@xuwei-k
xuwei-k / Main.scala
Last active May 21, 2019
getGenericParameterTypes Scala 2.13.0-RC2
View Main.scala
object A {
trait B {
// include outer param in getGenericParameterTypes
case class C1(a1: Int)
case class C2(a1: String)
case class C3(a1: Array[Int])
// NOT include outer
case class C4(a1: Option[Int])
case class C5(a1: List[Int])
View Main.scala
object A {
trait B {
case class C(a1: Int, a2: Option[Int])
}
object D extends B
}
object Main {
def main(args: Array[String]): Unit = {
@xuwei-k
xuwei-k / error.txt
Created May 16, 2019
sbt 1.3.0-RC1 "Session not initialized" error
View error.txt
[error] java.lang.RuntimeException: Session not initialized.
[error] at scala.sys.package$.error(package.scala:30)
[error] at sbt.Project$.$anonfun$getOrError$1(Project.scala:441)
[error] at scala.Option.getOrElse(Option.scala:138)
[error] at sbt.Project$.getOrError(Project.scala:441)
[error] at sbt.Project$.session(Project.scala:447)
[error] at sbt.Project$.extract(Project.scala:452)
[error] at sbt.BuiltinCommands$.$anonfun$setParser$1(Main.scala:602)
[error] at sbt.Command$.$anonfun$applyEffect$3(Command.scala:144)
[error] at sbt.Command$.$anonfun$argParser$1(Command.scala:165)
View replace-unicode-arrows.sh
find . -name "*.scala" -exec perl -i -pe 's/⇒/=>/g' {} \;
find . -name "*.scala" -exec perl -i -pe 's/→/->/g' {} \;
find . -name "*.scala" -exec perl -i -pe 's/←/<-/g' {} \;
git commit -am "avoid deprecated unicode arrow chars
https://github.com/scala/scala/commit/9e264483d04f48513f3a82e91365667f01a2f5f3"
View sonatype-releases.md

自分もどこまで正確に把握しているのが怪しいが、知ってる限りの情報を書いておくと

  • 基本的にsonatypeのreleasesとmaven centralは同じものがあるだけ(以下に例外を書いてる)
  • 運営元も同じ
  • 基本的に最近はsonatypeを経由してmaven centralにpublishする
  • 一部例外的にapacheのものや、古いgoogleのもの(例: protobuf)で、"maven centralに存在するがsonatypeのreleasesには存在しない"ものがあった
    • 何らかの歴史的経緯か、特別扱いにより、sonatypeのreleasesを経由してmaven centralにpublishしてない
  • sonatypeのreleasesにpublishされてもmaven centralに同期するのに時間がかかっていた(平均1時間前後?速いと数分。遅いと1日近く)
  • "大抵のものはsonatypeを経由してpublishする" かつ、上記の "同期するのに時間がかかる" ということにより、sonatypeのreleasesのresolverを追加しておくと、publishされたばかりのものについて、maven centalに同期を待たないですぐ取得できる、というメリットだけあった
  • 同期が遅れている、という要因以外で、その逆の "sonatypeのreleasesに存在するがmaven centalには存在しない" というものはなかったはず
View gist:ca5aa8c269c4b51418ef689a3a277148
[error] GC overhead limit exceeded
[error] java.util.Arrays.copyOf(Arrays.java:3332)
[error] java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
[error] java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
[error] java.lang.StringBuilder.append(StringBuilder.java:202)
[error] scala.collection.mutable.StringBuilder.append(StringBuilder.scala:266)
[error] scala.collection.mutable.StringBuilder.$plus$eq(StringBuilder.scala:174)
[error] scala.collection.mutable.StringBuilder.$plus$eq(StringBuilder.scala:30)
[error] scala.collection.generic.Growable.$anonfun$$plus$plus$eq$1(Growable.scala:58)
[error] scala.collection.generic.Growable$$Lambda$47/1002021887.apply(Unknown Source)
@xuwei-k
xuwei-k / scalatest_3.0.5-3.0.6.txt
Created Mar 2, 2019
scalatest binary compatibility
View scalatest_3.0.5-3.0.6.txt
class org.scalatest.InsertionOrderSet is declared final in scalatest_2.12-3.0.6.jar version
class org.scalatest.easymock.EasyMockSugar#MockObjects does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.jmock.JMockCycle does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.jmock.JMockExpectations does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.JUnit3Suite does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.JUnitRunner does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.JUnitSuite does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.JUnitTestFailedError does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.JUnitWrapperSuite does not have a correspondent in scalatest_2.12-3.0.6.jar version
class org.scalatest.junit.MyRunListener does not have a correspo
View gist:ebee7db618dd115871dbba94a725bc60
scala -Ywarn-adapted-args -language:_
Welcome to Scala 2.12.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_192).
Type in expressions for evaluation. Or try :help.
scala> def printInt(i: Int) = println(i)
printInt: (i: Int)Unit
scala> implicit def toOneInt(is: (Int, Int)): Int = is._1 + is._2
toOneInt: (is: (Int, Int))Int
You can’t perform that action at this time.