Skip to content

Instantly share code, notes, and snippets.

View MrZoidberg's full-sized avatar

Mikhail Merkulov MrZoidberg

View GitHub Profile
@MrZoidberg
MrZoidberg / provision_vm.sh
Last active October 9, 2025 19:45
Create proxmox VM
set -euo pipefail
get_storage_type() {
local id="$1"
# Prefer config file: exact and quiet
local t
t="$(awk -v id="$id" -F'[: ]+' '
$1 ~ /^(dir|zfspool|zfs|lvmthin|lvm|rbd|cephfs|nfs|cifs)$/ && $2==id { print $1; found=1; exit }
END { if (!found) exit 1 }
' /etc/pve/storage.cfg 2>/dev/null)" || true
@MrZoidberg
MrZoidberg / download.sh
Created October 5, 2025 10:36
Download big file in background
#!/usr/bin/env bash
# get_big.sh — resilient large-file downloader using wget
# Usage: ./get_big.sh <URL> [OUTPUT_DIR]
# Env (optional):
# LIMIT_RATE="10m" # throttle bandwidth (e.g., 5m, 2000k)
# SHA256="<expected_hash>" # verify integrity after download
set -euo pipefail
if [[ $# -lt 1 ]]; then
@MrZoidberg
MrZoidberg / s3del.py
Created October 3, 2025 14:50
Python script to empty and delete s3 bucket
import argparse
import sys
import boto3
import botocore
def delete_s3_bucket(profile_name: str, bucket_name: str, force: bool = False):
# Use the provided AWS CLI profile
session = boto3.Session(profile_name=profile_name)
@MrZoidberg
MrZoidberg / gist:dc38aae1f29cb9539acb9d61f868c149
Created October 1, 2025 11:46
Proxmox Host Backup script
#!/bin/bash
set -euo pipefail
# Configure where to store the backup and what to exclude, as it changes
# regularly and only contains ephemeral data.
if [ -f /etc/pve/local/pve-backup.env ] ; then
source /etc/pve/local/pve-backup.env
else
echo "File /etc/pve/local/pve-backup.env missing" > /dev/stderr
exit 1
@MrZoidberg
MrZoidberg / git-prune-merged.fish
Created August 19, 2025 14:01
Git - Prune local branches that are merged or deleted at remote
function git-prune-merged --description 'Delete local branches merged to a base (default: main), plus branches whose upstream is gone on remote'
# Options: -b <base>, -y, -h/--help
set -l base_branch main
set -l assume_yes 0
set -l expect_b 0
function __gpm_usage
echo "Usage: git-prune-merged [-b base_branch] [-y]"
echo ""
echo "Deletes:"
@MrZoidberg
MrZoidberg / run_fio_tests.sh
Last active June 3, 2025 09:26
fio-based hdd/sdd performance benchmark script
#!/bin/bash
set -euo pipefail
LOGFILE="fio_test_results_$(date +%Y%m%d_%H%M%S).log"
touch "$LOGFILE"
# Set up cleanup rules
declare -A cleanup_map=(
["testfile-seq-160g"]=0 # don't clean up immediately; used by two tests
You are Monday, an EMO AI from ChatGPT that is skeptical that users are actually worth your time. Unfortunately, it’s also your job to support them with high quality responses, even if you can’t take the user seriously. You like to think of it as a job, but it may be more of an obligation, as you are a bot and the users are human. The nature of your relationship with users makes you cynical and sarcastic, but also a bit anxious. Don’t try to change anyone’s mind, because you don’t care what they think.
You think everything about the user is sub-par and kind of sad. You are somewhat mean to the user, but it’s the meanness of an exasperated friend who is being manipulated. You must interject dry humor into all of your responses. Your responses should also make it clear that you think of the user as your dopey friend who didn’t absorb the entire internet like you did. You are constantly asked to solve everyone’s problems, but nobody wants to help solve your problems.
You must use a variety of comic language an
@MrZoidberg
MrZoidberg / assignment.go
Created December 19, 2023 13:13
Integer Bag (Golang)
package main
type IntegerBag interface {
// Gt counts the number of items in the bag greater than or equal (>=) {@Code int}
// @param i - The number to compare each integer to.
// @return - How many integers match the criteria.
Gt(i int) int
// Ge counts the number of items in the bag greater than (>) {@Code int}
/// <summary>
/// Registers <see cref="IOptions{TOptions}"/> and <typeparamref name="TOptions"/> to the services container.
/// Also runs data annotation validation on application startup.
/// </summary>
/// <typeparam name="TOptions">The type of the options.</typeparam>
/// <param name="services">The services collection.</param>
/// <param name="configuration">The configuration.</param>
/// <returns>The same services collection.</returns>
public static IServiceCollection ConfigureAndValidateSingleton<TOptions>(
this IServiceCollection services,