Uploaded using the New Issue
dialog (and its githubusercontent link copied from the Preview tab)
This file contains 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
# pip install sh pycountry | |
import re | |
from pathlib import Path | |
import pycountry | |
from sh import ffmpeg | |
def mux_mp4_subs(inp, outp, *subs, _cwd=None, **subs_map): | |
"""Mux multiple subtitle files into an mp4 file. |
This file contains 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 | |
# $ pip install pandas playwright tabulate && python -m playwright install --with-deps webkit | |
# $ GITHUB_REPOSITORY_OWNER=octocat python playwright_github_stars_lists.py | |
import asyncio | |
import os | |
from contextlib import asynccontextmanager | |
import pandas as pd | |
from playwright.async_api import async_playwright | |
from playwright.async_api._generated import Browser, Locator |
This file contains 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
# View node and container resource requests, limits, and usage, grouped per node,namespace,pod,container | |
# | |
# Installation: | |
# pip install mapply pandas kubernetes sh | |
# brew install watch kubectl coreutils | |
# | |
# Usage: | |
# alias kubetop='watch -n4 python ~/Downloads/kubetop.py' | |
# kubetop |
This file contains 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 asyncio | |
from functools import wraps, partial | |
def run_in_executor(fn=None, *, executor=None): | |
"""Make a sync function async. By default uses ThreadPoolExecutor. | |
Args: | |
fn: Function to decorate. | |
executor: Executor pool to execute fn in. |
This file contains 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
"""Interact with Doccano Sequence Labelling projects. | |
Trains on checked (approved) annotations, pushes back predictions for unchecked annotations. | |
### Notes | |
- Doccano might implement active learning themselves in the future: https://github.com/doccano/doccano/issues/191 | |
- To support multilingual NER projects, split_sentence() below uses polyglot, which in turn requires PyICU. |
This file contains 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 python | |
import zipfile | |
from pathlib import Path | |
def zipdir(src, dest=None, glob='*', **kwargs): | |
"""Zip contents of src directory into dest. | |
Args: | |
src: source directory path-like |
This file contains 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 translitcodec | |
def print_variations(x): | |
print(x) | |
print(translitcodec.short_encode(x)[0]) | |
print(translitcodec.long_encode(x)[0]) | |
print_variations("Gesellschaft mit beschränkter Haftung") | |
print_variations("Société Privée à Responsabilité Limitée") | |
print_variations("Shoqëri me përgjegjësi të kufizuar") |
This file contains 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
"""Convert ipynb file to py file from CLI. | |
Usage: | |
python ./convert_ipynb_to_py.py [full input path] [full output path] | |
!! overwrites output path without warning if it exists !! | |
""" | |
import sys | |
import json |
This file contains 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 boto3 | |
import logging | |
import os | |
import pprint | |
import xmltodict | |
pp = pprint.PrettyPrinter(depth=3).pprint | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.DEBUG) |