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
<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>
@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'))
ni file.txt -type file
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
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
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()
def _rgb_to_interior(rgb):
'''returns value of color for "Interior" property'''
return (rgb[2] << 16) + (rgb[1] << 8) + rgb[0]
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
from PG Hackaton
df = spark.table("userdb_eupscanalytics_im.hackaton_characters")
df_filtered = df.filter(regexp_extract(col("Character_id"), r'^\d+$', 0) != '')
df_filtered = df_filtered.filter(col("Death") == 'nan')
df_filtered[df_filtered['Name'] > 0]
go through API for libs/functions U use the most
compare wti vanilla PANDAS approach
import keyboard
def on_key_event(event):
if event.event_type == "down":
print(event.scan_code)
keyboard.hook(on_key_event)
import logging
import pathlib
console_log_formatter = logging.Formatter('%(levelname)s: %(module)s.%(funcName)s() line:%(lineno)s; Message: %(message)s')
file_log_formatter = logging.Formatter('%(levelname)s: %(module)s.%(funcName)s(); line:%(lineno)s; Message: %(message)s')
detailed_formatter = logging.Formatter('%(levelname)s: %(module)s.%(funcName)s() line:%(lineno)s; Message: %(message)s')
simple_formatter = logging.Formatter('%(message)s')
# Custom handler to switch formats based on the log level
class LevelBasedFormatter(logging.StreamHandler):
def emit(self, record):
# Set the formatter based on the log level
if record.levelno == logging.INFO:
self.setFormatter(simple_formatter) # Use simple format for INFO level
else:
self.setFormatter(detailed_formatter) # Use detailed format for all other levels
super().emit(record)
# ----- Logging setup ---------------------------------------------------------
logc = logging.getLogger("console logger")
logf = logging.getLogger("file logger")
logc.setLevel(logging.DEBUG)
logf.setLevel(logging.DEBUG)
console_log_handler = logging.StreamHandler()
log_fname = pathlib.Path(__file__).parent.parent.joinpath(pathlib.Path(__file__).stem).with_suffix(".log")
file_log_handler = logging.FileHandler(filename=log_fname,mode="w")
# console_log_handler.setFormatter(console_log_formatter)
file_log_handler.setFormatter(file_log_formatter)
console_log_handler = LevelBasedFormatter()
logc.addHandler(console_log_handler)
logf.addHandler(file_log_handler)
# -----------------------------------------------------------------------------
import json
import pathlib, os
from types import SimpleNamespace
class Config:
CONFIG_PATH = pathlib.Path(os.path.dirname(os.path.realpath(__file__)))
CONFIG_FILE = 'config.json'
CONFIG_FILEPATH = CONFIG_PATH.joinpath(CONFIG_FILE)
# def __init__(self, config_file='config.json'):
def __init__(self, config_file=CONFIG_FILEPATH):
with open(file=config_file, mode='r', encoding='utf-8') as f:
self.config = json.load(f, object_hook=lambda d: SimpleNamespace(**d))
log in on A as user a and generate a pair of authentication keys. all commands from a@A:~>
ssh-keygen -t rsa
create a directory ~/.ssh as user b on B.
ssh b@B mkdir -p .ssh
append a's new public key to b@B:.ssh/authorized_keys:
cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
cmd %userprofile%
powershell $env:userprofile
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState 0,1,0
save as *.ps1 script
(Add-Type -MemberDefinition "[DllImport(""user32.dll"")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);" -Name "Win32SendMessage" -Namespace Win32Functions -PassThru)::SendMessage(-1, 0x0112, 0xF170, 2)