Skip to content

Instantly share code, notes, and snippets.

Avatar

Přemysl Karbula smuuf

View GitHub Profile
@smuuf
smuuf / install_mariadb_service.sh
Created Nov 25, 2020
MariaDB 10.4 for WSL1 with sysVinit
View install_mariadb_service.sh
# 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
Created Nov 24, 2020
Simple install any version of pypy
View install_pypy.sh
PYPY_VER="pypy3.6-v7.3.2-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
Docker: WSL1 client WSL2 daemon
View gist:aa6b5bcf40fe075cca4cd84dbf9477ad
#!/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`
@smuuf
smuuf / wavtomp3.sh
Last active Mar 28, 2020
WAV to MP3 bash function
View wavtomp3.sh
# Best to put this in your .bashrc
# .wav extension will be replaced with .mp3 automatically.
# Usage: wavtomp3 lorem_ipsum.wav
function wavtomp3() {
ffmpeg -i "$1" -vn -ar 44100 -ac 2 -b:a 320k "${1/.wav/.mp3}"
}
@smuuf
smuuf / .bashrc
Last active Mar 28, 2020
Pretty prompt alá smuuf
View .bashrc
# smuuf.bashrc
# Prompt formatting
# 10:20:49 /etc
# [smuuf@smuuf-xubuntu]$
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
NC="$(tput sgr0)"
@smuuf
smuuf / bestrsync.sh
Created Apr 4, 2019
Copy whole directories via rsync with resuming
View bestrsync.sh
rsync -e ssh -avzP --inplace (<src_host>:)<src_path> (<target_host>:)<target_path>
View PHP xdebug config
# Use this to enable debugging for current terminal session.
# export XDEBUG_CONFIG="idekey=whatever"
[XDebug]
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.profiler_output_dir=/mnt/d/_produkce/_xdebug_profiles/
xdebug.profiler_output_name=callgrind.%t.out
xdebug.profiler_enable_trigger=1
#xdebug.idekey="asd"
View terminal_host_color.sh
# Sets the color of next text output to be a random color based on hostname's md5 hash.
# (If the terminal supports true colour (RGB) colors.)
set_host_based_color() {
HOSTHASH=$(hostname | md5sum)
printf "\x1b[38;2;%d;%d;%dm" 0x${HOSTHASH:0:2} 0x${HOSTHASH:2:2} 0x${HOSTHASH:4:2}
}
# Example usage:
# PS1="[\$(set_host_based_color)\$(hostname)\033[0m]: "
@smuuf
smuuf / git_status_in_function.sh
Last active Nov 30, 2018
git status in prompt function
View git_status_in_function.sh
#!/bin/bash
get_git_status() {
git_status=$(git status -s -u -v 2>/dev/null)
if [[ -z "$git_status" ]]; then return 0; fi
modified=$(echo "$git_status" | grep '^ M ' | wc -l)
deleted=$(echo "$git_status" | grep '^ D ' | wc -l)
untracked=$(echo "$git_status" | grep '^?? ' | wc -l)
echo "(~$modified -$deleted +$untracked) "
}
@smuuf
smuuf / ssh-multi-copy-id.sh
Last active Dec 20, 2018
Small BASH script which iterates over all hosts defined in SSH config and tries to ssh-copy-id your SSH ID to all of them.
View ssh-multi-copy-id.sh
#!/bin/bash
cd $(dirname $0)
CONF_PATH=~/.ssh/config
function title() {
echo "$1"
}