This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync -e ssh -avzP --inplace (<src_host>:)<src_path> (<target_host>:)<target_path> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]: " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) " | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd $(dirname $0) | |
CONF_PATH=~/.ssh/config | |
function title() { | |
echo "█ $1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Number of requests permitted for facebook crawler per second. | |
const FACEBOOK_REQUEST_THROTTLE = 20; | |
const FACEBOOK_REQUESTS_JAR = __DIR__ . '/.fb_requests'; | |
const FACEBOOK_REQUESTS_LOCK = __DIR__ . '/.fb_requests.lock'; | |
$ua = $_SERVER['HTTP_USER_AGENT'] ?? false; | |
if ($ua && strpos($ua, 'facebookexternalhit') !== false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker client inside WSL + Container running under Docker on Windows (tested on Hyper-V's VM) | |
docker run --add-host=localhost:$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1) -it <...containerID...> /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -f $1 ]]; then | |
cat $1 | while read line | |
do | |
youtube-dl --no-mtime --no-post-overwrites --extract-audio --audio-format mp3 --audio-quality 192K $line | |
done | |
else |