Skip to content

Instantly share code, notes, and snippets.

@mailinglists35
mailinglists35 / macanon.sh
Created March 21, 2024 21:22
anonymize ethernet mac address
#!/bin/bash
# thanks microsoft copilot. worked from first try. prompt:
# can you write a small script in a language of your choice that takes input as defined by the name of the input file, searches for patterns that resemble an ethernet mac address including those that omit the zero, such as like when netstat on macos does, then replace the last three octets of the mac address with xx:xx:xx
# it wrote python but python requires xcode so I asked for a rewrite in bash
filename="$1"
# MAC address pattern (with optional leading zeros)
pattern="([0-9A-Fa-f]{1,2}[:-]){5}([0-9A-Fa-f]{1,2})"
@mailinglists35
mailinglists35 / add_cow.sh
Last active July 12, 2023 16:33
Create writable device files from readonly images on Linux using device mapper
copied from https://git.scc.kit.edu/-/snippets/563, found on search for "device mapper volatile writeable readonly"
#!/bin/bash
set -e
# test if $1 exists
test -f "$1"
BASEDIR=$(dirname "$1")
@mailinglists35
mailinglists35 / dkms rebuild reinstall
Created June 21, 2023 15:13
dkms rebuild reinstall
27332 pts/0 S+ 0:00 | \_ sudo -E dnf --enablerepo=ol8_UEKR6 install kernel-uek-5.4.17-2136.320.7.1.el8uek.x86_64 kernel-uek-devel-5.4.17-2136.320.7.1.el8uek.x86_64
27334 pts/0 S+ 1:40 | \_ /usr/libexec/platform-python /bin/dnf --enablerepo=ol8_UEKR6 install kernel-uek-5.4.17-2136.320.7.1.el8uek.x86_64 kernel-uek-devel-5.4.17-2136.320.7.1.el8uek.x86_64
48159 pts/0 S+ 0:00 | \_ /bin/sh /var/tmp/rpm-tmp.UD5iFV 2
56855 pts/0 S+ 0:00 | \_ /bin/bash /bin/kernel-install add 5.4.17-2136.320.7.1.el8uek.x86_64 /lib/modules/5.4.17-2136.320.7.1.el8uek.x86_64/vmlinuz
56897 pts/0 S+ 0:00 | \_ /bin/sh /usr/lib/kernel/install.d/40-dkms.install add 5.4.17-2136.320.7.1.el8uek.x86_64 /boot/b26894ddea4a49caaac4c71d4e27f057/5.4.17-2136.320.7.1.el8uek.x86_64 /lib/modules/5.4.17-2136.320.7.1.el8uek.x86_64/vmlinuz
56898 pts/0 S+ 0:00 | \_ /bin/sh /usr/lib/
@mailinglists35
mailinglists35 / macos
Created June 18, 2023 19:50
trying to run macos under unsupported rhel9.2 via podman libvirt/qemu inside container
sudoedit /etc/tmpfiles.d/libvirt-container.conf
d /run/libvirt-fedora 0755 ml35 ml35 -
sudo systemd-tmpfiles --create /etc/tmpfiles.d/libvirt-container.conf
sudo gpasswd -a ml35 kvm
sudo setsebool -P container_use_devices=true
sudo setsebool -P container_manage_cgroup true
$ grep source /var/local/macos-mojave-10.14.xml
<resource>
</resource>
<source dev='/dev/zvol/gen8/vm/mojave-din-vmware'/>
@mailinglists35
mailinglists35 / choosing ext4 vs xfs
Last active May 27, 2023 22:21
when to choose EXT4 over XFS - ext4 is still king for home use or older systems
https://access.redhat.com/articles/3129891#choosing-a-local-file-system-6
Another way to characterize this is that the Ext4 file system variants tend to perform better on systems that have limited I/O capability. Ext3 and Ext4 perform better on limited bandwidth (< 200MB/s) and up to ~1,000 IOPS capability. For anything with higher capability, XFS tends to be faster. XFS also consumes about twice the CPU-per-metadata operation compared to Ext3 and Ext4, so if you have a CPU-bound workload with little concurrency, then the Ext3 or Ext4 variants will be faster. In general, Ext3 or Ext4 is better if an application uses a single read/write thread and small files, while XFS shines when an application uses multiple read/write threads and bigger files.
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_file_systems/overview-of-available-file-systems_managing-file-systems
ext4 is better when:
Single-threaded I/O
Limited I/O capability (under 1000 IOPS)
@mailinglists35
mailinglists35 / gptbios
Created May 27, 2023 22:17
create parted gpt partitions on bios disk including microsoft reserved
mktable gpt
mkpart ESP fat32 1MiB 513MiB
set 1 boot on
mkpart biosboot 513MiB 514MiB
set 2 bios_grub on
mkpart msftres 514MiB 530MiB
unit MiB
(parted) p
Model: ATA Samsung SSD 860 (scsi)
@mailinglists35
mailinglists35 / git marriage
Last active April 13, 2023 12:17
merge/revert analogy with marriage/divorce
generated using bing gpt:
Git merge is like getting married. You find someone (or some branch) that you like and want to spend the rest of your life (or project) with. You propose (or create a pull request) and hope they say yes (or approve). Then you have a big ceremony (or a commit message) where you exchange vows (or diffs) and become one (or merge). You celebrate with your friends and family (or collaborators and followers) and hope for a happy future together.
But sometimes, things don't work out as planned. Maybe you rushed into the marriage (or merge) without knowing your partner (or branch) well enough. Maybe you had unrealistic expectations or incompatible goals. Maybe you discovered some flaws or bugs that you couldn't live with. Maybe you fell out of love (or sync) or found someone else (or a better branch). Whatever the reason, you decide to get a divorce (or revert the merge).
Getting a divorce (or reverting a merge) is not as easy as getting married (or merging). You have to go through a lot
c:
cd "\program files\qemu"
start .\qemu-system-x86_64w.exe -name w7 -machine q35,vmport=off,dump-guest-core=off -accel hax -boot order=cd,menu=off -m 2048 -k en-us -spice addr=127.0.0.1,port=5901,disable-ticketing=on -chardev spicevmc,id=vdagent,debug=0,name=vdagent -device virtio-serial -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -vga qxl -display gtk -cpu Haswell,vme=on,x2apic=on,hypervisor=on,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_synic,hv_stimer -smp 4,cores=4,threads=1,sockets=1,maxcpus=4 -net nic,model=virtio -net user,hostfwd=tcp::22222-:22 -drive id=disk,file=c:\large_files\w7.qcow2,format=qcow2,if=none,cache=writeback,discard=unmap,detect-zeroes=unmap,aio=native -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0,id=disk -cdrom "C:\large_files\ubuntu-22.04-desktop-amd64.iso" -usb -device usb-mouse -device usb-kbd -device usb-tablet -global kvm-pit.lost_tick_policy=discard -no-hpet -global ICH9-LPC.disable_s3=1 -global ICH9-LPC.disable_s4=0 -rtc base=localtime -se
@mailinglists35
mailinglists35 / miui_adb_install.sh
Last active November 20, 2022 22:45 — forked from zpp0196/miui_adb_install.sh
MIUI 「USB安装」免登录账号
#!/bin/sh
set -e
setprop persist.security.adbinput 1
setprop persist.security.adbinstall 1
provider_prefs_xml=/data/data/com.miui.securitycenter/shared_prefs/remote_provider_preferences.xml
provider_prefs_tmp_xml=/data/local/tmp/remote_provider_preferences.xml
sed -e "/security_adb_install_enable/d;/permcenter_install_intercept_enabled/d" $provider_prefs_xml > $provider_prefs_tmp_xml
<?php
// Settings.
$feedName = 'Opus codec';
$feedDesc = 'Opus codec';
$feedURL = 'https://example.com/podcast/';
$coverImageFileName = 'audiobooks.png';
$ffprobePath = '/usr/bin/ffprobe';
$ffmpegPath = '/usr/bin/ffmpeg';