Skip to content

Instantly share code, notes, and snippets.

View tiesjan's full-sized avatar

Ties Jan Hefting tiesjan

  • Utrecht, The Netherlands
  • 04:38 (UTC +02:00)
View GitHub Profile
@tiesjan
tiesjan / DeleteCommentTags.yaml
Created September 25, 2025 17:21
MusicBrainz Picard script for deleting comments
id: a0e720df-89da-4b4a-a6a7-6c3ecc4af2c1
title: Delete comment tags
script_language_version: '1.1'
script: |
$delete(comment)
$delete(comment:ID3v1 Comment)
@tiesjan
tiesjan / _middleware.ts
Created July 5, 2024 19:15
HTTP Basic authentication for Cloudflare Pages
/*
* Cloudflare Pages middleware function for enforcing HTTP Basic authentication.
*
* Usage:
* 1. Add this file to the `functions` directory in your Pages repository.
* 2. Enable Node.js for your Pages functions through the dashboard:
* https://developers.cloudflare.com/workers/runtime-apis/nodejs/#enable-nodejs-from-the-cloudflare-dashboard
* 3. Set the following environment variables:
* - HTTP_BASIC_AUTH_USERNAME for the expected username.
* - HTTP_BASIC_AUTH_PASSWORD for the expected password.
@tiesjan
tiesjan / config_system.py
Created August 21, 2023 15:45
pgAdmin system configuration (/etc/pgadmin)
# Allow saving of tunnel passwords
ALLOW_SAVE_TUNNEL_PASSWORD = True
@tiesjan
tiesjan / europython_2023_schedule.md
Last active September 25, 2025 17:22
EuroPython 2023 Schedule
Time Talk
10:45 How we are making CPython faster. — Forum Hall
11:35 How we are supercharging f-strings in Python 3.12 — Forum Hall
12:10
14:00 CPython Core Developer Panel — Forum Hall
15:30 Dynamically generated methods with a non-generic signature — Forum Hall
16:05 DuckDB: Bringing analytical SQL directly to your Python shell — Terrace 2B
@tiesjan
tiesjan / europython_2022_schedule.md
Created July 11, 2022 13:45
EuroPython 2022 Schedule

Wednesday, July 13

Time Talk
10:45 Making Python better one error message at a time — The Auditorium
11:35 Booth shift
12:10 CPython bugs & risky features — The Auditorium
14:00 Protocols in Python: Why You Need Them — Liffy B
14:35 Dance with shadows: stubs, patch and mock — Liffey Hall 2
15:30 Booth shift
@tiesjan
tiesjan / discogs_api_client.py
Created March 13, 2022 09:30
Basic Python API client for Discogs
from json.decoder import JSONDecodeError
from urllib.parse import urljoin
import requests
class DiscogsAPIClientAuth(requests.auth.AuthBase):
"""
Authentication class used for authenticating requests using required
Discogs API access token.
@tiesjan
tiesjan / url_regex.py
Last active October 13, 2021 12:30
Simple URL regular expression (based on Django's URL validator)
import re
re.compile(
# Pattern
r'^'
r'(?:https?:\/\/)' # scheme
r'(?:(?!-)[a-z' + '\u00a1-\uffff' + r'0-9-]{1,63}(?<!-)\.)+' # domain
r'(?:(?!-)(?:[a-z' + '\u00a1-\uffff' + r'-]{2,63}|xn--[a-z0-9]{1,59})(?<!-)\.?)' # TLD
r'(?:[/?#][^\s]*)?' # path, query & fragment
r'$',
@tiesjan
tiesjan / url_regex.js
Last active October 13, 2021 12:30
Simple URL regular expression (based on Django's URL validator)
new RegExp(
// Pattern
"^" +
"(?:https?:\\/\\/)" + // scheme
"(?:(?!-)[a-z\\u00a1-\\uffff0-9-]{1,63}(?<!-)\\.)+" + // domain
"(?:(?!-)(?:[a-z\\u00a1-\\uffff-]{2,63}|xn--[a-z0-9]{1,59})(?<!-)\\.?)" + // TLD
"(?:[/?#][^\\s]*)?" + // path, query & fragment
"$",
// Flags
"i"
@tiesjan
tiesjan / convert_heic.bash
Created August 13, 2021 13:05
Convert HEIC files to JPEG
# Ignore case when globbing files
shopt -s nocaseglob
# Convert all HEIC files found in the current directory
for file in $(compgen -G "*.heic"); do
echo "Converting HEIC file ${file}..."
# Remove extension using parameter expansion
# (see: https://stackoverflow.com/a/12152997)