Some classes to showcase Java Iteratable<T>
and Iterator<E>
I've put everything in the same file by simplicity and declared inner classes static but I wouldn't recommend to do that in production code (separation of concerns).
#!/bin/bash | |
set -e | |
HERE=$(dirname $(realpath $0)) | |
rm -rf local remote.git | |
git init --bare $HERE/remote.git | |
git clone $HERE/remote.git local |
import time | |
from collections import Counter | |
from dataclasses import dataclass, field | |
from hashlib import sha512 | |
from typing import List | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from tqdm import trange |
from typing import Any, Sequence | |
def ascii_table(rows: Sequence[Sequence[Any]]) -> str: | |
""" | |
Format the rows in an ascii table. | |
First row is considered to be the header | |
Numbers are right justified, everything else is left justified | |
See example below: | |
package be.unamur.info.b314.compiler.main; | |
import org.apache.commons.io.FileUtils; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.rules.TemporaryFolder; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Parameterized; | |
import org.junit.runners.Parameterized.Parameters; |
def check(s1, s2): | |
return sorted(s1.lower()) == sorted(s2.lower()) |
; A set of scenario to record in training mode. | |
; place focus on button to start record then press shortcut for given scenario | |
F11::Suspend, Toggle | |
jump(direction) | |
{ | |
if (direction = "left") | |
{ | |
Send, {Left Down} |
#!/usr/bin/env python3 | |
import argparse | |
import re | |
from pathlib import Path | |
from subprocess import run | |
DEFAULT_PATTERN = re.compile(r'^(?P<track>\d+)---(?P<title>.+) - (?P<album>.+)---(?P<video_id>.+)\.opus$') | |
def extract_meta_from_path(full_path, pattern): | |
tentative_match = pattern.match(full_path.name) |
#!/usr/bin/env python3 | |
import argparse | |
import logging | |
import os | |
import re | |
from datetime import datetime | |
from subprocess import call | |
from tempfile import mkdtemp | |
Extends argparse.ArgumentParser to make it able to take in values from a configuration file.
Beyond the added functionality it doesn't not modify the behaviour of argparse.ArgumentParser and can thus be used as a drop in replacement.
You may want to provide values either to the CLI or by configuration file. And you don't want to check yourself if each value not provided to the CLI is present in the configuration file. And you also don't want the CLI to shout an error because it hasn't been provided an option when it is present in the configuration file.