Skip to content

Instantly share code, notes, and snippets.

View michaelballantyne's full-sized avatar

Michael Ballantyne michaelballantyne

View GitHub Profile
@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']
@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 =
#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 / 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
(require
'#%expobs
syntax/modcode)
(define (expand/observe stx)
(parameterize ([current-expand-observe (lambda (x y)
(when #t
(writeln y)))])
@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
(struct lit [v] #:transparent)
(struct lam [xs e] #:transparent)
(struct ref [x] #:transparent)
(struct app [e1 e2] #:transparent)
(struct quot [e] #:transparent)
(struct unquot [e] #:transparent)
(struct lif [c t e] #:transparent)
(struct run [e])
#lang racket
; Interpreter for MetaScheme, the core staged language.
(struct lit [v] #:transparent)
(struct lam [xs e] #:transparent)
(struct ref [x] #:transparent)
(struct app [e1 e2] #:transparent)
(struct lif [c t e] #:transparent)
(struct quot [e] #:transparent)
@michaelballantyne
michaelballantyne / submod.rkt
Created April 14, 2019 20:18
submodule problem
#lang racket
(module A racket
(provide m)
(require (for-syntax syntax/parse syntax/location))
(module empty racket
(provide #%module-begin))
(define-syntax (m stx)
#lang racket
(require
(for-syntax
ee-lib
syntax/parse))
(begin-for-syntax
(define lift-binds! (make-parameter #f))
(define lift-syntaxes! (make-parameter #f))