diff --git a/.functions b/.functions index 08723cd..e80e365 100644 --- a/.functions +++ b/.functions @@ -86,7 +86,7 @@ function dig_in_parallel() { function digscan() { set +m; - subdomains=( a alert adm admin administration api apis api-gateway assets b back backend b2b b2c black blog bo board brown build builds c cache cached ceph cli client clients ci cloud conf config configuration console consul contact contacts contract contracts cust customer customers d dark dashboard database db dev demo directory display dl dns doc documentation domain domains download downloads e elasticsearch elb elk endpoint exchange exchanges ext extern external externals extra extranet f factory free files front frontend ftp g gateway geo git gitlab github go golang grafana graph graphs grey green group h ha haproxy health healths home host hosting hub hubs i int integ integration intra intranet j jenkins jira k kibana k8s kube kubectl kubernetes l light live lb loadbalancer loader logs m mail manager market marketing minio mobile monitor monitoring mongo mongodb mysql movie movies n nas new news no o open openshift opensource order orders p package packages packagist partner partners perso preprod priv private prive portal postgres postgresql pro pros purple q quality qualys r recette red redis reg registry rule rules root roots s s3 secret secrets share sale sales serv server servers smtp source sources ssh sso stat static statistics stats status storage store stream t test tests time timeline u v vault view views vol vols volume volumes vpn w web webmail white wiki work worker workers www x y yellow yes z zoo ) + subdomains=( a alert adm admin administration api apis api-gateway assets auth authentication b back backend b2b b2c black blog bo board brown build builds c cache cached ceph cli client clients ci cloud conf config configuration console consul contact contacts contract contracts cust customer customers d dark dashboard database db dev demo directory display dl dns doc documentation domain domains download downloads e elasticsearch elb elk endpoint exchange exchanges ext extern external externals extra extranet f factory free files front frontend ftp g gateway geo git gitlab github go golang grafana graph graphs grey green group h ha haproxy health healths home host hosting hub hubs i int integ integration intra intranet j jenkins jira k kibana k8s kube kubectl kubernetes l light live lb loadbalancer loader logs m mail manager market marketing minio mobile monitor monitoring mongo mongodb mysql movie movies n nas new news no o open openshift opensource order orders p package packages packagist partner partners perso preprod priv private prive portal postgres postgresql pro pros purple q quality qualys r recette red redis reg registry rule rules root roots s s3 secret secrets share sale sales serv server servers smtp source sources ssh sso stat static statistics stats status storage store stream t test tests time timeline u v vault view views vol vols volume volumes vpn w web webmail white wiki work worker workers www x y yellow yes z zoo ) echo "Checking...\n"; @@ -126,3 +126,58 @@ function track() { echo "$artist - $name" } + +# Find files and exec commands at them. +# $ find-exec .coffee cat | wc -l +# # => 9762 +function find-exec() { + find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; +} + +# Count code lines in some directory. +# $ loc py js css +# # => Lines of code for .py: 3781 +# # => Lines of code for .js: 3354 +# # => Lines of code for .css: 2970 +# # => Total lines of code: 10105 +function loc() { + local total + local firstletter + local ext + local lines + total=0 + for ext in $@; do + firstletter=$(echo $ext | cut -c1-1) + if [[ firstletter != "." ]]; then + ext=".$ext" + fi + lines=`find-exec "*$ext" cat | wc -l` + lines=${lines// /} + total=$(($total + $lines)) + echo "Lines of code for ${fg[white]}$ext${reset_color}: ${fg[yellow]}$lines${reset_color}" + done + echo "${fg[white]}Total${reset_color} lines of code: ${fg[yellow]}$total${reset_color}" +} + +# Uploads a file to transfer.sh and returns the public URL +# Usage: transfer +transfer() { + if [ $# -eq 0 ]; then + echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; + return 1; + fi + + tmpfile=$( mktemp -t transferXXX ); + + if tty -s; then + basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); + curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; + else + curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile; + fi + + cat $tmpfile; + echo "\n"; + rm -f $tmpfile; +} +