Skip to content

Instantly share code, notes, and snippets.

@brimston3
brimston3 / lsiommugroups.bash
Created June 21, 2017 13:46
IOMMU group identification
#!/bin/bash
# I have no idea where I got this script, possibly here:
# https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF
for d in /sys/kernel/iommu_groups/*/devices/* ; do
n=${d#*/iommu_groups/*}
n=${n%%/*}
printf 'IOMMU Group %s ' "$n"
lspci -nns "${d##*/}"
@brimston3
brimston3 / restrict_punning.c
Created June 14, 2017 22:02
unexpected success with restrict keyword punning
// I expect this to generate errors on mismatched prototypes but apparently it does not. I should probably figure out why.
// gcc -std=c1x -Wstrict-aliasing -Wall -Wno-unused-but-set-variable restrict_punning.c
// clang -std=c1x -Wstrict-aliasing -Wall restrict_punning.c
void f1(char * restrict a, char * b)
{
return;
}
@brimston3
brimston3 / xc8_bug_syntax.c
Created May 2, 2017 15:04
xc8 1.41 syntax error in temporary file
#include <xc.h>
#include <stdint.h>
typedef struct _cmd_read_write_disp
{
uint8_t cmd;
void (*newseq)();
// ... Reduced for brevity ...
} CMD_READ_WRITE_DISP_ST;
@brimston3
brimston3 / debian_llvm39_link_check.sh
Last active April 15, 2017 01:34
Check libllvm-3.9.so dynamic links
@brimston3
brimston3 / conky.conf
Created April 11, 2017 22:42
pi3 conkyrc
alignment top_right
cpu_avg_samples 2
gap_x 5
gap_y 60
minimum_size 5 5
net_avg_samples 2
update_interval 2.0
double_buffer true
# Set font size to legible.
@brimston3
brimston3 / route_dev_prio.sh
Created April 11, 2017 19:35
Give wlan0 routing priority
#!/bin/sh
TARGET_IF=wlan0
ADDPRIO=101
DEFAULT_RT=$(ip ro show dev "$TARGET_IF" | grep 'default' | cut -d' ' -f3 | tail -1)
if [ -n "$DEFAULT_RT" ]; then
sudo ip ro add default via $DEFAULT_RT metric $ADDPRIO
sudo sed -i -e 's@^nameserver 10\.8\.1\.@#\0@' /etc/resolv.conf
else
// Put this in a separate .h file (called "getopt.h").
// The prototype for the header file is:
/*
#ifndef GETOPT_H
#define GETOPT_H
int getopt(int nargc, char * const nargv[], const char *ostr) ;
#endif
*/
@brimston3
brimston3 / do_not_do_this_interfaces
Created February 14, 2017 22:31
Things you should not do with /etc/network/interfaces
##################################################################
# If you have not read the multiple disclaimers, do not do this. #
# It is supposed to be a joke, haha. #
##################################################################
This goofiness is valid:
/etc/network/interfaces:
for procif in /etc/network/interfaces.d/*; do
procifname="$(basename $procif)"
@brimston3
brimston3 / Makefile
Last active February 13, 2017 21:07
cygwin sign unsigned binaries
# Makefile called like so:
#SIGN=YES gmake
RELEASEFILES:=a.exe a.dll
SIGNED_SDIR:=signed_bin
UNSIGNED_SDIR:=unsigned_bin
ODIR:=install
SIGNTOOL:='/cygdrive/c/Program Files (x86)/Windows Kits/8.1/bin/x64/signtool.exe'
# Update with your signtool options:
SIGOPTS:=/tr http://timestamp.digicert.com /td sha256 /fd sha256 /i DigiCert_Test
@brimston3
brimston3 / FindKeyutils.cmake
Last active February 1, 2017 20:07
CMake FindKeyutils module
# This module defines
# Keyutils_LIBRARIES, the name of the libraries to link against
# Keyutils_FOUND, if false, do not try to link keyutils
# Keyutils_INCLUDE_DIRS, where to find keyutils.h and dependent includes
#
# As keyutils is a Linux interface, paths for other OSes are not defined
#
# Copyright (c) 2017, Andrew Domaszek
#
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying