Skip to content

Instantly share code, notes, and snippets.

View smuuf's full-sized avatar

Přemysl Karbula smuuf

View GitHub Profile
@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 / 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 / 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 / settings.json
Created November 15, 2022 14:08
Settings for vscode highlight extension
{
// PHP highlights for https://github.com/fabiospampinato/vscode-highlight
"highlight.regexes": {
"(NOTE:)\s": {
"regexFlags": "g",
"filterLanguageRegex": "php",
"decorations": [
{
"color": "#CFC8A6",
"backgroundColor": "#CFC8A40",
@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 / 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 / a2manage.sh
Created January 28, 2022 10:19
a2enmod and a2dismod for Alpine
#!/bin/sh
# Usage:
# ./a2manage.sh a2dismod proxy.*
# ./a2manage.sh a2enmod proxy proxy_fcgi ssl
MODS_A_CONF_PATH="/etc/apache2/*.conf"
MODS_B_CONF_PATH="/etc/apache2/conf.d/*.conf"
function a2enmod {
@smuuf
smuuf / install_mariadb_service.sh
Created November 25, 2020 13:07
MariaDB 10.4 for WSL1 with sysVinit
# After installing MariaDB via apt, run this:
## Fix MySQL (MariaDB)
if [ ! -f "/etc/init.d/mysql" ]; then
sudo cp /usr/share/mysql/mysql.init /etc/init.d/mysql
sudo chmod a+x /etc/init.d/mysql
sudo service mysql restart
sudo mysql_secure_installation
sudo service mysql restart
fi
@smuuf
smuuf / install_pypy.sh
Last active April 4, 2023 10:35
Simple install any version of pypy
# This is the name of archive taken from https://downloads.python.org/pypy/
PYPY_VER="pypy3.9-v7.3.11-linux64"
PYPY_VER_NUM=`echo ${PYPY_VER} | grep -oP "v(\d\.?)+" | sed -r 's/[v.]//g'`
cd ~
mkdir pypy
wget https://downloads.python.org/pypy/$PYPY_VER.tar.bz2 && tar -xvjf $PYPY_VER.tar.bz2
rm $PYPY_VER.tar.bz2
mv $PYPY_VER pypy/
sudo ln -s ~/pypy/$PYPY_VER/bin/pypy3 /usr/bin/pypy3-$PYPY_VER_NUM; chmod +x /usr/bin/pypy3-$PYPY_VER_NUM
@smuuf
smuuf / gist:aa6b5bcf40fe075cca4cd84dbf9477ad
Last active May 27, 2020 13:26
Docker: WSL1 client WSL2 daemon
#!/bin/bash
# Have this in your client WSL1 ".bashrc" file.
WSL_DAEMON_DIST_NAME="Alpine" # WSL distribution name which has Docker daemon running in it.
export DOCKER_HOST=`wsl.exe -d $WSL_DAEMON_DIST_NAME eval ifconfig | grep -A 1 eth0 | grep -Po "\d+\.\d+\.\d+\.\d+" | head -n1`