# 202108 ## [テレワーク個室はテレスペ 緊急事態宣言限定プラン(都内) - レンタルスペースを簡単予約](https://upnow.jp/telespa2) ## [inode番号 (アイノード番号)とは|「分かりそう」で「分からない」でも「分かった」気になれるIT用語辞典](https://wa3.i-3-i.info/word14803.html) ## PlatformIO - [Advanced Scripting — PlatformIO latest documentation](https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html) - [ESP8266 SPIFFs | File System for NodeMCU | Microcontroller Tutorials](https://www.teachmemicro.com/esp8266-spiffs-web-server-nodemcu/) ## 資格勉強のしかた - まず過去問題などがあればとりあえず参考書をみつつでもといてみる.自分の実力を掌握し,目標達成との差分を認識する. - 勉強する. ## https://promcon.io/2019-munich/slides/improved-alerting-with-prometheus-and-alertmanager.pdf ## [データ分析の不思議、シンプソンのパラドックスを統計的因果推論から考える - Unboundedly](https://www.krsk-phs.com/entry/simpsonparadox) ## [Causal Inference Book | Miguel Hernan's Faculty Website | Harvard T.H. Chan School of Public Health](https://www.hsph.harvard.edu/miguel-hernan/causal-inference-book/) ## Rotary Encoder回路 - ロータリエンコーダのノイズ対策 ```eval_rst .. image:: ../resources/images/rotary_encoder_circuit.jpg ``` ## [SSH-AGENT](http://www.vicus-oryzae.com/gorua/agent.html) ## [チューリングマシン - Wikipedia](https://ja.wikipedia.org/wiki/%E3%83%81%E3%83%A5%E3%83%BC%E3%83%AA%E3%83%B3%E3%82%B0%E3%83%9E%E3%82%B7%E3%83%B3) ## PlatformIOでLittle FS(SPIFFS)のコンテンツを転送する. ``` board_build.filesystem = littlefs board_build.ldscript = eagle.flash.4m2m.ld ``` あたりを設定して, ``` platformio run --target uploadfs ``` こう.targetがこうだから. ``` % pio run --list-targets (git)-[develop] Environment Group Name Title Description ------------- -------- ----------- --------------------------- ----------------------------------------------------- FAST Advanced compiledb Compilation Database Generate compilation database `compile_commands.json` FAST Generic clean Clean FAST Platform buildfs Build Filesystem Image FAST Platform erase Erase Flash FAST Platform size Program Size Calculate program size FAST Platform upload Upload FAST Platform uploadfs Upload Filesystem Image FAST Platform uploadfsota Upload Filesystem Image OTA ``` ## ESP8266(esp-wroom-02)でPlatformIO iniにかけるconfigはこんなかんじ.もちろんupload_portなども指定できる.こちらは - [“platformio.ini” (Project Configuration File) — PlatformIO latest documentation](https://docs.platformio.org/en/latest/projectconf/index.html) これを参照. ``` { "build": { "arduino": { "ldscript": "eagle.flash.2m.ld" }, "core": "esp8266", "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP_WROOM_02", "f_cpu": "80000000L", "f_flash": "40000000L", "flash_mode": "qio", "mcu": "esp8266", "variant": "nodemcu" }, "connectivity": [ "wifi" ], "frameworks": [ "arduino", "simba", "esp8266-rtos-sdk", "esp8266-nonos-sdk" ], "name": "ESP-WROOM-02", "upload": { "maximum_ram_size": 81920, "maximum_size": 2097152, "require_upload_port": true, "resetmethod": "nodemcu", "speed": 115200 }, "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family", "vendor": "Espressif" } ``` - [platform-espressif8266/esp_wroom_02.json at master · platformio/platform-espressif8266 · GitHub](https://github.com/platformio/platform-espressif8266/blob/master/boards/esp_wroom_02.json) - [ESP-WROOM-02 — PlatformIO latest documentation](https://docs.platformio.org/en/latest/boards/espressif8266/esp_wroom_02.html) - OTAするときはこんなかんじにしておくとよいが,protocol指定がなくてもuplaod_portがipとか名前だと勝手にOTAになるっぽい. ``` upload_protocol = espota upload_port = 192.168.4.1 ``` ## ESP8266でOTA - [ESP32のOTA方式 | Lang-ship](https://lang-ship.com/blog/work/esp32-ota/) - [BasicOTA](https://garretlab.web.fc2.com/arduino/esp32/examples/ArduinoOTA/BasicOTA.html) - [arduino-esp32/AWS_S3_OTA_Update.ino at master · espressif/arduino-esp32 · GitHub](https://github.com/espressif/arduino-esp32/blob/master/libraries/Update/examples/AWS_S3_OTA_Update/AWS_S3_OTA_Update.ino) - [Arduino/WebUpdate.ino at master · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/examples/WebUpdate/WebUpdate.ino) - [arduino-esp32/OTAWebUpdater.ino at master · espressif/arduino-esp32 · GitHub](https://github.com/espressif/arduino-esp32/blob/master/libraries/ArduinoOTA/examples/OTAWebUpdater/OTAWebUpdater.ino) ## ESP8266のyield - [こじ研(ESP 入門編)](https://www.ei.tohoku.ac.jp/xkozima/lab/espTutorial0.html) > ウォッチドッグタイマ(WDT): プログラムが暴走するなどした場合に,自動的にリセットがかかる安全装置で,標準的な Arduino にはない機能です.プロセッサ内部にタイマーがあり,(1) loop() の終了・再呼出時,(2) delay() の実行時,(3) yield() の実行時にタイマが 0 に戻されますが,タイマが 3s を超えてしまうと,ESP-WROOM-02 が強制的にリセットされます.したがって,loop() の内部に while や for などで長時間実行される部分や入力待ちがある場合は注意が必要です.適宜,delay() や yield() を入れてください.delay(0) でもオーケーです.一方,delayMicroseconds() ではリセットされません. > WiFi 関連の機能: 後述する WiFi や TCP/IP 関連の機能(HTTP リクエストの処理など)は,上述の WDT リセットと同様に,(1) loop() の終了・再呼出時,(2) delay() の実行時,(3) yield() の実行時に,併せて実行されます.したがって,WiFi や TCP/IP の応答性を確保するには,プログラム構造を工夫したり,適宜 delay() や yield() を呼び出すようにしてください. - 時間がかかりそうなところには`yield();`をいれておいてやる.forで回す回数が多いとか. ## ESP8266でCaptive Portalっぽいしくみ - ESP8266ならESP8266 soft apの設定や初回接続などで応用できる. - soft APモードにして適当な端末で接続し,適当なwebページを見ようとすると発動するなど. - ESP8266でDNSサーバをあげておき,全nameを自分のIPで応答するよう設定する.これであらゆるHTTP requestは自分に着弾する. - 自分がserveしroutingをもつPATH以外のURLのリクエスト404になる.自分がserveしているものについてはそのまま素直に応答する. - ここでrouting先がないrequestを引っ掛けてリダイレクトしてやればよい.default routeにあるページへのリダイレクトを書いてやる. - [Arduino/CaptivePortal.ino at master · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/master/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino) - [Arduino/CaptivePortalAdvanced.ino at master · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/master/libraries/DNSServer/examples/CaptivePortalAdvanced/CaptivePortalAdvanced.ino) - [ESP8266/ESP32をアクセスポイント/Webサーバーにした時に接続時簡単にページを開く | Program Resource](https://programresource.net/2020/02/26/3006.html) - [ESP8266でmDNS (後編) – コーヒーサーバは香炉である](https://blog.maripo.org/2018/01/esp8266-mdns2/) - multicast dnsを含むzeroconf系のlinux実装的にはavahiってのがあるね. ## ESP8266のresetとrestartの違い - resetはいくつかのレジスタ(ex. SSID,PSKなど)は保存したままhard resetをする. - restartはそれらのレジスタを消去してresetする. - [ESP8266を使ってみる](http://nopnop2002.webcrow.jp/ESP-12/esp-Reset-1.html) - [difference between ESP.reset() and ESP.restart()?](https://www.pieterverhees.nl/sparklesagarbage/esp8266/130-difference-between-esp-reset-and-esp-restart) - serial flashingしたあとのrestart問題についても記述がある.とりあえずserialでかいたあとはmanualでresetしておくのがよさそう. - [hanging ESP.restart() · Issue #1722 · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/issues/1722) - [Automatic reboot after wdt reset · Issue #1017 · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/issues/1017) ## ESP8266のconnection practice - reconnectをtrueにしてもreconnectしてくれないケースがあってよくわかってない.普通にresetすると再接続に成功する. - statusてきにはこのへん. - [Arduino/wl_definitions.h at da6ec83b5fdbd5b02f04cf143dcf8e158a8cfd36 · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/da6ec83b5fdbd5b02f04cf143dcf8e158a8cfd36/cores/esp8266/wl_definitions.h) - [Arduino/ESP8266WiFiSTA.cpp at 5f04fbbf5fa77c5e71172f4032df095af3766e25 · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/5f04fbbf5fa77c5e71172f4032df095af3766e25/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L524) - reconnectまわり - [Arduino/ESP8266WiFiSTA.cpp at 5f04fbbf5fa77c5e71172f4032df095af3766e25 · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/5f04fbbf5fa77c5e71172f4032df095af3766e25/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L333) - autoreconnectはcoreの実装だけどreconnect methodはSTAに実装されててdisconnectとconnectを叩いてる感じ.coreのreconnectでも同じようなことしているのかもしれないけどよくわからない. - [Wi-Fi — ESP8266 RTOS SDK Programming Guide documentation](https://docs.espressif.com/projects/esp8266-rtos-sdk/en/latest/api-reference/wifi/esp_wifi.html?highlight=wifi_station_connect#_CPPv416esp_wifi_connectv) - [覚え書き: ESP32/arduino : ソフトウェアリセット](https://qazsedcftf.blogspot.com/2019/01/esp32arduino.html) - [arduino - How to connect to the AP in loop() in ESP8266 - Stack Overflow](https://stackoverflow.com/questions/60118789/how-to-connect-to-the-ap-in-loop-in-esp8266) - [2.4.0 will not automatically reconnect - Everything ESP8266](https://www.esp8266.com/viewtopic.php?f=28&t=16821) ## ESP8266でDigest/Basic認証 - [Arduino/ESP8266WebServer.h at master · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/src/ESP8266WebServer.h) - [Arduino/ESP8266WebServer-impl.h at master · esp8266/Arduino · GitHub](https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h) ``` bool authenticate(const char * username, const char * password); bool authenticateDigest(const String& username, const String& H1); void requestAuthentication(HTTPAuthMethod mode = BASIC_AUTH, const char* realm = NULL, const String& authFailMsg = String("") ); ``` あたりをつかってやる. ## [【研究成果・プレスリリース】熱平衡化の問題は、一般的な形では解決不可能な問題であることを証明 | 学習院大学](https://www.univ.gakushuin.ac.jp/about/pr/press/20210824release.html) - [Undecidability in quantum thermalization | Nature Communications](https://www.nature.com/articles/%20s41467-021-25053-0) - 物質には温度差を与えた後にエントロピー不変空間に十分な時間放置したときに熱平衡になるものとならないものがある.ほとんどの物質は熱平衡になる.これを熱平衡化という. - 熱平衝化するかどうかを調べたかったけどよくかんがえると熱平衡化するかどうかって決めることができるんだろうかという思想. - 熱平衡化するためにはどういう条件が必要なのかということについて観測的アプローチをとり研究されてきた. - 今回はそもそも熱平衡化するか否かは(何らかの要因によって)決定づけることがそもそもできるのかどうか,という点に着目.これが否である場合,あらゆる要素は熱平衡化するか否かを決定することはできない.つまりあらゆる物質の熱平衡化の可否を決定づける(一般化可能な)要因/原因が存在しないことを意味することになる. - 今回はこれを計算機科学におけるチューリングマシンと停止性問題に類似した手法で証明するものである. - かんたんに眺めたところ,物質の熱平衡におけるダイナミクスを表現する量子システムをチューリングマシンのテープに対応させ,る熱移動と対応するセルの移動をテープデータの操作(seek/read/calc./seek/write)に対応させているようにみえる. - このとき,熱平衡化する場合,このチューリングマシンは操作が完了し停止することに対応する.熱平衡化しない場合,チューリングマシンは停止しないことに対応する. - 停止性問題については決定不能であるため,熱平衡化か否かについても(今回用いた量子システムの視野においては)決定することはできない. - 物質の熱平衡現象と計算機科学および数学に深い関連があることにも意味がある. ## [NJU72751A | 製品情報 | 新日本無線株式会社 (NJR)](https://www.njr.co.jp/electronic_device/products/NJU72751A.html) ## [7sPro – 遊舎工房](https://shop.yushakobo.jp/products/7spro/) ## [GitHub - cloudnativedaysjp/dreamkast: dreamkast is Online Conference Platform !!!!!!](https://github.com/cloudnativedaysjp/dreamkast) ## [HTTPコネクションでIPパケットをProxyさせる、新しいCONNECT-IPメソッドの仕様 - ASnoKaze blog](https://asnokaze.hatenablog.com/entry/2021/04/20/003120) ## ブラケット表記とアインシュタイン記法 - [ブラケット記法 - EMANの量子力学](https://eman-physics.net/quantum/bracket.html) - [アインシュタインの縮約記法 - Wikipedia](https://ja.wikipedia.org/wiki/%E3%82%A2%E3%82%A4%E3%83%B3%E3%82%B7%E3%83%A5%E3%82%BF%E3%82%A4%E3%83%B3%E3%81%AE%E7%B8%AE%E7%B4%84%E8%A8%98%E6%B3%95) - [アインシュタインの縮約記法 | 高校生から味わう理論物理入門](https://manabitimes.jp/physics/1753) ## 15 minutes rule ## データベースにおけるLock - 共有ロックと占有ロック(悲観的排他制御) - 共有ロック(LOCK IN SHARE MODE) - 自身のconnectionはread/write可能,他のconnectionからはwrite不可read可. - 参照整合性の担保のためなどに利用される. - 占有ロック(FOR UPDATE) - 自身のconnectionはread/write可能,他のconnectionからはwrite不可read不可. - lockを掛ける場合はtransaction内で必要に応じてLOCK IN SHARE MODE/FOR UPDATEを利用しlockを取得する.writeも同一transactionに含めなければ正常な整合性担保は行うことはできない. - InnoDBの場合UNIQUEかINDEXがついていれば行ロック,ついてなければテーブルロックになるらしい. - [innodbでサブクエリを使ったときの FOR UPDATE のロックの範囲 - ngyukiの日記](https://ngyuki.hatenablog.com/entry/20120425/p1) - サブクエリ/結合についてはLOCKのセンテンスの位置によってロックのかかる対象が異なってくるので十分注意する必要がある. ## トランザクション分離レベル - transaction isolation level - transactionは一般に並行処理可能であるから,transactionにおいて競合状態は一般に発生しうる. - 発生するものの,transactionの性質からACIDは担保されるべき(but, この一貫性についてはパフォーマンスとの兼ね合いで不完全なのでユーザが考慮することも求められている). - リード事故 - Dirty Read - Commitされていない他のtransactionのdataをreadしてしまうこと. - readしたdataには他transactionによる変更が起きる可能性を孕んでいる. - Fuzzy Read/Non--Repeatable Read - あるtransactionで複数回dataをreadしたとき,他のtransactionのwriteによってtransaction内で再現性のないreadが起こること. - 異なるdata間で整合性を担保する必要がある場合に担保できなくなる可能性を孕んでいる. - Phantom Read - Fuzzy Readと似ているが,他transactionによるINSERTにより,繰り返しreadした際のテーブルデータが増えてしまうこと. - isolation levelをserializableにすることでしか解決できない(いくら既存のものをロックしても"増えるもの"については無駄). - LEVELS - READ UNCOMMITTED - いみふめいな(整合性のとれてない)かわりかたをするかも! - READ COMMITTED(postgresqlのdefault) - かわるかも! - REPEATABLE READ(InnoDBのdefault) - かわんないけどふえるかも! - SERIALIZABLE - かわんないしふえない! - isolation levelでの対策による解決が担保されるか否か ``` ┌─────────────────┬───────┬───────┬─────────┐ │ isolation level │ dirty │ fuzzy │ phantom │ ├─────────────────┼───────┼───────┼─────────┤ │ READ UNCOMMITED │ NG │ NG │ NG │ ├─────────────────┼───────┼───────┼─────────┤ │ READ COMMITED │ OK │ NG │ NG │ ├─────────────────┼───────┼───────┼─────────┤ │ REPEATABLE READ │ OK │ OK │ NG │ ├─────────────────┼───────┼───────┼─────────┤ │ SERIALIZABLE │ OK │ OK │ OK │ └─────────────────┴───────┴───────┴─────────┘ ``` - [トランザクション分離レベルについてのまとめ - Qiita](https://qiita.com/song_ss/items/38e514b05e9dabae3bdb) - ロックとの違いはなんなのか - read onlyについては同一transactionにおいてlockを活用することで解決可能である. - transactionで変更するdataが存在する場合,このtransaction内においてのreadについて通常lockを使って気を遣う必要があるが,このtransaction分離機構によりそれぞれのtransactionによるisolationを自ずと保証するという便利な機能となっている(と思う). - isolation levelはtransaction単位の整合の話であり行ロックとは必ずしもlock対象が一致ではない可能性がある? - transaction内部においても必要がある場合はlockをする必要がある(たぶん?transaction lessのreadのために.) # TODO: あとでexp.してcheck - Autocommit - 明示的に開始せずにSQLを打ったとき,transactionが都度commitされるか,明示commitをするかが選べる. - [MySQLのautocommitとトランザクション分離レベルのメモ - Qiita](https://qiita.com/rubytomato@github/items/562a1638191aacaeb333)