Skip to content

Instantly share code, notes, and snippets.

View schuhwerk's full-sized avatar

Vitus Schuhwerk schuhwerk

View GitHub Profile
@schuhwerk
schuhwerk / Docker & Spaces.md
Last active March 21, 2025 19:53
Docker & Spaces

Make sure the path you are cloning this in does not have spaces (like "New Folder")

git clone https://github.com/dol-lab/bedrock-multisite-docker
cd bedrock-multisite-docker
mkdir bedrock
git clone https://github.com/dol-lab/spaces.git bedrock
# checks/installs dependencies
bash ./docker/scripts/install.sh
@schuhwerk
schuhwerk / md-opener.bat
Last active December 28, 2024 17:53
Open with Obsidian. Choose Proper Markdown-Editor based on file-location (Windows)
:: Universal markdown (.md) file opener with Obsidian vault support
::
:: This script handles two scenarios:
:: 1. Files in Obsidian vault: Opens using obsidian://open?path protocol
:: 2. Files outside vault: Opens using alternative editor (e.g. Typora)
::
:: Setup:
:: 1. Set VAULT_PATH to your Obsidian vault location
:: 2. Set ALT_EDITOR to your preferred markdown editor
:: 3. Register as default .md handler:
@schuhwerk
schuhwerk / logwatch.sh
Last active December 2, 2024 18:22
Log file monitoring and error reporting (via email) script.
#!/bin/bash
# Log file monitoring and error reporting (via email) script.
#
# This script monitors log files for specified error patterns and sends email alerts.
# Features:
# - Configurable file search patterns using find
# - Regex-based error detection
# - Context lines around errors
# - Consolidated email reports
# - Support for custom configuration files
@schuhwerk
schuhwerk / Control Video Speed.js
Last active March 30, 2025 11:16
UserScript. Control Video Playback Speed with Keyboard.
// ==UserScript==
// @name Video Speed Control with Keyboard
// @description Decrease and increase HTML video playback speed with "," and ".". Remembers and applies speeds across page-loads.
// @version 2025-03-30
// @author Vitus Schuhwerk
// @license MIT
// @homepageURL https://gist.githubusercontent.com/schuhwerk/67fb4da50652681b857002e1ba2bf071
// @updateURL https://gist.githubusercontent.com/schuhwerk/67fb4da50652681b857002e1ba2bf071/raw
// @downloadURL https://gist.githubusercontent.com/schuhwerk/67fb4da50652681b857002e1ba2bf071/raw
// @grant GM_getValue
@schuhwerk
schuhwerk / Autolink React.js
Last active June 20, 2024 13:36
Create React App - Link Error Overlay to VS Code
@schuhwerk
schuhwerk / typescript.ts
Created May 14, 2024 10:58
Typescript Hints
// use the strings in an array as types.
const animals = ["cat", "dog", "mouse"] as const
type Animal = (typeof animals)[number] // transformer like "cat" | "dog" | ...
let myAnimal : Animal = "cat" // <- autocomplete works here
// merge two types.
type Prefix = "sub_"
type Numbers = 0 | 1 | 2 | 3 | 4 | 5
type SubNumbers = `${Prefix}${Numbers}` // transforms to sub_1 | sub_2 | ...
let myNumber : SubNumbers = "sub_0" // <- autocomplete works here
@schuhwerk
schuhwerk / Typescript Simple Logger.ts
Last active November 20, 2024 18:03
Simple Logger.ts
const stringToBool = (s: string) => (s.toString().match(/^(true|[1-9][0-9]*|[0-9]*[1-9]+|yes)$/i) ? true : false)
type levelNames = "emerg" | "alert" | "crit" | "error" | "warn" | "notice" | "info" | "debug"
type logLevel = {
name: levelNames
cb: CallableFunction
defaultEnabled: boolean
}
type callableNames = {
[K in levelNames]: CallableFunction
@schuhwerk
schuhwerk / defaults and types.ts
Last active January 9, 2024 10:28
Infer types from an object. Make object-key prefixed with "_" partials (not required)
// Keys in R overwrite the ones in Default.
type Modify<Default, R> = Omit<Default, keyof R> & R
// get only types where key is prefixed with Prefix.
type FilterPrefixed<O, Prefix extends string> = {
[K in keyof O as K extends `${Prefix}${infer _}` ? K : never]: O[K]
}
/**
* Object-Keys that are not prefixed with "_" become partials.
@schuhwerk
schuhwerk / Trellis WSL.bash
Created November 9, 2022 10:46
Trellis-CLI in Windows (WSL1)
# Do this step by step.
# WSL: https://learn.microsoft.com/de-de/windows/wsl/install
# Trellis-Cli: https://github.com/roots/trellis-cli
# install brew (packet manager) - Just for trellis-cli.
# If you don't have already probably easier to just download and add to Path...
sudo apt update
sudo apt-get install build-essential curl file git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
@schuhwerk
schuhwerk / get-user-logins.sql
Last active April 5, 2022 10:05
Get the login-times of users (no plugin required).
/*
* Get last login time of WordPress users.
* WordPress stores the last time a user logged in in a serialized array in the usermeta - table.
* Your prefix might be different (xyz_usermeta instead of wp_usermeta).
* @see https://shocksolution.com/2019/04/16/find-last-login-time-for-wordpress-users-in-the-sql-database/
*/
select
wu.user_login,
metatable.*,
FROM_UNIXTIME(metatable.login_time)