Skip to content

Instantly share code, notes, and snippets.

#lang rhombus/static/and_meta
import:
draw
pict open
space.enforest path:
space_path p/path
macro_definer macro
meta_namespace path_meta:
@samdphillips
samdphillips / nowrap.rkt
Created October 26, 2025 06:06
Why won't this wrap the text?
#lang racket/base
(require embedded-gui
framework
racket/class
racket/gui)
(define lorem #<<TEXT
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu metus non sem dapibus interdum. Nunc accumsan porttitor leo, a posuere dolor luctus quis. Suspendisse potenti. Morbi mattis nibh quis sem placerat, nec eleifend sem venenatis. Donec blandit ac velit a vulputate. Integer ex mauris, eleifend a velit quis, pharetra dictum risus. Phasellus imperdiet nunc ut metus blandit sagittis. Suspendisse potenti. Nam in ultricies leo. Fusce non euismod risus. Morbi iaculis erat vel massa aliquet, in ultricies lacus condimentum. Nullam placerat quam leo, faucibus interdum tellus aliquet sit amet. Curabitur ut vestibulum mauris. Donec posuere mi at eros egestas tristique. Nullam non mauris a eros finibus aliquam dapibus eu quam. Duis id lacus odio.
@samdphillips
samdphillips / Dockerfile.program
Last active September 9, 2025 00:18
Some Racket Dockerfiles
# Long running server program
FROM --platform=linux/amd64 racket/racket:8.6-full AS build
# ARGs for catalog urls so we don't need to repeat them
ARG RELEASE_CATALOG=https://download.racket-lang.org/releases/8.6/catalog/
ARG RACKSNAPS_CATALOG=https://racksnaps.defn.io/snapshots/2022/08/25/catalog/
ARG SP_CATALOG=https://samdphillips.github.io/package-catalog/catalog/
WORKDIR /src/ct-truck
RUN raco pkg config --set catalogs ${RELEASE_CATALOG} ${RACKSNAPS_CATALOG} ${SP_CATALOG}
@samdphillips
samdphillips / funcall.md
Created February 4, 2025 19:08
Scheme to C function translation

Fixed Arity Definition

(define (foo x) body ...)

==>

SCM foo(int nr, SCM k, SCM x)
{
  if (nr != 1) arity_error();
@samdphillips
samdphillips / select_demo2.rhm
Created December 12, 2024 23:41
Rhombus events
#lang rhombus/static/and_meta
import:
lib("racket/base.rkt") as rkt:
rename:
#{evt?} as is_evt
#{always-evt} as always_evt
#{alarm-evt} as alarm_evt
#{guard-evt} as guard_evt
#{handle-evt} as handle_evt
@samdphillips
samdphillips / json.patch
Created December 12, 2024 23:38
Racket JSON customization
--- racket/collects/json/main.rkt 2024-11-05 16:35:40
+++ racket/collects/json/exp.rkt 2024-12-12 07:43:11
@@ -65,12 +65,16 @@
any)] ;; jsexpr?
))
+(module* for-extension #f
+ (provide read-json*))
+
;; -----------------------------------------------------------------------------
@samdphillips
samdphillips / json.rhm
Created November 15, 2024 02:47
Rhombus JSON POC
#lang rhombus/static/and_meta
import:
lib("racket/base.rkt"):
only: #{bytes-convert}
#{bytes-open-converter}
#{object-name}
#{port-counts-lines?}
#{port-next-location}
@samdphillips
samdphillips / kw.rkt
Created September 1, 2024 03:51
Keyword bridge for R6RS
#lang racket/base
;; install in a kw-example collect
(require (for-syntax racket/base
racket/string
syntax/parse)
racket/format
syntax/parse/define)
@samdphillips
samdphillips / evdev.rkt
Created December 8, 2023 03:39
Simple Racket library to interact with Linux input event devices
#lang racket/base
(require ffi/unsafe
ffi/unsafe/custodian
ffi/unsafe/define
ffi/unsafe/schedule
racket/struct)
(provide evdev-open
evdev-read
(define (poll-evt poll-thunk
#:interval [interval-thunk (const 1000)]
#:cleanup [cleanup-thunk void])
(poll-guard-evt
(lambda (polling?)
(if polling?
(cond [(poll-thunk) =>
(lambda (v)
(wrap-evt always-evt (const v)))]
[else never-evt])