Skip to content

Instantly share code, notes, and snippets.

@dgoffredo
dgoffredo / capture.sh
Last active October 21, 2021 19:28
wrapper around tcpdump: limit capture size and duration
#!/bin/sh
# Capture all network traffic that mentions a particular port, and write the
# packets to a file. Stop capture when either enough data has been collected,
# or enough time has elapsed, where "enough" is configurable in this script.
port=80
file=dump.pcap
max_size_bytes=$((1024 * 1024 * 100))
max_time_seconds=$((60 * 10))
@dgoffredo
dgoffredo / foo.md
Last active December 3, 2020 04:58
scheme formatting
(λ (bde) 
  "\( ゚ヮ゚)/")
(λ (bde) 
 "\( ゚ヮ゚)/")
{"id": "1", "message": {"open": {"schema": ...}}}
{"id": "1", "message": {"request": {"service": "1", ...}}}
{"blah": "this is the request payload nananananannaana"}
{"id": "2", "message": {"respond": {"request": "1"}}}}
{"foo": "this is the payload OMGOMGOMGOMGOMGOM"}
{"id": "2", "message": {"complain": {"id": "2", "what": "unable to decode as JSON"}}}}
(status[int], {mime[str]: body[bytes]})

pattern

simple pattern matching in Python

Why

(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])
#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})

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,

Fear of Macros

Greg Hendershott

A practical guide to Racket macros.

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

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")