Skip to content

Instantly share code, notes, and snippets.

@rindeal
rindeal / _meta.py
Last active November 1, 2021 04:35
python enum
import typing
from sys import _getframe
class Enum(int):
__slots__ = []
"""type: typing.FrozenSet[str]"""
names2values = dict() # TODO: make it FrozenBimap
"""type: typing.Dict[str, int]"""
values2names = dict()
@rindeal
rindeal / print_process_call_stack.sh
Last active April 19, 2024 10:10
Print process call stack. Pure BASH function.
#!/bin/bash
# based on https://stackoverflow.com/a/1438241/2566213
# pure BASH solution
print_process_call_stack() {
local -a trace=()
local -- cmdline
local -i pid=$$ ppid
@rindeal
rindeal / README.md
Last active May 13, 2024 05:05
How to set English US Keyboard Layout with Czech, Slovak and German as third level symbols (using AltGr to engage the third level)

Linux Keyboard Layout Configuration Guide

This guide will assist you in configuring keyboard layout variants, such as the popular cz_sk_de variant of the us layout. These variants are specified in the file /usr/share/X11/xkb/rules/base.extras.xml and all have a property popularity="exotic", which renders them invisible to most common programs, including systemd and GNOME. Fortunately, there is a workaround for this.

Tools

xkb-list-layouts-variants.sh

Use xkb-list-layouts-variants.sh, a POSIX shell function and CLI utility, to print/list all XKB layouts and their variants, including the exotic ones, and also print their descriptions. This is a significant improvement over localectl's list-x11-keymap-layouts and list-x11-keymap-variants commands.

@rindeal
rindeal / mv-merge.sh
Created October 21, 2016 23:59
mv-merge.sh
#!/bin/bash
DEST="${@:${#@}}"
ABS_DEST="$(cd "$(dirname "$DEST")"; pwd)/$(basename "$DEST")"
for SRC in ${@:1:$((${#@} -1))}; do (
cd "$SRC";
find . -type d -exec mkdir -p "${ABS_DEST}"/\{} \;
find . -type f -exec mv -u \{} "${ABS_DEST}"/\{} \;
find . -type d -empty -delete
@rindeal
rindeal / libstdc++_upgrade_packages.sh
Created October 21, 2016 23:51
libstdc++_upgrade_packages.sh
#!/bin/bash -
# CREATED: 9.8.2015 01:04
set -o nounset # Treat unset variables as an error
IFS=: read -ra pathComponents <<<"$PATH"
while IFS= read -rd '' x; do
ldd -r -- "$x" | grep -q libstdc++ && bins+=("$x")
done < <(find "${pathComponents[@]}" -type f -executable -print0)
@rindeal
rindeal / wrap.sh
Created October 21, 2016 23:17
`fold` command wrapper which performs text wrapping and optionally commenting
#!/bin/sh
opts=""
comment=0
nocomment=0
while getopts bchsVw: opt; do
case $opt in
b)
opts="$opts -b"
@rindeal
rindeal / stack.sh
Last active July 29, 2016 23:13 — forked from bmc/stack.sh
A stack implementation, in bash
#!/bin/bash
# A stack, using bash arrays.
#
# Based on: https://gist.github.com/bmc/1323553 by Brian Clapper (bmc) <[email protected]>
# ---------------------------------------------------------------------------
# Check if a stack exists
#
# Usage: stack_exists name
@rindeal
rindeal / Linux file IO monitoring.sh
Last active April 19, 2024 10:35
Linux file IO monitoring sysdig read/write/open files
#!/bin/sh
sudo sysdig -p '%proc.name|%evt.arg.fd.name' \
'evt.dir=> and ( fd.type=file or fd.type=directory ) and fd.name!=""' | \
awk -F\| '
BEGIN{
OFS="|"
}
$2!~/^<f>\/(dev|proc|run|sys).*/ {
print $1,substr($2,4);
@rindeal
rindeal / clear_cache.sh
Last active December 3, 2015 22:36
OpenCart (vqMod) toolbox
#!/bin/bash
# Clear OpenCart (vqMod) caches
rm -rf ./system/cache/{cache*,smp/*}
rm -rf ./vqmod/vqcache/*
rm -f ./vqmod/*.cache
@rindeal
rindeal / df-him.png
Last active July 16, 2016 17:01
Colorized `df -h` and `df -hi` merged together -> df -hi(mproved)
df-him.png