env GOOS=target-OS GOARCH=target-architecture go build package-import-path
# Example
env GOOS=darwin GOARCH=amd64 go build
env GOOS=darwin GOARCH=amd64 go build main.go
env GOOS=darwin GOARCH=amd64 go build github.com/zoo/york/foo/bar
""" | |
This gist shows how to run asyncio loop in a separate thread. | |
It could be useful if you want to mix sync and async code together. | |
Python 3.7+ | |
""" | |
import asyncio | |
from datetime import datetime | |
from threading import Thread | |
from typing import Tuple, List, Iterable |
import cProfile | |
def profileit(func): | |
""" | |
Decorator (function wrapper) that profiles a single function | |
@profileit() | |
def func1(...) | |
# do something | |
pass |
from glob import glob | |
import multiprocessing | |
from concurrent.futures import ProcessPoolExecutor | |
import cv2 | |
from PIL import Image | |
import imagehash | |
from tqdm import tqdm |
[package] | |
name = "test" | |
version = "0.1.0" | |
authors = ["YOU <YOU@users.noreply.github.com>"] | |
edition = "2018" | |
[lib] | |
crate-type = ["cdylib"] |
from threading import Lock | |
import os, os.path | |
try: | |
import dill as pickle | |
import dill.settings | |
from dill import FILE_FMODE | |
dill.settings.update({'byref': True, 'fmode': FILE_FMODE, 'recurse': True, 'ignore': True}) | |
except ImportError: | |
import pickle |
""" | |
Persistent queue | |
A permanent queue with saving to disk. It is restored on restart. | |
Only waiting new elements that have not yet been taken into operation will be restored. | |
Source: | |
Persistent Queue « Python recipes « ActiveState Code | |
https://code.activestate.com/recipes/579124-persistent-queue/ | |
PERSISTENT QUEUE (PYTHON RECIPE) |
#!/bin/bash | |
# | |
# This script encapsulates the functionality of a queue. It requires there to be | |
# an input file with the data in the queue being separated on different lines. | |
# | |
INPUT=queue.txt | |
OUTPUT=trash.txt | |
CMD=/usr/bin/vlc |
FROM docker.io/python:3.9-bullseye AS build | |
WORKDIR "/app" | |
# Install dependecies | |
# hadolint ignore=DL3008,DL3013 | |
RUN set -eux && \ | |
apt-get update; \ | |
apt-get install --no-install-recommends -y \ | |
python3-dev build-essential patchelf upx; \ | |
apt-get clean; \ |
/var/log/supervisor/*.log { | |
weekly | |
rotate 52 | |
compress | |
delaycompress | |
notifempty | |
missingok | |
copytruncate | |
} |