Skip to content

Instantly share code, notes, and snippets.

View soegaard's full-sized avatar

Jens Axel Søgaard soegaard

View GitHub Profile
@soegaard
soegaard / screenshot.rkt
Created September 23, 2023 15:28
Screenshots: Capture whole screen and individual windows. For a widget gallery.
#lang racket
;;;
;;; This library provides functions to:
;;; 1. Take a screenshot of an entire screen
;;; 2. Get a list of all windows, window ids and window names
;;; 3. Capture a single window as an image.
;;; 4. Examples: Recreation of the widget gallery.
;;;
;;; Notes: The combo-field and the text field misses text
@soegaard
soegaard / How to Render
Last active August 22, 2023 09:37
Example of seclink in Scribble files
How to render html document
I used
raco scribble --htmls seclink-main.rkt
to render the document as multiple html files.
@soegaard
soegaard / regexp.rkt
Created May 5, 2022 10:40
Regular Expression Matching for S-expressions
#lang racket
;;;
;;; Regular Expression Matching for S-expressions
;;;
;; Exports
(provide regular-match ; the main form
named-groups) ; holds immutable hash table of named groups
;; Imports
@soegaard
soegaard / Urlang Counter Example
Created November 9, 2021 21:23
Urlang Counter Example using React
#lang at-exp racket
(require urlang urlang/html urlang/react/urx)
(require net/sendurl syntax/parse)
;;;
;;; Urlang Configuration
;;;
(current-urlang-run? #f) ; run using Node? No, use browser
(current-urlang-echo? #t) ; print generated JavaScript?
#lang at-exp racket/base
(require racket/runtime-path racket/format racket/file
urlang urlang/html urlang/extra urlang/react/urx urlang/for
syntax/parse racket/syntax)
;;;
;;; CONFIGURATION
;;;
@soegaard
soegaard / define-record.rkt
Created September 5, 2020 12:23
define-record and variant-case
#lang racket
(require (for-syntax racket/syntax syntax/parse))
(define-syntax (define-record stx)
(syntax-parse stx
[(_define-record name:id (field:id ...))
(with-syntax
([make-name (format-id #'name "make-~a" #'name)]
[(name->field ...) (for/list ([field (syntax->list #'(field ...))])
#lang racket/base
(require racket/match racket/list racket/port racket/string
"flomat.rkt")
;;;
;;; Homogeneous coordinates for 3 dimensions
;;;
; Follow the tutorial
; http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
@soegaard
soegaard / maxima-gamma.rkt
Created July 6, 2020 14:58
Test gamma function using Maxima
#lang at-exp racket
(require racket/tcp racket/string)
;;; Maxima
;; This module starts an external Maxima process.
;; The function send will send a command to Maxima.
;; The function receive will get the output from Maxima as a list of strings.
;; The various send-* and receive-* functions sends and receives to and from Maxima.
;; The various read-* and display-* functions reads and displays to Racket (DrRacket).
#lang at-exp racket
(require racket/tcp)
;;; Maxima
;; This module starts an external Maxima process.
;; The function send will send a command to Maxima.
;; The function receive will get the output from Maxima as a list of strings.
;; The various send-* and receive-* functions sends and receives to and from Maxima.
;; The various read-* and display-* functions reads and displays to Racket (DrRacket).
;;;
;;; General Editing
;;;
;; When a region is highlighted typed text should replace the selction.
(delete-selection-mode 1)
;; Bind cmd-z to undo.
(global-set-key (kbd "s-z") #'undo)