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
| // I want to create a generic convert function ("to") which takes the destination type as | |
| // a template argument and then the object to convert. Users should be able to overload | |
| // this type to add conversions ad-hoc in ways that single argument constructors or user- | |
| // defined conversions cannot handle. For example, converting from third-party library A's | |
| // type AA to another third party library B's BB type. They don't know about each other, | |
| // be we, the downstream user of both, do. | |
| // | |
| // Anyways, making `to<>()` an overloadable single-template argument function mostly works, | |
| // until it needs to use ADL to look up an overload. The issue is that the parser doesn't | |
| // know to<A> is a template function call until a trial substitution is done, at which point |
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
| class TaskManager(Mapping[str, Task[Any]]): | |
| """Associative container of names to child Tasks. | |
| Tasks created with this object are not allowed to leak; | |
| child tasks will be cancelled if the TaskManager is collected. | |
| Typically this is used as an async context manager, | |
| forcing all child Tasks to finish before returning. |
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 functools import update_wrapper, wraps | |
| class cached_method: | |
| def __init__(self, method): | |
| self._method = method | |
| update_wrapper(self, method) | |
| def __get__(self, instance, objtype=None): | |
| if instance 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
| #include <variant> | |
| template <typename ...Args> | |
| struct sum_; | |
| template <typename Last> | |
| struct sum_<Last> { | |
| using type = Last; | |
| }; |
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 functools import cache, cached_property | |
| from typing import ( | |
| Collection, | |
| Iterable, | |
| Optional, | |
| Reversible, | |
| Sized, | |
| TypeAlias, | |
| TypeVar, | |
| overload, |
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 collections.abc import Mapping, Sequence | |
| from typing import TypeVar | |
| T = TypeVar("T") | |
| def linearize(node: T, dep_tree: Mapping[T, Sequence[T]]) -> tuple[T, ...]: | |
| @cache | |
| def helper(node: T) -> tuple[T, ...]: | |
| return ( |
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 Optional, Tuple, Union, overload | |
| _time_unit_map = { | |
| "ps": -12, | |
| "ns": -9, | |
| "us": -6, | |
| "ms": -3, | |
| "s": 0, | |
| } |
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
| function logerr { | |
| file="$1" | |
| shift 1 | |
| "$@" 2> >(tee "$file" >&2) | |
| } |
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
| library ieee; | |
| use ieee.std_logic_1164.all; | |
| package generic_ff_pack is | |
| procedure FF | |
| generic ( | |
| type T) | |
| parameter ( | |
| signal q : out T; | |
| constant d : in T; |
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
| entity piecewise_function is | |
| generic ( | |
| NODE_MAP : NodeMapType; | |
| NODE_ID : string; | |
| NUM_SEGMENTS : natural; | |
| THRESHOLD_SIZE_RES : sfixed; | |
| BIAS_SIZE_RES : sfixed; | |
| GAIN_SIZE_RES : sfixed); | |
| port ( |
NewerOlder