Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurent Orseau Metaxal

  • Google DeepMind
  • London, UK
View GitHub Profile
@Metaxal
Metaxal / dragable-panels.rkt
Created Mar 31, 2021
Dragrable panels to resize containers by dragging the space between them
View dragable-panels.rkt
#lang racket/gui
(require framework)
(define fr (new frame% [label "gui"] [width 500] [height 500]))
(define p (new panel:vertical-dragable% [parent fr]))
(define pt (new panel:horizontal-dragable% [parent p] [border 1] [style '(border)]))
(define pb (new panel:horizontal-dragable% [parent p] [border 1] [style '(border)]))
(define ptl (new panel% [parent pt] [border 1] [style '(border)]))
(define ptr (new panel% [parent pt] [border 1] [style '(border)]))
@Metaxal
Metaxal / upcase.rkt
Last active Mar 22, 2021
A quickscript to change the selection to upcase
View upcase.rkt
#lang racket/base
(require quickscript)
;; Returns a replacement string for the selected string `selection`
;; ("" if no text is selected), or `#f` to leave the selection as is.
(define-script upcase
#:label "upcase"
(λ (selection)
(string-upcase selection)))
@Metaxal
Metaxal / count-words-trie.rkt
Last active Mar 19, 2021
The count-words problem using a discrimination tree with assocs and switching to hash when too many elements
View count-words-trie.rkt
#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 Mar 3, 2021
Replaces all occurrences of #t and #f with #true and #false in the selected text (quickscript)
View fix-true-false.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/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 Feb 11, 2021
Prints the contents of the current editor (quickscript)
View print-editor.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/class)
(script-help-string "Prints the contents of the current editor")
@Metaxal
Metaxal / save-and-run.rkt
Last active Feb 6, 2021
Save current file and execute it (quickscript)
View save-and-run.rkt
#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 Mar 27, 2021
Fetches a quickscript at a given url and adds it to the library
View url2script.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
quickscript/base
racket/class
racket/file
racket/match
@Metaxal
Metaxal / workspaces.rkt
Last active Feb 2, 2021
Workspaces for DrRacket (quickscript)
View workspaces.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.
;;; 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 Feb 1, 2021
A quickscript to create a new file in the same directory as the current file and opens it in DrRacket
View new-file-in-same-directory.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/file
racket/path
racket/gui/base
@Metaxal
Metaxal / open-multi.rkt
Last active Feb 1, 2021
Quickscript to open multiple files at once
View open-multi.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/class
racket/string
racket/gui/base)