2020-01-01から1年間の記事一覧

OculusQuest + Unity 2019.3以降でのVulkan APIについて

Unity 2019.3以降でのビルド時に以下エラーがでる BuildFailedException: The Vulkan Graphics API does not support XR in your configuration. To use Vulkan, you must use Unity 2019.3 or newer, and the XR Plugin Management. OVRGradleGeneration.On…

PartialFunction

specs2のAnyMatchers#beLikeを使ってみようと思ったらPartialFunctionなるものがでてきたので調べた /** matches if the value returns a successful result when applied to a PartialFunction */ def beLike[T](pattern: PartialFunction[T, MatchResult[_…

beLike

/** matches if the value returns a successful result when applied to a PartialFunction */ def beLike[T](pattern: PartialFunction[T, MatchResult[_]]) = new Matcher[T] { def apply[S

calss A @Inject() ( val hoge: Hoge ) extends B { ... } trait B { val hoge: Hoge ... }

Oculus Quest + Unity セットアップ

Unity Hubをインストール Unity Hub Macはbrewでこちらをunity-hub ライセンス認証 環境設定 -> ライセンス管理 -> 手動で認証 -> ライセンスリクエストを保存 から任意の場所にアクティベーションファイルを保存する 保存したらURLから認証ページへとんで認…

https://www.playframework.com/documentation/ja/2.2.x/ScalaJsonCombinators

implicit

Tech Tips: Scala: implicit の使い方

Object.keys()

Object.keys(obj).forEach((key) -> { let param = obj[key]; ... } Object.keys() - JavaScript | MDN

りふぁくた fold => emap

この指摘2回目では・・・・ foldでかくと Future.successful(Option(1)).flatMap(fold(Future.failed(new Exception("e")))(v => Future.successful(v))) scalaz Future.successful(Option(1)) emap (_ \/> new Exception("e")) うーんなぁ・・・ぐやじぃ …

tech.recruit-mp.co.jp

recursive value xxx needs type

case class Hoge(opt: Int) val hoge = Hoge(opt = 1) val opt = hoge コンパイル結果 [error] ~~~: recursive value hoge needs type [error] val opt = hoge 型推論こわしてるっぽいが、、、 参考 scala / bug github.com sbt / sbt github.com いったんは…

specs2 ExceptionMatchers#throwAが予期せぬ挙動をしたのでメモ

なかみ /** * @return a matcher checking the type of an Exception and its message (as a regexp) */ def throwA[E <: Throwable](message: String = ".*")(implicit m: ClassTag[E]): Matcher[Any] = { throwA(m).like { case e: Throwable => createExpectable(e.getMessage.notNull).applyMatcher(BeMatching.withPart(m…</:>

おまけくりかえし

閏年のおまけのやっつけくりかえし scala> :paste // Entering paste mode (ctrl-D to finish) val date = new LocalDate(2019,12,31) val date_1 = date.minusMonths(12) val minus = (date: LocalDate) => { date.minusMonths(1) } val retry: (LocalDate …

閏年

scala> :paste // Entering paste mode (ctrl-D to finish) val date = new LocalDate val date_1 = date.minusYears(1).plusDays(2) val date_2 = date.plusDays(2).minusYears(1) // Exiting paste mode, now interpreting. date: org.joda.time.LocalDate…

singletoonオブジェクトでの初歩的なミス

これなー。。。うん @Singleton class Hoge () { ... lazy val currentDate = DateTime.now }

MockWsでURIを検証する

github.com

Scalazを用いた安全なString->Int変換

import import scalaz.syntax.std.string._ val i: Option[String] = "12345".parseInt.toOption final class StringOps(val self: String) extends AnyVal { ... def parseInt: Validation[NumberFormatException, Int] = s.parseInt(self)

akka.pattern.RetrySupport

さんぷるのりとらい def retry[T](f: => Future[T]): Future[T] = { @tailrec def retry0(errors: List[Throwable], f: => Future[T]): Future[T] = { f.recoverWith { case e => run(e :: errors, f) } } run(Nil, f) } 末尾再帰になってない Future非同期…

Tuple

scala> :paste // Entering paste mode (ctrl-D to finish) val t1 = (1, 2) val t2 = 1 -> 2 val t3 = 1 → 2 val t4 = Tuple2(1,2) val t5 = Pair(1, 2) val t6 = Triple(1, 2, 3) // Exiting paste mode, now interpreting. <pastie>:15: warning: object Pair in </pastie>…

Mapができるまで

scalaパッケージ配下にいるMapたち package 共通 scala.collection 不変 scala.collection.immutable 可変 scala.collection.mutable scala> :paste // Entering paste mode (ctrl-D to finish) val im = Map("a" -> "A") // Exiting paste mode, now interp…

値渡し、無名関数、関数渡し

// docs // https://docs.scala-lang.org/tour/by-name-parameters.html def f0[T](f: T): T = f //値渡し def f1[T](f: => T): T = f //名前渡し def f2[T](f: () => T): T = f() //Function0 def f3[T](f: Function0[T]): T = f() //Function0 「名前渡し…

type

エイリアスをはれる type A = a.b.c.A val a: A = A() Cのtypedefみたいな。