Skip to content

Instantly share code, notes, and snippets.

@ftk
ftk / notification-watch.sh
Last active October 10, 2024 13:27
check for one-time codes coming as notifications via KDE connect and copy them to clipboard
#!/usr/bin/env bash
# check for one-time codes coming as notifications via KDE connect and copy them to clipboard
# requirements: qdbus(qt-tools), dbus-monitor, kde-connect, klipper
# the script must be run in user session
set -euo pipefail
shopt -s lastpipe
if [[ $# -eq 0 ]]
then
@ftk
ftk / mpv-playlist-kdialog.lua
Last active June 5, 2024 15:32
open mpv playlist in kdialog or zenity (default: Ctrl+L)
-- ==UserScript==
-- @name mpv-playlist-kdialog
-- @version 0.1
-- @description Display mpv playlist and select playlist entry in KDE's kdialog or Gnome's zenity.
-- @author ftk
-- @license 0BSD
-- @downloadURL https://gist.githubusercontent.com/ftk/5e26656a2ec9a6cb0fef46918f741d0a/raw/mpv-playlist-kdialog.lua
-- ==/UserScript==
local options = {
-- window dimensions
@ftk
ftk / Cargo.toml
Last active November 4, 2024 13:05
http mitm proxy. Simple http proxy to modify Range: http headers. Can be used to speed up youtube in mpv
# To generate mitm cert and key:
# openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -passout pass:"third-wheel" -subj "/C=US/ST=private/L=province/O=city/CN=hostname.example.com"
# see: https://github.com/campbellC/third-wheel
[package]
name = "http-ytproxy"
version = "0.1.0"
edition = "2021"
@ftk
ftk / Makefile
Last active July 27, 2024 12:16
libspnav example controlling mouse using spaceball (uinput)
CFLAGS ?= -O3 -flto
simple_uinput: proto.h spnav_config.h spnav.h proto.c spnav.c simple.c
$(CC) $(CFLAGS) -o $@ $^
spnav_config.h:
touch $@
proto.h spnav.h proto.c spnav.c:
curl -L -O --compressed --url "https://github.com/FreeSpacenav/libspnav/raw/master/src/{proto.c,proto.h,spnav.c,spnav.h}"
@ftk
ftk / win2lin.cpp
Last active February 3, 2019 14:52
Wrapper for windows subsystem for linux: run ubuntu applications from windows
// Wrapper for windows subsystem for linux (Bash on Ubuntu on Windows)
// It allows running native ubuntu applications from Windows
// 1. Compile (on windows, the command below is for mingw-gcc):
// g++ -O3 -flto -fwhole-program -fvisibility=hidden -fno-exceptions -fno-rtti -s win2lin.cpp -o win2lin.exe
// 2. make a copy for each program
// for i in git python perl; do cp win2lin.exe ${i}.exe; done
// 3. put directory with exes in windows PATH
// 4. example (from cmd.exe):
// cat "c:\test 1.txt"
// will be translated to: bash -c "exec cat \"/mnt/c/test 1.txt\""