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 / Wordpress Replace URL's SQL
Last active October 12, 2015 20:58
Wordpress Replace URL's SQL
SET @old_url = 'old';
SET @new_url = 'new';
UPDATE wp_posts
SET post_content = REPLACE(post_content, @old_url, @new_url),
post_excerpt = REPLACE(post_excerpt, @old_url, @new_url),
guid = REPLACE(guid, @old_url, @new_url);
UPDATE wp_options
SET option_value = REPLACE(option_value, @old_url, @new_url)
#!/usr/bin/env sh
# jpsubbers-dl.sh - chriskempson.com
# Download all subtiles within a directory from http://jpsubbers.web44.net/Japanese-Subtitles/
#
# Usage:
# ./jpsubbers-dl.sh http://jpsubbers.web44.net/Japanese-Subtitles/まんぷく/
wget --restrict-file-names=nocontrol --no-directories -r -l 1 --accept="*.srt" -e robots=off $1
// ==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
#!/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"
@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>
@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 / 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 / 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 / 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 / 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 *...)