Skip to content

Instantly share code, notes, and snippets.

@samdphillips
samdphillips / uuid.rkt
Created June 25, 2023 03:50
uuid in racket
#lang racket/base
(require (for-syntax racket/base
syntax/parse)
racket/stxparam
(only-in racket/format ~r)
(only-in racket/port
call-with-input-bytes
call-with-input-string
@samdphillips
samdphillips / python_codec_abuse.md
Last active June 18, 2023 20:28
Python Codec Abuse List

Python allows a codec directive at the start of a file which allows for a hook to rewrite the content.

Here are some uses I've found of this in the wild using this github query.

#lang racket
(define-logger workin)
(struct queue (fore aft))
(define (enqueue q w)
(match q
[(queue a d) (queue a (cons w d))]))
#lang rhombus/static/and_meta
import:
lib("racket/stream.rkt")
export:
Stream
meta:
namespace Stream:
#lang racket/base
(require mzlib/thread
racket/match
racket/port
racket/string
"mcast-channel.rkt")
(define-logger chat-server)
@samdphillips
samdphillips / mcast-channel.rkt
Created March 8, 2023 22:35
Multicast channels using IVars
#lang racket/base
;; uses https://github.com/samdphillips/racket-syncvar
(require racket/contract
racket/match
"ivar.rkt")
(provide mcast-channel?
mcast-output?
@samdphillips
samdphillips / supervisor.rkt
Created January 17, 2023 23:41
Simple thread supervisor
#lang racket/base
(require racket/exn
racket/set
"util.rkt")
(provide supervise)
(define-logger supervise)
@samdphillips
samdphillips / aa-shapes.rhm
Last active November 11, 2022 03:25
Rhombus with class
#lang rhombus
import:
racket/base
racket/math:
expose:
pi
operator (m ** n):
~stronger_than: *
@samdphillips
samdphillips / example-doc.rkt
Created November 9, 2022 22:16
Scribble pre-processing for Commonmark
#lang cmark-scribble
# This is a test document
1 + 1 is **@+[1 1]**
@samdphillips
samdphillips / deploy-and-restart.rkt
Created November 6, 2022 20:25
Some Racket "shell" scripts
#!/usr/bin/env racket
#lang rkshell
(require racket/date
"service.rkt"
"ssh.rkt")
(define-logger deploy)
(date-display-format 'iso-8601)