Skip to content

Instantly share code, notes, and snippets.

View knbknb's full-sized avatar
💭
🙅‍♀️💡💤😴🛌🤪🧔

Knut Behrends knbknb

💭
🙅‍♀️💡💤😴🛌🤪🧔
View GitHub Profile
@knbknb
knbknb / .editorconfig
Last active January 25, 2025 09:38
Editorconfog boilerplate
# http://editorconfig.org
# directory where .editorconfig resides is top level of project
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
@knbknb
knbknb / run-in-browser-console.js
Last active January 16, 2025 19:51
TYPO3 v10 javascript snippet for browser console
// this works in the browser console,
// when the modal dialog is visible
// after clicking on the "i" button for a frontendusergroup
function filterTableRows(tableDiv) {
if (!tableDiv) { console.error(`selector 'div.table-fit' not found!`); return; }
const table = tableDiv.querySelector('table');
if (!table) { console.error(`table contains no data`); return; }
const headers = table.querySelectorAll('thead th');
@knbknb
knbknb / yt-dlp-subtitles-only.sh
Last active December 30, 2024 12:36
bash: yt-dlp subtitles only
#!/usr/bin/env bash
url=$1
# if no url is provided, exit
if [ -z "$url" ]; then
echo "No URL provided"
exit 1
fi
subtitle_url=$(yt-dlp -q --skip-download --convert-subs srt --write-sub --sub-langs "en" --write-auto-sub --print "requested_subtitles.en.url" "$url")
content=$(curl -s "$subtitle_url" | sed '/^$/d' | grep -v '^[0-9]*$' | grep -v '\-->' | sed 's/<[^>]*>//g' | tr '\n' ' ')
@knbknb
knbknb / cisco-startup-gui-bugfix.sh
Last active December 20, 2024 12:12
bash: Cisco Secure Client start
#!/bin/bash
export WEBKIT_DISABLE_DMABUF_RENDERER=1 && /opt/cisco/anyconnect/bin/vpnui
#
# Fix for Cisco AnyConnect VPN client GUI startup bug on Linux
# AnyConnect 4.10.05111 displays blank page instead of SSO login
# https://community.cisco.com/t5/vpn/anyconnect-4-10-05111-displays-blank-page-instead-of-sso-login/td-p/4648440
@knbknb
knbknb / cut-csvkit-cheatsheet.sh
Created December 17, 2024 14:08
".sh for data" Cheatsheet: curl, in2csv, csvkit...
curl -LOC myurl
# - L: folllow redirects
# - O: use Original Remote Filename
# - C: Continue interrupted downloads
wget -bc myurl
# -b : do it in background
# -c : continue broken downloads
@knbknb
knbknb / speech2text-whisper.sh
Created December 15, 2024 20:29
Whisper Speech to Text Shellscript
#!/bin/bash
# Speech to text with Whisper model using OpenAI API
# Assumes that the OpenAI API key is set as an environment variable
# Usage: ./speech2text-whisper.sh input_audio_file
# Check if an input argument is provided and validate the file extension
if [ -z "$1" ]; then
echo "Error: No input file provided. Please specify an audio file (MP3, WAV, etc.) as the first argument."
exit 1
fi
@knbknb
knbknb / recraft-text2image.sh
Last active January 22, 2025 10:38
recraft-text2image.sh
#!/usr/bin/env bash
RECRAFT_API_KEY=YOU_MUST_REPLACE_THIS_WITH_YOUR_API_KEY
now=$(date +"%Y%m%d_%H%M%S")
logo_description_outfile=logo_description_$now.svg
temp_response_file=response_$now.json
@knbknb
knbknb / recraft-vectorize.api.sh
Created December 15, 2024 18:23
recraft-vectorize
#!/usr/bin/env bash
RECRAFT_API_KEY=...
now=$(date +"%Y%m%d_%H%M%S")
# Check if an input argument is provided and validate the file extension
if [ -z "$1" ]; then
echo "Error: No input file provided. Please specify a Webp, PNG or JPG file as the first argument."
exit 1
fi
@knbknb
knbknb / ansible-adhoc-commands-cheatsheet.sh
Last active December 7, 2024 08:50
ansible-adhoc-commands
# Visualize the gathering phase of Ansible, on a target host.
# Returns a JSON structure with all the facts about the target host
# More than ping, less than a full playbook
ansible -m setup 192.168.178.29
# Filter the output of the setup module to only show facts related to the distribution
ansible -m setup 192.168.178.29 -a "filter=ansible_distribution*"
# a LOT of facts are gathered and put into variables
# this is how to get them back as pure json
ANSIBLE_STDOUT_CALLBACK=json ansible -m setup localhost
@knbknb
knbknb / smurfette.rq
Created October 26, 2024 11:25
Smurfette in div languages
# lists the names of smurfette in all languages that wikidata knows about .
# the result should have two columns, "language_label" and "smurfette_name"
SELECT ?language_label ?smurfette_name WHERE {
wd:Q305405 rdfs:label ?smurfette_name.
FILTER(LANG(?smurfette_name) != "").
BIND(LANG(?smurfette_name) AS ?lang).
?language_item wdt:P218 ?lang.