Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name htw autologin
// @namespace lsf-htw-berlin
// @include https://lsf.htw-berlin.de/*
// @version 1
// @grant none
// ==/UserScript==
x=document.getElementsByName("submit").item(0);
@hylophile
hylophile / waitForSelector.ts
Created January 22, 2023 21:55
wait for an element to appear in the DOM (useful for SPA)
function waitForSelector(s:string) {
const d = Date.now();
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
clearInterval(interval);
reject(new Error(`never found {s}`));
}, 2000);
const interval = setInterval(() => {
const el = document.querySelector(s);
if (el) {
@hylophile
hylophile / info.md
Created June 10, 2023 12:59
Sidebery expand on hover (with tab drag'n'drop working) & scrolling long tab titles
@hylophile
hylophile / layouts.lua
Last active July 10, 2023 04:28
Saving and loading layouts for Wezterm (without writing layout definitions manually)
local wezterm = require("wezterm")
local act = wezterm.action
local module = {}
local function write_layout(name, window_config)
local file = io.open(wezterm.config_dir .. "/layouts/" .. name .. ".json", "w")
if file then
file:write(wezterm.json_encode(window_config))
file:close()
end
@hylophile
hylophile / annotate.sh
Last active March 1, 2024 13:00
annotate every page of some pdf files with some text
#!/usr/bin/env bash
pdf_dir="lec"
mkdir -p lec_out/lec
for file in "$pdf_dir"/*.pdf; do
filename=$(basename -- "$file")
filename_no_ext="${filename#lec_}"
filename_no_ext="${filename%.*}"
echo "$filename_no_ext" > filename.txt
@hylophile
hylophile / Justfile
Last active October 20, 2024 21:39
Color-coded prefixed logging of long-running commands with Just (similar to `docker compose logs`)
[positional-arguments]
parallog +args:
#!/usr/bin/env bash
trap "kill 0" EXIT SIGINT SIGTERM
align=$((1 + `printf "%s\n" "$@" | wc -L`))
while (("$#")); do
color=$((31 + ("$#" % 6)))
prefix=`printf "\033[${color};m%+${align}s\033[0m" "$1"`
FORCE_COLOR=1 just $1 2>&1 | sed "s/^/${prefix} │ /;" &
shift
@hylophile
hylophile / envsubst.sh
Created September 14, 2024 17:25
envsubst in one line of bash
#!/usr/bin/env
while IFS= read -r line; do eval echo "$line"; done < infile > outfile