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 / new-line-keep-comments.rkt
Last active October 13, 2023 13:22
quickscript: Like pressing Enter, but keeps the comments at the end of the line
#lang racket/base
(require quickscript
racket/list
racket/class
racket/gui/event)
(script-help-string "Like pressing Enter, but keeps the comments at the end of the line")
;;; Author: Laurent Orseau <laurent.orseau@gmail.com>
@Metaxal
Metaxal / remove-trailing-spaces.rkt
Last active September 10, 2023 09:41
remove trailing spaces on save
#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 quickscript
racket/string
racket/class)
@Metaxal
Metaxal / tab-panel-example.rkt
Last active July 23, 2023 20:04
Usage example of tab-panel%
#lang racket/gui
(define fr (new frame% [label "Tab example"]))
(define (tab-panel-set-tab tp idx)
(send tp change-children
(λ (previous-children)
(list (list-ref tab-contents idx)))))
(define tp (new tab-panel%
@Metaxal
Metaxal / run-main-file.rkt
Last active June 26, 2023 09:00
A proof-of-concept quickscript to run the main file in the same directory
#lang racket/base
;;; Author: Laurent Orseau
;;; 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/file
racket/path
@Metaxal
Metaxal / hasheq-ref-vs-bin-search.rkt
Created October 16, 2022 17:16
Comparison between hash-ref on hasheq (for fixnums) and a custom binary search
#lang racket
(require racket/fixnum
math/base)
;;; Conclusion: hasheq-ref is (slightly) faster than a custom binary search
;;; (It's actually probably implemented as a binary search, with some more optimization,
;;; as the bin search is within a factor 2)
(#%declare #:unsafe)
@Metaxal
Metaxal / rectangle-selection.rkt
Last active October 9, 2022 13:38
A quickscript to select a rectangle of text, like Geany
#lang racket/base
(require quickscript
racket/class
racket/list
racket/gui/base
racket/string
framework)
;;; Author: Laurent Orseau - laurent.orseau at gmail.com
@Metaxal
Metaxal / bigfasl.rkt
Created October 6, 2022 21:08
fast load large amount of data
#lang racket
(require racket/fasl
racket/fixnum)
;;; Author: Laurent Orseau
;;; 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.
#| Usage:
@Metaxal
Metaxal / softmax.rkt
Last active September 28, 2022 09:26
softmax speedup issue with futures
#lang racket/base
(require racket/flonum
(only-in math/flonum flvector-sum) ; slow due to type/untype boundary
racket/fixnum
racket/future)
#;(#%declare #:unsafe) ; doesn't make much difference
(provide softmax-ref/unstable
softmax-ref/stable)
@Metaxal
Metaxal / examples-details.scrbl
Last active September 2, 2022 13:50
scribble examples in <details> html element
#lang scribble/manual
@(require scribble/core
scribble/html-properties
racket
scribble/example)
@(define the-eval (make-base-eval))
@examples[#:eval the-eval #:hidden
(require racket/string)]
@Metaxal
Metaxal / plot-snip-pasteboard-overlay.rkt
Last active September 15, 2022 05:20
A simple standalone program using overlays with plot-snip in a pasteboard, and switching with the zooming feature
#lang racket/gui
(require plot
pict)
;;; Author: Laurent Orseau
;;; 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 in particular this blog bost:
;;; https://alex-hhh.github.io/2019/09/map-snip.html#2019-09-08-map-snip-footnote-2-return