Skip to content

Instantly share code, notes, and snippets.

View martin-kokos's full-sized avatar
πŸ’­
Looking for collaboration

martin-kokos martin-kokos

πŸ’­
Looking for collaboration
View GitHub Profile
AliExpress RGBW E27 Lightbulb. Marking; AC85-265V 50/60Hz
18W RGB+2700-6500K
- marked 18W
- in reality 18VA, power factor 0.6, so 10W
- works with Tuya app
- board housing part is aluminum
- LED board is aluminum
- casing, easy to open, white silicone
- LED board easy to pry up, on connector
@martin-kokos
martin-kokos / venv_audit.md
Created July 5, 2025 14:32
Audit python virtual environments

Venvs can go stale. Find venvs with old python versions. Using the pyenv.cfg file works across venv, poetry, etc.

$ find ~ -name pyvenv.cfg |xargs grep -h executable |sort | uniq -c
     11 base-executable = /usr/bin/python3.10
     56 base-executable = /usr/bin/python3.11
     26 base-executable = /usr/bin/python3.12
      6 base-executable = /usr/bin/python3.13
      5 base-executable = /usr/bin/python3.9
 1 base-executable = /usr/lib/python-exec/python3.11/python3
@martin-kokos
martin-kokos / opencv_shared_enum_dict.md
Last active May 30, 2025 07:25
OpenCV shared option enum space

OpenCV functions use argument to modify their behavior. These arguments are integers which have special meaning, also called enums. These enums share the same integer space. You can sometimes see this in the wild and in docs that people use nondescript numbers as options when calling a function (even without keywords) eg. cv2.putText(img, "yolo", (10, 20), 0, 1, (255, 255, 255), 1, 2). Due to this it is possible to set the wrong option to the wrong funciton and OpenCV he no way to check for this (not that it does much checking).

For example the following example unexpectedly opens the image in grayscale mode because cv2.ROTATE_180 is int(0) and that is interpreted in this function as cv2.IMREAD_GRAYSCALE (sometimes the prefix of the option is not obvious):

img = cv2.imread('myimage.jpg', cv2.ROTATE_180)

(Sometimes, options can be combined by for more "fun" just like bitmasks - by adding them up)

❌ FAIL: torch=2.1.0 torchvision=0.1.6 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.1.7 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.1.8 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.1.9 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.2.0 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.2.1 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.2.2 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.2.2.post2 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.2.2.post3 (exit=1)
❌ FAIL: torch=2.1.0 torchvision=0.9.1 (exit=1)
@martin-kokos
martin-kokos / mini_metrics.md
Last active April 22, 2025 09:09
Mini metrics server setup VictoriaMetrics (Datadog-like)

This is a very minimal setup how to achieve a minimal metrics server for a small project or an embedded setup. Install VictoriaMetrics. https://docs.victoriametrics.com/quick-start/#starting-vm-single-from-a-binary

Install

Essentially:

VM_VERSION="v1.112.0"
wget -O /tmp/victoria-metrics.tar.gz "https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/${VM_VERSION}/victoria-metrics-linux-arm64-${VM_VERSION}.tar.gz"
sudo tar -xvf /tmp/victoria-metrics.tar.gz -C /usr/local/bin
sudo useradd -s /usr/sbin/nologin victoriametrics || true
@martin-kokos
martin-kokos / distcc_ubuntu.md
Last active June 1, 2024 09:58
Install gcc-14 and distcc on Ubuntu

Install gcc

apt install software-properties-common  # installs apt-add-repository
# apt-add-repository ppa:ubuntu-toolchain-r/test
apt-add-repository universe
apt update
apt install gcc-14 g++-14
ll /usr/bin/gcc-14
ll /usr/bin/g++-14
update-alternatives --display gcc
@martin-kokos
martin-kokos / task_manager.py
Last active January 8, 2021 14:40
Simple multiprocessing task manager
'''
If the tasks are inequally sized, it may happen with starmap and similar schedulers
which schedule tasks ahead of time, that some workers are lucky and finish early and some unlucky
and finish much later having the effect of the task batch using all CPU cores at first,
but then lucky workers finishing and core sitting idle.
This task manager serves as an example on how to have workers fetch tasks from a Queue.
Joblib, Pool.starmap or something else might be better, but maybe this is useful.
'''
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
JAVA_ANT_ENCODING=UTF-8
ESVN_REPO_URI="https://josm.openstreetmap.de/svn/trunk"
inherit eutils java-pkg-2 java-ant-2 subversion desktop
@martin-kokos
martin-kokos / kravi_hora_server.py
Last active August 31, 2020 18:48
Kravi hora occupancy provider
'''
Provides occupancy number http://localhost:8080/kravi_hora
'''
import logging
import re
import requests
from bs4 import BeautifulSoup
from aiohttp import web
@martin-kokos
martin-kokos / Webexpo 2019.md
Last active June 24, 2021 15:37
Webexpo 2019