Skip to content

Instantly share code, notes, and snippets.

View yamatt's full-sized avatar

Matt Copperwaite yamatt

View GitHub Profile
@yamatt
yamatt / rar2fs-build.sh
Created December 3, 2023 22:14
Build and install rar2fs on Ubuntu
#!/bin/bash
# The rar2fs version needs to be a release after the latest unrarsrc version
UNRARVER=5.1.1 # https://ftp.osuosl.org/pub/blfs/conglomeration/unrarsrc/
RAR2FSVER=1.22.0 # https://github.com/hasse69/rar2fs/releases
WORKDIR=`mktemp -d` && cd $WORKDIR
# Get deps
sudo apt-get -q update
@yamatt
yamatt / fedora.sh
Last active May 18, 2022 08:35
Set up headless server with gnome and VNC
# https://unix.stackexchange.com/questions/584174/enable-gnome-screen-sharing-via-commandline
systemctl stop cockpit && systemctl disable cockpit
dnf update -y && dnf install -y gnome-shell mutter gdm
mutter --wayland --headless --virtual-monitor 1920x1080 &
ETH0_UUID=$(nmcli -t -f uuid,type c s --active | cut -d':' -f1)
echo "UUID=$ETH0_UUID" >> /etc/sysconfig/network-scripts/ifcfg-eth0
gsettings set org.gnome.desktop.remote-desktop.vnc auth-method 'password'
@yamatt
yamatt / locals.tf
Last active January 31, 2022 13:00
Iterate over files in directory and parse in a Terraform module
locals {
base_path = "${path.module}/files"
yaml_files = fileset(local.base_path, "**.yml")
contents = zipmap(
[for file_path in local.yaml_files : trimsuffix(basename(file_path), ".yml")],
[for file_path in local.yaml_files : yamldecode(file("${local.base_path}/${file_path}"))]
)
}
@yamatt
yamatt / changed-in-branch.sh
Created November 22, 2021 09:43
Run command against changed files in branch
# When using a feature branching model against the main branch this will allow you to iterate over
# all the files that have changed compared to branch and run a command against each of them.
for file_path in $(git diff --name-only origin/main | grep '^content/'); do
echo "$file_path"
done
@yamatt
yamatt / README.md
Created September 28, 2021 12:09
cron daylight saving

GitHub Actions that are scheduled to run always run as UTC+0. This means that the time that they run varies depending on the time of year if you are in an area that uses daylight savings.

The simplest solution I found is to have two different cron lines with the same command that differ depending on the month since most countries switch their daylight savings on the last weekend of the month.

This is far from completely accurate. Some countries switch at other points of the month. However it may be accurate enough for your purposes.

@yamatt
yamatt / atupload.sh
Last active June 14, 2021 11:22
Upload a bunch of files over time
#!/bin/bash
if [ -z "$1" ]; then
WD="$CWD"
else
WD="$1"
fi
readarray -d '' FILES < <(find $WD -type f -print0)
@yamatt
yamatt / detect-secrets.md
Last active October 25, 2021 09:41
Libraries that detect secrets in code
@yamatt
yamatt / README.md
Created January 15, 2021 13:31
Running Duplicity under Gnome Wayland and Systemd

Setup

Install duplicity and gnupg2

GnuPGP public keys

Configure yourself a GPG key to encrypt the data with. Note the key ID/hash to use in the duplicity-backup.service.

Remember to backup your private key separately so it is not lost when you need your backups, and so you can recover your files.

Object Storage Provider

Create yourself a place to put your backups

@yamatt
yamatt / README.md
Last active January 5, 2020 16:24
WIP CI/CD Stages Starting Point

This is a list of stages that I look to use in my integration pipelines for any project. This is a starting point for me, to remind me when starting a new project as to what to look to include. They are in rough order, starting from ones that are likely to be caught first to ones that are to be more complex to catch.

As is always the way with technology these stages do not have to be used exactly as directed here. They are a starting point so as not to overlook anything when starting a new project, and save me from doing a load of digging through old repositories.

I also find that considering these as early as possible means that you will have a better end product. So it's best to ensure you try to include as many as possible, but also not to put too much effort in to them.

This is still a work in progress and therefore incomplete.

@yamatt
yamatt / split.css
Last active September 25, 2021 14:11 — forked from jpnelson/split.css
Responsive, resizable panel layout with flexbox JUST CSS
* {
box-sizing: border-box;
}
html, body {
height: 100%;
padding: 0;
margin: 0;
}