From 989992278475aefa0f4679d89896cba462f5de9a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Apr 2023 22:53:07 +0900 Subject: スライド作成 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + Dockerfile | 14 +++ Makefile | 28 ++++++ README.md | 1 + assets/me.jpeg | Bin 0 -> 10890 bytes slide.pdf | Bin 0 -> 205906 bytes slide.saty | 305 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 349 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 assets/me.jpeg create mode 100644 slide.pdf create mode 100644 slide.saty diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..19780ee --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/slide.satysfi-aux diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0cbb1ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM amutake/satysfi + +RUN opam update && \ + opam install satysfi-base + +RUN opam install satysfi-class-slydifi && \ + opam install satysfi-code-printer && \ + opam install satysfi-fonts-noto-sans && \ + opam install satysfi-fonts-noto-sans-cjk-jp + +RUN eval $(opam env) && \ + satyrographos install + +WORKDIR /work diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2e45d1a --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +.PHONY: all +all: slide.pdf + +slide.pdf: slide.saty + docker run \ + --rm \ + --name satysfi \ + --mount type=bind,src=$$(pwd),dst=/work \ + satysfi \ + satysfi slide.saty + +.PHONY: shell +shell: + docker run \ + -it \ + --rm \ + --name satysfi \ + --mount type=bind,src=$$(pwd),dst=/work \ + satysfi \ + sh + +.PHONY: docker +docker: + docker build --tag satysfi . + +.PHONY: clean +clean: + rm -f *.pdf *.satysfi-aux diff --git a/README.md b/README.md new file mode 100644 index 0000000..a5fffda --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +https://phpstudy.doorkeeper.jp/events/154280 diff --git a/assets/me.jpeg b/assets/me.jpeg new file mode 100644 index 0000000..4e01020 Binary files /dev/null and b/assets/me.jpeg differ diff --git a/slide.pdf b/slide.pdf new file mode 100644 index 0000000..4ecf896 Binary files /dev/null and b/slide.pdf differ diff --git a/slide.saty b/slide.saty new file mode 100644 index 0000000..f8f38d5 --- /dev/null +++ b/slide.saty @@ -0,0 +1,305 @@ +@require: class-slydifi/theme/akasaka +@require: code-printer/code-design +@require: code-printer/code-printer +@require: code-printer/code-syntax +@require: code-printer/code-theme +@require: figbox/figbox + +let-block +code-block-php source = + '< + +code-printer?:( + CodePrinter.make-config CodeSyntax.php CodeTheme.iceberg-light + |> CodePrinter.set-number-fun CodeDesign.number-fun-null + )(source); + > + +let-block +code-block-c source = + '< + +code-printer?:( + CodePrinter.make-config CodeSyntax.c CodeTheme.iceberg-light + |> CodePrinter.set-number-fun CodeDesign.number-fun-null + )(source); + > + +open FigBox +in + +document '< + +set-config(| + SlydifiThemeAkasaka.default-config with + color-emph = Color.black; + |); + + +make-title(| + title = { + |list でない array の末尾を探す + |}; + author = {|nsfisis (いまむら)|}; + date = {|第151回PHP勉強会@東京|}; + |); + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +frame{自己紹介}< + +fig-center(vconcat [ + gap 75pt; + hconcat [ + textbox{nsfisis (いまむら)}; + gap 20pt; + include-image 50pt `assets/me.jpeg`; + ]; + gap 20pt; + textbox{\@ デジタルサーカス株式会社}; + ]); + > + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +frame{配列の末尾挿入}< + +code-block-php(` + + +frame{PHP クイズ}< + +code-block-php(` 1, + "b" => 2, + "c" => 3, +]; +$xs[] = 42; +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + "b" => 2, + "c" => 3, +]; +$xs[] = 42; +assert($xs[0] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + 1 => 2, + 3 => 4, +]; +$xs[] = 42; +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + 1 => 2, + 3 => 4, +]; +$xs[] = 42; +assert($xs[4] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + -7 => 2, + -5 => 4, +]; +$xs[] = 42; +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + -7 => 2, + -5 => 4, +]; +$xs[] = 42; +assert($xs[-4] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` + + +frame{PHP クイズ}< + +code-block-php(` + + +section{|php-srcを読む|}< + +frame{ZEND_ASSIGN_DIM}< + +listing{ + * \inline-code(`Zend/zend_vm_opcodes.h`); + ** PHP の VM (virtual machine) の opcode (operation code) 一覧 + } + > + + +frame{ZEND_ASSIGN_DIM}< + +listing{ + * \inline-code(`Zend/zend_vm_opcodes.h`); + ** PHP の VM (virtual machine) の opcode (operation code) 一覧 + * \inline-code(`ZEND_ASSIGN_DIM`); + ** 配列への代入 (assign dimensional) + } + > + + +frame{ZEND_ASSIGN_DIM}< + +listing{ + * \inline-code(`Zend/zend_vm_opcodes.h`); + ** PHP の VM (virtual machine) の opcode (operation code) 一覧 + * \inline-code(`ZEND_ASSIGN_DIM`); + ** 配列への代入 (assign dimensional) + * \inline-code(`Zend/zend_vm_def.h`); + ** 各 opcode のハンドラが定義されている + } + > + + +frame{php-srcを読むヒント}< + +listing{ + * \inline-code(`EXPECTED`); + ** よく通るパス。最も一般的なケース + * \inline-code(`UNEXPECTED`); + ** ほとんど通らないパス。エラー処理など + } + > + + +frame{zend_hash_next_index_insert}< + +code-block-c(`value = zend_hash_next_index_insert( + Z_ARRVAL_P(object_ptr), + value +);`); + +p{※説明のためやや改変} + > + + +frame{zend_hash_next_index_insert}< + +code-block-c(`zval* zend_hash_next_index_insert( + HashTable *ht, + zval *pData +) { + return _zend_hash_index_add_or_update_i( + ht, + ht->nNextFreeElement, /* 挿入先のインデックス */ + pData, + HASH_ADD | HASH_ADD_NEXT + ); +} +`); + +p{※説明のためやや改変} + > + + +frame{nNextFreeElement}< + +listing{ + * \inline-code(`Zend/zend_hash.c`); + * \inline-code(`_zend_hash_index_add_or_update_i()`); + } + > + + +frame{nNextFreeElement}< + +listing{ + * \inline-code(`Zend/zend_hash.c`); + * \inline-code(`_zend_hash_index_add_or_update_i()`); + } + +p{ + \inline-code(`array`);に数値のキーで代入したとき、そのキーが\inline-code(`nNextFreeElement`);以上なら、その値+1になる + } + > + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + "b" => 2, + "c" => 3, +]; +$xs[] = 42; +assert($xs[0] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + 1 => 2, + 3 => 4, +]; +$xs[] = 42; +assert($xs[4] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` 1, + -7 => 2, + -5 => 4, +]; +$xs[] = 42; +assert($xs[-4] === 42); +`); + > + + +frame{PHP クイズ}< + +code-block-php(` + + +frame{おまけ}< + +code-block-php(` + +> -- cgit v1.2.3-70-g09d2