Skip to content

Instantly share code, notes, and snippets.

@LaptopDev
LaptopDev / transcribeee.sh
Created November 29, 2025 13:11
Linux transcription (x11 & wayland) with whisper.cpp and built-in VAD. Records microphone and desktop, and transcribes existing .wav files with arguments.
#!/usr/bin/env bash
set -euo pipefail
# CONFIG
DIR="${HOME}/.transcription"
mkdir -p "$DIR"
WHISPER_BIN="/home/user/source/git/whisper_gpu.cpp/bin/whisper-cli"
WHISPER_MODEL="/home/user/source/git/whisper_gpu.cpp/models/ggml-large-v3.bin"
@LaptopDev
LaptopDev / gist:eebe422d8c43e6fd609a7ac68e95f9f5
Created October 14, 2025 01:47
Explore the parent directory of a file in netrw and escape it easily
function OpenParentDirectory()
if vim.bo.filetype == "netrw" then
vim.cmd("bd!") -- close netrw if already open
return
end
local path = vim.fn.expand("%:p:h")
if path == "" then return end
vim.cmd("Ex " .. vim.fn.fnameescape(path))
local buf = vim.api.nvim_get_current_buf()
vim.defer_fn(function()
@LaptopDev
LaptopDev / showdef.sh
Created September 2, 2025 22:01
User/session definition resolver that prints shell definitions for aliases, functions, and exported variables.
showdef () { # Check if alias, function, or environment variable & print the definition
if alias "$1" &> /dev/null; then # alias?
alias "$1";
elif declare -f "$1" &> /dev/null; then # function?
declare -f "$1";
elif [ -n "${!1}" ]; then # environment variable? (no$)
echo "${!1}";
else
echo "No alias, function, or environment variable found for '$1'";
fi;
@LaptopDev
LaptopDev / calibfind.sh
Created September 2, 2025 21:51
Lists ebook matches in user's default calibre library by title and (with arg) path.
calibfind ()
{
local cmd;
local title;
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --h | -help | --help)
echo "Usage:";
echo " calibfind <title> # list ebook info by title";
echo " calibfind -path <title> # return space-delimited quoted file paths";
@LaptopDev
LaptopDev / OpenThing.lua
Created July 23, 2025 03:58
Open URL/File under cursor in normal mode w/o selection - Neovim
local function trim_edges(s)
return (s or ""):gsub("^%s+", ""):gsub("%s+$", "")
:gsub('^[\'"()<>%[%],]+', ""):gsub('[\'"()<>%[%],]+$', "")
end
local function stat(p) return vim.loop.fs_stat(p) end
function OpenThing()
local candidates = {
vim.fn.expand("<cfile>"),
vim.fn.expand("<cWORD>"),
}
@LaptopDev
LaptopDev / dump.sh
Created April 1, 2025 19:00
shell function for kitty to dump the pane screen content to new file to prevent overwrite
dump ()
{
local id="$1";
local dir="/tmp/pane_dump";
local base="pane";
local index=1;
local file;
if [ -z "$id" ]; then
echo "Usage: dump <pane-id>" 1>&2;
return 1;
@LaptopDev
LaptopDev / stitch.py
Created April 1, 2025 18:37
a python script to stitch together uncopyable ncurses buffer dumps
#This was made for stitching uncopyable ncurses buffers textdumped to files
#Expects correct ordering of input, i.e.: pane1, pane2, pane3, etc.
#Accepts UTF-8 plain text files There is no restriction on file extension, but
# dumpfile names must regex match by 'pane\d+'
#If a proceeding pane contains completely new content it will be appended in full and in order,
# ortherwise it will append only non-overlapping tail of the next pane, effectively deduplicating overlaps.
#!/usr/bin/env python3
import os
import re
@LaptopDev
LaptopDev / paneid_alias.sh
Last active April 1, 2025 20:09
current kitty window pane query shell alias
alias paneid='kitty @ ls | jq -r ".[] | .tabs[] | select(.is_active) | .windows[] | select(.is_focused) | .id"'
@LaptopDev
LaptopDev / log_last_opened.lua
Created March 23, 2025 04:10
log opened files in neovim
-- Log file opening to last_opened.txt
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local date = os.date("%b %d, %Y") -- Format the current date
local file_path = vim.fn.shellescape(vim.fn.expand("<afile>:p"))
os.execute(string.format("sed -i '1i%s' /home/user/.config/nvim/last_opened.txt", date .. " " .. file_path))
end,
})
@LaptopDev
LaptopDev / vtt-to-srt.lua
Created March 16, 2025 05:15
Convert youtube .vtt to .srt
local input_file = "tG1hCDXoE-I.en.vtt" -- Change this to your VTT file path
local output_file = "output.srt"
-- Define input and output file paths.
-- Read the entire VTT file into an array of lines.
local lines = {}
for line in io.lines(input_file) do
table.insert(lines, line)
end