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
  • 16:28 (UTC +03:00)
View GitHub Profile
@Rainyan
Rainyan / wine_japanese_locale.sh
Last active February 17, 2022 16:49
Wine Japanese locale oneliner
LANG="ja_JP.UTF8" wine binary
# Alternative
LC_ALL="ja_JP" wine binary
@Rainyan
Rainyan / debug_example.sh
Last active October 18, 2019 18:56
ptrace toggling kludge for debug stuff
#!/bin/bash
# This script toggles ptrace protection for attaching a debugger during development.
# kernel.yama.ptrace_scope = 0: all processes can be debugged, as long as they have same uid. This is the classical way of how ptracing worked.
# kernel.yama.ptrace_scope = 1: only a parent process can be debugged.
# kernel.yama.ptrace_scope = 2: Only admin can use ptrace, as it required CAP_SYS_PTRACE capability.
# kernel.yama.ptrace_scope = 3: No processes may be traced with ptrace. Once set, a reboot is needed to enable ptracing again.
# Need sudo for this script.
@Rainyan
Rainyan / nico_batch_dl.ps1
Last active November 12, 2019 15:50
PowerShell script to persistently download from Nicovideo using ytdl resume state despite connection timeouts / keepalive failures. This is just a crude kludge around this ytdl issue: https://github.com/ytdl-org/youtube-dl/issues/14582
[CmdletBinding()]
param (
[Parameter(Mandatory=$True,Position=1)]
[string]$download_url,
# Where to store downloaded file
[string]$download_location = (Split-Path $MyInvocation.MyCommand.Path),
[string]$download_tool = "youtube-dl",
# If download stops, try resume this many times at most
[int]$max_iterations = 10000,
@Rainyan
Rainyan / Download_Unzip_Verify_SteamCMD.cpp
Last active November 28, 2019 08:39
C++ snippet to download (Windows) SteamCMD, unzip it, and then verify its integrity.
// C++ snippet to download (Windows) SteamCMD, unzip it, and then verify its integrity.
// Tested very little, use at your own risk.
#include <iostream>
#include <vector>
#include <fstream>
#include <iterator>
#include <stdarg.h>
#include <tchar.h>
#include <string>
@Rainyan
Rainyan / settings.json
Last active October 12, 2020 05:19
mouse accel profile
{
"Degrees of rotation": 0.0,
"Use x as whole/combined accel": true,
"Accel modes": {
"x": "classic",
"y": "noaccel"
},
"Accel parameters": {
"x": {
"offset": 0.0,
@Rainyan
Rainyan / srcds_ip_grepper.py
Last active December 22, 2022 19:04
Python 3 script to iterate all SRCDS logs, and store connected players' IPv4 addresses to a single file, one per line.
#!/usr/bin/env python3
"""Python 3 script to iterate all SRCDS logs,
and store connected players' IPv4 addresses to a single file, one per line.
Note that this script currently only handles IPv4 addresses."""
# Copyright (c) 2020 Rainyan https://github.com/Rainyan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@Rainyan
Rainyan / symlink_vpks.cmd
Last active May 11, 2020 16:47
REM Set links for large amounts of "pak01_nnn.vpk" files.
@Rainyan
Rainyan / nt_propstester.sp
Last active June 24, 2020 16:33
SourceMod test plugin to spawn all NT prop models at map origin, one at a time. TODO: precache will overflow; either clear string table or keep track of available edicts and force mapchange periodically to flush.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.1"
public Plugin myinfo = {
name = "NT Props Tester",
description = "Spawn all NT props.",
@Rainyan
Rainyan / ww21_renamer.py
Last active July 11, 2021 13:52
Ad hoc demo renamer script for the NT WW2021 tournament. Reformats the demo file names to a more human readable format. Written for Python 3.
#!/usr/bin/env python3
import os
import time
from pathlib import Path
from shutil import copyfile
from struct import unpack
###############################################################################
@Rainyan
Rainyan / sm_ipv4_to_int32.sp
Last active August 3, 2021 13:31
SourceMod conversion helper functions for IPv4 n-octet string representation <--> int32.
// Convert IPv4 octet string representation to int.
// Supports 1 to 4 octets ("127" == 2130706432. "127.1" == "127.0.1" == "127.0.0.1" == 2130706433).
stock int Ip4ToDecimal(const char[] sIp, const int ipLen)
{
int numOctets = GetNumOfCharInStr('.', sIp, ipLen) + 1;
if (numOctets > 4) {
ThrowError("More than 4 octets (%d) in string: \"%s\"", numOctets, sIp);
}
int numPaddingOctets = 4 - numOctets;