Skip to content

Instantly share code, notes, and snippets.

Avatar

Lulu Cathrinus Grimalkin erkin

View GitHub Profile
@erkin
erkin / csexp.rkt
Last active Jul 2, 2021
Crude canonical S-expression parser
View csexp.rkt
#lang racket/base
(define (read-csexp (in (current-input-port)))
(letrec ((left-paren (char->integer #\())
(right-paren (char->integer #\)))
(colon (char->integer #\:))
(zero (char->integer #\0))
(nine (char->integer #\9))
(byte-list->number
(λ (byte-list)
@erkin
erkin / little-macros.ss
Last active Apr 7, 2021
Useful Scheme macros I keep rewriting for every project
View little-macros.ss
(define-syntax define-syntax-rule
(syntax-rules ()
((_ (name args ...) body)
(define-syntax name
(syntax-rules ()
((name args ...) body))))))
(define-syntax-rule (do-times n . body)
(do ((i n (sub1 i)))
((< i 1))
@erkin
erkin / sudoku.rkt
Created Dec 11, 2020
Nondeterministic sudoku solver
View sudoku.rkt
#lang racket
(module amb racket/base
(provide amb assert!)
(define-syntax-rule (pop! stack)
(begin0 (car stack) (set! stack (cdr stack))))
(define-syntax-rule (push! v stack)
(set! stack (cons v stack)))
(define (U f) (f f))
@erkin
erkin / regexp-checker.rkt
Created Oct 30, 2020
A graphical regular expression checker in plain Racket, supports PCRE
View regexp-checker.rkt
#lang racket/base
(require racket/gui/base
racket/class
racket/list
racket/string)
(define program-name "regexp-checker")
(define program-version "v0.1")
(define version-message
@erkin
erkin / get-pass.ss
Last active Oct 5, 2020
getpass in Chez Scheme
View get-pass.ss
;;; Chez Scheme clone of Python `getpass'
;;; Based on github.com/smitchell556/get-pass
(library (get-pass)
(export get-pass)
(import (chezscheme))
;;; FFI portion
;;; See termios(3) for more info
(define-ftype termios
(struct
@erkin
erkin / webhook.rkt
Last active Jul 22, 2020
Minimal Discord webhook client (text-only)
View webhook.rkt
#lang racket/base
(require net/http-client json)
(define webhook-id "foo")
(define webhook-token "bar")
(module+ main
(http-conn-send!
(http-conn-open "discord.com" #:ssl? #t)
(string-append "/api/webhooks/" webhook-id "/" webhook-token)
@erkin
erkin / docker-compose.yaml
Created May 29, 2020
SchemeBBS with Varnish
View docker-compose.yaml
version: "3.3"
services:
bbs:
image: erkin/schemebbs
container_name: sbbs
ports:
- '8080'
volumes:
- ${SBBS_DATADIR}:/opt/schemebbs/data
proxy:
@erkin
erkin / docker-compose.yaml
Created May 29, 2020
SchemeBBS with Traefik
View docker-compose.yaml
version: "3.3"
services:
bbs:
image: erkin/schemebbs
container_name: sbbs
labels:
- "traefik.enable=true"
- "traefik.http.services.bbs.loadbalancer.server.port=80"
- "traefik.http.routers.bbs.rule=Host(`example-bbs.org`)"
- "traefik.http.routers.bbs.entrypoints=websecure"
@erkin
erkin / pure-mlang.rkt
Created Jan 9, 2020
`racket/base` sans mutative procedures
View pure-mlang.rkt
#lang racket/base
(provide
(except-out
(all-from-out racket/base)
set!
set!-values
box-cas!
bytes-copy!
bytes-fill!
bytes-set!
@erkin
erkin / pride.rkt
Last active Dec 6, 2019
Print pride flags to your terminal
View pride.rkt
#lang racket ; -*- racket -*-
(define gay
'((228 003 003) ; red
(255 140 000) ; orange
(255 237 000) ; yellow
(000 128 038) ; green
(000 077 255) ; blue
(117 007 135) ; purple
))