Skip to content

Instantly share code, notes, and snippets.

View tekk's full-sized avatar

Peter Javorsky tekk

View GitHub Profile
@tekk
tekk / lipol-battery-voltage-to-percents.cpp
Created November 26, 2025 17:24
Li-Ion / Li-Pol battery percentage interpolation - better algorithm with lookup table
#include <array>
#include <cstddef>
#include <algorithm>
struct LipoPoint {
float voltage;
float percent;
};
static constexpr std::array<LipoPoint, 21> kLipoCurve = {{

Backup and restore like a pro

Use Clonezilla!

But if you want to do it manually in the shell, with post-quantum encryption, do it this way:

Prerequsities

  • zstd - ZStandard is a real-time compression algorithm with compression ratios similar to brotli or standard deflate (zip)
  • rust & cargo - cargo is needed to install rage (use package manager of your choice)
// Cycloidal Drive(s) for 28BYJ-48 + M3 screws OR 623ZZ bearings
// Author: Peter "Tekk" Javorsky, OM7TEK
// Single-file parametric OpenSCAD. Set `part` below to generate each printed part.
// Units: millimeters.
/********************** CONFIG *************************/
part = "assembly_v1"; // choices: motor_mount, hub_eccentric, cycloid_disk_v1, ring_pins_v1, output_carrier_v1, spacer, cover,
// cycloid_disk_v2, ring_rollers_v2, output_carrier_v2, assembly_v1, assembly_v2
// Global tolerances
@tekk
tekk / SCD40.md
Last active September 29, 2025 19:10

SCD40 CO2 Sensor with ESP8266 D1 mini and ESPHome

Connect a Sensirion SCD40 CO2 sensor to an ESP8266 D1 mini and run it with ESPHome. This allows you to measure CO2, temperature, and humidity in your room and integrate the data into Home Assistant, Prometheus, or MQTT.

Wiring

SCD40 ESP8266
VCC 3V3
GND G
@tekk
tekk / how_to_add_ctrl_alt_t_shortuct_to_open_terminal_and_terminal_integrations_on_macos_2025.md
Created July 9, 2025 11:07
How to add Ctrl + Alt + T keyboard shortcut similar to Linux to open Terminal on MacOS (2025 guide)

How to add Ctrl + Alt + T keyboard shortcut similar to Linux to open Terminal on MacOS (⌃ + ⌘ + T 2025 how-to guide)

On macOS there is no global “open Terminal” shortcut out of the box.

  • Option (⌥)+⌘+T is already used in Finder to show/hide the toolbar.
  • Control (⌃)+⌘+T isn’t assigned system-wide (only in some apps for context-specific commands), so it’s free to grab for a global hot-key.

Below is a Linux-style setup using Automator + System Settings so that ⌃+⌘+T will launch Terminal no matter which app you’re in.


def hsv_to_rgb(h, s, v):
if s == 0.0:
r, g, b = v, v, v
else:
i = int(h * 6.0)
f = (h * 6.0) - i
p = v * (1.0 - s)
q = v * (1.0 - s * f)
t = v * (1.0 - s * (1.0 - f))
i = i % 6
@tekk
tekk / msys2.reg
Created February 7, 2019 12:05 — forked from magthe/msys2.reg
MSYS2 "Open Here" registry settings
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\open_msys2]
@="Open MSYS2 here"
[HKEY_CLASSES_ROOT\Directory\Background\shell\open_msys2\command]
@="c:\\msys64\\usr\\bin\\mintty.exe /bin/sh -lc 'cd \"$(cygpath \"%V\")\"; exec bash'"
[HKEY_CLASSES_ROOT\Folder\shell\open_msys2]
@="Open MSYS2 here"
@tekk
tekk / ring.ino
Last active August 13, 2024 03:28
Neopixel Ring Wemos D1 Mini
#include <Adafruit_NeoPixel.h>
#define PIN D7
#define STRIPSIZE 16
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIPSIZE, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.setBrightness(25); // Lower brightness and save eyeballs!
@tekk
tekk / serial_tekk.py
Created April 23, 2018 03:04
Serial list ports in Python - serial_ports()
import sys
import glob
import serial
def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms