mirror of
https://github.com/kmein/niveum
synced 2026-03-20 03:51:07 +01:00
feat: 256color + countdown + pdf-ocr.sh
This commit is contained in:
38
.bin/256color
Executable file
38
.bin/256color
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
set -euf
|
||||||
|
|
||||||
|
pl() {
|
||||||
|
for i in $(seq $1 $(expr $2 - 1)); do
|
||||||
|
printf '\e[38;5;%sm%03i\e[m ' $i $i
|
||||||
|
done
|
||||||
|
printf '\e[38;5;%sm%03i\e[m\n' $2 $2
|
||||||
|
}
|
||||||
|
|
||||||
|
p() {
|
||||||
|
printf '\e[38;5;%sm%03i\e[m ' $1 $1
|
||||||
|
}
|
||||||
|
pn() {
|
||||||
|
printf '\e[38;5;%sm%03i\e[m\n' $1 $1
|
||||||
|
}
|
||||||
|
|
||||||
|
p6x6() {
|
||||||
|
for i in $(seq 0 5); do
|
||||||
|
for j in $(seq 0 5); do
|
||||||
|
p $(expr $1 + $i + $j \* 6)
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
pl 0 7
|
||||||
|
pl 8 15
|
||||||
|
|
||||||
|
p6x6 16
|
||||||
|
p6x6 52
|
||||||
|
p6x6 88
|
||||||
|
p6x6 124
|
||||||
|
p6x6 160
|
||||||
|
p6x6 196
|
||||||
|
|
||||||
|
pl 232 243
|
||||||
|
pl 244 255
|
||||||
13
.bin/countdown
Executable file
13
.bin/countdown
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env -S awk -f
|
||||||
|
function z() {
|
||||||
|
getline < "/proc/uptime"
|
||||||
|
close("/proc/uptime")
|
||||||
|
return $0
|
||||||
|
}
|
||||||
|
BEGIN {
|
||||||
|
x = z()
|
||||||
|
while (1) {
|
||||||
|
y = z()
|
||||||
|
printf "%02d:%05.2f\r", (y - x) / 60, (y - x) % 60
|
||||||
|
}
|
||||||
|
}
|
||||||
23
.bin/pdf-ocr.sh
Executable file
23
.bin/pdf-ocr.sh
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i bash -p poppler_utils tesseract4
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
pdf_path="$(realpath "$1")"
|
||||||
|
|
||||||
|
[ -f "$pdf_path" ] || {
|
||||||
|
echo "Usage: $0 FILE.pdf" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf $tmpdir' EXIT
|
||||||
|
|
||||||
|
cd "$tmpdir"
|
||||||
|
|
||||||
|
pdftoppm -png "$pdf_path" pdf-ocr
|
||||||
|
for png in pdf-ocr*.png; do
|
||||||
|
tesseract "$png" "$png.txt" 2>/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
cat pdf-ocr-*.txt
|
||||||
Reference in New Issue
Block a user