Skip to content

Instantly share code, notes, and snippets.

@cn-ml
cn-ml / ffmcheck.py
Last active August 3, 2021 20:23
ffmpeg based video checking tool, accepts files as CLI args and runs ffmpeg for all files (now with file globbing).
#!/usr/bin/python3
import sys
import subprocess
import glob
from yachalk import chalk
def test_file(file):
proc = subprocess.Popen(['ffmpeg', '-v', 'error', '-i', file, '-f', 'null', '-'], stderr=subprocess.PIPE, shell=True)
line = proc.stderr.readline()
@cn-ml
cn-ml / foreach.py
Created March 22, 2023 16:45
Python script for executing a command for every file (similar to linux "find -exec" command)
from argparse import REMAINDER, ArgumentParser, BooleanOptionalAction
from pathlib import Path
from subprocess import run
from typing import Sequence
class ProgramException(Exception):
pass
def parse_args():
@cn-ml
cn-ml / .gitlab-ci.yml
Created April 18, 2023 17:13
Build LaTeX document using Gitlab CI Docker Executor
image: mfisherman/texlive-full:2022
stages:
- build
build-job:
stage: build
script:
- latexmk -interaction=nonstopmode -file-line-error -pdf main
artifacts:
@cn-ml
cn-ml / .dockerignore
Created April 19, 2023 00:42
release-cli multi-platform build script
Dockerfile
.dockerignore
build.py
### .gitignore
# Ignore binaries, cover profiles and build files
*.out
.tmp
builds/
@cn-ml
cn-ml / pre-commit-schema.py
Created May 25, 2023 12:35
Generate the pre-commit schema file dyamically.
from __future__ import annotations
from enum import Enum
from typing import Literal, Optional, Type, TypeAlias, get_args
from pydantic import BaseModel, Extra, Field
from identify.identify import ALL_TAGS
IdentifyTypes = Enum("IdentifyTypes", {tag: tag for tag in ALL_TAGS})
IdentifyTypesLiteral: TypeAlias = Literal["gherkin", "zsh", "adobe-illustrator", "markdown", "gitmodules", "edn", "dart", "bazel", "gitlint", "mention-bot", "terraform", "dockerignore", "dtd", "xquery", "ino", "php8", "makefile", "ts", "idris", "audio", "woff2", "inc", "c++", "verilog", "yaml", "ttf", "geojson", "system-verilog", "python3", "yamlld", "scss", "txsprofile", "eps", "png", "gitconfig", "sln", "pem", "ngdoc", "rust", "haskell", "awk", "m4", "bazelrc", "spec", "c2hs", "purescript", "flake8", "ocaml", "vim", "nunjucks", "nimble", "vdx", "less", "groovy", "aspectj", "toml", "css", "def", "objective-c", "jsonnet", "gitignore", "babelrc", "wkt", "plantuml", "vue", "bib", "swf", "xhtml", "browserslistrc", "text", "pkgbuild", "myst",
@cn-ml
cn-ml / .releaserc.schema.json
Last active May 30, 2023 05:14
.releaserc Schema
{
"title": "ReleaseRC",
"type": "object",
"properties": {
"extends": {
"title": "Extends",
"description": "List of modules or file paths containing a shareable configuration. If multiple shareable configurations are set, they will be imported in the order defined with each configuration option taking precedence over the options defined in a previous shareable configuration.",
"anyOf": [
{
"type": "string"
@cn-ml
cn-ml / backup.py
Last active August 9, 2024 12:17
Docker container database backup script
#!/usr/bin/env python3
from __future__ import annotations
from argparse import OPTIONAL, ArgumentParser
from datetime import datetime
from functools import wraps
from gzip import compress, decompress
from pathlib import Path
from re import compile
from subprocess import PIPE, run
from typing import (