Skip to content

Instantly share code, notes, and snippets.

@skyhisi
skyhisi / socket-term.sh
Created May 3, 2024 07:42
Connect to Virtual Box serial port pipe terminal
#!/bin/bash
# Connect to a Virtual Box serial port pipe
# 1. Enable Virtual Box serial port 1 as "Host Pipe", untick "Connect to
# existing", enter path, e.g "/tmp/apollo"
# 2. Start VM, SSH in and enable terminal and reboot:
# systemctl enable serial-getty@ttyS0.service
# 3. Connect to port with this script, pass the filename
# 4. Disconnect with escape key Ctrl+O (letter not zero)
if [ $# -ne 1 ]; then echo "Usage: $0 PIPE"; exit 1; fi
@skyhisi
skyhisi / compact-ext.sh
Last active February 9, 2024 09:43
Compact ext3/4 filesystems in a VM
#!/bin/bash
# Compact ext3/4 filesystems in a VM
# Tools should all be available within a gparted live VM
# Enable discard support in VirtualBox with a command like:
# vboxmanage storageattach "GParted Live" --storagectl=VirtIO --port=0 --discard=on --nonrotational=on
# Or disable the fstrim and use
# vbox-img.exe compact --filename DISK.vdi
set -eux
for DEV in $(lsblk -o name,fstype --raw --paths | grep 'ext[34]' | cut '-d ' -f1)
@skyhisi
skyhisi / alignment.c
Created August 25, 2020 08:01
Enable Alignment Checks on x86-64
void enable_ac(void)
{
__asm__("pushf\n"
"orl $0x40000, (%rsp)\n"
"popf");
}
@skyhisi
skyhisi / fping-lan.service
Created November 14, 2019 10:23
Run fping as a systemd service, get network stats and keeps powerline/homeplug network adapters connected
[Unit]
Description=FPing LAN
After=network.target auditd.service time-sync.target
[Service]
ExecStart=/usr/bin/fping \
--loop --period=1000 --timeout=500 --squiet=1800 \
192.168.0.1 \
192.168.0.2
@skyhisi
skyhisi / confluence-uncheck-all.html
Created August 6, 2019 12:39
Create button to untick all check boxes
<button id="uncheckAll">Uncheck All</button>
<script type="text/javascript">
$('#uncheckAll').click(function(){$('.inline-task-list li.checked').each(function(i,e){ev = jQuery.Event("click"); ev.target = ev. currentTarget = e; ev.offsetX = ev.offsetY = 10; $(e).trigger(ev);});});
</script>
@skyhisi
skyhisi / qtlogging.ini
Created August 6, 2019 12:20
Qt - Enable qDebug on Fedora - /etc/xdg/QtProject/qtlogging.ini
[Rules]
*.debug=true
qt.*.debug=false
@skyhisi
skyhisi / vlc-udp-stream.sh
Created August 6, 2019 12:17
VLC Ouput UDP Multicast Stream
#!/bin/bash
cvlc "$1" \
--sout='#udp{dst=239.1.1.170:1234}' \
--no-sout-rtp-sap \
--no-sout-standard-sap \
--sout-all --ttl=1 --sout-keep --loop
@skyhisi
skyhisi / vbox-compact-all.sh
Created August 6, 2019 12:15
Virtual Box - Compact all disks
#!/bin/bash
for ID in $(vboxmanage list hdds | grep '^UUID:' | cut -c14-)
do
vboxmanage modifyhd $ID --compact
done
@skyhisi
skyhisi / example.mk
Created August 6, 2019 12:13
Enable strict flags in a makefile for specific files
# Enable very strict flags for some files to ensure compatibility with
# all compilers (enables C99 strict compliance mode and more warnings).
STRICTFLAGS := \
-D_XOPEN_SOURCE --std=c99 -pedantic-errors -W -Wall -Wextra \
-Wno-variadic-macros -Wno-overlength-strings -fdiagnostics-show-option
STRICTFLAGS_FILES := \
file_a.c \
file_b.c
# Use '=' not ':=' to create a makefile macro
@skyhisi
skyhisi / pgkill.sh
Created August 6, 2019 12:11
Script to kill postgres workers for a given process
#!/bin/bash
PGPORT=5678
APP_PID=$(pidof -s $1)
if [ $? -ne "0" ]
then
echo "Can not find PID of $1"
exit 1
fi