Skip to content

Instantly share code, notes, and snippets.

@rgov
rgov / CMakeLists.txt
Created March 19, 2019 00:56
Build sigrok using a CMake parent project
cmake_minimum_required(VERSION 3.12)
project(sigrok)
set(REPO_BASE "git://sigrok.org")
# Add keg-only Homebrew formulae to the pkg-config search path
string(REPLACE ":" ";" PKG_CONFIG_PATHS "$ENV{PKG_CONFIG_PATH}")
foreach(FORMULA libffi python@2 python@3 qt)
execute_process(
COMMAND brew --prefix "${FORMULA}"
# Redefine add_test to set the LLVM_PROFILE_FILE environment variable
# on each test
function(add_test)
_add_test(${ARGN})
# There are two signatures to the add_test function to handle
if(ARGV0 STREQUAL "NAME")
set(TEST_NAME "${ARGV1}")
else()
set(TEST_NAME "${ARGV0}")
# I was playing around with trying to correctly set the TSAN_OPTIONS
# environment variable on a test, without hosing any other environment
# variables that might be set on it.
#
# CAVEAT EMPTOR: I DON'T THINK THIS WORKS YET
function(test_tsan_option OPTION)
get_test_property(test ENVIRONMENT TEST_ENV)
set(TSAN_OPTIONS "")
#!/usr/bin/env python
'''
This script finds CMakeLists.txt files and patches them so that each test
explicitly declares what it depends on.
'''
import os
import re
import sys
#!/usr/bin/env python
'''
This script patches a CMake script to add a check before every macro and
function definition to make sure that an existing definition is not being
replaced.
'''
import sys
from cmakeast import ast
@rgov
rgov / tpl5110.py
Last active January 31, 2019 22:28
Compute time interval/resistance correlation for the TPL5110 system timer
#!/usr/bin/env python
'''
The TPL5110's time interval is configured by the applying resistance between the
DELAY pin and GND. The correspondance between time interval and resistance is
given starting on page 12 of this document:
http://www.ti.com/lit/ds/symlink/tpl5110.pdf
The documentation contains lookup tables for common intervals between 100ms to
2h. This script can also be used to calculate values between 1s and 2h.
@rgov
rgov / telnet_transfer.py
Created January 19, 2019 01:33
File transfer-over-Telnet. For when you have no other option.
#!/usr/bin/env python
'''
File transfer-over-Telnet. For when you have no other option.
There are probably better ways to do this.
This expects the server to drop you into a shell immediately upon connection.
It also expects the `openssl` tool to be available.
The file is transferred in small Base64-encoded chunks. After each chunk, a
# I spent a while adding a step to a CircleCI config that installed a more recent
# version of QEMU on an Ubuntu 14.04 VM. I ended up not needing it, but I didn't
# want to lose it in case it was useful for some reason.
#
# This builds and installs the qemu-aarch64-static tool and configures binfmt to
# support ELF files for ARM64.
- run:
name: Build QEMU
command: >-
'''
I was playing around with dynamically compiling and loading protobuf files. This kind of works,
so I wanted to save it for later.
I guess what I would want it to do is create a container object representing the message and enum
descriptors that allows you to access them as normal attributes.
Alternatively you can have protoc output a .py file and then fuss around with importlib to load it.
'''
#!/usr/bin/env python
'''
These are some helper routines I wrote for drawing images for a dual-color
128x64 OLED display. The display has a 16-row strip of cyan pixels along the
top, followed by an unaddressable strip of black which is 2 pixels in height,
then the remaining 48 rows are yellow.
https://www.amazon.com/gp/product/B00O2LLT30/
To make it easier to keep drawings in the correct aspect ratio, I preferred to