Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
((λ (x) (x x)) (λ (y) (y y)))

Ashton Wiersdorf ashton314

👨‍💻
((λ (x) (x x)) (λ (y) (y y)))
View GitHub Profile
View inspect_with_pipe_yasnippet.ex
# -*- mode: snippet -*-
# name: pipe inspect
# key: pi
# --
|> IO.inspect(label: "$1")
$0
@ashton314
ashton314 / minimal.el
Created Apr 4, 2021
Minimal package manager set up
View minimal.el
(defvar bootstrap-version)
(setq straight-repository-branch "develop")
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
@ashton314
ashton314 / turing.rkt
Last active Feb 23, 2021
Showing how you can build a lambda calculus in 7 lines of Racket (that's the first function)
View turing.rkt
#lang racket
;; Demonstration of a turing-complete language
(define (ev e [ρ '()])
(match e
[(? symbol? x) (cadr (assoc x ρ))]
[`(λ (,xs ...) ,es) `(cls ,ρ ,xs ,es)]
[`(,f ,as ...)
(match (ev f ρ)
[`(cls ,cρ ,xs ,es) (ev es (append (map list xs (map (λ (v) (ev v ρ)) as)) cρ ρ))])]))
@ashton314
ashton314 / nondet-callcc.rkt
Created Feb 17, 2021
Non-determinism implemented with the call/cc operator in Racket
View nondet-callcc.rkt
#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)))))
View pandoc-converter.el
;; 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 Apr 9, 2020
The Command pattern from GoF design patterns is a nice pattern. However, the problem it solves is more deftly handled by Lambda: the Ultimate.
View command.rkt
#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 Aug 22, 2019
Custom mix task for development environments to start/stop a Postgres database in a Docker container
View docker.db.exs
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.
View keybase.md

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: