<reponame>medeiser/kubernetes-samples
#!/usr/bin/env bash

#
# Shell script for deploying a service dynamically using the config map template 'deployment-template.yaml'
#
# Usage: ./deploy-app.sh <app-name> <app-port>
#

set -euxo pipefail

# validate input
if [ "$#" -ne 2 ]
then
  echo "$0: Expected mandatory arguments <app-name>> and <app-port>"
	exit 3
fi

# replace application name and port variables
CONFIG_MAP=`cat "deployment-template.yaml" | sed "s/{{APP}}/$1/g" | sed "s/{{PORT}}/$2/g"`

# deploy service
echo "$CONFIG_MAP" | kubectl apply -f -


<reponame>SilasK/academic-kickstart<gh_stars>0
#!/usr/bin/env bash

hugo

# https://sourcethemes.com/academic/docs/deployment/


#!/bin/bash

#
# Copyright (C) 2011 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#     * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# This script checks a WebCore static library for potential Objective-C
# class name collisions with the system's copy of the WebCore framework.
# See the postbuild action that calls it from ../WebCore.gyp for details.

set -e
set -o pipefail

if [[ $# -ne 2 ]]; then
  echo "usage: ${0} class_whitelist_pattern category_whitelist_pattern" >& 2
  exit 1
fi

lib="${BUILT_PRODUCTS_DIR}/${FULL_PRODUCT_NAME}"
nm_pattern='[atsATS] ([+-]\[|\.objc_class_name_)'

class_whitelist_pattern="${1}"
category_whitelist_pattern="${2}"

# Send nm's stderr in the pipeline to /dev/null to avoid spewing
# "nm: no name list" messages. This means that if the pipelined nm fails, there
# won't be any output, so if the entire assignment fails, run nm again to get
# some output.
violators=$(nm -p "${lib}" 2> /dev/null | \
    (grep -E "${nm_pattern}" || true) | \
    (grep -Ev "${nm_pattern}(${class_whitelist_pattern})" || true) | \
    (grep -Ev "\((${category_whitelist_pattern})\)" || true)) || nm -p "${lib}"

if [[ -z "${violators}" ]]; then
  # An empty list means that everything's clean.
  exit 0
fi

cat << __EOF__ >&2
These Objective-C symbols may clash with those provided by the system's own
WebCore framework:
${violators}

These symbols were found in:
${lib}

This should be corrected by adding the appropriate definitions to
$(dirname ${0})/../WebCore.gyp
or by updating the whitelist in
${0}
__EOF__

exit 1


#!/bin/bash
# process named arguments
for ARGUMENT in "$@"
do

    KEY=$(echo $ARGUMENT | cut -f1 -d=)
    VALUE=$(echo $ARGUMENT | cut -f2 -d=)

    case "$KEY" in
            GPUS)     GPUS=${VALUE} ;;
            BG) BG=${VALUE} ;;
            MODEL)     MODEL=${VALUE} ;;
            *)
    esac
done

GPUS=${GPUS:-0}
BG=${BG:-0}
MODEL=${MODEL:-"transformer"}

# since nohup creates its own child process to run train function,
# we have export them as env variables

