Skip to content

Instantly share code, notes, and snippets.

View Metaxal's full-sized avatar

Laurent Orseau Metaxal

  • Google DeepMind
  • London, UK
View GitHub Profile
@Metaxal
Metaxal / show-highlighted.rkt
Created July 13, 2020 15:26
quickscript: simply displays the highlighted text "flashing" 5 times in a World-window in random colors
#lang racket/base
;;; From: https://github.com/Quickscript-Competiton/July2020entries/issues/9
;;; License: Apache 2/MIT
#|
My first submitted Racket Quickscript
(mostly a proof-of-concept, to try my hand at writing these)
@Metaxal
Metaxal / keymap.rkt
Created July 13, 2020 11:42
Reuse global keymap functions for a custom keymap
(define map-global-function
(let* ([km-global (keymap:get-global)]
[table (for/hash ([name (in-list (dict-values (send km-global get-map-function-table)))])
(values name #t))])
(λ (km key name)
(unless (dict-has-key? table name)
(error "Unknown function" name))
(send km add-function name
(λ (in ev)
(send km-global call-function name in ev #t)))
@Metaxal
Metaxal / letterfall.rkt
Last active July 11, 2020 10:16
Stare at your code falling like rocks!
#lang racket/base
;;; License: MIT/Apache2.0
;;;
;;; Stare at your code falling like rocks.
(require quickscript
framework/preferences ; to disable syncheck
racket/class
racket/string)
@Metaxal
Metaxal / quickscript-competition-2020-scripts.rkt
Last active July 10, 2020 07:18
A quickscript to install them all! (from the 2020 competition)
#lang racket/base
;; License: Apache2.0/MIT
(require quickscript
quickscript/base
quickscript/library
racket/gui/base
racket/class
racket/file
@Metaxal
Metaxal / raco-pkg-migrate.rkt
Last active November 12, 2021 14:35
When installing a new version of racket, run this script instead of just `raco pkg migrate <version-number-you-have-to-remember>`
#!/usr/bin/racket
#lang racket/base
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or
;;; [MIT license](http://opensource.org/licenses/MIT) at your option.
;; When installing a new version of Racket,
;; running this script setups all existing packages that had been installed
;; in the *user* scope.
;;
@Metaxal
Metaxal / all-tabs.rkt
Created May 2, 2020 13:58
Display a "All tabs" menu in DrRacket
#lang racket/base
(require racket/gui/base
racket/class
quickscript)
;;; The default 'Tabs' menu in DrRacket lists only the first 10 tabs.
;;; This script displays all tabs, which is particularly convenient when
;;; there are many tabs and not all of them are visible.
(define-script all-tabs
@Metaxal
Metaxal / classify-position-quickscript.rkt
Last active February 1, 2021 09:27
Quickscript script to try out classify-position
#lang racket/base
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or
;;; [MIT license](http://opensource.org/licenses/MIT) at your option.
(require quickscript
racket/format
racket/class)
;; Like classify position, but gives the class of the character at the insert position,
@Metaxal
Metaxal / with-limits-test.rkt
Created December 18, 2019 08:58
The limits of with-limits
#lang racket
(require racket/sandbox)
;; Make sure you have at least 4×max-memory available
;; otherwise your computer might freeze.
(define max-memory 1024)
(define a-tree #f)
;; with-limits should limit the memory use, but it fails in this case.
;; See below for an explanation.
@Metaxal
Metaxal / racket-logo-plot.rkt
Created September 2, 2019 12:50
Lambda logo with Racket's plot
#lang racket
(require plot)
(let ([blue '(0 0 164)] [red '(164 0 0)])
(parameterize ([plot-decorations? #f])
(plot3d
(list
(surface3d (λ(x y)(/ x 10)) 0 5 0 1 #:color red #:line-color red)
(surface3d (λ(x y)(- 1 (/ (+ 1 (exp (- 5 x)))))) 0 10 0 1 #:color blue #:line-color blue))
@Metaxal
Metaxal / hanoi.rkt
Created August 19, 2019 16:19
Towers of hanoi, breadth-first search
#lang racket
(require data/heap)
;;; Not the most optimized version.
(define N 12)
(define (hanoi N)
(define visited (make-hash))
(define heap (make-heap (λ(a b) (<= (first a) (first b)))))