Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
arron-green committed Sep 24, 2020
1 parent ed7c09a commit 1a274f1
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 16 deletions.
112 changes: 97 additions & 15 deletions profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export EDITOR=$(command -v vim)
function echo-err() {
printf "%s\n" "$*" >&2;
}
export -f echo-err

function ps1-prompt() {
# current working directory
Expand Down Expand Up @@ -52,6 +53,7 @@ function ps1-prompt() {
END="${COLOR_GREEN}\$${COLOR_NIL} "
export PS1="${PS1_PREFIX}${VENV}${GIT} ${END}"
}
export -f ps1-prompt
export PROMPT_COMMAND=ps1-prompt
BREW_PREFIX=$(brew --prefix)

Expand Down Expand Up @@ -157,22 +159,24 @@ function docker-init {

function docker-image-grep {
QUIET=false
IMAGE=()
while [[ $# -gt 0 ]] && [[ ."$1" = .--* ]] ;do
opt="$1"; shift;
case "$opt" in
"--" ) break 2;;
"--image" )
IMAGE="$1"; shift;;
"--image="* ) # alternate format: --first=date
IMAGE="${opt#*=}";;
"-q" )
QUIET=true;;
"--quiet" )
QUIET=true;;
*) echo >&2 "Invalid option: $@";
"-q" | "--quiet" )
QUIET=true
;;
-*)
echo >&2 "Invalid option: $@";
return 1;;
*)
IMAGE+=("${1}");
shift;
;;
esac
done
IMAGE=$( IFS=$'|'; echo "${IMAGE[*]}" )

JSON=$(docker images --format '{{json .}}' | jq --arg IMAGE $IMAGE -rc 'select(.Repository | test($IMAGE))')
if [[ "$?" == "0" ]]; then
Expand Down Expand Up @@ -317,7 +321,8 @@ function ack-json-log {
}


GRAALVM_VERSION="java8-20.0.0"
# GRAALVM_VERSION="java8-20.0.0"
GRAALVM_VERSION="java11-20.0.0"
GRAALVM_HOME="/Library/Java/JavaVirtualMachines/graalvm-ce-${GRAALVM_VERSION}"
# On macOS Catalina, you may get a warning that "the developer cannot be
# verified". This check can be disabled in the "Security & Privacy"
Expand All @@ -327,7 +332,7 @@ GRAALVM_HOME="/Library/Java/JavaVirtualMachines/graalvm-ce-${GRAALVM_VERSION}"
# export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
if [[ -e "${GRAALVM_HOME}/Contents/Home" ]]; then
export JAVA_HOME="${GRAALVM_HOME}/Contents/Home"
export PATH="${JAVA_HOME}/bin:${PATH}"
# export PATH="${JAVA_HOME}/bin:${PATH}"
fi

export GRADLE_HOME="${BREW_PREFIX}/opt/gradle"
Expand All @@ -340,7 +345,8 @@ if [[ -d "${BREW_SCALA_HOME}/bin" ]]; then
export SCALA_HOME="$(find-scala-home)"
fi

export PATH="$HOME/.bin:/usr/local/sbin:$PATH"
export HOME_BIN="${HOME}/.bin"
export PATH="${HOME_BIN}:/usr/local/sbin:$PATH"

export LOCAL_BIN_HOME="${HOME}/.local/bin"
if [[ -d ${LOCAL_BIN_HOME} ]]; then
Expand All @@ -356,7 +362,7 @@ export OPENSSL_HOME="${BREW_PREFIX}/opt/openssl"
export PATH="$OPENSSL_HOME/bin:$PATH"


export CONFLUENT_VERSION="5.3.1"
export CONFLUENT_VERSION="5.5.0"
export CONFLUENT_SCALA_VERSION="2.12"
export CONFLUENT_HOME="/usr/local/confluent-${CONFLUENT_VERSION}"
if [[ -d ${CONFLUENT_HOME}/bin ]]; then
Expand All @@ -379,7 +385,7 @@ function confluent-cli-install {
CLI_URL="https://s3-us-west-2.amazonaws.com/confluent.cloud/confluent-cli/archives/latest/${CLI_FILE}"
curl --silent -L -o ${CLI_DL_FILE} -C - ${CLI_URL}
tar -C /tmp -xvf ${CLI_DL_FILE}
cp /tmp/confluent/confluent ${HOME}/.bin
cp /tmp/confluent/confluent ${HOME_BIN}
}

