Skip to content

Instantly share code, notes, and snippets.

View jeapostrophe's full-sized avatar
🍕

Jay McCarthy jeapostrophe

🍕
View GitHub Profile
(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))
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 (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))))
(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)))
@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")
@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,
#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 / 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
@jeapostrophe
jeapostrophe / test.ll
Created October 29, 2015 23:51
Vectorizing structure reads, writes, etc examples
; External declaration of the puts function
declare i32 @exit() nounwind
; float = 1, 2, 3, 4, 5, 6, 7, 8
; i16 = 2, 4, 6, 8, 10, 12, 13, 14, 15, 16
; i8 = 4, 8, 12, 16, 20, 24, 26, 28, 29, 30, 31, 32
%athing = type { float, float, float, float, float, float, i16, i16, i8, i8, i8, i8 }
@one = external global %athing
@two = external global %athing
#lang racket/base
(require (for-syntax racket/base
syntax/parse)
racket/splicing)
(begin-for-syntax
(define special-define-set
(make-parameter (box '())))
(define (add-to-boxed-list! b v)
(set-box! b (cons v (unbox b)))))