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
@samdphillips
samdphillips / gpio.rkt
Last active December 28, 2020 21:22
Soothing GPIO Light Changer in Racket
#lang racket/base
#|
Three color LED connected to RPi GPIO pins 2 3 4.
The process is pretty straightforward.
1. Use FFI to get open and mmap /dev/gpiomem
2. Use FFI ptr-ref and ptr-set! to change the gpio registers
@dvanhorn
dvanhorn / syntax-rules-eval.rkt
Last active October 21, 2020 16:46
A CPS interpreter for a CBV language written in syntax-rules
#lang racket
;; A CPS interpreter for a CBV language written in syntax-rules
;; e ::= 'd literal
;; | x variable
;; | (e e) application
;; | (λ (x) e) abstraction
;; (eval e) interprets e in an environment
@Metaxal
Metaxal / paint.rkt
Last active October 25, 2020 08:52
A very simple painting program
#lang racket
;; 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 racket/gui/base
pict)
(define line-width-init 1)
@samdphillips
samdphillips / minitalk.rkt
Last active September 6, 2020 20:44
Very small single dispatch object language.
#lang racket/base
(struct %class [parent ivars methods] #:transparent)
(struct %object [class ivars] #:transparent)
(define (new class vals)
(%object class vals))
(define (send obj method-name args)
(define method (lookup-method (object-class obj) method-name))
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@jackfirth
jackfirth / continuation-lessons.md
Last active June 26, 2023 13:54
Examples of how to build control flow structures with continuations

Lessons in Using Continuations

This gist contains examples of how to build different kinds of control flow structures in Racket using macros and continuations. Examples include:

  • Early exit from functions using a return statement.
  • Early exit from arbitrary expressions using a simple exception system.
  • Temporarily interrupting execution in order to check permissions.
@samdphillips
samdphillips / AOC-2019-Racket.md
Last active November 7, 2021 17:12
read the file

Advent of Code 2019 Racket Leaderboard

Proposal Author

Sam Phillips

Background

Advent of Code is a coding contest that takes place December 1st to 25th every year. Everyday a new puzzle is posted to the site. The puzzles form a larger story that is Christmas/Holiday themed. There is a global leaderboard which is pretty competitive. They also allow users to

@alex-hhh
alex-hhh / world-map.rkt
Last active August 20, 2019 03:01
World Map, standard-fish competition 2019
#lang racket
(require json racket/draw math/base)
(define (lat-lon->map-point coordinates)
(match-define (list lon lat _ ...) coordinates)
(define-values (x y) (values (degrees->radians lon) (asinh (tan (degrees->radians lat)))))
(list (/ (+ 1 (/ x pi)) 2) (/ (- 1 (/ y pi)) 2)))
(define (draw-polygon dc polygons)
(define path
http://chronos-st.blogspot.com/2007/12/smalltalk-in-one-page.html
http://www.csci.csusb.edu/dick/samples/smalltalk.syntax.html
Formal EBNF Specification of Smalltalk Syntax
1. Character = ? Any Unicode character ?;
2. WhitespaceCharacter = ? Any space, newline or horizontal tab character ?;
3. DecimalDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
4. Letter = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M"
| "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
@nilp0inter
nilp0inter / fizzbuzz.rkt
Last active January 7, 2020 13:06
The first beautiful implementation of FizzBuzz?
#lang 2d racket
(require 2d/match)
(define (fizz? n)
(= 0 (modulo n 5)))
(define (buzz? n)
(= 0 (modulo n 3)))