Skip to content

Instantly share code, notes, and snippets.

View yamatt's full-sized avatar

Matt Copperwaite yamatt

View GitHub Profile
@yamatt
yamatt / troubleshooting.md
Created April 14, 2025 20:20
optimus troubleshooting

Troubleshooting

Discrete card will not switch off

On some secondary GPUs they report that they have the VGA port enabled. This has been seen on the GeForce GT 520M.

Symptoms include higher drain on the battery, fans constantly running, Xorg attempting to treat the discrete card as a secondary monitor.

This issue can be detected by opening a console and typing xrandr:

[root@localhost ~]# xrandr

Screen 0: minimum 8 x 8, current 2390 x 768, maximum 32767 x 32767

@yamatt
yamatt / system.properties
Last active March 30, 2025 19:21
Unifi System Config File for the Network Appliance
## system.properties
#
# each unifi instance requires a set of ports:
#
## device inform
# unifi.http.port=8080
## controller UI / API
# unifi.https.port=8443
## portal redirect port for HTTP
# portal.http.port=8880
@yamatt
yamatt / keybase.md
Created November 9, 2024 07:54
keybase.md

Keybase proof

I hereby claim:

  • I am yamatt on github.
  • I am mattcopp (https://keybase.io/mattcopp) on keybase.
  • I have a public key whose fingerprint is 4C8C 6483 FDB4 8B3F 1863 29F6 737A 0879 4C13 FA5C

To claim this, I am signing this object:

@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