Skip to content

Instantly share code, notes, and snippets.

View tarneaux's full-sized avatar

tarneo tarneaux

View GitHub Profile
@tarneaux
tarneaux / levenshtein.py
Last active January 24, 2024 20:44
Levenshtein and Damerau-Levenshtein distances in Python
# This is my (tarneaux's) implementation of the Levenshtein and Damerau-Levenshtein distances,
# in a recursive and non-optimized manner based on the formulas on Wikipedia.
# For more complete and/or optimized versions of them see:
# - https://github.com/TheAlgorithms/Python/blob/master/strings/levenshtein_distance.py
# - https://github.com/TheAlgorithms/Python/blob/master/strings/damerau_levenshtein_distance.py
# See https://en.wikipedia.org/wiki/Levenshtein_distance
def levenshtein(s1, s2):
if len(s1) == 0:
return len(s2)
@tarneaux
tarneaux / reorder_m3u.py
Created June 8, 2023 11:07
Reorder an m3u playlist with fzf
#!/usr/bin/env python3
# Reorder m3u playlist files with fzf
import os
import sys
import subprocess
from time import sleep
# Get the path to the m3u file
if len(sys.argv) == 2:
@tarneaux
tarneaux / bitwarden_to_pass.py
Last active May 21, 2023 15:26
Convert bitwarden CSV to GNU passwordstore
#!/usr/bin/env/python3
# Convert Bitwarden CSV export to pass format
import pandas
import os
import sys
import subprocess
# Check for correct number of arguments
@tarneaux
tarneaux / convert.py
Created August 25, 2022 19:30
Convert kitty theme to pywal theme
import json
import os
import re
from sys import argv
def get_kitty_theme():
with open(os.getenv('HOME') + '/.config/kitty/current-theme.conf', 'r') as f:
data = f.read()
return data