Skip to content

Instantly share code, notes, and snippets.

View mutability's full-sized avatar

Oliver Jowett mutability

View GitHub Profile
@mutability
mutability / fx3-timer-patch.diff
Last active January 9, 2020 13:02
Measure Cypress FX3 timer tick period / errors
diff -ur fx3_sdk_1_3_4_src/sdk/firmware/src/system/cyu3vic.c fx3_sdk_1_3_4_src.patched/sdk/firmware/src/system/cyu3vic.c
--- fx3_sdk_1_3_4_src/sdk/firmware/src/system/cyu3vic.c 2017-11-24 09:45:52.000000000 +0800
+++ fx3_sdk_1_3_4_src.patched/sdk/firmware/src/system/cyu3vic.c 2020-01-09 16:46:45.146468433 +0800
@@ -34,12 +34,18 @@
#define CY_U3P_WDT1_DISABLE_MASK (CY_U3P_GCTL_MODE1_MASK)
#define CY_U3P_WDT1_MODE_INTR_MASK (1 << CY_U3P_GCTL_MODE1_POS)
-/* Assuming timer clock frequency as 32KHz */
-#define CY_U3P_OS_TIMER_TICK_OFFSET (7)
-#define CY_U3P_OS_TIMER_TICK_COUNT (32)
@mutability
mutability / flightaware-root.cert.pem
Last active April 30, 2017 22:39
(mostly) standalone tcltls tester
-----BEGIN CERTIFICATE-----
MIIF0jCCA7qgAwIBAgIJAKn+dW2ea5S0MA0GCSqGSIb3DQEBCwUAMHYxCzAJBgNV
BAYTAlVTMQswCQYDVQQIDAJUWDEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwP
RmxpZ2h0QXdhcmUgTExDMRMwEQYDVQQLDApPcGVyYXRpb25zMRkwFwYDVQQDDBBG
bGlnaHRBd2FyZSBSb290MB4XDTE1MTIwOTE2NTAwNFoXDTM1MTIwNDE2NTAwNFow
djELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAlRYMRAwDgYDVQQHDAdIb3VzdG9uMRgw
FgYDVQQKDA9GbGlnaHRBd2FyZSBMTEMxEzARBgNVBAsMCk9wZXJhdGlvbnMxGTAX
BgNVBAMMEEZsaWdodEF3YXJlIFJvb3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw
ggIKAoICAQDTlR/hn6y+RqUVZnRxc9Wp0mQaYJpXEDBAzAVUipXdertL1c0mYqda
22J9E0ubZS5nqYXhj9/YHN0G8fP9LmTjzB4mxH0TZCRTglNCsQDzKLuxnt1ynHCl
// g++ -Wall -O -o sdlgpu-test $(pkg-config SDL2_gpu --cflags) $(sdl2-config --cflags) sdlgpu-test.cc $(pkg-config SDL2_gpu --libs) $(sdl2-config --libs)
#include <SDL_gpu.h>
int main(int argc, char* argv[])
{
GPU_SetDebugLevel(GPU_DEBUG_LEVEL_MAX);
GPU_Target* screen = GPU_Init(400, 300, GPU_DEFAULT_INIT_FLAGS);
if (!screen)
@mutability
mutability / damage_analysis.py
Last active May 26, 2019 19:59
cdda ranged damage simulation
#!/usr/bin/env python3
import math, sys
from contextlib import closing
def normal_cdf(x, mu, sigma):
return 0.5 * (1 + math.erf((x - mu) / (sigma * math.sqrt(2))))
def rng_normal_cdf(x, hi):
mu = hi / 2.0
@mutability
mutability / adepttest.tcl
Created August 2, 2016 17:29
quick adept client tester
#!/usr/bin/env tclsh8.6
package require tls
proc testit {host port} {
puts "connecting to $host $port"
set sock [tls::socket -cipher ALL \
-ssl2 0 \
-ssl3 0 \
-tls1 1 \
@mutability
mutability / OVERLAYFS
Last active August 10, 2024 02:39
readonly root via overlayfs
- install the two shellscripts into the appropriate places under /etc/initramfs-tools
- run update-initramfs
- put "overlay=yes" on the kernel command line
- reboot
With the overlay in place, the real root is mounted readonly on /ro.
Only the root fs is changed, other filesystems are mounted normally.
Remove "overlay=yes" (or change it to something other than yes) and reboot to go back to readwrite.
(This probably means that you want the commandline config to live somewhere other than on the root fs, e.g. under /boot)
@mutability
mutability / produce.tcl
Last active August 29, 2015 14:26
try to provoke delivery reports from kafkatcl
package require kafka
proc the_delivery_callback {message} {
puts stderr "delivery callback: $message"
set ::die 1
}
proc the_error_callback {message} {
puts stderr "error callback: $message"
set ::die 1