Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurent Orseau Metaxal

  • Google DeepMind
  • London, UK
View GitHub Profile
@Metaxal
Metaxal / server-worker-threads.rkt
Last active Mar 18, 2022
read issue on server-worker
View server-worker-threads.rkt
#lang racket
#|
Save this file to "server-worker.rkt"
then run
$ time racket server-worker.rkt
Then toggle the commented expression in `read-msg` and again
$ time racket server-worker.rkt
@Metaxal
Metaxal / readme.md
Last active Feb 23, 2022
Making a pull request for a main distribution package for Racket
View readme.md

Making a pull request for a main distribution package

Say we want to modify the docs of errortrace, which is bundled with the main distribution. I assume the system is a Unix.

  1. Install Racket from a binary as a local distribution, so you don't have to use sudo/root.

If you don't create symlinks, make sure you run the correct version of raco and friends below.

  1. Create a pkgs directory somewhere and cd to it.
@Metaxal
Metaxal / andmap-stress-test.rkt
Last active Dec 16, 2021
andmap stress test
View andmap-stress-test.rkt
#lang racket
;; Allows for improper lists
(define (my-andmap proc l1 l2)
(let loop ([l1 l1] [l2 l2])
(cond [(and (null? l1) (null? l2)) #t]
[(or (null? l1) (null? l2))
(error "Lists must have the same length" (length l1) (length l2))]
[(and (pair? l1) (pair? l2))
(and (proc (car l1) (car l2))
@Metaxal
Metaxal / select-or-send-sexp.rkt
Last active Feb 17, 2022
Send the current s-expression to the interactions window (quickscript)
View select-or-send-sexp.rkt
#lang racket/base
(require quickscript
racket/list
racket/class
framework
racket/gui/base)
;;; Author: Laurent Orseau https://github.com/Metaxal
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or
@Metaxal
Metaxal / commonmark-render.rkt
Created Nov 23, 2021
Renders the current markdown file as HTML in the browser (quickscript)
View commonmark-render.rkt
#lang racket/base
;;; Author: Laurent Orseau https://github.com/Metaxal
;;; 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.
;;; Requires `commonmark`
(require quickscript
commonmark
@Metaxal
Metaxal / plot-ticks.rkt
Created Nov 5, 2021
Customizing plot ticks
View plot-ticks.rkt
#lang racket
(require plot)
(define (tlayout low high)
(list
; major ticks: tick is shown with label
(pre-tick pi #t)
(pre-tick (sqrt 2) #t)
(pre-tick 0.5 #t)
; minor ticks: tick is shown, but without label
@Metaxal
Metaxal / command-palette.rkt
Last active Nov 6, 2021
`Navigate' the menus with a search-list-box (quickscript)
View command-palette.rkt
#lang racket/base
(require quickscript
racket/gui/base
racket/class
racket/list
search-list-box)
(provide (except-out (all-defined-out)
search-list-box-filter))
@Metaxal
Metaxal / debug-tool.rkt
Last active Oct 28, 2021
Map quickscript menus and keyboard shortcut to the Debug tool
View debug-tool.rkt
#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/string
racket/list
racket/class)
@Metaxal
Metaxal / reopen-last-tab.rkt
Last active Nov 8, 2021
Reopen the last closed file in DrRacket (quickscript)
View reopen-last-tab.rkt
#lang racket/base
(require quickscript
quickscript/utils
racket/class
racket/list
framework)
;;; Author: Laurent Orseau https://github.com/Metaxal
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or
@Metaxal
Metaxal / rename-identifier.rkt
Last active Oct 23, 2021
Rename identifier quickscript, like in the right-click menu item
View rename-identifier.rkt
#lang racket/base
(require quickscript
racket/class
racket/gui/base
string-constants)
;;; 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.