Skip to content

Instantly share code, notes, and snippets.

@epakai
epakai / close_matching_vim_buffers
Created January 17, 2023 20:42
Close all vim buffers with files under a path
Your vim needs to be compiled with clientserver support. You can check:
vim --version|grep +clientserver
Set up an alias so regular vim starts with a server (add it to your shell aliases):
alias vim='vim --servername "VIM"'
@epakai
epakai / Makefile
Last active June 28, 2020 01:57
Org mode publishing with code evaluation
LMAKE = latexmk
LMAKE_OPTIONS = -xelatex -pdfxe
LMAKE_PREVIEW = -xelatex -interaction=nonstopmode -pdfxe -pvc
ORG_FILES = $(shell find src/ -type f -name '*.org')
IMAGES = src/images/network.png src/images/backup.png
all: html system.pdf
.PHONY: clean html tex preview
@epakai
epakai / kobo_categorize.py
Last active November 6, 2018 03:08
Categorize (or Collection-ize) your kobo ebooks by the directory's they're contained in. Tested on kobo mini and kobo aura one.
#!/usr/bin/env python3
# usage ./kobo_categorize.py /path/to/kobo/mountpoint
# A backup of the kobo database is placed in your home directory before modification
# Script to add ebooks to the kobo reader sqlite db categories based on their
# directory structure
# Example:
# animals/giraffes/The Tallest Mammal.epub
# would be categorized in both animals and giraffes category
# animals/Fauna of the Nile.epub
@epakai
epakai / devhelp2epub.py
Created November 3, 2018 14:16
Generate epub files from Devhelp documentation
#!/usr/bin/env python3
# Generates epub given a .devhelp2 file.
# Run this to generate epub for all installed devhelp files on a Debian system:
# for i in $(locate .devhelp2|grep ^\/usr\/share); do ./devhelp2epub.py $i; done
import argparse, os, hashlib, locale, collections, sys, zipfile, tempfile, shutil
import xml.etree.ElementTree as ET
from ebooklib import epub
import ebooklib
ns = {'devhelp': 'http://www.devhelp.net/book'}
@epakai
epakai / #Sample output
Last active November 3, 2018 14:17
Document LaTeX \usepackage lines with CTAN caption in Vim. Requires one package per line.
\usepackage{fancyhdr} % Extensive control of page headers and footers in LaTeX2e
\usepackage{enumitem} % Control layout of itemize, enumerate, description
\usepackage{multicol} % Intermix single and multiple columns
\usepackage{multirow} % Create tabular cells spanning multiple rows
\usepackage{mathtools} % Mathematical tools to use with amsmath
\usepackage{amsthm} % Typesetting theorems (AMS style)
\usepackage{amssymb} %
\usepackage{amsfonts} % TeX fonts from the American Mathematical Society
\usepackage{graphicx} % Enhanced support for graphics