Skip to content

Instantly share code, notes, and snippets.

@Rainyan
Rainyan / volume_common
Last active October 25, 2026 03:38
ad hoc wpctl sink volume control, for controlling a non-default sink via media keys
soundcard_sink_id() {
wpctl status | grep "Scarlett Solo" | head -n2 | tail -n1 | grep -oP "\d+\." | head -n1 | grep -oP "\d+"
}
notify_volume_change() {
SINK_ID="$1"
NEW_VOLUME_MSG="$(wpctl get-volume $SINK_ID)"
# Trim: "Volume: 0.12 [MUTED]" -> "0.12 [MUTED]"
NEW_VOLUME_SCALAR="${NEW_VOLUME_MSG#*: }"
@Rainyan
Rainyan / hello.asm
Last active September 7, 2026 18:10
x64 MS ASM example
.data
greeting BYTE "Hello, World!", 10
.code
extern GetStdHandle:proc
extern WriteConsoleA:proc
helloworld proc
sub rsp, 28h ; 32 bytes of shadow space + 8 bytes for the 5th arg of WriteConsoleA
@Rainyan
Rainyan / dpi.ps1
Last active August 5, 2026 18:33
Steam Remote Play convenience script for faux-"rdp" for a Windows host. Todo: merge all of this into one script for simplicity.
# https://stackoverflow.com/questions/10365394/change-windows-font-size-dpi-in-powershell/68215326#68215326
function Set-Scaling {
# Posted by IanXue-MSFT on
# https://learn.microsoft.com/en-us/answers/questions/197944/batch-file-or-tool-like-powertoy-to-change-the-res.html
# $scaling = 0 : 100% (default)
# $scaling = 1 : 125%
# $scaling = 2 : 150%
# $scaling = 3 : 175%
param($scaling)
$source = @'
::SnowfallEvents <- {
function LowerElevatorByDeltaTime(dt)
{
local elevator = Entities.FindByName(null, "elevator");
Assert(elevator.IsValid());
local elevatorOrigin = elevator.GetOrigin();
// The assumed elevator brush world coordinate after the sequence.
const finalElevatorHeight = -160;
@Rainyan
Rainyan / concave_object_to_convex_objects_by_face.py
Created March 19, 2026 16:41 — forked from GuyPaddock/concave_object_to_convex_objects_by_face.py
Blender 2.91 Script for Convex Hull Decomposition into Separate Shapes Using Blender's Convex using "Split Concave Faces"
##
# A script to split simple, architectural geometry into convex pieces.
#
# This script makes use of Blender's built-in "Split Concave Faces" clean-up
# algorithm to break-up the faces of an object into convex pieces. The script
# attempts to identify all the edges that represent convex boundaries, and then
# it splits objects up along those edges. Each resulting piece is then made into
# a closed object by converting it into a convex hull.
#
# Be sure to select the object you wish the split into convex pieces before
@Rainyan
Rainyan / phys_lump_size.py
Last active September 18, 2026 16:02
Read the physics lump size from a Source engine BSP
#!/usr/bin/python3
import os
import struct
import sys
def get_phys_lump_size(bsp_path: os.PathLike) -> int:
"""Read the physics lump size from a Source engine BSP"""
lump_phys = 29
@Rainyan
Rainyan / nt_cbaseentitylist.sp
Created January 7, 2026 21:11
CBaseEntityList overrides for NT from SourceMod (untested)
#include <sourcemod>
#include <dhooks>
#pragma semicolon 1
#pragma newdecls required
static int _numAdds = 0;
public void OnPluginStart()
{
@Rainyan
Rainyan / .bashrc
Last active August 12, 2025 13:25
NT;RE Linux buildenv alias
# Assuming deps installed as per: https://github.com/NeotokyoRebuild/neo?tab=readme-ov-file#linux-prerequisite---steam-runtime-3-sniper-container
# Assuming pwd of NT;RE code repo root dir.
# Following the "buildenv" command, enter the following commands inside the container:
# cd /root/neo/src
# cmake --preset linux-debug # or linux-release
# cmake --build --preset linux-debug # or linux-release
alias buildenv='sudo docker run -v .:/root/neo/ --rm -it --entrypoint /
│ bin/bash registry.gitlab.steamos.cloud/steamrt/sniper/sdk'
@Rainyan
Rainyan / sm_compile.py
Last active September 1, 2025 12:40
SourceMod batch multicompile Python 3 script for Windows. For Linux, see Bash script: https://gist.github.com/Rainyan/f09aaca597d9197a92fc0342d5d20176
#!/usr/bin/env python3
import os
from pathlib import Path
import subprocess
# Without file extension
PLUGIN = "nt_spec_quicktarget"
# Assuming code lives in ./scripting of this
REPO_NAME = "sourcemod-nt-spec-quicktarget"
@Rainyan
Rainyan / memtools.inc
Last active June 27, 2025 09:31
Call malloc, realloc, free from SourceMod plugins, with optional automatic memory cleanup. Gamedata available only for Neotokyo (2006/ep1 engine, Windows 32bit), but could probably be used for other games too with some modifications. Tested on SM version 1.12. Experimental; use at own risk.
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
// SemVer 2.0.0
#define MEMTOOLS_VERSION_MAJOR 0
#define MEMTOOLS_VERSION_MINOR 1
#define MEMTOOLS_VERSION_PATCH 0