Skip to content

Instantly share code, notes, and snippets.

View Rainyan's full-sized avatar
💭
I may be slow to respond.

Rain Rainyan

💭
I may be slow to respond.
  • Finland
  • 21:49 (UTC +03:00)
View GitHub Profile
@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.
#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>
#!/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.
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
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#…
adb shell settings put secure unsafe_volume_music_active_ms 1
# reboot device
@Rainyan
Rainyan / rot13.py
Last active May 5, 2023 17:06
ROT-n cipher in Python 3, 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):
"""ROT-n cipher.
Decode by running the output through the function again
@Rainyan
Rainyan / macros.doskey
Last active June 4, 2023 18:16
Some doskey macros for limited aliasing-like behaviour on Windows. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/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.
@Rainyan
Rainyan / yt-reverse-playlist.user.js
Last active March 27, 2022 16:05
WIP; currently this just flips the playlist but it doesn't persist and it won't affect autoplay.
// ==UserScript==
// @name YouTube Reverse Playlist
// @namespace yt-reverse-playlist
// @updateURL https://gist.githubusercontent.com/Rainyan/28f85d23de9ac850a3d27ae39d4d1e62/raw/
// @version 0.2.1
// @description Adds a playlist button to reverse/invert the current YouTube playlist. Useful when wanting to watch oldest to newest, or vice versa.
// @author Rain
// @match https://www.youtube.com/*
// @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.2/waitForKeyElements.js
// @require https://code.jquery.com/jquery-3.6.0.slim.min.js
@Rainyan
Rainyan / git_checkout_latest_tag.cmd
Last active November 30, 2021 02:51
git checkout at latest tag (Windows)
@ECHO off
git pull
REM Use single '%' symbols to call directly from command prompt: %%a -> %a
for /f "delims=" %%a in ('git describe --tags --abbrev^=0') do set "tag=%%a"
git checkout %tag%
git status
@Rainyan
Rainyan / fix-old-reddit-links.user.js
Last active January 8, 2023 14:58
Fix old reddit URLs – Fixes problems with displaying old.reddit URLs. Examples of breakage include links with underscores, double quotes, or trailing closing braces. If you also want to enforce old.reddit via another userscript, see: https://gist.github.com/Rainyan/fbb1ff337eac3e6c604d9a6eee7badda