Skip to content

Instantly share code, notes, and snippets.

View chriskempson's full-sized avatar
😵
Eternally busy

Chris Kempson chriskempson

😵
Eternally busy
View GitHub Profile
@chriskempson
chriskempson / script.sh
Last active August 11, 2023 06:23
Play Youtube audio CLI (yt-dlp, ffmpeg)
yt-dlp -f bestaudio "https://www.youtube.com/watch?v=jfKfPfyJRdk" -o - 2>/dev/null | ffplay -nodisp -autoexit -i - &>/dev/null
@chriskempson
chriskempson / youtube-dl-playlist-audio.sh
Last active February 12, 2020 22:14
Download audio files from a YouTube playlist
#!/bin/sh
# Downloads a YouTube playlist and coverts it to 320kbps MP3 with
# embedded thumnails, metadata and proper track naming.
#
# Example usage:
#
# ./youtube-dl-playlist-audio.sh https://www.youtube.com/playlist?list=PLFgquLnL59alxIWnf4ivu5bjPeHSlsUe9
#
# MP3 320 kbps
@chriskempson
chriskempson / willmollywilly-assist.user.js
Last active August 3, 2019 20:00
A little JS and CSS to clean up WillMollyWilly and add a couple of navigational buttons for a more pleasant reading experience.
// ==UserScript==
// @name WillMollyWilly Assist
// @author Chris Kempson (chriskempson.com)
// @version 1.0.0
// @match *://blogs.yahoo.co.jp/willmollywilly*
// @grant none
// ==/UserScript==
// Replaces ----... with <hr>, adds class to sentence numbers, adds class
// to separators (***... and *...)
@chriskempson
chriskempson / willmollywilly-clean.md
Last active July 23, 2019 10:11
Cleans up WillMollyWilly

Clean up WillMollyWilly

A little JS and CSS to clean up WillMollyWilly and add a couple of navigational buttons for a more pleasant reading experience.

Grab a browser extension such as User JavaScript and CSS and copy the JS and CSS into the relevent fields.

Javascript

// Replaces ----... with <hr>, adds class to sentence numbers, adds class
// to separators (***... and *...)
@chriskempson
chriskempson / video2audio.sh
Last active May 24, 2020 08:54
Converts a directory of video files to audio files with ffmpeg
#!/bin/bash
# Convert a directory of videos to audio files
#
# ## Requirements
# bc, ffmpeg
#
# ## Usage
# Call from a directory containing videos:
#
@chriskempson
chriskempson / wget-mirror.sh
Created July 5, 2019 10:04
Mirror a Website with Wget
#!/bin/bash
wget --restrict-file-names=nocontrol --execute robots=off --convert-links --adjust-extension --page-requisites --no-parent --mirror $1
@chriskempson
chriskempson / vs-code-strip-attributes-from-html-tags.txt
Last active October 25, 2023 00:27
VS Code - Strip Attributes from HTML Tags
# Couldn't figure out how to do /s or get VS Code to search over newlines so came up with this convoluted mess '[\S\s]*?\n?' that matches all characters plus newlines
Search for: <(table|tr|td|p|div|span)[\S\s]*?\n?>
Replace with: <$1>
@chriskempson
chriskempson / anki-toggle-furigana.js
Last active April 1, 2022 20:33
Hidy ruby text (furigana) on Anki cards by default, touch or click to reveal ruby text.
// Paste this code at the bottom of your front template or back tempate (or
// both) and add a class="toggle-furigana" to an element to furigana text
// until clicked/touched. Afterwards, furigana will automatically be hidden
<script>for(var toggleRubyElements=document.getElementsByClassName("toggle-furigana"),i=0;i<toggleRubyElements.length;i++)for(var rubyElements=toggleRubyElements[i].getElementsByTagName("ruby"),j=0;j<rubyElements.length;j++){var rt=rubyElements[j].getElementsByTagName("rt")[0];rt.style.visibility="hidden",rubyElements[j].onclick=function(e){toggleRubyText(e.target)}}function toggleRubyText(e){var t=e.parentNode.getElementsByTagName("rt")[0];"hidden"==t.style.visibility?(t.style.visibility="visible",setTimeout(function(){t.style.visibility="hidden"},2e3)):t.style.visibility="hidden"}</script>
#!/usr/bin/env sh
title=$(echo $@ | grep -Po '(?<=copy ).+?(?=.ts)')
m3u8_url=$(echo $@ | grep -Po '(?<=-i ).+?\.m3u8')
if [ -z "$title" ] || [ -z "$m3u8_url" ]; then
echo "Please enter a valid ffmpeg command from http://kmake.net/gyaommsurl"
return
fi
echo "\nDownloading:\n$title\n\nFrom:\n$m3u8_url\n"
// ==UserScript==
// @name Netflix Study Assist
// @author Chris Kempson (chriskempson.com)
// @version 1.0.0 (2018-08-23)
// @grant none
// @include *netflix.com*
// ==/UserScript==
// TODO: Stop space from being clobbered on multiline subtitles for languages that use spaces