Skip to content

Instantly share code, notes, and snippets.

@oroce

oroce/.functions

Created Oct 10, 2018
Embed
What would you like to do?
function onport(){
lsof -n -i4TCP:$1 | grep LISTEN
}
function tmuxhelp() {
open "https://gist.github.com/henrik/1967800"
}
function weather() {
curl -4 wttr.in
}
function killssh() {
PATTERN=""
if [ -n "$@" ]; then
PATTERN="$@"
fi
ps aux | grep ssh | grep "$PATTERN" | grep -v grep | awk '{print $2}' | xargs kill -9
}
function pdf-to-black-and-white() {
if [ "$1" == "" ]; then
echo -e "USAGE: pdf-to-black-and-white input.pdf\nIt will write an output.pdf\n\n pdf-to-black-and-white input.pdf out2.pdf\nit will an out2.pdf"
return 1
fi
OUTPUT="$2"
gs -sOutputFile=${OUTPUT-output.pdf} \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
$1
}
function optim-image() {
if [ "$1" == "" ]; then
echo "output is missing";
return -1;
fi
convert -strip -interlace Plane -quality 85% "$1" "$2"
}
function mkdirp {
mkdir -p $1 && pushd $1
}
function concat() {
ls *.{mp4,MP4,MOV,mov} 2>/dev/null | perl -ne 'print "file $_"' | ffmpeg -f concat -i - -c copy $1
}
function vudo() { eval "vagrant ssh -c \"cd /vagrant && $@\"" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment