Skip to content

Instantly share code, notes, and snippets.

View jirihnidek's full-sized avatar

Jiri Hnidek jirihnidek

View GitHub Profile
@jirihnidek
jirihnidek / bar-collector
Created August 19, 2025 10:36
Bar rhc collector (Proof of concept)
#!/bin/bash
# /usr/libexec/bar-collector
VERSION=0.2
DELAY="0.1"
if [[ $1 = "--help" ]]; then
echo "NAME:"
@jirihnidek
jirihnidek / com.redhat.foo.toml
Last active August 19, 2025 12:52
Foo rhc collector (Proof of concept)
# /usr/lib/rhc/collector.d/com.redhat.foo.toml
[meta]
name = "Red Hat Foo Collector"
[exec]
version_command = "/usr/libexec/foo-collector --version"
user = "foo"
group = "foo"
[exec.collector]
@jirihnidek
jirihnidek / wip_dmidecode_output.json
Created July 3, 2023 16:06
WIP: output of dmidecode --json
{
"data":[
{
"header":{
"handle":0,
"type":0,
"length":24
},
"description":"BIOS Information",
"values":{
@jirihnidek
jirihnidek / dmidecode_output.json
Created June 23, 2023 14:24
Example of "dmidecode --json | python -m json.tool"
{
"BIOS Information": {
"Vendor": "SeaBIOS",
"Version": "1.16.2-1.fc38",
"Release Date": "04/01/2014",
"Address": "0xE8000",
"Runtime Size": "96 kB",
"ROM Size": "64 kB",
"Characteristics:": [
"BIOS characteristics not supported",
@jirihnidek
jirihnidek / flock_example.py
Created June 21, 2021 13:56
File locking using fcntl.flock using Python
"""
Example of using fcntl.flock for locking file. Some code inspired by filelock module.
"""
import os
import fcntl
import time
def acquire(lock_file):
@jirihnidek
jirihnidek / sub-sub-command.py
Last active September 12, 2025 19:04
Python example of using argparse sub-parser, sub-commands and sub-sub-commands
"""
Example of using sub-parser, sub-commands and sub-sub-commands :-)
"""
import argparse
def main(args):
"""
Just do something
@jirihnidek
jirihnidek / register_system.sh
Created July 1, 2020 08:35
Register system using D-Bus API
#!/bin/bash
echo "reseting config file..."
cp /etc/rhsm/rhsm.conf.default /etc/rhsm/rhsm.conf
echo "restarting rhsm.service..."
systemctl restart rhsm.service
# Set new variables using D-Bus API
echo "changing configuration..."
@jirihnidek
jirihnidek / singleton.py
Last active February 3, 2020 18:01
Python singleton
class Singleton(object):
"""
Singleton and parent for singletons
"""
_instance = None
_initialized = False
def __new__(cls, *args, **kwargs):
"""
@jirihnidek
jirihnidek / CMakeLists.txt
Created February 27, 2019 13:30
Libdnf plugin
CMAKE_MINIMUM_REQUIRED (VERSION 3.11.2)
project(example C)
include(GNUInstallDirs)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
# Build type
@jirihnidek
jirihnidek / client_multi_process.py
Created May 29, 2018 16:06
Multi-threaded vs multi-process vs serial https client
#!/usr/bin/env python
import requests
import time
import copy
from multiprocessing import Process
from data import URLS
def send_request(num, url):