Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3.6
##
# Copyright 2018 Jan Chren (rindeal)
# Distributed under the terms of the GNU General Public License v3
##
class _FilesAndDirsGen:
_root_tmpdir: tempfile.TemporaryDirectory
_defs: typing.Union[dict, set]
@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 / kb.conf
Last active August 6, 2020 14:22
English, German, Czech, Slovak Xorg keyboard configuration
Section "InputClass"
Identifier "keyboard"
Driver "evdev"
MatchIsKeyboard "true"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
Option "XkbVariant" "cz_sk_de"
Option "XkbOptions" "grp:shift_toggle"
EndSection
@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) <bmc@clapper.org>
# ---------------------------------------------------------------------------
# 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