Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurent Orseau Metaxal

  • Google DeepMind
  • London, UK
View GitHub Profile
@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
View hasheq-ref-vs-bin-search.rkt
#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
View rectangle-selection.rkt
#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
View bigfasl.rkt
#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
View softmax.rkt
#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
View examples-details.scrbl
#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
View plot-snip-pasteboard-overlay.rkt
#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
@Metaxal
Metaxal / mandelbrot-futures.rkt
Created July 18, 2022 17:14
Mandelbrot with futures, one future per processor
View mandelbrot-futures.rkt
#lang racket/base
(require racket/future
racket/flonum)
;;; 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.
;;;
;;; Based on the docs for racket/future,
;;; with one future per cpu
@Metaxal
Metaxal / fmt-quickscript.rkt
Last active August 19, 2022 09:49
Quickscript for sorawee's `fmt`
View fmt-quickscript.rkt
#lang racket/base
(require quickscript
fmt ; needs to be installed first
racket/class)
;;; 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.
(script-help-string "Format the selection or the whole program using `fmt`")
@Metaxal
Metaxal / server-worker-threads.rkt
Last active March 18, 2022 12:35
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 February 23, 2022 13:41
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.