Skip to content

Instantly share code, notes, and snippets.

View argdata.rkt
#lang racket
;; https://github.com/NuxiNL/argdata
(provide (all-defined-out))
;;---------------------------------------------------------------------------
;; Representing values
(struct timestamp (ns) #:transparent)
(struct fd (number) #:transparent)
View inf.py
from syndicate import relay, turn
from syndicate.during import During
import logging
@relay.service(name='inf', debug=True)
@During().add_handler
def main(args):
logging.info(f'in main {args}')
turn.on_stop(lambda: logging.info(f'args retracted {args}'))
@tonyg
tonyg / xml-infoset.prs
Created Jan 24, 2022
Sketch of a representation of XML infoset in Preserves Schema
View xml-infoset.prs
version 1 .
Node = Text / Element .
Text = string .
Element =
/ @withAttributes
<<rec> @localName symbol [@attributes Attributes @children Node ...]>
/ @withoutAttributes
<<rec> @localName symbol @children [Node ...]> .
Attributes = { symbol: string ...:... } .
View Semi-automatic Defunctionalization of Continuations.md

Semi-automatic Defunctionalization of Continuations

Tony Garnock-Jones. February 2016.

Abstract

Programmers use continuations to achieve all manner of interesting control effects (e.g. Shivers & Turon 2011). But common representations of continuations cause problems in practice in two ways. On one hand, continuations represented as functions are entirely opaque; the only available operation is to invoke the continuation. On the other hand, continuations represented as reified machine stacks expose too much information; irrelevant detail of the program's information becomes visible. In this paper, we present a design for a middle-ground. Using our new language construct, continuations are represented as censored reified machine stacks. Programmers precisely control the information and behavior associated with each frame in the continuation, allowing them the benefits of automatic continuation reification combined with the benefits of a defunctionalized representation of control as data.


View buckling.rkt
#lang racket
(require tabular)
;; A floor of original length x
;; that expands by n
;; but is constrained to fit in a space of length x
;; will buckle.
;;
;; Let's approximate by treating the resulting shape as an isosceles
@tonyg
tonyg / boring.rkt
Created Aug 26, 2021 — forked from samdphillips/boring.rkt
syndicate shutdown ...
View boring.rkt
#lang syndicate
(require racket/set)
(require/activate syndicate/drivers/external-event)
(provide shutdown!)
(define-logger top)
(define log-receiver
@tonyg
tonyg / dump-custodian.rkt
Created Jun 16, 2021
Printing out everything managed by a custodian
View dump-custodian.rkt
(on (message (dump-debug-info))
(local-require racket/exn)
(local-require racket/tcp)
(printf "------------------------------------------------------------\n")
(for [(index (in-naturals))
(item (custodian-managed-list (current-custodian) outer-custodian))]
(printf "\nItem ~a.\n~v\n" index item)
(cond
[(thread? item)
(printf "Thread: (dead? ~v)\n~a"
View interfaces.ts
// This Tuple type (and tuple() function) is a hack to induce
// TypeScript to infer tuple types rather than array types. (Source:
// https://github.com/microsoft/TypeScript/issues/27179#issuecomment-422606990)
//
// Without it, [123, 'hi', true] will often get the type (string |
// number | boolean)[] instead of [number, string, boolean].
//
export type Tuple = any[] | [any];
export const tuple = <A extends Tuple>(... args: A) => args;
@tonyg
tonyg / dmesg.txt
Created Sep 23, 2020
dmesg output of kernel crash on Samsung Galaxy S7 when accessing audio playback
View dmesg.txt
[ 58.675916] dhdpcie_resume_dev: Enter
[ 58.677482] dhdpcie_send_mb_data: H2D_MB_DATA: 0x00000010
[ 58.677734] dhdpcie_send_mb_data: send H2D_HOST_D0_INFORM to dongle
[ 58.678145] dhd_runtimepm_state : runtime resume ended
[ 59.037968] lpass_get_sync: i2s (use:1)
[ 59.040822] i2s_startup : pri --
[ 59.040853] i2s_startup : pri --
[ 59.040870] dma_open: prtd = ffffffc8743200c0
[ 59.040894] lucky-audio sound: lucky_aif_startup
[ 59.040910] lucky-audio sound: codec_dai: moon-aif1
@tonyg
tonyg / qnd_cbd.py
Created Sep 9, 2020
Quick-and-dirty plain-kernel-interface python modem boot and operation scripts for Samsung Galaxy S7
View qnd_cbd.py
#!/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