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 / reopen-last-tab.rkt
Last active November 8, 2021 08:45
Reopen the last closed file in DrRacket (quickscript)
#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 October 23, 2021 14:07
Rename identifier quickscript, like in the right-click menu item
#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.
@Metaxal
Metaxal / requiring-provided-by-quickscript.rkt
Created October 18, 2021 13:33
Using quickscripts as normal racket modules
#lang racket/base
(require quickscript-extra/scripts/provided-by ; exports the `provided-by` script, which is also a function
racket/class)
;; Create a mock class to avoid creating an actior editor% from the framework.
(define my-ed%
(class object%
(init-field string)
(define/public (get-start-position) 0)
@Metaxal
Metaxal / with-it.rkt
Created September 21, 2021 13:00
Hygienic 'threading' macro for Racket
#lang racket/base
(require (for-syntax racket/base
syntax/parse))
(provide with)
(define-syntax (with stx)
(syntax-parse stx
[(with it last)
#'last]
@Metaxal
Metaxal / move-tab-to-new-window.rkt
Last active August 2, 2021 16:15
Quickscript to move the current (saved) tab to a new DrRacket window
#lang racket/base
(require quickscript
quickscript/utils
racket/class
drracket/tool-lib
racket/gui/base)
(script-help-string "move the current (saved) tab to a new DrRacket window")
@Metaxal
Metaxal / transform-s-exp.rkt
Last active July 30, 2021 11:54
A quickscript to transform a s-exp into another. The transformation is currently hardcoded.
#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.
;;; Transforms a s-exp into another.
;;; Tries to keep most of the original indentation, parenthesis shapes,
;;; but it will remove all comments within the s-exp.
;;; New lines can be added with #\n.
@Metaxal
Metaxal / string2unicode.rkt
Last active November 10, 2021 12:40
Quickscript to turn latex-like strings into unicode symbols
#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.
(require racket/dict
racket/class
(submod text-block/symbols codes)
quickscript
@Metaxal
Metaxal / remove-trailing-spaces
Last active May 20, 2021 15:03
quickscript to remove trailing spaces in the whole file
#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)
(script-help-string "Remove trailing spaces in the current tab")
@Metaxal
Metaxal / dragable-panels.rkt
Created March 31, 2021 09:02
Dragrable panels to resize containers by dragging the space between them
#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 March 22, 2021 14:56
A quickscript to change the selection to upcase
#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)))