Skip to content

Instantly share code, notes, and snippets.

@suzuki-hoge
suzuki-hoge / README.md
Last active February 21, 2018 14:57
chunked executor (tmp)

chunked executor

まだ雑だけどそのうちもう少し整える

データが複数件書いてあるファイルパスを受け取り、それに対して任意の変換と処理を行うスクリプトがあるとする。それを複数サイズに分割して実行したい。
負荷のために分割をしたり、ひとまず先頭だけを流して結果を検証したりしたいため。

本来やりたいこと

  • 国際電話番号とステータスがあるとする
@suzuki-hoge
suzuki-hoge / README.md
Created February 21, 2018 13:08
ruby for pythonista
  • file io
  • map
  • filter
  • strip
  • slice
  • join
  • split
  • format
  • sys.args
  • arg parse
@suzuki-hoge
suzuki-hoge / README.md
Created January 8, 2018 14:40
タブ
  • タブ
  • 順番
  • 多い奴は遅い
  • AppBP
  • いちいち開く方が意識する
  • 午後使うのは別Windowで

  • Issue/PR
  • Service/Repository

  • gl gh
  • tl th
  • a, i, s, t, f 系 -> h, i, j, k
  • o, p, x 系 -> u
  • prefix をまとめる space

お題概要

とある会員と契約を管理するシステムを実現します。

会員はモバイル回線と固定回線をそれぞれ最大1つ持つことが出来ます。 (固定回線は今回は登場しません)

モバイル回線には最大1つの音声オプションが付き、 音声オプションには最大1つの留守番電話オプションが付きます。

以上のデータ構成を前提として、以下の要求を実現します。

もっともっと Either

flatMapforを作る

意図

  • flatMapで更にmap系の訓練をする
  • Eitherを実用する際は複数のEitherを組み合わせて初めて真価を発揮することを知る
  • forの存在を知る

お題

フォームのバリデーションをEitherを使って実装する

class EitherTest extends Specification {
// テスト準備
Either<String, Integer> r = Either.right(5)
Either<String, Integer> l = Either.left('parse error')
enum ResultType {
EVEN, ODD, PARSE_ERROR, RANGE_ERROR
}
class MoreResultTest extends Specification {
private static Result result = new Result(
Parser.parse(ParserTest.bobio)
)
def test_enum() {
expect:
result.as('status', { it == '1' ? Status.OK : Status.NG }) == Status.OK
}