Skip to content

Instantly share code, notes, and snippets.

@ReinforceZwei
ReinforceZwei / pve_list_instances.py
Created June 28, 2026 10:50
Python script to get VM/LXC list and details from Proxmox VE. Create an API token with permission to read VMs (e.g. PVEAuditor) and put it in .env file (SECRET, TOKEN_ID, PVE_ID)
import argparse
import json
import os
import ssl
import sys
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.parse import urlparse
from urllib.request import Request, urlopen
@ReinforceZwei
ReinforceZwei / override_created_field.pb.js
Created April 25, 2024 08:21
Pocketbase Javascript hook to allow overriding created/updated when creating record
// Override created/updated field from request data
onRecordBeforeCreateRequest((e) => {
const requestData = $apis.requestInfo(e.httpContext)
const overrideCreated = requestData.data['override_created']
const overrideUpdated = requestData.data['override_updated']
if (overrideCreated) {
e.record.set('created', overrideCreated)
@ReinforceZwei
ReinforceZwei / calendarSundayFirst.js
Created December 21, 2023 02:55
Trilium Calendar: Set Sunday as first weekday
// Move "SUN" to first day of week
$('.calendar-week').children().last().prependTo('.calendar-week')
let marginStep = 14.28;
let config = {
childList: true,
subtree: true
}
let callback = (mutationList, observer) => {
@ReinforceZwei
ReinforceZwei / switch_input.ahk
Last active June 7, 2023 09:04
Custom AHK script to one-click switch monitor input source and display scaling, using Nirsoft Control My Monitor
#Requires AutoHotkey v2.0
SWITCH_INPUT := 17
LAPTOP_INPUT := 15
SCALE_16_9_VALUE := 20
CODE_INPUT_SELECT := 60
CODE_SCALING := 86
CTRL_MON_EXE := "controlmymonitor.exe"
@ReinforceZwei
ReinforceZwei / oled_clock.py
Last active December 13, 2022 08:20
OLED display clock for SSD1306 + Raspberry Pi
import time
from datetime import datetime
import Adafruit_GPIO.SPI as SPI
import Adafruit_SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
@ReinforceZwei
ReinforceZwei / clock.ps1
Last active July 20, 2022 04:36
A pixel style digital clock in PowerShell
function draw-box {
param([string]$content)
if ($content.length){
$content = "| $content |"
$border = '+' + ('-' * ($content.length - 2)) + '+'
echo $border
echo $content
echo $border -no
}
}
@ReinforceZwei
ReinforceZwei / match_video_ass.py
Created June 9, 2022 08:57
Rename subtitle file (e.g. .ass file) to match video file name so that video player can pick them up automically
import os, sys
from os import listdir
from os.path import isfile, join
from pathlib import Path
def must_get_dir_params(argv):
video_dir = ""
ass_dir = ""
if len(argv) == 3:
video_dir = argv[1]
@ReinforceZwei
ReinforceZwei / sss.ps1
Created June 4, 2022 12:52
Powershell script to reduce typing SSH command
#member -in $args
[CmdletBinding(PositionalBinding=$false)]
param(
[Parameter(Position=0)]
[string]$Name,
[switch]$Add,
[switch]$List,
[switch]$Help,
[Parameter(
ValueFromRemainingArguments = $true
@ReinforceZwei
ReinforceZwei / v_ramdisk.ps1
Last active May 4, 2023 09:59
Create temporary drive that will clean up itself on every start up
Add-Type -AssemblyName System.Windows.Forms
$workingDirectory = 'D:\v_ram'
$daysBeforeDelete = 3
$driveLetter = 'S:'
$workFolder = 'current'
$backupFolder = 'backup'
$dateFormat = 'yyyy_MM_dd'
@ReinforceZwei
ReinforceZwei / SunmobileDataUsage.py
Created December 23, 2021 10:59
查詢SunMobile手機號碼數據用量
import requests
import time
from bs4 import BeautifulSoup
LOGIN_URL = "https://www.sunmobile.com.hk/cs/topup/login"
DATA_USAGE_URL = "https://www.sunmobile.com.hk/cs/topup/value_add_servicePlan?datatime{}&mylocale=ch"
class SunMobile:
@staticmethod
def login(number, password):