Skip to content

Instantly share code, notes, and snippets.

# bpm is from debian's bpm-tools package
# ffmpeg is from the usual places
# > bpmff "Rundfunk-Tanzorchester Ehrenfeld - Daft Punk - 'Harder, Better, Faster, Stronger'-B3gG03bh7WA.mp4"
# 123.181
bpmff() {
if [ ! -f "$1" ]; then
echo "File not found"
else
@brimston3
brimston3 / get_simplicitystudio_packages.sh
Created September 2, 2018 19:26
Discover all debian/ubuntu packages needed for simplicity studio
find $HOME/silab/SimplicityStudio_v4 -executable -type f -print0 | xargs --null -i@ ldd "@" > ~/sistudio_ldd.txt
sed -e 's@(0x[^)]*)@@' ~/sistudio_ldd.txt | sort -u | grep -v /home/ | grep -v 'not found' | grep '=>' | awk '{print $3}' | xargs -i@ dpkg -S '@' > ~/sistudio_pkg.txt
sed -e 's@: .*@@' ~/sistudio_pkg.txt| sort -u
@brimston3
brimston3 / Makefile
Created February 21, 2018 14:25
Embed program source code (or any binary) in the output ELF.
DEBUG=-ggdb
selfprint: selfprint.c.o selfprint.c
$(CC) -o $@ $(DEBUG) $^
selfprint.c.o: selfprint.c
objcopy -I binary -O elf64-x86-64 -B i386 $< $@
.PHONY: show
show: selfprint
@brimston3
brimston3 / mosqsub.c
Last active December 7, 2017 21:17
libmosquitto test program
// Connect to local mosquitto server over tls with no client authentication, then subscribe to everything.
// $(CC) -o mosqsub -lmosquitto mosqsub.c
/* vim: set sw=2 ts=2 expandtab: */
//! @todo reconnect lost connections automatically
#include <mosquitto.h>
#include <poll.h>
@brimston3
brimston3 / cxx11_threadcheckdone.cpp
Created October 12, 2017 16:29
playing around with C++11 threads
// g++ -lpthread -std=c++11 -o cxx11_threadcheckdone.cpp
/*! vim: set ts=2 sw=2 expandtab: */
#include <stdio.h>
#include <thread>
#include <deque>
#include <string>
#include <mutex>
#include <condition_variable>
#include <future>
@brimston3
brimston3 / gfshare_test.sh
Created September 13, 2017 20:39
shamir's secret sharing with libgfshare-bin
#!/bin/sh
##
# Briefly demonstrate splitting a key with libgfshare-bin
# This breaks the key into M parts, N of which are needed for key recovery.
rm -vf key key.[2345] gfkey.*
dd if=/dev/urandom of=key bs=4k count=1
echo
@brimston3
brimston3 / MQTTTransport_mbedTLS.cpp
Created September 12, 2017 15:08
paho.mqtt.embedded-c (C++) with mbedTLS example
/*******************************************************************************
* Copyright 2017 Andrew Domaszek
*
* All rights reserved.
* This program made available under BSD-new.
*******************************************************************************/
/**
* This example is designed for Linux, using such calls as setsockopt and gettimeofday.
* On embedded, it's likely that all of the mbedtls_net_* functions would need to be
@brimston3
brimston3 / has_rtti.cpp
Created September 12, 2017 14:34
use preprocessor to detect C++ RTTI flags
/*
* g++ has_rtti.cpp -o has_rtti && ./has_rtti
* g++ -fno-rtti has_rtti.cpp -o has_rtti && ./has_rtti
* clang++ has_rtti.cpp -o has_rtti && ./has_rtti
* clang++ -fno-rtti has_rtti.cpp -o has_rtti && ./has_rtti
* @TODO: add msc++ cli, /GR, /GR-
*
* Copyright 2017, Andrew Domaszek
* All rights reserved.
* Program made available under BSD-new license.
@brimston3
brimston3 / openssl_acme_cert_script_examples.sh
Created August 16, 2017 18:28
Some examples for extracting certificate information and tests for checking if a HTTPD reload is needed
#!/bin/sh
:<<"EOF"
openssl_acme_cert_script_examples.sh
CodeLibrary, server management
Inspecting acmetool generated certificates.
===========================================
This file contains some handy script examples for checking various details in
@brimston3
brimston3 / steam_chroot.sh
Last active November 9, 2020 17:35
debian buster steam chroot install script
#!/bin/sh
# Copyright 2017-07-21 Andrew Domaszek
# BSD-New license
# https://wiki.debian.org/chroot
# https://superuser.com/questions/616922/schroot-dont-share-home-directory
# install prereqs:
# apt-get install debootstrap schroot