Skip to content

Instantly share code, notes, and snippets.

View mikaelhg's full-sized avatar
🏠
Working from home

Mikael Gueck mikaelhg

🏠
Working from home
View GitHub Profile
@mikaelhg
mikaelhg / tracking.py
Created August 21, 2022 19:37
Five minute pedestrian tracking with norfair and yolov5 from Torch Hub
#!/bin/env python
import argparse
from typing import List
import numpy as np
import torch
import norfair
from norfair import Detection, Tracker, Video
@mikaelhg
mikaelhg / journal_listener.py
Last active August 7, 2023 09:50
rtw89 CTRL-EVENT-BEACON-LOSS workaround
#!/bin/env python
# journalctl -u wpa_supplicant -f -o json | python event_listener.py
import json
import sys
import subprocess
__BEACON_LOSS = 'CTRL-EVENT-BEACON-LOSS'
@mikaelhg
mikaelhg / build.sh
Created August 7, 2022 12:49
tippecanoe static build
CC=/usr/bin/clang-14 CXX=/usr/bin/clang++-14 \
CFLAGS="-static --ld-path=/usr/bin/ld.lld-14" \
CXXFLAGS="-static --ld-path=/usr/bin/ld.lld-14" \
LDFLAGS="-static" \
make -j16
@mikaelhg
mikaelhg / empty_favicon_data_link.html
Created December 18, 2021 08:28
Empty favicon.ico data link embedded in HTML page
@mikaelhg
mikaelhg / ubuntu_2104_gcc_alternatives.sh
Created May 8, 2021 20:27
Script for bringing all of the GCC versions on Ubuntu 21.04 into the alternatives system
#!/bin/sh
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 --slave /usr/bin/gcov gcov /usr/bin/gcov-8
@mikaelhg
mikaelhg / README.md
Last active April 7, 2021 12:54
Run a Finnish to English language translation model fully on your own computer, in minutes.

Run a Finnish to English language translation model fully on your own computer, in minutes.

Automatically downloads the 300 MB language model to your disk.

Install:

python -m venv venv
venv/bin/pip install torch transformers sentencepiece
@mikaelhg
mikaelhg / helsinki_maps.sh
Last active September 7, 2022 09:57
Generate static, Helsinki only map tiles from OpenStreetMap data
# Bounding box from http://norbertrenner.de/osm/bbox.html
HELSINKI_BBOX=24.577,60.079,25.228,60.335
# OpenStreetMap extract file from Geofabrik
wget https://download.geofabrik.de/europe/finland-latest.osm.pbf
# Cut the 500 MB Finland data file into a 34 MB Helsinki data file
# as this is much faster than using the import bbox.
osmconvert finland-latest.osm.pbf -b="$HELSINKI_BBOX" --out-pbf >helsinki.pbf
@mikaelhg
mikaelhg / UploadTestApplication.kt
Last active March 6, 2021 20:46
Spring multipart file upload test with TestRestTemplate and ByteArrayResource
package com.example.uploadtest
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
@SpringBootApplication
@mikaelhg
mikaelhg / cleanup.sh
Created March 5, 2021 10:14
Clean up after NVidia driver update failure
ls /var/lib/initramfs-tools | sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start
sudo update-initramfs -c -k all