Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurent Orseau Metaxal

  • Google DeepMind
  • London, UK
View GitHub Profile
@Metaxal
Metaxal / softmax.rkt
Last active Sep 28, 2022
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 Sep 2, 2022
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 Sep 15, 2022
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 Jul 18, 2022
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 Aug 19, 2022
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 Mar 18, 2022
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 Feb 23, 2022
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.
@Metaxal
Metaxal / andmap-stress-test.rkt
Last active Dec 16, 2021
andmap stress test
View andmap-stress-test.rkt
#lang racket
;; Allows for improper lists
(define (my-andmap proc l1 l2)
(let loop ([l1 l1] [l2 l2])
(cond [(and (null? l1) (null? l2)) #t]
[(or (null? l1) (null? l2))
(error "Lists must have the same length" (length l1) (length l2))]
[(and (pair? l1) (pair? l2))
(and (proc (car l1) (car l2))
@Metaxal
Metaxal / select-or-send-sexp.rkt
Last active Feb 17, 2022
Send the current s-expression to the interactions window (quickscript)
View select-or-send-sexp.rkt
#lang racket/base
(require quickscript
racket/list
racket/class
framework
racket/gui/base)
;;; Author: Laurent Orseau https://github.com/Metaxal
;;; License: [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) or
@Metaxal
Metaxal / commonmark-render.rkt
Created Nov 23, 2021
Renders the current markdown file as HTML in the browser (quickscript)
View commonmark-render.rkt
#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.
;;; Requires `commonmark`
(require quickscript
commonmark