Skip to content

Instantly share code, notes, and snippets.

#lang racket/base
(require racket/match)
(define-logger ytdl)
(struct ytdl (thread req-ch rsp-ch))
(define (make-ytdl vid dir)
(define args (list "--no-color" "-f" "bestaudio" "-w" "-o" (format "~a/vid.%(ext)s" dir) vid))
#lang racket/base
(require syncvar/mvar)
(provide make-barrier
barrier-wait-evt
barrier-wait
log-barrier-info)
(define-logger barrier)
#lang racket
(require racket/draw)
(define (mandelbrot1 z c)
(+ (* z z) c))
(define (escaped? z)
(<= 2 (magnitude z)))
@samdphillips
samdphillips / manager.rkt
Created October 9, 2022 21:05
places work channel sharing
#lang racket/base
(require racket/place)
(define-logger guess)
(define num-workers (processor-count))
(define secret-number (random 10))
(define-values (manager-work-ch worker-work-ch) (place-channel))
#!/usr/bin/env racket
#lang racket
(require lens
net/http-easy
qi
racket/date
syntax/parse/define)
(current-print
@samdphillips
samdphillips / ivar.rkt
Created August 19, 2022 18:09
One shot synchronizable variables.
#lang racket/base
(require racket/contract
racket/undefined)
(provide ivar?
exn:fail:ivar?
make-ivar
(contract-out
[ivar-put! (-> ivar? any/c any)]
@samdphillips
samdphillips / waiter.rkt
Last active July 27, 2022 23:00
One-shot type condition variable
#lang racket/base
(require racket/async-channel
racket/function)
(struct waiter (thd req-ch notify-ch))
(define (make-waiter)
(define req-ch (make-channel))
(define notify-ch (make-channel))
@samdphillips
samdphillips / static-exception-checking.rkt
Created April 12, 2022 01:07
not even close to being a full handling for checked exceptions
#lang racket/base
(require (for-syntax racket/base
racket/format
syntax/parse/lib/function-header)
(rename-in racket/base [raise base:raise])
racket/stxparam
syntax/parse/define)
(begin-for-syntax
#lang racket/base
(define (apples a-string)
(define string-size (string-length a-string))
(define (once current count i)
(cond
[(= i string-size)
(if current
(list (cons current count))
null)]
@samdphillips
samdphillips / holder.rkt
Created April 1, 2022 20:42
threaded box thingy
#lang racket/base
(require racket/match)
(struct holder (thd req-ch))
(define (make-holder initial-value)
(define req-ch (make-channel))
(define thd
(thread