Skip to content

Instantly share code, notes, and snippets.

@tonyg
tonyg / possible-patch-for-swpal-and-casal.patch
Last active April 19, 2024 14:19
Weird issue with Guile 3.0.9's `atomic-box-swap!`
diff --git a/libguile/lightening/lightening/aarch64-cpu.c b/libguile/lightening/lightening/aarch64-cpu.c
index 13aa351e9..a47900b7c 100644
--- a/libguile/lightening/lightening/aarch64-cpu.c
+++ b/libguile/lightening/lightening/aarch64-cpu.c
@@ -225,6 +225,8 @@ oxxrs(jit_state_t *_jit, int32_t Op,
#define A64_STLR 0xc89ffc00
#define A64_LDAXR 0xc85ffc00
#define A64_STLXR 0xc800fc00
+#define A64_SWPAL 0xf8e08000
+#define A64_CASAL 0xc8e0fc00
@tonyg
tonyg / 2d.rkt
Last active April 8, 2024 03:41
Playing with OpenGL in Racket
#lang send-exp racket/gui
(require sgl/gl)
(require sgl/gl-vectors)
(require pict)
(define texture%
(class object%
(init [(initial-bitmap bitmap)])
(field [width 0]
@tonyg
tonyg / monad.rkt
Last active March 30, 2024 09:05
Monads in Racket
#lang racket/base
;; Monads in Racket, including polymorphic bind, return and fail.
;; Haskell-like do-notation.
(provide define-monad-class
(struct-out monad-class)
monad?
gen:monad
monad->monad-class
determine-monad
;;; markdown-join.el --- Join markdown tables based on cell contents -*- lexical-binding: t; -*-
;; Copyright (C) 2023 Tony Garnock-Jones
;; Author: Tony Garnock-Jones <tonyg@leastfixedpoint.com>
;; Keywords: data, convenience, matching
;; Version: 0.0.1
;; Package-Requires: ((markdown-mode "2.6") (emacs "25.1"))
;; Homepage: https://gist.github.com/tonyg/c951be93656b45027ed7d15e79f07c01
@tonyg
tonyg / Makefile
Last active July 10, 2023 19:14
Exploring uxn
%.run: %.rom
uxncli $<
%.debug: %.rom
uxnemu ~/build/uxn11/beetbug/bin/beetbug.rom $<
%.rom: %.tal
uxnasm $< $@
@tonyg
tonyg / diff.py
Last active December 15, 2022 04:48
Myers-Ukkonen diff in 39 lines of python
# Copyright (c) 2015 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
@tonyg
tonyg / mainline-dht-singlefile-nologging.rkt
Last active July 19, 2022 13:47
Mainline BitTorrent DHT (Kademlia) implementation in Syndicate/rkt
#lang syndicate
;;;; # Mainline BitTorrent DHT implementation in 297 SLOC
;;;;
;;;; [Syndicate](http://syndicate-lang.org/) is a new, actor-style
;;;; approach to concurrency. Syndicate programs exchange state and
;;;; messages within *conversational contexts*.
;;;;
;;;; This program demonstrates Syndicate programming by implementing
;;;; the Mainline BitTorrent Distributed Hash-Table.
;;;;
#lang racket
;; https://github.com/NuxiNL/argdata
(provide (all-defined-out))
;;---------------------------------------------------------------------------
;; Representing values
(struct timestamp (ns) #:transparent)
(struct fd (number) #:transparent)
@tonyg
tonyg / MediaPlayer2-cmd
Created June 27, 2016 18:01
Use DBus to control whichever DBus-compatible media player happens to be running.
#!/bin/bash
if [ -z "$1" ]
then
echo "Usage: MediaPlayer2-cmd { PlayPause | Next | Previous | Stop | ... }"
exit 1
fi
tried_starting_something=false
@tonyg
tonyg / qnd_cbd.py
Created September 9, 2020 21:06
Quick-and-dirty plain-kernel-interface python modem boot and operation scripts for Samsung Galaxy S7
#!/usr/bin/env python3
# Per cbd, "SS310 modem", "shannon310". This is a Samsung Galaxy S7 SM-G930F.
# ["/sbin/cbd", "-d", "-tss310", "-bm", "-mm", "-P", "platform/155a0000.ufs/by-name/RADIO"]
boot0_path = '/dev/umts_boot0'
firmware_partition = '/dev/disk/by-partlabel/RADIO' ## maps to /dev/sda8 on my phone
nv_data_path = '/efs/nv_data.bin' ## mount /dev/disk/by-partlabel/EFS (/dev/sda3 for me) on /efs
import cffi