Skip to content

Instantly share code, notes, and snippets.

@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
@LaptopDev
LaptopDev / log_last_watched.lua
Last active March 27, 2025 21:35
Log MPV watch history
--https://chatgpt.com/c/67e44b59-292c-800b-80b6-3e6b1c609524
local mp = require("mp")
local utils = require("mp.utils")
local log_file = utils.join_path(os.getenv("HOME"), ".config/mpv/last_watched.txt")
-- Function to log current playback
local function log_last_watched()
local path = mp.get_property("path")
if not path then return end
@LaptopDev
LaptopDev / ocr.py
Last active November 5, 2023 17:21
Tesseract OCR with Grim - also accepts CL image paths as arguments
# Tesseract OCR ; process images as arguments to convert image to text
## .bashrc:
# alias catpic='python3 $home/scripts/ocr.py'
## keybind that I use in my hyprland configuration file:
# bind = SUPER, o, exec, grim -g "$(slurp)" - | python3 $home/scripts/ocr.py | wl-copy
@LaptopDev
LaptopDev / transcribe.sh
Last active August 31, 2023 14:50
linux transcribe.sh (bg script, hotkey adaptable) for whisper.cpp - Backup voice memo and transcription, and copy transcription to clipboard
#!/bin/bash
# place in whisper.cpp/
# assign this scfript to a hotkey to start a recording
# assign ffmpeg kill command to another hotkey to stop it
# if desired,
# modify the whisper.cpp/main command to add an argument
# for using a specific model other than whisper.cpp's base model
cd /home/user/whisper.cpp