function mk-kafka-topic-compact {
Expand Down Expand Up @@ -411,6 +417,27 @@ function pid-of-port {
fi
}

function coursier-update {
[[ -d "${HOME_BIN}" ]] || mkdir -p "${HOME_BIN}"
curl --silent --fail -Lo ${HOME_BIN}/cs "https://git.io/coursier-cli-macos" \
&& chmod +x ${HOME_BIN}/cs \
&& (xattr -d com.apple.quarantine ${HOME_BIN}/cs || true) \
&& ${HOME_BIN}/cs
}

function password-env {
local ENV_VAR="${1}"
if [[ -n "${ENV_VAR}" ]]; then
echo -n "Assign password to ${ENV_VAR}: "
stty -echo
read ${ENV_VAR}
stty echo
echo
else
echo-err "Usage: ${0} [env-var]"
fi
}

if [[ -d $BREW_PREFIX/opt/curl/bin ]]; then
export PATH="$BREW_PREFIX/opt/curl/bin:$PATH"
fi
Expand Down Expand Up @@ -506,6 +533,61 @@ function http-python {
esac
}

function kafka-topic-size {
local BOOTSTRAP_SERVERS="${1}"
local TOPIC="${2}"
OUTPUT="$(kafka-log-dirs \
--bootstrap-server "${BOOTSTRAP_SERVERS}" \
--topic-list "${TOPIC}" \
--describe | egrep '^{' \
| jq -rc \
--arg TOPIC "${TOPIC}" \
'{topic: $TOPIC, size: ([ ..|.size? | numbers ] | add)}')"
SIZE="$(jq -rc '.size'<<<${OUTPUT})"
HR="$(numfmt --to=iec<<<${SIZE})"
RESULT="$(jq -rc --arg HR "${HR}" '.+={hr: $HR}'<<<${OUTPUT})"
echo-err "${RESULT}"
echo "${RESULT}"
}
export -f kafka-topic-size

function kafka-topics-report2 {
local BOOTSTRAP_SERVERS="${1}"
if [[ -z "${BOOTSTRAP_SERVERS}" ]]; then
echo-err "usage: $0 [instance-ids]"
else
REPORT="$(mktemp -t kafka-topics-report)"
kafka-topics \
--bootstrap-server "${BOOTSTRAP_SERVERS}" \
--list \
| xargs -n 1 -P8 -I {} bash -c "$(printf 'kafka-topic-size "%s" $@' ${BOOTSTRAP_SERVERS})" _ {} > ${REPORT}
jq --slurp -rc 'sort_by(.size * -1) | .[]' ${REPORT}
fi
}

function kafka-topics-report {
local BOOTSTRAP_SERVERS="${1}"
if [[ -z "${BOOTSTRAP_SERVERS}" ]]; then
echo-err "usage: $0 [instance-ids]"
else
TOPICS="$(mktemp -t kafka-topics)"
REPORT="$(mktemp -t kafka-topics-report)"
kafka-topics --bootstrap-server "${BOOTSTRAP_SERVERS}" --list > "${TOPICS}"
while read TOPIC; do
OUTPUT="$(kafka-log-dirs \
--bootstrap-server "${BOOTSTRAP_SERVERS}" \
--topic-list "${TOPIC}" \
--describe | egrep '^{' \
| jq -rc \
--arg TOPIC "${TOPIC}" \
'{topic: $TOPIC, size: ([ ..|.size? | numbers ] | add)}')"
SIZE="$(jq -rc '.size'<<<${OUTPUT})"
HR="$(numfmt --to=iec<<<${SIZE})"
jq -rc --arg HR "${HR}" '.+={hr: $HR}'<<<${OUTPUT}
done < <(kafka-topics --bootstrap-server "${BOOTSTRAP_SERVERS}" --list) | jq --slurp -rc 'sort_by(.size * -1) | .[]'
fi
}

alias "kctl"="kubectl"
alias "ip-addr"="ipconfig getifaddr en0"
alias "docker-rm-dangling"='docker rmi -f $(docker images -q --filter "dangling=true")'
Expand Down Expand Up @@ -551,4 +633,4 @@ fi
eval "$(direnv hook bash)"

ulimit -S -n 2049
# export GOPATH=~/dev/go
export GOPATH=~/dev/go
19 changes: 18 additions & 1 deletion vscode.extensions
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
caarlos0.language-prometheus
casualjim.gotemplate
christian-kohler.npm-intellisense
dandric.vscode-jq
Expand All @@ -9,27 +10,42 @@ eamodio.gitlens
eg2.vscode-npm-script
esbenp.prettier-vscode
felipecaputo.git-project-manager
foxundermoon.shell-format
golang.go
hashicorp.terraform
IgorSbitnev.error-gutters
jkeys089.plantuml
jq-syntax-highlighting.jq-syntax-highlighting
k--kato.intellij-idea-keybindings
liamdawson.jsonnet-language
mdickin.markdown-shortcuts
mhutchie.git-graph
ms-azuretools.vscode-docker
ms-kubernetes-tools.vscode-kubernetes-tools
ms-mssql.mssql
ms-python.python
ms-vscode.Go
ms-vscode.vscode-typescript-tslint-plugin
ms-vsliveshare.vsliveshare
octref.vetur
panaeon.dhall-lang
panaeon.vscode-dhall-lsp-server
rakam.rakam-data-modeling
redhat.java
redhat.vscode-microprofile
redhat.vscode-quarkus
redhat.vscode-yaml
rmoff.ksql
scala-lang.scala
scalameta.metals
searKing.preview-vscode
shd101wyy.markdown-preview-enhanced
Somejack.mdoc-extension-pack
streetsidesoftware.avro
streetsidesoftware.code-spell-checker
tgriesser.avro-schemas
tht13.html-preview-vscode
timonwong.shellcheck
usernamehw.errorlens
VisualStudioExptTeam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
Expand All @@ -38,6 +54,7 @@ vscjava.vscode-java-test
vscjava.vscode-maven
vscodevim.vim
wholroyd.HCL
xrc-inc.jsonnet-formatter
yzane.markdown-pdf
yzhang.markdown-all-in-one
zxh404.vscode-proto3

0 comments on commit 1a274f1

Please sign in to comment.