Skip to content

Instantly share code, notes, and snippets.

@icchy
Last active May 2, 2018
Embed
What would you like to do?
zshfunc
function prezto-update() {
olddir=`pwd`
cd ~/.zprezto && git pull && git submodule update --init --recursive
cd $olddir
}
function swap() {
mv $1 .$1.myswp
mv $2 $1
mv .$1.myswp $2
}
function cv++() {
g++ $@ -lopencv_core -lopencv_highgui -lopencv_imgproc -std=c++0x
}
function glcc() {
gcc $@ -framework OpenGL -framework GLUT
}
function vm() {
case "$2" in
start)
/usr/local/bin/VBoxManage startvm "$1" --type headless
;;
stop|poweroff)
/usr/local/bin/VBoxManage controlvm "$1" acpipowerbutton
;;
save)
/usr/local/bin/VBoxManage controlvm "$1" savestate
;;
status)
/usr/local/bin/VBoxManage showvminfo "$1" | grep "State"
;;
esac
}
_vm() {
local words completions commands
read -cA words
commands=`cat <<EOS
start
stop
save
poweroff
status
EOS`
if [ "${#words}" -eq 2 ]; then
completions=$(ls -1 "$HOME/VirtualBox VMs/")
else
completions="$commands"
fi
reply=(${(ps:\n:)completions})
}
compctl -K _vm vm
function run_angr() {
if [ $# -gt 0 ]; then
WRAPPER=$(basename `mktemp`)
cat << EOF > $WRAPPER
#!/bin/sh
. ~/.virtualenvs/angr/bin/activate
rm -f \$0
\$@
EOF
chmod +x $WRAPPER
docker run \
-v `pwd`:/home/angr/mnt \
-u angr \
-w /home/angr/mnt \
-it --rm angr/angr \
./$WRAPPER $@
fi
}
function run_ctfbox() {
if [ $# -gt 0 ]; then
docker run \
-v `pwd`:/mnt \
-w /mnt \
-it --rm inaz2/ctfbox \
$@
fi
}
function ctfbox() {
docker run --privileged -v `pwd`:/mnt -w /mnt -it --rm inaz2/ctfbox /bin/bash
}
function docker_php() {
docker run --privileged -v `pwd`:/mnt -w /mnt -it --rm php:7.1 /usr/local/bin/php "$@"
}
function notify() {
osascript -e 'display notification "'$2'" with title "'$1'"'
}
function noerr() {
"$@" 2>/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment