Skip to content

Instantly share code, notes, and snippets.

@mekb-turtle
mekb-turtle / util.c
Created January 30, 2025 12:43
C file reading util function
#include "util.h"
struct file get_file(FILE *fp, void *(*malloc_)(size_t), void *(*realloc_)(void *, size_t), void (*free_)(void *)) {
return (struct file){
.fp = fp,
.size = 0,
.capacity = 0,
.data = NULL,
.error = false,
.complete = false,
@mekb-turtle
mekb-turtle / explain.bash
Last active January 14, 2025 18:44
Explain a command using explainshell.com
#!/bin/bash
explain() {
if [[ "$#" == 0 ]]; then
echo "Usage: explain <command>..."
echo "Explain a command using explainshell.com"
echo "Example: explain 'ls -l -a'"
echo "For best results, quote the command to prevent shell expansion"
return 1
fi
@mekb-turtle
mekb-turtle / crontab
Created January 9, 2025 21:49
cronjob to update packages (uses checkupdates)
# /etc/crontab: configuration file for cron
# See cron(8) and crontab(5) for details.
# m h dom mon dow user command
0 * * * * root /root/idlenice /root/fetch-updates
@reboot root /root/idlenice /root/fetch-updates
@mekb-turtle
mekb-turtle / README.md
Created October 6, 2024 06:18
Arduino caps lock LED indicator

This script reads the state of the Caps Lock key and sends it to an Arduino connected to a serial port. The Arduino then controls an LED to indicate the state of the Caps Lock key.

The script can be run multiple times, but only one instance will be running at a time. If another instance is started, it will send a message to the running instance to update the state of the Caps Lock key.

If you use Hyprland, paste this into your config file:

@mekb-turtle
mekb-turtle / liminetest.sh
Last active August 4, 2024 06:56
Test Limine configurations
#!/usr/bin/bash
DIR=/tmp/liminetest
ISO_DIR=$DIR/isoroot
ISO=$DIR/out.iso
LIMINE_CONFIG=limine.conf
LIMINE_EXTRA_FILES=(limine_bg.bmp)
LIMINE_BIN_DIR=/usr/share/limine
LIMINE_TOOL=limine
#LIMINE_BIN_DIR=~/clone2/limine/bin
#LIMINE_TOOL=~/clone2/limine/bin/limine
@mekb-turtle
mekb-turtle / shrink-video
Created July 27, 2024 02:10
Script to shrink video file sizes
#!/bin/bash
fIn="$1"
if [[ ! -f "$fIn" ]]; then echo file does not exist; exit 1; fi
ext="${fIn##*.}"
fOut="${fIn}.shrunk.${ext}"
durationSeconds="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$fIn" || exit 1)"
mul="$(($2))"
[[ "$mul" == "0" ]] && mul=20
mul="${mul:-1}"
echo "Target size: ${mul}MB."
@mekb-turtle
mekb-turtle / update-dracut.sh
Created June 15, 2024 05:45
Script to regenerate dracut initramfs
#!/bin/sh
set -o errexit
KERNEL="$(pacman -Q linux | awk '{print $2}' | sed 's/\.\([a-z]\+\)/-\1/')"
echo "Generating initramfs for kernel $KERNEL"
echo "This may take a while..."
echo "Generaing /boot/initramfs-linux.img..."
dracut --hostonly --no-hostonly-cmdline /boot/initramfs-linux.img -f "$KERNEL"
echo "Generaing /boot/initramfs-linux-fallback.img..."
dracut /boot/initramfs-linux-fallback.img -f "$KERNEL"
diff --git a/src/bot.js b/src/bot.js
index ce523a4..716f3da 100644
--- a/src/bot.js
+++ b/src/bot.js
@@ -171,7 +171,7 @@ async function handleMessage(message) {
if (reply.author.id != client.user.id) return;
if (messages[channelID] == null) return;
if ((context = messages[channelID][reply.id]) == null) return;
- } else if (message.type != MessageType.Default || (message.guild && !message.content.match(myMention))) {
+ } else if (message.type != MessageType.Default) {
@mekb-turtle
mekb-turtle / power
Last active September 8, 2023 02:45
rofi power menu script
#!/bin/bash
RES="$(rofi -dmenu -p "Power" <<< $'Shutdown\nRestart\nLog Out\nLock')"
if [[ "$RES" == "Shutdown" ]]; then /usr/local/sbin/do shutdown & disown; fi
if [[ "$RES" == "Restart" ]]; then /usr/local/sbin/do restart & disown; fi
if [[ "$RES" == "Log Out" ]]; then hyprctl dispatch exit; fi
if [[ "$RES" == "Lock" ]]; then swaylock; fi
#if [[ "$RES" == "Suspend" ]]; then swaylock & /usr/local/sbin/do suspend1 & disown; fi
@mekb-turtle
mekb-turtle / swapfile
Last active April 28, 2023 08:55
bash script to swap two files around
#!/usr/bin/bash
if [[ "$#" != "2" ]]; then echo "Usage: swapfile <file1> <file2>"; exit 1; fi
f1="$1"
f2="$2"
if [[ ! -e "$f1" ]]; then echo "File not found: $f1"; exit 1; fi
if [[ ! -e "$f2" ]]; then echo "File not found: $f2"; exit 1; fi
while [[ "$f1" == */ ]]; do f1="${f1%\/}"; done
while [[ "$f2" == */ ]]; do f2="${f2%\/}"; done
echo "Swapping $f1 and $f2"
IDTEMP="$(uuidgen|tr -d '-')"