Skip to content

Instantly share code, notes, and snippets.

@dgoffredo
dgoffredo / diversion.md
Last active December 9, 2016 04:44
Proposal for a directory version management tool

diversion (DIrectory VERSIONing)

A set of conventions for managing versions of a flat directory.

Layout

If the directory to be versioned is /bb/data/configs, then the diversion-compatible layout of the parent directory, /bb/data/, could look

Let's see whether github highlights racket as a language.

(require graph)

(define g (directed-graph '((a b) (b a))))

(with-output-to-file "out.dot"
  (lambda () (graphviz g)))
@dgoffredo
dgoffredo / test.rkt
Created May 12, 2018 21:37
Does Racket get highlighted?
#lang racket
(provide
; function that converts an SXML s-expression into one of the types below
sxml->bdlat
; function that finds all types define in an SXML s-expression and returns
; an association list of name -> type.
sxml->types

python

This module provides data structures representing Python code abstract syntax tree (AST) elements and procedures for producing python code from bdlat types.

For example, this module can be used to tranform the following list of bdlat types:

(list 
  (sequence "BerDecoderOptions" 
    '("BER decoding options") 

Does it need a blank line?

  • if this works
  • then no

Does it need a blank line?

  • if this is all that works
  • then yes

Fear of Macros

Greg Hendershott

A practical guide to Racket macros.

Copyright (c) 2012-2018 by Greg Hendershott. All rights reserved.

piat

Parse into attribute types

Why

Tiny domain specific languages sometimes find their way into C++ code. An ideal way to parse these langauges is to use [boost.spirit][spirit]. However, sometimes the full glory of Spirit is more or less than you need. Spirit is powerful and general, but you have to tell it how to parse into your AST types,

#lang at-exp racket
(displayln "here's a string
with line breaks
in it.")
(displayln @~a{Here's an attempt
at using the at-exp reader
list list foo first})
(json {"how": "does", "it": ["look", 2, 3]})
(json-object ("how" "does") ("it" (json-array "look" 2 3)))
"{\"how\": \"does\", \"it\": [\"look\", 2, 3]}"
; What about null?
(json [1, null, 3])
(status[int], {mime[str]: body[bytes]})

pattern

simple pattern matching in Python

Why