Skip to content

Instantly share code, notes, and snippets.

View pavel-kirienko's full-sized avatar
:shipit:

Pavel Kirienko pavel-kirienko

:shipit:
View GitHub Profile
@pavel-kirienko
pavel-kirienko / zubax_forum_export.py
Last active February 28, 2026 22:19
Download Zubax forum threads (incl. private) with attachments and all linked threads to make them easily available to AI agents. Mostly intended for design specification threads and experiment notes.
#!/usr/bin/env python3
"""
Export Zubax Forum threads (Discourse) to local Markdown with attachments. This is designed to make forum thread
contents easily available to AI agents, especially when referenced threads contain design specifications.
FEATURES
- Fetch root topic and recursively fetch internally linked topics.
- Supports private topics using ZUBAX_FORUM_API_KEY or ZUBAX_FORUM_API_TOKEN (+ username).
- Downloads attachment assets and rewrites references to local files.
@pavel-kirienko
pavel-kirienko / 1shot.py
Last active February 25, 2026 18:15
Ultimate disposable software generator: describe what needs to be done in command line arguments, get a script that does that and run it, dispose the script immediately
#!/usr/bin/env python3
#
# A simple CLI utility that accepts natural-language description of what needs to be done and provides a Python
# script doing just that, with an option to run it immediately. The tool requires no dependencies and runs anywhere.
#
# 1shot.py find the largest file in this directory excluding hidden directories
# 1shot.py count lines of Python code excluding blanks and comments, show top 10
#
# Quotes are not necessary, just write the prompt like you normally would.
#
@pavel-kirienko
pavel-kirienko / settings.json
Last active February 19, 2026 18:31
Zed config
// Zed settings
//
// For information on how to configure Zed, see the Zed
// documentation: https://zed.dev/docs/configuring-zed
//
// To see all of Zed's default settings without changing your
// custom settings, run `zed: open default settings` from the
// command palette (cmd-shift-p / ctrl-shift-p)
{
"session": {
@pavel-kirienko
pavel-kirienko / .wezterm.lua
Last active March 4, 2026 13:20
WezTerm config
local wezterm = require 'wezterm'
local act = wezterm.action
-- https://wezterm.org/config/lua/config/
return {
font = wezterm.font("MesloLGS NF"),
font_size = 10,
color_scheme = "deep",
colors = {
background = "black",
@pavel-kirienko
pavel-kirienko / memory_block.h
Created December 25, 2025 14:20
Single-header memory block pool allocator in C
/// ____ ______ __ __
/// / __ `____ ___ ____ / ____/_ ______ / /_ ____ / /
/// / / / / __ `/ _ `/ __ `/ / / / / / __ `/ __ `/ __ `/ /
/// / /_/ / /_/ / __/ / / / /___/ /_/ / /_/ / / / / /_/ / /
/// `____/ .___/`___/_/ /_/`____/`__, / .___/_/ /_/`__,_/_/
/// /_/ /____/_/
///
/// A header-only implementation of a fairly standard O(1) free-list block pool allocator.
/// Consider also O1Heap (https://github.com/pavel-kirienko/o1heap) if a more conventional heap is required.
///
@pavel-kirienko
pavel-kirienko / crc32c.c
Created December 6, 2025 20:43
CRC32C with out-of-order blocks
#include <stddef.h>
#include <stdint.h>
#define CRC_INITIAL 0xFFFFFFFFUL
#define CRC_OUTPUT_XOR 0xFFFFFFFFUL
#define CRC_RESIDUE_BEFORE_OUTPUT_XOR 0xB798B438UL
#define CRC_RESIDUE_AFTER_OUTPUT_XOR (CRC_RESIDUE_BEFORE_OUTPUT_XOR ^ CRC_OUTPUT_XOR)
#define CRC_SIZE_BYTES 4U
static const uint32_t crc_table[256] = {
@pavel-kirienko
pavel-kirienko / sine_lookup_1024.v
Created August 6, 2025 17:17
10-bit sin(x) lookup table in Verilog based on a 256x9-bit ROM cell
/// Stateless, purely combinational sin(x) look-up table. Can be used as the phase-to-amplitude converter of an NCO.
/// It stores 256 9-bit items in a look-up table representing the first quarter of the wave.
/// The input x is expected to be normalized into [0, 1024) that maps to [0, 2 pi).
/// The signed output is normalized into [-511, +511] (sic! -512 not used).
module sine_lookup_1024(
input wire [9:0] x,
output wire signed [9:0] out
);
reg [8:0] entry; // Not an actual register, just a wire assignable from the always block.
assign out = x[9] ? -$signed({1'b0, entry}) : $signed({1'b0, entry}); // The MSb represents the half-wave index.
@pavel-kirienko
pavel-kirienko / nco.v
Created August 6, 2025 12:33
A simple numerically controlled oscillator (NCO) in Verilog
/// A numerically controlled oscillator (NCO) that outputs a sawtooth wave, whose frequency is a function of
/// clk rate and frequency_control_word, and the amplitude spans the range [0, 2**OUTPUT_WIDTH).
/// The output frequency is defined as:
///
/// f_out = (f_clk * frequency_control_word) / (2**PHASE_ACCUMULATOR_WIDTH)
///
/// Solve for frequency_control_word:
///
/// frequency_control_word = ((2**PHASE_ACCUMULATOR_WIDTH) * f_out) / f_clk
///
@pavel-kirienko
pavel-kirienko / stack_canary.hpp
Created May 26, 2025 19:56
A simple utility class for debugging stack memory corruption.
#include <cassert>
#include <cstdint>
#include <cstdlib>
namespace stack_canary
{
/// Do not use this directly; see the StackCanary definition below.
template <std::size_t n_bytes, std::uint8_t seed = 0xC9>
class StackCanary_Impl final
@pavel-kirienko
pavel-kirienko / disable_windows_security.ps1
Last active November 20, 2025 23:23
A script that disables Windows security features: Defender, Firewall, UAC, SmartScreen, Windows Update, etc.
# This script will disable most of the Windows security-related features.
# It is mostly intended for use in disposable VMs, such as simulation and CI/CD runners.
# Read the source to see what exactly is done.
# Author: Pavel Kirienko <pavel.kirienko@zubax.com>
# Relaunch elevated if needed
$IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $IsAdmin) {