Skip to content

Instantly share code, notes, and snippets.

@qexat
qexat / iterators.c
Created June 26, 2024 19:25
basic generic iterators in C
#include <stdio.h>
#include <stdlib.h>
#define ITERATOR_IMPL(T, state_t) \
struct \
{ \
T (*__next__)(state_t *); \
}
#define ITERATOR_STATE(T) \
struct iterator_state_##T \
@qexat
qexat / config.py
Last active June 29, 2024 10:42
My ptpython config as of 2024.06.29
"""
My configuration file for ptpython.
Want it for yourself? Put it inside `<XDG home dir>/.config/ptpython/`.
"""
## LINT COMMAND #######################################################################
# ruff check ~/.config/ptpython/config.py --select ALL --ignore D212,D203,INP001,D202 #
#######################################################################################
@qexat
qexat / precision_fixer.py
Last active May 13, 2024 18:08
seems to fix float inaccuracies not too badly x)
import math
import sys
CORRECTOR = ((4 - sys.float_info.max * sys.float_info.min) / 2.5)
def fix_float(value: float) -> float:
if abs(value) < sys.float_info.epsilon:
return 0.0
@qexat
qexat / settings.json
Created April 8, 2024 15:59
laptop vs code settings (needs cleanup)
{
/* GLOBAL VS CODE SETTINGS */
"window.titleBarStyle": "custom",
"editor.tabSize": 4,
"editor.stickyScroll.enabled": true,
"editor.lineNumbers": "on",
"editor.tabCompletion": "on",
"editor.formatOnSave": true,
"editor.suggestSelection": "first",
"editor.unicodeHighlight.allowedCharacters": {
@qexat
qexat / int_input.py
Created April 1, 2024 00:09
idk i'm just having fun
#!/usr/bin/env python
# pyright: reportUnusedCallResult = false
# Requires outspin:
# pip install outspin
from __future__ import annotations
import io
import os
@qexat
qexat / fine.py
Created January 29, 2024 10:32
everything is fine.. until it's not!
import ctypes
import dataclasses
import faulthandler
import typing
@dataclasses.dataclass(slots=True, repr=False)
class Human:
name: str
age: int = 0
@qexat
qexat / spec.txt
Last active January 30, 2024 08:38
CyTUI `FormattedTextElement` format spec
@status DRAFT
@version
MAJOR 1
MINOR 0
REV 5
all specifiers produce an escape sequence.
DEFINITIONS
• Tag: text surrounded by brackets that signal the start of a formatted
@qexat
qexat / aprint.py
Created January 14, 2024 16:57
async typewriting
import argparse
import asyncio
import os
import sys
import typing
class APrintNamespace(typing.Protocol):
message: str
tasks: int
@qexat
qexat / .pythonrc.py
Last active June 23, 2024 06:51
my .pythonrc (2024.06.23)
#!/usr/bin/env python3
# pyright: reportUnusedCallResult = false, reportUnusedImport = false
# ruff: noqa: ANN101, D105, D107, D202, D205, D212, D401, DTZ005, EM101, S311, T201, TRY003
"""
.pythonrc is a file which is executed when the Python interactive shell is
started if $PYTHONSTARTUP is in your environment and points to this file. It's
just regular Python code, so do what you will. Your ~/.inputrc file can
greatly complement this file.
@qexat
qexat / eep_sort.py
Created December 31, 2023 20:48
eep sort
from __future__ import annotations
import asyncio
import collections.abc
import io
import os
import random
import sys
import time
import typing