Skip to content

Instantly share code, notes, and snippets.

View soegaard's full-sized avatar

Jens Axel Søgaard soegaard

View GitHub Profile
;;;
;;; 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)
Process: Defle [49183]
Path: /Volumes/VOLUME/*/DefleMask.app/Contents/MacOS/Defle
Identifier: com.deflemask.app
Version: DefleMask Tracker 12.0.1 (12.0.1)
Code Type: X86 (Native)
Parent Process: ??? [1]
Responsible: Defle [49183]
User ID: 501
Date/Time: 2019-09-01 17:37:38.597 +0200
@soegaard
soegaard / uniq.rkt
Created August 18, 2019 16:26
Uniq for Racket lists
#lang racket/base
(provide uniq)
;;;
;;; Uniq
;;;
; The function uniq takes a list as input and returns a new list:
; adjacent elements are compared and omits any repeated elements.
; In other words, uniq works like the Unix utility uniq, but on list.
@soegaard
soegaard / sicp-concurrency.rkt
Created December 16, 2018 16:48
Concurrency primitives for SICP for Racket 7
#lang racket
;; adapted from:
;; https://planet.racket-lang.org/package-source/dyoo/sicp-concurrency.plt/1/2/sicp-concurrency.ss
;; concurrency: SICP concurrency primitives
;; adapted from http://list.cs.brown.edu/pipermail/plt-scheme/2002-September/000620.html
;;; Sources:
;;; Dorai Sitaram, "Learn Scheme in a Fixnum of Dayes", chapter 15
;;; Dyvig, http://www.scheme.com/tspl2d/examples.html#g2433
@soegaard
soegaard / SpaceInvaders.rkt
Created July 22, 2017 17:26
Space Invaders
(let ()
(current-namespace (make-base-namespace))
(define (hello) (displayln "Space Invaders!"))
(namespace-set-variable-value! 'hello hello)
;;;
;;; Browser API
;;;
;;; Time
(define now (js-import-from (js-date) "now" 0))
;;; Window
#lang racket/gui
(let ([new-es (make-eventspace)])
(parameterize ([current-eventspace new-es])
(define frame (new frame%
[label "Bug demo"]))
(define button (new button%
[callback
(lambda _
@soegaard
soegaard / name_p
Created July 8, 2015 16:38
Does this construct have a name?
> (define (make-map+fold f)
; f : α β -> (values α β)
; map f over xs while threading the seconding value
(define (f* xs ρ)
(match xs
['() (values '() ρ)]
[(cons x xs) (letv ((x ρ) (f x ρ))
(letv ((xs ρ) (f* xs ρ))
(values (cons x xs) ρ)))]))
f*)
#lang racket
(provide (for-syntax x))
(begin-for-syntax
(define x 1)
(set! x 2))
(define-syntax (foo stx)
(syntax-case stx ()
[(_foo)
mba-5:plt soegaard$ make
if [ "" = "" ] ; \
then make plain-in-place PKGS="main-distribution main-distribution-test" ; \
else make cpus-in-place CPUS="" PKGS="main-distribution main-distribution-test" ; fi
make base
mkdir -p build/config
echo '#hash((links-search-files . ()))' > build/config/config.rktd
mkdir -p racket/src/build
make racket/src/build/Makefile
make[3]: `racket/src/build/Makefile' is up to date.
#lang racket
(require (for-syntax syntax/parse racket/syntax))
(require ffi/unsafe/objc)
(require ffi/unsafe
ffi/unsafe/objc
ffi/unsafe/define
mred/private/wx/cocoa/image
mred/private/wx/cocoa/types)
;;; Bit operations