Skip to content

Instantly share code, notes, and snippets.

View Dimfred's full-sized avatar

Dimfred

View GitHub Profile
@Dimfred
Dimfred / Makefile
Created September 30, 2023 17:44
make help target (parses the makefile itself and prints the target and description, which is provided behind ##)
target1: ## does some stuff
echo target1
target2: target1 ## this wil l only print target2 not target1
echo target2
help: ## prints help for target1 and target2
@grep '##' $(MAKEFILE_LIST) \
| grep -Ev 'grep|###' \
| sed -e 's/^\([^:]*\):[^#]*##\([^#]*\)$$/\1:\2/' \
@Dimfred
Dimfred / reverse_search.sh
Created June 9, 2023 12:43
zsh fzf reverse search (like bash)
reverse_search() {
sel="$( \
cat ${HOME}/.zsh_history \
| grep -i "$BUFFER" \
| cut -d';' -f2 \
| sort \
| uniq -ui \
| fzf)"
[ -z "$sel" ] && return
BUFFER="$sel"
@Dimfred
Dimfred / ansible_vault_decode_from_stdin.sh
Last active December 4, 2022 11:01
Ansible Vault: Read password from stdin and print to stdout
echo password | EDITOR=cat ansible-vault edit --vault-password-file /bin/cat test.vault
@Dimfred
Dimfred / clean_registry.sh
Created September 21, 2022 08:05
Rofi registryv2 clean / delete
#!/usr/bin/env zsh
REGISTRY="<YOU_REGISTRY_URL_HERE>"
sel() {
echo "$1" | rofi -dmenu -multi-select -config "~/.config/rofi/config-multi-select.rasi"
}
PARSE="
import sys
@Dimfred
Dimfred / mk.sh
Last active September 9, 2022 09:17
FZF for lets.yaml and Makefile in one command
#!/usr/bin/env zsh
DISTANCE_COMMAND_DESCRIPTION=15
cmd_parse_lets="
import yaml
with open('lets.yaml', 'r') as f:
commands = yaml.safe_load(f)
commands = commands['commands'].items()
lmax = max(len(k) for k, _ in commands)
@Dimfred
Dimfred / Dockerfile
Created August 3, 2022 10:11
poetry for python3.9 alpine linux (ssh enabled)
FROM python:3.9-alpine
################################################################################
# PYTHON INIT
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
LANG=C.UTF-8 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
@Dimfred
Dimfred / img_to_text.sh
Created May 10, 2022 15:03
Text from screenshot with tesseract
#!/usr/bin/env sh
main() {
# path to store tmp stuff
dir=/tmp
# tmp path of the img to process by tesseract
out_img=$dir/tesseract_img.png
# output text read from the img
out_txt=$dir/tesseract_text
@Dimfred
Dimfred / fzfpytest.sh
Created April 19, 2022 12:28
fzfpytest
#!/usr/bin/env sh
parse() {
code='\
import re
import sys
files = sys.argv[1:]
tests = []
# pip3 install pysha3 eth-account requests
from eth_account.messages import encode_defunct
from eth_account import Account
import sha3
import json
import os
import requests as req
acc = Account.from_key("4c4b2554e43b374f4cafdd5adaeea5e9aff9b3be54d329bc939752bb747294b9")
@Dimfred
Dimfred / lfbulkrename.sh
Last active December 4, 2022 11:01
bulkrename for lf filemanager
#!/usr/bin/env zsh
print_usage() {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "usage: lfbulkrename <lfid> <files_separated_by_newline>"
exit
fi
}
lfecho() {