Skip to content

Instantly share code, notes, and snippets.

View Daniel-Abrecht's full-sized avatar

Daniel Abrecht Daniel-Abrecht

View GitHub Profile
@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);
@Daniel-Abrecht
Daniel-Abrecht / greco
Created May 12, 2021 20:08
Colors matched lined such that the same matches have the same color
#!/bin/bash
pattern="$1"
while IFS= read -r line
do
if ! matchpart="$(grep -o "$pattern" <<<"$line")"
then printf "%s\n" "$line"; continue
fi
rstr="$(printf "%s\n" "$matchpart" | head -n 1 | md5sum | head -c 6)"
@Daniel-Abrecht
Daniel-Abrecht / rtsp-reflector.py
Created January 29, 2021 13:40
RTSP RTP Multicast reflector
#!/usr/bin/env python3
#
# If there is an existing h264 rtp multicast stream, but an application requires rtsp,
# but does support rtp multicast over rtsp, then this program will help. It's an
# rtsp server which simply tells the client to use the rtp stream encoded in the rtsp URI.
# For example, with "vlc rtsp://127.0.0.1:8090/rtp/239.1.2.50:5004", it'll tell vlc
# that there is an h264 rtp multicast stream at 239.1.2.50:5004.
#
# SPDX-License-Identifier: MIT-0
# Copyright 2021 Daniel Abrecht
@Daniel-Abrecht
Daniel-Abrecht / White paper thought experiment.md
Created July 3, 2018 20:13
A thought experiment to show that if everything exists, it may be basically the same as nothing existing at all.

White paper thought experiment

What is this about

There are many theories about what time is. What is the future, and what is the past? Do they exist at all? Is there only one future and one past? Is the universe really fundamentally indeterministic, or is everything predetermined? I can't answer these questions, and maybe humanity will never be able to do so, but we can think about the implications different natures of time would have.

I like determinism. I like the idea that everything follows a fixed set of rules, that with infinite computing

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<canvas id="canvas" width="512" height="512"></canvas>
<script type="x-shader/x-vertex">
uniform vec3 direction, ucamera;
attribute vec3 coordinates;
varying vec3 ray;
@Daniel-Abrecht
Daniel-Abrecht / my_hello_world_distro.sh
Created January 28, 2018 21:56
Shellscript to build the most minimalistic linux live CD which just starts /sbin/init from the CD root directory and outputs "Hello World!"
#!/bin/bash
# Vorhandensein der Programme prüfen
MKISOFS=( $(which genisoimage mkisofs) )
if ! [ -x "$MKISOFS" ]; then echo "genisoimage aka mkisofs is missing"; exit 1; fi
if ! [ -x "$(which gcc)" ]; then echo "gcc is missing"; exit 1; fi
if ! [ -x "$(which nasm)" ]; then echo "nasm is missing"; exit 1; fi
if ! [ -x "$(which cpio)" ]; then echo "cpio is missing"; exit 1; fi
if ! [ -x "$(which tar)" ]; then echo "tar is missing"; exit 1; fi
@Daniel-Abrecht
Daniel-Abrecht / vm_login.sh
Last active February 16, 2019 13:01
Server scripts
#!/bin/bash
# This sctipt can be added in /etc/inittab in any system with traditional init systems
# to replace the login prompt whith a selection of VMs
# This script uses virsh to get list of all local lxc and qemu VMs managed using libvirt.
# The list will be displayed using dialog. When selecting a VM, this script attempts to
# get a spice or vnc display. It will connect to those with spice-client or directvnc.
# If no display is available, virsh console is used to connect to the vm console.