Skip to content

Instantly share code, notes, and snippets.

@dzogrim
dzogrim / CertDERConvert.go
Last active March 6, 2024 10:39
This Go program provides a secure way to extract certificates from PKCS#12 (.p12 or .pfx) files using a password entered securely through the terminal and extract in DER format.
package main
import (
"fmt"
"io/ioutil"
"os"
"golang.org/x/term"
"software.sslmate.com/src/go-pkcs12"
)
@dzogrim
dzogrim / GMail_not-important.py
Created March 1, 2024 11:14
Add "shouldNeverMarkAsImportant" to exported GMail filters to be reimported after mods
from xml.etree import ElementTree as ET
# Enregistrement des namespaces avec leurs préfixes pour éviter l'ajout de préfixes non désirés
ET.register_namespace('', 'http://www.w3.org/2005/Atom')
ET.register_namespace('apps', 'http://schemas.google.com/apps/2006')
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
if not elem.text or not elem.text.strip():
@dzogrim
dzogrim / README.md
Last active February 26, 2024 14:30
This script is used to generate an SSH public key to be used from a private key stores on a YubiKey (tested on v4 and v5).

YubiKey SSH Key Generator

Overview

This script automates the generation of SSH public keys using private keys stored on a YubiKey. It supports various cryptographic algorithms, ensuring compatibility across different YubiKey models. Features include comprehensive checks for tool availability, YubiKey compatibility, and the presence of a single connected YubiKey.

Features

  • Supports RSA and ECC algorithms, including RSA2048, RSA4096, ECCP256, ECCP384, ED25519, and X25519.
  • Automatically detects connected YubiKeys and verifies compatibility.
  • Generates SSH keys based on the YubiKey's serial number, enhancing security and organization.
  • Includes a counter to track the number of keys generated.
@dzogrim
dzogrim / list_gcp_res_json.sh
Created February 6, 2024 14:57
Basic GCP Resource listing on project
#!/bin/bash
# Set your GCP project ID
PROJECT_ID="graphite-victor-413210"
gcloud config set project $PROJECT_ID
# Compute Engine: List VM instances
echo "Listing Compute Engine VM instances..."
gcloud compute instances list --format="table(name,zone,status)"
@dzogrim
dzogrim / events.csv
Last active January 10, 2024 17:02
Automatic creation of a timeline from a CSV file with two date/event columns with python3
01/12/1951 Arrivée Untel en France
10/01/2004 Décès Unetelle
@dzogrim
dzogrim / zipped-userData.db-sqlite3-diff.sh
Last active December 23, 2023 17:03
Compare sqlite 'userData.db' stored in ZIP archive and display differences without writing out files on disk (macOS only)
#!/bin/bash
# Description:
# This script aims to compare two zipped SQLite database files (<file1.zip> and <file2.zip>),
# each containing a 'userData.db' file. It extracts these databases, converts them into SQL dumps,
# and then compares the dumps using diff.
# The script is designed to avoid writing the SQLite databases to disk by using process substitution (for fun?).
# You should use the script as indicated in the usage instructions below ...
# Error handling
@dzogrim
dzogrim / fuzzy-sort-dupes-lines.py
Created August 1, 2023 16:55
Help to find similar titles from Shazam CSV export file with Python 3.9
#!/opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
"""Find similar duplicated lines in CSV file.
Needs py39-levenshtein, py39-fuzzywuzzy and py39-pandas.
"""
# -*- coding: utf-8 -*-
import pandas as pd
from fuzzywuzzy import fuzz
@dzogrim
dzogrim / find-missing-torrent-dl.sh
Last active July 14, 2022 16:02
macOS Vuze server companion to match torrent registered and torrent downloaded files (should not be interesting for anyone).
#!/opt/local/bin/bash
LANG="fr_fr.UTF-8"
LC_COLLATE="fr_fr.UTF-8"
LC_CTYPE="fr_fr.UTF-8"
LC_MESSAGES="fr_fr.UTF-8"
LC_MONETARY="fr_fr.UTF-8"
LC_NUMERIC="fr_fr.UTF-8"
LC_TIME="fr_fr.UTF-8"
LC_ALL=
@dzogrim
dzogrim / parse_abcdp_meta.sh
Created January 22, 2022 09:21
Basic tool to compare 2 macOS Address book backups (archive) metadata to find missing or added from CSV outputs …
#!/usr/bin/env bash
# $ cat F141345E-04C2-4DFE-86DA-89C7A4094E74:ABPerson.abcdp | plutil -convert xml1 -o - - | perl -CSDA -pe's/[^\x9\xA\xD\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]+//g' | \
# xmllint --xpath '/plist/dict/key[text()="Last"]/following-sibling::string[position()=1]/text()' -
find . -type f -iname '*.abcdp' | while read line
do
@dzogrim
dzogrim / migration_MacPorts-2.7.1-12-Monterey.sh
Last active December 25, 2021 11:04
Migrating MacPorts after a major operating system upgrade
#!/bin/bash
#
# Migrating MacPorts after a major operating system upgrade
# from - MacPorts-2.7.1-11-BigSur
# to - MacPorts-2.7.1-12-Monterey
#
# Migration procedure (december 2021)
# from : https://trac.macports.org/wiki/Migration