Skip to content

Instantly share code, notes, and snippets.

@kl
kl / yt_dlp_save_playlist.py
Last active November 22, 2023 15:43
yt_dlp plugin to create a m3u playlist when downloading a playlist. #ytdlp-plugins
# Plugin that creates an m3u playlist of the downloaded videos in the order
# they are downloaded. The m3u is named after the playlist and put in the
# output directory.
import os
# ⚠ Don't use relative imports
from yt_dlp.postprocessor.common import PostProcessor
# ℹ️ See the docstring of yt_dlp.postprocessor.common.PostProcessor
class SavePlaylistPP(PostProcessor):
[
{
"name": "NHK FM",
"status": "ACTIVE",
"country_code": "jp",
"country_name": "Japan",
"streams": [
{
"quality": 0,
"url": "https://nhkradioakfm-i.akamaihd.net/hls/live/512290/1-fm/1-fm-01.m3u8"
@kl
kl / .Xmodmap
Created June 25, 2017 07:55
Xmodmap
!
! Make Caps_Lock a Control_L
!
remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L
!
! Swap Mod1 and Mod5
!
@kl
kl / safe_navigation_operator.rb
Last active August 29, 2015 14:02
Hacking the Groovy Safe Navigation Operator in Ruby
class Object
# Given a method name that ends with ¤ call the method name without ¤.
# If the method (excluding ¤) is not found call BasicObject#method_missing,
# unless self is nil, in which case nil is returned.
#
# If the original method is the single character "¤" and self is nil,
# return the first argument. This is the "Elvis" operator.
#
# Examples:
@kl
kl / guesser.rb
Last active September 14, 2016 13:48
test
require 'open-uri'
def decipher_function_name_pattern
# Find "C" in this: var A = B.sig || C (B.s)
/
\.sig
\s*
\|\|
(\w+)
\(
@kl
kl / decipherer.rb
Created February 18, 2014 13:00
Youtube signature dechipherer
class Decipherer
class UnknownCipherVersionError < StandardError; end
class UnknownCipherOperationError < StandardError; end
# Big credit to http://www.jwz.org/hacks/youtubedown
CIPHERS = {
'vflNzKG7n' => 's3 r s2 r s1 r w67', # 30 Jan 2013, untested
'vfllMCQWM' => 's2 w46 r w27 s2 w43 s2 r', # 15 Feb 2013, untested
'vflJv8FA8' => 's1 w51 w52 r', # 12 Mar 2013, untested
@kl
kl / tmux-dev
Created November 6, 2013 12:51
tmux-development
tmux has-session -t development
if [ $? != 0 ]
then
tmux new-session -s development -n editor -d
tmux send-keys -t development 'cd ~/Programming' C-m
tmux send-keys -t development 'vim' C-m
tmux split-window -h -p 35 -t development
tmux split-window -v -p 50 -t development
tmux send-keys -t development:1.2 'cd ~/Programming' C-m
tmux send-keys -t development:1.3 'cd ~/Programming' C-m
@kl
kl / .tmux.conf
Last active February 21, 2020 08:37
tmux.conf
# Enable 256 color mode
set -g default-terminal "screen-256color"
# Disable mouse
set -g mouse off
# Set the prefix from C-b to C-a
set -g prefix C-a
unbind C-b
@kl
kl / .vimrc
Created November 6, 2013 12:49
vimrc
execute pathogen#infect()
autocmd vimenter * if !argc() | NERDTree | endif
set expandtab
set hidden
set number
set shiftwidth=2
set softtabstop=2
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Event [
<!ELEMENT Event (EventName, Race*)>
<!ELEMENT Race (RaceNumber, RaceDistance, RaceComment?, Horse*)>
<!ELEMENT EventName (#PCDATA)>
<!ELEMENT RaceNumber (#PCDATA)>
<!ELEMENT RaceDistance (#PCDATA)>
<!ELEMENT RaceComment (#PCDATA)>
<!ELEMENT Horse (HorseName, Teamster, HorseComment?)>