Skip to content

Instantly share code, notes, and snippets.

View pojntfx's full-sized avatar
💭
🍂

Felicitas Pojtinger pojntfx

💭
🍂
View GitHub Profile
@pojntfx
pojntfx / main.s
Created May 8, 2024 06:53
Enable fractional scaling for GNOME 45 on Fedora 40
#!/bin/bash
gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"
# Now logout & login in again
# You can also set manual scaling factors (i.e. 75%) by heading to `~/.config/monitors.xml` and editing the configuration manually, logging out & loging in again
@pojntfx
pojntfx / main.sh
Last active April 24, 2024 23:39
Uninstall an old kernel version from a DNF-based system bypassing `kernel` package deletion protection
#!/bin/bash
uname -r # Get installed kernels - make sure that there is at least one more kernel than the one you're removing!
sudo rpm -e kernel-6.7.0_rc6_pvm_host_fedora_baremetal-1.x86_64
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo reboot
@pojntfx
pojntfx / README.md
Last active April 21, 2024 21:43
Boot Linux or OpenBSD on the PowerBook G4 (PowerPC/ppc32)

Boot Linux or OpenBSD on the PowerBook G4 (PowerPC/ppc32)

Creating the USB sticks

Use an older USB 2.0 stick, newer ones will most certainly not work.

sudo dd if=debian-11.0.0-powerpc-NETINST-1.iso of=/dev/sda1 status=progress # Or use GNOME Disks, Etcher etc.
sync
@pojntfx
pojntfx / main.c
Last active April 12, 2024 22:55
Overlay/"hole punch" a section of an `mmap`ed region with another `mmap`ed region
#include <bits/time.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
int main() {
const size_t page_size = 4096 * 64;
@pojntfx
pojntfx / main.sh
Last active April 9, 2024 00:38
Use `slirp4netns` to add a tap device with working networking to an unprivileged/rootless namespace
# Also see: https://passt.top/passt/about/ for an alternative setup
# In first terminal (namespace 1)
unshare --user --map-root-user --net --mount
echo $$ > /tmp/pid
# In second terminal
# For port-forwarding: http://web.archive.org/web/20240112152726/https://rootlesscontaine.rs/how-it-works/netns/incoming/ for port-forwarding
# For communicating between different slirp4netns instances: https://github.com/rootless-containers/slirp4netns/blob/master/slirp4netns.1.md#inter-namespace-communication
slirp4netns --configure --mtu=65520 --disable-host-loopback --macaddress 26:87:71:8f:6f:57 --outbound-addr 100.111.168.3 --outbound-addr6 fd7a:115c:a1e0::1def:a803 --enable-ipv6 $(cat /tmp/pid) tap0
@pojntfx
pojntfx / main.sh
Last active April 6, 2024 15:32
Windows 11 VM with QEMU
#!/bin/bash
mkdir -p "${PWD}/.tpm"
swtpm socket --tpmstate dir="${PWD}/.tpm" --ctrl type=unixio,path="${PWD}/.tpm/swtpm-sock" --tpm2 -d
qemu-system-x86_64 -enable-kvm -m 4096 -smp $(nproc) -cpu host -device ac97 -audiodev alsa,id=snd0,out.buffer-length=500000,out.period-length=726 -show-cursor -usb -device usb-tablet -device virtio-keyboard-pci -net nic -net user -cdrom distro.iso -vga qxl -display spice-app,gl=on -hda disk.qcow2 -machine q35,smm=on -global driver=cfi.pflash01,property=secure,value=on -drive if=pflash,format=raw,unit=0,file=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,readonly=on -drive if=pflash,format=raw,unit=1,file=OVMF_VARS.secboot.fd -chardev socket,id=chrtpm,path="${PWD}/.tpm/swtpm-sock" -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 -drive file=virtio.iso,media=cdrom
@pojntfx
pojntfx / main.sh
Created March 28, 2024 00:25
Shut down all NBD clients on a Linux host
#!/bin/bash
sudo su -c 'for file in /dev/nbd*; do nbd-client -d $file & done; wait'
@pojntfx
pojntfx / main.sh
Created March 22, 2024 04:54
Mark broken postmarketOS dependencies for rebuilds
#!/bin/bash
pmbootstrap pkgrel_bump --auto
@pojntfx
pojntfx / main.sh
Last active March 19, 2024 03:03
Bluesky/AT Protocol: cURL API Interaction Cheatsheet
#!/bin/bash
# This script resolves a DID, retrieves an API key, fetches a user's feed,
# and posts a "Hello, world" message to the user's feed.
# Resolve DID for handle
HANDLE='felicitas.pojtinger.com'
DID_URL="https://bsky.social/xrpc/com.atproto.identity.resolveHandle"
export DID=$(curl -G \
--data-urlencode "handle=$HANDLE" \
@pojntfx
pojntfx / README.md
Last active March 10, 2024 22:20
Enable GTK4, Wayland and hardware acceleration for Chrome on Linux

Update: As of June 2023, Chrome has officially added support for prefers-color-scheme as of this in version 114!

Paste the following into your terminal. You'll have to fully close the browser with pkill chrome each time you want Chrome to re-read the settings.

Also, use the following flags for full GPU acceleration:

  • ignore-gpu-blocklist
  • enable-webrtc-pipewire-capturer
  • enable-gpu-rasterization
  • enable-vulkan