Skip to content

Instantly share code, notes, and snippets.

seraph seraphr

Block or report user

Report or block seraphr

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
@seraphr
seraphr / build.sbt
Created Feb 7, 2019
sbt all command
View build.sbt
val dockerPublish = taskKey[Unit]("ダミーのタスク。本来sbt-native-packagerのやつ")
lazy val commonSettings = Def.settings(
dockerPublish := {
import java.time.LocalTime
println(s"${LocalTime.now()} ${name.value} のpublish開始")
// 並列で実行されるのがわかりやすいように、途中sleepする
Thread.sleep(3000)
println(s"${LocalTime.now()} ${name.value} のpublish終了")
}
View implicit.repl
> scala -Xlog-implicits
Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172).
Type in expressions for evaluation. Or try :help.
scala> object A {
| import scala.language.implicitConversions
| implicit val int: Int = 1
| def a[A]: A = ???
| implicit def asString[A](implicit i: Int): Long => A = _ => a[A]
|
@seraphr
seraphr / this.type
Created Nov 13, 2017
scala this.type
View this.type
scala> class Hoge {
| def m1: this.type = this // OK
| def m2: this.type = new Hoge // NG
| }
<console>:9: error: type mismatch;
found : Hoge
required: Hoge.this.type
def m2: this.type = new Hoge // NG
@seraphr
seraphr / fav0100.txt
Last active Jun 7, 2017
なろう小説(ポイント / ブックマーク)順
View fav0100.txt
2017/06/08 06:49
ブックマーク数100以上
連載中
文字数10万文字以上
all novel count = 30060
unique novel count = 12320
filtered novel count = 2759
順位 URL 文字数 ポイント評価 ブックマーク数 (ポイント評価 / ブックマーク数) title keyword
View macro memo
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
/**
*/
object MethodsMacro {
def apply[T]: Seq[String] = macro genMethods[T]
def genMethods[T: c.WeakTypeTag](c: Context): c.Tree = {
View UseUpickle.scala
import upickle.{Js, Api}
trait UseUpickle {
val mJsonApi: upickle.Api
def write[T: mJsonApi.Writer](a: T): String = mJsonApi.write(a)
def writeHoge(aHoge: Hoge): String = {
import mJsonApi._
mJsonApi.write(aHoge)
@seraphr
seraphr / Structural.scala
Created Nov 29, 2013
scala 構造的部分型
View Structural.scala
trait Hoge{def hoge: String}
def h(a: Hoge) = a.hoge
val hogeInstance: Hoge = new Hoge{def hoge = "hoge"}
val hogeLikeInstance: {def hoge: String} = new {def hoge = "fuga"}
h(hogeInstance) // OK
h(hogeLikeInstance) // NG
@seraphr
seraphr / 00readme
Last active Dec 24, 2015
Generics使って実装したGraph
View 00readme
Generics使って実装したGraph
TypeMember版 https://gist.github.com/seraphr/6858219
@seraphr
seraphr / 00readme
Last active Dec 24, 2015
TypeMember使って実装したGraph
View 00readme
TypeMember使って実装したGraph
generics版 https://gist.github.com/seraphr/6858351
@seraphr
seraphr / CanCompile.scala
Created Sep 26, 2013
Scalaのimplicitなものをimportした時のコンパイラの挙動が謎い。 仕様確認してないけど、仕様通りなの…? CompileErrorになるコードを2.8 / 2.9 で試してもコンパイルエラーだった。
View CanCompile.scala
// Implicitを上に書くとコンパイルできる
object Implicits {
implicit val v = 10
}
object ImplicitTest {
import Implicits._
def main(args: Array[String]): Unit = {
You can’t perform that action at this time.