Skip to content

Instantly share code, notes, and snippets.

View ashton314's full-sized avatar
👨‍💻
Expanding ((λ (x) (x x)) (λ (y) (y y)))

Ashton Wiersdorf ashton314

👨‍💻
Expanding ((λ (x) (x x)) (λ (y) (y y)))
View GitHub Profile
@ashton314
ashton314 / nondet-callcc.rkt
Created February 17, 2021 18:23
Non-determinism implemented with the call/cc operator in Racket
#lang racket
(define *remaining-choices* '())
(define (choose choices)
(call/cc
(λ (k)
(for ([i (cdr choices)])
(set! *remaining-choices* (cons (cons k i) *remaining-choices*)))
(k (car choices)))))
;; Pandoc conversion function
;; Requires f.el, as well as pandoc and pandoc-citeproc installed on the host system.
;; If on macOS, install with `brew install pandoc pandoc-citeproc'
(defcustom pandoc-converter-args "--filter pandoc-citeproc --pdf-engine=xelatex" "Additional arguments to pass to pandoc when running `convert-with-pandoc'")
(defun convert-with-pandoc ()
"Convert a file between formats with Pandoc.
This will place the outputted function in the same directory as
the source folder.
@ashton314
ashton314 / command.rkt
Last active April 9, 2020 20:44
The Command pattern from GoF design patterns is a nice pattern. However, the problem it solves is more deftly handled by Lambda: the Ultimate.
#lang racket
;; First, define the undo stack with a few helper functions
(define *undo-stack* '())
(define (push-undo! command)
(set! *undo-stack* (cons command *undo-stack*)))
(define (pop-undo!)
(let ([head (car *undo-stack*)])
@ashton314
ashton314 / docker.db.exs
Created August 22, 2019 02:51
Custom mix task for development environments to start/stop a Postgres database in a Docker container
defmodule Mix.Tasks.Docker.Db do
use Mix.Task
@project_name "Program Builder"
@project_sname "program_builder"
@shortdoc "Start/stop the docker Postgres container for development"
@moduledoc """
Fire up a postgres database for #{@project_name}, named #{@project_sname} in Docker.

Keybase proof

I hereby claim:

  • I am ashton314 on github.
  • I am ashton314 (https://keybase.io/ashton314) on keybase.
  • I have a public key ASAGVAKmpoeIZ8lp6vPnxzyS3oyH-v2vhhrxZODU-hA3ego

To claim this, I am signing this object: