Skip to content

Instantly share code, notes, and snippets.

@Vftdan
Vftdan / import-clementine-into-strawberry.sql
Last active August 28, 2025 06:19
Replace strawberry player library (songs and playlists) with existing clementine library
-- () { :; }; exec sqlite3 -init "$0" # Shebang
-- XXX: THIS WILL DELETE EXISTING STRAWBERRY LIBRARY!!!
-- Based on instructions at <url:https://wiki.strawberrymusicplayer.org/wiki/Import_collection_library_and_playlists_from_Clementine>
-- You will need to replace '~' with its expansion
ATTACH '~/.local/share/strawberry/strawberry/strawberry.db' AS strawberry;
ATTACH '~/.config/Clementine/clementine.db' AS clementine;
BEGIN;
DELETE FROM strawberry.directories;
@Vftdan
Vftdan / morewrap.lua
Last active August 5, 2025 19:38
Suspends ComputerCraft program after each written screenful
local parentTerm
local linesFed = 0
local eventQueue = {}
local consumeQueue = true
local skipKeyUp = {}
local function getChar()
-- If the wrapped program received key event,
-- we should not consume its corresponding char event
local hadKeyDown = false
@Vftdan
Vftdan / startseat.lua
Last active August 4, 2025 02:00
ComputerCraft monitor & keyboard environment
local keyboardEvents = {["char"] = true, ["key"] = true, ["key_up"] = true}
local touchButtonId = 1
local useParentKeyboard = true
local useTmKeyboards = {}
local monName = nil
local scale = nil
local seat = {monitor = nil, co = nil, monitorName = nil}
local args = {...}
@Vftdan
Vftdan / ccevtest.lua
Last active August 5, 2025 05:06
ComputerCraft event monitor
local selectedEvents = {"key", "key_up", "char", "paste", "mouse_click", "mouse_drag", "mouse_up", "mouse_scroll"}
local allEvents = false
local function repr(x)
local visited = {}
local visitedCount = 0
local function reprInner(x)
visitedCount = visitedCount + 1
local t = type(x)
if t == "string" then
@Vftdan
Vftdan / ser.sprak
Last active May 9, 2025 20:20
A JSON-like serialization and deserialization for Sprak from the `Else Heart.Break()` game
# Was not checked for compilation and runtime errors
string Serialize(var obj)
string t = Type(obj)
if t == 'number'
string s = obj
return s
else if t == 'bool'
if obj
return 'true'
@Vftdan
Vftdan / dot2tex.lua
Last active June 5, 2024 17:34
dot2tex pandoc lua filter
--[[
dot2tex — convert "dot2tex" code blocks to "tikz" code blocks
Should be followed by diagram-generator.lua or diagram.lua in the filter chain.
"dot2tex" must be installed into $PATH or it's executable filename should be
provided in $DOT2TEX or dot2tex_path option.
Copyright: (c) 2024 vftdan (https://github.com/Vftdan)
License: MIT
]]
@Vftdan
Vftdan / slice.c
Last active January 16, 2024 11:57
Slice types in C as anonymous struct types
// Copyright (c) 2024, vftdan
// SPDX-License-Identifier: MIT
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define DEBUG_PRINT_VALUE(x, fmt) fprintf(stderr, #x " = " fmt "\n", x); fflush(stderr)
@Vftdan
Vftdan / owncast-chat2ass.sh
Created July 16, 2023 21:17
Owncast chat log to ASS/SSA subtitles
#! /bin/sh
# owncast-chat2ass.sh
# Copyright (c) 2023 vftdan (https://github.com/Vftdan)
TimeToSeconds() {
date -d "$1" +'%s.%N'
}
TimespanSeconds() {
printf '%s\n' "$(TimeToSeconds "$2") - $(TimeToSeconds "$1")" | bc
@Vftdan
Vftdan / sunskribo.vim
Created October 24, 2022 20:00
Vim keymap for https://bouncepaw.github.io/sunskribo (breaks in my version of NeoVim, but works in vim.gtk3)
scriptencoding utf-8
let b:keymap_name = "sunskribo"
lmapclear <buffer>
function! s:get_any_var(name, default)
let l:g = get(g:, a:name, a:default)
let l:b = get(b:, a:name, l:g)
return get(w:, a:name, l:b)
endfunction
@Vftdan
Vftdan / cue_to_flac_cmd.py
Last active August 14, 2022 14:54 — forked from Theldus/cue_to_flac.py
CUE splitter using ffmpeg (to flac)
#! /usr/bin/env python3
import sys
def unquote(s):
if len(s) < 2:
return s
if s[0] == '"' and s[-1] == '"':
return s[1:-1]
return s