Skip to content

Instantly share code, notes, and snippets.

View jeapostrophe's full-sized avatar
🍕

Jay McCarthy jeapostrophe

🍕
View GitHub Profile
@jeapostrophe
jeapostrophe / ab.log
Created April 28, 2015 10:52
Responding to requests concurrently in the Racket Web server
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software: Racket
Server Hostname: localhost
Server Port: 9000
#lang racket/base
(require (for-syntax racket/base
racket/list)
rackunit)
(let ()
(define-syntax (123-list stx)
(define middle-x-stx (second (syntax->list stx)))
(define x-id (syntax-e middle-x-stx))
(define new-ctxt-stx (datum->syntax #f 'new-ctxt))
@jeapostrophe
jeapostrophe / explore.rkt
Created July 5, 2012 03:00 — forked from jadudm/explore.rkt
Exploration of the PLT web server...
#lang racket/base
;; Each library function is prefixed by the module it came from.
(require web-server/dispatch)
(define-values (dispatch blog-url)
(dispatch-rules
[("go") go]))
;; dispatch-rules patterns cover the entire URL, not just the prefix,
@jeapostrophe
jeapostrophe / fac.rkt
Created March 8, 2012 20:25
Test collecting macro
#lang racket
(define (! n)
(if (zero? n)
1
(* n (! (sub1 n)))))
(module* test-manual #f
(require rackunit)
(printf "Factorial testing (manual)!\n")
(define (apply-reduction-relation/generator red t visited?)
(generator
()
(let loop ([t t])
(unless (visited? t)
(let ([tps (apply-reduction-relation red t)])
(if (empty? tps)
(yield t)
(for-each loop tps)))))
(yield #f)))
(define (list-ref/random l)
(list-ref l (random (length l))))
(define (apply-reduction-relation/random red t)
(define tps (apply-reduction-relation red t))
(if (empty? tps)
t
(apply-reduction-relation/random red (list-ref/random tps))))
source ~/.profile
hash -d ws=$PLTHOME/collects/web-server
hash -d drdr=$PLTHOME/collects/meta/drdr
hash -d work=$PROJS
hash -d papers=$PROJS/papers
hash -d planet=$SVNROOT/github.jeapostrophe.planet
setopt autopushd pushdminus pushdsilent pushdtohome
(define-syntax-rule (code/size s c ...)
(parameterize ([current-font-size s])
(code c ...)))
(define opt-code
(code/size
20
(define y 5)
(define (g z)
(+ z 3))