Skip to content

Instantly share code, notes, and snippets.

@sebastian-berlin-wmse
sebastian-berlin-wmse / time-diff.py
Created April 11, 2025 08:31
Calculate difference between two timestamps
#! /usr/bin/env python
"""Calculate time difference between two timestamps
First argument is the "from" time and second is the "to" time. Format should
be anything that works with `datetime.fromisoformat`
(https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat).
"""
from datetime import datetime
@sebastian-berlin-wmse
sebastian-berlin-wmse / venv
Last active May 30, 2024 15:18
Setup and run venv
#! /usr/bin/env bash
# Add the following to .bashrc to make this work:
# alias venv=". venv"
source .venv/bin/activate && return 0
read -p "Create venv in .venv/? [y/N] " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then