This file contains 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/gui | |
(define xmax 200) | |
(define ymax 200) | |
(define seconds-in-loop 3) | |
(define fr (new frame% [label ""])) | |
(define cv (new canvas% [parent fr] [min-width xmax] [min-height ymax])) | |
(define dc (send cv get-dc)) | |
(send fr show #t) |
This file contains 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 (planet shawnpresser/racket-unix-sockets) | |
"communicate.rkt") | |
(define-values (i o) | |
(unix-socket-connect socket-path)) | |
(communicate i o) |
This file contains 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 | |
(require racket/class | |
racket/list | |
racket/format | |
;racket/gui ;for message-box | |
) | |
(define non-word-str "\"'`,;\r\n\t (){}[]") | |
(define non-word-chars (string->list non-word-str)) | |
(define non-word-re (regexp-quote non-word-str)) |
This file contains 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/gui | |
(require framework) ; for keymap:get-editor | |
(define keymap (keymap:get-editor)) | |
#| ; Or define them yourself: | |
(define keymap (new keymap%)) | |
(add-text-keymap-functions keymap) |
This file contains 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/ |
This file contains 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 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 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 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 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)) |
OlderNewer