Skip to content

Instantly share code, notes, and snippets.

@BrianZbr
BrianZbr / txtImages2srt.sh
Created April 24, 2023 22:44
Create an SRT file from a VideoSubFinder TXTImages folder
#!/bin/bash
outfile="output.srt"
main(){
i=0
for filename in *.txt; do
no_unders="${filename//_}"
start_hour="${no_unders:0:1}"
start_min="${no_unders:1:2}"
start_sec="${no_unders:3:2}"
@BrianZbr
BrianZbr / main.py
Created February 13, 2023 23:05
Python3 script inspired by pyvobsub2srt, using Google Vision API as the OCR engine.
import os
import argparse
import requests
import json
import base64
from xml.dom.minidom import parse
def get_image_from_xml(nodelist):
rc = []
for node in nodelist:
@BrianZbr
BrianZbr / Dockerfile
Last active November 3, 2022 00:07
Arch-based Dockerfile for running dpsprep
# Dockerfile for running https://github.com/kcroker/dpsprep
# Steps to deploy:
# 1) in an empty folder with this Dokcerfile run:
# docker build . -t dps-arch
# 2) in a folder with the djvu file(s) you want to convert to PDF:
# sudo docker run --name dps-arch -d -it -v "$(pwd)":/files dps-arch
# 3) convert a file "infile.djvu" to "outfile.pdf":
# docker exec -it dps-arch dpsprep infile.djvu outfile.pdf
FROM archlinux:base-devel
@BrianZbr
BrianZbr / paste-quote.el
Created January 15, 2016 16:21
elisp function for pasting quotes from pdfs into org-mode documents
(defun my/paste-quote (pages)
"inserts and formats text from the clipboard, formatted for org-mode"
(interactive "sEnter page number\(s\): ")
;;;; convert clipboard to string
(setq quote
(with-temp-buffer
(yank)
(buffer-string)
))
;;;; remove newlines from string
# convert multipage pdf to single page tiff
gs -q -dNOPAUSE -dBATCH -sDEVICE=tiffg4 -sOutputFile=%04d.tif source.pdf -c qui
# or use -sDEVICE=pgmraw to convert to pgm
# unpaper, rotate the logical page 90 degrees, each logical page contained two scanned physical pages, so we use --layout double (for input) and --output-pages 2 since we want to split these two pages.
unpaper -v --deskew-scan-deviation 3.0 --border-align top --deskew-scan-range 15 --no-grayfilter --no-blurfilter --no-noisefilter --overwrite --pre-rotate 90 --border-scan-step 4 --layout double --output-pages 2 %04d.pgm.pbm unpaper%04d.pbm
# trim the pages and convert the to single-page pdfs
find . -name 'unpaper*' | xargs -i -n1 -P6 convert -trim +repage {} {}.pdf

Chapter Title

private notes

Don’t read this.

Introduction

This should appear directly after “Chapter Title”, not “Introduction”.