Skip to content

Instantly share code, notes, and snippets.

@zonque
zonque / mcasttest.c
Last active November 13, 2021 09:03
Simple client/server multicast test
/*
* Compile:
*
* gcc mcasttest.c -o server -Wall
* ln -s server client
*
* Invoke:
*
* ./client
* ./server
@zonque
zonque / sctptest.c
Last active May 25, 2025 07:07
Simple client/server test for SCTP
/*
* Compile:
*
* gcc sctptest.c -o server -lsctp -Wall
* ln -s server client
*
* Invoke:
*
* ./client
* ./server
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
static int recv_creds(int fd) {
unsigned char buf[128], ctrl[128];
/* pidns_init_sleep.c
Copyright 2013, Michael Kerrisk
Licensed under GNU General Public License v2 or later
A simple demonstration of PID namespaces.
*/
#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
@zonque
zonque / tone.rb
Last active August 29, 2015 14:10
class Tone
NAMES = ["C", "Cis/Des", "D", "Dis/Es", "E", "F", "Fis/Ges", "G", "Gis/As", "A", "Ais/B", "H" ]
C = 1
Cis = 2
Des = 2
D = 3
Dis = 4
Es = 4
E = 5
@zonque
zonque / xymodem-mini.c
Last active May 27, 2026 00:11
simple xmodem/ymodem implementation in C
/*
* Minimalistic implementation of the XModem/YModem protocol suite, including
* a compact version of an CRC16 algorithm. The code is just enough to upload
* an image to an MCU that bootstraps itself over an UART.
*
* Copyright (c) 2014 Daniel Mack <github@zonque.org>
*
* License: MIT
*/
@zonque
zonque / glib-utils.c
Created April 17, 2014 19:00
pa_thread_mq → GSource bridge
/***
This file is part of PulseAudio.
Copyright 2014 - Daniel Mack
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <errno.h>
#include <poll.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@zonque
zonque / dbus-redirect.c
Created November 6, 2013 09:48
LD_PRELOAD hack for working on the kdbus bridge
/* gcc -fPIC -shared -o dbus-redirect.so dbus-redirect.c -ldl */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <dlfcn.h>
@zonque
zonque / gist:6579314
Last active December 23, 2015 04:19
Test case to tigger a mwifiex command timeout bug.
#include <stdio.h>
#include <string.h>
#include <ifaddrs.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/wireless.h>
static void get_signal_strength(const char *ifname)