Skip to content

Instantly share code, notes, and snippets.

View nilreml's full-sized avatar
💾
Core dump in progress

Merlin nilreml

💾
Core dump in progress
  • Hamburg, Germany
  • 14:36 (UTC +02:00)
View GitHub Profile
Render markdown cells:
from IPython.display import display, Markdown
display(Markdown(...)) # e.g. df.to_markdown()
Pretty print tensors:
import lovely_tensors as lt
lt.lovely(...)
Requirements:
# Monkeypatch pytorch to run kernel autotuning on non-enterprise CUDA GPUs
# until https://github.com/pytorch/pytorch/issues/109489 is resolved:
import sys
def uncache(exclude):
"""Remove package modules from cache except excluded ones.
On next import they will be reloaded.
Args:
@nilreml
nilreml / docker
Last active April 17, 2024 17:33
Fast one-liner in current dir:
docker run -v $PWD:$PWD -w $PWD --net=[host|none] image cmd
Verbose docker info:
docker system df -v
Delete all build cache:
docker builder prune -af
check for bash version 4+ (POSIX-compliant) :
[ -z "${BASH_VERSINFO}" ] || [ -z "${BASH_VERSINFO[0]}" ] || [ ${BASH_VERSINFO[0]} -lt 4 ]
path to script even if symlinked:
SCRIPT_DIR="$( cd -P "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" >/dev/null 2>&1 && pwd )"
# Best practice pyproject.toml:
# https://github.com/airbytehq/airbyte/blob/master/airbyte-lib/pyproject.toml
[tool.coverage.run]
include = ["src/*"]
parallel = true
branch = true
[tool.coverage.paths]
@nilreml
nilreml / poetry
Last active March 25, 2024 10:59
Bash completions:
mkdir -p ${XDG_DATA_HOME:-~/.local/share}/bash-completion/completions
poetry completions bash > ${XDG_DATA_HOME:-~/.local/share}/bash-completion/completions/poetry
Enter virtual environment:
poetry shell
Exit virtual environment:
exit
browser.compactmode.show true
browser.search.region EN
browser.tabs.insertAfterCurrent true
browser.tabs.loadBookmarksInBackground true
browser.tabs.loadBookmarksInTabs true
browser.tabs.tabClipWidth 10000
browser.toolbars.bookmarks.visibility always
browser.translations.neverTranslateLanguages de
browser.uidensity 1
full-screen-api.transition.timeout 0
Slow apt search:
rm /etc/apt/apt.conf.d/docker-gzip-indexes
rm /var/lib/apt/lists/*.lz4
apt update
Apt cache & non-interactive config:
ARG DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# hadolint ignore=DL3008,DL3014
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt/lists \
# Use german apt mirror
APT mirror:
sed -i -- 's/deb.debian.org/mirror.netcologne.de/g' /etc/apt/sources.list.d/*
APT components:
main contrib non-free non-free-firmware -> see end
APT external repos:
apt install extrepo
sed -i -E "s/# (- (contrib|non-free))/\1/g" /etc/extrepo/config.yaml
apt update