Skip to content

Instantly share code, notes, and snippets.

View jerichosy's full-sized avatar

Matthew Jericho Sy jerichosy

View GitHub Profile
@jerichosy
jerichosy / jellyfin-vm-mount-lxc.md
Last active April 25, 2026 03:59
Mount LXC storage to VM in Proxmox

🚀 Accessing LXC Media from a Jellyfin VM (No Data Copy)

This guide shows how to make a Jellyfin VM access media stored in an LXC container — without copying your files — by reusing the existing disk and exposing it via VirtioFS.


🎯 Why Move Jellyfin from LXC to VM?

Originally, Jellyfin was running in an LXC container. The move to a VM was mainly to take advantage of PCIe passthrough so a GPU can be used for hardware transcoding in a more straightforward way.

@jerichosy
jerichosy / systemd_stuff.md
Last active December 19, 2024 17:32
A guide on how to write systemd unit files to start services in the background and on startup

systemd stuff

Create file sudo nano /etc/systemd/system/alecz.service (this is the correct directory) with the ff:

[Unit]
Description=Alecz Discord bot
After=network-online.target
Wants=network-online.target
@jerichosy
jerichosy / compare_inverse_sqrt.c
Last active September 24, 2024 23:21
Comparison between fast inverse square root and modern implementation
// Compile with `-lm` flag in gcc.
// Doesn't properly work with @I Run Code#2537 Discord bot.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
float Q_rsqrt( float number )
@jerichosy
jerichosy / aiohttp-dump_request_headers.py
Created August 28, 2024 14:52
Dumping the request headers with aiohttp
#!/usr/bin/env python3
# Source: https://stackoverflow.com/a/54204340
import aiohttp
import asyncio
async def on_request_start(session, trace_config_ctx, params):
print("Starting %s request for %s. I will send: %s" % (params.method, params.url, params.headers))
@jerichosy
jerichosy / NetworkUtils.java
Created February 29, 2024 00:04
Correctly find own IP address in Java
import java.net.*;
import java.util.*;
public class NetworkUtils {
public static String getExternalIPAddress() {
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
@jerichosy
jerichosy / whitelist_checker.py
Created August 6, 2023 21:59
Checks if Minecraft server player in usercache.json is not present in whitelist.json
import json
f = open('usercache.json')
usercache_dict = json.load(f)
f.close()
f = open('whitelist.json')
whitelist_dict = json.load(f)
f.close()
@jerichosy
jerichosy / clamp_number.py
Last active July 29, 2023 00:58
Clamp (clip, restrict) a number to some range - using min()/max() method
def clamp(n, smallest, largest):
return min(max(n, smallest), largest)
# Example:
for i in range(2, 11):
n = clamp(i, 4, 8)
print(n)
@jerichosy
jerichosy / page_range_parser.py
Last active July 29, 2023 00:59
This will parse page selection indices and ranges (e.g., "2", "9", "2, 9", "4-6", "1, 3-5, 8").
def parse_selected_pages(input_str, last_page):
pages = []
for part in input_str.split(","):
# Remove whitespaces
part = part.strip()
# Check if part contains a range (e.g. 4-6)
if "-" in part:
start, end = part.split("-")
@jerichosy
jerichosy / heroku_regions.json
Last active July 29, 2023 01:07
Heroku regions as of 230729
[
{
"country": "Ireland",
"created_at": "2013-09-19T01:29:12Z",
"description": "Europe",
"id": "ed30241c-ed8c-4bb6-9714-61953675d0b4",
"locale": "Dublin",
"name": "eu",
"private_capable": false,
"provider": {