This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax racket/base | |
syntax/parse) | |
racket/list | |
racket/match) | |
;; Related post: http://jeapostrophe.github.io/2013-11-12-condd-post.html | |
(define (f-condd4 l) | |
(condd4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require measures) | |
(define-syntax-rule (define-units-contract name m1) | |
(define name | |
(make-flat-contract | |
#:name 'name | |
#:first-order | |
(λ(m2)(measure-units-equal? m1 m2))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang slideshow | |
(require bazaar/slideshow/slideshow-tree) | |
(define t1 '(a (b1 (c1 d1 d2) | |
(c2 d3 d4)) | |
(b2 (c3 d5) | |
c4))) | |
(draw-tree-top-left-right | |
(tree-map t1 (λ(x)(t (symbol->string x)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require framework | |
racket/gui/base) | |
(provide theme->frame) | |
; Call (theme->frame) to open a frame with the current style as an info.rkt file | |
(color-prefs:register-info-based-color-schemes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
; One way to define a logger | |
(define lg (make-logger 'my-logger)) | |
; Define a receiver for this logger, along with a log level | |
(define rc (make-log-receiver lg 'error)) ; also try with 'debug | |
; Another way to define a logger, with additional forms | |
(define-logger lg2) | |
(define rc2 (make-log-receiver lg2-logger 'debug)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is not really a script and should be run line by line instead. | |
# With the admin user, do the following. | |
# Install Optware (ipkg) | |
# and configure the admin's path. | |
# http://wiki.qnap.com/wiki/Install_Optware_IPKG | |
# Install correct versions of basic tools, | |
# otherwise the following will not work. | |
ipkg install coreutils make find grep sed gawk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax syntax/parse)) | |
;;; Allow every argument to be passed by-name or by-position in a procedure call. | |
;;; Keywords do not need to apper in procedure headers in definitions. | |
;;; Accepts rest and keyword-rest arguments. | |
;;; A new definition of instantiate is also given to resemble this procedure call style. | |
;;; Resources: | |
;;; - http://www.mail-archive.com/[email protected]/msg08846.html | |
;;; - https://gist.github.com/Metaxal/5851215 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax syntax/parse | |
racket/syntax)) | |
;;; Recognizes super-id and keyword arguments of struct. | |
;;; Caveats: | |
;;; - does not recognize per-field options (like per-field mutability). | |
;;; - the hash table uses the symbol of the super-id, but should use the binding instead. | |
;;; - may not work if the default expr depends on bindings not available in the context of the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax syntax/parse)) | |
(define-syntax (and/def stx) | |
(syntax-parse stx | |
#:literals (define define-values) | |
[(_) #'#t] | |
[(_ [define-values (var:id ...) val:expr] rest ...) | |
#'(let-values ([(var ...) val]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/sandbox) | |
#| | |
Self-link: http://gist.github.com/Metaxal/5723825 | |
Original idea by Eliezer Yudkowski and Alex Mennen: | |
http://lesswrong.com/lw/7f2/prisoners_dilemma_tournament_results/4ru9 | |
http://lesswrong.com/lw/hmx/prisoners_dilemma_with_visible_source_code/ |