Skip to content

Instantly share code, notes, and snippets.

View smuuf's full-sized avatar

Přemysl Karbula smuuf

View GitHub Profile
@smuuf
smuuf / git-add-regex.sh
Created May 26, 2022 22:53
Git add / stage lines matching regex
#!/bin/bash
# Put this into your .bashrc, or whatever.
function git-add-regex {
git diff -U0 | grepdiff -E "$1" --output-matching=hunk | git apply --cached --unidiff-zero
}
@smuuf
smuuf / psleep.sh
Last active June 2, 2022 14:16
Bash sleep with countdown
#!/bin/bash
function psleep {
S="$1"
O="$S"
while [ $S -gt 0 ]; do
echo -ne "\r$S s (from $O) "
sleep 1
((S--))
done
@smuuf
smuuf / settings.json
Last active March 23, 2025 19:37
Settings for vscode highlight extension
{
// PHP highlights for https://github.com/fabiospampinato/vscode-highlight
"highlight.regexes": {
"(NOTE:)\\s": {
"regexFlags": "g",
"filterLanguageRegex": ".*",
"decorations": [
{
"color": "#CFC8A6",
"backgroundColor": "#CFC8A440",
@smuuf
smuuf / reorpyre.py
Created December 7, 2022 09:01
Re or Pyre2
import random
import logging
import re as module_re
import re2 as module_re2
USAGE_PROBABILITY = 0.5
USE_ONLY_PYRE2 = True
@smuuf
smuuf / gitdifffind.sh
Created January 13, 2023 09:27
Find string in git diff with info about function or class
#!/bin/bash
PREVIOUS="(@@.*function|class)" NEEDLE="getTraced" \
bash -c 'git diff | awk "(/$PREVIOUS/ && !/$NEEDLE/) {capture=1; buffer = \$0; next} capture==1 {buffer = buffer \$0 \"\n\"} (\$capture && /$NEEDLE/) {printf(\"%s\", buffer); capture=0}"'
@smuuf
smuuf / darkize_git_gui.py
Created February 26, 2024 15:47
git-gui dark theme patcher
#!/bin/env python
import os
import subprocess
from sys import stderr
FORCED_GIT_GUI_PATH=None
# Do NOT modify anything below.
UNPATCHED_NEEDLE = 'pave_toplevel .'
@smuuf
smuuf / howto.md
Created February 23, 2025 16:47
WSL1 docker client with WSL2 docker daemon

WSL1 docker client with WSL2 docker daemon

  1. Install Docker engine in both WSL1 and WSL2.
  2. In WSL1: Create, configure and use new context:
    $ docker context create wsl2daemon
    $ docker context update --docker "host=tcp://[::]:2375" wsl2daemon
    $ docker context use wsl2daemon
    
  3. In WSL2: Configure the daemon in /etc/docker/daemon.json: