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 / SystemProperties.kt
Last active July 13, 2023 20:38
Kotlin utility class for easily fetching standard system props
View SystemProperties.kt
package io.mikael
import java.time.LocalDate
object SystemProperties {
operator fun get(key: String): String? = System.getProperty(key)
fun get(key: String, default: String): String = get(key) ?: default
@mikaelhg
mikaelhg / zstd_compress.py
Created June 29, 2023 13:46
Setting zstd compression level to 22 with pandas and parquet
View zstd_compress.py
import pandas as pd
df = ...
df.to_parquet("foobar.parquet.zst", compression='zstd', compression_level=22)
View logging.kt
internal inline fun <reified T : Any> T.getClassLogger() : java.util.logging.Logger
= java.util.logging.Logger.getLogger(T::class.java.name)
@mikaelhg
mikaelhg / runrandr.sh
Created February 2, 2023 12:33
Use xrandr to reset screens
View runrandr.sh
xrandr --output eDP --auto
xrandr --output HDMI-A-0 --auto
View xsessionrc
#!/bin/bash
export QT_AUTO_SCREEN_SCALE_FACTOR=1
export QT_SCREEN_SCALE_FACTORS=2
/usr/bin/synclient TapButton3=2 &
@mikaelhg
mikaelhg / 01_README.md
Last active November 14, 2022 12:19
Hetzner + Caddy + GoToSocial
View 01_README.md

Zero to self-hosted Fediverse presence

With Hetzner + Caddy + GoToSocial.

1. You probably already have some way to host content on the Internets, but if not, get a $5 Hetzner cloud server. I just put it on my home server, a old repurposed thin client.

2. Install Caddy.

@mikaelhg
mikaelhg / README.md
Last active September 19, 2022 09:13
Get started with Protomaps single-file static map hosting
View README.md

Get started with Protomaps single-file static map hosting

Install tools

Install Python 3 with pip, and Java 11+ - I used 18.

pip install --user --upgrade pmtiles
wget https://github.com/onthegomap/planetiler/releases/download/v0.5.0/planetiler.jar
@mikaelhg
mikaelhg / pno_2022_download.sh
Last active October 19, 2022 06:24
Postinumeroalueet 2022 query and conversion to GeoJSON (Paavo)
View pno_2022_download.sh
#!/bin/bash
wget -O pno_2022.zip \
'https://geo.stat.fi/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&typeName=postialue:pno_2022&outputFormat=SHAPE-ZIP'
unzip pno_2022.zip
ogr2ogr -f GeoJSON -s_srs pno_2022Polygon.prj -t_srs EPSG:4326 \
-lco RFC7946=YES pno_2022.geojson.iso88591 pno_2022Polygon.shp
iconv -f iso-8859-15 -t utf-8 < pno_2022.geojson.iso88591 > pno_2022.geojson
pigz -k pno_2022.geojson
@mikaelhg
mikaelhg / keybindings.json
Created August 27, 2022 12:34
Some VS Code keybindings
View keybindings.json
[
{ "key": "alt+1", "command": "workbench.action.openEditorAtIndex1" },
{ "key": "alt+2", "command": "workbench.action.openEditorAtIndex2" },
{ "key": "alt+3", "command": "workbench.action.openEditorAtIndex3" },
{ "key": "alt+4", "command": "workbench.action.openEditorAtIndex4" },
{ "key": "alt+5", "command": "workbench.action.openEditorAtIndex5" },
{ "key": "alt+6", "command": "workbench.action.openEditorAtIndex6" },
{ "key": "alt+7", "command": "workbench.action.openEditorAtIndex7" },
{ "key": "alt+8", "command": "workbench.action.openEditorAtIndex8" },
{ "key": "alt+9", "command": "workbench.action.openEditorAtIndex9" },
@mikaelhg
mikaelhg / tracking.py
Created August 21, 2022 19:37
Five minute pedestrian tracking with norfair and yolov5 from Torch Hub
View tracking.py
#!/bin/env python
import argparse
from typing import List
import numpy as np
import torch
import norfair
from norfair import Detection, Tracker, Video