Skip to content

Instantly share code, notes, and snippets.

View gakuzzzz's full-sized avatar

Manabu Nakamura gakuzzzz

View GitHub Profile
@gakuzzzz
gakuzzzz / file.md
Last active November 23, 2024 08:11
UserId など値型はどうするべきか

UserId などの型はどうするべきか

1. primitive 型をそのまま使う

case class Person(id: Long, name: String, organizationId: Long)
object Person {

  def groupByOrg: Map[Long, Seq[Person]] = ...
def doAction6 = Action { implicit req =>
(for {
_ <- authorizeHeaders(req.headers) \/> BadRequest("Unauthorized request")
json <- req.body.asJson \/> BadRequest("Wrong POST body")
user <- validateJson(json) \/> BadRequest("Invalid JSON")
} yield {
doSomething(user)
Ok("Success")
}).merge
}
@gakuzzzz
gakuzzzz / lens.md
Last active August 29, 2015 14:22
Lens&Prism勉強会

!SLIDE

Lens の説明

Lens & Prism 勉強会 2015/05/30

!SLIDE

自己紹介

@gakuzzzz
gakuzzzz / Hoge.java
Last active August 29, 2015 14:19 — forked from tokuhirom/Hoge.java
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Map.Entry;
import java.util.Map;
import java.util.stream.Stream;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.counting;
@gakuzzzz
gakuzzzz / note.md
Last active August 29, 2015 14:17
Scalaでランク2多相がほげほげ という話
@gakuzzzz
gakuzzzz / REPL.scala
Created March 3, 2015 17:58
Option.apply の使いどころ
scala> val f: (Option[Int], Int) => Option[Int] = _ orElse Some(_)
f: (Option[Int], Int) => Option[Int] = <function2>
scala> val seq: Seq[Int] = Seq(1,2,3)
seq: Seq[Int] = List(1, 2, 3)
scala> seq.foldLeft(Some(0))(f)
<console>:10: error: type mismatch;
found : (Option[Int], Int) => Option[Int]
required: (Some[Int], Int) => Some[Int]
@gakuzzzz
gakuzzzz / ci.md
Created February 24, 2015 11:59
CI サービス比較
機能\サービス Travis CI Circle CI Shippable Wercker BuildHive
Private Repo 有料 無料 無料 無料
@gakuzzzz
gakuzzzz / hoge.md
Created December 19, 2014 15:11
doctest import
  /**
   * {{{
   * prop> import org.scalacheck.{Gen, Arbitrary}
   * prop> import org.scalacheck.Arbitrary._
   * prop> import foo.BarType
   * prop> val itemTypeGen = Gen.oneOf(BarType.values)
   * prop> implicit val barTypeArbitrary = Arbitrary(barTypeGen)
   * prop> (i: Int, t: BarType) => i > 10
   * }}}
@gakuzzzz
gakuzzzz / fooo.txt
Created December 18, 2014 05:21
MalformedInputException
[fooo] $ test
[info] Compiling 1 Scala source to C:\Users\ma-nakamura\workspace\fooo\target\scala-2.11\classes...
[trace] Stack trace suppressed: run last *:doctestGenTests for the full output.
[error] (*:doctestGenTests) java.nio.charset.MalformedInputException: Input length = 1
[error] Total time: 5 s, completed 2014/12/18 14:06:38
[fooo] $ test
@gakuzzzz
gakuzzzz / play2-auth-social-sample.md
Last active August 29, 2015 14:11
play2-auth で OpenID とか Twitter OAuth とか OAuth2.0 とか

play2-auth で OpenID とか Twitter OAuth とか OAuth2.0 とか

この記事は Scala Advent Calendar 2014 の 12日目です。

昨日は @tototoshi さんの sbt でファイル変更をフックしてコンソールをクリアしつつコンパイルする でした。

明日は @qtamaki さんの 「関数プログラミング 珠玉のアルゴリズムデザイン」をScalaで実装してみる です。

というわけで play2-auth で OpenID とか Twitter OAuth とか OAuth2.0 とかをやるサンプルを作ってみたのですが、だいぶ時間切れになりました。