Skip to content

Instantly share code, notes, and snippets.

@rindeal
rindeal / ucenter_hex_parser.py
Last active July 21, 2024 19:55
Parse UBX messages from u-center's Messages View hex output
#!/usr/bin/env python3
# SPDX-FileCopyrightText: ANNO DOMINI 2024 Jan Chren ~rindeal <dev.rindeal gmail.com>
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
# Homepage: https://gist.github.com/rindeal/852365c3b241dfee813cfd02b4e3f705/
import io
import sys
import re
@rindeal
rindeal / !cp-attr.sh.md
Created July 1, 2024 03:26
File Attributes Copier (ownership, permissions, SELinux security contexts)

File Attributes Copier

A robust Bash script for copying file attributes (ownership, permissions, and SELinux context) from a source file to one or more destination files.

Features

  • Copies ownership (user and group)
  • Copies permissions (read, write, execute)
  • Copies SELinux security context (if SELinux is enabled)
  • Provides detailed, color-coded logging
jobs:
JOB_NAME:
name: "JOB'S PRETTY NAME"
runs-on: ubuntu-latest
defaults:
run:
# -o noclobber: prevent existing regular files from being overwritten by redirection of output
# -o noexec: This option will not execute commands; it’s useful for checking a script for syntax errors.
NORMAL = "\x1b[0m", RESET = "\x1b[0m"
BLACK = "\x1b[30;21m", RED = "\x1b[31;21m", GREEN = "\x1b[32;21m", YELLOW = "\x1b[33;21m", BLUE = "\x1b[34;21m", MAGENTA = "\x1b[35;21m", CYAN = "\x1b[36;21m", WHITE = "\x1b[37;21m", GREY = "\x1b[38;21m"
BOLD_BLACK = "\x1b[30;1m", BOLD_RED = "\x1b[31;1m", BOLD_GREEN = "\x1b[32;1m", BOLD_YELLOW = "\x1b[33;1m", BOLD_BLUE = "\x1b[34;1m", BOLD_MAGENTA = "\x1b[35;1m", BOLD_CYAN = "\x1b[36;1m", BOLD_WHITE = "\x1b[37;1m", BOLD_GREY = "\x1b[38;1m"
BG_BLACK = "\x1b[40m", BG_RED = "\x1b[41m", BG_GREEN = "\x1b[42m", BG_YELLOW = "\x1b[43m", BG_BLUE = "\x1b[44m", BG_MAGENTA = "\x1b[45m", BG_CYAN = "\x1b[46m", BG_WHITE = "\x1b[47m", BG_GREY = "\x1b[48m"
@rindeal
rindeal / !Firefox Color Palette.md
Last active June 27, 2024 16:54
Firefox Brand Color Palette
<!--- Firefox Color Palette ------------------------------------------------------------->
<link rel="stylesheet" href="https://gist.github.com/rindeal/4c869c95087f1bf8cf7cecb4206e2d4f/raw/firefox-color-palette-2024.min.css" referrerpolicy="no-referrer" />
@rindeal
rindeal / !gsettings-array.py.md
Last active May 24, 2024 01:02
GSettings array manipulation made easy from CLI. Implements ls, insert, pop, rm, sort and dedup operations

GSettings Array Manipulator

Welcome to the GSettings Array Manipulator, a powerful command-line tool designed to simplify and streamline your interactions with GSettings arrays. With this tool, you can perform a variety of tasks, from inserting items into an array to sorting and deduplicating items, all with a few simple commands.

Features

  • Insert: Add one or more items to your array at a specified index.
  • List: Display all items in your array, each on a new line.
  • Sort: Sort all items in your array.
  • Deduplicate: Remove duplicate items from your array.
@rindeal
rindeal / buffered_io_get_buffer_size.py
Last active May 13, 2024 06:41
Python 3 function to calculate optimal buffer size for any io.BufferedIOBase subclass, like io.BufferedReader and io.BufferedWriter
"""
===============================
BufferedIOBase Buffer Size Calculator
===============================
This Python script contains a function `buffio_get_buffsz` that calculates
the buffer size of a `BufferedIOBase` object.
Functionality
=============
@rindeal
rindeal / !xkb-list-layouts-variants.sh.md
Last active May 13, 2024 01:28
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.

XKB Layouts and Variants List

Welcome to the home of the ultimate tool for listing all XKB layouts and their variants, including those rare and "exotic" ones. This POSIX shell script and CLI utility is a much-improved alternative to "localectl"'s "list-x11-keymap-layouts" and "list-x11-keymap-variants" commands.

Versatile and Easy to Use

This script is designed with versatility in mind. It can be used in two ways:

  1. As a standalone script which acts as a CLI utility.
  2. As a module with functions that can be sourced and used inside some other script.
@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