Skip to content

Instantly share code, notes, and snippets.

View krzys-h's full-sized avatar

Krzysztof Haładyn (krzys_h) krzys-h

View GitHub Profile
@krzys-h
krzys-h / README.md
Last active April 30, 2024 22:03
Public IP for a home lab using a VPS as a proxy
  1. Buy a second IP on your VPS ([PUBLIC_IP])
  2. Do NOT set it up on any local interface. Instead, set up a Wireguard server which will let you use the IP on the other end of the tunnel, and set up IP forwarding and proxy ARP such that the VPS will present it to the provider network as if it was local. Example:
    cat > /etc/wireguard/wg0.conf <<EOF
    [Interface]
    ListenPort = ...
    PrivateKey = ...
    
    [Peer]

AllowedIPs = [PUBLIC_IP]/32

@krzys-h
krzys-h / config.ini
Last active October 14, 2022 10:47
[polybar] Start polybar on all monitors and restart on monitor configuration change
[barsettings]
monitor = ${env:MONITOR:}
; ... any other global settings for all bars ...
[bar/top]
inherit=barsettings
bottom=false
modules-left = ...
modules-center = ...
@krzys-h
krzys-h / read_els.py
Last active October 16, 2023 09:26
Reading ELS (Elektroniczna Legitymacja Studencka) data on Linux
# TODO: verify signatures
# TODO: clean up the APDU code
# Some documentation on the ELS format: https://isap.sejm.gov.pl/isap.nsf/download.xsp/WDU20062241634/O/D20061634.pdf
from smartcard.System import readers
from binascii import hexlify, unhexlify
from pyasn1_modules import rfc2315
from pyasn1.codec.der.decoder import decode as der_decoder
from pyasn1.type import univ
@krzys-h
krzys-h / main.cpp
Last active April 30, 2022 12:14
WWW18 GameBoy qualification tasks
// sudo apt-get install libsdl2-dev
// g++ -O3 main.cpp -lSDL2 -I/usr/include/SDL2 -o main
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <SDL.h>
//#define DEBUG_TILES
@krzys-h
krzys-h / Hyper-V GPU-PV with Linux guest.md
Last active April 30, 2024 21:56
Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Ubuntu 21.04 VM with GPU acceleration under Hyper-V...?

Modern versions of Windows support GPU paravirtualization in Hyper-V with normal consumer graphics cards. This is used e.g. for graphics acceleration in Windows Sandbox, as well as WSLg. In some cases, it may be useful to create a normal VM with GPU acceleration using this feature, but this is not officially supported. People already figured out how to do it with Windows guests though, so why not do the same with Linux? It should be easy given that WSLg is open source and reasonably well documented, right?

Well... not quite. I managed to get it to run... but not well.

How to do it?

  1. Verify driver support
@krzys-h
krzys-h / validate.sh
Created April 11, 2021 13:58
Validating e-DO App (Polish e-dowód electronic ID) signed files on Linux
#!/bin/bash
DIR=/tmp/pl.ID_CA
rm -rf $DIR
mkdir $DIR
# Import the root CA
curl -sS http://repo.e-dowod.gov.pl/certs/PLID_Root_CA.cer | certutil -d $DIR -A -n "PLID_Root_CA.cer" -t "C,C,C"
# Verify the root CA fingerprint against https://www.gov.pl/attachment/325d4a20-6347-454c-b3dd-9164535021ee (page 5)
@krzys-h
krzys-h / keybase.md
Created February 1, 2021 23:16
Keybase proof

Keybase proof

I hereby claim:

  • I am krzys-h on github.
  • I am krzys_h (https://keybase.io/krzys_h) on keybase.
  • I have a public key ASBPsWySGX2e8XG6RP5GB4dDMfqm8pn2JuRGtQmZ9iG5Ogo

To claim this, I am signing this object:

@krzys-h
krzys-h / journalctl_to_plymouth.sh
Created January 15, 2021 00:09
Display systemd init messages on the plymouth boot screen
#!/bin/sh
journalctl --quiet -f -n0 --system -t systemd -o cat | while read -r line; do
plymouth display-message --text="$line"
if [ $? -ne 0 ]; then
break
fi
done
echo "Plymouth died, exiting..."
@krzys-h
krzys-h / encrypt.sh
Last active February 24, 2024 22:26
Encrypt existing partitions with LUKS2 on Ubuntu 20.04
#!/bin/bash
# Encrypt an existing partition with LUKS2 on Ubuntu 20.04 LTS
# DISCLAIMER: USE AT YOUR OWN RISK AND MAKE BACKUPS
# Made for my personal use and has almost NO error checking!!
# Based on instructions from:
# https://wiki.archlinux.org/index.php/dm-crypt/Device_encryption#Encrypt_an_existing_unencrypted_filesystem
DISK="$1"
@krzys-h
krzys-h / SpriteOverlayer.cs
Created April 29, 2019 10:29
UndertaleModLib overlay hitboxes on sprites
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;