Skip to content

Instantly share code, notes, and snippets.

@toofar
toofar / pw-easylink
Last active May 27, 2023 06:03 — forked from nidefawl/pw-easylink
Small tool to configure and maintain PipeWire links between sets of input/output port querie
@toofar
toofar / pr_mergability.sh
Created November 8, 2022 09:46
qutebrowser#1455
#!/bin/sh
# requires the github binary, authorized, to list open PRs. Probably could get
# them from the API anonymously since its a public repo.
[ -e prs.json ] || gh -R qutebrowser/qutebrowser pr list -s open --json number,title,mergeable,updatedAt -L 100 > prs.json
[ -e qutebrowser/app.py ] && {
echo "don't run this from your qutebrowser checkout. Run it from a tmp dir, it'll checkout out a new copy to work on"
exit 1
}
[ -d qutebrowser ] || {
@toofar
toofar / steam_save_sync.sh
Created June 25, 2022 05:07
Symlink steam wine prefix user dirs to common directory
#!/usr/bin/env sh
# Symlink drive_c/user directories from Steam wine prefixes to a common
# location.
# To mitigate https://github.com/ValveSoftware/Proton/issues/428
# Run it from cron every day or week or whatever.
# Doesn't currently handle the case of reinstalling an application and a
# prefix being recreated (will print '... already exists' to stderr).
# todo: try other common dirs
@toofar
toofar / watchFor.user.js
Last active January 27, 2020 07:28
Mutation observer snippet, probably not optimal
const watchFor = function(container, selector, callback) {
let observer = new MutationObserver(function(mutations) {
for (let mindx = 0; mindx < mutations.length; mindx++) {
let mutation = mutations[mindx]
let found = new Set(Array.from(mutation.addedNodes).filter(
(node) => node.matches(selector)
))
if (found.size === 0)
found = new Set(
Array.from(mutation.addedNodes).map(
@toofar
toofar / pids.py
Last active October 19, 2020 22:13
Switch to qutebrowser tab for renderrer by PID.
# pause all the `QtWebEngineProc`s except one, inject JS into each of the tabs
# to see which one returns something.
# :activate-pid <pid>
import os, signal, functools
from PyQt5.QtCore import QTimer
from qutebrowser.misc import objects
from qutebrowser.utils import objreg
@toofar
toofar / desknote.sh
Last active July 12, 2019 09:39
Ghetto desktop notifications
#!/bin/sh
## Listen on localhost and send to notifyd
# Daemonize it however you like
while test 1;do
printf 'HTTP 204 No Content\r\nAccess-Control-Allow-Origin: *\r\n\r\n' |\
nc -lp 5587 | sed -n '/==BEGIN==/,$p' | (
read header; read icon; read title; body="$(cat)";
ct="none"
case "$icon" in
"data:image/"*)
@toofar
toofar / proxySetTest.js
Created April 14, 2018 06:17
Test that ES6 Proxy handler.set() works, also at https://jsbin.com/dorupeqabu/edit?js,console
// Expected output:
// > "setting one to 2"
// > 2
// > 2
const store = { one: 1 };
const myProxyHandler = {
set: function(target, key, value) {
console.log(`setting ${key} to ${value}`);
target[key] = value;
}
@toofar
toofar / .bashrc.bash
Last active May 13, 2016 07:28
Bash/Readline function to insert previously used files into the current command line.
maybefile () {
case "$1" in
*/*|/*|*/)
return 0;;
esac
return 1
}
# Parse shell commands (eg from `history`) and look for parameters that look
# like files, that is they contain a '/'. Handles quoting and backslash
@toofar
toofar / burnshare.py
Created March 23, 2015 03:19
Self hosted single share resumable file hosting server.
#!/usr/bin/env python
# Serve files from the current directory.
# Delete after the last byte of a file has been served once.
# Supports resumable downloads (Range header subset).
# Delete files with an mtime older than a week (with --prune).
# Follows symlinks if the leaf is a symlink or the leaf ends up in the current
# directory.
# Bonus:
@toofar
toofar / zbase32
Created July 9, 2014 02:21
zbase32 CLI app.
#!/usr/bin/env python
import sys
import fileinput, zbase32
# TODO: Parse args properly.
# TODO: | fold -s76 like base64
# TODO: padding?
if len(sys.argv) > 1 and sys.argv[1] == '-d':