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
| # /// script | |
| # requires-python = ">=3.11" | |
| # dependencies = [ | |
| # "numpy", | |
| # "sentence-transformers", | |
| # ] | |
| # /// | |
| import argparse | |
| import urllib.request |
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 import OrderedDict | |
| from typing import Iterable, Any, TypeVar, Dict, Callable | |
| from operator import length_hint | |
| from rich.progress import Progress | |
| T = TypeVar("T") | |
| def multi_track() -> Callable[[Iterable[T], str, Dict[str, Any]], Iterable[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
| from itertools import combinations | |
| from z3 import Int, Solver, And, Or, sat, Not | |
| def draw_model(solution): | |
| grid = [ | |
| ["." if (x, y) not in solution else "Q" for y in range(8)] | |
| for x in range(8) | |
| ] | |
| return "\n".join(" ".join(row) for row in grid) |
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
| // based on a keyboard map from an 'xkb/symbols/no' file | |
| default partial alphanumeric_keys | |
| xkb_symbols "basic" { | |
| include "us(basic)" | |
| name[Group1]="US (Norwegian)"; | |
| key <AC01> { [ a, A, aring, Aring ] }; | |
| key <AD03> { [ e, E, ae, AE ] }; |
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 torch | |
| from torch import nn | |
| class MinPool2d(nn.Module): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__() | |
| self.max_pool = nn.MaxPool2d(*args, **kwargs) | |
| def forward(self, x): |
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 requests | |
| def _gpt(prompt): | |
| response = requests.post( | |
| "https://dashboard.scale.com/spellbook/api/app/REDACTED", | |
| json={"input": prompt}, | |
| headers={"Authorization": "Basic REDACTED"}, | |
| ) | |
| return response.json()["text"] |
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 itertools | |
| from typing import Union, Iterator | |
| NestedSet = tuple[set[int], ...] | |
| def _missing_singletons(groups: NestedSet, cap: int) -> NestedSet: | |
| return tuple({e} for e in range(cap + 1) if {e} not in groups) | |