Skip to content

Instantly share code, notes, and snippets.

View wrouesnel's full-sized avatar

Will Rouesnel wrouesnel

View GitHub Profile
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "PyGitHub",
# "GitPython"
# ]
# ///
import argparse
import subprocess
@wrouesnel
wrouesnel / gist:b9e7403eeb4f112f11d8f91e4a647903
Created April 17, 2025 11:26
Open a sqlitedb using the pure Golang modernc recompilation in readonly mode
db, err := sqlx.Open("sqlite", fmt.Sprintf("file:%s?mode=ro", tempDb.Name()))
if err != nil {
return errors.Join(&ErrCommand{}, err)
}
@wrouesnel
wrouesnel / launch-instance
Created March 21, 2025 15:19
Wrapper script for launching an "on-demand" ephemeral EC2 instance
#!/usr/bin/env python3
# Wrapper script to launch an ephemeral EC2 instance
import os
import time
import sys
import argparse
import boto3
import logging
import socket
@wrouesnel
wrouesnel / gist:40244779d16b59545483ead017b018eb
Last active March 11, 2025 20:23
automount powershell provisioning
Import-Module ActiveDirectory
# New-ADOrganizationalUnit -Name "autofs" -Path "dc=default,dc=libvirt"
# New-ADObject -Name auto.master -Path 'ou=autofs,dc=default,dc=libvirt' -Type nisMap -OtherAttributes @{'nisMapName'='auto.master'}
#New-ADObject -Name '/home' -Path 'cn=auto.master,ou=autofs,dc=default,dc=libvirt' -Type nisObject -OtherAttributes @{'nisMapName'='/home'; 'nisMapEntry'='auto.home'}
#New-ADObject -Name auto.home `
# -Path 'ou=autofs,dc=default,dc=libvirt' `
@wrouesnel
wrouesnel / clipboard-type.ps1
Last active March 6, 2025 10:08
Clipboard Typer in Powershell - Types the contents of the clipboard into the targeted window
Add-Type -AssemblyName System.Windows.Forms
Add-Type @"
using System;
using System.Runtime.InteropServices;
using System.Text;
public class APIFuncs {
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetWindowText(IntPtr hwnd,StringBuilder lpString, int cch);
@wrouesnel
wrouesnel / clevis-regen.sh
Created March 3, 2025 13:32
Script for regenerating clevis-luks bindings on a standard Ubuntu ZFS rpool installation
#!/bin/bash
# Script to regenerate the Clevis LUKS bindings (and to track the changes causing them.)
# PCR#
# Used by From Location Measured Objects Log Use Reported By
# 0
# Firmware 💻 UEFI Boot Component Core system firmware executable code UEFI TPM event log n/a
# 1
# Firmware 💻 UEFI Boot Component Core system firmware data/host platform configuration; typically contains serial and model numbers UEFI TPM event log n/a
# 2
@wrouesnel
wrouesnel / output.py
Created February 10, 2025 22:57
Easy structured output types
import enum
import functools
import json
import uuid
from datetime import datetime, timedelta
import pyrfc3339
import ruamel.yaml
@wrouesnel
wrouesnel / clitypes.py
Created February 10, 2025 22:56
Extended click parameter types
import csv
import typing
import typing as t
import click
from furl import furl
from timelength.timelength import TimeLength
class TimelengthType(click.ParamType):
@wrouesnel
wrouesnel / folderctl
Created August 30, 2024 06:21
Structured Syncthing share management
# This is the list of leaf folders which exist in the entire sync infrastructure.
# This file is processed as a list of command line arguments.
#
# Support syntax:
# Template Controls - prevent templated lines from existing
# --not-if : Don't template if device condition matches
# --only-if : Template only if device condition matches
# Share Controls - restrict hosts the folder is offered to (and whether they elect to receive it)
# --not-shared-if: Don't offer this template result to a device if it matches
# --only-shared-if: Only offer this template result to a device if it matches
@wrouesnel
wrouesnel / jetbrains_product.py
Created October 5, 2023 23:49
Ansible lookup plugin which retreives the list of Jetbrains products
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
__metaclass__ = type
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display