Skip to content

Instantly share code, notes, and snippets.

Avatar

Mai Krakauer mkrakauer-rio

View GitHub Profile
@mkrakauer-rio
mkrakauer-rio / .bash_profile
Created Apr 17, 2018
Mac SSH Autocomplete
View .bash_profile
_complete_ssh_hosts() {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/config | \
grep "^Host " | \
awk '{print $2}'
`
COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
return 0
}
@mkrakauer-rio
mkrakauer-rio / disable-full-sync-on-flush.sh
Last active Jun 12, 2022
Docker for Mac - Disable full disk sync on flush
View disable-full-sync-on-flush.sh
cd ~/Library/Containers/com.docker.docker/Data/database/
git reset --hard
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# if you see true, continue
echo false > com.docker.driver.amd64-linux/disk/full-sync-on-flush
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# you should now see false
git add com.docker.driver.amd64-linux/disk/full-sync-on-flush
git commit -s -m "Disable flushing"
# wait for docker to restart
@mkrakauer-rio
mkrakauer-rio / post-merge
Created Mar 13, 2016
git hook to run a command after `git pull` if a specified file was changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
View post-merge
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}
# `npm install` and `npm prune` if the `package.json` file gets changed
@mkrakauer-rio
mkrakauer-rio / table_size.sql
Created Dec 4, 2015
Calculate MySQL Table sizes
View table_size.sql
SELECT table_schema as `Database`, table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
@mkrakauer-rio
mkrakauer-rio / checkcron.sh
Created Oct 12, 2015
Check crontab for all users. Must be run as root
View checkcron.sh
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done