Skip to content

Instantly share code, notes, and snippets.

View NomadBlacky's full-sized avatar

Takumi Kadowaki NomadBlacky

View GitHub Profile
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@ val options = List(None, None, Some(1), None, Some(2))
options: List[Option[Int]] = List(None, None, Some(1), None, Some(2))
@ options.collectFirst {
case Some(v) => v
}
res4: Option[Int] = Some(1)
@NomadBlacky
NomadBlacky / foo.scala
Last active August 13, 2018 06:08
scala.reflect.ClassTag
@ def foo[T: scala.reflect.ClassTag](obj: Any): Unit = obj match {
case t: T => println(t.getClass.getName)
case _ => println("ng")
}
defined function foo
@ foo[Int](1)
java.lang.Integer
scala> val a = doc >> elements("rect") >> attrs("data-date")
a: Iterable[String] = List(2016-06-05, 2016-06-06, 2016-06-07, 2016-06-08, 2016-06-09, 2016-06-10, 2016-06-11, 2016-06-12, 2016-06-13, 2016-06-14, 2016-06-15, 2016-06-16, 2016-06-17, 2016-06-18, 2016-06-19, 2016-06-20, 2016-06-21, 2016-06-22, 2016-06-23, 2016-06-24, 2016-06-25, 2016-06-26, 2016-06-27, 2016-06-28, 2016-06-29, 2016-06-30, 2016-07-01, 2016-07-02, 2016-07-03, 2016-07-04, 2016-07-05, 2016-07-06, 2016-07-07, 2016-07-08, 2016-07-09, 2016-07-10, 2016-07-11, 2016-07-12, 2016-07-13, 2016-07-14, 2016-07-15, 2016-07-16, 2016-07-17, 2016-07-18, 2016-07-19, 2016-07-20, 2016-07-21, 2016-07-22, 2016-07-23, 2016-07-24, 2016-07-25, 2016-07-26, 2016-07-27, 2016-07-28, 2016-07-29, 2016-07-30, 2016-07-31, 2016-08-01, 2016-08-02, 2016-08-03, 2016-08-04, 2016-08-05, ...
scala> a.filter(_ == "2017-06-01")
res1: Iterable[String] = List(2017-06-01)
scala> doc >> elements("rect") >/~ validator(attr("data-date"))(_ == "2017-06-01")
res2: Either[Unit,net.ruip
scala> Some("a").map(_ == "a").getOrElse(false)
res5: Boolean = true
scala> Some("a").exists(_ == "a")
res6: Boolean = true
scala> Some("a").contains("a")
res7: Boolean = true
package org.nomadblacky.oreoretemplate
import xsbti.{ AppConfiguration, MainResult }
import scala.reflect.io.File
/**
* Created by blacky on 17/05/02.
*/
case class Config(variablesFile: File = File("variables"), templateDirectory: File = File("templates"))
@NomadBlacky
NomadBlacky / file0.txt
Last active September 28, 2016 06:48
【git】 authorを間違えてcommitした上で、pushしてしまった時の対処法と再発防止策 ref: http://qiita.com/NomadBlacky/items/51d39ab83e0118c0cd4a
$ git rebase -i 【間違えたコミットのひとつ前のコミット】