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
@Urpagin
Urpagin / xc.sh
Created November 30, 2025 03:40
A Bash script to quickly build & execute a C project.
#!/usr/bin/env bash
# Author: Urpagin
# Date: 2025-11-30
# Description: eXecute C (xc) compiles and executes a C project
# without cluttering your machine.
set -euo pipefail
@Urpagin
Urpagin / main.c
Created November 27, 2025 20:56
Bitwise shenanigans
#if 0
_TMP="$(mktemp -d)"
clang -Wall -Wextra -pedantic -o "${_TMP}/a.out" "$0"
"${_TMP}/a.out" "$@"
RV=$?
# [, [[ and test are unsuitable on some shell (e.g., dash)
case $_TMP in
'/tmp/'*)
rm -rf "$_TMP"
@Urpagin
Urpagin / mkbak.sh
Created November 11, 2025 22:31
Archives a directory simply and efficiently (but slowly mx=9). (output is .tar.7z)
#!/usr/bin/env bash
# Author: Urpagin
# Date: 2025-11-11 around 20:00.
# License: MIT
# Description: - Makes a backup of an entire directory (including hidden files)
# and conserving permissions and other metadata using the tar algo first.
# - Creates .tar.7z files and uses maximum 7z compression.
# - CLI flags for a filename, appends the date after.
# E.g., <name>_YYYY-MM-DD_HH-MM-SS.tar.7z
@Urpagin
Urpagin / dll.c
Created October 9, 2025 02:11
An attempt at creating a Doubly-Linked List in C from memory.
#if 0
TMP=$(mktemp -d)
clang -Wall -Wextra -pedantic -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=$?
rm -rf ${TMP}
exit ${RV}
#endif
/// Metadata
/// Author: Urpagin
/// Date: 2025-10-09 @ 02:54AM
@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]}.")
@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 / 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 / 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 / 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 / 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" && \