Skip to content

Instantly share code, notes, and snippets.

View begriffs's full-sized avatar

Joe Nelson begriffs

View GitHub Profile
@begriffs
begriffs / testserial.c
Last active March 14, 2023 02:58
Code from WG0A to test RTS-based PTT at a low level
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
int main(int argc, char *argv[])
{
@begriffs
begriffs / multilib.md
Last active January 3, 2023 21:05
arm-none-eabi-gcc multilib on openbsd 7.2

Using package arm-none-eabi-gcc-linaro-7.4.2019.02p0 and arm-none-eabi-newlib-2.2.0.1p1, the compiler can't find a multilib match for this combination of CFLAGS:

  • -mcpu=cortex-m4
  • -mthumb
  • -mfloat-abi=hard
  • -mfpu=fpv4-sp-d16

This is all it provides:

@begriffs
begriffs / nmalloc.c
Created February 15, 2021 16:40
Might be a good idea, might not. Not yet tested
bool nmalloc(size_t n, void ***elts, ...)
{
va_list ap;
*elts = malloc(n * sizeof **elts);
if (!*elts)
return false;
va_start(ap, elts);
for (size_t i = 0; i < n; i++)
{
@begriffs
begriffs / concat.c
Last active February 15, 2021 03:19
Concatenate multiple strings to a freshly allocated result
/* concat(0) creates a new "" in heap memory,
and concat(1, foo) is equivalent to strdup(foo).
Note I haven't tested this function yet. */
char *concat(size_t n, ...)
{
va_list ap;
size_t retlen = 0;
char *ret = calloc(1,1);
@begriffs
begriffs / dict.c
Created February 13, 2021 20:28
C dictionary based on POSIX tree
#include "dict.h"
#include <stdlib.h>
#include <search.h>
/* XOPEN for strdup */
#define _XOPEN_SOURCE 600
#include <string.h>
struct dict_entry
@begriffs
begriffs / fail.c
Created October 3, 2020 18:22
malloc: *** error for object 0x7ffc49c02850: pointer being freed was not allocated
#define _POSIX_C_SOURCE 200112L
#include <search.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct st_symbol
{
@begriffs
begriffs / Makefile
Last active July 3, 2019 02:36
Installing binaries as needed
VPATH=/usr/local/bin
BINARIES=ruby node
all : ${BINARIES}
echo "Deps are installed"
${BINARIES} :
asdf plugin-add $@
dig $1 MX +short
dig $1 TXT +short | grep spf
dig default._domainkey.$1 TXT +short
dig google._domainkey.$1 TXT +short
dig _dmarc.$1 TXT +short
@begriffs
begriffs / citus
Created October 29, 2018 22:49
little hacky script I use to manage versions
#!/bin/bash
ACTION="${1:-start}"
VER="${2:-8.0}"
case $ACTION in
install)
echo "Installing versioned extension shared object"
cp src/backend/distributed/citus.so /usr/local/lib/postgresql/citus-${VER}.so
;;
@begriffs
begriffs / znc.patch
Created September 19, 2018 21:32
Making ZNC work with a dedicated user
Index: infrastructure/db/user.list
===================================================================
RCS file: /cvs/ports/infrastructure/db/user.list,v
retrieving revision 1.318
diff -u -p -r1.318 user.list
--- infrastructure/db/user.list 15 Jun 2018 09:29:03 -0000 1.318
+++ infrastructure/db/user.list 7 Jul 2018 19:44:42 -0000
@@ -321,3 +321,4 @@ id user group port options
810 _sabnzbd _sabnzbd news/sabnzbd
811 _openvpnusers net/openvpn_bsdauth