Skip to content

Instantly share code, notes, and snippets.

#include <cstdint>
#include <charconv>
#include <iostream>
#include <fstream>
#include <regex>
void test1();
@darealshinji
darealshinji / linux_check_instance.c
Last active September 13, 2025 23:25
check if another instance of this program is already running
/* Linux: check if another instance of this program is already running
* by looking through the /proc/<PID>/ entries */
/**
* MIT License
*
* Copyright (C) 2024 Carsten Janssen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
#include <assert.h>
#include <stdint.h>
/* boolean value */
#define BIT_IS_SET(VAL, POS) \
((VAL >> (POS)) & 1)
/* unsigned number */
#!/bin/bash
set -e
set -x
# how to run this script in podman:
#
# BUILD_ROOT="$HOME/Downloads"
#
# podman run --rm --init \
@darealshinji
darealshinji / mis2x264.sh
Last active September 29, 2024 22:27
Convert MediaInfo encoding settings to x264 commands
#!/bin/sh
if [ -z "$1" ] ; then
echo "Convert MediaInfo encoding settings to x264 commands"
echo "Usage: $0 <video>"
echo " $0 \"MediaInfo encoding settings\""
exit 0
fi
--- a/libaegisub/unix/path.cpp
+++ b/libaegisub/unix/path.cpp
@@ -22,8 +22,22 @@
#include <boost/filesystem/operations.hpp>
#include <pwd.h>
+#ifdef LINUX_PORTABLE_BUILD
+#include <iostream>
+#endif
+
@darealshinji
darealshinji / kbhit-linux.c
Last active June 8, 2024 18:14
kbhit() for Linux
/**
* MIT License
*
* Copyright (C) 2024 Carsten Janssen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
#!/bin/sh
set -e
set -x
mkdir -p build
cd build
# readelf
#include <iostream>
/*
./bootstrap.sh --with-libraries=filesystem,url
./b2 -j4 link=static variant=release cxxflags="-O3 -ffunction-sections -fdata-sections"
g++ -O3 -Wall -Wextra -I. ../boost_misc.cpp -o ../boost_misc -Lstage/lib -lboost_filesystem -lboost_url -s -Wl,--gc-sections
*/
/* generate UUID (header-only) */
#include <boost/lexical_cast.hpp>
@darealshinji
darealshinji / zelotes-c12-data.txt
Created December 27, 2023 01:42
Zelotes C-12 Gaming USB Mouse data
#define USB_VENDOR_ID 0x12c9
#define USB_PRODUCT_ID 0x1028
Class-Specific Request (DOWN)
Destination: Interface, Index 2
Reserved Bits: 34
Request: 0x9
Value: 0x300