Skip to content

Instantly share code, notes, and snippets.

View DahlitzFlorian's full-sized avatar
🎯
Focused

Florian Dahlitz DahlitzFlorian

🎯
Focused
View GitHub Profile
@DahlitzFlorian
DahlitzFlorian / Dockerfile
Last active March 23, 2019 19:22
Run Python application as non-root in Docker - Pipenv
FROM python:3.7.2-alpine
RUN pip install --upgrade pip
RUN adduser -D worker
USER worker
WORKDIR /home/worker
RUN pip install --user pipenv
@DahlitzFlorian
DahlitzFlorian / Dockerfile
Last active March 31, 2022 10:56
Run Python application as non-root in Docker - requirements.txt
FROM python:3.7.2-alpine
RUN pip install --upgrade pip
RUN adduser -D worker
USER worker
WORKDIR /home/worker
COPY --chown=worker:worker requirements.txt requirements.txt
RUN pip install --user -r requirements.txt
import click
from tool import __version__
from tool.custom_decorators import add_version
@click.group()
@click.version_option(
__version__, "-V", "--version", message="%(prog)s, version %(version)s"
)
"""
A module including custom decorators.
"""
from . import __version__
def add_version(f):
"""
Add the version of the tool to the help heading.
import click
from tool import __version__
@click.group()
@click.version_option(
__version__, "-V", "--version", message="%(prog)s, version %(version)s"
)
@click.pass_context
"""
Tool.
Example tool.
"""
__version__ = "1.2.3"
import dis
def f_string(number: int):
return f"{number}"
def str_string(number: int):
return str(number)
from boxx import timeit
with timeit(name="f-strings"):
for i in range(500_000):
x = 6
f"{x}"
with timeit(name="str"):
for i in range(500_000):
# Some more code above
val = 6
value = f"{val}"
# some more code
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6m/config-3.6m-darwin/libpython3.6.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/include/python3.6m/ \
-D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \