Skip to content

Instantly share code, notes, and snippets.

@WinkelCode
WinkelCode / example.conf
Created December 2, 2021 05:53
My Example WireGuard Config
[Interface]
Address = 10.0.0.1/24
PrivateKey =
ListenPort =
PreUp = iptables -w -P FORWARD DROP; iptables -w -A FORWARD -i %i -o %i -j ACCEPT; echo 1 > /proc/sys/net/ipv4/ip_forward
PostDown = echo 0 > /proc/sys/net/ipv4/ip_forward; iptables -w -D FORWARD -i %i -o %i -j ACCEPT; iptables -w -P FORWARD ACCEPT
[Peer]
PublicKey =
PresharedKey =
# Script to automatically remove "appleprecisiontrackpadbluetooth.inf" and "appleprecisiontrackpadusb.inf".
# Get installed drivers with pnputil and include previous line (the published name)
$drivers = (pnputil /enum-drivers | Select-String -Pattern "appleprecisiontrackpadbluetooth.inf|appleprecisiontrackpadusb.inf" -Context 1,0)
# Sanity check the results
switch ($drivers.Count) {
0 {Write-Host "No drivers found, exiting"; pause; exit}
1 {Write-Host "Only one driver found, are you sure you want to continue?"; Read-Host "Press any key to continue, or Ctrl+C to abort"; Write-Host "Continuing"}
2 {Write-Host "Two drivers found, continuing"}
@WinkelCode
WinkelCode / mtp_driver_man.ps1
Last active May 2, 2023 09:18
Messing around with Windows drivers can break stuff, use at your own risk. Script requres elevated permissions. You will need PS execution policy "RemoteSigned" (or any that allows running local scripts) and unblock script via file options (or paste it into an empty text file).
# Script to automatically remove and install "appleprecisiontrackpadbluetooth.inf" and "appleprecisiontrackpadusb.inf".
# Script needs to be in an extracted "AppleBcUpdate" folder.
function remove_driver {
$driver_orignames = @("appleprecisiontrackpadbluetooth.inf", "appleprecisiontrackpadusb.inf")
# Get matching installed drivers with pnputil and include previous line (the published name)
$drivers = pnputil /enum-drivers | Select-String -Pattern $driver_orignames -Context 1,0
if ($drivers.Count -gt 2) {
Write-Host "Error: More than 2 drivers found."
@WinkelCode
WinkelCode / install_portmaster_to_var.sh
Last active April 12, 2024 14:01
Work in progress
#!/usr/bin/env bash
set -e # Exit on error
if [ "$EUID" -ne 0 ]; then
echo "To ensure correct permissions, this script must be run as root."
exit 1
fi
install_location="/var/lib/safing-portmaster" # Must not include trailing slash
@WinkelCode
WinkelCode / wggenconf.sh
Last active May 2, 2023 09:17
WireGuard Config Generator
#!/usr/bin/env bash
wgcmd="wg"
if command -v qrencode >/dev/null 2>&1; then
generate_qr="true"
else
generate_qr="false"
fi
echo "WireGuard configuration file generator"
echo "======================================"
@WinkelCode
WinkelCode / battery-notify4silverblue.sh
Last active May 2, 2023 09:17
Unofficial and WIP, for this program: https://github.com/the-weird-aquarian/Battery-Notifier (License: unlicense.org)
#!/usr/bin/env bash
set -e
# --- Preamble ---
# username will be pulled from arguments
program_name="battery-notify"
sourceloc_script="./$program_name.sh"
#!/usr/bin/env bash
if [ "$EUID" != '0' ]; then
echo "This script must be run as root"
exit 1
fi
# Or just run the parts below in the terminal as root!
mkdir -p '/var/lib/sd-battmgr/'
echo "Downloading script"
@WinkelCode
WinkelCode / bookmarklet.js
Last active April 23, 2023 21:49
YouTube Ultrawide Fullscreen Bookmarklet
// Bookmarklet will fullscreen the video and fill the screen
// Might not work on Chromium derivatives, probably same issue: https://github.com/dvlden/ultrawideo/issues/94
// One line
javascript:(function(){var e=document.querySelector(".ytp-fullscreen-button");if(e){e.click();setTimeout(function(){var e=document.querySelector("video");if(e){e.style.width="100vw",e.style.height="100vh",e.style.left="0px",e.style.top="0px"}},250)}})();
//Pretty + Comments
javascript:(function(){
// Find the fullscreen button element
var fullscreenButton = document.querySelector(".ytp-fullscreen-button");
@WinkelCode
WinkelCode / user-battery-notify.service
Created May 2, 2023 13:53
Put in `~/.config/systemd/user/user-battery-notify.service`, enable with `systemctl --user enable --now user-battery-notify.service`. Change variables as required for your system.
[Unit]
Description=Battery Level Notifier
[Service]
Environment=BATT_PATH=/sys/class/power_supply/BAT1/capacity
Environment=MIN_BATT_PCT=35
Environment=BATT_REFRESH_SECS=5
ExecStart=bash -c 'set -e; snooze=false; while true; do [ "$(cat "${BATT_PATH}")" -le "${MIN_BATT_PCT}" ] && [ "$snooze" != "true" ] && { notify-send --urgency=critical "Battery is at or below ${MIN_BATT_PCT}%"; snooze=true; }; [ "$(cat "${BATT_PATH}")" -gt "${MIN_BATT_PCT}" ] && [ "$snooze" == "true" ] && snooze=false; sleep "${BATT_REFRESH_SECS}"; done'
Restart=always
@WinkelCode
WinkelCode / cfgdumpparse.py
Created June 28, 2023 23:55
Python script to parse dumped config of Realtek NVMe Enclosures into usable config file
# Usage ./python3 cfgdumpparse.py mydumpedconfig.txt
# Warning: This is not a "end user" tool.
# Warning: Verify output by hand, it may include unwanted values.
# Warning: This tool may produce an incorrect config that can brick your device.
import re
import sys
try:
file = sys.argv[1]
with open(file, 'r') as cfg_file: