Skip to content

Instantly share code, notes, and snippets.

View blindstitch's full-sized avatar

Karl T blindstitch

View GitHub Profile
# Youtube filters for Ublock Origin
! Previews
i.ytimg.com/an_webp
youtube.com##ytd-thumbnail-overlay-loading-preview-renderer
youtube.com##.ytp-ce-element.ytp-ce-video.ytp-ce-element-show
youtube.com##.ytp-ce-element.ytp-ce-channel.ytp-ce-channel-this
youtube.com##.ytp-ce-element
youtube.com##.ytp-inline-preview-ui
youtube.com##.ytd-video-preview
@blindstitch
blindstitch / video-clip-gif.py
Last active November 26, 2021 16:13
Clip a range of frames from a video and turn them into a gif. PIL/cv2
import cv2
import random
import pathlib
from PIL import Image
src_path = 'pie.mp4' # Replace with your video
outfolder = 'temp' # Create folder before running
time_per_frame = 5 # Milliseconds? Reduce for faster speed
looping = 0 # 0 is looping for PIL
@blindstitch
blindstitch / friendships.ipynb
Last active November 26, 2021 16:14
Mostly incomplete experiments modeling the friendship paradox
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@blindstitch
blindstitch / ubuntu-desktop-slideshow.py
Last active March 3, 2021 23:06
Ubuntu desktop background slideshow XML generator that uses gsettings and a jinja2 template. Searches 1 level deep into subdirectories, will not see files at root level of script
import os
import subprocess
from jinja2 import Template
import pathlib
from glob import glob
import random
# Utility
list_collapse = lambda l: [item for sublist in l for item in sublist]
def randname(len=8):
@blindstitch
blindstitch / autocrop.py
Last active March 15, 2021 18:37
Crop white borders from images - numpy, pillow
import numpy
from PIL import Image
from matplotlib.colors import rgb_to_hsv
minions = Image.open('minons_test_autocrop_lossy.jpg')
def autocrop(image,thresh_v=255,thresh_s=.01,pad=0):
a = numpy.asarray(image)
hsv = rgb_to_hsv(a.take([0,1,2],axis=2))
@blindstitch
blindstitch / cmus-music-adder.py
Last active March 19, 2020 02:11
Adds music to cmus with a very simple keyboard interface, some smart defaults, index cache generation.
import subprocess
from argparse import ArgumentParser
import os
# Bad code deal with it
# run with -fc to generate your indexes
# Modify these paths to match your root folder for music
os.chdir('/kt/media/music/downloads')
filelist_path = '/kt/media/music/downloads/.index_files'
@blindstitch
blindstitch / build.vim
Last active December 2, 2019 17:03
Execute python or r code in vim
" Run standard compile/run commands
function! RunBuildCommand()
" Choose between python3, Rscript based on extension
w
cd %:p:h
let filename = expand('%t')
let extension = expand('%:e')
let basename = expand('%:r')
" rscript