Skip to content

Instantly share code, notes, and snippets.

View mikeri's full-sized avatar

Michael Ilsaas mikeri

View GitHub Profile
@mikeri
mikeri / xattr_metadata.py
Last active January 5, 2024 23:59
Ranger plugin for storing metadata in extended file attributes
# Ranger plugin for storing metadata in extended file attributes
# Requires Python 3.3
# drop it in ~/.config/ranger/plugins
from ranger.ext.openstruct import DefaultOpenStruct as ostruct
import ranger.core.metadata
import os
def get_metadata(_, filename):
@mikeri
mikeri / cssembed.py
Created May 6, 2022 08:01
CSS image/file embedder (generates data uri)
import base64
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("file")
args = parser.parse_args()
mime_args = ("mimetype", "-b", args.file)
mime_type = subprocess.run(mime_args, capture_output=True).stdout.decode().strip()
@mikeri
mikeri / ocr-copy.sh
Last active June 27, 2021 21:38
Mark an area of the screen, convert it to text and put the text in clipboard
#!/bin/bash
sleep .1
scrot --select /tmp/ocr.png
tesseract -c page_separator="" /tmp/ocr.png /tmp/ocr-out
xclip -selection clipboard -i < /tmp/ocr-out.txt
rm /tmp/ocr.png
rm /tmp/ocr-out.txt
@mikeri
mikeri / scc.zsh-theme
Last active May 18, 2020 11:20
SCC zsh theme
RPROMPT='$(git_prompt_info)%F{yellow}%n%{$reset_color%}%F{240}@%F{blue}%m%{$reset_color%}%(?,,%F{red} [%?]%{$reset_color%})'
PROMPT='%F{240}%25<...<%F{cyan}%~%F{yellow}%B>%b%{$reset_color%}%f '
ZSH_THEME_GIT_PROMPT_PREFIX="%F{240}(%F{246}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%F{240})%F{red}x%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%F{240})%{$reset_color%}"
@mikeri
mikeri / mutool-pdf.thumbnailer
Created May 11, 2019 12:14
PDF thumbnailer for freedesktop.org using mutool. Very fast.
[Thumbnailer Entry]
TryExec=mutool
Exec=mutool draw -w %s -h %s -o %o %i 1
MimeType=application/pdf;application/x-pdf;image/pdf;
@mikeri
mikeri / sp-download.sh
Last active July 4, 2018 20:10
South Park downloader
#!/bin/bash
# South Park download script
#
# Uses youtube-dl and ffmpeg
#
# Downloads the whole series
# and joins the multipart
# episodes into single files
for season in `seq 1 22`:
@mikeri
mikeri / imagemagick-pdf.thumbnailer
Created May 28, 2018 10:09
PDF thumbnailer for freedesktop.org using ImageMagick (for users without Evince)
[Thumbnailer Entry]
TryExec=convert
Exec=convert -alpha deactivate %i[0] -thumbnail %s %o
MimeType=application/pdf;application/x-pdf;image/pdf;
@mikeri
mikeri / ilbm.thumbnailer
Created May 28, 2018 10:07
ILBM/Amiga IFF thumbnailer for freedesktop.org
[Thumbnailer Entry]
TryExec=convert
Exec=convert %i -thumbnail %s %o
MimeType=image/x-ilbm;
@mikeri
mikeri / userContent.css
Last active November 15, 2017 19:53
userContent.css to fix checkmarks and input fields in Firefox running on dark themed Linux
/* ~/.mozilla/firefox/XXXXXX.default/chrome/userContent.css */
input {
border: 2px inset white;
background-color: white;
color: black;
-moz-appearance: none !important;
}
textarea {
border: 2px inset white;