Skip to content

Instantly share code, notes, and snippets.

@CzechJiri
CzechJiri / podcast_copy.sh
Last active July 20, 2026 13:56
I love listening to podcasts while swimming with my Shokz OpenSwim Pro, but it has no Bluetooth/streaming — I have to load MP3s onto it directly. Apple Podcasts already downloads episodes locally for offline playback, but buries them in an obscure app cache folder with no filenames to speak of. This script digs those MP3s out of Apple Podcasts' …
#!/usr/bin/env python3
"""
Copies MP3 files created/modified in the last 2 hours from the Apple
Podcasts local cache into ~/Downloads/Podcasts, renamed to
"Author - Podcast Name.mp3" using each file's ID3 tags.
Any existing .mp3 files in the destination folder are deleted first.
"""
import argparse
import json
@CzechJiri
CzechJiri / run.sh
Created July 16, 2020 19:53
openVPN server Let's Encrypt renewal via single command line
certbot certonly --standalone \
--non-interactive \
--preferred-challenges tls-sni \
--agree-tos \
--email hostmaster@mydomain.com \
--domains vpn.mydomain.com \
--pre-hook '/usr/local/openvpn_as/scripts/sacli stop' \
--post-hook '/usr/local/openvpn_as/scripts/sacli --key "cs.priv_key" --value_file "/etc/letsencrypt/live/office.deep-labs.com/privkey.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli --key "cs.cert" --value_file "/etc/letsencrypt/live/office.deep-labs.com/cert.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli --key "cs.ca_bundle" --value_file "/etc/letsencrypt/live/office.deep-labs.com/fullchain.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli start'

Keybase proof

I hereby claim:

  • I am czechjiri on github.
  • I am czechjiri (https://keybase.io/czechjiri) on keybase.
  • I have a public key ASACq5_vCcvs6OfAcIuzbClI4oKCmHFERAMW6Ml2pNGdlgo

To claim this, I am signing this object:

@CzechJiri
CzechJiri / datetime.py
Created May 25, 2017 16:23
my ideal date format for python logging with no spaces, commas or missing timezone
from datetime import datetime, timezone
print( datetime.now(timezone.utc).isoformat() )
@CzechJiri
CzechJiri / wait-for-it postgres style
Last active June 24, 2016 20:55
running application and DB using docker-compose.yml is tricky, because app will not wait for DB to be fully up and read to accept connections (docker-compose.yml only deals with dependencies). This function can be part of application entrypoint script, it waits up to 30 seconds for postgres to start. It uses pg_isready (works even without passwo…
function pg_ready()
{
waitTime=30 # keep trying for x seconds
n=0
until [ $n -ge $waitTime ]; do
# please note pg_isready does not care about username/dbname
# you can add correct values if you want to avoid errors in PG log
pg_isready --host=$DB_HOST --port=$DB_PORT && break