Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am kivava on github.
  • I am kivava (https://keybase.io/kivava) on keybase.
  • I have a public key ASAqyYmuAPWRYv76BFqzAEFjI5aYsIL1aiN6q2FrNIaaNwo

To claim this, I am signing this object:

@kivava
kivava / gcc_instrument-functions.md
Last active July 9, 2024 10:24
gcc instrument-functions

Fib sample

gcc -o fib -Og -rdynamic -finstrument-functions test_fib.c instrument.c -ldl
@kivava
kivava / deterministic_rsa_key_generation.md
Created July 9, 2024 10:06
Generate a deterministic RSA key by a specified seed/password

Generate A Deterministic RSA Key by A Specified SEED/Password

The OpenSSL cannot specify the seed by a simple CLI. The gnutls supports.

Generate a RSA 2048 bit key

certtool --generate-privkey --outfile privkey.pem --key-type=rsa --sec-param=medium -d 2 --seed=00000000000000000000000000000000000000000000000000000000
@kivava
kivava / sigv_handler with backtrace.md
Last active July 9, 2024 10:21
sigv_handler with backtrace

execinfo

To generate backtrace on segmentation fault, one simple way is use execinfo.h.

struct sigaction act;

memset((void *)&act, 0, sizeof(act));
act.sa_sigaction = sigv_handler;
act.sa_flags = SA_RESTART | SA_SIGINFO;
@kivava
kivava / python_source_import.rst
Created March 26, 2025 02:43 — forked from mportesdev/python_source_import.rst
Importing Python source code from a script without the .py extension

Importing Python source code from a script without the .py extension

Generally, to import a python module programatically when you know the file's path, you could do something like this:

import importlib.util
import sys
@kivava
kivava / script-template.sh
Created March 27, 2025 02:37 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
# Decompile
dtc -I dtb -O dts -o devicetree.dts /boot/dtb/<your_devicetree_file_name>.dtb
# Compile
dtc -I dts -O dtb devicetree.dts -o <your_devicetree_file_name>.dtb
# Merge with DTBO
fdtoverlay -i modified-base.dtb -o modified-full.dtb /boot/tegra194-p3668-all-p3509-0000-user-custom.dtbo
# DTS from fs