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 / count-words-trie.rkt
Last active March 19, 2021 14:14
The count-words problem using a discrimination tree with assocs and switching to hash when too many elements
#lang racket/base
(require racket/dict)
;;; 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.
(define N-PAIRS-MAX 20)
(define int-downcase (- (char->integer #\a) (char->integer #\A)))
@Metaxal
Metaxal / fix-true-false.rkt
Last active March 3, 2021 14:48
Replaces all occurrences of #t and #f with #true and #false in the selected text (quickscript)
#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/class)
(script-help-string
"Replaces all occurrences of #t and #f with #true and #false in the selected text (warning: in strings too!)")
@Metaxal
Metaxal / print-editor.rkt
Created February 11, 2021 22:47
Prints the contents of the current editor (quickscript)
#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/class)
(script-help-string "Prints the contents of the current editor")
@Metaxal
Metaxal / save-and-run.rkt
Last active February 6, 2021 10:11
Save current file and execute it (quickscript)
#lang racket/base
(require quickscript
racket/class)
;;; 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.
(script-help-string "Save file an execute")
@Metaxal
Metaxal / url2script.rkt
Last active October 29, 2021 09:32
(OBSOLETE: now part of quickscript-extra) Fetches a quickscript at a given url and adds it to the library
#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
quickscript/base
racket/class
racket/file
racket/match
@Metaxal
Metaxal / workspaces.rkt
Last active February 2, 2021 12:49
Workspaces for DrRacket (quickscript)
#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.
;;; See also: https://pkgs.racket-lang.org/package/drracket-restore-workspace
(require quickscript
racket/class
racket/match
@Metaxal
Metaxal / new-file-in-same-directory.rkt
Last active May 23, 2021 05:11
A quickscript to create a new file in the same directory as the current file and opens it in DrRacket
#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/file
racket/path
racket/gui/base
@Metaxal
Metaxal / open-multi.rkt
Last active October 31, 2021 13:19
Quickscript to open multiple files at once
#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
quickscript/utils
racket/class
racket/string
racket/gui/base)
@Metaxal
Metaxal / easy-wrapping.rkt
Last active December 29, 2020 16:46
Helpers to define wrappable functions and wrappers (proof of concept)
#lang racket
(require syntax/parse/define
(for-syntax racket/syntax
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.
(define no-value (gensym))
@Metaxal
Metaxal / syntax-tooltip.rkt
Last active December 11, 2020 10:22
How to augment the syntax to make DrRacket display information in a tooltip–LIVE! (without even saving the file!)
#lang racket
;;; License: [MIT](http://opensource.org/licenses/MIT)
;;; Adapted from: https://github.com/samth/fancy-app
(begin-for-syntax
(define (make-tooltip stx id msg)
(define pos (syntax-position id))
(define span (syntax-span id))
(syntax-property