This file contains hidden or 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
| import asyncio | |
| def reader() -> None: | |
| for _ in range(3): | |
| print("next", end=" ") | |
| try: | |
| r = yield None | |
| except ValueError: | |
| pass |
This file contains hidden or 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
| given = "abcdef" | |
| it = iter(given) | |
| res = [(a + b) for a,b in zip(it, it)] | |
| assert ['ab', 'cd', 'ef'] == "".join(res) |
This file contains hidden or 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
| m = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | |
| ll = [i for l in m for i in l] | |
| assert list(range(1, 10)) == ll |
This file contains hidden or 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
| import weakref | |
| class A: ... | |
| def test_() -> None: | |
| o = A() | |
| ref = weakref.ref(o) | |
| assert ref() is not None | |
| del o | |
| assert ref() is None |
This file contains hidden or 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
| def fake() -> None: | |
| print("fake") | |
| @lambda this: fake | |
| def x() -> None: | |
| pass |
This file contains hidden or 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
| from typing import TypeAlias, TypeVar | |
| T = TypeVar("T") | |
| Tuple6: TypeAlias = tuple[T, T, T, T, T, T] | |
| OCTET_MAX = 0xFF | |
| def parse(octets: Tuple6[str]) -> int: # like: int(str, 16) |
This file contains hidden or 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
| --- | |
| x-logging: &logging | |
| driver: json-file | |
| options: | |
| max-size: 1m | |
| max-file: 3 | |
| compress: 'true' | |
| services: | |
| linux: |
This file contains hidden or 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
| # STM32F411CEU6: 100MHz Arm Cortex-M4 core with DSP and FPU, 512KB Flash, 128KB SRAM, ART Accelerator | |
| # https://stm32-base.org/boards/STM32F411CEU6-WeAct-Black-Pill-V2.0.html | |
| # increase working area to 128KB | |
| set WORKAREASIZE 0x20000 | |
| set CHIPNAME STM32F411CEU6 | |
| source [find interface/stlink.cfg] | |
| # source [find interface/stlink-dap.cfg] | |
| # source [find interface/stlink-v2-1.cfg] |
This file contains hidden or 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
| Add | |
| scrub on bridge100 all min-ttl 65 | |
| to | |
| '/etc/pf.conf' | |
| Reload with | |
| sudo pfctl -f /etc/pf.conf | |
| Check with | |
| sudo pfctl -sa |
This file contains hidden or 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
| task = asyncio.create_task(read_output()) | |
| handler = event_loop().call_later(2, cancel_asyncio_task, task) | |
| task.add_done_callback(lambda _: handler.cancel()) | |
| await task |
NewerOlder