A simple reminder for myself of some often used commands. Plenty of useful docs over on https://git-annex.branchable.com/
This is a work in progress notebook...
| # Make cards out of exported lists | |
| # https://5e.tools/makecards.html | |
| # Export then pass to tool to add background images | |
| import json | |
| import argparse | |
| import unicodedata | |
| import urllib.parse | |
| import urllib.request |
| import time | |
| import sys | |
| anim = ( | |
| "\r| |", | |
| "\r| |", | |
| "\r| |", | |
| "\r| |", | |
| "\r| |", | |
| "\r} |", |
| import dataclasses | |
| class DataFactory(type): | |
| def from_number(cls, num: int) -> "Data": | |
| return cls(str(num)) | |
| @dataclasses.dataclass | |
| class Data(metaclass=DataFactory): | |
| value: str |
| " Install vim-plug with following command | |
| " curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
| " Then ':PlugInstall' to install them | |
| " Set leader to space. This is set up before plugins are loaded. | |
| let mapleader = " " " map leader to Space | |
| " Declare plugins | |
| call plug#begin() |
| from functools import partial | |
| import builtins | |
| class Emoji: | |
| """ Execute functions with style """ | |
| __empty = object() | |
| def __init__(self, left=__empty, right=__empty): | |
| self.__left = left | |
| self.__right = right |
| import re | |
| def parse_compact_range(expression): | |
| numbers = set() | |
| for match_ in re.finditer(r"(?:(\d+)\s*\-\s*(\d+)|(\d+))\s*(?:,|$)", expression): | |
| start, stop, exact = match_.group(1,2,3) | |
| if exact is not None: | |
| numbers.add(int(exact)) | |
| else: | |
| begin, end = sorted(map(int, (start, stop))) |
A simple reminder for myself of some often used commands. Plenty of useful docs over on https://git-annex.branchable.com/
This is a work in progress notebook...
| import re | |
| import os | |
| import html | |
| import shutil | |
| import logging | |
| import tempfile | |
| from functools import partial | |
| from threading import Lock | |
| from urllib.request import urlopen, Request |
| from multiprocessing import Pool as MPool, current_process | |
| from gevent.threadpool import ThreadPool | |
| from gevent.pool import Pool as GPool | |
| from contextlib import closing | |
| class ProcessPool(ThreadPool): | |
| def __init__(self, procs, **kwargs): | |
| super(ProcessPool, self).__init__(procs) | |
| self._m_pool = MPool(procs, **kwargs) |
| from PyQt5 import QtWidgets, QtCore | |
| import gevent | |
| import random | |
| import weakref | |
| def getData(key): | |
| data = "{}_{}_{}".format(key[0], key[1], random.choice("abcdefg")) | |
| gevent.sleep(random.random() * 5 + 2) | |
| return data |