Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / settings.json
Last active March 9, 2025 16:54
Visual Studio Code on my laptop (clarisse)
{
/*
--- Visual Studio Code settings ---
*/
// Global
"chat.commandCenter.enabled": false,
"window.customTitleBarVisibility": "auto",
"window.titleBarStyle": "custom",
"window.zoomLevel": 1,
"window.autoDetectColorScheme": true,
@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 / 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 / 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 / ruff.toml
Last active August 26, 2024 14:41
Ruff configuration
fix = true
unsafe-fixes = false
preview = true
exclude = [".venv", "build", "dist"]
line-length = 80
indent-width = 4
[lint]
@qexat
qexat / recreate-venv
Last active August 25, 2024 11:48
recreate-venv - a Python-oriented shell utility to recreate a fresh new virtual environment
#!/bin/sh
# ===================== LICENSE ===================== #
# MIT License #
# #
# Copyright (c) 2024 Qexat #
# #
# Permission is hereby granted, free of charge, to #
# any person obtaining a copy of this software and #
# associated documentation files (the "Software"), to #