This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Generate an SVG label-sheet template for Inkscape. | |
| Everything is in millimetres, and the document is set up so that | |
| 1 SVG user unit == 1 mm. Coordinates in the file are therefore the | |
| numbers you measured off the sheet, with no dpi conversion anywhere. | |
| Output structure: | |
| layer "template" -- non-printing outline of every label cell (locked) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2021 Bowen Fu | |
| * Distributed Under The Apache-2.0 License | |
| */ | |
| #ifndef MATCHIT_H | |
| #define MATCHIT_H | |
| #ifndef MATCHIT_CORE_H | |
| #define MATCHIT_CORE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from pathlib import Path | |
| from functools import partial, reduce | |
| from pprint import pprint | |
| eval_path = partial(reduce, lambda d, k: d[k]) | |
| def extract_includes(output_path): | |
| results = [] | |
| with open(output_path, 'r', encoding='utf-16') as f: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NEWUSER=$1 | |
| USERFULLNAME=$2 | |
| PASS=$(diceware) | |
| adduser --disabled-password --gecos "$USERFULLNAME,,," $NEWUSER | |
| echo "$NEWUSER:$PASS" | chpasswd | |
| sudo -u $NEWUSER -s <<USERSCRIPT | |
| mkdir -p ~/.ssh | |
| umask 177 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from subprocess import run | |
| from pathlib import Path as path | |
| from functools import lru_cache | |
| def wg_show(interface, field): | |
| res = run(["wg", "show", interface, field], check=True, text=True, capture_output=True) | |
| return map(lambda l: l.split(maxsplit=1), res.stdout.strip().split('\n')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RunOutput(): | |
| def __init__(self, returncode, stdout, stderr): | |
| self.returncode = returncode | |
| self.stdout = stdout | |
| self.stderr = stderr | |
| # the following three commands are adapted from https://kevinmccarthy.org/2016/07/25/streaming-subprocess-stdin-and-stdout-with-asyncio-in-python/ | |
| async def _read_stream(stream, callback): | |
| while True: | |
| line = await stream.readline() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Result(metaclass=ABCMeta): # abstract base class | |
| '''A result monad whose interface is patterned after that of Rust's std::Result<T, E> ''' | |
| def is_ok(self) -> bool: return NotImplemented | |
| def unwrap_or_else(self, func): return NotImplemented | |
| def unwrap_or(self, val): return NotImplemented | |
| def then(self, f): return NotImplemented # techincally this breaks the monad rules because f might be a functor (A->Result(B)) or it could be just a function (A->B) | |
| class Error(Result): | |
| def __init__(self, err): | |
| self._err = err |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://vega.github.io/schema/vega/v3.json", | |
| "autosize": "pad", | |
| "padding": 5, | |
| "width": 500, | |
| "height": 400, | |
| "style": "cell", | |
| "data": [ | |
| {"name": "selector091_store"}, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make arrays for sets of machines so you don't have to remember the name | |
| $S415_all = @( | |
| "ESC-1C58BM1", | |
| "ESC-CBX7JN1", | |
| "ESC-2958BM1", | |
| "ESC-B858BM1", | |
| "ESC-5858BM1", | |
| "ESC-6B58BM1", | |
| "ESC-2C58BM1", | |
| "ESC-F2BVLL1", |
NewerOlder