Skip to content

Instantly share code, notes, and snippets.

View kisssko's full-sized avatar
⁉️

Alexander Gurov kisssko

⁉️
  • Voronezh, Russia
View GitHub Profile
@kisssko
kisssko / tk_colors.hpp
Created September 28, 2026 16:06
Standard color name table from the Tk lib and the X11 window system.
#ifndef TK_COLORS_HPP
#define TK_COLORS_HPP
#include <cstdint>
#define RGB2U32_(R, G, B) ((uint32_t(R) << 16) | \
(uint32_t(G) << 8) | \
uint32_t(B))
#define COLOR_ENTRY(N,R,G,B) {N, RGB2U32_((R),(G),(B))}
@kisssko
kisssko / rndtable.c
Created September 28, 2026 16:03
Doom I/II legendare random number table
unsigned char rndtable[256] =
{
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, 74, 21,
211, 47, 80, 242, 154, 27, 105, 128, 150, 116, 34, 11, 19, 73, 31, 114,
25, 46, 137, 210, 211, 41, 41, 100, 248, 14, 129, 24, 180, 244, 239, 9,
121, 4, 72, 47, 197, 147, 85, 18, 167, 130, 214, 221, 142, 214, 158, 96,
99, 119, 17, 59, 121, 28, 42, 223, 174, 98, 254, 203, 171, 12, 145, 137,
34, 18, 161, 88, 251, 22, 219, 251, 127, 86, 36, 79, 181, 127, 189, 11,
58, 33, 177, 181, 242, 182, 42, 191, 153, 7, 38, 189, 135, 210, 10, 23,
@kisssko
kisssko / fnmatch.c
Created September 28, 2026 16:00
Small fnmatch() implementation w/o deps.
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#define EOS '\0'
#define FNM_NOMATCH 1 /* Match failed */
#define FNM_NOESCAPE 0x01 /* Disable backslash escaping */
#define FNM_PATHNAME 0x02 /* Slash must be matched by slash */
#define FNM_PERIOD 0x04 /* Leading period must be matched by period */
@kisssko
kisssko / hexdump.h
Created September 28, 2026 15:58
Small hexdump implementation for MCUs and tiny CPUs.
// #include <stdint.h>
// #include <stdio.h>
#define DEBUGOUT(MSG) fputs(MSG, stderr)
#define EOL "\n"
#define GET_NIBBLE(V,N) (((V) >> ((N) * 4)) & 0x0F)
#define IS_NOT_PRINTABLE(C) (((C) < 0x20) || ((C) > 0x7E))
static void hexDump(const char *desc, void *addr, int len)
{
@kisssko
kisssko / san_float.c
Last active September 28, 2026 15:53
Sanitize float (and also double) types for using a result for equal comparison.
#include <stdint.h>
#define MASK_BITS 4
typedef union
{
float f;
uint32_t i;
} float_uint_t;
@kisssko
kisssko / drawline.c
Created September 28, 2026 15:50
draw line algos. Bresenham algos optimisation.
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void plot(int x, int y, int c)
{
gotoxy(x+1,y+1);
putchar(c);
putchar(8);
@kisssko
kisssko / tb_progress.hpp
Created September 28, 2026 15:24
Windows Taskbar Progress indicator for C++
#pragma once
#include <windows.h>
#include <shobjidl.h>
#include <wrl/client.h>
class TaskbarProgress
{
private:
HWND m_hwnd;
Microsoft::WRL::ComPtr<ITaskbarList3> m_taskbarList;
@kisssko
kisssko / taskbar_progress.py
Last active September 28, 2026 14:33
Pure Python Windows Taskbar Progress indicator using ctypes without external dependencies
import ctypes
from ctypes.wintypes import HWND
# Windows Taskbar State Constants (TBPFLAG)
STATE_NO_PROGRESS = 0x0
STATE_INDETERMINATE = 0x1 # Marquee/indeterminate indicator (when time is unknown)
STATE_NORMAL = 0x2 # Green indicator
STATE_ERROR = 0x4 # Red indicator
STATE_PAUSED = 0x8 # Yellow indicator
@kisssko
kisssko / tiny_rand.c
Created February 3, 2022 10:09
tiny randomizer
#include <stdint.h>
#include <stdlib.h>
uint32_t tiny_rand(void)
{
uint32_t t = _seed;
t ^= t >> 10;
t ^= t << 9;
t ^= t >> 25;
@kisssko
kisssko / passgen.sql
Last active February 3, 2022 10:18
SQL (sqlite3) password generator
WITH RECURSIVE t(x) AS (SELECT 0 UNION ALL SELECT x + 1 FROM t LIMIT 8 * 16)
SELECT group_concat(substr('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
abs(random()%(62))+1,1), '')
AS PASSWORD FROM t GROUP BY x % 16;