-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.rkt
28 lines (23 loc) · 828 Bytes
/
util.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#lang racket
(require scribble/base
scribble/core
(only-in srfi/1 cons*)
sha)
(provide graphviz ttt)
(define (ttt . lines)
(list (linebreak)
(map (lambda (x)
(list (tt x) (linebreak)))
(filter-not (compose char-whitespace?
(curryr string-ref 0))
lines))))
(define (graphviz . str)
(define filehash (bytes->hex-string (sha1 (string->bytes/locale (string-join str)))))
(define file (format "/tmp/rkttmp~a.png" filehash))
(unless (file-exists? file)
(define cmd (~a "printf \"" (string-replace (apply string-append str) "\""
"\\\"") "\" | dot -Tpng > " file))
(display cmd)
(newline)
(system cmd))
(image (~a file) #:scale 0.5))