file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
code_snippets/typing/1135.py | Python | from typing import Callable, Generic, Any
from typing_extensions import ParamSpec
_P = ParamSpec("_P")
class Job(Generic[_P]):
def __init__(self, target: Callable[_P, None]) -> None:
self.target = target
def call_job(
job: Job[...],
*args: Any
) -> None:
job.target(*args)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/1160.py | Python | def less_than(value: int, limit: int | None) -> bool:
if limit is None:
return True
return value < limit
def less_than(value: int, limit: int | Literal[float("inf")]) -> bool:
return value < limit
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/1179.py | Python | from typing import TypeVar, Callable
T = TypeVar('T')
MkFoo = Callable[[T], list[T]]
def foo(mkfoo: MkFoo) -> None:
_ = mkfoo(0)
def foo(mkfoo: Callable[[T], list[T]]) -> None:
_ = mkfoo(0)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/1183.py | Python | import asyncio
from typing import Any, Coroutine, Generic, TypeVar
from httpx import AsyncClient, Client, Response
ClientT = TypeVar("ClientT", bound=Client | AsyncClient)
class API(Generic[ClientT]):
client: ClientT
def __init__(self, client: ClientT) -> None:
self.client = client
def get_it... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/1202.py | Python | Email: TypeAlias = str
def send_email(email: Email) -> int:
# Send an email
...
# passes
send_email("test@example.com")
# passes
send_email("badddd")
# passes even if unknown_var is only identified as `str`
send_email(unknown_var)
# This is a bad regex pattern, but you get the idea :)
Email: TypeAlias = st... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/182.py | Python | JSON = t.Union[str, int, float, bool, None, t.Mapping[str, 'JSON'], t.List['JSON']]
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/213.py | Python | from typing import Iterable, Container
class IterableContainer(Iterable[int], Container[int]):
...
def f(x: IterableContainer) -> None: ...
class Test(IterableContainer):
def __iter__(self): ...
def __contains__(self, item: int) -> bool: ...
f(Test())
def assertIn(item: T, thing: Intersection[Iterable[... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/241.py | Python | class Foo:
def factory(self) -> str:
return 'Hello'
class Bar(Foo):
def factory(self) -> int:
return 10
class QPixmap(QPaintDevice):
def swap(self, other: 'QPixmap') -> None: ...
class QBitmap(QPixmap):
def swap(self, other: 'QBitmap') -> None: ...
class QBitmap(QPixmap):
@covari... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/246.py | Python | @puremixin
class MyMixin:
def do_stuff(self) -> int:
self.one_thing() # ok, even though not defined in this class
return self.second_thing(1) # also ok
class Thing(Implementation[MyMixin]):
def one_thing(self) -> None: pass # ok
def second_thing(self, x: int) -> str: # error: return t... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/276.py | Python | def f(x) -> None:
reveal_type(x) # Revealed type is 'Any'
def g(x: int):
pass
reveal_type(g(1)) # Revealed type is 'Any'
def f(x: ...) -> None:
...
def g(x: int) -> ...:
...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/307.py | Python | class Base: pass
class Derived(Base): pass
T = TypeVar('T', bound=Base)
class MyType(Generic[T]):
pass
myvar: MyType = None # type of `myvar` is `MyType[Any]`
class Base: pass
class Derived(Base): pass
T = TypeVar('T', bound=Base, default=Base)
class MyType(Generic[T]):
pass
myvar: MyType = None # type o... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/424.py | Python | async def foo(x: int): pass
callback = foo # What does this type to?
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/496.py | Python | if __typing__:
from typing import *
T = TypeVar('T')
UserId = NewType('UserId', int)
... # etc.
def f(users: List[UserId]) -> Optional[UserId]:
...
# reveal_type(previous_result) is `builtins.int`
result: cast(UserId) = previous_result
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/510.py | Python | def foo(xs: Iterable[Text]):
return '|'.join(xs)
# list(Text) should return List[Char]
foo("abcd") # error
foo(list("abcd")) # correct, List[Char] is a special case of List[Text]
def bar(xs: Iterable[Char]):
return '|'.join(xs)
bar("abcd") # correct, Text is a Iterable[Char]
bar(list("abcd")) # correct, List[Cha... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/535.py | Python | from enum import Enum
class MyEnum(Enum):
a = 1
b = 2
c = 3
some_func(MyEnum.a.value)
from typing import Enum
class MyEnum(Enum[int]):
a = 1
b = 2
some_func(MyEnum.a.value)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/542.py | Python | def some_deferred() -> Awaitable[int]: ...
def some_future() -> Awaitable[int]: ...
async def x() -> Awaitable[List[int]]:
y = []
y.append(await some_deferred())
y.append(await some_future())
return y
def some_deferred() -> Awaitable[int, Deferred]: ...
def some_future() -> Awaitable[int]: ... # presu... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/548.py | Python | A = TypeVar('A')
B = TypeVar('B')
F = TypeVar('F')
class M(Generic[F[X], A]):
def x(fa: F[A], f: Callable[[A], B]) -> F[B]:
return map(f, fa)
M().x([1], str)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/555.py | Python | from datetime import datetime
from mypy_extensions import TypedDict
from somewhere import AliasWithMetadata
# define metadata type
Options = TypedDict('Options', {'min': int, 'max': int})
# define type alias with allowed metadata
MinMaxInt = AliasWithMetadata(int, Options)
# define age arg as type int with metadata a... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/564.py | Python | class Reader(Protocol[AnyStr]):
def read(self, n: int = ...) -> AnyStr: ...
def readlines(self) -> List[AnyStr]: ...
def close(self) -> None: ...
class Writer(Protocol[AnyStr]):
def write(self, s: AnyStr) -> int: ...
def writelines(self, lines: List[AnyStr]) -> None: ...
def close(self) -> None... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/565.py | Python | def downcast(type, expr):
assert isinstance(expr, type)
return expr
x = downcast(type, expr)
assert isinstance(expr, type)
x = expr
def upcast(type, expr):
return expr
x = upcast(type, expr)
x: type = expr
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/566.py | Python | from datetime import date
x: AnyOf[str, date] = ...
s: str = x # ok
dt: date = x # ok
i: int = x # type error
u: Union[str, bytes] = x # ok
x = u # type error (although the type checker could do something smart here and infer that u can only be str here)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/592.py | Python | def foo(x: Tuple[int, str]) -> None:
a, b = x
def bar(x: Tuple[int, str]) -> None:
a = x[0]
b = x[1]
class Iter:
def __iter__(self):
yield 1
yield ""
foo((1, ""))
foo([1, ""])
foo(Iter())
bar((1, ""))
bar([1, ""])
def foo(x: TupleLike[str, str]): ...
x: List[str] = ...
foo(x)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/601.py | Python | class addbase:
def __init__(self, fp):
self.fp = fp
self.read = self.fp.read
self.readline = self.fp.readline
if hasattr(self.fp, "readlines"): self.readlines = self.fp.readlines
if hasattr(self.fp, "fileno"):
self.fileno = self.fp.fileno
else:
... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/629.py | Python | import typing
import typing_inspect
T = typing.TypeVar("T")
class Inst(typing.Generic[T]):
@classmethod
def hi(cls):
return cls
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/641.py | Python | import typing as tp
T = tp.TypeVar("T")
@tp.overload
def gf1(i: int, j: tp.Any) -> str:
...
@tp.overload
def gf1(i: tp.Iterable[T], j: bool) -> tp.Dict[T, T]:
...
def gf1(i: tp.Union[int, tp.Iterable[T]], j: tp.Any) -> tp.Union[str, tp.Dict[T, T]]:
pass
gf1.resultType = lambda *a: None
class C(... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/653.py | Python | import typing
T = typing.TypeVar("T")
class Test(typing.NamedTuple, typing.Generic[T]):
a: T
x: Test[int] = Test(a=1) # TypeError: 'type' object is not subscriptable
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/684.py | Python | import builtins
from typing import List, Union
def fun(x: Union[builtins.ellipsis, List], y: List):
if x is not Ellipsis:
y = x # error: Incompatible types in assignment (expression has type "Union[ellipsis, List[Any]]", variable has type "List[Any]")
return y
# another attempt:
def fun2(x: Union[E... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/685.py | Python | class Column:
def mean(self) -> int:
return 0
class GeoColumn(Column):
def length(self) -> int:
return 0
T = TypeVar("T", bound=Dict[str, Column])
K = TypeVar("K", bound=str)
V = TypeVar("V", bound=Column)
class Dataframe(Generic[T]):
def __init__(self, cols: T):
self.cols = c... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/688.py | Python | class MySubType(TypedSimpleNamespace):
bar: int
class MyType(TypedSimpleNamespace):
foo: MySubType
# correct
a: MyType = SimpleNamespace(foo=SimpleNamespace(bar=1))
# incorrect, `bar` should be a number
a: MyType = SimpleNamespace(foo=SimpleNamespace(bar='abc'))
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/689.py | Python | class PSS(AsymmetricPadding):
MAX_LENGTH: ClassVar[object]
def __init__(self, mgf: MGF1, salt_length: Union[int, Literal[MAX_LENGTH]]) -> None: ...
class PSS(AsymmetricPadding):
MAX_LENGTH: Singleton
def __init__(self, mgf: MGF1, salt_length: Union[int, MAX_LENGTH]) -> None: ...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/703.py | Python | def assert_positive(x: object) -> AssertsInstance["x", int]:
assert isinstance(x, int) and x > 0
def is_positive(x: object) -> ChecksInstance["x", int]:
return isinstance(x, int) and x > 0
def my_func(x: Union[int, str]) -> None:
if is_positive(x):
# x must be an int
...
else:
... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/718.py | Python | # foo accepts a date object, but allows to add and access
# unknown attributes at runtime. It basically treats date
# as having __getattr__()/__setattr__() methods.
def foo(date: Dynamic[datetime.date]) -> None:
date.my_attr = 123
print(date.added_by_called)
# typing.dynamic() is a no-op at runtime and basica... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/735.py | Python | from typing import NoReturn
def assert_never(x: NoReturn) -> NoReturn:
raise AssertionError(f"Invalid value: {x!r}")
from typing import Union
def type_checking_ok(foo: Union[str, int]) -> None:
if isinstance(foo, str):
print("str")
elif isinstance(foo, int):
print("int")
else:
... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/742.py | Python | def fun() -> Union[bool, NotImplemented]: ...
def fun() -> Union[bool, Any]: ...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/769.py | Python |
foo: int = 1
Foo = type[foo] # equivalent to Foo = int
def bar(x: string) -> None :
...
Bar = type[bar] # equivalent to Bar = Callable[[str], None]
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/776.py | Python | from typing import Generic, TypeVar, get_type_hints
T = TypeVar("T")
class A(Generic[T]):
a: T
U = TypeVar("U")
class B(A[U]):
b: U
assert get_type_hints(B) == {"a": T, "b": U}
assert get_type_hints(B, substitute_type_vars=True) == {"a": U, "b": U} # typevars are consistent
assert get_type_hints(B[T], subs... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/777.py | Python | from typing import Generic, TypeVar, generic_mro
T = TypeVar("T")
class A(Generic[T]): ...
U = TypeVar("U")
class B(A[U]): ...
class C(B[int]):
pass
assert generic_mro(C) == (C, B[int], A[int], Generic, object)
assert generic_mro(B) == (B, A[U], Generic, object)
assert generic_mro(B[int]) == (B[int], A[int], Ge... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/779.py | Python | SpecialReturn[int, bool, str]
Annotated[Tuple[int, bool, str], 'special return!']
class SpecialReturn():
def __class_getitem__(self, params: Tuple[Any, ...]) -> Tuple[Any, ...]:
return typing.cast(
Tuple[Any, ...],
_typing.Annotated[
typing.Tuple.__getitem__(params)... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/781.py | Python | class LinkageCriterion(enum.Enum):
WARD = "ward"
COMPLETE = "complete"
AVERAGE = "average"
SINGLE = "single"
LinkageCriterionLike = Union[
LinkageCriterion,
Literal["ward", "complete", "average", "single"]
]
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/786.py | Python | def foo(ten_floats: Tuple[float,float,float,float,float,float,float,float,float,float]):
...
def foo(ten_floats: HomogeneousTuple[float, 10]):
...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/801.py | Python | from __future__ import annotations
from phantom.sized import NonEmpty, Empty
i: tuple[int, ...] = ()
assert isinstance(i, Empty)
assert isinstance(i, NonEmpty)
reveal_type(i)
class NonEmpty:
...
class Empty(Not[NonEmpty]):
...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/813.py | Python | T_co = TypeVar("T_co", covariant=True)
T_contra = TypeVar("T_contra", contravariant=True)
T_co = +TypeVar("T_co")
T_contra = -TypeVar("T_contra")
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/815.py | Python | T = TypeVar('T')
Element = tuple[T]
def fn(elements: tuple[Element, ...]): ...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/900.py | Python | from typing import TypeVar
T = TypeVar("T")
def assert_something(expected: T, actual: T) -> None:
...
assert_something(1, "") # no error, SUS alert!, T is inferred as `object`
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/912.py | Python | Thing1 = TypeVar("Thing1", bound=Base1, covariant=True)
Thing2 = TypeVar("Thing2", bound=Base2, covariant=True)
Thing3 = TypeVar("Thing3", bound=Base3, covariant=True)
class ThingWithLotsOfGenerics(Generic[Thing1, Thing2, Thing3]):
...
def foo(value: ThingWithLotsOfGenerics[..., ..., ...]) -> None:
...
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/920.py | Python | def foo(cond: bool) -> None:
if cond:
a: Final = Funny("spam")
else:
a: Final = Funny("eggs") # this is currently an error
def foo(cond: bool) -> None:
a: Final[Funny]
if cond:
a = Funny("spam")
else:
a = Funny("eggs")
def foo(cond: bool) -> None:
a: Final = Fu... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/926.py | Python | R_T = TypeVar("R_T")
P = ParamSpec("P")
async def maybe_coroutine(func: Callable[P, Union[R_T, Coroutine[Any, Any, R_T]]], *args: P.args, **kwargs: P.kwargs) -> R_T:
value = func(*args, **kwargs)
if isawaitable(value):
value = await value
return value
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/928.py | Python | from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from foo.bar import Baz
def foo(baz: Baz):
print(baz.bat)
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/930.py | Python | y: str
assert is_list_of_str(x)
assert len(x) > 0
y = x[0]
y: str
assert_is_nonempty_list_of_str(x) # note, this encodes another runtime check, the len check
y = x[0]
def assert_is_nonempty_list_of_str(x) -> AssertingTypeGuard[list[str]]:
if not isinstance(x, list):
raise ExpectedListError(x)
if not ... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/953.py | Python | from typing import TypeAlias
Str: TypeAlias = "str"
Int: TypeAlias = "int"
a: Str | Int = 0 # SUS ALERT
MyStr = NewType("MyStr", str)
from typing import NoReturn, TypedDict, TypeAlias, TypeVar, Generic, Protocol, etc, etc, etc, etc
from typing import TypeVar, Generic
T_cont = TypeVar("T_cont", contravariant=True... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/955.py | Python | from typing import _KT, _promote
| Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
code_snippets/typing/956.py | Python | # _collections_abc.pyi
@StubOnlyBase(KeysView[_KT_co], Generic[_KT_co, _VT_co])
class dict_keys:
...
# builtins.pyi
@StubOnlyBase(numbers.Integral)
class int:
...
from typing import _alias # type: ignore[attr-defined]
from typing import TYPE_CHECKING
from _collections_abc import dict_keys
if not TYPE_CHECKI... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
update.py | Python | import ast
import json
from pathlib import Path
from datetime import datetime
import requests
time_at_start_of_script = datetime.utcnow()
print("Updating code snippets starts at", time_at_start_of_script.isoformat())
try:
with open("last_updated_utc.json", "r") as file:
last_updated = json.load(file)
exc... | Akuli/issue-downloader | 0 | Downloads code from GitHub issues and saves it to files | Python | Akuli | ||
bootstrap.sh | Shell | #!/usr/bin/env bash
#
# The Jou compiler is written in Jou, but it doesn't help you very much if you
# have nothing that can compile or run Jou code. That's why this script exists.
#
# See the bootstrapping section in README.md for details.
#
# If you just want to setup a Jou development environment, you probably don't... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
bootstrap_transpiler.py | Python | """This file converts Jou code to C code.
This is meant to be used only when setting up Jou on a system for the first
time. Usually you don't need to run this manually, because bootstrap.sh figures
out where Python is installed and invokes this with whatever Python you have.
This is basically a mini Jou compiler. Her... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
check-markdown-links.py | Python | """Check that links in markdown files point to reasonable places."""
# There is a similar script in https://github.com/Akuli/porcupine/
import argparse
import json
import os
import re
import subprocess
import sys
from http.client import responses as status_code_names
from pathlib import Path
from datetime import datet... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
create_issue.sh | Shell | #!/bin/bash
# This script is invoked from GitHub actions that run every night.
# It creates an issue on GitHub that lets me know the tests failed.
set -e -o pipefail
if [ -z "$GITHUB_RUN_ID" ]; then
echo "This script can only be ran in GitHub Actions"
exit 1
fi
if [ $# != 2 ]; then
echo "Usage: $0 <gith... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
doctest.sh | Shell | #!/usr/bin/env bash
#
# This file runs code snippets in markdown files.
set -e -o pipefail
for arg in "$@"; do
if [[ "$arg" =~ ^- ]]; then
echo "Usage: $0 [file1.md file2.md ...]" >&2
exit 2
fi
done
if [ $# == 0 ]; then
files=(README.md doc/*.md doc/*/*.md)
else
files=("$@")
fi
if [[... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
examples/aoc2023/day20/visualize.sh | Shell | #!/usr/bin/env bash
set -e
if [ $# != 1 ] || [[ "$1" =~ ^- ]]; then
echo "Usage: $0 input.txt"
exit 2
fi
dot -T png -o /tmp/aoc20-graph.png <(
echo "digraph G {"
cat "$1" | sed s/'#.*'// | sed '/^$/d' | sed -E s/'^%([A-Za-z0-9]*)'/'\1[label="flip-flop \1"]\n\1'/g | sed -E s/'^&([A-Za-z]*)'/'\1[label=... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
examples/aoc2025/day11/to_graphviz.sh | Shell | #!/bin/bash
set -e
(
echo 'digraph G {'
echo '"you" [style=filled, fillcolor=red, fontcolor=white];' # thanks AI
cat sampleinput.txt | while read line; do
start=$(echo $line | cut -d: -f1)
for part in $(echo $line | cut -d: -f2); do
echo "$start -> $part;"
done
done... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
release.sh | Shell | #!/bin/bash
#
# This scripts generates a new Jou release. It is invoked from GitHub Actions
# automatically as documented in CONTRIBUTING.md.
set -e -o pipefail
dry_run=no
auth_header=""
while [ $# != 0 ]; do
case "$1" in
--dry-run)
dry_run=yes
shift
;;
--githu... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
runtests.sh | Shell | #!/usr/bin/env bash
#
#
#
# *** If you edit this file, make sure that the instructions
# *** in README stay up to date.
#
#
#
export LANG=C # "Segmentation fault" must be in english for this script to work
set -e -o pipefail
function usage() {
echo "Usage: $0 [--valgrind] [--verbose] [--dont-run-make] [--jou-fla... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
update.ps1 | PowerShell | #
# On Windows, "jou --update" runs this script.
#
# Disable Progress Bar
$ProgressPreference = 'SilentlyContinue'
# Stop on error
$ErrorActionPreference = 'Stop'
# Clean up anything that this script leaves when it either succeeds or crashes mid-way.
Write-Output "Cleaning up..."
Remove-Item jou_update -Force -Recur... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/alpine.sh | Shell | #!/bin/bash
set -e -o pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <architecture>"
exit 1
fi
arch=$1
case $arch in
x86)
qemu=kvm
sha=4c6c76a7669c1ec55c6a7e9805b387abdd9bc5df308fd0e4a9c6e6ac028bc1cc
disk_name_inside_vm=sda
;;
aarch64)
qemu='qemu-system-aarch64 ... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/download.sh | Shell | #!/bin/bash
#
# This script downloads a file. But unlike plain old wget:
#
# - If the file has been downloaded before (either fully or partially), it
# will not be downloaded again.
#
# - If the file has been deleted, it STILL won't be downloaded again, because
# it is first placed into a separate "download... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/keygen.sh | Shell | #!/bin/bash
#
# This script generates ssh keys if they don't exist yet.
#
# We use the same key for all VMs, but not for anything else. So you don't need
# to worry about accidentally pushing your "private" key to Git.
#
# The key is not committed to git, because putting generated files to Git can
# look suspicious (se... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/netbsd.sh | Shell | #!/bin/bash
set -e -o pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <architecture>"
exit 1
fi
arch=$1
case $arch in
amd64)
qemu=kvm
sha256=92a40431b2488785172bccf589de2005d03c618e7e2618a6a4dd0465af375bfd
;;
*)
echo "$0: Unsupported architecture '$arch' (must be amd64)"... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/raspios.sh | Shell | #!/bin/bash
#
# This script creates a Raspberry PI OS virtual machine running on armv6. It is
# quite close to raspberry pi 1.
set -e -o pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <architecture>"
exit 1
fi
arch=$1
case $arch in
armv6)
qemu=qemu-system-arm
;;
*)
echo "$0: U... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/ssh.sh | Shell | #!/bin/bash
set -e -o pipefail
if [[ "$1" == -* ]]; then
echo "Usage:"
echo " $0 # Interactive shell"
echo " $0 git status # Run a command inside VM (git status is just an example)"
echo ""
echo "You need to start a VM first before using this script."
exit 2
fi
if ! [ -f "$(d... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
vm/wait_for_string.sh | Shell | #!/bin/bash
#
# "./wait_for_string.sh foo somecommand --bar" runs "somecommand --bar" and
# kills it when it prints anything that contains "foo". The string "foo" can
# appear as a substring anywhere in the output, and killing happens immediately
# as soon as the command writes it to its standard output. Output of the
... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
windows_setup.sh | Shell | #!/usr/bin/env bash
# Run this script in Git Bash to get started with developing Jou on Windows.
# It downloads everything you need (except a text editor).
set -e
if ! [[ "$OS" =~ Windows ]]; then
echo "This script must be ran on Windows." >&2
exit 1
fi
small=no
offline_zip=
while [ $# != 0 ]; do
case ... | Akuli/jou | 24 | Programming language that looks like Python but behaves like C | Python | Akuli | ||
main.go | Go | package main
import (
"fmt"
"strings"
"os"
"os/exec"
"github.com/charmbracelet/glamour"
)
func readInput() string {
if len(os.Args) == 2 && !strings.HasPrefix(os.Args[1], "-") {
inputBytes, err := os.ReadFile(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "Can't... | Akuli/md | 0 | Terminal markdown viewer | Go | Akuli | ||
config.py | Python | import re
import json
import copy
import sys
import time
import tkinter
import threading
import subprocess
import random
from functools import partial
from pathlib import Path
from typing import TypedDict, Any, Literal, cast
from tkinter import ttk, messagebox
from math import sin, pi
# The hardware has room for syst... | Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
images/resize.sh | Shell | #!/bin/bash
# Assumes you have imagemagick installed
# sudo apt install imagemagick
for infile in large-to-be-resized-with-script/*.jpg; do
outfile=$(basename $infile)
echo "$infile --> $outfile"
convert -resize 1000x1000 $infile $outfile
done
| Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
mittari.c | C | #define _POSIX_C_SOURCE 200809L
#define _GNU_SOURCE // needed only for adjusting pipe size https://stackoverflow.com/a/25463268
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <spawn.h>
#include <errno.... | Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
tests/fake_aplay.sh | Shell | #!/bin/bash
# This is used in tests.
# Write a message to stderr, like aplay does.
echo "message from fake aplay" >&2
# Store command-line arguments to file so we can see how aplay was called.
echo "$@" > "$(dirname "$0")"/aplay_args.txt
| Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
tests/test_c_program.py | Python | import subprocess
import shutil
from shlex import quote
from pathlib import Path
from os import PathLike
import pytest
@pytest.fixture
def mittari():
subprocess.run(["make", "-s"], check=True)
def run_the_executable(*args, timeout=None):
command = ['./mittari', *args]
if timeout:
... | Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
tests/test_config_script.py | Python | from shutil import which
from pathlib import Path
import pytest
from config import (
list_audio_devices,
load_config,
save_config,
DEFAULT_CONFIG,
map_percentage_to_gain,
)
@pytest.mark.skipif(which("aplay") is None, reason="uses 'aplay -L'")
def test_listing_audio_devices():
device_names = ... | Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
tests/test_images.py | Python | import shutil
import subprocess
import glob
import os
import pytest
@pytest.mark.skipif(
shutil.which("identify") is None,
reason="imagemagic not installed, it's needed to find image sizes"
)
@pytest.mark.parametrize("image_filename", glob.glob("images/*.jpg"))
def test_jpg_sizes(image_filename):
output ... | Akuli/mittari | 1 | Analog CPU and RAM usage meters for my computer | Python | Akuli | ||
build.py | Python | import textwrap
from pathlib import Path
from htmlthingy import Builder
builder = Builder()
builder.infiles = ['content.txt']
builder.infile2outfile = lambda infile: "html/index.html"
builder.additional_files = []
mathjax_config = r'''
MathJax = {
tex: {
inlineMath: [ ['$','$'] ],
... | Akuli/music-theory | 4 | A website that explains music theory using mathematics (Finnish) | Python | Akuli | ||
playNotes.js | JavaScript | function noteToFrequency(noteName) {
if (noteName === '.') {
return 0; // silence
}
const match = /^([A-G])([#b]?)(-?\d+)$/.exec(noteName);
if (!match) {
throw new Error(`bad note name: ${noteName}`);
}
const letter = match[1];
const sharpOrFlat = match[2];
const octaveNum = match[3];
let... | Akuli/music-theory | 4 | A website that explains music theory using mathematics (Finnish) | Python | Akuli | ||
style.css | CSS | html {
color: white;
background-color: #333;
}
body {
margin: 0.5em;
}
.headerlink {
color: #4d4d4d;
}
#content {
padding: 0.5em;
}
a {
color: #00cff1;
border-bottom: 1px dotted;
text-decoration: none; /* taken care of with the border-bottom thing */
}
a:hover {
color: #f99c3f... | Akuli/music-theory | 4 | A website that explains music theory using mathematics (Finnish) | Python | Akuli | ||
src/lib.rs | Rust | use core::slice;
use std::{
borrow::{Borrow, BorrowMut},
cmp,
fmt::Debug,
mem::{self, MaybeUninit},
ops::{self, Deref, DerefMut},
ptr,
slice::SliceIndex,
};
/// A fixed-size array-backed Vec, which stores at most 255 elements.
/// Attempting to push() when the vec is at capacity will panic.... | AlCalzone/tinyvec | 0 | A fixed-capacity vector type for Rust with just a single byte of overhead | Rust | AlCalzone | OpenHomeFoundation | |
dut/zwave-js/run.ts | TypeScript | /**
* Z-Wave JS Runner
*
* This is a standalone process that implements the IPC protocol to communicate
* with the orchestrator. It manages the Z-Wave JS driver and server.
*
* Usage: Spawned by RunnerHost, connects via WebSocket IPC
*/
import WebSocket from "ws";
import * as path from "path";
import... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
setup/download-zwave-stack.ps1 | PowerShell | <#
.SYNOPSIS
Downloads the latest Z-Wave stack binaries from GitHub.
.DESCRIPTION
This script downloads the latest Z-Wave stack release from the
Z-Wave-Alliance/z-wave-stack-binaries repository and extracts
the required ELF binaries to zwave_stack/bin/.
.EXAMPLE
.\download-zwave-stack.ps... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
setup/pack-ctt-archive.ps1 | PowerShell | <#
.SYNOPSIS
Creates an archive containing CTT installation files for CI.
.DESCRIPTION
This script packages the following into setup/ctt-setup.zip:
- CTT AppData folder -> appdata/
- CTT Keys file (homeId-specific) -> keys/
- CTT binaries (from CTT_PATH or default location) -> ctt-bin/
.... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
setup/pack-network-state-archive.ps1 | PowerShell | <#
.SYNOPSIS
Creates an archive containing Z-Wave network state for CI.
.DESCRIPTION
This script packages the following into setup/network-state.zip:
- zwave_stack/storage/ -> storage/
- DUT storage files (from config.json glob patterns) -> dut-storage/
.EXAMPLE
.\pack-network-state-arch... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
setup/unpack-ctt-archive.ps1 | PowerShell | <#
.SYNOPSIS
Extracts the CTT setup archive on CI before running tests.
.DESCRIPTION
This script extracts setup/ctt-setup.zip and places files in the correct locations:
- appdata/ -> %APPDATA%/Z-Wave Alliance/Z-Wave CTT 3/
- keys/ -> %USERPROFILE%/Documents/Z-Wave Alliance/Z-Wave CTT 3/Keys/
... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
setup/unpack-network-state-archive.ps1 | PowerShell | <#
.SYNOPSIS
Extracts the network state archive on CI before running tests.
.DESCRIPTION
This script extracts setup/network-state.zip and places files in the correct locations:
- storage/ -> zwave_stack/storage/
- dut-storage/ -> DUT storage directory (from config.json)
.EXAMPLE
.\unpack... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/ctt-client.ts | TypeScript | import WebSocket from 'ws';
import { testCaseEvents, type TestCaseResult } from './ws-server.ts';
const CTT_HOST = '127.0.0.1';
const CTT_PORT = 4711;
const CTT_URL = `ws://${CTT_HOST}:${CTT_PORT}/json-rpc`;
let messageId = 0;
interface JsonRpcRequest {
jsonrpc: '2.0';
method: string;
params: Recor... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/ctt-output.ts | TypeScript | /**
* CTT Output Parser
*
* Handles parsing of CTT-specific output formats including:
* - Color codes: {color:darkgray}text{color}
* - User prompts: »YES-NO:SHOW«
*/
import c from "ansi-colors";
// Type for ansi-colors style functions
type StyleFunction = (text: string) => string;
// Map CTT color... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/runner-host.ts | TypeScript | /**
* RunnerHost - Spawns and manages communication with runner processes
*
* This class handles:
* 1. Starting a WebSocket IPC server
* 2. Spawning the runner process as a subprocess
* 3. Waiting for the runner to connect and send "ready"
* 4. Sending requests and receiving responses via JSON-RPC
*/
... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/runner-ipc.ts | TypeScript | /**
* IPC Message Types for Runner Communication
*
* All runners (regardless of language) communicate with the orchestrator
* via WebSocket using these JSON-RPC message formats.
*/
// === Security Key Types ===
export interface SecurityKeys {
S2_Unauthenticated: string; // hex string
S2_Authentica... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/start.ts | TypeScript | import { spawn, ChildProcess } from "child_process";
import * as path from "path";
import * as fs from "fs";
import { fileURLToPath } from "url";
import { createWebSocketServer } from "./ws-server.ts";
import type { ManagedWebSocketServer } from "./ws-server.ts";
import { runTestCases, closeCTT, getTestCases } fr... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
src/ws-server.ts | TypeScript | import { WebSocketServer, WebSocket } from 'ws';
import { EventEmitter } from 'events';
import { getTestCases } from './ctt-client.ts';
import { convertCttColorsToAnsi } from './ctt-output.ts';
import type { RunnerHost } from './runner-host.ts';
// Global event emitter for test case events
export const testCase... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
zwave_stack/bin/zniffer.py | Python | #!/usr/bin/env python3
#
# SPDX-FileCopyrightText: 2022 Silicon Laboratories Inc. <https://www.silabs.com/>
#
# SPDX-License-Identifier: BSD-3-Clause
import socket
import struct
import binascii
import threading
import errno
import argparse
import select
import signal
import enum
class ZpalRegion(enu... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
zwave_stack/run.sh | Shell | #!/bin/bash
# Start all Z-Wave binaries in the background
# Note: Run this script from the repository root directory
echo "Starting Z-Wave Stack..."
# Start 3 controllers
echo "Starting Controller 1 (Z-Wave JS) on port 5000..."
./zwave_stack/bin/ZW_zwave_ncp_serial_api_controller.elf --port 5000 --storage ./zwave_sta... | AlCalzone/zwave-ctt-automation | 0 | A framework for automating Z-Wave certification tests | TypeScript | AlCalzone | OpenHomeFoundation | |
app_init.c | C | /***************************************************************************//**
* @file
* @brief app_init.c
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
************************************************... | AlCalzone/zwave-rcp-firmware | 1 | Z-Wave Radio Co-Processor firmware for sending and receiving raw frames | C | AlCalzone | OpenHomeFoundation | |
app_init.h | C/C++ Header | /***************************************************************************//**
* @file
* @brief app_init.h
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
************************************************... | AlCalzone/zwave-rcp-firmware | 1 | Z-Wave Radio Co-Processor firmware for sending and receiving raw frames | C | AlCalzone | OpenHomeFoundation | |
app_process.c | C | /******************************************************************************
* @file
* @brief app_process.c
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
**********************************************... | AlCalzone/zwave-rcp-firmware | 1 | Z-Wave Radio Co-Processor firmware for sending and receiving raw frames | C | AlCalzone | OpenHomeFoundation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.