export EX_POSTFIX=$(date +%T | sed "s/:/-/g" | echo "-$(cat -)")
export ARCH=$MODEL"_wmt_en_de"
export DATA=data-bin/wmt16_en_de_bpe32k
export CKPT_DIR="checkpoints/""${ARCH//_/-}""$EX_POSTFIX"
export UPDATE_FREQ=$(( 8 / (1 + (${#GPUS} / 2)) ))
mkdir -p $CKPT_DIR

train() {
    fairseq-train $DATA \
            --arch $ARCH --share-all-embeddings \
            --optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 \
            --lr-scheduler inverse_sqrt --warmup-init-lr 1e-07 --warmup-updates 4000 \
            --lr 0.0007 --stop-min-lr 1e-09 --dropout 0.1\
            --tensorboard-logdir $CKPT_DIR --seed 2\
            --best-checkpoint-metric ppl\
            --criterion label_smoothed_cross_entropy --label-smoothing 0.1 --weight-decay 0.0\
            --max-tokens  4096 --save-dir $CKPT_DIR\
            --update-freq $UPDATE_FREQ --no-progress-bar --log-interval 50\
            --save-interval 10  --keep-last-epochs 1 --max-update 275000\
            --save-interval-updates  1000 --keep-interval-updates 15 --ddp-backend=no_c10d
}
export -f train

# nohup sh -c '(date > fmt1 2>&1 ; sleep 2; date > fmt2)' &

if [ $BG == 1 ];
then
    CUDA_VISIBLE_DEVICES=$GPUS nohup bash -c "train" > $CKPT_DIR/train.output 2>&1 &
else
    CUDA_VISIBLE_DEVICES=$GPUS train
fi


# check number of arguments
if [ $# != 1 ]; then
    echo "error: Wrong number of arguments. Only version number should be provided."
    echo "Script stopped..."
    exit
fi

TMUX_VER=$1
VER_REGEX='^[0-9]+([.][0-9]+)?$'
if ! [[ $TMUX_VER =~ $VER_REGEX ]] ; then
    echo "error: please provide a valid version number (character is not accepted)." >&2; exit 1
fi

echo "tmux v$TMUX_VER is going to be installed..."
#: <<'END'  # this is used to comment out below code to debug above logic"

# install deps
yum install gcc kernel-devel make ncurses-devel

# DOWNLOAD SOURCES FOR LIBEVENT AND MAKE AND INSTALL
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar -xvzf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/local
make
sudo make install

# DOWNLOAD SOURCES FOR TMUX AND MAKE AND INSTALL
wget https://github.com/tmux/tmux/releases/download/2.6/tmux-2.6.tar.gz
tar -xvzf tmux-2.6.tar.gz
cd tmux-2.6
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local
make
sudo make install

# pkill tmux
# close your terminal window (flushes cached tmux executable)
# open new shell and check tmux version
tmux -V

#END


#!/usr/bin/env bash
# MIT License
#
# Copyright (c) 2022, <NAME> Computer Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

set -e

if [[ -z "${ANALYZE_CONTAINERS_ROOT_DIR}" ]]; then
  echo "ANALYZE_CONTAINERS_ROOT_DIR variable is not set"
  echo "Please run '. initShell.sh' in your terminal first or set it with 'export ANALYZE_CONTAINERS_ROOT_DIR=<path_to_root>'"
  exit 1
fi

# Load common functions
source "${ANALYZE_CONTAINERS_ROOT_DIR}/utils/commonFunctions.sh"
source "${ANALYZE_CONTAINERS_ROOT_DIR}/utils/serverFunctions.sh"
source "${ANALYZE_CONTAINERS_ROOT_DIR}/utils/clientFunctions.sh"

# Load common variables
source "${ANALYZE_CONTAINERS_ROOT_DIR}/examples/pre-prod/utils/simulatedExternalVariables.sh"
source "${ANALYZE_CONTAINERS_ROOT_DIR}/utils/commonVariables.sh"
source "${ANALYZE_CONTAINERS_ROOT_DIR}/utils/internalHelperVariables.sh"

warnRootDirNotInPath
###############################################################################
# Running a new Solr container                                                #
###############################################################################
print "Running a new Solr container"
runSolr "${SOLR3_CONTAINER_NAME}" "${SOLR3_FQDN}" "${SOLR3_VOLUME_NAME}" "8985" "solr3" "${SOLR3_SECRETS_VOLUME_NAME}"
waitForSolrToBeLive "${SOLR3_FQDN}"

###############################################################################
# Adding a Solr replica                                                       #
###############################################################################
print "Adding a Solr replica"

# The curl command uses the container's local environment variables to obtain the SOLR_ADMIN_DIGEST_USERNAME and SOLR_ADMIN_DIGEST_PASSWORD.
# To stop the variables being evaluated in this script, the variables are escaped using backslashes (\) and surrounded in double quotes (").
# Any double quotes in the curl command are also escaped by a leading backslash.
runSolrClientCommand bash -c "curl -u \"\${SOLR_ADMIN_DIGEST_USERNAME}:\${SOLR_ADMIN_DIGEST_PASSWORD}\" --cacert ${CONTAINER_CERTS_DIR}/CA.cer \"${SOLR1_BASE_URL}/solr/admin/collections?action=ADDREPLICA&collection=main_index&shard=shard1&node=${SOLR3_FQDN}:8983_solr\""


<gh_stars>0
#!/bin/bash

VERSION=${1:-latest}
BASE_PATH=installer/manifests

# Note: Currently, the Helm chart always has version 0.1.0 and
# $VERSION cannot be used as it is an invalid Semantic Version
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
helm dependency build ${BASE_PATH}/keptn/charts/control-plane

helm package ${BASE_PATH}/keptn --app-version latest --version 0.1.0
if [ $? -ne 0 ]; then
  echo 'Error packing installer, exiting...'
  exit 1
fi

mkdir keptn-charts/
mv keptn-0.1.0.tgz keptn-charts/

helm repo index keptn-charts --url https://storage.googleapis.com/keptn-installer/${VERSION}
if [ $? -ne 0 ]; then
  echo 'Error generating index.yaml, exiting...'
  exit 1
fi

# upload to gcloud
gsutil cp keptn-charts/index.yaml gs://keptn-installer/${VERSION}/index.yaml
gsutil cp keptn-charts/keptn-0.1.0.tgz gs://keptn-installer/${VERSION}/keptn-0.1.0.tgz


<reponame>centrevillage/cv_logue_oscillators
cd ../../ && bundle exec ruby script/wave_converter.rb osc/mist/res/wav osc/mist --format=src


<gh_stars>0
#!/bin/bash

mkdir -p fields/omg
mkdir -p fields/phi
mkdir -p fields/rho
mkdir -p fields/data

mkdir -p ksre/omg
mkdir -p ksre/phi
mkdir -p ksre/rho
mkdir -p ksre/data

mkdir -p ksim/omg
mkdir -p ksim/phi
mkdir -p ksim/rho
mkdir -p ksim/data

mkdir -p kx_ensp/omg
mkdir -p kx_ensp/phi
mkdir -p kx_ensp/rho
mkdir -p kx_ensp/data

mkdir -p ky_ensp/omg
mkdir -p ky_ensp/phi
mkdir -p ky_ensp/rho
mkdir -p ky_ensp/data

mkdir -p velocity/vx
mkdir -p velocity/vy
mkdir -p velocity/data

mkdir -p kdata

mkdir -p pbk/data

if [[ -e n00000_t00.000000.dat ]]; then
  mv n*.dat fields/data
fi

if [[ -e ksre_t00.000000.dat ]]; then
  mv ksre*.dat ksre/data
fi
if [[ -e ksim_t00.000000.dat ]]; then
  mv ksim*.dat ksim/data
fi

if [[ -e kx_ensp.txt ]]; then
  mv kx_ensp.txt kx_ensp/data
  mv kx*.dat kx_ensp/data
fi
if [[ -e ky_ensp.txt ]]; then
  mv ky_ensp.txt ky_ensp/data
  mv ky*.dat ky_ensp/data
fi

if [[ -e befk_n00000_t00.000000.dat ]]; then
  mv bef*.dat kdata
fi
if [[ -e after_kdata.txt ]]; then
  rm after_kdata.txt
  mv aft*.dat kdata
fi

if [[ -e vel_t00.000000.dat ]]; then
  mv vel*.dat velocity/data
fi

if [[ -e pbk.txt ]]; then
  mv pbk.txt pbk/data
  mv pbk*.dat pbk/data
fi

cd fields/data
if [[ -e n00000_t00.000000.dat ]]; then
  gnuplot ../../gp_files/plot_fields_omg.gp
  mv *.png ../omg

  gnuplot ../../gp_files/plot_fields_phi.gp
  mv *.png ../phi

  gnuplot ../../gp_files/plot_fields_rho.gp
  mv *.png ../rho
fi
cd ../..

cd ksre/data
if [[ -e ksre_t00.000000.dat ]]; then
  gnuplot ../../gp_files/plot_kspace_omg.gp
  mv *.png ../omg

  gnuplot ../../gp_files/plot_kspace_phi.gp
  mv *.png ../phi

  gnuplot ../../gp_files/plot_kspace_rho.gp
  mv *.png ../rho
fi
cd ../..

cd ksim/data
if [[ -e ksim_t00.000000.dat ]]; then
  gnuplot ../../gp_files/plot_kspace_omg.gp
  mv *.png ../omg

  gnuplot ../../gp_files/plot_kspace_phi.gp
  mv *.png ../phi

  gnuplot ../../gp_files/plot_kspace_rho.gp
  mv *.png ../rho
fi
cd ../..

cd kx_ensp/data
if [[ -e kx_ensp.txt ]]; then
  rm kx_ensp.txt

  gnuplot ../../gp_files/plot_kx_ensp_omg.gp
  mv *.eps ../omg

  gnuplot ../../gp_files/plot_kx_ensp_phi.gp
  mv *.eps ../phi

  gnuplot ../../gp_files/plot_kx_ensp_rho.gp
  mv *.eps ../rho
fi
cd ../..

cd ky_ensp/data
if [[ -e ky_ensp.txt ]]; then
  rm ky_ensp.txt

  gnuplot ../../gp_files/plot_ky_ensp_omg.gp
  mv *.eps ../omg

  gnuplot ../../gp_files/plot_ky_ensp_phi.gp
  mv *.eps ../phi

  gnuplot ../../gp_files/plot_ky_ensp_rho.gp
  mv *.eps ../rho
fi
cd ../..

cd velocity/data
if [[ -e vel_t00.000000.dat ]]; then
  gnuplot ../../gp_files/plot_vx.gp
  mv *.png ../vx

  gnuplot ../../gp_files/plot_vy.gp
  mv *.png ../vy
fi
cd ../..

cd pbk/data
if [[ -e pbk.txt ]]; then
  rm pbk.txt

  gnuplot ../../gp_files/plot_pbk.gp
  mv *.png ../
fi
cd ../..


python generate.py \
    -cfg='./configs/styleformer_cifar10.yaml' \
    -num_out_images=16 \
    -out_folder='./images_cifar10' \
    -pretrained='./cifar10.pdparams'


<reponame>msmbuilder/msmexplorer
#!/bin/bash

# Print each line, exit on error
set -ev

# Install the built package
conda create --yes -n docenv python=$CONDA_PY
source activate docenv
conda install -yq --use-local msmexplorer

# We don't use conda for these:
# sphinx_rtd_theme's latest releases are not available
# neither is msmb_theme
# neither is sphinx > 1.3.1 (fix #1892 autodoc problem)
pip install -I urllib3 sphinx sphinx_bootstrap_theme

# Install doc requirements
conda install --yes --file docs/requirements.txt

# Make docs
cd docs && make html && cd -

# Move the docs into a versioned subdirectory
python devtools/travis-ci/set_doc_version.py

# Prepare versions.json
python devtools/travis-ci/update_versions_json.py


<filename>obfuscated.sh
#=---------=# case-esac based arg parser and help screen generator #=---------=#
p(){ printf "$@";};e=$(p '\033');G="${e}[32m";Y="${e}[33m";R="${e}[0m";I="   ";
    g(){ grep "$@";};t(){ p "%b$1:%b\n" "$Y" "$R";}; i(){ p "$I";};usage(){
      >&2 t "USAGE";echo;i; >&2 p "%b [SUBCOMMAND]\n\n" "$(basename "$0")"
   >&2 t "FLAGS";sed -n '/case $[0-9] in/,$p' "$0"|g '([^)]*)'|g '(\-\|(\--'|
sed "/(\*)/d;s/\t/${I}/g;s/ #\([^#]*\)/\1/g;s/|/$R, $G/g;s/(/$G/g;s/)/$R/g";echo
 >&2 t "SUBCOMMANDS";sed -n '/case $[0-9] in/,$p' "$0"|g '([^)]*)'|g -v '(\-'|
     sed "/(\*)/d;s/\t/${I}/g"|sed "s/#\([^#]*\)/\1/g;s/(/$G/g;s/)/$R/g";}
#=-----------------------=# like a vegan burger huh #=------------------------=#


#! /bin/bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

STOLON_PODNAME="oisp-stolon-keeper-0"
STOLON_SERVICE="postgres"
ZALANDO_PODNAME="acid-oisp-0"
ZALANDO_SERVICE="acid-oisp"
ZALANDO_DBNAME="oisp"

ZALANDO_OISP_USER="oisp_user"
NAMESPACE="${NAMESPACE:-oisp}"

TMPDIR="/tmp/stolon-zalando-migration/"
echo "Migrating from ${STOLON_HOSTNAME} to ${ZALANDO_HOSTNAME}, dumping to: /tmp/${TMPDIR}"

# Dump Stolon DB to TMPDIR/database.sql
rm -rf ${TMPDIR}/database.sql
(export TMPDIR && export DBHOSTNAME=${STOLON_SERVICE} && export NAMESPACE=${NAMESPACE} && cd $DIR/../../ && make backup-db) || (echo "DB dumping from Stolon failed" && exit 1)
echo "Done dumping Stolon to ${TMPDIR}/database.sql"

(kubectl -n ${NAMESPACE} exec ${ZALANDO_PODNAME} -- psql -U superuser -l | grep "oisp" && echo "DB Oisp found") || \
    (echo "Creating db" && \
	 kubectl -n ${NAMESPACE} exec ${ZALANDO_PODNAME} -- psql -d postgres -U superuser -c "CREATE DATABASE oisp;" && \
	 kubectl -n ${NAMESPACE} exec ${ZALANDO_PODNAME} -- psql -d postgres -U superuser -c "ALTER DATABASE oisp OWNER TO ${ZALANDO_OISP_USER};")

echo "Database oisp exists, ready for migration"
(export TMPDIR && export DBHOSTNAME=${ZALANDO_SERVICE} && export NAMESPACE && cd $DIR/../../ && \
     make restore-db) || (echo "DB restoration failed" && exit 1)

echo "Found following users and maybe more (sanity check:)"
kubectl -n ${NAMESPACE} exec ${ZALANDO_PODNAME} -- psql -d oisp -U oisp_user -c "SELECT email FROM dashboard.users;" | tail

echo "Data migration successful, configuration can be updated to use Zalando from now on."


#!/bin/sh

cat os.map | awk '{split($0,part,"|"); print part[1]"\n"part[2]}' | xargs -n 2 bash -c 'GOOS=$0 GOARCH=$1 CGO_ENABLED=0 go build -o ./out/gtg-$0-$1 ./cmd/gtg/main.go'


<reponame>keadyk/Draco<gh_stars>0
#!/bin/bash
#-----------------------------------------------------------------------------#
# Darwin Environment setups (Power9)
#-----------------------------------------------------------------------------#

source $draco_script_dir/darwin-env.sh

# symlinks will be generated for each machine that point to the correct
# installation directory.
export siblings="darwin-x86_64"

# The following toolchains will be used when releasing code:
environments="x86gcc730env"

# Special setup for CTS-1: replace the 'draco-latest' symlink
(cd /usr/projects/$package; if [[ -L draco-latest ]]; then rm draco-latest; fi; ln -s $source_prefix draco-latest)

#------------------------------------------------------------------------------#
# Specify environments (modules)
#------------------------------------------------------------------------------#

case $ddir in

  #---------------------------------------------------------------------------#
  draco-7_2* | draco-7_3* | draco-7_4*)
    function x86gcc730env()
    {
      export darwin_queue="-p volta-v100-x86"
      run "module purge"
      module use --append ${VENDOR_DIR}/user_contrib
      module use --append ${VENDOR_DIR}-ec/Modules/$DRACO_ARCH
      module load user_contrib

      cflavor="gcc-7.3.0"
      mflavor="$cflavor-openmpi-3.1.3"
      lapackflavor="lapack-3.8.0"
      noflavor="emacs git ack gcc/7.3.0 cuda/10.1"
      compflavor="cmake/3.14.2-$cflavor gsl/2.5-$cflavor
netlib-lapack/3.8.0-$cflavor numdiff/5.9.0-$cflavor random123/1.09-$cflavor
metis/5.1.0-$cflavor eospac/6.4.0-$cflavor openmpi/3.1.3-gcc_7.3.0"
      mpiflavor="parmetis/4.0.3-$mflavor superlu-dist/5.2.2-$mflavor-$lapackflavor trilinos/12.14.1-cuda-10.1-$mflavor-$lapackflavor"
      ec_mf="ndi"

      export dracomodules="$noflavor $compflavor $mpiflavor $ec_mf"
      for m in $dracomodules; do
        module load $m
      done
      export CXX=`which g++`
      export CC=`which gcc`
      export FC=`which gfortran`
      export MPIEXEC_EXECUTABLE=`which mpirun`
      unset MPI_ROOT
      run "module list"
    }
    ;;

  *)
    die "darwin-x86_64-env.sh:: did not set any build environments, ddir = $ddir."
    ;;

  #---------------------------------------------------------------------------#

esac

#------------------------------------------------------------------------------#
# Sanity check
#------------------------------------------------------------------------------#

for env in $environments; do
  if [[ `fn_exists $env` -gt 0 ]]; then
    if [[ $verbose ]]; then echo "export -f $env"; fi
    export -f $env
  else
    die "Requested environment $env is not defined."
  fi
done

##---------------------------------------------------------------------------##
## End
##---------------------------------------------------------------------------##


ruby_version=$(ruby -e 'puts RUBY_VERSION')

git apply --ignore-space-change --ignore-whitespace '.azure-pipelines\rbreadline.diff' --directory="C:/hostedtoolcache/windows/Ruby/$ruby_version/x64/lib/ruby/site_ruby" --unsafe-paths


<filename>shell/spark/submit-app.sh
#!/bin/bash

# submit a application
$SPARK_HOME/bin/spark-submit \
    --class cn.neyzoter.aiot.fddp.FddpApplication \
    --master spark://localhost:7077 \
    /home/scc/code/java/aiot/fddp/target/fddp*.jar


function show_usage_and_exit
{
  printf "\nUsage: $(basename $0) <final_size(MB)>"; exit -1;
}

[ $# -eq 0 ] && show_usage_and_exit

################################################################################
#                                                                              #
# Main                                                                         #
#                                                                              #
################################################################################

final_size=$1
if [ $final_size -eq 0 ]; then
  echo "Final size 0 MB requested, nothing to do."
  exit 0
fi

paging_space_size=`lsps -s | tail -1 | awk '{print $1}' | sed -e '/MB/s///'`

if (( $paging_space_size < $final_size )) ; then
  page_lv=`lsvg -l rootvg | fgrep paging | awk '{print $1}'`

  # Find the physical partition size for allocating paging space(MB's)
  ppsize=`/usr/sbin/lsvg rootvg |grep 'PP SIZE' |awk '{print $6}'`

  _num_pps=$(echo "($final_size - $paging_space_size) / $ppsize" | bc -l)
  asize=$(( `echo $_num_pps|cut -f1 -d"."` + 1 ))
  echo "Adding $asize segments to Paging"
  echo "/usr/sbin/chps -s $asize $page_lv"
  /usr/sbin/chps -s $asize $page_lv
  echo "Paging LV $page_lv changed."

  paging_space_size=`lsps -s | tail -1 | awk '{print $1}' | sed -e '/MB/s///'`

  if (( $paging_space_size < $final_size )) ; then
    error_if_non_zero 50 "Failure to increase paging size"
  else
    echo "Paging size is = ${paging_space_size} MB"
  fi

else
  echo "Current paging size $paging_space_size MB >= requested $final_size MB. No action taken."

fi

exit 0


#!/usr/bin/env bash
docker build -t python-base:latest -f Dockerfile.base .


#!/usr/bin/env bash
function upRegistry() {
    # IMPORTANT: REGISTRY_STORAGE_DELETE_ENABLED=true mandatory for delete rights
    docker run -d -p ${port}:5000 -e REGISTRY_STORAGE_DELETE_ENABLED=true --name ${containerName} registry:2
}

# setImage source targetTag
function setImage() {
    docker pull alpine:$1
    docker tag alpine:$1 localhost:${port}/test-project:$2
    docker push localhost:${port}/test-project:$2
}

#
# SCRIPT
#
containerName=dregcli_lab_registry
port=5001

upRegistry

# layer with only commit tags
setImage 3.2 master-2ze98e000wx39d60a7390925d0czr3qs03j90aaa-1382

# a layer with a release tag between 2 layers with only commit tags
setImage 3.3 master-2yu50j111dy72e70b9623522e0zdt9wz29h71ddd-1383
setImage 3.3 alpha

# layer with only commit tags
setImage 3.4 master-2bd32d000ez93c50h8486935f0fda5ee09z98bbb-1384

# layers with release tags
# old-prod layer
setImage 3.5 master-6da64c000cf59c30e4841371e0dac3dd02c31aaa-1385
setImage 3.5 old-prod

# prod layer
setImage 3.6 master-b2a7d05ca36cdd3e8eb092f857580b3ed0f7159a-1386
setImage 3.6 prod

# old-staging layer
setImage 3.7 master-1c48755c0b257ccd106badcb973a36528f833fc0-1387
setImage 3.7 old-staging

# staging layer
setImage 3.8 master-128a1e13dbe96705917020261ee23d097606bda2-1388
setImage 3.8 staging

# latest layer
setImage 3.9 latest


<filename>create-user.sh
#!/bin/bash
set -e

cd "$(dirname "$0")"

function usage() {
    echo "Usage: $0 USERNAME PASSWORD"
    exit 1
}

if [ -z $1 ] || [ -z $2 ]; then
  usage
fi
USERNAME=$1
PASSWORD=$2
echo "Creating new user:"
echo "USERNAME: $USERNAME"
echo "PASSWORD: $PASSWORD"

USER_POOL_ID=$(cat .build/stack.json | jq -r .UserPoolId)
USER_POOL_CLIENT_ID=$(cat .build/stack.json | jq -r .UserPoolClientId)

## Signup API
#aws cognito-idp sign-up \
#  --profile lab-cognito_auth \
#  --client-id ${USER_POOL_CLIENT_ID} \
#  --username mark<EMAIL> \
#  --password <PASSWORD>
#
#aws cognito-idp admin-confirm-sign-up \
#  --profile lab-cognito_auth \
#  --user-pool-id ${USER_POOL_ID} \
#  --username <EMAIL>

aws cognito-idp admin-create-user \
  --profile lab-cognito_auth \
  --user-pool-id ${USER_POOL_ID} \
  --username ${USERNAME} \
  --temporary-password ${PASSWORD}


cd /home/pi/backend
python -m uvicorn server:app &
python -m http.server --directory html 8080 &
chromium-browser http://localhost:8080 -kiosk --incognito --noerrdialogs


<reponame>bittrance/pumba<gh_stars>0
#!/bin/sh

set -o xtrace

for i in $(seq 1 10); do docker run -d --name=stopme-${i} alpine tail -f /dev/null; done

watch docker ps -a

for i in $(seq 1 10); do docker kill stopme-${i}; done


<filename>src/ripple/rocksdb/rocksdb/build_tools/mac-install-gflags.sh<gh_stars>10-100
#!/bin/sh
# Install gflags for mac developers.

set -e

DIR=`mktemp -d /tmp/rocksdb_gflags_XXXX`

cd $DIR
wget https://gflags.googlecode.com/files/gflags-2.0.tar.gz
tar xvfz gflags-2.0.tar.gz
cd gflags-2.0

./configure
make
make install

# Add include/lib path for g++
echo 'export LIBRARY_PATH+=":/usr/local/lib"' >> ~/.bash_profile
echo 'export CPATH+=":/usr/local/include"' >> ~/.bash_profile

echo ""
echo "-----------------------------------------------------------------------------"
echo "|                         Installation Completed                            |"
echo "-----------------------------------------------------------------------------"
echo "Please run `. ~/bash_profile` to be able to compile with gflags"


<gh_stars>0
#!/usr/bin/env bash
#/      --push_changes.sh--
#/  Pushes a commit to master while also incrementing the version based on
#/      the "level" of changes that have taken place and tagging that onto the commit.
#/
#/  Usage: push_changes.sh [options]
#/
#/  Options
#/      -v|--version                        Prints script name & version.
#/      -l|--level (patch|minor|major)      Sets level of update, to determine version bump (default: patch)
#/

# Calls the push_changes file at whatever path the py-package-manager repo is in
PPM_PATH=../py-package-manager/push_changes.sh

if [[ ! -z "${PPM_PATH}" ]]
then
  ADDL="${@}" # Option for passing additional commands onwards
  sh ${PPM_PATH} --config ./config.py ${ADDL}
else
  echo -e "The py-package-manager repo is not in the expected path: ${PPM_PATH}\nAborting process..." && exit 1
fi


<filename>entities/worm.command
register_command('worm', array(
	'description': 'Creates a worm',
	'usage': '/worm <create|delete> [length]',
	'permission': 'command.entity',
	'tabcompleter': closure(@alias, @sender, @args, @info) {
		return(array());
	},
	'executor': closure(@alias, @sender, @args, @info) {
		@worms = import('worms', array());

		@body = 'BLACK_CONCRETE_POWDER';
		@heart = 'NETHER_WART_BLOCK';
		@speed = 0.25;
		@digSpeed = 0.10;

		if(@args[0] == 'create') {
			@loc = ptarget_space();
			@length = integer(array_get(@args, 1, 11));

			@segments = spawn_entity('ARMOR_STAND', @length, @loc);
			foreach(@i: @segment in @segments) {
				set_entity_spec(@segment, array('baseplate': false, 'gravity': false, 'arms': true, 'visible': false, 'poses': array(
					'poseArmLeft': array(-0.2, 0, -0.9),
					'poseArmRight': array(-0.3, 0, 1.0),
					'poseLegLeft': array(-3.2, 0, 0),
					'poseLegRight': array(-3.2, 0, 0),
				)));
				set_mob_equipment(@segment, array(
					'helmet': array('name': if(@i % 4 != 1, @body, @heart)),
				));
			}
			@worm = array(
				'segments': @segments,
				'target': '',
				'loc': entity_loc(@segments[0]),
			);
			@worms[] = @worm;
			export('worms', @worms);

			if(array_size(@worms) == 1) {
				set_interval(50, closure(){
					@clear = false;
					try {
						foreach(@i: @w in @worms) {
							if(entity_exists(@w['segments'][0])) {
								@loc = entity_loc(@w['segments'][0]);
								@p = @w['target'];

								if(!@p || phealth(@p) == 0 || pmode(@p) == 'SPECTATOR') {
									@players = players_in_radius(@loc, 32);
									@p = '';
									foreach(@pl in @players) {
										if(phealth(@pl) > 0 && pmode(@pl) != 'SPECTATOR') {
											@w['target'] = @pl;
											@p = @pl;
											break();
										}
									}
									if(!@p) {
										continue();
									}
								}

								// tick worm
								@headLoc = location_shift(@loc, 'up', 2);
								@headLoc['pitch'] = 90;
								@gravity = false;
								if(get_block_info(@headLoc)['solid']) {
									spawn_particle(@headLoc, array('particle': 'BLOCK_DUST', 'count': 15, 'block': get_block(@headLoc)));
									@speed = @digSpeed;
								} else if(!ray_trace(@headLoc, 0.60)['hitblock']) {
									@gravity = true;
								}

								@ploc = ploc(@p);
								@newLoc = location_shift(@ploc, 'down', 0.45);
								if(distance(@loc, @newLoc) < 1) {
									damage_entity(puuid(@p), 2, @w['segments'][0]);
								} else {
									play_sound(@loc, array('sound': 'ENTITY_SPIDER_STEP', 'pitch': 1.5 + (@speed * 2), 'volume': 0.05));
									@yaw = get_yaw(@loc, @newLoc);
									@pitch = get_pitch(@loc, @newLoc);

									// clamp turning radius
									@diffYaw = @w['loc']['yaw'] - @yaw;
									if(abs(@diffYaw) > 180) {
										if(@diffYaw < 0) {
											@diffYaw += 360;
										} else {
											@diffYaw -= 360;
										}
									}
									if(@diffYaw < -7) {
										@yaw = @w['loc']['yaw'] + 7;
									} else if(@diffYaw > 7) {
										@yaw = @w['loc']['yaw'] - 7;
									}

									if(@gravity && (@pitch < 1 || @pitch > 4)) {
										@pitch = min(90, @w['loc']['pitch'] + 4);
									} else {
										@diffPitch = @w['loc']['pitch'] - @pitch;
										if(@diffPitch < -7) {
											@pitch = min(90, @w['loc']['pitch'] + 7);
										} else if(@diffPitch > 7) {
											@pitch = max(-90, @w['loc']['pitch'] - 7);
										}
									}

									@loc['yaw'] = @yaw;
									@loc['pitch'] = @pitch;
									@v = get_vector(@loc, @speed);
									@newLoc['x'] = @loc['x'] + @v['x'];
									@newLoc['y'] = @loc['y'] + @v['y'];
									@newLoc['z'] = @loc['z'] + @v['z'];
									@newLoc['yaw'] = @yaw;
									@newLoc['pitch'] = @pitch;
									set_entity_loc(@w['segments'][0], @newLoc);
									@poseHead = array(to_radians(@pitch), 0, 0);
									set_entity_spec(@w['segments'][0], array('poses': array('poseHead': @poseHead)));
									@w['loc'] = @newLoc;

									foreach(@i: @s in @w['segments']) {
										if(@i > 0) {
											@loc = entity_loc(@s);
											if(distance(@loc, @newLoc) > 0.7) {
												@loc['yaw'] = get_yaw(@loc, @newLoc);
												@poseHead[0] = to_radians(get_pitch(@loc, @newLoc));
												@newLoc = location_shift(@loc, @newLoc, @speed);
												set_entity_loc(@s, @newLoc);
												set_entity_spec(@s, array('poses': array('poseHead': @poseHead)));
											} else {
												@newLoc = @loc;
											}
										}
									}
								}
							} else {
								array_remove(@worms, @i);
								foreach(@s in @w['segments']) {
									try {
										spawn_particle(location_shift(entity_loc(@s), 'up', 2), array('particle': 'BLOCK_DUST', 'count': 15, 'block': @body));
										entity_remove(@s);
									} catch (BadEntityException @ex) {
										// doesn't exist
									}
								}
							}
						}
					} catch (Exception @ex) {
						console(@ex);
						@clear = true;
					}
					if(!@worms || @clear) {
						clear_task();
						unbind('wormdamage');
						export('worms', null);
						if(@worms) {
							foreach(@w in @worms) {
								foreach(@s in @w) {
									try(entity_remove(@s));
								}
							}
						}
					}
				});
				bind('entity_damage', array('id': 'wormdamage', 'priority': 'HIGH'), array('type': 'ARMOR_STAND'), @event, @worms, @body, @heart) {
					if(is_cancelled()) {
						foreach(@i: @w in @worms) {
							@found = false;
							foreach(@s in @w['segments']) {
								if(@event['id'] == @s) {
									@equipment = get_mob_equipment(@s);
									if(@equipment['helmet'] && @equipment['helmet']['name'] == @heart) {
										@equipment['helmet'] = array('name': @body);
										set_mob_equipment(@s, @equipment);
										@loc = location_shift(@event['location'], 'up', 2);
										spawn_particle(@loc, array('particle': 'BLOCK_DUST', 'count': 15, 'block': @heart));
										play_sound(@loc, array('sound': 'BLOCK_SLIME_BLOCK_BREAK', 'pitch': 0.7));
										spawn_entity('AREA_EFFECT_CLOUD', 1, location_shift(@loc, 'down', 0.55), closure(@id){
											set_entity_spec(@id, array(
												'particle': array('particle': 'REDSTONE','color': array('r': 200, 'g': 90, 'b': 60)),
												'color': array('r': 160, 'g': 80, 'b': 60),
												'radius': 2,
												'duration': 200,
												'reapplicationdelay': 10,
												'potionmeta': array(
													'base': array(
														'type': 'INSTANT_DAMAGE',
													),
												),
												'source': @event['id'],
											));
										});
										@found = true;
										break();
									}
									if(array_index_exists(@event, 'damager') && length(@event['damager']) < 17) {
										@w['target'] = @event['damager'];
									} else if(array_index_exists(@event, 'shooter') && length(@event['shooter'])) {
										@w['target'] = @event['shooter'];
									}
								}
							}
							if(@found) {
								@alive = false;
								foreach(@s in @w['segments']) {
									@equipment = get_mob_equipment(@s);
									if(@equipment['helmet']['name'] == @heart) {
										@alive = true;
										break();
									}
								}
								if(!@alive) {
									array_remove(@worms, @i);
									foreach(@s in @w['segments']) {
										queue_push(closure() {
											@loc = location_shift(entity_loc(@s), 'up', 2);
											spawn_particle(@loc, array('particle': 'BLOCK_DUST', 'count': 15, 'block': @body));
											play_sound(@loc, array('sound': 'BLOCK_SLIME_BLOCK_BREAK', 'pitch': 1.4));
											entity_remove(@s);
										}, 'worm');
										queue_delay(50, 'worm');
									}
								}
								break();
							}
						}
					}
				}
			}
		} else if(@args[0] == 'delete') {
			foreach(@i: @w in @worms) {
				foreach(@s in @w['segments']) {
					try(entity_remove(@s));
				}
				array_remove(@worms, @i);
			}
			export('worms', null);
			unbind('wormdamage');
		}
	}
));


#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

# create windows_instances.data
echo "data:" > "${SHARED_DIR}"/windows_instances.data

# look for Windows instances files in the shared dir.
# the pattern is:
#   <address>_windows_instance.txt
# where, <address> is the network address used to SSH into the instance, it can be an IPv4 or a DNS name.
# See https://github.com/openshift/windows-machine-config-operator#adding-instances
for f in "${SHARED_DIR}"/*_windows_instance.txt;
do
  if test -f "${f}"
    then
      echo "$(date -u --rfc-3339=seconds) - Processing Windows instance file: ${f}"
      # parse instance's address from filename
      instance_address=$(basename "${f}" "_windows_instance.txt")
      # load instance's information from file content
      instance_info=$(<"${f}")
      # append current Windows instance information
      cat >> "${SHARED_DIR}/windows_instances.data" << EOF
  ${instance_address}: |-
    ${instance_info}
EOF
  fi
done

WINDOWS_INSTANCES_DATA=$(<"${SHARED_DIR}"/windows_instances.data)
export WINDOWS_INSTANCES_DATA
export AWS_SHARED_CREDENTIALS_FILE=${CLUSTER_PROFILE_DIR}/.awscred
export KUBE_SSH_KEY_PATH=${CLUSTER_PROFILE_DIR}/ssh-privatekey

make run-ci-e2e-byoh-test


#!/bin/bash
set -e
sudo apt install -y automake build-essential pkg-config libevent-dev libncurses5-dev

if [-d /tmp/tmux]; then
    cd /tmp/tmux
    git pull
else
    git clone https://github.com/tmux/tmux.git /tmp/tmux
fi

./autogen.sh
./configure && make
sudo make install
rm -fr /tmp/tmux


<reponame>zxlhhyccc/Actions-OpenWrt
#!/bin/bash
#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/Actions-OpenWrt
# File name: diy-part1.sh
# Description: OpenWrt DIY script part 1 (Before Update feeds)
#

# 添加5.10内核的QCA支持
rm -rf ./target/linux/ipq807x
svn co https://github.com/zxlhhyccc/acc-imq-bbr/trunk/master/qca/target/linux/ipq807x target/linux/ipq807x
rm -rf ./target/linux/ipq807x/.svn
rm -f ./target/linux/ipq807x/patches-5.10/601-netfilter-export-udp_get_timeouts-function.patch

# boot-envtools添加ipq807x
wget -P package/boot/uboot-envtools/files/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/boot/uboot-envtools/files/ipq807x

# firmware添加ax6等文件
svn co https://github.com/zxlhhyccc/acc-imq-bbr/trunk/master/qca/package/firmware/ath11k-board package/firmware/ath11k-board
rm -rf ./package/firmware/ath11k-board/.svn

svn co https://github.com/zxlhhyccc/acc-imq-bbr/trunk/master/qca/package/firmware/ath11k-firmware package/firmware/ath11k-firmware
rm -rf ./package/firmware/ath11k-firmware/.svn

rm -f ./package/firmware/ipq-wifi/Makefile
wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/Makefile

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-hiwifi_c526a.qca4019

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-netgear_sxr80.ipq8074

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-p2w_r619ac.qca4019

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-qnap_301w.ipq8074

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-redmi_ax6.ipq8074

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-xiaomi_ax3600.ipq8074

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-xiaomi_ax3600.qca9889

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-xiaomi_ax9000.ipq8074

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-xiaomi_ax9000.qca9889

wget -P package/firmware/ipq-wifi/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/firmware/ipq-wifi/board-zte_mf269.ipq8074

# kernel/linux替换修改后hwmon.mk、usb.mk
rm -f ./package/kernel/linux/modules/hwmon.mk
wget -P package/kernel/linux/modules/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/kernel/linux/modules/hwmon.mk

rm -f ./package/kernel/linux/modules/usb.mk
wget -P package/kernel/linux/modules/ https://github.com/zxlhhyccc/acc-imq-bbr/raw/master/master/qca/package/kernel/linux/modules/usb.mk

# MAC80211添加ipq807x支持
rm -rf package/kernel/mac80211
svn co https://github.com/zxlhhyccc/acc-imq-bbr/trunk/master/qca/package/kernel/mac80211 package/kernel/mac80211
rm -rf ./package/kernel/mac80211/.svn

# 添加NSS
svn co https://github.com/zxlhhyccc/acc-imq-bbr/trunk/master/package/nss-packages package/nss-packages
rm -rf ./package/nss_packages/.svn


#! /bin/bash

# from https://github.com/mercurius-js/auth/tree/main/bench

echo '=============================='
echo '= Normal Mode                ='
echo '=============================='
npx concurrently --raw -k \
  "node ./bench/standalone.js" \
  "npx wait-on tcp:3000 && node ./bench/standalone-bench.js"

echo '==============================='
echo '= Gateway Mode                ='
echo '==============================='
npx concurrently --raw -k \
  "node ./bench/gateway-service-1.js" \
  "node ./bench/gateway-service-2.js" \
  "npx wait-on tcp:3001 tcp:3002 && node ./bench/gateway.js" \
  "npx wait-on tcp:3000 && node ./bench/gateway-bench.js"


<filename>thirdparty/instant-meshes/instant-meshes-dust3d/ext/tbb/build/generate_tbbvars.sh
#!/bin/bash
#
# Copyright (c) 2005-2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#
#

# Script used to generate tbbvars.[c]sh scripts
bin_dir="$PWD"  #
cd "$tbb_root"  # keep this comments here
tbb_root="$PWD" # to make it unsensible
cd "$bin_dir"   # to EOL encoding
[ -f ./tbbvars.sh ] || cat >./tbbvars.sh <<EOF
#!/bin/bash
export TBBROOT="${tbb_root}" #
tbb_bin="${bin_dir}" #
if [ -z "\$CPATH" ]; then #
    export CPATH="\${TBBROOT}/include" #
else #
    export CPATH="\${TBBROOT}/include:\$CPATH" #
fi #
if [ -z "\$${2}LIBRARY_PATH" ]; then #
    export ${2}LIBRARY_PATH="\${tbb_bin}" #
else #
    export ${2}LIBRARY_PATH="\${tbb_bin}:\$${2}LIBRARY_PATH" #
fi #
if [ -z "\$${1}LD_LIBRARY_PATH" ]; then #
    export ${1}LD_LIBRARY_PATH="\${tbb_bin}" #
else #
    export ${1}LD_LIBRARY_PATH="\${tbb_bin}:\$${1}LD_LIBRARY_PATH" #
fi #
${TBB_CUSTOM_VARS_SH} #
EOF
[ -f ./tbbvars.csh ] || cat >./tbbvars.csh <<EOF
#!/bin/csh
setenv TBBROOT "${tbb_root}" #
setenv tbb_bin "${bin_dir}" #
if (! \$?CPATH) then #
    setenv CPATH "\${TBBROOT}/include" #
else #
    setenv CPATH "\${TBBROOT}/include:\$CPATH" #
endif #
if (! \$?${2}LIBRARY_PATH) then #
    setenv ${2}LIBRARY_PATH "\${tbb_bin}" #
else #
    setenv ${2}LIBRARY_PATH "\${tbb_bin}:\$${2}LIBRARY_PATH" #
endif #
if (! \$?${1}LD_LIBRARY_PATH) then #
    setenv ${1}LD_LIBRARY_PATH "\${tbb_bin}" #
else #
    setenv ${1}LD_LIBRARY_PATH "\${tbb_bin}:\$${1}LD_LIBRARY_PATH" #
endif #
${TBB_CUSTOM_VARS_CSH} #
EOF
# Workaround for copying Android* specific stl shared library to "."
if [ ! -z "${LIB_STL_ANDROID}" ]; then #
	cp ${LIB_STL_ANDROID} . #
fi #


<filename>run.sh
#!/usr/bin/env bash

set -e

which scrapy > /dev/null || sudo pip install Scrapy

>properties.json
scrapy runspider scrape.py -t json -o properties.json
#cat properties.json | jq '.'


<reponame>huncros/texas_holdem<filename>dev/setup.sh
#!/bin/bash
# Sets up local development environment.
set xue

cd $(dirname $0)

ROOT_DIR=$(git rev-parse --show-toplevel)
# Set up git hook
pushd $ROOT_DIR/.git/hooks
ln -sf ../../dev/pre-commit pre-commit
popd

# Create python virtual env containing the necessary packages for testing / development
pushd $ROOT_DIR
python -m venv .dev_venv
source .dev_venv/bin/activate
pip install autopep8 coverage tox sphinx
pip install -e .
popd


#!/bin/bash

install_j2_renderer() {

  j2 -v  &>/dev/null

  if [ $? != 0 ]; then
    # ensure j2 renderer installed
    pip install wheel --user
    pip freeze | grep j2cli || pip install j2cli[yaml] --user
    export PATH=~/.local/bin:$PATH
  fi
}

generate_yamls() {

  #
  # Client Pods
  #

  # client-daemonSet-host.yaml
  test_image=${TEST_IMAGE} \
  j2 "./manifests/client-daemonSet-host.yaml.j2" -o "./manifests/yamls/client-daemonSet-host.yaml"

  # client-daemonSet-smartNic.yaml
  sriov_resource_name=${SRIOV_RESOURCE_NAME} \
  test_image=${TEST_IMAGE} \
  j2 "./manifests/client-daemonSet-smartNic.yaml.j2" -o "./manifests/yamls/client-daemonSet-smartNic.yaml"

  # client-daemonSet.yaml
  test_image=${TEST_IMAGE} \
  j2 "./manifests/client-daemonSet.yaml.j2" -o "./manifests/yamls/client-daemonSet.yaml"

  #
  # http Server Pods
  #

  # http-server-pod-v4-host.yaml
  http_clusterip_host_svc_port=${HTTP_CLUSTERIP_HOST_SVC_PORT} \
  j2 "./manifests/http-server-pod-v4-host.yaml.j2" -o "./manifests/yamls/http-server-pod-v4-host.yaml"

  # http-server-pod-v4-smartNic
  sriov_resource_name=${SRIOV_RESOURCE_NAME} \
  http_clusterip_pod_svc_port=${HTTP_CLUSTERIP_POD_SVC_PORT} \
  j2 "./manifests/http-server-pod-v4-smartNic.yaml.j2" -o "./manifests/yamls/http-server-pod-v4-smartNic.yaml"

  # http-server-pod-v4.yaml
  http_clusterip_pod_svc_port=${HTTP_CLUSTERIP_POD_SVC_PORT} \
  j2 "./manifests/http-server-pod-v4.yaml.j2" -o "./manifests/yamls/http-server-pod-v4.yaml"

  #
  # iperf Server Pods
  #

  # iperf-server-pod-v4-host.yaml
  test_image=${TEST_IMAGE} \
  iperf_clusterip_host_svc_port=${IPERF_CLUSTERIP_HOST_SVC_PORT} \
  j2 "./manifests/iperf-server-pod-v4-host.yaml.j2" -o "./manifests/yamls/iperf-server-pod-v4-host.yaml"

  # iperf-server-pod-v4-smartNic.yaml
  sriov_resource_name=${SRIOV_RESOURCE_NAME} \
  test_image=${TEST_IMAGE} \
  iperf_clusterip_pod_svc_port=${IPERF_CLUSTERIP_POD_SVC_PORT} \
  j2 "./manifests/iperf-server-pod-v4-smartNic.yaml.j2" -o "./manifests/yamls/iperf-server-pod-v4-smartNic.yaml"

  # iperf-server-pod-v4.yaml
  test_image=${TEST_IMAGE} \
  iperf_clusterip_pod_svc_port=${IPERF_CLUSTERIP_POD_SVC_PORT} \
  j2 "./manifests/iperf-server-pod-v4.yaml.j2" -o "./manifests/yamls/iperf-server-pod-v4.yaml"

  #
  # Network-Attachment-Definitions
  #

  # netAttachDef-sriov.yaml
  sriov_resource_name=${SRIOV_RESOURCE_NAME} \
  iperf_clusterip_host_svc_port=${IPERF_CLUSTERIP_HOST_SVC_PORT} \
  j2 "./manifests/netAttachDef-sriov.yaml.j2" -o "./manifests/yamls/netAttachDef-sriov.yaml"

  #
  # Services
  #

  # svc-clusterIP.yaml
  http_clusterip_host_svc_port=${HTTP_CLUSTERIP_HOST_SVC_PORT} \
  iperf_clusterip_host_svc_port=${IPERF_CLUSTERIP_HOST_SVC_PORT} \
  j2 "./manifests/svc-clusterIP-host.yaml.j2" -o "./manifests/yamls/svc-clusterIP-host.yaml"

  # svc-clusterIP.yaml
  http_clusterip_pod_svc_port=${HTTP_CLUSTERIP_POD_SVC_PORT} \
  iperf_clusterip_pod_svc_port=${IPERF_CLUSTERIP_POD_SVC_PORT} \
  j2 "./manifests/svc-clusterIP.yaml.j2" -o "./manifests/yamls/svc-clusterIP.yaml"

  # svc-nodePort-host.yaml
  http_clusterip_host_svc_port=${HTTP_CLUSTERIP_HOST_SVC_PORT} \
  http_nodeport_host_svc_port=${HTTP_NODEPORT_HOST_SVC_PORT} \
  iperf_clusterip_host_svc_port=${IPERF_CLUSTERIP_HOST_SVC_PORT} \
  iperf_nodeport_host_svc_port=${IPERF_NODEPORT_HOST_SVC_PORT} \
  j2 "./manifests/svc-nodePort-host.yaml.j2" -o "./manifests/yamls/svc-nodePort-host.yaml"

  # svc-nodePort.yaml
  http_clusterip_pod_svc_port=${HTTP_CLUSTERIP_POD_SVC_PORT} \
  http_nodeport_pod_svc_port=${HTTP_NODEPORT_POD_SVC_PORT} \
  iperf_clusterip_pod_svc_port=${IPERF_CLUSTERIP_POD_SVC_PORT} \
  iperf_nodeport_pod_svc_port=${IPERF_NODEPORT_POD_SVC_PORT} \
  j2 "./manifests/svc-nodePort.yaml.j2" -o "./manifests/yamls/svc-nodePort.yaml"
}


#!/bin/bash

set -e

# Install required pakages
sudo apt-get install -yq \
    build-essential \
    python3-setuptools \
    freetds-bin \
    freetds-dev \
    libct4 \
    libsybdb5 \
    tdsodbc \
    unixodbc \
    unixodbc-dev

cat << EOF | sudo tee /etc/odbcinst.ini
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
EOF

pip3 install -qr ./test/requirements.txt
ls -l /usr/lib/x86_64-linux-gnu/odbc/

python3 ./test/import_fakenames.py --filename=test/dataset/10k_fakenames_fra.csv


<filename>docker/prod/web/entrypoints/entrypoint.sh
#!/bin/sh

python manage.py wait_for_db

python manage.py check --deploy

python manage.py migrate
python manage.py collectstatic --no-input

gunicorn src.asgi:application


#!/bin/bash
GCR_PROJECT_ID=devenv-215523
DOCKER_IMAGE_NAME=logojs-webapp
KUBE_DEPLOYMENT_NAME=logojs-webapp-deployment
KUBE_DEPLOYMENT_CONTAINER_NAME=logojs-webapp


<reponame>goncaloperes/bokeh<filename>docker-tools/npm-install.sh
#!/bin/bash

COMMAND="cd /bokeh/bokehjs && npm ci --no-progress"

source "$(dirname $0)/base.sh"


workon () {
  SCRIPT="$(fw -q gen-workon $@)";
  if [ $? -eq 0 ]; then
    eval "$SCRIPT";
  else
    printf "$SCRIPT\n";
  fi
};
reworkon () {
  SCRIPT="$(fw -q gen-reworkon $@)";
  if [ $? -eq 0 ]; then
    eval "$SCRIPT";
  else
    printf "$SCRIPT\n";
  fi
};

nworkon () {
  SCRIPT="$(fw -q gen-workon -x $@)";
  if [ $? -eq 0 ]; then
    eval "$SCRIPT";
  else
    printf "$SCRIPT\n";
  fi
};

_workon() {
  if ! command -v fw > /dev/null 2>&1; then
      _message "fw not installed";
  else
    __fw_projects;
  fi
};

compdef _workon workon;
compdef _workon nworkon;


<gh_stars>1-10
#!/bin/bash

gcc_version=$1
gcc_version_elements=(${gcc_version//./ })
module_file=$2

echo "#%Module1.0" > $module_file
echo "##" >> $module_file
echo "## gcc"  >> $module_file
echo "##" >> $module_file
echo "" >> $module_file

echo "module-whatis \"sets application for gcc ${gcc_version}\"" >> $module_file
echo "set              gccroot              /packages/gcc/${gcc_version}" >> $module_file
echo "" >> "$module_file"

# gcc
echo "prepend-path PATH \"\$gccroot/bin\"" >> $module_file
echo "prepend-path LD_LIBRARY_PATH \"\$gccroot/lib:\$gccroot/lib64\"" >> $module_file

echo "" >> $module_file
echo "conflict gcc" >> $module_file


#!/bin/sh

mkdir -p "$XDG_CONFIG_HOME/git/gitconfig.d"

if [ -e "$HOME/.gitconfig" ]; then
	rm "$HOME/.gitconfig"
fi


python setup.py install;majime -g http://backend.yoisho.dob.jp/fixeddeposit/swagger


#!/usr/bin/env bash

# Export global symbols to the file.
# The file is later used by the UNEXPORTED_SYMBOLS_FILE to hide the symbols

BASE_PWD="$PWD"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
LIBS_DIR=$( realpath ${SCRIPT_DIR}/../vendor/OpenSSL )

xcrun nm -gUj "${LIBS_DIR}/ios/lib/libcrypto.a" | grep -v "^$" | grep "^_" > "${LIBS_DIR}/ios/lib/unexported_symbols"
xcrun nm -gUj "${LIBS_DIR}/macosx/lib/libcrypto.a" | grep -v "^$" | grep "^_" > "${LIBS_DIR}/macosx/lib/unexported_symbols"


catkin_make -C /home/$USER/dev_ws ;
source /home/$USER/dev_ws/devel/setup.bash

# Get the current directory
CURR_DIR=$(pwd)
# Get the location of the viral package
roscd lio_sam
PACKAGE_DIR=$(pwd)
# Return to the current dir, print the directions
cd $CURR_DIR
echo CURRENT DIR: $CURR_DIR
echo VIRAL DIR:   $PACKAGE_DIR

export EPOC_DIR=/home/$USER/nucssd2/MATLAB_WS/RAL_VIRAL_SLAM/hhrig_liosam
export DATASET_LOCATION=/home/$USER/DATASETS/hhrig/
# export DATASET_LOCATION=/media/$USER/myHPSSD/hhrig

export CAPTURE_SCREEN=false;
export LOG_DATA=false;

#region 0 UWB NO VIS --------------------------------------------------------------------------------------------------

# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR iot_01 $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;
# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR iot_02 $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;

# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR ac_01  $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;
# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR ac_02  $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;
wait;
./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR ac_03  $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;

# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR ac_walk_01  $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;
# wait;
# ./run_one_bag_hhrig.sh $EPOC_DIR $DATASET_LOCATION $PACKAGE_DIR ac_walk_02  $CAPTURE_SCREEN $LOG_DATA 450 0 0 0.75 -1;

#endregion NO UWB NO VIS ----------------------------------------------------------------------------------------------

#region ## Poweroff ---------------------------------------------------------------------------------------------------

wait;
# poweroff

#endregion ## Poweroff ------------------------------------------------------------------------------------------------


#! /usr/bin/env bash

set -e

github_user=${1:-cncf}
github_token=${2}
ci_version=${3:-latest-dev}

echo "ci_version: ${ci_version}, github_user: ${github_user}"

this_dir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
namespace=podtato-kubectl
kubectl create namespace ${namespace} --save-config || true &> /dev/null
kubectl config set-context --current --namespace ${namespace}

if [[ -n "${github_token}" ]]; then
    kubectl create secret docker-registry ghcr \
        --docker-server 'https://ghcr.io/' \
        --docker-username "${github_user}" \
        --docker-password "${<PASSWORD>}"

    kubectl patch serviceaccount default \
        --patch '{ "imagePullSecrets": [{ "name": "ghcr" }]}'
fi

cat "${this_dir}/manifest.yaml" | \
    sed "s@ghcr\.io\/podtato-head@ghcr.io/${github_user}/podtato-head@g" | \
    sed "s/latest-dev/${ci_version}/g" | \
        kubectl apply -f -

kubectl wait --for=condition=Available --timeout=90s \
    deployment --namespace ${namespace} podtato-main

kubectl get deployments --namespace=${namespace}


<gh_stars>1-10
#!/bin/bash

# TODO should use site.wxxeibo.short_name defined in _config.yml

photos_yml="../chen-shy.github.io/_galleries/photos.yml"

# yaml file header
cat <<EOT > ${photos_yml}
---
name: "photos"
arts:
EOT

# yaml file content body
cd ../attachments
count=1
for file in *.jpg; do
  echo "process ${file}"
  cat <<EOT >> ${photos_yml}
- image: "${file}"
  order: "${count}"
  title: "<NAME> (陈诗雨)"

EOT
  (( count++ ))
done
cd -

# yaml file footer
cat <<EOT >> ${photos_yml}
---

EOT


<reponame>marcozov/asw<filename>projects/asw-890-docker/a-hello-world/delete-container.sh
#!/bin/bash

docker rm hello


<reponame>idaholab/hpcswtest
MPIPROCS=1
OMPTHREADS=1
THREADS=1
HELP=0
XTRA_MEM=0
SIZEPERMPI=96
SUBMIT_JOB=1

HOSTNAME=`hostname`
if [ "$HOSTNAME" = "flogin1" -o "$HOSTNAME" = "flogin2" -o "$HOSTNAME" = "fbuild" -o "$HOSTNAME" = "fpbs" -o "$HOSTNAME" = "fbuild2" ]
then
CLUSTER="fission"
CORES_PER_NODE=32
CPU_TYPE="magnycours"
elif [ "$HOSTNAME" = "falcon1" -o "$HOSTNAME" = "falcon2" -o "$HOSTNAME" = "service2" -o "$HOSTNAME" = "falconviz" ]
then
CLUSTER="falcon"
CORES_PER_NODE=24
CPU_TYPE="haswell"
elif [ "$HOSTNAME" = "quark" ]
then
CLUSTER="quark"
CORES_PER_NODE=12
elif [ "$HOSTNAME" = "bechler" ]
then
CLUSTER="bechler"
CORES_PER_NODE=32
CPU_TYPE="sandybridge"
else
echo "Error: Machine $HOSTNAME is not supported."
exit 1
fi

#IOZONE_EXEC=iozone_$CLUSTER
IOZONE_EXEC=iozone
MD_EXEC=mdtest_$CLUSTER

MPI_PER_NODE=$CORES_PER_NODE

function calc_chunk {
  if [ $CPU_TYPE == "broadwell" ]
  then
     CORES_PER_NODE=36
     if [ -z $MPI_PER_NODE_SET ]
     then
        MPI_PER_NODE=$CORES_PER_NODE
     fi
  fi
  if [ $XTRA_MEM -eq 1 ]
  then
     MPIPROCS=$(($MPIPROCS - 1))
  fi
#  TOTAL_PROCS=$(($MPIPROCS * $OMPTHREADS))
  TOTAL_PROCS=$MPIPROCS
#  echo "TOTAL_PROCS = $TOTAL_PROCS"
  NNODES=`expr $TOTAL_PROCS / $MPI_PER_NODE`
  DIV_BY_CORES_PER_NODE=`expr $TOTAL_PROCS % $CORES_PER_NODE`
  MOD_BY_MPI_PER_NODE=`expr $TOTAL_PROCS % $MPI_PER_NODE`
  STR1=""
  STR2=""
#  if [ $DIV_BY_CORES_PER_NODE -ne 0 ]
#  then
#    STR1="Warning: You have requested $TOTAL_PROCS mpi processes, it would be more efficient to"
#    STR2="         request mpi processes in multiples of $CORES_PER_NODE."
##    echo "Warning: You have requested $1 mpi processes, it would be more efficient (on Fission) to"
##    echo "         request mpi processes in multiples of 32."
#  fi
  if [ $TOTAL_PROCS -le $CORES_PER_NODE -a $MPI_PER_NODE -eq $CORES_PER_NODE ]
  then
     NNODES=1
     RPROCS1=$MPIPROCS
  elif [ $MOD_BY_MPI_PER_NODE -eq 0 ]
  then
     RPROCS1=`expr $MPIPROCS / $NNODES`
  else
     RPROCS1=$MPI_PER_NODE
     TMP2=$(($RPROCS1 * $NNODES))
     RPROCS2=`expr $MPIPROCS - $TMP2`
  fi
#  echo "NNODES = $NNODES RPROCS1 = $RPROCS1  RPROCS2 = $RPROCS2"
#  echo "MOD_BY_MPI_PER_NODE = $MOD_BY_MPI_PER_NODE"
}

function check_command_args {
   if [ $HELP -ne 1 ]
   then
      if [ -z "$PBS_JOB_ARRAY_RANGE" -a -z "$PBS_JOB_ARRAY_FILENAME" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            if [ -z "$WALLTIME" ]
	    then
	       echo "Error: Make sure you specify the Scheduler Walltime."
	       usage
	       exit 1
            fi
	 else
            if [ -z "$INPUT" -o -z "$WALLTIME" ]
	    then
	       if [ "$EXE_NAME" == "starccm+" ]
	       then
	          echo "Error: Make sure you specify the Sim file and PBS Walltime."
	       else
	          echo "Error: Make sure you specify the input file and PBS Walltime."
	       fi
	       usage
	       exit 1
            fi
	 fi
      else
         if [ -z "$PBS_JOB_ARRAY_RANGE" -o -z "$PBS_JOB_ARRAY_FILENAME" ]
	 then
	    echo "Error: If you want to use job arrays you need to provide the job_array_range and a job_array_filename"
	    usage
	    exit 1
	 fi
      fi
      if [ $THREADS -gt $CORES_PER_NODE ]
      then
         echo " Error: Maximum number of threads per node is $CORES_PER_NODE"
	 exit 1
      fi
   fi
   if [ -n "$PBS_JOB_ARRAY_RANGE" -a -z "$WALLTIME" ]
   then
      echo "Error: Walltime not specified on the command line."
      usage
      exit 1
   fi
   if [ $OMPTHREADS -gt $CORES_PER_NODE ]
   then
      echo " Error: You specified $OMPTHREADS threads, you cannot specify more than $CORES_PER_NODE."
      exit 1
   fi
}

function slurm_check_command_args {
   if [ $HELP -ne 1 ]
   then
      if [ -z "$JOB_ARRAY_RANGE" -a -z "$JOB_ARRAY_FILENAME" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            if [ -z "$WALLTIME" ]
	    then
	       echo "Error: Make sure you specify the Scheduler Walltime."
	       usage
	       exit 1
            fi
	 else
            if [ -z "$INPUT" -o -z "$WALLTIME" ]
	    then
	       if [ "$EXE_NAME" == "starccm+" ]
	       then
	          echo "Error: Make sure you specify the Sim file and PBS Walltime."
	       else
	          echo "Error: Make sure you specify the input file and PBS Walltime."
	       fi
	       usage
	       exit 1
            fi
	 fi
      else
         if [ -z "$JOB_ARRAY_RANGE" -o -z "$JOB_ARRAY_FILENAME" ]
	 then
	    echo "Error: If you want to use job arrays you need to provide the job_array_range and a job_array_filename"
	    usage
	    exit 1
	 fi
      fi
      if [ $THREADS -gt $CORES_PER_NODE ]
      then
         echo " Error: Maximum number of threads per node is $CORES_PER_NODE"
	 exit 1
      fi
   fi
   if [ -n "$JOB_ARRAY_RANGE" -a -z "$WALLTIME" ]
   then
      echo "Error: Walltime not specified on the command line."
      usage
      exit 1
   fi
   if [ $OMPTHREADS -gt $CORES_PER_NODE ]
   then
      echo " Error: You specified $OMPTHREADS threads, you cannot specify more than $CORES_PER_NODE."
      exit 1
   fi
}

function set_default_jobname {
   if [ -n "$PBS_JOB_ARRAY_RANGE" ]
   then
      INPUT=job_array
   fi
   if [ -z "$JOBNAME" ]
   then
      if [ "$EXE_NAME" == "vasp" ]
      then
         JOBNAME=$NAME
      else
         JOBNAME=$INPUT
      fi
   fi
}

function slurm_set_default_jobname {
   if [ -n "$JOB_ARRAY_RANGE" ]
   then
      INPUT=job_array
   fi
   if [ -z "$JOBNAME" ]
   then
      if [ "$EXE_NAME" == "vasp" ]
      then
         JOBNAME=$NAME
      else
         JOBNAME=$INPUT
      fi
   fi
}

function pbs_set_defaults {
   echo "#PBS -N $JOBNAME" >> $1
   if [ -n "$QUEUE" ]
   then
      echo "#PBS -q $QUEUE" >> $1
   fi
   echo "#PBS -l walltime=$WALLTIME" >> $1
   echo "#PBS -ko" >> $1
   echo "#PBS -j oe" >> $1
   if [ -n "$PROJECT" ]
   then
      echo "#PBS -P $PROJECT" >> $1
   fi
}

function slurm_set_defaults {
   if [ -n "$JOB_ARRAY_RANGE" ]
   then
      echo "#SBATCH --job-name=${JOBNAME}"_"%a" >> $1
      echo "#SBATCH --output=$JOBNAME.o%A_%a" >> $1
      echo "#SBATCH --error=$JOBNAME.o%A_%a" >> $1
   else
      echo "#SBATCH --job-name=$JOBNAME" >> $1
      echo "#SBATCH --output=$JOBNAME.o%A" >> $1
      echo "#SBATCH --error=$JOBNAME.o%A" >> $1
   fi
   if [ -n "$QUEUE" ]
   then
      echo "#SBATCH --partition=$QUEUE" >> $1
   fi
   echo "#SBATCH --time=$WALLTIME" >> $1
#   if [ -n "$PROJECT" ]
#   then
#      echo "#PBS -P $PROJECT" >> $1
#   fi
}

function pbs_depends_on {
   if [ -n "$DEPENDS_ON_JOBID" ]
   then
      echo "#PBS -W depend=afterany:$DEPENDS_ON_JOBID" >> $1
   fi
}

function slurm_depends_on {
   if [ -n "$DEPENDS_ON_JOBID" ]
   then
      echo "#SBATCH --dependency=afterany:$DEPENDS_ON_JOBID" >> $1
   fi
}

function pbs_depends_on {
   if [ -n "$DEPENDS_ON_JOBID" ]
   then
      echo "#PBS -W depend=afterany:$DEPENDS_ON_JOBID" >> $1
   fi
}

function pbs_jobarray {
   if [ -n "$PBS_JOB_ARRAY_RANGE" ]
   then
      echo "#PBS -r y" >> $1
      echo "#PBS -J $PBS_JOB_ARRAY_RANGE" >> $1
   fi
}

function slurm_jobarray {
   if [ -n "$JOB_ARRAY_RANGE" ]
   then
      echo "#SBATCH --array $JOB_ARRAY_RANGE" >> $1
   fi
}

function pbs_select {
   if [ $XTRA_MEM -eq 1 ]
   then
      if [  -n "$RPROCS2" ]
      then
         if [  -n "$PBS_MEM" ]
         then
            echo "#PBS -l select=1:ncpus=$CORES_PER_NODE:cputype=$CPU_TYPE:mem=$PBS_MEM:mpiprocs=1+$NNODES:ncpus=$NCPUS:cputype=$CPU_TYPE:mem=$PBS_MEM:mpiprocs=$RPROCS1+1:ncpus=$NCPUS:mpiprocs=$RPROCS2:cputype=$CPU_TYPE:mem=$PBS_MEM" >> $1
         else
            echo "#PBS -l select=1:ncpus=$CORES_PER_NODE:cputype=$CPU_TYPE:mpiprocs=1+$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE+1:ncpus=$NCPUS:mpiprocs=$RPROCS2:cputype=$CPU_TYPE" >> $1
         fi
      else
         if [  -n "$PBS_MEM" ]
         then
            echo "#PBS -l select=1:ncpus=$CORES_PER_NODE:cputype=$CPU_TYPE:mem=$PBS_MEM:mpiprocs=1+$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE:mem=$PBS_MEM" >> $1
         else
            echo "#PBS -l select=1:ncpus=$CORES_PER_NODE:cputype=$CPU_TYPE:mpiprocs=1+$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE" >> $1
         fi
      fi
   else
      if [  -n "$RPROCS2" ]
      then
         if [  -n "$PBS_MEM" ]
         then
            echo "#PBS -l select=1:ncpus=$NCPUS:mem=$PBS_MEM:mpiprocs=$RPROCS2:cputype=$CPU_TYPE+$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE:mem=$PBS_MEM" >> $1
         else
            echo "#PBS -l select=1:ncpus=$NCPUS:mpiprocs=$RPROCS2:cputype=$CPU_TYPE+$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE" >> $1
         fi
      else
         if [  -n "$PBS_MEM" ]
         then
            echo "#PBS -l select=$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE:mem=$PBS_MEM" >> $1
         else
            echo "#PBS -l select=$NNODES:ncpus=$NCPUS:mpiprocs=$RPROCS1:cputype=$CPU_TYPE" >> $1
         fi
      fi
   fi
}

function slurm_tasks {
   if [  -n "$MEM_PER_PROCESS" ]
   then
      echo "#SBATCH --ntasks=$MPIPROCS" >> $1
      echo "#SBATCH --ntasks-per-node=$MPI_PER_NODE" >> $1
      echo "#SBATCH --mem-per-cpu=$MEM_PER_PROCESS" >> $1
   else
      echo "#SBATCH --ntasks=$MPIPROCS" >> $1
      echo "#SBATCH --ntasks-per-node=$MPI_PER_NODE" >> $1
   fi
}

function load_modules {
   echo "source /etc/profile.d/modules.sh" >> $1
   if [ -n "$EXTRA_MODULE_NAME1" ]
   then
      echo "module load $EXTRA_MODULE_NAME1" >> $1
   fi
   if [ -n "$EXTRA_MODULE_NAME2" ]
   then
      echo "module load $EXTRA_MODULE_NAME2" >> $1
   fi
   if [ -n "$DEBUG_JOB" ]
   then
      echo "module load use.projects utils" >> $1
   fi
   echo "module load $MODULE_NAME" >> $1
   if [ "$EXE_NAME" == "abaqus" ]
   then
      if [ -n "$GCC_MODULE_NAME" ]
      then
         echo  "module load $GCC_MODULE_NAME" >> $1
      fi
      echo  "module load $COMPILER_MODULE_NAME" >> $1
   fi
}

#function create_slurm_nodefile {
#   python /home/garvct/my_sw_development/pbs_job_submit/slurm_nodefile.py $1
#}

function slurm_create_nodefile {
   echo "export SLURM_NODEFILE=/tmp/slurm_\$SLURM_JOBID" >> $1
   echo "scontrol show hostname \$SLURM_JOB_NODELIST >& \$SLURM_NODEFILE" >> $1
}

function debug_job {
   if [ -n "$DEBUG_JOB" ]
   then
      echo "cat \$PBS_NODEFILE | uniq > mpd.hosts_\$\$" >> $1
      echo "checkBasicStatus.py -f mpd.hosts_\$\$" >> $1
#      echo "check_node_mem_pbs.sh 180 &" >> $1
   fi
# Not the best place to put this logic, but didnot want to break existing sub_app scripts.
   echo "JOB_NUM=\${PBS_JOBID%\.*}" >> $1
   if [ -z "$PBS_JOB_ARRAY_RANGE" ]
   then
      echo "if [ \$PBS_O_WORKDIR != \$HOME ]" >> $1
      echo "then" >> $1
      echo "ln -s \$HOME/\$PBS_JOBNAME.o\$JOB_NUM \$PBS_JOBNAME.o\$JOB_NUM" >> $1
      echo "fi" >> $1
   fi
}

function slurm_debug_job {
   if [ -n "$DEBUG_JOB" ]
   then
      echo "cat \$SLURM_NODEFILE | uniq > mpd.hosts_\$\$" >> $1
      echo "checkBasicStatus.py -f mpd.hosts_\$\$" >> $1
#      echo "check_node_mem_pbs.sh 180 &" >> $1
   fi
   echo "JOB_NUM=\${SLURM_JOB_ID%\.*}" >> $1
}

function setup_run_in_scratch {
   if [ -n "$SCRATCH_TYPE" ]
   then
      echo "export TMPDIR=$SCRATCH_BASE_DIR/\$\$" >> $1
      if [ $SCRATCH_TYPE != "scratch" ]
      then
         echo "for host in \`uniq \$PBS_NODEFILE\`" >> $1
         echo "do" >> $1
         echo "ssh \$host mkdir $SCRATCH_BASE_DIR/\$\$" >> $1
         echo "done" >> $1
         echo "hostfile=(\$(cat \$PBS_NODEFILE))" >> $1
         echo "echo \"Job run on \${hostfile[0]} at $SCRATCH_BASE_DIR/\$\$\"" >> $1
      else
         echo "mkdir $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ -z "$PBS_JOB_ARRAY_RANGE" ]
         then
            echo "ln -s $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
      fi
      if [ -z "$PBS_JOB_ARRAY_RANGE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
         then
            echo "rsync --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS --exclude $JOBNAME.pbs . $SCRATCH_BASE_DIR/\$\$" >> $1
         else
            echo "rsync --exclude $2 --exclude $JOBNAME.pbs . $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
         echo "cd $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ "$EXE_NAME" == "vasp" ]
         then
            echo "ln -s \$PBS_O_WORKDIR/INCAR && ln -s \$PBS_O_WORKDIR/KPOINTS && ln -s \$PBS_O_WORKDIR/POSCAR && ln -s \$PBS_O_WORKDIR/POTCAR" >> $1
         else
            echo "ln -s \$PBS_O_WORKDIR/$2" >> $1
         fi
      fi
   else
      echo "export TMPDIR=/tmp" >> $1
   fi
}

function slurm_setup_run_in_scratch {
   if [ -n "$SCRATCH_TYPE" ]
   then
      echo "export TMPDIR=$SCRATCH_BASE_DIR/\$\$" >> $1
      if [ $SCRATCH_TYPE != "scratch" ]
      then
         echo "for host in \`uniq \$SLURM_NODEFILE\`" >> $1
         echo "do" >> $1
         echo "ssh \$host mkdir $SCRATCH_BASE_DIR/\$\$" >> $1
         echo "done" >> $1
         echo "hostfile=(\$(cat \$SLURM_NODEFILE))" >> $1
         echo "echo \"Job run on \${hostfile[0]} at $SCRATCH_BASE_DIR/\$\$\"" >> $1
      else
         echo "mkdir $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ -z "$JOB_ARRAY_RANGE" ]
         then
            echo "ln -s $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
      fi
      if [ -z "$JOB_ARRAY_RANGE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
         then
            echo "rsync --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS --exclude $JOBNAME.sbatch . $SCRATCH_BASE_DIR/\$\$" >> $1
         else
            echo "rsync --exclude $2 --exclude $JOBNAME.sbatch . $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
         echo "cd $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ "$EXE_NAME" == "vasp" ]
         then
            echo "ln -s \$SLURM_SUBMIT_DIR/INCAR && ln -s \$SLURM_SUBMIT_DIR/KPOINTS && ln -s \$SLURM_SUBMIT_DIR/POSCAR && ln -s \$SLURM_SUBMIT_DIR/POTCAR" >> $1
         else
            echo "ln -s \$SLURM_SUBMIT_DIR/$2" >> $1
         fi
      fi
   else
      echo "export TMPDIR=/tmp" >> $1
   fi
}

function setup_jobarray {
   if [ -n "$PBS_JOB_ARRAY_RANGE" ]
   then
      echo "OLDIFS=\$IFS" >> $1
      echo "IFS=\$'\n'" >> $1
      echo "job_array_file=(\$(cat $PBS_JOB_ARRAY_FILENAME))" >> $1
      echo "IFS=\$OLDIFS" >> $1
      echo "job_array_file_line=( \${job_array_file[\$PBS_ARRAY_INDEX]} )" >> $1
      if [ "$EXE_NAME" == "vasp" ]
      then
         echo "dir_path=\$job_array_file_line" >> $1
      else
         echo "dir_path=\$(dirname \$job_array_file_line)" >> $1
         echo "input_name=\$(basename \$job_array_file_line)" >> $1
      fi
      if [ "$EXE_NAME" == "abaqus" ]
      then
         echo "if [[ \$input_name =~ .*\.inp ]]" >> $1
	 echo "then" >> $1
	 echo "   input_name=\$input_name" >> $1
	 echo "else" >> $1
	 echo "   input_name=\$input_name\".inp\"" >> $1
	 echo "fi" >> $1
      fi
      if [ "$EXE_NAME" == "starccm+" ]
      then
         echo "if [[ \$input_name =~ .*\.sim ]]" >> $1
	 echo "then" >> $1
	 echo "   input_name=\$input_name" >> $1
	 echo "else" >> $1
	 echo "   input_name=\$input_name\".sim\"" >> $1
	 echo "fi" >> $1
      fi
      echo "cd \$dir_path" >> $1
      if [ "$NAME" == "mc21" ]
      then
         echo "ln -sf $ND_LIBRARY_FULLPATH ND_LIBRARY" >> $1
      fi
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS --exclude $JOBNAME.pbs . $SCRATCH_BASE_DIR/\$\$" >> $1
	 else
            echo "rsync --exclude \$input_name --exclude $JOBNAME.pbs . $SCRATCH_BASE_DIR/\$\$" >> $1
	 fi
         if [ $SCRATCH_TYPE == "scratch" ]
         then
            echo "ln -s $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
         echo "cd $SCRATCH_BASE_DIR/\$\$" >> $1
	 if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "ln -s \$dir_path/INCAR" >> $1
            echo "ln -s \$dir_path/KPOINTS" >> $1
            echo "ln -s \$dir_path/POSCAR" >> $1
            echo "ln -s \$dir_path/POTCAR" >> $1
	 else
            echo "ln -s \$dir_path/\$input_name" >> $1
	 fi
      fi
      echo "JA_JOB_NUM=\${JOB_NUM%[*}" >> $1
      echo "ln -s $HOME/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX \$dir_path/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX" >> $1
   fi
}

function slurm_setup_jobarray {
   if [ -n "$JOB_ARRAY_RANGE" ]
   then
      echo "OLDIFS=\$IFS" >> $1
      echo "IFS=\$'\n'" >> $1
      echo "job_array_file=(\$(cat $JOB_ARRAY_FILENAME))" >> $1
      echo "IFS=\$OLDIFS" >> $1
      echo "job_array_file_line=( \${job_array_file[\$SLURM_ARRAY_TASK_ID]} )" >> $1
      if [ "$EXE_NAME" == "vasp" ]
      then
         echo "dir_path=\$job_array_file_line" >> $1
      else
         echo "dir_path=\$(dirname \$job_array_file_line)" >> $1
         echo "input_name=\$(basename \$job_array_file_line)" >> $1
      fi
      if [ "$EXE_NAME" == "abaqus" ]
      then
         echo "if [[ \$input_name =~ .*\.inp ]]" >> $1
	 echo "then" >> $1
	 echo "   input_name=\$input_name" >> $1
	 echo "else" >> $1
	 echo "   input_name=\$input_name\".inp\"" >> $1
	 echo "fi" >> $1
      fi
      if [ "$EXE_NAME" == "starccm+" ]
      then
         echo "if [[ \$input_name =~ .*\.sim ]]" >> $1
	 echo "then" >> $1
	 echo "   input_name=\$input_name" >> $1
	 echo "else" >> $1
	 echo "   input_name=\$input_name\".sim\"" >> $1
	 echo "fi" >> $1
      fi
      echo "cd \$dir_path" >> $1
      if [ "$NAME" == "mc21" ]
      then
         echo "ln -sf $ND_LIBRARY_FULLPATH ND_LIBRARY" >> $1
      fi
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS --exclude $JOBNAME.sbatch . $SCRATCH_BASE_DIR/\$\$" >> $1
	 else
            echo "rsync --exclude \$input_name --exclude $JOBNAME.sbatch . $SCRATCH_BASE_DIR/\$\$" >> $1
	 fi
         if [ $SCRATCH_TYPE == "scratch" ]
         then
            echo "ln -s $SCRATCH_BASE_DIR/\$\$" >> $1
         fi
         echo "cd $SCRATCH_BASE_DIR/\$\$" >> $1
	 if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "ln -s \$dir_path/INCAR" >> $1
            echo "ln -s \$dir_path/KPOINTS" >> $1
            echo "ln -s \$dir_path/POSCAR" >> $1
            echo "ln -s \$dir_path/POTCAR" >> $1
	 else
            echo "ln -s \$dir_path/\$input_name" >> $1
	 fi
      fi
#      echo "JA_JOB_NUM=\${JOB_NUM%[*}" >> $1
#      echo "ln -s $HOME/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX \$dir_path/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX" >> $1
   fi
}

function finish_jobarray_and_scratch {
   if [ -n "$PBS_JOB_ARRAY_RANGE" ]
   then
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync -a --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS . \$dir_path" >> $1
	 else
            echo "rsync -a --exclude \$input_name . \$dir_path" >> $1
	 fi
      fi
      echo "rm \$dir_path/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX" >> $1
      echo "mv \$HOME/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX \$dir_path/\$PBS_JOBNAME.o\$JA_JOB_NUM.\$PBS_ARRAY_INDEX" >> $1
   else
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync -a --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS . \$PBS_O_WORKDIR" >> $1
	 else
            echo "rsync -a --exclude $INPUT . \$PBS_O_WORKDIR" >> $1
         fi
      fi
      echo "#" >> $1
      echo "if [ \$PBS_O_WORKDIR != \$HOME ]" >> $1
      echo "then" >> $1
      echo "rm \$PBS_O_WORKDIR/\$PBS_JOBNAME.o\$JOB_NUM" >> $1
      echo "mv \$HOME/\$PBS_JOBNAME.o\$JOB_NUM \$PBS_O_WORKDIR/\$PBS_JOBNAME.o\$JOB_NUM" >> $1
      echo "fi" >> $1
   fi
   if [ -n "$SCRATCH_TYPE" ]
   then
      if [ $SCRATCH_TYPE != "scratch" ]
      then
         echo "for host in \`uniq \$PBS_NODEFILE\`" >> $1
         echo "do" >> $1
         echo "ssh \$host rm -R $SCRATCH_BASE_DIR/\$\$" >> $1
         echo "done" >> $1
      else
         echo "rm -R $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ -n "$PBS_JOB_ARRAY_RANGE" ]
         then
            echo "rm \$dir_path/\$\$" >> $1
         else
            echo "rm \$PBS_O_WORKDIR/\$\$" >> $1
         fi
      fi
   fi
}

function slurm_finish_jobarray_and_scratch {
   if [ -n "$JOB_ARRAY_RANGE" ]
   then
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync -a --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS . \$dir_path" >> $1
	 else
            echo "rsync -a --exclude \$input_name . \$dir_path" >> $1
	 fi
      fi
   else
      if [ -n "$SCRATCH_TYPE" ]
      then
         if [ "$EXE_NAME" == "vasp" ]
	 then
            echo "rsync -a --exclude INCAR --exclude POTCAR --exclude POSCAR --exclude KPOINTS . \$SLURM_SUBMIT_DIR" >> $1
	 else
            echo "rsync -a --exclude $INPUT . \$SLURM_SUBMIT_DIR" >> $1
         fi
      fi
      echo "#" >> $1
#      echo "if [ \$PBS_O_WORKDIR != \$HOME ]" >> $1
#      echo "then" >> $1
#      echo "rm \$PBS_O_WORKDIR/\$PBS_JOBNAME.o\$JOB_NUM" >> $1
#      echo "mv \$HOME/\$PBS_JOBNAME.o\$JOB_NUM \$PBS_O_WORKDIR/\$PBS_JOBNAME.o\$JOB_NUM" >> $1
#      echo "fi" >> $1
   fi
   if [ -n "$SCRATCH_TYPE" ]
   then
      if [ $SCRATCH_TYPE != "scratch" ]
      then
         echo "for host in \`uniq \$SLURM_NODEFILE\`" >> $1
         echo "do" >> $1
         echo "ssh \$host rm -R $SCRATCH_BASE_DIR/\$\$" >> $1
         echo "done" >> $1
      else
         echo "rm -R $SCRATCH_BASE_DIR/\$\$" >> $1
         if [ -n "$JOB_ARRAY_RANGE" ]
         then
            echo "rm \$dir_path/\$\$" >> $1
         else
            echo "rm \$SLURM_SUBMIT_DIR/\$\$" >> $1
         fi
      fi
   fi
}

function calc_chunk_new {
  if [ -z $MPI_PER_NODE_SET ]
  then
     if [ $XTRA_MEM -eq 1 ]
     then
        MPIPROCS=$(($MPIPROCS - 1))
     fi
     NNODES=$MPIPROCS
     RPROCS1=1
     NCPUS=1
  else
     if [ $CPU_TYPE == "broadwell" ]
     then
        CORES_PER_NODE=36
        if [ -z $MPI_PER_NODE_SET ]
        then
           MPI_PER_NODE=$CORES_PER_NODE
        fi
     fi
     if [ $XTRA_MEM -eq 1 ]
     then
        MPIPROCS=$(($MPIPROCS - 1))
     fi
#     TOTAL_PROCS=$(($MPIPROCS * $OMPTHREADS))
     TOTAL_PROCS=$MPIPROCS
#     echo "TOTAL_PROCS = $TOTAL_PROCS"
     NNODES=`expr $TOTAL_PROCS / $MPI_PER_NODE`
     DIV_BY_CORES_PER_NODE=`expr $TOTAL_PROCS % $CORES_PER_NODE`
     MOD_BY_MPI_PER_NODE=`expr $TOTAL_PROCS % $MPI_PER_NODE`
     STR1=""
     STR2=""
#  if [ $DIV_BY_CORES_PER_NODE -ne 0 ]
#  then
#    STR1="Warning: You have requested $TOTAL_PROCS mpi processes, it would be more efficient to"
#    STR2="         request mpi processes in multiples of $CORES_PER_NODE."
##    echo "Warning: You have requested $1 mpi processes, it would be more efficient (on Fission) to"
##    echo "         request mpi processes in multiples of 32."
#  fi
     if [ $TOTAL_PROCS -le $CORES_PER_NODE -a $MPI_PER_NODE -eq $CORES_PER_NODE ]
     then
        NNODES=1
        RPROCS1=$MPIPROCS
     elif [ $MOD_BY_MPI_PER_NODE -eq 0 ]
     then
        RPROCS1=`expr $MPIPROCS / $NNODES`
     else
        RPROCS1=$MPI_PER_NODE
        TMP2=$(($RPROCS1 * $NNODES))
        RPROCS2=`expr $MPIPROCS - $TMP2`
     fi
     NCPUS=$CORES_PER_NODE
     fi
#  echo "NNODES = $NNODES RPROCS1 = $RPROCS1  RPROCS2 = $RPROCS2"
#  echo "MOD_BY_MPI_PER_NODE = $MOD_BY_MPI_PER_NODE"
}

function get_ramdisk_size {
   if [ $CLUSTER == "falcon" ]
   then
      RAMDISK_SIZE=100
   elif [ $CLUSTER == "fission" ]
   then
      RAMDISK_SIZE=48
   elif [ $CLUSTER == "bechler" ]
   then
      RAMDISK_SIZE=12
   fi
}

function get_localdisk_size {
   if [ $CLUSTER == "bechler" ]
   then
      LOCALDISK_SIZE=250
   elif [ $CLUSTER == "quark" ]
   then
      LOCALDISK_SIZE=100
   else
      echo "Error: localdisk not available on $CLUSTER"
      exit 1
   fi
}

function get_scratch_dir {
   if [ $1 == "scratch" ]
   then
      SCRATCH_BASE_DIR="/scratch/$LOGNAME"
   elif [ $1 == "ramdisk" ]
   then
      if [ $CLUSTER == "bechler" ]
      then
         SCRATCH_BASE_DIR="/dev/shm"
      else
         SCRATCH_BASE_DIR="/tmp"
      fi
      get_ramdisk_size
      echo
      echo "Warning: You have requested to run your job in ramdisk."
      echo "Warning: $CLUSTER has $RAMDISK_SIZE GB of ramdisk space available on each Compute Node."
      echo "Warning: Make sure your job (temporary files, resulting/output files etc) can fit in this space or else the node will go down and your job will crash."
      echo
   elif [ $1 == "localdisk" ]
   then
      if [ $CLUSTER == "bechler" ]
      then
         SCRATCH_BASE_DIR="/tmp"
      else
         echo "Error: localdisk not available on $CLUSTER"
         exit 1
      fi
      get_localdisk_size
      echo
      echo "Warning: You have requested to run your job in localdisk."
      echo "Warning: $CLUSTER has $LOCALDISK_SIZE GB of ramdisk space available on each Compute Node."
      echo "Warning: Make sure your job (temporary files, resulting/output files etc) can fit in this space or else the node may go down and your job will crash."
      echo
   fi
}


#/bin/sh

HASH=`git rev-parse HEAD`

cat > githash.f90 <<EOF
module gitstuff

  implicit none

   integer :: HASHLEN=${#HASH}

contains

  function githash() result (hash)
    implicit none

    character (len=HASHLEN) :: hash
    hash = "${HASH}"

    return
  end function githash
end module gitstuff
EOF


<filename>hack/upload-release-assets.sh
#!/bin/sh

set -eu
set -o pipefail

if ! test -f VERSION; then
	echo "Error: VERSION file not found" >&2
fi

TARGET_VERSION="v$(cat VERSION)"

echo "*** extracting release assets for $TARGET_VERSION"

TEMP_DIR=$(mktemp -d /tmp/argocd-image-updater.${TARGET_VERSION}.XXXXXXX)
TARGET_BIN=argocd-image-updater_${TARGET_VERSION}_linux-amd64

cid=$(docker create argoprojlabs/argocd-image-updater:${TARGET_VERSION})
docker cp $cid:/usr/local/bin/argocd-image-updater ${TEMP_DIR}/${TARGET_BIN}
docker rm -v ${cid}

echo "*** uploading release assets"
echo "***    ${TARGET_BIN}"
gh release upload ${TARGET_VERSION} ${TEMP_DIR}/${TARGET_BIN}

echo "*** deleting temp directory"
rm -rf "${TEMP_DIR}"


<gh_stars>1-10
#!/usr/bin/env sh

set -e

yarn build

cd docs/.vuepress/dist

echo 'shirleyliuchn.github.io' > README.md

git init
git add -A
git commit -m 'deploy'

git push -f https://github.com/shirleyliuchn/shirleyliuchn.github.io.git master

cd -


#!/bin/sh

#	Do not modify this script, modify the source tree copy:
#	src/utils/decipher/checkDecipher.sh
#	This script is used via a cron job and kept in $HOME/bin/scripts/

# set EMAIL here for notification list
EMAIL="<EMAIL>"
# set DEBUG_EMAIL here for notification of potential errors in the process
DEBUG_EMAIL="<EMAIL>"

#	cron jobs need to ensure this is true
umask 002

WORKDIR="/hive/groups/gsid/medical/fan/decipher/auto"
export WORKDIR

#	this is where we are going to work
if [ ! -d "${WORKDIR}" ]; then
    echo "ERROR in DECIPHER release watch, Can not find the directory:
    ${WORKDIR}" \
	| mail -s "ERROR: DECIPHER watch" ${DEBUG_EMAIL}
    exit 255
fi

cd "${WORKDIR}"

ftppass=`cat ftp.pwd`
gpgpass=`cat gpg.pwd`

#	create ftp response script for the ftp connection session
rm -f ftp.decipher.rsp
echo "user ftp-decipher-dda ${ftppass}
cd pub
ls
bye" > ftp.decipher.rsp

#	reorganize results files
rm -f prev.release.list
rm -f ls.check
cp -p release.list prev.release.list
rm -f release.list

#	connect and list a directory, result to file: ls.check
ftp -n -v -i ftp.sanger.ac.uk  < ftp.decipher.rsp > ls.check

#	fetch the release directory names from the ls.check result file
grep "decipher_" ls.check | sort > release.list
chmod o+w release.list

#	verify we are getting a proper list
WC=`cat release.list | wc -l`
if [ "${WC}" -lt 1 ]; then
    echo "potential error in DECIPHER release watch,
check release.list in ${WORKDIR}" \
	| mail -s "ERROR: DECIPHER watch" ${DEBUG_EMAIL}
    exit 255
fi

#	see if anything is changing, if so, email notify, download, and build

diff prev.release.list release.list  >release.diff
WC=`cat release.diff | wc -l`
if [ "${WC}" -gt 1 ]; then
    echo -e "New DECIPHER update noted at:\n" \
"ftp://ftp.sanger.ac.uk/pub/\n"`comm -13 prev.release.list release.list`"/" \
    | mail -s "DECIPHER update watch" ${EMAIL}

FN=`cat release.diff |grep decipher_|sed -e 's/decipher_/\tdecipher_/'|cut -f 2`

today=`date +%F`
mkdir -p $today
cd $today

echo "${FN}" >j.fn.gpg
cat j.fn.gpg |sed -e 's/.gpg//' >j.fn.txt

# prepare ftp download response file
rm -f ftp.decipher.rsp
echo "user ftp-decipher-dda ${ftppass}
cd pub
get "${FN}"
bye" > ftp.decipher.rsp

# download the new data file
ftp -n -v -i ftp.sanger.ac.uk  < ftp.decipher.rsp > ftp.log

rm -f `cat j.fn.txt`

# unpack the gpg encrypted file
gpg --passphrase "${gpgpass}"  "${FN}"

# build the new DECIPHER track tables
../buildDecipher `cat j.fn.txt`

rm j.fn.txt
rm j.fn.gpg
fi


<reponame>ctkaczyk/ear-update
#!/bin/bash
#==============================================================================
# Copyright 2017 <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#==============================================================================
# This script has been downloaded from:
#   https://github.com/ctkaczyk/ear-update
#==============================================================================

# {
#   "fileName":"ear-update.sh",
#   "description":[
#     "Bash script for manipulating files inside nested zip's (like jar's in ear)"  ],
#   "options":[
#   	{"var":"OPER", 	"letter":"t", "type":"ENUM", "enum":["UPDATE", "ADD", "DELETE", "GET"], "default":"GET", "required":"1", "desc":"operation type", "longDesc": "operation type."},
#     {"var":"EAR", 	"letter":"i", "type":"VAL", "enum":[], "default":"", "required":"2", "desc":"input ear", "longDesc": "path to ear to be manipulated"},
#     {"var":"XPATH",	"letter":"p", "type":"VAL", "enum":[], "default":"", "required":"3", "desc":"path", "longDesc": "path in the ear, e.g.: app-ejb.jar/META-INF/ejb-jar.xml"},
#     {"var":"SEDEXP","letter":"e", "type":"VAL", "enum":[], "default":"", "required":"0", "desc":"sed expresion", "longDesc": "in case of UPDATE, this is sed expression to be applied on file chosen by -p"},
#     {"var":"REGEXP","letter":"r", "type":"VAL", "enum":[], "default":"", "required":"0", "desc":"regexp", "longDesc": "regexp, which finds places in file chosen by -p to be replaced by file contents given by -f"},
#     {"var":"FILE",	"letter":"f", "type":"VAL", "enum":[], "default":"", "required":"0", "desc":"file", "longDesc": "if -p ADD, then this is a path to a file to be added, if -t UPDATE, then this is a path to a file used for replaceing matches of -r regexp"},
#     {"var":"OUTPUT", "letter":"o", "type":"VAL", "enum":[], "default":"", "required":"0", "desc":"output file", "longDesc": "output file name"}
#   ],
#   "examples":[
#   	"$0 -o ADD -i app.ear -p app-ejb.jar/META-INF/ejb-jar.xml -f ejb-jar.xml -vv",
#   	"$0 -o UPDATE -i app.ear -p app-ejb.jar/META-INF/ejb-jar.xml -r '<!-- SOME PLACEHOLDER -->' -f ejb-jar.xml.part -vv"
#   	],
#   "insertFileIntoFile":true,
#   "license":true,
#   "scriptSource":"https://github.com/ctkaczyk/ear-update",
#   "tmpDir":true
# }

#==============================================================================
set -e

usage() {
	echo "" 1>&2
	echo "Bash script for manipulating files inside nested zip's (like jar's in ear)" 1>&2
	echo "" 1>&2
	echo "Usage: $0 -t <UPDATE|ADD|DELETE|GEToperation type> -i <input ear> -p <path> [-e <sed expresion>] [-r <regexp>] [-f <file>] [-o <output file>] " 1>&2
	echo "" 1>&2
	echo "	-t		- operation type." 1>&2
	echo "	-i		- path to ear to be manipulated" 1>&2
	echo "	-p		- path in the ear, e.g.: app-ejb.jar/META-INF/ejb-jar.xml" 1>&2
	echo "	-e		- in case of UPDATE, this is sed expression to be applied on file chosen by -p" 1>&2
	echo "	-r		- regexp, which finds places in file chosen by -p to be replaced by file contents given by -f" 1>&2
	echo "	-f		- if -p ADD, then this is a path to a file to be added, if -t UPDATE, then this is a path to a file used for replaceing matches of -r regexp" 1>&2
	echo "	-o		- output file name" 1>&2
	echo "	-v		- verbose" 1>&2
	echo "	-l		- log file" 1>&2
	echo "" 1>&2
	echo "Examples: " 1>&2
	echo "" 1>&2
	echo "	$0 -o ADD -i app.ear -p app-ejb.jar/META-INF/ejb-jar.xml -f ejb-jar.xml -vv" 1>&2
	echo "" 1>&2
	echo "	$0 -o UPDATE -i app.ear -p app-ejb.jar/META-INF/ejb-jar.xml -r '<!-- SOME PLACEHOLDER -->' -f ejb-jar.xml.part -vv" 1>&2
	echo "" 1>&2
	exit 1
}

function logv () {
	if [[ $_V -gt 0 ]]; then
		if [ -z "$LOGFILE" ]; then
			echo "$_INDENT$@"
		else
			echo "[$(date "+%Y-%m-%d %H:%M:%S")]$_INDENT $@" >> $LOGFILE
		fi
	fi
}

function logvv () {
	if [[ $_V -gt 1 ]]; then
		if [ -z "$LOGFILE" ]; then
			echo "$_INDENT$@"
		else
			echo "[$(date "+%Y-%m-%d %H:%M:%S")]$_INDENT $@" >> $LOGFILE
		fi
	fi
}

function callDomestic {
	logvv $@
	(export _V && export LOGFILE && export _INDENT+="    " && $@)
}

function callExternal {
	logvv $@
	if [ -z "$LOGFILE" ]; then
		$@
	else
		$@ >> $LOGFILE 2>&1
	fi
}

INITIAL_CALL="$@"

#OPTS TO ENV VARIABLES
[[ -z $_V ]] && _V=0
OPER="GET"

while getopts ":vl:t:i:p:e:r:f:o:" ARG; do
	case "$ARG" in
		v)
			_V=$(($_V + 1))
			;;
		l)
			LOGFILE=$(pwd)/$OPTARG
			;;
		t)
			OPER=$OPTARG
			((OPER == "UPDATE" || OPER == "ADD" || OPER == "DELETE" || OPER == "GET")) || usage
			;;
		i)
			EAR=$OPTARG
			;;
		p)
			XPATH=$OPTARG
			;;
		e)
			SEDEXP=$OPTARG
			;;
		r)
			REGEXP=$OPTARG
			;;
		f)
			FILE=$OPTARG
			;;
		o)
			OUTPUT=$OPTARG
			;;
		*)
			usage
			;;
	esac
done
shift $((OPTIND-1))

#PARAMETERS VALIDATION
if [ -z "$OPER" ]; then
	usage
fi
if [ -z "$EAR" ]; then
	usage
fi
if [ -z "$XPATH" ]; then
	usage
fi

#PARAMETERS LOGOUT
logvv "================================================================================"
logvv "$0 $INITIAL_CALL"
logvv "================================================================================"
logvv OPER=$OPER
logvv EAR=$EAR
logvv XPATH=$XPATH
logvv SEDEXP=$SEDEXP
logvv REGEXP=$REGEXP
logvv FILE=$FILE
logvv OUTPUT=$OUTPUT
logvv LOGFILE=$LOGFILE

SCRIPT=$(realpath ${BASH_SOURCE[0]})
SCRIPTPATH=$(dirname $SCRIPT)
logvv SCRIPT=$SCRIPT
logvv SCRIPTPATH=$SCRIPTPATH
logvv "================================================================================"

function insertFileIntoFile {
	logvv "insertFileIntoFile" $@
	TEMPLATE_FILE=$1
	INSERTING_FILE=$2
	_REGEXP="$3"
	OUTPUT_FILE=$4
	logvv TEMPLATE_FILE=$TEMPLATE_FILE
	logvv INSERTING_FILE=$INSERTING_FILE
	logvv _REGEXP=$_REGEXP
	logvv OUTPUT_FILE=$OUTPUT_FILE

	TEMPLATE=$(<$TEMPLATE_FILE)
	INSERTING=$(<$INSERTING_FILE)

	logvv 'echo "${TEMPLATE//$_REGEXP/$INSERTING}" > ' $OUTPUT_FILE
	echo "${TEMPLATE//$_REGEXP/$INSERTING}" > $OUTPUT_FILE
	logvv
}

#Preparing temp directory
TMPDIR=$(mktemp -d)
function cleanup() {
  logvv "Cleaning $TMPDIR"
  test -n "$TMPDIR" && test -d "$TMPDIR" && rm -rf "$TMPDIR"
}

trap 'cleanup; exit 127' INT TERM ERR
#================================== SETUP FINISHED ====================================

if [ ! -z $FILE ]; then
  FILE=$(realpath $FILE)
  FILECONTENTS=$(<$FILE)
fi

#Parsing xpath
XPATH_DELIMITER='###'
XPATH_ELEMS=$(echo $XPATH | sed -e "s/\.\(jar\|war\|zip\|rar\|ear\|JAR\|WAR\|ZIP\|RAR\|EAR\)\//.\1$XPATH_DELIMITER/g" )
XPATH_ELEMS="root.ear$XPATH_DELIMITER$XPATH_ELEMS"
callExternal cp $EAR $TMPDIR/root.ear

logvv "Working in $TMPDIR"
callExternal cd $TMPDIR

function first() {
  echo $(echo $1 | sed -e "s/$XPATH_DELIMITER/\n/g" | head -n 1)
}

function last() {
  echo $(echo $1 | sed -e "s/$XPATH_DELIMITER/\n/g" | tail -n 1)
}

function sublist() {
  FROM=+$(( $2 + 1 ))
  TO="-$3"
  echo $1 | sed -e "s/$XPATH_DELIMITER/\n/g" | tail -n $FROM | head -n $TO
}

#logvv "first"
#first $XPATH_ELEMS
#logvv "last"
#last  $XPATH_ELEMS
#logvv "all"
#sublist "$XPATH_ELEMS" 0 0
#logvv "all but last"
#sublist $XPATH_ELEMS 0 1
#logvv "all but fist"
#sublist $XPATH_ELEMS 1 0
#logvv "all but first and last"
#sublist $XPATH_ELEMS 1 1

XPATH_ELEM_FIRST=$(first $XPATH_ELEMS)
XPATH_ELEM_LAST=$(last $XPATH_ELEMS)

# ===================== EXTRACTING =============================================
logv Extracting
SKIP=0;
if [ $OPER == "ADD" ] || [ $OPER == "DELETE" ]; then SKIP=1; fi
logvv SKIP=$SKIP
unset XPATH_ELEM_PREVIOUS
for XPATH_ELEM in $(sublist "$XPATH_ELEMS" 0 $SKIP); do
  if [ ! -z $XPATH_ELEM_PREVIOUS ]; then
    callExternal unzip -q -d . $XPATH_ELEM_PREVIOUS $XPATH_ELEM
  fi
  XPATH_ELEM_PREVIOUS=$XPATH_ELEM
done

# ======================== UPDATING ============================================
if [ $OPER == "UPDATE" ]; then
  logv "Updating $XPATH_ELEM"
  callExternal cp $XPATH_ELEM $XPATH_ELEM.tmp
  if [ ! -z "$SEDEXP" ]; then
    #REPLACING USING SED EXPRESSION
    logvv "cat $XPATH_ELEM.tmp | sed -e $SEDEXP > $XPATH_ELEM"
    cat $XPATH_ELEM.tmp | sed -e $SEDEXP > $XPATH_ELEM
  else
    #REPLACING USING REGEXP AND FILE CONTENTS
    if [ -z "$REGEXP" ] || [ -z "$FILE" ]; then
      usage
    fi
    insertFileIntoFile $XPATH_ELEM.tmp $FILE "$REGEXP" $XPATH_ELEM
  fi
elif [ $OPER == "ADD" ]; then
  callExternal mkdir -p $(dirname $XPATH_ELEM_LAST)
  callExternal cp $FILE $XPATH_ELEM_LAST
fi
#Deleting file
if [ $OPER == "DELETE" ]; then
  callExternal zip -qd $XPATH_ELEM $XPATH_ELEM_LAST
fi

# ===================== REPACKING ==============================================
if [ $OPER == "UPDATE" ] || [ $OPER == "ADD" ] || [ $OPER == "DELETE" ]; then
  SKIP=0
  [ $OPER == "DELETE" ] && SKIP=1
  logvv SKIP=$SKIP
  unset XPATH_ELEM_PREVIOUS
  for XPATH_ELEM in $(sublist "$XPATH_ELEMS" 0 $SKIP | tac); do
    if [ ! -z $XPATH_ELEM_PREVIOUS ]; then
      callExternal zip -qur $XPATH_ELEM $XPATH_ELEM_PREVIOUS
    fi
    XPATH_ELEM_PREVIOUS=$XPATH_ELEM
  done
fi

# ===================== FINAL RESPONSE =========================================
logvv cd -
cd - > /dev/null
case $OPER in
  UPDATE|ADD|DELETE)
    if [ -z $OUTPUT ]; then
      callExternal cp $TMPDIR/root.ear $EAR
    else
      callExternal cp $TMPDIR/root.ear $OUTPUT
    fi
    ;;
  GET)
    if [ -z $OUTPUT ]; then
      callExternal cp $TMPDIR/$XPATH_ELEM .
    else
      callExternal cp $TMPDIR/$XPATH_ELEM $OUTPUT
    fi
    ;;
  *)
    logv Wrong OPER=$OPER
    exit 127
    ;;
esac

cleanup


<reponame>at0x0ft/VSCode-Remote-Container-Development-Environments<filename>development_base/.devcontainer/generate_docker_compose.sh<gh_stars>0
#!/usr/bin/env sh
set -eu

generate_docker_compose() {
  # ref: https://github.com/ko1nksm/readlinkf/blob/master/readlinkf.sh
  readlinkf() {
    [ "${1:-}" ] || return 1
    max_symlinks=40
    CDPATH='' # to avoid changing to an unexpected directory

    target=$1
    [ -e "${target%/}" ] || target=${1%"${1##*[!/]}"} # trim trailing slashes
    [ -d "${target:-/}" ] && target="$target/"

    cd -P . 2>/dev/null || return 1
    while [ "$max_symlinks" -ge 0 ] && max_symlinks=$((max_symlinks - 1)); do
      if [ ! "$target" = "${target%/*}" ]; then
        case $target in
          /*) cd -P "${target%/*}/" 2>/dev/null || break ;;
          *) cd -P "./${target%/*}" 2>/dev/null || break ;;
        esac
        target=${target##*/}
      fi

      if [ ! -L "$target" ]; then
        target="${PWD%/}${target:+/}${target}"
        printf '%s\n' "${target:-/}"
        return 0
      fi

      # `ls -dl` format: "%s %u %s %s %u %s %s -> %s\n",
      #   <file mode>, <number of links>, <owner name>, <group name>,
      #   <size>, <date and time>, <pathname of link>, <contents of link>
      # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
      link=$(ls -dl -- "$target" 2>/dev/null) || break
      target=${link#*" $target -> "}
    done
    return 1
  }

  local readonly DEVCONTAINER_ROOT=$(dirname $(readlinkf "${0}"))
  local readonly REPOSITORY_ROOT="${DEVCONTAINER_ROOT}/.."
  local readonly ENV_FILE="${REPOSITORY_ROOT}/.env"
  local readonly DEVENV_CONFIG_FILE="${DEVCONTAINER_ROOT}/config"

  local line
  for line in $(cat "${ENV_FILE}"); do
    eval "local readonly ${line}"
  done
  for line in $(cat "${DEVENV_CONFIG_FILE}"); do
    eval "local readonly ${line}"
  done

  local readonly development_docker_compose_template_path=$(readlinkf "${DEVCONTAINER_ROOT}/${DEVELOPMENT_DOCKER_COMPOSE_TEMPLATE_FILE}")
  local readonly development_docker_compose_path=$(readlinkf "${DEVCONTAINER_ROOT}/${DEVELOPMENT_DOCKER_COMPOSE_FILE}")

  # development container preparing
  local readonly development_container_context_absolute_path=$(readlinkf $(dirname "${DEVCONTAINER_ROOT}/${DEVELOPMENT_DOCKER_COMPOSE_FILE}")"/${DEVELOPMENT_BASE_DOCKER_CONTEXT}")

  calculate_relative_path() {
    local readonly origin=$(readlinkf "${1}")
    local readonly destination=$(readlinkf "${2}")

    get_common_parent_path() {
      local path1="${1#/}"
      local path2="${2#/}"
      local result=''
      while true; do
        local dirname1="${path1%%/*}"
        path1="${path1#*/}"
        local dirname2="${path2%%/*}"
        path2="${path2#*/}"
        if [ "${dirname1}" != "${dirname2}" ]; then
          printf "%s" "${result}"
          return 0
        fi
        result="${result}/${dirname1}"
      done
      return 1
    }
    local readonly common_parent_path=$(get_common_parent_path "${origin}" "${destination}")

    get_relative_path_from_common() {
      local readonly path="${1}"
      local readonly common_path="${2}"
      local readonly rest_path=${path##"${common_path}"}
      printf '%s' "${rest_path#?}"
      return 0
    }
    local readonly common_to_origin_relative_path=$(get_relative_path_from_common "${origin}" "${common_parent_path}")
    local readonly common_to_destination_relative_path=$(get_relative_path_from_common "${destination}" "${common_parent_path}")

    calculate_relative_ancestor_path() {
      local path="${1}"
      local result=''
      if [ "${path}" = "" ]; then
        printf '%s' "${result}"
        return 0
      fi

      result='..'
      while [ "${path}" != "${path%/*}" ]; do
        result="${result}/.."
        path="${path%/*}"
      done
      printf '%s' "${result}"
      return 0
    }
    local readonly relative_ancestor_path=$(calculate_relative_ancestor_path "${common_to_origin_relative_path}")

    connect_origin_to_destination_relative_path() {
      local readonly relative_ancestor_path="${1}"
      local readonly relative_descendant_path="${2}"
      if [ "${relative_ancestor_path}" = "" ]; then
        printf '%s' "${relative_descendant_path}"
        return 0
      fi
      printf '%s/%s' "${relative_ancestor_path}" "${relative_descendant_path}"
      return 0
    }
    printf '%s' $(connect_origin_to_destination_relative_path "${relative_ancestor_path}" "${common_to_destination_relative_path}")
    return 0
  }
  local readonly development_container_context_path=$(calculate_relative_path $(dirname "${development_docker_compose_path}") "${development_container_context_absolute_path}")

  # VSCode extensions volume settings
  local readonly vscode_extension_path="/home/${DEVELOPMENT_BASE_CONTAINER_USERNAME}/.vscode-server/extensions"
  local readonly vscode_insider_extension_path="/home/${DEVELOPMENT_BASE_CONTAINER_USERNAME}/.vscode-server-insiders/extensions"

  local readonly prev_IFS="${IFS}"
  IFS='\n'
  while read line; do
    eval "printf '%s\n' \"${line}\""
  done <"${development_docker_compose_template_path}" > "${development_docker_compose_path}"
  IFS="${prev_IFS}"
  return 0
}
generate_docker_compose


#!/bin/bash

echo "Installing the required snaps for testing..."

echo "Will install edgexfoundry (edge)..."

sudo snap install edgexfoundry --edge

echo "Will install edgex-app-service-configurable (stable)..."

sudo snap install edgex-app-service-configurable --edge

echo "Installing the required snaps for testing...Done"


#!/bin/sh
#
# File:   get_cpu_ghz.sh
# Author: t35brown
#
# Created on 6-Aug-2019, 4:25:34 PM
#

#echo "scale=3 ;" `lscpu | grep "CPU max MHz" | cut -d":" -f2 | tr -d " "` "/ 1000" | bc
lscpu | grep "Model name" | cut -d"@" -f2 | tr -d " a-zA-Z"


#!/bin/bash
set -e
# a helper script to run tests in the appropriate directories

if [ "$HOME" == "/home/travis" ]; then
    echo "moving back to build path, and removing checkout in GOPATH"
    echo "this is because nsq uses relative imports, and that precludes building in $GOPATH"
    GITHUB_USER=$(pwd | awk -F/ '{print $(NF-1)}')
    cd ~/builds/$GITHUB_USER/nsq
fi

for dir in nsqd nsqlookupd util/pqueue; do
    echo "testing $dir"
    pushd $dir >/dev/null
    go test -test.v -timeout 15s
    popd >/dev/null
done

pushd nsqd >/dev/null
go build
rm -f *.dat
echo "starting nsqd --data-path=/tmp"
./nsqd --data-path=/tmp >/dev/null 2>&1 &
PID=$!

cleanup() {
    kill -s TERM $PID
}

trap cleanup INT TERM EXIT

popd >/dev/null
pushd nsq >/dev/null
echo "testing nsq"
go test -v -timeout 15s
popd >/dev/null

# no tests, but a build is something

for dir in nsqadmin nsqlookupd examples/nsq_to_file examples/nsq_pubsub examples/nsq_to_http; do
    pushd $dir >/dev/null
    echo "building $dir"
    go build
    popd >/dev/null
done


#!/usr/bin/env bash
cd ${PROJECT_ROOT}
pwd
ls

# db

python sigda/manage.py db init
python sigda/manage.py db migrate -m "auto "
python sigda/manage.py db upgrade heads
while [ $? -ne 0 ]
do
    sleep 10
    python sigda/manage.py db upgrade heads
done

:<<'
# celery
echo "celery -A------------------"

if [ -f 'celerybeat.pid' ]; then
    rm  'celerybeat.pid'
fi

if [ -f 'celerybeat_schedule' ]; then
    rm  'celerybeat_schedule'
fi

celery beat -A hamster.celeryapp.tasks -l debug &
celery -A hamster.celeryapp.tasks worker -l debug &

'