Skip to content

Instantly share code, notes, and snippets.

View deeglaze's full-sized avatar

Dionna Amalie Glaze deeglaze

View GitHub Profile
@deeglaze
deeglaze / bug-but-not.rkt
Created September 2, 2013 23:48
A small presentation of the generics scoping weirdness, but doesn't exhibit the bug.
#lang racket/load
(module A racket
(provide gen:foo (rename-out [*a a]))
(define *a #t)
(define a #f)
(define-syntax gen:foo (list #'a)))
(module B racket
(require 'A) (provide ga)
(define-syntax (bar stx)
@deeglaze
deeglaze / annulus.rkt
Created September 20, 2013 20:05
A library-grade annulus drawing function.
#lang racket
(require racket/draw pict)
(define (nonneg-real? x) (and (real? x) (>= x 0)))
(define style/c
(one-of/c 'transparent 'solid 'xor 'hilite
'dot 'long-dash 'short-dash 'dot-dash
'xor-dot 'xor-long-dash 'xor-short-dash
'xor-dot-dash))
(define (within-width-and-height w h)
(make-contract #:name (format "within width and height ~a ~a" w h)
@deeglaze
deeglaze / mini-church.sch
Last active December 29, 2015 11:58
Minimal language CFA problem. Unary untyped lambda calculus. Can you get this is always true?
;; multiplication distributes over addition test: (2 * (1 + 3)) = ((2 * 1) + (2 * 3))
((lambda (plus)
((lambda (mult)
((lambda (pred)
((lambda (sub)
((lambda (church0)
((lambda (church1)
((lambda (church2)
((lambda (church3)
((lambda (true)
@deeglaze
deeglaze / define-struct-comment.rkt
Created July 15, 2014 20:11
probably won't happen (?)
#lang racket
(require (for-syntax racket/struct-info))
(define-values (s:p mkp recp refp setp)
(make-struct-type 'parent #f 1 0 #f))
(define-values (s:c mkc recc refc setc)
(make-struct-type 'child s:p 1 0 #f))
(define (refc0 c) (refc c 0))
(define-syntax P 'gotcha!)
(define-syntax C
(make-struct-info (λ ()
@deeglaze
deeglaze / gist:40ec1ee101ee7f316180
Created July 17, 2014 19:16
This destroys abstract garbage collection.
(define (flatten x)
(cond
((pair? x)
(append (flatten (car x)) (flatten (cdr x))))
((null? x) x)
(else (list x))))
(flatten '((1 2) (((3 4 5)))))
@deeglaze
deeglaze / op-struct.rkt
Created July 29, 2014 22:04
structs with optional representation
#lang racket
(require (for-syntax racket/syntax
syntax/parse
racket/list
syntax/id-table
racket/match
syntax/struct
racket/struct-info))
(provide mk-op-struct)
@deeglaze
deeglaze / standard-cat.rkt
Last active July 20, 2019 14:11
working out the definition of Racket's to-be standard-cat
#lang racket
(require pict/color)
(provide
(contract-out
[cat-silhouette
(->i ([width positive?] [height positive?])
(#:left-ear-extent [left-ear-extent (>=/c 0)]
#:left-ear-arc [left-ear-arc (real-in 0 (* 2 pi))]
#:left-ear-angle [left-ear-angle (real-in 0 (* 2 pi))]
@deeglaze
deeglaze / standard-dog.rkt
Last active October 16, 2017 03:46
working out the math for standard-dog
#lang racket
(require pict racket/draw)
;; Not exported by pict/private/utils.rkt
(define (draw-shape/border w h draw-fun
color [border-color #f] [border-width #f]
#:draw-border? [draw-border? #t]
#:transparent? [transparent? #f])
(dc (λ (dc dx dy)
(define old-brush (send dc get-brush))
@deeglaze
deeglaze / Keybase proof
Created April 26, 2019 22:28
Keybase proof
### Keybase proof
I hereby claim:
* I am deeglaze on github.
* I am deeglaze (https://keybase.io/deeglaze) on keybase.
* I have a public key ASBRdo0rzlQWKjZkWSr39Saz0sooRmEU9KOVfkgmLAwGrgo
To claim this, I am signing this object:
@deeglaze
deeglaze / repro.sh
Created October 23, 2019 23:58
Reproduces a label_flag bug in bazel
#!/bin/bash
function executable() {
local name="$1"
cat > "${name}.cc" <<EOF
#include <cstdlib>
#include <iostream>
int main(int argc, char *argv[]) {
std::cout << "${name}\n";