Skip to content

Instantly share code, notes, and snippets.

View michaelballantyne's full-sized avatar

Michael Ballantyne michaelballantyne

View GitHub Profile
@michaelballantyne
michaelballantyne / everywhere.rkt
Created May 25, 2018 16:43
Generic traversal `everywhere` macro for Hackett
#lang racket/base
(require
(for-syntax
racket/base
syntax/parse)
(only-in hackett #%app)
hackett/private/base
hackett/private/adt)
#lang racket
(require
'#%expobs
syntax/modcode)
(define (expand/observe stx)
(parameterize ([current-expand-observe (lambda (x y)
(when #t
(writeln y)))])
@michaelballantyne
michaelballantyne / tagless-final-hackett.rkt
Created March 14, 2018 19:24
An example of tagless final embedding in Hackett, with full extensibility for language, interpretations, and syntactic sugar.
#lang hackett
(require (only-in racket module quote let-syntax define-for-syntax define-syntax for-syntax)
(for-syntax racket syntax/parse))
; Helper for syntax stuff later
(module deflang racket
(require (for-syntax syntax/parse))
(provide define-language define-language-syntax)
#lang racket/base
(require racket/place
racket/list
racket/sequence
(except-in racket/match ==)
minikanren)
(define-syntax-rule (forever proc)
(let loop () (proc) (loop)))
@michaelballantyne
michaelballantyne / nebo.idr
Last active August 26, 2015 03:21
Broken attempt to embed a DSL for operations on 3D regular grids with bounds checking into Idris
module Main
import Data.Vect
import Data.Fin
data NumType =
NAT
| FIN Nat
data LocType =
@michaelballantyne
michaelballantyne / osx_socks.py
Last active October 13, 2015 09:23
Yet another Mac SSH SOCKS proxy script. This one handles connection failure properly.
#!/usr/bin/env python
# Public domain.
"""A script to establish an SSH SOCKS proxy and enable it in the OS X network configuration.
Cleanly handles failure to connect. Kills ssh and removes network configuration on CTRL-C.
First argument gives the hostname for use with ssh."""
import subprocess, sys, signal
proxy_command_base = ['networksetup', '-setsocksfirewallproxystate', 'Wi-Fi']