- 更新
2021-05-23
- 作者
@voluntas
- バージョン
2021.1
- URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
val l = List(IO(println(1).asRight), IO(println(2).asRight), IO("foo".asLeft), IO(println(4).asRight)) | |
val io = l.foldLeft[IO[Either[String, Unit]]](IO(Right(())))((prev, next) => { | |
prev.flatMap({ | |
case Left(err) => IO(Left(err)) | |
case Right(_) => next | |
}) | |
}) |
著者: 青い鴉(ぶるくろ)さん @bluecrow2
これは結城浩さんの運用されていた YukiWiki に当時 Coffee 様 (青い鴉(ぶるくろ)さん)がかかれていた文章です。 ただ 2018 年 3 月 7 日に YukiWiki が運用停止したため消えてしまいました。その記事のバックアップです。
今は 404 ですが、もともとの記事の URL は http://www.hyuki.com/yukiwiki/wiki.cgi?%A5%C7%A5%B9%A5%DE%A1%BC%A5%C1%A4%AC%B5%AF%A4%AD%A4%EB%CD%FD%CD%B3 になります。
昔、自分がとても感銘を受けた文章なので、このまま読めなくなるのはとてももったいないと思い、バックアップとして公開しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Base64 encode | |
val text = "This is plaintext." | |
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes()) | |
// Base64 decode | |
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded)) | |
println(textDecoded) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Prerequirements | |
# brew install gcc (gmp libmpc mpfr isl) | |
# copy /usr/lib && /usr/include from arch linux into your CC_ROOT. | |
# /usr/local/linux/usr/include | |
# /usr/local/linux/usr/lib | |
# /usr/local/linux/usr/local/include | |
# arch linux is target enviroment for this cross compiler | |
# x86_64 binutils && gcc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
api "github.com/osrg/gobgp/api" | |
"github.com/osrg/gobgp/gobgp/cmd" | |
"github.com/osrg/gobgp/packet" | |
"github.com/satori/go.uuid" | |
"golang.org/x/net/context" | |
"google.golang.org/grpc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(unboxed_closures)] | |
#![feature(core)] | |
#![feature(io)] | |
use std::old_io::stdio::{stdin}; | |
use std::collections::HashMap; | |
// This is our toy state example. | |
#[derive(Debug)] | |
struct State { |
Moved to git repository: https://github.com/denji/golang-tls
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
- 基本は迷ったら trait にしておけば良いと思います
- trait は一つの class に複数 mixin できますが、class は一つしか継承できません
- つまり、trait であれば mixin される class を気にしなくてよいですが、 abstract class にした場合は、extends される class が他に継承したい物が無いか気にする必要があります
- trait はコンストラクタを持つ事ができませんが、abstract class はコンストラクタを持つ事ができます
- 従って、型引数に制約をつけたい時や、共通のフィールドの初期化などがある場合は、abstract class にすると楽な場合があります。
- 以下に具体例を示します。良くある Java の enum を Scala で定義する場合の例です。
NewerOlder