Skip to content

Instantly share code, notes, and snippets.

View Daniel-Abrecht's full-sized avatar

Daniel Abrecht Daniel-Abrecht

View GitHub Profile
%import common.WS
%ignore WS
token: keyword
| identifier
| constant
| string_literal
| punctuator
#!/usr/bin/python3
import sys
import json
import pymysql
from datetime import datetime, timezone
mariadb=pymysql
a = [*sys.argv[1:]]
@Daniel-Abrecht
Daniel-Abrecht / main.c
Created April 11, 2023 21:17
Periodic tty locker
#include <libttymultiplex.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
const static struct tym_super_position_rectangle fullscreen_coordinates = {
.edge[TYM_RECT_TOP_LEFT].type[TYM_P_CHARFIELD].axis[TYM_AXIS_VERTICAL].value.integer = 1,
.edge[TYM_RECT_BOTTOM_RIGHT].type[TYM_P_RATIO].axis = {
[TYM_AXIS_HORIZONTAL].value.real = 1,
[TYM_AXIS_VERTICAL].value.real = 1,
@Daniel-Abrecht
Daniel-Abrecht / example
Last active November 13, 2022 15:21
A program for easily summarizing test results
$ testsuite "Hello World" bash
$$ testsuite Example bash
$$$ testsuite "This will succeed" true
$$$ testsuite "This will fail" false
$$$ testsuite "This will not start" 123
execvp: No such file or directory
$$$ exit
$$ testsuite "Another Test" test 1 = 1
$$ exit
success
#!/bin/bash
# The MIT License (MIT)
#
# Copyright © 2022
#
#
# 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
@Daniel-Abrecht
Daniel-Abrecht / alsa_all.c
Last active October 31, 2021 19:37
Makes all alsa devices available to jack using alsa_in and alsa_out programs. Polls alsa hw devices every 5 seconds to spawn / kill alsa_out programs as needed.
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <spawn.h>
#include <alloca.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <assert.h>
#include <stdbool.h>
@Daniel-Abrecht
Daniel-Abrecht / dpajail
Last active February 3, 2024 17:30
A simple jail using unprivileged userspace namespaces
#!/bin/sh
set -e
PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin"
self="$(realpath "$0")"
rodirs="
bin
sbin
@Daniel-Abrecht
Daniel-Abrecht / mount.ovtmp
Last active October 19, 2021 08:43
Put this script at /sbin/mount.ovtmp . Script for tmpfs overlays. Put a line for mounting an "ovtmp" fs into fstab, and it'll use a tmpfs and overlayfs to mount over the target. Useful if the root is readonly, but changes need to be possible but don't need persistance.
#!/bin/sh
set -e
cleanup(){
set +e
if [ -n "$tmp" ]
then
umount -l "$tmp" 2>/dev/null
rmdir "$tmp"
@Daniel-Abrecht
Daniel-Abrecht / anbox-container-manager
Created September 19, 2021 17:44
Anboxinit scripts
#!/bin/sh
# /etc/init.d/anbox-container-manager
### BEGIN INIT INFO
# Provides: anbox-container-manager
# Required-Start: dbus $network $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: init script for anbox container manager.
@Daniel-Abrecht
Daniel-Abrecht / main.c
Created June 2, 2021 21:18
Ringbuffer using memory mapping
#include "ringbuffer.h"
#include <stdio.h>
#include <string.h>
int main(){
char* buf = ringbuffer_create("Hello World ringbuffer");
strcpy(buf+ring_buffer_size-6, "Hello ");
strcpy(buf, "World!");
printf("%s\n", buf+ring_buffer_size-6);