Skip to content

Instantly share code, notes, and snippets.

View spdegabrielle's full-sized avatar
🏠
Working from home

Stephen De Gabrielle spdegabrielle

🏠
Working from home
View GitHub Profile
@Chubek
Chubek / FewlPP.rkt
Last active February 8, 2024 14:35
FewlPP.rkt -> C Preprocessor that adds Fork-Exec-Wait Loops
#!/usr/bin/racket
#lang racket
(define directives '())
(define bypasses '())
(define declarations '())
(define definitions '())
(define (process-line line)
@swatson555
swatson555 / compile.ss
Created June 22, 2022 13:13
nanopass compiler for r0 language
#!/usr/bin/env scheme --script
(import (nanopass))
(define unique-var
(let ()
(define count 0)
(lambda (name)
(let ([c count])
(set! count (+ count 1))
#lang racket
(require math/array)
;; https://en.wikipedia.org/wiki/Conway's_Game_of_Life
;; These are the game rules for a single CELL which can be 1 (alive) or 0
;; dead. NEIGHBOR-COUNT is the number of live neighbors the cell has.
(define (game-rules cell neighbor-count)
(cond
;; Any live cell with fewer than two live neighbours dies, as if by
;; underpopulation.
@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?
@Metaxal
Metaxal / rename-identifier.rkt
Last active October 23, 2021 14:07
Rename identifier quickscript, like in the right-click menu item
#lang racket/base
(require quickscript
racket/class
racket/gui/base
string-constants)
;;; 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.
@samdphillips
samdphillips / 00-rhombus-sheepdogs.md
Last active August 10, 2021 19:05
Another rhombus experiment

Rhombus Sheepdogs

This is an incomplete implementation of a sheep and sheepdog agent simulation in Rhombus.

NOTE The Rhombus proposal is not stable. This example should be considered a point in time example. I may or may not update this to reflect newer versions of the proposal.

@samdphillips
samdphillips / 00-kicking-the-tires-of-rhombus.md
Last active October 29, 2021 14:46
Kicking the tires of the Rhombus prototype

Kicking the tires of Rhombus

NOTE The Rhombus proposal is not stable. This example should be considered a point in time example. I may or may not update this to reflect newer versions of the proposal.

2021/08/04

This is a translation of a kind of scraping script I've written in Racket.

Some notes:

@samdphillips
samdphillips / archive-email.rkt
Created August 2, 2021 21:17
Archive emails from outlook
#lang racket/base
(require ffi/unsafe
ffi/unsafe/objc
ffi/unsafe/nsstring
gregor
racket/match
racket/sequence
threading)
@srcreigh
srcreigh / syntax-error.rkt
Created February 2, 2021 23:19
How to add static compilation errors to Racket
#lang racket/base
(require (for-syntax racket/base syntax/parse))
(define-syntax (error stx)
(syntax-parse stx
[(_ ...) (raise-syntax-error #f "This is an error." stx)]))
;; The following line will be highlighted in the IDE and say "This is an error."
;; in DrRacket or racket-xp-mode for emacs.
(error 'hi)
@Metaxal
Metaxal / url2script.rkt
Last active October 29, 2021 09:32
(OBSOLETE: now part of quickscript-extra) Fetches a quickscript at a given url and adds it to the library
#lang racket/base
;;; 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/base
racket/class
racket/file
racket/match