Skip to content

Instantly share code, notes, and snippets.

@webevt
webevt / gist:1aaece8a49c5e88f6d4558fc93cb3547
Created September 10, 2018 10:52
Audio control commands
# Increase volume
amixer -q -D pulse sset Master 5%+
# Decrease volume
amixer -q -D pulse sset Master 5%-
# Toggle mute
amixer -q -D pulse sset Master toggle
@webevt
webevt / fastphp.bash
Created November 17, 2017 10:38
Run php without xdebug extension loaded
#!/usr/bin/env bash
DIR_INI_TMP=$(mktemp -d)
find "${PHP_INI_DIR}"/conf.d/* | grep -v xdebug | xargs cp -t "${DIR_INI_TMP}"
PHP_INI_SCAN_DIR="${DIR_INI_TMP}" exec php "$@"
@webevt
webevt / gist:3f7c8990fd80f6f43052ed5a28769cbd
Last active November 15, 2017 23:30
Resize Virtualbox Disk
# Find your VM name
VBoxManage list vms
VMNAME="YOUR_VM_NAME"
# Get VM disk path.
VMDISK1=$(VBoxManage showvminfo "${VMNAME}" --machinereadable | grep -E '^\"SATA' | head -n1 | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//')
# Convert disk to VDI
if [ "${VMDISK##*.}" != "vdi" ]; then
VMDISK2="${VMDISK1%%.*}.$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1).vdi"
@webevt
webevt / gist:e69b88c8e7a9958b8d0899b9ad43b418
Created November 5, 2017 09:52
Drop active connections for TARGET_DB in postgres
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();
git log --follow -p -- FILE
@webevt
webevt / parse_yml.bash
Last active October 27, 2017 08:01
Parse YAML in BASH with support of plain arrays and arrays of hashes
#!/usr/bin/env bash
parse_yml() {
[ -n "$2" ] && local prefix="$2" || {
local prefix=$(basename "$1"); prefix=${prefix%%.*}
}
local file="$1"
local s='[[:space:]]*'
local w='[a-zA-Z0-9_]*'
local fs="$(echo @|tr @ '\034')"
@webevt
webevt / selenium
Created July 6, 2017 15:58
Start selenium with chrome driver located nearby
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
java -Dwebdriver.chrome.driver="${DIR}/drivers/chromedriver" -jar "${DIR}/selenium-server-standalone-3.4.0.jar"
@webevt
webevt / idea.properties
Created May 8, 2017 10:41
Makes WIN key work as META
# Makes WIN key work as META to enable OS X keymap.
keymap.windows.as.meta=true
@webevt
webevt / gist:b1f79d5c3b1a6f1a7d7fa34f2c960ecf
Created March 22, 2017 17:35
Find non-existent services in Symfony app
app/console debug:container | tail -n +8 | head -n-5 | grep -v "alias for" | while read -r LINE; do CLASS=$(echo $LINE | awk '{print $2}'); SERVICE=$(echo $LINE | awk '{print $1}'); if [ -z $CLASS ]; then continue; fi; php -r "require_once 'app/autoload.php'; class_exists('$CLASS') || interface_exists('$CLASS') ?: print('Service $SERVICE ($CLASS) does not exist'.PHP_EOL);"; done
@webevt
webevt / .profile
Last active March 21, 2017 13:29
Save & Restore the Latest Working Dir in Bash
# Put in the end of your ~/.profile or ~/.bashrc
PROMPT_COMMAND='printf %s "$PWD" > ~/.lastpwd'
[ -s ~/.lastpwd ] && cd "$(<~/.lastpwd)"