Skip to content

Instantly share code, notes, and snippets.

@tommyvdv
tommyvdv / .bashrc
Last active March 8, 2019 07:45
Make(file) completion
# List make targets since this is not something make can do the way we want it to
list_make_targets() {
file=Makefile && [[ -f "$file" ]] && grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' "$file" | sed 's/[^a-zA-Z0-9_.-]*$//' || printf '"%s" not found\n' "$file"
}
# Tell (ba)sh completion to use function "list_make_targets" for completion
make_load_autocomplete() {
complete -W "\`list_make_targets\`" make
}
@tommyvdv
tommyvdv / sync.sh
Last active October 31, 2018 11:35
quick sync & reboot
#!/bin/bash
# usage:
# $ ./sync.sh /home/user/tmp/A /home/user/tmp/B /home/user/tmp/C /home/user/script.py
source="$1"
temp="$2"
destination="$3"
scriptpath="$4"
rsync -avr "${source}/" "${temp}/" > /dev/null
diff "${temp}" "${destination}" > /dev/null
exitcode="$?"
@tommyvdv
tommyvdv / bash-alias-docker-cleanup.sh
Created October 26, 2018 07:28
free up disk-space when done with docker
#!/bin/bash
alias dck="echo '-- docker cleanup: kill..' && docker ps -q | xargs docker kill"
alias dcrm="echo '-- docker cleanup: rm..' && docker ps -q | xargs docker rm"
alias dcrmi="echo '-- docker cleanup: rmi..' && docker images -q -f dangling=true | xargs docker rmi"
alias dcrmia="echo '-- docker cleanup: rmia..' && docker images -q | xargs docker rmi"
alias dockercleanup="echo '-- docker cleanup: all..' && dck; dcrm; dcrmi; dcrmia"
# usage, output:
# $ dockercleanup
# -- docker cleanup: all..
@tommyvdv
tommyvdv / osx-port-80.txt
Last active March 6, 2019 10:32
osx port 80
Port 80 happens to close every reboot.
Opening it should work using these. It is however quite unclear why my setup closes it (and others don't.
$ cat /etc/pf.conf
# Allow access to port 80
pass in proto tcp from any to any port 80
$ sudo pfctl -F all
No ALTQ support in kernel
@tommyvdv
tommyvdv / useful-linux-commands.md
Last active June 26, 2018 10:36
useful linux commands

Far from a comprehensive list.

Switching back and forth between directories using cd -;

$ cd ~/Downloads
$ cd ~/Documents
$ cd -

Use cd to enter directory Downloads then Document and then return to directory Downloads.

@tommyvdv
tommyvdv / rpi-resolution.md
Last active August 3, 2016 19:04
Raspberry Pi misc

resolution

from bleroy

tvservice -d edid
edidparser edid

example output: HDMI:EDID DMT mode (82) 1920x1080p @ 60 Hz with pixel clock 148 MHz

@tommyvdv
tommyvdv / after.png
Last active February 19, 2016 16:09
Making tabs stand out in Atom.
after.png
@tommyvdv
tommyvdv / git-tabs-in-indent-1.png
Last active February 22, 2016 08:17
Make tabs stand out in git.
git-tabs-in-indent-1.png
@tommyvdv
tommyvdv / gist:d978d8a4f0fafd302e41
Created October 14, 2015 06:31
Calendar incrementing badge
$HOME/Library/Calendars/Calendar\ Cache is a sqlite3 embedded database.
1) Close your Apple iCal.
2) Open your Terminal or any shell application
3) Go to the above directory "$HOME/Library/Calendars"
4) Open the db using "sqlite3 Calendar\ Cache"
5) ".tables" will show you all the tables in this database
6) "select * from ZMESSAGE" will show you all the pending notifications
7) To remove all the pending notifications, use "delete from ZMESSAGE;"
8) to quit, type ".quit"
# creates a new gitignore file that ignores everything except the gitignore file itself
add_gitignore()
{
directory=$1
if [[ "$directory" == "" ]]
then
directory="."
fi