Tag « python »

python, conversion

Convert string to duration

I found myself wanting to convert a string to a duration (int), for some configuration.

Something you can call like this:

string_to_duration("1d", target="days") # returns 1
string_to_duration("1d", target="hours") # returns 24
string_to_duration("3m", target="hours") # returns 3 * 24 * 30

The code :

from typing import Literal


def string_to_duration(value …
python, llm, bash, sqlite

llm command-line tips

I’m using llm more and more, and today I had to find back prompts I used in the past. Here is a command I’ve been using, which allows me to filter the results based on what I want. It leverages sql-utils, a cli tool which is able to …

python, packaging, zsh

Python packaging with Hatch, pipx and Zsh environment variables

It’s been a while I didn’t packaged something new. I recently remembered an old package of mine that needed some attention : debts. It’s now time to package it, so I discovered hatch

hatch new —init

This does the heavy-lifting for you, actually porting the setup.py files …