Skip to content

Instantly share code, notes, and snippets.

@qexat
qexat / update.fish
Last active October 5, 2024 16:57
Arch Linux: Check updates and perform upgrades if available (requires yay)
#!/usr/bin/env fish
##################################################################
# Check if there are updates available. #
# -------------------------------------------------------------- #
# First, it runs `checkupdates` (with `-d` to prefetch). If it #
# returns 2, this means it has not found any updates. We then #
# query the AUR database to verify if there are updates on their #
# side. #
# #
@qexat
qexat / comb.py
Last active September 7, 2024 20:23
make pyright cook your CPU speedrun any%
# ruff: noqa: DOC201, DOC501
"""
Combinatorial arithmetic
"""
from __future__ import annotations
import abc
import typing
@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 #
@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 / 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
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 / 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