Skip to content

Instantly share code, notes, and snippets.

@rindeal
rindeal / xkb-list-layouts-variants.sh
Last active April 24, 2024 06:21
POSIX shell functions and CLI utility to print/list all XKB layouts and their variants including "exotic" ones. Much improved replacement for "localectl"'s "list-x11-keymap-layouts" and "list-x11-keymap-variants" commands.
#!/bin/sh
# SPDX-FileCopyrightText: ANNO DOMINI 2024 Jan Chren (rindeal) <dev.rindeal(a)gmail.com>
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
# NOTE: Developed for xkbcli 1.5.0, might not work with later versions
xkb_list_layouts()
{
xkbcli list --load-exotic | \
@rindeal
rindeal / gsettings-array.py
Last active April 24, 2024 08:28
GSettings array manipulation made easy from CLI
#!/usr/bin/env python3
# SPDX-FileCopyrightText: ANNO DOMINI 2024 Jan Chren (rindeal) <dev.rindeal(a)gmail.com>
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
import sys
assert sys.version_info >= (3, 11)
import argparse
@rindeal
rindeal / curl-timing-write-out-format
Created September 10, 2020 20:27
curl timing --write-out format
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
@rindeal
rindeal / hash-multi-n-print-markdown-table.sh
Last active March 17, 2024 01:30
Generate multiple hashes for a file and print them as a markdown table
#!/bin/sh
# requires `pee` command from `moreutils` suite
SUMS=(
md5sum
sha1sum
sha256sum
)
FILE="${1}"
printf '<details>\n'
@rindeal
rindeal / TheIOfTheDragon.res.h
Last active July 11, 2020 22:54
Structure/format defintion of a .res file archive (`Geometry.res` and `Textures.res`) from the game "The I of The Dragon" for use in "Hex Editor Neo" software
#include <stddefs.h>
#pragma byte_order(LittleEndian)
#pragma pack(1)
struct String
{
uint32 len;
char str[len];
};
@rindeal
rindeal / lockup_timer.c
Created August 19, 2018 22:09
Lockup Timer
#include "lockup_timer.h"
#define PRINT_ERR(fmt, ...) \
fprintf(stderr, "%s:%d:%s(): " fmt, \
__FILE__, __LINE__, __func__, \
__VA_ARGS__)
#include <stdio.h> /* fprintf */
#include <errno.h> /* errno */
@rindeal
rindeal / gen.py
Last active August 16, 2018 16:02
MIN MAX __VA_ARGS__
#!/usr/bin/env python3
# Python-Version-Compatibility: 3.6
##
# Copyright (C) 2018 Jan Chren (rindeal)
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
@rindeal
rindeal / pp_narg.h
Last active August 16, 2018 16:03
PP_NARG
/**
* Copyright (C) 2018 Jan Chren (rindeal)
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@rindeal
rindeal / github-camo-purge.sh
Created May 11, 2018 18:30
GitHub Camo (Varnish cache) Purge
#/bin/sh
curl -so - https://github.com/... | \
pup 'img attr{src}' | \
awk '/:\/\/camo.githubusercontent.com\// { if ( !cache[$0] ) { print; cache[$0]=1; } }' | \
xargs curl -X PURGE
@rindeal
rindeal / fetch_tar.py
Last active April 19, 2024 09:01
Python 3 function to extract/unpack TAR archive file directly from web URL in one continous stream.
# SPDX-FileCopyrightText: 2018 Jan Chren (rindeal)
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
import pathlib
import urllib
import shutil
import tarfile
def fetch_tar(url: str, dest_dir: pathlib.Path, clean_dest: bool = False, strip_components: int = 0):
if clean_dest and dest_dir.exists():