Skip to content

Instantly share code, notes, and snippets.

View mavant's full-sized avatar

Matthew Avant mavant

View GitHub Profile
(defmacro s-expr->semantic-whitespace "Convert a list of expressions in Clojure to semantic-whitespace form." ([l] (apply str (macroexpand-1 `(s-expr->semantic-whitespace ~l 1)))) ([l n] (map (fn [x] (if (list? x) (apply str "\n" (apply str (repeat n "\t")) (interpose " "(macroexpand-1 `(s-expr->semantic-whitespace ~x ~(+ n 1)))) ) x)) l)))
(print (macroexpand-1 '(s-expr->semantic-whitespace (defn
tabs->parens [c] (map add-parens (rest
(split-on-newlines
c)) (list-deltas (code->numtabs c)))))))
;=>
;defntabs->parens[c]
(defmacro s-expr->semantic-whitespace "Convert a list of expressions in Clojure to semantic-whitespace form." ([l] (apply str (interpose " "(macroexpand-1 `(s-expr->semantic-whitespace ~l 1))))) ([l n] (map (fn [x] (if (list? x) (apply str "\n" (apply str (repeat n "\t")) (interpose " "(macroexpand-1 `(s-expr->semantic-whitespace ~x ~(+ n 1)))) ) x)) l)))
(print (macroexpand-1 '(s-expr->semantic-whitespace (defn
tabs->parens [c] (map add-parens (rest
(split-on-newlines
c)) (list-deltas (code->numtabs c)))))))
;=>
;defntabs->parens[c]
(defmacro s-expr->semantic-whitespace
"Convert a list of expressions in Clojure to semantic-whitespace form."
([l] (apply str (interpose " " (macroexpand-1 `(s-expr->semantic-whitespace ~l 1)))))
([l n] (map (fn [x] (if (list? x) (apply str "\n" (apply str (repeat n "\t")) (interpose " " (macroexpand-1 `(s-expr->semantic-whitespace ~x ~(+ n 1)))) ) x)) l)))
(defn split-on-newlines "Splits a string into a list of strings by any newline characters." [s] (clojure.string/split s #"\n"))
(defn indented? "Returns true if the string has at least one tab character, otherwise false." [s] (not (nil? (re-find #"\t" s))))
(defn remove-first-tab "Removes the first tab character from a string." [x] (clojure.string/replace-first x #"\t" ""))
{-# LANGUAGE OverloadedStrings #-}
import Data.Conduit.List (sinkNull, mapMaybe)
import Numeric (showFFloat, showInt)
import System.Console.GetOpt.Simple
import Data.Conduit
import Data.List.Split (splitPlacesBlanks)
import Data.List (isSuffixOf)
import Network.Pcap.Conduit (Packet, sourceOffline, sourceLive)
import Network.Pcap.Base (hdrSeconds, hdrUseconds)
import Data.Time.Clock.POSIX
import Data.Time.Clock (NominalDiffTime)
import qualified Data.Map as Map
data Check = Check { name :: String, action :: IO Result }
instance Eq Check where
c1 == c2 = name c1 == name c2
instance Ord Check where
compare c1 c2 = compare (name c1) (name c2)
data Result = Pass | Warn String | Fail String deriving (Show, Eq, Ord)

Keybase proof

I hereby claim:

  • I am mavant on github.
  • I am mavant (https://keybase.io/mavant) on keybase.
  • I have a public key whose fingerprint is 7D92 673E 93A1 2E1D EF57 8D0E D4D2 5B06 7EDA 7470

To claim this, I am signing this object: