Skip to content

Instantly share code, notes, and snippets.

View korjaa's full-sized avatar

Jaakko Korhonen korjaa

View GitHub Profile
@korjaa
korjaa / avg_dbm.py
Last active September 9, 2022 11:10
Average dBm
def average_dbm(dbms):
# https://en.wikipedia.org/wiki/Decibel
# https://en.wikipedia.org/wiki/LogSumExp
# Less numerically stable version:
# 10*numpy.log10(numpy.mean(numpy.power(10, (dbms-30)/10)))
bel_np = 0.5 * numpy.log(10) # Bel & Neper by definition
dbel_np = bel_np / 10
np_to_db = 1 / dbel_np
@korjaa
korjaa / cv2_player.py
Created August 7, 2022 18:45
OpenCV Player
import logging
import cv2
def main():
cap = cv2.VideoCapture("uhU.webm")
cap.set(cv2.CAP_PROP_POS_MSEC, 1000.0)
#cap.set(cv2.CAP_PROP_POS_FRAMES, 1000.0)
w, h = cap.get(cv2.CAP_PROP_FRAME_WIDTH), cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
@korjaa
korjaa / egpu_razer_core_x.md
Last active July 22, 2022 19:28
Notes for Ubuntu 20.04 external GPU setup

grub bootloader changes

Two changes were required for GRUB bootloader

Delay

Adding 15 second boot menu delay to grub config solves thunderbolt boot failure.

Delay is added to /etc/default/grub

$ cat /etc/default/grub
...
@korjaa
korjaa / buildroot.rst
Last active May 26, 2022 14:34
Buildroot & QEMU notes

Buildroot & QEMU

Navigating menuconfig

  • Search with /
  • Jump with 1

Building Commands

@korjaa
korjaa / bash.sh
Last active May 18, 2022 06:11
Bash snippets.
#
# Loops
#
# Loop files with weird names and reading from console stdin.
while IFS= read -r -d $'\0' FILE; do
read -p "Press Enter to continue to \"$FILE\"" </dev/tty
done < <(find . -printf "%P\0" | grep --null-data "filter")
# Loop files with less surprises
@korjaa
korjaa / gnuplot.plt
Last active October 7, 2021 09:39
Gnuplot spells
# Defaults
# ==========
set grid
set datafile separator ","
set print "-" # enable logging
print "Hello world"
set autoscale fix # Axes tight
# CSV column headers
# ====================
@korjaa
korjaa / factorio_red_circuit_15s.txt
Created January 26, 2020 10:02
Factorio - Red Circuit board 15/s
0eNqsvd2OJUeSpPkuvK4ouP2b9asMBgsWi8NOgM0kksnBNhr97hvFYmQeslxOyCe9V0T9UEJNVc3cj7iY6H9987cff/3+508ffvr8zb/91zcfvvv40y/f/Nv/+q9vfvnww0/f/viP/+7zf/78/Tf/9s2Hz9//xzd/+eanb//jH//p27//329/+u77v7989+HTd79++PzNf//lmw8//f37//ebfyv//Zebf/3/fvj0+dfX/+YLwj//Hy/14d+s//2///LN9z99/vD5w/f/jOK3//Cf/89Pv/7H377/9Ar95d/+/Onbn375+eOnzy9/+/7Hz6+oP3/85fVf+/jTP/7kK9RLbX/55j9f/7nnK/7fP3z6/rt//q/1H9H9CbYGsOO/b4AaACp+fB3AVh92+LDl+LATRHv5sCuIdvwRdt7A7iDaP8H2G9gDol1+EsoFcDfALQGukd1Sgzw4uGCnlQHyALZamQB3BLhOHmaQBweX7DZw0haw3f5RCxv3BLhGHuoV5MHBJfsNPCkq2W/gUVFbEK+Thx7E6+CC/QYebZVsN/BsqyvAddKweRocWLDbwMOtgc0Gnm2t8GiNJLTKo3VgwU4DD7YGNhp4rrXBo3WSMHm0DizYZuAh0cAuA8+Idjis82Pi4klwYMkTzU9CJ7/NAGzj0TpJ6DxaB9bfZSS1/iYDj5y+cKxOBjaO1UH1dxjoreFvMHAajIJRHQqg4gw4qP7uAg+F4W8ucHiPgWN1MjBxrA6qv7fAU3H4ewu8Ho2DUR1u6cIZcFD9vQXekqe/t8D74Ww4VicDHcfqoILnFuDW5uSw04AFT67yjAWemwM52fR3FPlpv/wtRZie9XVPffvLL9//x99+/PDTDy//8e13//7hp+9fyg3424Z9rc03r9Affvts8N3Hn3/+/tPLd9/+7cfvv7n7M/4mIzzg8ncZoamWv80Iu7jAPgOH7QL77Pj7bC0Oa5wKC+w6cIatA/v4yxcY1Mf7Cr5B9bvTZycfydotUg2+jbT3K7VbgNs
@korjaa
korjaa / gist:059127ad9c65cf0d71943c040fd989d7
Created September 17, 2019 14:25
MAF MAP Fuel Consumption
From: http://www.mp3car.com/vbulletin/engine-management-obd-ii-engine-diagnostics-etc/75138-calculating-mpg-vss-maf-obd2.html
For the record, the first "one-line" MPG formula above, taken from
my Circuit Cellar article, is off by 100! The "4.54" should in
fact be "454". The correct formula is:
MPG = (14.7 * 6.17 * 454 * VSS * 0.621371) / (3600 * MAF / 100) MPG
= 710.7 * VSS / MAF
@korjaa
korjaa / cool-retro-term-setup.sh
Last active August 22, 2019 09:54
cool-retro-term
# Install fromm Ubuntu Software Center
# Add following to ~/.bashrc
# Cool Retro Term doesn't properly identify as a 256 color terminal.
# Force it to identify as xterm-256color instead of just xterm.
[ -z "$COLORSCHEMES_DIR" ] || export TERM='xterm-256color'
@korjaa
korjaa / mbed_trace_remove_color.c
Created June 10, 2019 07:04
mbed_trace remove color.
mbed_trace_config_set(mbed_trace_config_get() & ~TRACE_MODE_COLOR);