Skip to content

Instantly share code, notes, and snippets.

@Rainyan
Rainyan / fix_sdk06_tools.md
Last active March 9, 2023 00:40
Fix for the Source SDK 2006 tools "Can't find steam app user info" error.
View fix_sdk06_tools.md
@Rainyan
Rainyan / timestamp_delta.py
Last active March 25, 2023 03:27
For "HOURS:MINUTES:SECONDS" start-end timestamp pair, return the difference in seconds.
View timestamp_delta.py
#!/usr/bin/env python3
# License: MIT. https://github.com/Rainyan
from datetime import datetime
import sys
# Usage:
# $ python timestamp_delta.py 00:12:34 02:01:13
# $ 6519
@Rainyan
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=-----------------------------------------
ECHO %DIVIDER%
SET SMVER=1.7
cp .\neotokyo.inc "%SMVER%\addons\sourcemod\scripting\include"
"%SMVER%\addons\sourcemod\scripting\spcomp.exe" %TEST_FILE%.sp
ECHO %DIVIDER%
@Rainyan
Rainyan / benchmark.inc
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.
View benchmark.inc
#if defined(_BENCHMARK_INC_H_)
#endinput
#else
#define _BENCHMARK_INC_H_
#endif
#include <profiler>
// Can nest max this many profilers, total.
#define MAX_PROFILERS 32
@Rainyan
Rainyan / write_dummy_data.py
Last active November 20, 2022 01:20
Write a dummy file to disk, with optional parameters. Usage: ./write_dummy_data.py <num_mb filename use_mib verbose byte_to_write max_chunk_size>
View write_dummy_data.py
#!/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
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(
HRESULT hr = S_OK;
const WCHAR *pszVendorPreferred = L"VendorPreferred";
- const ulLenVendorPreferred = wcslen(pszVendorPreferred);
+ const size_t ulLenVendorPreferred = wcslen(pszVendorPreferred);
@Rainyan
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." https://github.com/ValveSoftware/source-sdk-2013/issues/72#issuecomment-20534954
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.
; https://github.com/ValveSoftware/source-sdk-2013/issues/72#issuecomment-20534954
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\VC\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}]
"DefaultProjectExtension"="vcproj"
@Rainyan
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: https://forums.oculusvr.com/t5/Support/Headphones-plugged-into-Quest-2-can-t-turn-volume-to-max/m-p/937395/highlight/true#…
View Fix_Oculus_Quest_volume_limiter.adb
adb shell settings put secure unsafe_volume_music_active_ms 1
# reboot device
@Rainyan
Rainyan / rot13.py
Last active January 16, 2023 14:18
ROT-n cipher in Python, defaulting as ROT-13
View rot13.py
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
Rainyan / macros.doskey
Last active February 14, 2023 12:54
Some doskey macros for limited aliasing-like behaviour on Windows. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/doskey
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:
;= https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/doskey
;= Extract audio from a media url using yt-dlp.