Skip to content

Instantly share code, notes, and snippets.

@dgjustice
dgjustice / texttree.py
Created July 16, 2021 00:51
Cannonical interface sorting
from itertools import groupby
import re
import typing as t
WEIGHTS: t.Dict[str, int] = {".": 10, "/": 20}
def split_interface_tuple(interface: str) -> t.Tuple[str, ...]:
"""Crappy parser-combinator hacky-hack"""
head = interface.rstrip(r"/\0123456789. ")
@dgjustice
dgjustice / script-template.sh
Created December 15, 2020 12:57 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
from pydantic import BaseModel
import requests
from returns.context import RequiresContext
from returns.functions import tap
from returns.io import IOResultE, impure_safe
class OVHIpAddr(BaseModel):
@dgjustice
dgjustice / junos.py
Last active May 21, 2020 20:28 — forked from jobec/junos.py
Junos config parsing with pyparsing
import textwrap
from collections import OrderedDict
import pyparsing as pp
class Statement(str):
def __str__(self):
return super().__str__() + ";"

Keybase proof

I hereby claim:

  • I am dgjustice on github.
  • I am crzdriver (https://keybase.io/crzdriver) on keybase.
  • I have a public key ASAaAtTllHQ0txMG6MsvSXUr4vTfm5dpcWgheNcmYQ-xTQo

To claim this, I am signing this object: