Skip to content

Instantly share code, notes, and snippets.

@zonque
zonque / vim-dts-syntax
Created September 10, 2012 08:25
DTS syntax highlighting for VIM
if exists("b:current_syntax")
finish
endif
syntax region dtsComment start="/\*" end="\*/"
syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
syntax region dtsBinaryProperty start="\[" end="\]"
syntax match dtsStringProperty "\".*\""
syntax match dtsKeyword "/.*/"
syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
@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)
@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>
#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 / 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.
@zonque
zonque / xymodem-mini.c
Last active October 17, 2024 20:59
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 <[email protected]>
*
* License: MIT
*/
@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
/* 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>
#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];
@zonque
zonque / sctptest.c
Last active September 19, 2023 16:37
Simple client/server test for SCTP
/*
* Compile:
*
* gcc sctptest.c -o server -lsctp -Wall
* ln -s server client
*
* Invoke:
*
* ./client
* ./server