Skip to content

Instantly share code, notes, and snippets.

View wrouesnel's full-sized avatar

Will Rouesnel wrouesnel

View GitHub Profile
@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
@wrouesnel
wrouesnel / certificate-normalize.sh
Created October 5, 2023 21:12
Script to move TLS certificates around in a container so they land in all commonly searched locations
#!/bin/bash
# See: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
# Note: you can't refactor this out: its at the top of every script so the scripts can find their includes.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
@wrouesnel
wrouesnel / gitlab-container-build
Created October 5, 2023 21:11
Bash script to build and tag containers in Gitlab
#!/bin/bash
# Script to build a container from common gitlab CI parameters.
declare -a logstack
function log() {
echo -e "\033[0;93m$*\e[0m"
}
function glog() {
@wrouesnel
wrouesnel / zed.service
Last active July 11, 2023 19:25
systemd unit files for ZFS
[Unit]
Description=ZFS Event Daemon (zed)
Documentation=man:zed(8)
After=zfs-import-cache.service
After=zfs-import-scan.service
[Service]
Type=forking
ExecStart=/sbin/zed
PIDFile=/run/zed.pid
@wrouesnel
wrouesnel / .editorconfig
Last active February 15, 2023 02:30
Python project autogen.sh
# Project editorconfig file.
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
[defaults]
nocows = 1
remote_tmp=/tmp
inventory = inventory
timeout=20
# vault-keyring.py uses the Python 'keyring' module to retrieve and store the
# vault password. This should be reasonably cross-platform and you definitely
# should have a working python environment if you're using this repo.
#vault_password_file = vault-keyring.py
@wrouesnel
wrouesnel / .bashrc
Created February 2, 2023 04:13
Generic bashrc with some sensible defaults
#!/bin/bash
# Common Linux bashrc
function prompt_add() {
if [ ! -z "$PROMPT_COMMAND" ]; then
export PROMPT_COMMAND="$PROMPT_COMMAND;$*"
else
export PROMPT_COMMAND="$*"
fi
}
@wrouesnel
wrouesnel / ansible-vm-base-image.yml
Created January 29, 2016 10:56
Ansible VM base image builder
---
# Provisions a Debian base-image
- hosts: local
connection: local
force_handlers: True
sudo: yes
tasks:
# - name: Check environment set
# fail: msg="Configuration incompletely specified!"
# when: (server_ip is defined|bool and netmask is defined|bool and gateway is defined|ipaddr and
@wrouesnel
wrouesnel / dependency-free-requests.py
Created October 17, 2022 23:13
Make request without requests
# https://dev.to/bowmanjd/http-calls-in-python-without-requests-or-other-external-dependencies-5aj1
import json
import typing
import urllib.error
import urllib.parse
import urllib.request
from email.message import Message
FROM rocm/rocm-terminal
USER root
WORKDIR /root
# Install font for prompt matrix
COPY data/DejaVuSans.ttf /usr/share/fonts/truetype/
RUN apt update && apt install -y python3.8-venv wget