From 2316c468d05d2339f0f550aa7a39edbcb52a0450 Mon Sep 17 00:00:00 2001 From: Bin Date: Wed, 8 Mar 2017 14:24:49 -0800 Subject: [PATCH] major re-org --- .gitignore | 2 ++ aws.env | 1 + go.env | 11 +++++++++ java.env | 1 + k8s.env | 10 ++++++++ kafka.env | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ nodejs.env | 3 +++ runcoms/zprofile | 24 ++---------------- runcoms/zshrc | 38 ++++++++++++---------------- spark.env | 11 +++++++++ 10 files changed, 121 insertions(+), 44 deletions(-) create mode 100644 aws.env create mode 100644 go.env create mode 100644 java.env create mode 100644 k8s.env create mode 100644 kafka.env create mode 100644 nodejs.env create mode 100644 spark.env diff --git a/.gitignore b/.gitignore index e05465fe..0f979c92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.zwc *.zwc.old modules/*/cache.zsh +appuri.env +redshift.env \ No newline at end of file diff --git a/aws.env b/aws.env new file mode 100644 index 00000000..635f250a --- /dev/null +++ b/aws.env @@ -0,0 +1 @@ +export AWS_DEFAULT_REGION=us-west-2 diff --git a/go.env b/go.env new file mode 100644 index 00000000..e9025964 --- /dev/null +++ b/go.env @@ -0,0 +1,11 @@ +# conflict with go's gb +unalias gb &>/dev/null + +export GOROOT=/usr/local/go +export GOPATH=$MYSRC/gopath + +# Set the list of directories that Zsh searches for programs. +path=( + $path + $GOPATH/bin +) \ No newline at end of file diff --git a/java.env b/java.env new file mode 100644 index 00000000..4f14dadd --- /dev/null +++ b/java.env @@ -0,0 +1 @@ +export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home diff --git a/k8s.env b/k8s.env new file mode 100644 index 00000000..cde71805 --- /dev/null +++ b/k8s.env @@ -0,0 +1,10 @@ +source <(kubectl completion zsh) + +function kube-pod-restart { + SVC_TOKILL=$1 + NAMESPACE="${2-default}" + + if [ "$SVC_TOKILL" = "" ]; then exit 1; fi + + kubectl delete po --namespace $NAMESPACE $(kubectl get po --namespace $NAMESPACE | grep $SVC_TOKILL | awk '{print $1}' | tr '\n' ' ') +} diff --git a/kafka.env b/kafka.env new file mode 100644 index 00000000..0f394347 --- /dev/null +++ b/kafka.env @@ -0,0 +1,64 @@ +export KAFKA09=$MYSW/kafka + +function kafka-stop { + $KAFKA09/bin/zookeeper-server-stop.sh $KAFKA09/config/zookeeper.properties + sleep 3 + $KAFKA09/bin/kafka-server-stop.sh $KAFKA09/config/server.properties +} + +function kafka-start { + rm -rf /tmp/zookeeper /tmp/kafka-logs + $KAFKA09/bin/zookeeper-server-start.sh $KAFKA09/config/zookeeper.properties & + sleep 2 + $KAFKA09/bin/kafka-server-start.sh $KAFKA09/config/server.properties & + sleep 1 +} + +function kafka-topic-produce-zombie-raw { + kafka-topic-produce _test_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} +function kafka-topic-produce-zombie-sch { + kafka-topic-produce _test_sch_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} + +function kafka-topic-produce { + TOPIC="${1-}" + HOST="${2-localhost}" + PORT="${3-9092}" + + if [ "$TOPIC" = "" ]; then exit 1; fi + + $KAFKA09/bin/kafka-console-producer.sh --topic $TOPIC --broker-list $HOST:$PORT +} + +function kafka-topic-consume-zombie-raw { + kafka-topic-consume _test_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} +function kafka-topic-consume-zombie-sch { + kafka-topic-consume _test_sch_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} +function kafka-topic-consume { + TOPIC="${1-}" + HOST="${2-localhost}" + PORT="${3-9092}" + + if [ "$TOPIC" = "" ]; then exit 1; fi + + $KAFKA09/bin/kafka-topics.sh --zookeeper $HOST:$PORT --describe --topic $TOPIC +} + +function kafka-topic-create-zombie-raw { + kafka-topic-create _test_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} +function kafka-topic-create-zombie-sch { + kafka-topic-create _test_sch_events-1ebef931-8f30-49c9-9681-c5b22f5382d3 +} +function kafka-topic-create { + TOPIC="${1-}" + HOST="${2-localhost}" + PORT="${3-2181}" + + if [ "$TOPIC" = "" ]; then exit 1; fi + + $KAFKA09/bin/kafka-topics.sh --create --zookeeper $HOST:$PORT --replication-factor 1 --partitions 1 --topic $TOPIC +} \ No newline at end of file diff --git a/nodejs.env b/nodejs.env new file mode 100644 index 00000000..c01142d6 --- /dev/null +++ b/nodejs.env @@ -0,0 +1,3 @@ +export NVM_DIR="$HOME/.nvm" + +alias ejs='code -n ~/.eslintrc ~/.esformatter $MYTOOL/setup-js-lint-formatter.sh' diff --git a/runcoms/zprofile b/runcoms/zprofile index 4337e369..87ca4121 100644 --- a/runcoms/zprofile +++ b/runcoms/zprofile @@ -17,8 +17,8 @@ fi # Editors # -export EDITOR="code -n" -export VISUAL="code -n" +export EDITOR="vi" +export VISUAL="vim" export PAGER='less' # @@ -29,24 +29,6 @@ if [[ -z "$LANG" ]]; then export LANG='en_US.UTF-8' fi - -# -# Others -# -export MYSRC=$HOME/src -export MYSW=$HOME/sw -export MYDEV=$HOME/dev - -# AWS -export AWS_DEFAULT_REGION=us-west-2 - -# GO -export GOROOT=/usr/local/go -export GOPATH=$MYSRC/gopath - -# java -export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home - # # Paths # @@ -63,8 +45,6 @@ typeset -gU cdpath fpath mailpath path path=( /usr/local/{bin,sbin} $path - $GOPATH/bin - $MYDEV ) # diff --git a/runcoms/zshrc b/runcoms/zshrc index 8e54cfee..f8c8643b 100644 --- a/runcoms/zshrc +++ b/runcoms/zshrc @@ -9,29 +9,23 @@ fi unsetopt correct export PSQL_EDITOR="vi" - -export KAFKA09=$MYSW/kafka -export HADOOP_HOME=/usr/local/opt/hadoop/libexec -export HIVE_HOME=/usr/local/opt/hive/libexec -export HCAT_HOME=/usr/local/opt/hive/libexec/hcatalog export HOMEBREW_CASK_OPTS=--caskroom=/opt/homebrew-cask/Caskroom -# node -export NVM_DIR="$HOME/.nvm" +export MYENV=$HOME/.myenv +export MYSRC=$HOME/src +export MYSW=$HOME/sw +export MYTOOL=$HOME/tool -# alias alias sz='source ~/.zshrc' -alias ez='code -n ~/.zprezto/' -alias ec='code -n $MYDEV' - -alias cdsrc='cd $MYSRC' -alias cdsw='cd $MYSW' -alias cddev='cd $MYDEV' - -alias cdapi='cd $MYSRC/api-server && nvm use' -unalias gb - -source $MYDEV/appuri.env -source $MYDEV/api-server.env - -source <(kubectl completion zsh) \ No newline at end of file +alias ez='code -n ~/.zprezto/ ' +alias et='code -n $MYTOOL' + +source ${MYENV}/aws.env +source ${MYENV}/go.env +source ${MYENV}/nodejs.env +source ${MYENV}/java.env +source ${MYENV}/appuri.env +source ${MYENV}/redshift.env +source ${MYENV}/k8s.env +source ${MYENV}/kafka.env +source ${MYENV}/spark.env diff --git a/spark.env b/spark.env new file mode 100644 index 00000000..50765894 --- /dev/null +++ b/spark.env @@ -0,0 +1,11 @@ +export HADOOP_HOME=/usr/local/opt/hadoop/libexec +export HIVE_HOME=/usr/local/opt/hive/libexec +export HCAT_HOME=/usr/local/opt/hive/libexec/hcatalog + +function parquet-tools { + ARGS="$@" + + if [ "$ARGS" = "" ]; then ARGS="--help"; fi + + java -jar $MYSRC/parquet-mr/parquet-tools/target/parquet-tools-1.6.0rc4.jar $ARGS +} \ No newline at end of file