Skip to content

Instantly share code, notes, and snippets.

@dzogrim
dzogrim / gitea-migr-issues.sh
Created March 21, 2025 13:36
This script exports all issues, milestones, labels, and comments from a Gitea repository, then re-imports them into another Gitea repository via the API, preserving essential metadata.
#!/usr/bin/env bash
set -euo pipefail
# Ce script exporte toutes les issues, milestones, labels et commentaires d’un dépôt Gitea,
# puis les réimporte dans un autre dépôt Gitea via l’API, en conservant les métadonnées essentielles.
#
# ⚠️ Ce script n’est pas idempotent : il n’écrase pas les données existantes
# mais crée de nouveaux objets (issues, milestones, labels, commentaires).
# 👉 Il est donc à utiliser *une seule* fois par cible, sous peine de doublonnage massif.
# Pour un re-run, supprimez le projet ou videz les entités concernées avant de relancer !
@dzogrim
dzogrim / gitea-migr.sh
Created March 20, 2025 17:24
This script migrates repositories from a source Gitea instance to another Gitea instance
#!/usr/bin/env bash
# This script migrates repositories from a source Gitea instance to another Gitea instance.
# It clones all personal repositories from the source using HTTPS and pushes them to the
# destination using SSH, with an option for a default dry-run mode.
#
# USAGE:
# ./gitea-migr.sh # Runs in dry-run mode (NO actual cloning or pushing)
# ./gitea-migr.sh --no-dry-run # Performs the actual migration (cloning and pushing)
@dzogrim
dzogrim / refresh-nix-mac-os.sh
Last active February 11, 2025 14:56
Nix System Maintenance Script for macOS
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Nix System Maintenance Script for macOS
# -----------------------------------------------------------------------------
# This script performs routine maintenance for a Nix-based system, ensuring
# that packages, flakes, and the Nix store remain up to date and optimized.
#
# Features:
# - Checks if Nix is installed before running
@dzogrim
dzogrim / file_magic.py
Created January 31, 2025 08:38
Script Python pour détecter le type MIME et le type détaillé d'un fichier en utilisant libmagic
#!/usr/bin/env python3.9
"""
Script pour détecter le type MIME et le type détaillé d'un fichier en utilisant libmagic.
Installation nécessaire au préalable de la dépendance :
pip3 install python-magic
Usage :
python file_magic.py <chemin_du_fichier>
"""
@dzogrim
dzogrim / pip-cleaner.sh
Created January 2, 2025 13:23
This script automates the detection and resolution of Python package architecture mismatches on macOS
#!/usr/bin/env bash
# This script automates the detection and resolution of Python package architecture mismatches on macOS.
#
# It scans for '.so' files compiled for x86_64 under all installed Python versions in '~/Library/Python',
# uninstalls the affected packages, and reinstalls them with ARM64 support. Additionally,
# it checks for dependency conflicts using pip check and resolves them by reinstalling problematic packages.
# This ensures compatibility with ARM-based systems, streamlining the transition from x86_64 to ARM architectures.
#
# TODO: clean-up everything and handle brew or port installations ...
@dzogrim
dzogrim / update_finalizeSystems_config.sh
Last active November 20, 2024 19:28
Ensures a specific line stays uncommented in a finalizeSystems block in default.nix
#!/usr/bin/env bash
# This script processes a default.nix file to ensure a specific configuration
# line provided as an argument remains uncommented within a block starting with
# `finalizeSystems [` and ending with `]`, while commenting out other lines
# in the block, and keeps a backup of the original file.
# VERSION=2024-11-20
# Check for the argument
@dzogrim
dzogrim / sketchrizer.py
Created November 16, 2024 17:12
This script converts an image into a pencil sketch using OpenCV.
#!/usr/bin/env python3.11
# -*- coding: utf-8 -*-
"""
Image to Pencil Sketch Converter
================================
This script converts an image into a pencil sketch using OpenCV.
It accepts the image file path as a command-line argument, processes the image,
and saves the pencil sketch as an output file.
Usage:
@dzogrim
dzogrim / clone-user.sh
Last active September 26, 2024 16:39
Use a full configuration template for new user creation by cloning directory
#!/bin/bash
# Ensure that the script receives two arguments: first name and last name
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <prenom> <nom>"
exit 1
fi
PRENOM=$1
NOM=$2
@dzogrim
dzogrim / DeployNixOS.sh
Last active November 20, 2024 07:54
The script deploys a NixOS system by writing an image file (disk.raw) to a target disk (/dev/nvme0n1) using dd
#!/bin/sh
# This script deploys a pre-configured NixOS image from an NTFS device
# to a specified disk, ensuring robust error handling and user confirmations.
# It validates necessary tools, verifies mount points, and optionally checks
# SHA256 checksums for the image. Deployment overwrites all data on the target
# disk, with a power-off mechanism post-deployment unless canceled.
# Designed for Linux-based live USB environments like SystemRescue.
# VERSION=2024-11-20
@dzogrim
dzogrim / check_and_log_system_info.sh
Created September 18, 2024 08:53
Performs a series of checks and logs system information related to security and system configuration. It retrieves the system’s serial number and logs various outputs, including systemd PCR logs, BIOS information, and EFI boot settings to a specific mount point.
#!/bin/sh
for cmd in dmidecode systemd-pcrlock efibootmgr; do
if ! which "$cmd" > /dev/null 2>&1; then
echo "Erreur : La commande $cmd n'est pas installée ou n'est pas disponible dans PATH."
exit 1
fi
done
SERIAL=$( sudo dmidecode -s system-serial-number )