merge avi files

Create filelist to merge
ls *.avi | while read each; do echo "file '$each'" >> mylist.txt; done
use ffmpeg to concatenate files.
ffmpeg -f concat -i mylist.txt -c copy video_draft.avi

insert icon
<a class="link" href="https://192.168.1.199:8006/" target="_blank">
<picture class="layer-machine-header-logo">  
<source type="image/avif" srcset="img/avif/proxmox.avif">  
<img src="img/proxmox.png" alt="pve_logo">   
</a>  
edit test not real snippet
@app.route('/add', methods=['POST'])
def add_snippet():
    category = request.form['category']
    title = request.form['title']
    content = request.form['content']
    description = request.form['description']
    add_new_snippet(category, title, content, description)
    return redirect(url_for('index'))
Create empty file

ni file.txt -type file

find

search text in file
find /path/to/folder -type f -exec grep -H "search_term" {} \;

show all dirs & files with size and sort by size
du -sh | sort -n

find files bigger than 20M
find . -type f -size +20M

awk

find all not matching (EXACT!!!) "#" and copy to new file
awk '$0!="#"' config >> config_clean

find all mathing/not matching PATTERN

awk '/#/' config
awk '!/#/' config
image magicks

expand to 1:1 aspect ratio and resize
magick input.png -gravity center -background none -extent 145 -resize 128 output.png
create icon from file
magick code-logo.png -define icon:auto-resize=128,64,48,32,16 code-logo.ico
convert to avif
magick input.png -define heic:speed=2 output.avif

SQLite3 Context Manager

context manager class for SQLite3 db connection

class SQLite():
    ''' Class is a wrapper for sqlite3 context manager. 
        Returs sqlite3.connection().cursor object ready to execute query
        Usage: with SQLite() as c:
                  c.execute('SELECT * FROM table')
    '''

    def __init__(self, db):
        self.db = db

    def __enter__(self):
        self.conn = sqlite3.connect(self.db)
        return self.conn.cursor()

    def __exit__(self, type, value, traceback):
        self.conn.commit()
        self.conn.close()
RGB Colors for VBA
def _rgb_to_interior(rgb):
    '''returns value of color for "Interior" property'''
    return (rgb[2] << 16) + (rgb[1] << 8) + rgb[0]
Intercept keypressed

this is base for macro keyboard to intercept Fx keys under Windows 10/11

import psutil
import keyboard
import pygetwindow as gw
import time

def is_teams_open():
    # Check if Microsoft Teams process is running
    for process in psutil.process_iter(['name']):
        if 'Teams' in process.info['name']:
            return True
    return False

def activate_teams():
    # Activate Microsoft Teams if open
    if is_teams_open():
        windows = gw.getWindowsWithTitle("Microsoft Teams")
        if windows:
            teams_window = windows[0]
            if teams_window.isMinimized:
                teams_window.restore()
            teams_window.activate()
            print("Microsoft Teams activated.")
        else:
            print("Teams is running but no window found.")
    else:
        print("Microsoft Teams is not running.")

# Bind F20 key to activate Teams if it is open
keyboard.add_hotkey('f20', activate_teams)

print("Listening for F20 to activate Teams...")
keyboard.wait('esc')  # Press 'Esc' to exit