Skip to content

Instantly share code, notes, and snippets.

https://umd.zoom.us/j/93087492464?pwd=bUU1OVJYbUtBRlN2UFNRVlQ1K1dpZz09
@dvanhorn
dvanhorn / explode.rkt
Last active December 19, 2021 13:42
Idiomatic explode
#lang racket
(require redex)
(current-cache-all? #t)
;; String -> (Listof 1String)
(define (explode s)
(car (apply-reduction-relation* split+join s)))
;; String -> Void
(define (show-explode s)
I am testifying today as a public witness to express my total dismay
at the prospect of the Council moving forward to confirm Mr. Lott as
Director of DDOT.
My daughter is a former kindergarten schoolmate of Allison Hart.
Allison was struck and killed while in a District crosswalk about six
weeks ago. I learned of her death at school drop-off by overhearing
one five year old explain to another ``someone in my class died
yesterday.''
@dvanhorn
dvanhorn / transcript.txt
Created February 6, 2021 18:17
macos linking hell
☞ # finds .dylib version first, but that's not the kind of linking we're doing
☞ # so barfs
☞ ld -lunistring -exported_symbol _uc_is_property_white_space -r -arch x86_64 -o runtime.o
ld: warning: /usr/local/lib/libunistring.dylib, ignoring unexpected dylib file
Undefined symbols for architecture x86_64:
"_uc_is_property_white_space", referenced from:
-exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
☞ # finds .a version because ain't no search, so it works, but ugh.
☞ ld /usr/local/lib/libunistring.a -exported_symbol _uc_is_property_white_space -r -arch x86_64 -o runtime.o
@dvanhorn
dvanhorn / call_f.s
Created January 26, 2021 02:23
mfftw
global frog
global duck
default rel
section .text
extern ptr_to_f
extern f
frog:
sub rsp, 8
lea rax, [rel f wrt ..plt]
call rax
global frog
global duck
default rel
section .text
extern ptr_to_f
extern f
frog:
sub rsp, 8
lea rax, [rel f wrt ..plt]
call rax
@dvanhorn
dvanhorn / linux_transcript.md
Last active January 25, 2021 22:17
problem running indirect function call via ffi

Here's a transcipt of something very similar that seems to result in an infinite loop on Linux. :(

dvanhorn@starburst:small $ cat f.c
int f() {
  return 42;
}

int (*ptr_to_f)() = f;
@dvanhorn
dvanhorn / f.c
Created January 20, 2021 03:54
can't link an external call in a shared library
int f () {
return 42;
}
@dvanhorn
dvanhorn / push.yml
Created January 5, 2021 20:29
GHA for Racket with scribble and deploy via rsync
on:
- push
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Install dependencies
@dvanhorn
dvanhorn / advent-05.rkt
Created December 5, 2020 22:33
Advent of Code, Day 5, Part II
#lang racket
(define in "...")
(define ss
(sort (for/list ([l (in-list (with-input-from-string in port->lines))])
(string->number
(string-append "#b"
(regexp-replaces l '(("F" "0")
("B" "1")
("L" "0")