2018-01-01から1ヶ月間の記事一覧

Docker を支える Linux カーネル機能 Network Namespace から docker exec の実装が ip netns exec である雰囲気をつかむ

Linux の Network Namespace を ip netns exec で操作しているうちに「docker exec の正体」がなんとなく見えてきた。 Bridge Networking Deep Dive — Docker Kubernetes Lab 0.1 documentation デフォルトでは docker はコンテナの Network Namespace を見…

Disjunction と Either の違い

Safari Books Online で検索したところ、以下の記述が見つかった。 Disjunction is conceptually similar to Either, which can be used to represent one of two possible types. Disjunction is different from Either because its operations are right-b…

docker-machine で aws に docker 環境(docker host) を構築する

いままでメインの docker 環境は AWS EC2 上で curl -fsSL get.docker.com -o get-docker.sh && sudo sh get-docker.sh のように構築していたけれど、 docker-machine for AWS を使ったほうがいろいろ便利だった。 Amazon Web Services (AWS) EC2 example | …

Udemy の Learning Docker and Kubernetes by Lab がとてもよい

Docker 再入門として Learning Docker and Kubernetes by Lab | Udemy のコースを受講しているのだが、とてもよい。コンテナを支える Linux カーネルの機能として cgroups, Network Namespaces (Strorage(aufs), Security, Process Namespaces) の概要から、…

better-files を使用して複数ファイルの一括処理を書き直す

会社の Scala エキスパートから、better-fs, fs2 というライブラリを教えていただいたので書き直してみる。とても短くなりました。(^q^)。 GitHub - pathikrit/better-files: Simple, safe and intuitive Scala I/O ayakumo.hatenablog.com @ import better.…

読み解き PiS3: Higher Order Functions を使って複数ファイルの一括処理を行う

9.4 WRITING NEW CONTROL STRUCTURES を読んでいて、複数ファイルに対して「ファイルを開いて特定の処理を行う」ことができるはずと思って実装した。Scala でメソッドをメソッドの引数に取るのは HOF(Higher Order Functions) というらしい。 C でいう関数ポ…

Ammonite ではじめるすくすく Scala 生活

だいたい Ammonite に書いてある。Magic Imports はとてもありがたい。 インストール $ sudo curl -L -o /usr/local/bin/amm https://git.io/vdNv2 && sudo chmod +x /usr/local/bin/amm && amm REPL として使う $ amm (... snip the greeting message ...) …

Ammonite を使用してお手軽に Scala のスクリプトを書く

sbt は優秀なツールだけれども、さくっと Scala のスクリプトを書くには Ammonite のほうがお気に入り。シェルからは -c オプションで気軽に Scala をスクリプトとして実行可能。 $ amm -c 'import scala.io.Source; val file = Source.fromFile("/home/kyag…

シングルトンオブジェクトを IntelliJ の Scala Worksheet で確認する

Singleton objects are sort of a shorthand for defining a single-use class, which can’t directly be instantiated, and a val member at the point of definition of the object, with the same name. Indeed, like vals, singleton objects can be def…

読み解き PiS3: ケースシーケンスの実体は関数リテラルである

A sequence of cases (i.e., alternatives) in curly braces can be used anywhere a function literal can be used.Essentially, a case sequence is a function literal, only more general. Instead of having a single entry point and list of paramete…

 読み解き PiS3: ケースクラスのパターンマッチング(Constructor パターン)

case class は abstract class の派生でなくてもいい。コップ本だと Expr の派生クラスとして UnOp や BinOp クラスを定義しているが別に親がいなくてもいい。 パターンマッチのブロックの中の e はパターンに束縛される一時変数。「この e はどこから出てき…

読み解き PiS3: def の後のイコールのありなし

def の後の body の前に = を置かない場合と置く場合の違いが気になっていた。 = を置かない場合はメソッド/関数の戻り値は Unit になる。 = を置く場合はメソッド/関数の戻り値を任意に指定する。 The equals sign that precedes the body of a function hi…