Skip to content

Instantly share code, notes, and snippets.

View jeremyd2019's full-sized avatar

jeremyd2019

View GitHub Profile
@jeremyd2019
jeremyd2019 / YubiKeyCryptSetup.md
Last active June 7, 2017 06:39
YubiKey cryptsetup

Write the object that tells OpenSC that we have 20 retired key slots to the YubiKey. Apparently this makes the OSX Keychain utility crap itself when it sees this, so watch out!

  echo -n C10114C20100FE00 | yubico-piv-tool -a write-object --id 0x5FC10C -i -

Generate a new private key, and require a touch on the device to use it.

  yubico-piv-tool -a generate -s 8e --touch-policy=always -o public.pem

OpenSC needs there to be a certificate in the slot to go with the private key, even though nobody is ever going to use it...

@jeremyd2019
jeremyd2019 / sync_bfi.h
Created September 20, 2018 05:15
Atomic bitfield insert for Cortex-M3
#ifndef SYNC_BFI_H_839745__
#define SYNC_BFI_H_839745__
#include <stdint.h>
__attribute__((always_inline)) static inline void sync_bitfield_insert(uint8_t * p, uint8_t v, int bitno)
{
uint8_t retval;
uint8_t tmp;
__asm__ volatile ("dmb ish\n"
"sbfi_%=:\n\t"
@jeremyd2019
jeremyd2019 / README.md
Last active November 1, 2018 23:51
OpenOCD config to flash stm32f103t8c6 from raspberry pi 3

Usage:

sudo /usr/local/bin/openocd -f ~/raspberrypi2-native.cfg -f ~/stm32f1x.cfg -c init -c 'reset halt' -c "stm32f1x unlock 0" -c reset -c exit
sudo /usr/local/bin/openocd -f ~/raspberrypi2-native.cfg -f ~/stm32f1x.cfg -c init -c 'reset halt' -c "program build/gnuk.elf verify reset" -c "reset halt" -c "stm32f1x lock 0" -c reset -c exit
@jeremyd2019
jeremyd2019 / evdev-calibrate.py
Created April 9, 2020 18:59
Python script to calibrate a joystick using the evdev interface
#!/usr/bin/python
import libevdev
import sys
def adjust_range(axis_min, axis_center, axis_max):
if ((axis_max - axis_min)//2 + axis_min) > axis_center:
axis_max = 2*axis_center - axis_min
else:
axis_min = 2*axis_center - axis_max
@jeremyd2019
jeremyd2019 / monitor-monitor.py
Last active July 17, 2020 20:33
Python script to fix up xrandr after Xfce4 messes it up trying to hotplug monitors
#!/usr/bin/python3
#
import sys, subprocess, time
import Xlib
from Xlib import X, display
from Xlib.protocol import rq
from Xlib.ext import randr
@jeremyd2019
jeremyd2019 / settings.json
Last active November 17, 2021 22:44
Windows Terminal settings
// vim: set filetype=jsonc :
// This file was initially generated by Windows Terminal 1.11.2921.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@jeremyd2019
jeremyd2019 / MSYS2-JIT-Debugging.md
Last active April 1, 2021 02:46
Just-in-time debugging in MSYS2

MSYS2 processes

To get just-in-time debugging of MSYS2 processes, use the error_start MSYS environment variable setting:

export MSYS="error_start:$(cygpath -w /usr/bin/gdb)"
./crashy.exe

Native Windows processes

@jeremyd2019
jeremyd2019 / build.sh
Last active June 29, 2021 18:10
Scripts to bootstrap a clang prefix
#!/bin/bash -x
declare -a pkgs
pkgs=(libmangle-git
tools-git
headers-git
crt-git
winpthreads-git
winstorecompat-git
ntldd-git
@jeremyd2019
jeremyd2019 / clang32-autobuild-notes.md
Last active September 2, 2021 01:36
notes from clang autobuild runs
  • openlibm (JuliaMath/openlibm#237)
    lld-link: error: undefined symbol: isinff
    >>> referenced by src/s_isinf.c.o
    
    lld-link: error: undefined symbol: __isinff
    >>> referenced by src/s_isinf.c.o
    
    lld-link: error: undefined symbol: isnanf
    >>> referenced by src/s_isnan.c.o
    
@jeremyd2019
jeremyd2019 / repoup.sh
Last active May 27, 2021 20:31
scripts for updating clangarm64 repos
#!/bin/bash
shopt -s nullglob extglob
cd packages
# work around github issue with ~ in file name (turns into .)
for a in *~*; do
mv "$a" "`tr '~' '.' <<<"$a"`"
done
for u in https://github.com/msys2/CLANG-packages/releases/download/bootstrap-stage3-clangarm64/clangarm64.{db,db.tar.xz,files,files.tar.xz}{,.sig}; do
curl -LO $u