Skip to content

Instantly share code, notes, and snippets.

@Rainyan
Rainyan / gh_disable_shortcuts.user.js
Last active July 18, 2023 16:15
Make the GitHub web interface usable by turning off all its forced keyboard shortcuts that are interfering with browser and OS shortcuts.
View gh_disable_shortcuts.user.js
// ==UserScript==
// @name Disable all GitHub shortcut keys
// @description Make the GitHub web interface usable by turning off all its forced keyboard shortcuts that are interfering with browser and OS shortcuts.
// @version 0.3.0
// @namespace githubPls
// @include https://github.com/*
// @updateURL https://gist.githubusercontent.com/Rainyan/bdc81d2280936e26ac8690e7ac1292f9/raw/
// ==/UserScript==
const ALLOWED_KEYS = [
@Rainyan
Rainyan / files_of_dir.sp
Created June 21, 2023 00:30
Get files of a directory as DataPack for SourceMod
View files_of_dir.sp
// For path "dir_path", get files that match the "filter_by_extension" filter,
// and pass them by reference to a valid DataPack "out_datapack".
// Optionally supports SM's OpenDirectory parameters.
// Returns the number of files passed by reference.
// Caller is responsible for initializing and freeing the DataPack memory.
int GetFilesOfDir(const char[] dir_path, DataPack out_datapack,
const char[] filter_by_extension="",
bool use_valve_fs=false, const char[] valve_path_id="GAME")
{
int num_files_found = 0;
@Rainyan
Rainyan / get_aspect_ratio.py
Last active May 7, 2023 12:51
Return the aspect ratio of a screen resolution.
View get_aspect_ratio.py
#!/usr/bin/env python3
import sys
def get_aspect_ratio(width: int, height: int) -> tuple[int, int]:
"""Return the aspect ratio of a screen resolution."""
a, b = width, height
while b != 0:
temp = b
@Rainyan
Rainyan / autohotkey.ahk
Last active April 25, 2023 00:42
My AutoHotkey stuff
View autohotkey.ahk
; Ripcord doesn't have mouse binds yet, so use F24 redirection as the mic mouse bind.
#HotIf WinExist("ahk_exe Ripcord.exe")
*$~xButton1::F24 ; don't block the mouse action, just replicate as a function key
#HotIf
; Disable left Windows key when inside CS:GO to avoid mispresses
#HotIf WinActive("ahk_exe csgo.exe")
~LWin::vkFF ; only block plain key press, ie. still allow Win+key combos
#HotIf
@Rainyan
Rainyan / yt-dehyperlink-chat.user.js
Last active October 27, 2023 10:18
For YouTube A/B testing victims. Removes the unhelpful clickable fake links, when trying to highlight text in YT live stream chat.
View yt-dehyperlink-chat.user.js
@Rainyan
Rainyan / fix_sdk06_tools.md
Last active April 2, 2023 16:53
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(