Skip to content

Instantly share code, notes, and snippets.

View gwpl's full-sized avatar

Grzegorz Wierzowiecki gwpl

  • Europe - usually: Zürich, Warsaw or Berlin
View GitHub Profile
@gwpl
gwpl / installing_mods_on_ubuntu_with_older_ubuntu_failover_strategies.md
Last active March 20, 2025 10:42
Installing `mods` golang from source on fresh Ubuntu
@gwpl
gwpl / 0_top_answers_to_grep_man_page_paragraph.md
Created March 9, 2025 13:43
Grep e.g. `man` page for specific paragraph - `gawk` AND comparison of "AIs" answers

example of use of best Answer:

$ man journalctl 2>/dev/null | gawk -v RS='' '/-S.*--since/'
       -S, --since=, -U, --until=
           Start showing entries on or newer than the specified date, or on or
           older than the specified date, respectively. Date specifications
           should be of the format "2012-10-30 18:17:16". If the time part is
           omitted, "00:00:00" is assumed. If only the seconds component is
@gwpl
gwpl / cute_b64_png.json
Last active March 14, 2025 20:56
Example JSON with PNG base64 value.
{"src":"https://icons8.com/icons/set/cute--style-mtwotone","img":"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAAAAADFHGIkAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAD/h4/MvwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+kDCBcrNUYhPmoAAAFMSURBVCjPjZK/S0JRFIC/dy18Qxa+RNCWxBqDoCwHa87MikLagmqIwv+gqKaCQKKlTQzdspbeGlLaj6HGtjKyQSmCRq3I2/CwVBw80znnG+493zmKpHGImupl2fmXy6pItf/X1eC5g7n7RmCF2bKsAedjVs0fDQhGo37N6r+ogF1R96GIlFKRnIRMq77yZXRxhHRsyScyB+XjGRRZdBfWh4FPM1BSgZttZ1YVHBUGhgDMACqAtz+fRKAzodS+oQTREdzhhngoYTTjoQT0covgDQvoJd0AekkHC68VV5NqsCYRKLI7F7fWmf2Ydz214MllBwFYeMcWA+ABD4IgurGTsM0WNoSfEkSRxZ78mrcyW0kFrne6HlXTVqsreaU5v1IbbY7vs02L4ye1z2EfSCkjdRJNexXt6XGtMxCbstunYwFNC2SkYbeZY2gG/AKmQbIANUwYqQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyNS0wMy0wOFQyMzo0MzowOCswMDowMKP1plEAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjUtMDMtMDhUMjM6NDE6MDkrMDA6MDBwKsVkAAAAKHRFWHRkYXRlOnRpbWVzdGFtcAAyMDI1LTAzLTA4VDIzOjQzOjUzKzAwOjAwz1plrAAAABN0RVh0bWltZTp0eXBlAGltYWdlL3BuZ7mVEIcAAAAASUVORK5CYII=", "geometry": "24x24" }
#!/bin/bash
# Bash completion for the "ollama" CLI. Requires jq and curl.
#
# Published:
# * https://github.com/CLIAI/handy_scripts/blob/main/bash_completion/etc/bash_completion.d/ollama
# * https://gist.github.com/gwpl/a5e47034029bcb37de5b13f64108fc80/
# Cache settings
_OLLAMA_MODEL_TTL=300
_OLLAMA_MODELS_TIMESTAMP=0
@gwpl
gwpl / ocr_tesseract.py
Last active March 7, 2025 17:06
OCR with Tesseract including enhancing options leverages adaptive and simple thresholding to boost text extraction accuracy; employs preprocessing for grayscale conversion and bounding box details as differentiators; core features include user-configurable options for grayscale, thresholding, OCR engine, page segmentation, and language support; …
#!/usr/bin/env python3
# OCR with Tesseract including enhancing options leverages adaptive and
# simple thresholding to boost text extraction accuracy; employs
# preprocessing for grayscale conversion and bounding box details as
# differentiators; core features include user-configurable options for
# grayscale, thresholding, OCR engine, page segmentation, and language
# support; with additional functionalities like auto-preprocessing and
# bounding box extraction, this tool provides detailed text recognition
# data while ensuring ease of use through command-line interface.
@gwpl
gwpl / fix_markdown_urls
Last active February 26, 2025 11:27
fix_markdown_urls - `# Fixg URLs in markdown to be surrounded by <...>`
#!/bin/bash
# Fixg URLs in markdown to be surrounded by <...>
# https://gist.github.com/gwpl/8006aad209b84b0f618b45490948a044
function usage() {
echo "Usage: $0 [-h|--help] [-i|--in-place] [file]"
echo " -h, --help Show this help message and exit"
echo " -i, --in-place Edit files in place"
echo " file File to process (use '-' for standard input)"
@gwpl
gwpl / Debian_Ubuntu_Alternative_Versions_System_101.md
Last active February 22, 2025 16:58
Ubuntu/Debian and python3.8 vs python3.9 versioning hell? Use update-alternatives to switch seamlessly and resolve problems/conflicts.

Debian_Ubuntu_Alternative_Versions_System_101.md

Based on https://chatgpt.com/share/67b9ff44-bd6c-8007-84f4-a51d8dddfd95

You can switch between the registered Python versions using the update-alternatives interactive selection tool. Here’s how to do it:

  1. Run the Configuration Command:

sudo update-alternatives --config python3

@gwpl
gwpl / on_git_commit_change.py
Last active February 21, 2025 18:53
A Python script to monitor Git commits and execute a specified command upon detecting changes.
#!/usr/bin/env python3
# TL;DR- Put it in PATH and `chmod +x` and enjoy `on_git_commit_change.py -c -- command to run every time I make new commit`
# https://gist.github.com/gwpl/6f2c8f2574db6df770c51795d02cd458
import argparse
import subprocess
import time
import sys