Skip to content

Instantly share code, notes, and snippets.

Rainyan /
Last active March 9, 2023 00:40
Fix for the Source SDK 2006 tools "Can't find steam app user info" error.
Rainyan /
Last active March 25, 2023 03:27
For "HOURS:MINUTES:SECONDS" start-end timestamp pair, return the difference in seconds.
#!/usr/bin/env python3
# License: MIT.
from datetime import datetime
import sys
# Usage:
# $ python 00:12:34 02:01:13
# $ 6519
Rainyan / sm_build_test.cmd
Last active January 4, 2023 04:00
Test script (Windows) for quickly building a plugin for multiple SM versions. Compiler binaries need to be downloaded to the relative dirs accordingly.
View sm_build_test.cmd
@ECHO off
SET TEST_FILE=source_code_filename_without_extension
SET DIVIDER=-----------------------------------------
cp .\ "%SMVER%\addons\sourcemod\scripting\include"
"%SMVER%\addons\sourcemod\scripting\spcomp.exe" %TEST_FILE%.sp
Rainyan /
Last active October 30, 2022 17:50
Quick and dirty SourcePawn inline benchmark for when you're feeling lazy. Just #include <benchmark> & wrap the tested code between BENCHMARK_START(); ... BENCHMARK_END(); Note that the START-END "stack" has to be unwound in the same LIFO order.
#if defined(_BENCHMARK_INC_H_)
#include <profiler>
// Can nest max this many profilers, total.
#define MAX_PROFILERS 32
Rainyan /
Last active November 20, 2022 01:20
Write a dummy file to disk, with optional parameters. Usage: ./ <num_mb filename use_mib verbose byte_to_write max_chunk_size>
#!/usr/bin/env python3
from inspect import signature
import os
import sys
# TODO: fix the megabytes/mebibytes inconsistency in comments/docstrings.
def write_data(
Rainyan / sapi51_patch.diff
Created August 28, 2022 11:00
Diff patch for the Source SDK 2013 dependency Microsoft Speech SDK 5.1 (sapi51) compile errors.
View sapi51_patch.diff
diff --git a/sphelper.h b/sphelper.h
index fbc5668..c684e32 100644
--- a/sphelper.h
+++ b/sphelper.h
@@ -767,7 +767,7 @@ inline HRESULT SpFindBestToken(
const WCHAR *pszVendorPreferred = L"VendorPreferred";
- const ulLenVendorPreferred = wcslen(pszVendorPreferred);
+ const size_t ulLenVendorPreferred = wcslen(pszVendorPreferred);
Rainyan / fix_sourcesdk2013_win_makescripts_vs2013_vcproj.reg
Created August 28, 2022 08:54
This is a fix for the Source SDK 2013 mp/src/createXprojects.bat scripts erroring out as: "ERROR: Unable to find RegKey for .vcproj or .vcxproj files in solutions."
View fix_sourcesdk2013_win_makescripts_vs2013_vcproj.reg
Windows Registry Editor Version 5.00
; This is a fix for the Source SDK 2013 mp/src/createXprojects.bat scripts erroring out as:
; ERROR: Unable to find RegKey for .vcproj or .vcxproj files in solutions.
Rainyan / Fix_Oculus_Quest_volume_limiter.adb
Last active October 29, 2022 03:24
Fix for the stupid headphones max volume regulation on some Android devices, making it difficult to drive high impedance headphones on the headset. Probably need to restart headset after applying. Source/credit for this fix:…
View Fix_Oculus_Quest_volume_limiter.adb
adb shell settings put secure unsafe_volume_music_active_ms 1
# reboot device
Rainyan /
Last active January 16, 2023 14:18
ROT-n cipher in Python, defaulting as ROT-13
from string import ascii_lowercase, ascii_uppercase
# Note that this already exists in Python as codecs.encode("text", "rot13")
# so you'd probably wanna use that instead of this implementation,
# unless you need a rotation of n places with n != 13.
def rot(text, rotation=13):
"""ROT13 cipher.
Decode by running the output through the function again
Rainyan / macros.doskey
Last active February 14, 2023 12:54
Some doskey macros for limited aliasing-like behaviour on Windows.
View macros.doskey
;= Some doskey macros for limited aliasing-like behaviour on Windows.
;= To install, drop this file into %USERPROFILE%\.config\macros.doskey, and run:
;= reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d "DOSKEY /MACROFILE=\"%USERPROFILE%\.config\macros.doskey\"" /f
;= Be sure to check the doskey docs before relying on this for complex stuff,
;= as there are some nonobvious ways in which more complex commands can fail:
;= Extract audio from a media url using yt-dlp.