Skip to content

Instantly share code, notes, and snippets.

@foreignmeloman
foreignmeloman / restic-s3-boilerplate.sh
Created June 4, 2024 13:21
A boilerplate shell code to implement restic backups with S3-compatible backend.
#!/bin/bash
export RESTIC_REPOSITORY="s3:https://url.to/s3/compatible/bucket"
export RESTIC_PASSWORD="RESTIC_PASSWORD"
export AWS_ACCESS_KEY_ID="AWS_ACCESS_KEY_ID"
export AWS_SECRET_ACCESS_KEY="AWS_SECRET_ACCESS_KEY"
# Automatically initialize restic repo if it does not exist
status="$(restic cat config 2>&1)"
if [ $? -ne 0 ]; then
@foreignmeloman
foreignmeloman / ssh-split.sh
Last active February 28, 2024 07:28
Split SSH tool for tmux
#!/bin/bash
if [ "${TERM_PROGRAM}" != 'tmux' ]; then
echo "Error: Must be run inside a tmux session!"
exit 1
fi
ssh_list=($@)
split_list=()
@foreignmeloman
foreignmeloman / clear-queue-and-stop-jobs.groovy
Last active November 8, 2023 08:02
Jenkins administrative snippets
import java.util.ArrayList
import hudson.model.*;
import jenkins.model.Jenkins
// Remove everything which is currently queued
def q = Jenkins.instance.queue
for (queued in Jenkins.instance.queue.items) {
q.cancel(queued.task)
}
@foreignmeloman
foreignmeloman / git-branch-size.py
Last active April 25, 2024 11:28
A script to analyze uncompressed storage cost of a git commit, base or a topic branches.
#!/usr/bin/env python3
import argparse
import copy
import json
import subprocess
import sys
import multiprocessing as mp
@foreignmeloman
foreignmeloman / mxmaster3.md
Last active November 24, 2025 07:23
Logitech MX Master 3 horizontal scroll flip without `Options+` software
  1. Find the mouse device instance path in the Device Manager: image
  2. Open RegEdit and follow this path:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID\<device_instance_path>\Device Parameters
  1. Change value of FlipFlopHScroll from 0 to 1.
@foreignmeloman
foreignmeloman / settings.json
Last active August 26, 2025 08:17
Windows Terminal tricks
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema-preview",
"actions":
[
{
"command":
{
"action": "globalSummon",
"monitor": "any"
@foreignmeloman
foreignmeloman / git-ssh-signing.md
Last active April 23, 2025 09:22
Signing git commits and tags with an SSH key

Imperative configuration example:

git config gpg.format ssh
git config user.signingKey /path/to/private/ed25519key
git commit -S -m "signed commit"
git tag --sign --annotate -m "signed tag" v0.1.0

Now we can verify the signatures with allowed_signers file: