Skip to content

Instantly share code, notes, and snippets.

@kernc
kernc / minify.sh
Created February 28, 2022 01:07
Minify HTML / CSS / JS resources in a directory (crude and clumsy)
#!/bin/bash
set -eux
# DANGER THROUGHOUT
dir="${1:-output}"
# Consecutive whitespace
find "$dir" -type f -regex '.*\.\(html\|js\|css\)$' -exec sed -i -E -e 's/^\s+//g' \
@kernc
kernc / yt_playlist_import.py
Last active September 22, 2019 15:53
Import local M3U file list as YouTube playlist
"""
Import local M3U playlists into YouTube as playlist.
The script accepts one argument, path to an M3U playlist, such as one produces with:
find mp3/genre/directory -type f > My_genre_name_playlist_name.m3u
It then searches for the best video match to each item in the playlist
and adds it to a newly created PRIVATE YouTube playlist bearing the
M3U playlist file name.
@kernc
kernc / skytorrents.py
Created June 11, 2018 16:05
SkyTorrents.lol search plugin for qBittorrent
# -*- coding: utf-8 -*-
#VERSION: 2.0
#AUTHORS: Joost Bremmer (toost.b@gmail.com)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kernc
kernc / audiobook-volume-amplifier.sh
Last active April 30, 2016 11:55
Increase the volume -- and impair the quality -- of your audiobooks
#!/bin/bash
set -e
if [ $# != 0 ]; then
echo "Usage: $(basename "$0")
This program accepts no arguments. It takes all the *.mp3 files
in the current directory and makes them louder by first detecting
their mean and max volumes and then amplifying the mean volume by
@kernc
kernc / test_doctests.py
Last active February 6, 2016 14:35
unittest.TestSuite module that recursively loads all doctests from my package
"""
unittest.TestSuite module that recursively loads all doctests from my package
"""
from doctest import DocTestSuite, ELLIPSIS, NORMALIZE_WHITESPACE
SKIP_DIRS = (
'MyPackage/unimportable-modules/',
'MyPackage/skip_this_too',
@kernc
kernc / gtk_menu_hierarchy.py
Created September 1, 2014 21:15
Constructing multi-level GtkMenu by example of time zone hierarchy.
""" Constructing multi-level GtkMenu by example of time zone hierarchy.
The example below is missing a GtkWindow and a gtk.main() to work."""
import gtk
from collections import defaultdict
from commands import getoutput
def autovivified():
return defaultdict(autovivified)
@kernc
kernc / null.py
Last active July 14, 2022 09:53
Null object pattern (Python)
"""
This module provides the Null class for the null object design pattern.
"""
from collections import MutableMapping, MutableSequence
class _MetaNull(type): pass
class Null(type):
"""Null object design pattern.